Skip to content

API Reference parrot.flows.dev_loop.sdd_coder.lint

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.flows.dev_loop.sdd_coder.lint

View source

Engine-owned per-task lint pass for coder branches.

Formatting and auto-fixable lint are mechanical, so the engine runs them at the merge boundary instead of spending coder-LLM turns on them: ruff check --fix plus the repo's declared formatter over the task's changed .py files, committed on the attempt branch. What remains is reported, never blocking — correctness findings (LintConfig.error_select) go to the orchestrator to fix, style residue is left for the single full pass in /sdd-done.

The formatter is scoped to the lines the task actually changed (FEAT-702, LintConfig.format_scope): a pre-existing file that is not formatter-clean at its base is never reformatted wholesale under the task's name, so the autofix commit stays a minimal diff.

Attribute LINT_TIMEOUT_S

Type: float

Alias LintConfig

Re-exported from parrot.flows.dev_loop.sdd_coder.models.LintConfig.

Alias LintReport

Re-exported from parrot.flows.dev_loop.sdd_coder.models.LintReport.

Function changed_line_ranges

Line ranges of path in the working tree that differ from diff_base.

changed_line_ranges(cwd: str, diff_base: str, path: str) -> Tuple[Optional[List[Tuple[int, int]]], str]

Parameter Type Default Description
cwd str The attempt sub-worktree.
diff_base str The merge-base commit the task branch is compared against.
path str Repo-relative path of one changed .py file.

Returns: Tuple[Optional[List[Tuple[int, int]]], str] — (ranges, error). ranges is None when the whole file must be formatted: the file has no base version (added by the task) or git failed, in which case error names the failure (empty otherwise).

Function detect_formatter

Resolve the formatter for the repo checked out at cwd.

detect_formatter(cwd: str, configured: str) -> str

Parameter Type Default Description
cwd str Repository (sub-worktree) root.
configured str LintConfig.formatter; anything but "auto" is returned as-is.

Returns: str — "black", "ruff" or "none".

Function parse_unified_hunks

Post-image (start, end) line ranges (1-based, inclusive) of every hunk in a -U0 diff.

Pure deletions (+N,0) are skipped: there is nothing left to format at that position.

parse_unified_hunks(diff_text: str) -> List[Tuple[int, int]]

Parameter Type Default Description
diff_text str Output of git diff -U0 for one file.

Returns: List[Tuple[int, int]] — The ranges in diff order, possibly empty.

Function resolve_bin

Locate name on PATH, falling back to the interpreter's own bin dir.

The MCP server is launched by absolute path (.venv/bin/parrot), so its PATH may not include the venv that ships ruff/black.

resolve_bin(name: str) -> Optional[str]

Parameter Type Default Description
name str Executable name, e.g. "ruff".

Returns: Optional[str] — The absolute executable path, or None when not found.

Alias run_bounded

Re-exported from parrot.flows.dev_loop.procs.run_bounded.

Function run_lint_pass

Auto-fix, format, commit and report lint for the changed .py files of one task branch.

Never raises and never blocks: a missing tool or failed commit is recorded in LintReport.tool_error and the working tree is restored to the committed state.

run_lint_pass(cwd: str, changed: List[str], *, config: LintConfig, commit_message: str, diff_base: Optional[str] = None) -> LintReport

Parameter Type Default Description
cwd str The attempt sub-worktree (its branch is checked out there, tree clean).
changed List[str] Repo-relative paths the branch changed against the feature branch.
config LintConfig Engine lint settings.
commit_message str Message for the autofix commit.
diff_base Optional[str] None Merge-base commit the branch is compared against; enables LintConfig.format_scope == "changed-lines". None formats whole files.

Returns: LintReport — The lint report attached to the task result.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally