Purpose
Design the durable lifecycle for routed and issue-created PR babysitters before routed-PR activation is enabled. PR #223 ships only declarative intake and read-only discovery; ROUTED_PR_BABYSITTER_ACTIVATION_ENABLED remains false.
This is a design record, not implementation-ready work. Do not add a dispatch/readiness label until the lifecycle is reviewed and decomposed.
Governing invariant
Only an active, current-generation babysitter whose durable completion CAS succeeds may emit a completion outcome.
Every provisional, quarantined, stale, cleanup, released, or orphan state must suppress issue advancement. Retry is the sole valid transition from retained/quarantined back to active.
State model
Definitions:
- T: the issue record tracks the babysitter in
record.agents.
- F:
#issueBabysitterClaims holds that agent's claim token/fence.
- R: fleet release has been confirmed.
- E: an exit may be interpreted as successful PR completion and advance the issue to Human Review.
| State |
T |
F |
R |
Reachable today? |
Required completion rule |
| Provisional spawn/adopt |
1 |
0 |
0 |
Yes: from spawn/adopt until persist + markRunning + local fence installation |
E=0 until markRunning succeeds |
| Active current generation |
1 |
1 |
0 |
Yes: normal running state |
E=1 only when the durable completion CAS returns true |
| Claim lost / cleanup in flight |
1 |
0 |
unknown |
Yes: before and during the release await |
E=0, synchronously before the first await |
| Release failed, retained for retry |
1 |
0 |
0 |
Yes |
E=0; only a retry that atomically reclaims and marks running may return it to active |
| Release confirmed, cleanup transient |
1 |
0 |
1 |
Yes |
E=0, then promptly become released/untracked |
| Released/untracked terminal |
0 |
0 |
1 |
Yes; desired terminal state |
E=0 |
| Stale local fence / replaced durable generation |
1 |
stale |
0 |
Yes after takeover until observed |
E=0 unless the durable completion CAS succeeds |
| Fence without record |
0 |
1 |
either |
Yes, but forbidden: retirement does not clear the issue-claim map; resume can retarget the record without retargeting its claim-map key |
E=0; clean up the stale fence |
| Live orphan |
0 |
0 |
0 |
Yes, but forbidden: standalone routed spawn can reach it if markRunning fails and direct release throws before registry installation |
E=0; recover or release explicitly |
Reachable but forbidden states
Fence without record
Retirement does not clear the issue-claim map. Resume can retarget the record without retargeting its claim-map key, leaving a fence that no longer corresponds to the tracked record.
Live orphan
The standalone routed spawn path can successfully create a process, then fail markRunning, then fail the direct release before registry installation. The process is live but absent from both the issue record and local claim fence.
The design must make both states unrepresentable or define synchronous, durable recovery that preserves the governing invariant.
Open P1s subsumed by this design
Neither P1 should be patched independently. They are constraints on one lifecycle.
Design deliverables
- Name every durable and local phase, its allowed transitions, and which transition owns each side effect.
- Define generation/token creation, takeover, renewal, expiry, completion CAS, quarantine, retry, release, retirement, and restart recovery.
- Make issue advancement consume only a successful durable completion outcome from the current generation.
- Specify crash boundaries around spawn,
markRunning, registry installation, local fence installation, release, and exit handling.
- Prove the two forbidden states are either unreachable or durably recoverable.
- Define tests for every row in the state table and for races between expiry/takeover, cleanup/exit, resume/retirement, and spawn/release failure.
- Only after review, decompose implementation work and define the change that may turn routed-PR activation on.
Related
Purpose
Design the durable lifecycle for routed and issue-created PR babysitters before routed-PR activation is enabled. PR #223 ships only declarative intake and read-only discovery;
ROUTED_PR_BABYSITTER_ACTIVATION_ENABLEDremainsfalse.This is a design record, not implementation-ready work. Do not add a dispatch/readiness label until the lifecycle is reviewed and decomposed.
Governing invariant
Only an active, current-generation babysitter whose durable completion CAS succeeds may emit a completion outcome.
Every provisional, quarantined, stale, cleanup, released, or orphan state must suppress issue advancement. Retry is the sole valid transition from retained/quarantined back to active.
State model
Definitions:
record.agents.#issueBabysitterClaimsholds that agent's claim token/fence.markRunning+ local fence installationmarkRunningsucceedsmarkRunningfails and direct release throws before registry installationReachable but forbidden states
Fence without record
Retirement does not clear the issue-claim map. Resume can retarget the record without retargeting its claim-map key, leaving a fence that no longer corresponds to the tracked record.
Live orphan
The standalone routed spawn path can successfully create a process, then fail
markRunning, then fail the direct release before registry installation. The process is live but absent from both the issue record and local claim fence.The design must make both states unrepresentable or define synchronous, durable recovery that preserves the governing invariant.
Open P1s subsumed by this design
Neither P1 should be patched independently. They are constraints on one lifecycle.
Design deliverables
markRunning, registry installation, local fence installation, release, and exit handling.Related