Skip to content

Plan check before the PR; fix rounds get their own budget, push once, and never fail an open PR; generated files are regenerated - #331

Merged
nambok merged 5 commits into
mainfrom
fix/plan-coverage-and-round-budgets
Oct 27, 2026
Merged

nambok merged 5 commits into
mainfrom
fix/plan-coverage-and-round-budgets

Conversation

@nambok

@nambok nambok commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

In a real run, a complex ticket's plan listed several new files. The first implement pass changed one of them. The proof check listed the rest as "gaps under Open items", and the draft PR opened anyway. CoderHelm's reviewer then asked for changes several times. Each round re-entered implement inside whatever was left of a single 15-minute worker invocation, with no deadline of its own. The last round was killed partway through. The stuck-run sweep then marked the whole run failed, even though its PR was open and CI was green. Nothing recorded what the round had pushed.

A second case: a PR in a web repo changed its CMS schema files but not the types generated from them. When the generator did run, it could fail for a missing public project id, and the run opened the PR without the regenerated types.

This PR makes five changes:

  1. The plan is checked task by task before the first PR opens.
  2. Each fix round gets its own time budget and can be resumed.
  3. Each fix round pushes to the PR exactly once, and partial work never reaches the PR.
  4. An open PR whose last round didn't finish is reported plainly, with Resume.
  5. Generated files are regenerated with the change. A generator that can't run (for example, missing public values) blocks the PR with a plain reason.

Changes

Plan coverage (worker/passes/plan_coverage.rs)

  • Compares the plan's - [ ] path: task checklist with the branch diff, task by task. A task counts as done only when the branch changes its file. The coder's summary doesn't count.
  • Missing tasks get up to 2 implement rounds aimed at exactly those tasks. After that, the run continues in a fresh invocation, bounded. A continuation is told which tasks are left, and it no longer resets its own branch to base. Resetting it was an existing bug that wiped the earlier attempt's commits.
  • If required tasks are still missing, no PR opens. The run stops with a plain status: "Stopped before opening a pull request: N of M planned tasks are not done (…)". The branch is copied to coderhelm-wip/<branch>.
  • Only tasks the plan marks optional may be left out. They appear under Open items with the reason.
  • The proof judge now sees the checklist and has a new point, planned_work. It gets a fix round and is never downgraded to Open items.
  • tasks.md now checks off only the tasks the branch actually did.

Round budgets (common::run_round, worker/passes/round.rs, resume.rs, feedback.rs)

  • CI fix, review fix and feedback rounds each have their own deadline. The deadline is measured from the invocation the round runs in (750s), never from the run's start. The round is recorded on the run as round.
  • If an invocation has less than 7 minutes left, the round is parked. A fresh invocation runs it first.
  • A round that uses its budget with work left continues in the next invocation, up to 3 steps. Transient model errors count as steps.

One push per round

  • A round writes its checkpoint commits to coderhelm-wip/<pr branch>, never to the PR head. A continuing round reuses its own WIP branch.
  • When the round finishes, everything it changed lands on the PR as one commit in the team's commit style (round::land, including removals and renames), and the WIP branch is deleted. This means one CI run per round, and on repos that dismiss stale approvals, one dismissal.
  • If the PR changed the same files meanwhile, nothing lands and the round is reported as unfinished.

Unfinished rounds

  • A round that times out, errors or can't land keeps its WIP branch.
  • The run stays completed with round_incomplete: the reason, the checkpoint commits and files, wip_branch and base_sha.
  • The status reads "Pull request open; the last fix round didn't finish: ", and says the PR is unchanged.
  • Feedback and resume worker errors on a run with an open PR end the same way instead of failed.
  • The stuck-run sweep waits for a round's own deadline. A stuck run with an open PR becomes round_incomplete, never failed.

Generated files (worker/passes/generators.rs, common::codegen_env)

  • Detects the repo's generators, the files each reads and, where known, the files each writes:
    • package scripts named like typegen/codegen/generate/gen:types
    • Sanity typegen config
    • GraphQL codegen config, in YAML or TS
    • OpenAPI client generators
    • Prisma
    • buf
    • "regenerate after changing X" rules in AGENTS.md, CLAUDE.md or CONTRIBUTING
  • Before the PR opens, generators whose inputs the diff touches run in the sandbox, and their output is committed with the change:
    • Package-script generators go through the existing detect_codegen_command (root script or pnpm -r typegen/codegen), once, with the repo's public load_codegen_env.
    • Other generators run their own command.
  • A generator still out of date gets one fix round, then blocks the PR with a plain reason.
  • A generator that fails for missing public values blocks immediately, with no fix round. The reason names exactly which values are missing (read from sanity.cli, sanity.config and codegen configs, plus the failure output, minus what is already set) and where to set them. The run records them as codegen_env_missing.
  • The coder's run_codegen tool falls back to every detected generator.

API and gateway

  • Run.round_incomplete (including wip_branch) and Run.codegen_env_missing are documented in OpenAPI.
  • POST /api/runs/{id}/retry on a run with an unfinished round resumes that round on the same run (resuming), continuing from its WIP branch. It gives one automated-fix slot back.
  • GET and PUT /api/repos/{owner}/{repo}/codegen-env are admin-only (the repos capability). They accept public values only: names and values that look like credentials are refused, with the reason.

The dashboard part is in CoderHelm/coderhelm#242.

Existing-PR paths in run_passes

  • The re-run "existing PR has failing checks or review comments" fix now works like the other fix rounds: it writes to the WIP branch, lands as one commit, keeps partial work off the PR, and uses the run's implement deadline.
  • Not covered here: the ticket-updated-under-an-open-PR path still runs the whole first pipeline (implement, test/security/proof/plan/generator rounds) directly on the PR branch. Routing it through the WIP branch means changing the branch every one of those passes writes to, and landing once before the PR step. That doesn't fit cleanly in this PR, so it is left for a follow-up.

Verification

@nambok
nambok force-pushed the fix/plan-coverage-and-round-budgets branch 2 times, most recently from cce0252 to 123a42c Compare October 27, 2026 17:15
@nambok nambok changed the title Plan check before the first PR; fix rounds get their own budget and never fail an open PR Plan check before the PR; fix rounds get their own budget, push once, and never fail an open PR; generated files are regenerated Oct 27, 2026
…d never fails an open PR

A complex ticket's plan listed several new files. The first implement pass
changed one, the proof check listed the rest as "gaps under Open items" and
the PR opened anyway. CoderHelm's reviewer then asked for changes three
times; each round re-entered implement inside what was left of one worker
invocation, the third was killed mid-way, the stuck-run sweep marked the run
failed while its PR was open and green, and nothing said what the round had
pushed.

Plan coverage (plan_coverage.rs):
- The plan's task checklist is compared with the branch's diff, task by
  task. Missing tasks get up to two implement rounds aimed at exactly them,
  then a continuation in a fresh invocation (bounded); a continuation keeps
  its branch and is told what is left.
- Planned work still missing stops the run before any PR, with a plain
  status naming the tasks; the branch is copied to <branch>-wip so a later
  run's reset can't lose it. Only tasks the plan marks optional may be left
  out, and the PR names them under Open items with the reason.
- The proof judge sees the checklist and reports planned_work; it gets a fix
  round and is never downgraded to Open items.
- tasks.md marks only the tasks the branch did.
- A continuation no longer resets its own branch to base.

Fix rounds (common::run_round, passes/round.rs):
- CI fix, review fix and feedback rounds each run with their own deadline,
  measured from the invocation they run in, recorded on the run as `round`.
  A round with too little of its invocation left is parked and runs first in
  a fresh one; a round that uses its budget with work left continues there
  (up to three steps).
- A round that can't finish leaves the run completed with
  `round_incomplete` (why, the commits it pushed, the files): "Pull request
  open; the last fix round didn't finish: <reason>". Feedback and resume
  errors on a run with an open PR end the same way instead of failed.
- The stuck-run sweep waits for a round's own deadline, and a stuck run
  with an open PR becomes completed with round_incomplete, never failed.

No lost work: every coder write is already its own commit on the branch;
the coder is told to write each task's files as soon as the task is done,
the deadline note asks it to write any finished file before stopping, and
an unfinished round records the commits it pushed.

API: Run.round_incomplete (OpenAPI), and POST /api/runs/{id}/retry resumes
the unfinished round on the same run ("resuming"), giving one automated-fix
slot back.
…block it

A pull request in a web repository changed its CMS schema files but not the
types generated from them; the repository has a type generation script and
the reviewer had to point it out.

generators.rs finds the generators a repository uses and what each reads
and writes: package scripts named like typegen/codegen/generate/gen:types
(mapped to the tool they run), Sanity typegen config, GraphQL codegen config
(YAML or TS: schema, documents, generates), OpenAPI client generators (spec
in, -o out), Prisma, buf/protobuf, and "regenerate after changing X" rules
in AGENTS.md, CLAUDE.md or CONTRIBUTING.

Before the pull request opens (single and multi-repo), each generator whose
inputs the diff touches runs in the sandbox and its output is committed
with the change, in the team's commit style. A generator still out of date
(its known outputs not in the change, or its run failing) gets one fix
round, then stops the run with a plain reason naming the files and the
generator; the work is kept on the WIP branch. The coder's run_codegen tool
falls back to every detected generator when the repo has no codegen script.

Tests use small fixture repos per kind: npm-script typegen with Sanity
config, GraphQL codegen in YAML and in TS through a nested script, OpenAPI,
Prisma, buf and a documented rule.
…them

Builds the generator gate on the worker's existing codegen path: package
script generators run through detect_codegen_command (the root script or
pnpm -r typegen/codegen) once, with the repository's public codegen
environment from load_codegen_env. When a generator fails, the run no longer
goes on to open the PR without regenerated files.

common::codegen_env holds the rules for that environment
(SETTINGS#CODEGEN_ENV#<owner>/<repo>): public values only; names and values
that look like credentials are refused. A failed generator's missing values
are the public names its configs read (sanity.cli/sanity.config/codegen
configs: process.env and import.meta.env) or its output names, less those
set. When any are missing, the run stops before the PR with a plain reason
naming them and where to set them (Settings, Repositories, the repository's
Codegen environment), and keeps them on the run as codegen_env_missing (in
the API's Run, documented in OpenAPI). No fix round: a person sets them.

Gateway: GET/PUT /api/repos/{owner}/{repo}/codegen-env for admins (the
repos capability), validated by the same rules.
Every push to a pull request branch re-runs CI and, on repositories that
dismiss stale approvals, dismisses them. A fix round now pushes to the pull
request exactly once.

- CI fix, review fix and feedback rounds write their checkpoint commits to
  coderhelm-wip/<pr branch>, opened at the PR head when the round starts
  (a continuing round reuses its own).
- When the round is done, everything it changed since it started lands on
  the PR as ONE commit in the team's commit style (round::land: removals
  and renames included), and the WIP branch is deleted. If the PR changed
  the same files meanwhile, nothing lands and the round is left unfinished.
- A round that times out, errors or is cancelled keeps its WIP branch; the
  run records it (round / round_incomplete.wip_branch and base_sha, also
  written by the stuck-run sweep), Resume continues from it, and nothing
  partial reaches the PR. The status note says the PR is unchanged.
- API: RoundIncomplete.wip_branch (OpenAPI). The pre-PR stop copy is now
  coderhelm-wip/<branch> too.
A run that finds its ticket's PR open with failing checks or review
comments fixed them by writing straight to the PR branch, one push per
edit. It now works like the other fix rounds: checkpoints on
coderhelm-wip/<branch>, one commit landed on the PR at the end in the
team's commit style, and a fix that runs out of time or can't land keeps
its work on the WIP branch and never reaches the PR. It also gets the
run's implement deadline instead of none.

Also updates the run_of tests for the trigger lookups argument main added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant