Skip to content

Lockfiles out of sync are repaired by code; a fault inside a fix round has a way around it - #646

Merged
nambok merged 1 commit into
mainfrom
lockfile-repair-resilient-rounds
Nov 12, 2026
Merged

nambok merged 1 commit into
mainfrom
lockfile-repair-resilient-rounds

Conversation

@nambok

@nambok nambok commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

A security update's pull request changed three package.json files (a pnpm workspace root and two npm packages with lockfiles of their own) and none of the lockfiles. Every CI job failed at its frozen install. A person pressed Retry, and the run ended failed ten minutes later with "CI is failing: the pull request's checks; CI is failing: the pull request's checks". The fix an engineer makes takes no thought: run each package manager's lockfile command and commit the result.

What the logs and the code showed:

  1. The retry planned its bumps by rule, then found the open pull request red and went into the model fix loop (run_passes, "existing PR needs fixes"), which returns before the dependency run is ever driven.
  2. The pull request's lockfiles were never written: the earlier run's coder edited the manifests, stalled on a later task, and its pull request was opened by the stopped-run path. In the retry, run_codegen ran the repository's codegen command, whose first step is pnpm install --frozen-lockfile; it failed on the stale lockfile both times. Lockfile generators ran only for security tickets and only after a finished implement step.
  3. Nothing refused a model's write to a lockfile.
  4. The first attempt changed nothing. round::land deletes the work branch when a round changed nothing, and the loop ran the second attempt on that deleted branch: get_diff, edit_file, restore_file and batch_write all returned 404, then landing returned "its changes couldn't be read (404)".
  5. That refusal ended the round as "didn't finish" and completed the run; the completion guard saw red CI and sent the run to its ending with ladder_spent: true hard-coded, so one attempt of three counted as every way spent.
  6. The ending text joined the same sentence to itself, and that sentence named no cause.
  7. fix_decision.planner_failure was set on a plan no planner wrote.

Changes

  • Lockfile repair by code (common::lockfile_sync, generators::repair_lockfiles)
    • Reads a log for the frozen-install errors of npm, pnpm, yarn, bun, cargo, poetry, uv, pipenv, bundler and go.
    • Regenerates every lockfile the branch touches or whose manifest it touches, each with its own manager in its own folder, in one sandbox build. A manager that fails is tried another way (its other mode, then the LTS Node). Each lockfile reports on its own, so one that can't be written never hides the others. Only lockfiles are committed.
    • Runs before any model round, for any ticket, in all three places CI failures are fixed: the run's CI fix round (resume), a re-run that finds its pull request red (run_passes), and the CI rounds on a finished run's pull request (feedback). In the CI fix round it runs before the fix budget and the stall check.
    • The coder's run_codegen writes lockfiles first and is offered whenever there is a sandbox. run_checks regenerates them when its install fails on a stale lockfile.
    • Before a pull request opens, any run that changed a manifest gets its lockfile written (this was a security ticket's alone). Outside a security fix, a lockfile the sandbox can't write is a note, never a hold.
  • No hand edits: write_file, edit_file and batch_write refuse a lockfile in both coders, with the tool that regenerates it.
  • A dependency fix retry rebuilds from its plan (rebuilds_by_plan): the branch goes back to the base branch's files and the verified bumps are committed again. A person's review comments still get their fix round.
  • Faults inside a fix round (round)
    • Every CI fix attempt opens its work branch before it writes.
    • land: a missing work branch is "nothing saved"; a compare GitHub refuses is read from the two trees; a commit GitHub refuses is sent once more on the current head.
    • A fault is classified (fault_of, way_around). The round runs again from a clean work branch while it has attempts and time, then once in a fresh step, and only then is the supervisor's ending asked (after_fault). The CI fix round no longer calls a round unfinished, completes the run or fails it.
    • A round out of its invocations goes to the supervisor's ending (revert to green first) instead of "completed".
  • An attempt that changed nothing is followed by the repairs by code not yet run, then fresh evidence, then the strongest model on the last attempt (ci_fix_effort).
  • Endings: a run about to complete with red checks goes back to its CI fix round first, once (redrive_red_ci). The fix round records what fails (ci_cause), and the ending for red checks says it once (red_ending_text).
  • Planner failure: a plan the rules wrote is not recorded as one (no_decision_reason).
  • Guard: the supervisor's source scan now covers the CI fix round and the re-run on an open pull request: nothing inside them ends the run, the repairs by code come before the model, and only the two endings that revert to green first may fail a run for red checks.

Not changed: when the repairs by code, the three attempts, the fresh step and the revert to green are all spent with checks still red, the run still ends failed with the exact cause. That is the supervisor's existing last rung.

Verification

  • cargo test -p worker: 1,611 passed. cargo test -p common --lib: passed, with 9 new lockfile_sync tests.
  • cargo clippy -p common -p worker --all-targets -- -D warnings and cargo fmt --check --all: clean.
  • New incident case af_lockfiles_out_of_sync (7 tests) on an invented monorepo with a pnpm root and two npm packages:
    • the run's own CI lines are read as lockfile mismatches; the three lockfiles are chosen; the repair build is read by the real sandbox reader and only lockfiles are committed; the pipeline calls the repair before the budget, the stall check and the model;
    • a lockfile its manager can't write is named and the others still land;
    • a dependency fix retry rebuilds from its plan;
    • a model can't write a lockfile, in either coder, through any write tool;
    • each fault class (no work branch, a refused compare, a refused push, a clash, GitHub busy, a sandbox failure, anything else) is injected and the round goes on; with every attempt faulted the round runs again in a fresh step before the supervisor's ending;
    • an attempt that changed nothing changes approach;
    • red checks send the run back to fixing, and the ending names the cause once.
  • Unit tests: every manager's frozen-install line, ordinary failures that are not mismatches, the repair command and its marks, the tree diff, the fault classes.
  • docs/incidents.md has the case's row.

…d has a way around it

A security update's pull request changed three package.json files and
none of their lockfiles, so every CI job failed at its frozen install. A
retry planned its bumps by rule, then handed the red pull request to a
model. The model changed nothing; landing "nothing" removed the round's
work branch, the next attempt wrote to a branch that was gone, the round
was called unfinished, and the run ended failed after one attempt of
three with the same vague sentence twice.

- common::lockfile_sync reads a CI or sandbox log for every package
  manager's frozen-install error, builds the one sandbox command that
  writes each affected lockfile with its own manager (with another mode
  and the LTS Node as fallbacks), and names lockfiles so a model's write
  to one is refused.
- The CI fix round, a re-run on an open pull request and the CI rounds on
  a finished run's pull request regenerate the lockfiles before any model
  round, for any ticket. run_codegen and run_checks do it for the coder.
  Any run that changes a manifest gets its lockfile written before the
  pull request opens.
- A retry of a dependency fix rebuilds its change from its plan instead
  of patching the earlier attempt with a model.
- Every CI fix attempt opens its work branch first. Landing reads a
  missing work branch as nothing saved, reads a refused compare from the
  trees and sends a refused commit once more. A fault inside the round is
  classified and the round runs again from a clean state, then once in a
  fresh step, before the supervisor's ending is asked.
- A run about to complete with red checks goes back to its CI fix round
  first. The ending for red checks names the recorded cause, once.
- A plan the rules wrote is no longer recorded as a planner failure.
@nambok
nambok merged commit 8a2d6b1 into main Nov 12, 2026
10 checks passed
@nambok
nambok deleted the lockfile-repair-resilient-rounds branch November 12, 2026 21:09
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