Repository navigation
Description
What to build
Give Delivery one module that owns its stage. Today each Delivery step records its stage twice, by hand:
- once in the stage that a Failed run's recovery lines report as
Stopped at:; - once in the Command record stage that
thirdshift statusand the Console show.
The mapping between the two vocabularies is written nowhere. It is spread over about a dozen adapter methods and one partial match in the Repair loop's adapter.
After this change, Delivery's steps and the Repair loop name each stage they enter through their Outside seam, and one exhaustive table maps it to both records. What users see does not change: every Stopped at: line and every Command record stage stays as it is today.
Acceptance criteria
-
A Delivery stage module owns a Delivery
Stageenum with these variants: Implementation, Spec review, Security review, Push, Pull request readiness, Repair loop round, Repair session, CI watch, Base fix, Self-merge. It also owns the tracker that holds the current stage, whichdeliverreads when it fails. -
One exhaustive
matchmaps each variant to its recovery stage and, where there is one, its Command record stage. It reproduces today's pairs exactly:Delivery stage Stopped at:Command record stage Implementation Implementation none (the Session log names it) Spec review Spec review none (the Session log names it) Security review Security review Security review Push Push pull request Pull request readiness Pull request readiness pull request Repair loop round Repair none Repair session Repair Repair CI watch CI watching CI watch Base fix Base fix none Self-merge Self-merge Self-merge -
Entering a stage is one call. It sets the tracker and, when the table names a Command record stage, records it. Recording the same Command record stage twice still collapses into one, as it does today.
-
Delivery's
Outsidegains astagemethod.Route::stepscalls it before the opening session, the Security review, the push and marking the pull request ready. The Repair loop's existingOutside::stagetakes the DeliveryStageinstead of the recovery stage. The loop calls it before:- each round (a Repair loop round);
- each Repair session;
- each push;
- each CI watch and Check re-run;
- the Base fix;
- the Self-merge.
-
The real adapters,
InWorktreeandRunOutside, implementstageonce each, by entering the tracker. None of their other methods sets a stage or calls the Command record's stage recording.RunOutside's partialmatchis gone, and so istake_to_goal's redundant stage set, since the loop's first round sets it. -
The opening's stage comes from one fact on the opening: spec review or implementation. It replaces both the
catch_up_from_origintest for the initial stage and thekind == "spec-review"string comparison. -
After a Security hold, the failure path still reports
Stopped at: Security reviewwithout adding a Command record stage. It does this through a tracker method for that one case, never by entering the stage again. -
Inline tests cover:
- the table, through the module's interface. Entering each stage leaves the expected recovery stage and records the expected Command record stage, or none. Use an in-memory recording adapter at the module's own seam, or the existing in-memory Command record test support, whichever the module's interface makes natural; no new global.
- the Repair loop's
Scripteddouble, which keeps the stages it is given in a list of their own, apart from its call log, so the existing call-sequence assertions stay unchanged. New tests assert the stage in force when a failure happens: a failed merge of the Base branch (Repair loop round), a failed CI watch (CI watch), a failed Repair session (Repair session) and a refused Self-merge (Self-merge). - Delivery's own
Scripteddouble, which records stages the same way. New tests assert the stages of the opening session, the Security review, the push and readiness, plus the Security hold case.
-
Existing integration tests that check
Stopped at:lines or Command record stages pass unchanged. -
docs/code-navigation.md's Delivery row names the Delivery stage module. -
cargo testpasses, andcargo clippyandcargo fmt --checkare clean.
Blocked by
None (can start immediately)
Decisions
- Keep both vocabularies; own the mapping. The
Stopped at:names and the Command record names are user-visible and already shown bythirdshift status, the Console and Failed run endings. Renaming either one is a separate decision, and this is a behaviour-preserving deepening. - Split "Repair" into a Repair loop round and a Repair session. Today one recovery stage,
Repair, means two things: being in a round (merging the Base branch, Foreign commits) and running a Repair session. Only the session reaches the Command record, because the glossary's Repair is a session. Two variants make that difference explicit in the table rather than in which call sites happen to log. - The steps name the stages; the adapters stop. Stage order is a fact of Delivery's steps and the Repair loop, both of which already sit behind an
Outsideseam with aScripteddouble. Announcing stages there puts stage order where it is tested, and the two doubles plus the real adapters make the seam real. Leaving the calls in the adapters would keep them out of every unit test. - Keep the stage recording idempotent and call it on every entry. The Command record already collapses a repeated stage name, so re-entering CI watch on every round records nothing new, exactly as today's repeated calls do.
- The Session log's own stage route stays.
logs::sessionsets the Command record stage from the session kind when a Session log starts. That route serves Architect runs, Security runs and Resumes outside Delivery. Replacing it belongs to a typed session kind, which is out of scope here. That is why Implementation and Spec review record no Command record stage in the table. - A Security hold overrides only the recovery stage. The hold is found after the pull request is ready. Entering Security review again would add a misleading Command record stage after the fact.
- Leave Spec run's own recovery stages alone.
Tickets, and the Spec run'sPushbefore its Spec review, are set outside Delivery, and the recovery stage enum stays shared with them. - Stage recording for Pass kinds (Architecture review, Security audit and the rest) is out of scope. They are not Delivery and record one stage each.
- No
GLOSSARY.mdor ADR change. Delivery stage is an implementation term, like Ticket board, and the change is easy to reverse.
Architecture review
Strength: Strong · Dependencies: in-process
Files: src/delivery.rs, src/delivery/repair_loop.rs, src/recovery.rs, src/logs.rs, src/logs/command_record.rs, docs/code-navigation.md
Before
flowchart LR
Steps[Delivery steps] --> IW[InWorktree adapter]
Loop[Repair loop] --> RO[RunOutside adapter]
IW -.set + log by hand.-> Rec[Recovery stage]
IW -.set + log by hand.-> CR[Command record stage]
RO -.partial match.-> Rec
RO -.partial match.-> CR
classDef leak stroke:#dc2626,stroke-width:2px;
class IW,RO leak
After
flowchart LR
Steps[Delivery steps] -->|stage| DS
Loop[Repair loop] -->|stage| DS
subgraph DS[Delivery stage module]
direction LR
table[one table] --> Rec[Recovery stage]
table --> CR[Command record stage]
end
classDef deep stroke-width:3px;
class DS deep
Problem: every Delivery step records its stage twice, in two vocabularies, by hand across about a dozen adapter methods. Nothing tests the mapping, and the Repair loop's double ignores stages.
Solution: the Delivery stage module owns one stage enum and one table to both records, and the steps announce stages through their Outside seam.
Wins
- Locality: one table, both vocabularies
- Stage order tested through
Outside - Adapters lose twenty stage lines
- "Repair" ambiguity becomes two variants
- Interface shrinks to one
stagecall
Activity