forge-lcdl

Coding task executor (`forge_lcdl.coding`)

Cheap models should work on one bounded patch unit at a time: allowed paths, forbidden paths, acceptance checks, and explicit verification commands. This package plans units, runs a caller-supplied apply function…

Coding task executor (forge_lcdl.coding)

Purpose

Cheap models should work on one bounded patch unit at a time: allowed paths, forbidden paths, acceptance checks, and explicit verification commands. This package plans units, runs a caller-supplied apply function, optionally verifies outcomes, and emits a proof report (Markdown + JSON). It does not call LLMs and does not auto-edit the filesystem; only your apply_fn may write files.

Patch unit

PatchUnit carries:

  • patch_id, goal
  • allowed_files / forbidden_files (path strings; overlap rejected by validate_patch_unit)
  • acceptance_criteria, verification_commands (each entry is an argv tuple for PytestVerifier — same explicit-argv model as VERIFICATION.md)
  • Optional ContextPack, max_files_changed, max_lines_changed

Planner

create_patch_units is deterministic: keywords in the task string add ordered units (pytest / test → tests, contract → contracts, doc / readme → docs), otherwise one generic unit. Default forbidden list denies env / secret-like globs (callers must still enforce in real tools). Optional ContextPack.included_files seed allowed hints.

Execution

execute_patch_unit:

  1. validate_patch_unit
  2. apply_fn(unit) -> ApplyPatchOutcome
  3. Optional post_verify(unit, outcome) returning VerificationResult tuples (for tests/MCP)
  4. Each verification_commands argv run via PytestVerifier unless skip_verification=True
  5. Failures map to PatchUnitResult; first failed verification can attach a RepairInstruction via REPAIR-LOOPS.md helpers

Proof report

proof_report_from_results aggregates PatchUnitResult rows into ProofReport. Use proof_report_to_markdown for human-readable output and proof_report_to_dict for JSON.

Risks

Callers must enforce repo policy (branches, backups, review). verification_commands run subprocesses with caller-supplied argv only.