Description
What to build
Give each head commit at most one factory Check re-run throughout a Delivery. After a CI-fix Repair leaves that head unchanged, a successful Check re-run must not reset its allowance when the Repair loop takes another round or reconciles a refused Self-merge. If a later CI watch finds the branch's own checks red on that already-consumed head, end as a Declined CI fix without another CI-fix Repair or Check re-run. A different head keeps its own allowance.
Deepen the Repair loop's private Check re-run decision module so its existing interface owns pending Repair facts and consumed head history for the complete Delivery. Keep CI observation, Inherited failure classification and GitHub attempt reconciliation behind their existing seam.
Acceptance criteria
- One private Check re-run decision module lives for the complete Repair loop, including every call that resumes rounds after a refused Self-merge. It owns both the latest completed CI-fix Repair's head/failures and the set of head commits whose factory Check re-run decision has been consumed. Round-local variables no longer implement this lifetime policy.
- After a successful CI-fix Repair, record the head and failed checks handed to that Repair together. On the next CI assessment, an unchanged head consumes its allowance before delegating to the existing Check re-run implementation. A changed head discards that pending pair and receives an ordinary CI watch. Match full commit IDs, never shortened display text.
- A head's consumed allowance survives a green Check re-run, Inherited failures and a Base fix, upstream moves, repeated calls to rounds, and visits to other heads. Watching that head again remains allowed; finding the branch's own failures on it fails with the existing Declined CI fix cause before another CI-fix Repair or re-run can start. Inherited-only results retain their existing handling.
- The one-time rule applies to the factory's Check re-run decision for a head, not to the number of workflow requests within that decision. Unsupported checks, refused requests, partial request success, attempt replacement, grace periods, disappearing checks, read errors and interruption keep their existing reconciliation and failure behavior. An agent's own requests are not counted as an additional factory decision.
- Every assessment uses the Base branch commit selected by that round's clean merge, including a changed or rewound Base branch; a Base fix continues comparing no Inherited failures. Do not cache a successful CI result or reuse the old comparison commit to avoid a fresh watch.
- A different head may receive its own CI-fix Repair and one Check re-run. A Repair that advances the head still follows ordinary watch behavior. Returning to a previously consumed head never refreshes its allowance. History is private to one Delivery; a separately started Continuation begins with fresh history.
- Preserve the existing Repair and upstream-move budgets, shared counting of Repair kinds, Foreign commit review, pending-merge validation, Policy refusal detection, exact watched-head Self-merge, and Failed run preservation/drafting. A Check re-run consumes neither budget; a later Declined CI fix takes the existing failure path rather than leaving the PR ready as a Policy refusal.
- Permanent behavior tests through the existing Repair loop interface reproduce the second re-run after a refused Self-merge and cover same-head own failures after an inherited-only re-run/Base fix, an upstream-move round with unchanged head, a visit to another head followed by return, and independent allowances for distinct heads. Assert the outcome, relevant head/Base comparison and bounded CI-fix Repair/re-run effects; do not couple tests to private fields or complete incidental call ordering.
- Keep the existing immediate unchanged-Repair, changed-head Repair, newly sampled Base comparison, inherited-only result, impossible/refused re-run, Policy refusal and budget tests. Existing CI, Merge run and Spec run behavior remains green. Remove only private-helper tests made redundant by equivalent interface coverage.
- Clarify the domain glossary's Check re-run and Declined CI fix definitions: the allowance is once per head across one Delivery, including later rounds and refused Self-merge reconciliation; own checks red on a consumed head fail without another CI-fix Repair. Preserve Inherited failure and fresh-head behavior. This Ticket makes the documentation change through its pull request; no new term or ADR is needed.
- Run focused Repair loop, CI and Merge run checks, then the repository's formatting, clippy and full test checks. Keep supported Linux and macOS behavior intact.
Blocked by
None (can start immediately).
Decisions
The design tree is settled in four rounds: lifetime contract and scope → state and seam → transitions and compatibility → tests, documentation and Ticket size. Each frontier was settled before its dependent decisions; nothing requires a human decision.
- Round 1 — own the contract for a complete Delivery. A throwaway regression on the Base branch reproduced two Check re-runs on the same head after a refused Self-merge. The current last-Repair pair also disappears after an inherited-only re-run and Base fix. ADR 0010 already rejects more than one re-run per head, so this fixes demonstrated friction without making a new product choice.
- Round 1 — deepen Check re-run decisions rather than merging all CI behavior. Concentrate lifetime, head/failure pairing and the watch-versus-re-run-versus-decline choice in one private module. The existing CI module already has depth in polling and classification. Moving it would increase scope without improving locality for this defect.
- Round 1 — preserve the existing Delivery and Repair loop interfaces. Delivery callers continue taking a PR to its goal through the same interface. The decision module is private implementation, so no caller learns a history protocol or gains authority to refresh an allowance. Deleting this deeper implementation would spread pending facts and spent-head checks back into ordinary rounds and failed Self-merge reconciliation: it passes the deletion test.
- Round 2 — retain two distinct facts. Keep one optional pending pair for the latest completed CI-fix Repair, plus a set of all consumed full head IDs. The pending pair answers whether the immediately preceding Repair left the head unchanged; the set answers whether a previously consumed head may be retried. A single last-head field loses the second fact when another head is visited.
- Round 2 — use two small private operations. Record a successfully completed CI-fix Repair's head/failures, then assess the current head against the current Base comparison. Assessment owns choosing the watch or Check re-run, consuming the allowance and translating impossible or still-red results to Declined CI fix. The rest of the Repair loop receives ordinary CI outcomes and retains scheduling of Repairs and Base fixes. This gives leverage without an extra public interface or another history check at each re-entry.
- Round 2 — use the existing effect seam and adapters. Production effects already reach CI/GitHub through the Worktree Delivery adapter, while Repair loop tests use its scripted adapter. Those two adapters make the seam real. The history itself is in-process; GitHub is a true external dependency already substituted in tests. Add no new transport interface, runtime dependency or persisted record.
- Round 3 — record pending facts only after the CI-fix Repair succeeds. The snapshot describes the head and failures handed to the session, not a new observation after it. A failed session already ends Delivery. On the next clean CI assessment, consume that pending snapshot; discard it when the head differs because the Repair changed the branch.
- Round 3 — consume the allowance before delegating. Mark the unchanged full head as consumed before the existing re-run operation can send its first workflow request. A refusal or partial request success cannot reopen permission. The current re-run implementation continues deciding how to observe and reconcile those effects.
- Round 3 — decline later own failures without another Repair. Ordinary watches on consumed heads still obtain fresh facts. Green proceeds, and inherited-only red follows the existing Base move/Base fix path. Own red fails with the existing Declined CI fix cause; starting another unchanged CI-fix Repair would recreate the same waste and temporal obligation. Do not infer this decision from the agent's prose or GitHub error text.
- Round 3 — keep history through every re-entry, but only within one Delivery. Ordinary rounds, upstream changes, Base fixes and failed Self-merges share the same owner. New heads get independent allowances, and returning to an old head does not reset it. A later Command or Continuation starts a new Delivery, matching existing recoverability without inventing cross-Command persistence.
- Round 3 — use fresh comparison facts and unchanged budgets. Assessment receives the selected Base commit from the current clean merge; no cached green result or older Base sample substitutes for it. Repair and upstream-move budgets remain owned by the Repair loop, and the Check re-run consumes neither. A later own-red result is a Declined CI fix, while a green round with nothing to fix still produces the existing Policy refusal.
- Round 4 — test through the existing interface. The interface is the test surface: use the same complete take-to-goal path production calls, with the existing scripted adapter to control CI results and merge refusal. Assert success/failure, relevant comparison facts, one factory re-run decision per head and absence of an extra CI-fix Repair. No public test-only history seam is justified.
- Round 4 — verify lifetime and independent-head behavior together. Keep permanent cases for refused Self-merge, inherited-only reconciliation, an unchanged head after an upstream move, revisiting an earlier head, and two distinct heads each receiving their own allowance. Existing CI and Merge run checks cover request reconciliation, real local Git and final PR behavior; they survive because those implementations retain their interfaces.
- Round 4 — clarify established domain language through this Ticket. Check re-run, Declined CI fix, Delivery and Repair loop already exist in the glossary. Clarify their shared lifetime rule during implementation. ADR 0010 supplies the one-time rule, ADR 0008 supplies inherited handling, and ADR 0004 supplies refused Self-merge behavior; none is contradicted or reopened. This private, reversible implementation choice needs no new ADR.
- Round 4 — publish one standalone Ticket. The state owner, call sites and regressions fit one fresh context window; splitting them would temporarily duplicate a single lifetime protocol. The complete slice delivers bounded per-head remediation, behavior tests and the glossary clarification together. It has no parent or blockers, and its sole label is
needs-triageso thirdshift can decide readiness after the review ends.
Coverage check: all 47 open issue titles and bodies were read and checked again before publication; none proposes this deepening of Check re-run lifetime ownership.
Review validation: on Base branch main at 5ec943dcb0c4dfe26aa9f5d98916aa947f48ca42, a throwaway Repair loop-interface regression failed because one head received two factory Check re-runs and two CI-fix Repairs across refused Self-merge reconciliation. A throwaway prototype moved pending Repair facts and a consumed-head set into a private Check re-run decision module owned by the complete Repair loop. All 34 Repair loop tests passed, including five probes covering merge refusal, inherited-only reconciliation, an unchanged head after an upstream move, revisiting a consumed head and independent allowances for distinct heads. All 19 CI module tests, 23 CI integration tests and 22 Merge run integration tests passed: 98 focused tests total. Prototype edits are discarded; permanent implementation, regression coverage and documentation are this Ticket's work.
Architecture review
Strength: Strong · Dependencies: mock (in-process history; existing GitHub and scripted adapters)
Files: src/delivery/repair_loop.rs, src/delivery.rs, src/ci.rs, tests/ci.rs, tests/merge_run.rs, tests/spec_run.rs, CONTEXT.md
Before
flowchart LR
D[Delivery] --> R[Repair loop]
R --> N[Ordinary rounds]
R --> M[Self-merge reconciliation]
N --> C[Check re-run decisions]
M -. restarts .-> N
C --> W[CI watch]
C --> U[Check re-run]
U -. forgets history .-> N
classDef leak stroke:#dc2626,stroke-width:2px;
class M,U leak;
After
flowchart LR
D[Delivery] --> R[Repair loop]
R --> N[Ordinary rounds]
R --> M[Self-merge reconciliation]
N --> C[Check re-run decisions]
M --> N
C --> W[CI watch]
C --> U[Check re-run]
U --> C
R -->|owns lifetime| C
classDef deep stroke-width:3px;
class C deep;
Problem: The Check re-run decision module is shallow on lifetime: its implementation forgets consumed heads, so later rounds leak the once-per-head rule across the seam.
Solution: Deepen Check re-run decisions behind the existing Repair loop interface, retaining Repair facts and consumed heads for the complete Delivery.
Wins
- Depth: lifetime rules stay private
- Locality: one head-history owner
- Leverage: all rounds share decisions
- Existing adapter seam stays real
- Tests cross the existing interface
- One Check re-run per head
Activity