Repository navigation
refactor(subagents): centralize end-of-run decisions - #206454
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. What this changesThis PR centralizes subagent completion, termination, cleanup, and retry decisions while leaving persistence and effect dispatch in their existing adapters. Example: A child publishes “first final” at timestamp 4000, followed by an older receipt at 3999.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored PR open: it makes a coherent ownership cutover, and inspection found no definite introduced bug. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSubagent terminal events and Stop requests enter the registry lifecycle; terminal row plans pass through the existing persistence owner before resource cleanup, hooks, and requester delivery run. flowchart TD
A[Completion observations] --> C[Terminal transition owner]
B[Stop requests] --> C
C --> D[Registry persistence adapters]
D --> E[Committed terminal rows]
E --> F[Resource cleanup and hooks]
E --> G[Requester delivery and settlement]
Technical reviewBest possible solution: Keep one terminal decision owner while preserving existing persistence admission, cancellation reconciliation, and resource-dispatch ordering. Do we have a high-confidence way to reproduce the issue? This is an internal refactor with no claimed user-visible defect to reproduce; source comparison preserves the existing terminal-state contracts. Is this the best way to solve the issue? The extraction provides one decision owner without introducing parallel persistence or dispatch paths, and the additional decision fields serve the stated maintainer-approved cutover. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1da35905e5b7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +129. Total +129 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 27, 2026, 2:31 AM ET / 07:31 UTC. |
54503b9 to
92f6467
Compare
|
Merged via squash.
|
* refactor(subagents): centralize terminal transition decisions * refactor(subagents): simplify cleanup decision booleans * test(subagents): preserve admitted stop after session replacement
What Problem This Solves
Terminal policy is distributed across completion, termination publication, effect dispatch, cleanup bookkeeping, and retries. This cutover gives those adapters one owner for the terminal row and the work owed after publication.
User Impact
No intended behavior change. Result capture, cancellation reconciliation, collector results, cleanup ordering, and requester delivery preserve their existing contracts. No persisted fields, public SDK contracts, or configuration change. One Gateway test is updated to the already accepted admitted-Stop contract.
Why This Change Was Made
The internal transition owner prepares result capture, plans completion and termination, and returns explicit effect, cleanup, and retry decisions. Completion and termination share the outcome writer. The five registry adapters retain persistence, dispatch, and live ownership checks instead of deriving terminal policy again.
Mechanical caller updates
The five registry adapters consume the transition owner. The queued-collector settlement test now acknowledges an admitted Stop after session replacement, retains actual cleanup rejection, compares the full replacement entry, and checks that the original collector terminates without launching or publishing replacement metadata. No announce, requester-custody, or kill implementation files are changed.
Integration and overlap
Rebased onto the merged kill-claim repair from #206405 at
be3c73e2becd42a8cb4bfc4aba2698ce00498a04. The moved termination planner retains its exact kill-claim predicate; the adapter passes the claim through and preserves the acquisition-owned session release rule. The separately merged announce-export cleanup in #206429 is included through the base.PR overlap inventory from the scope search
Other work identified with overlapping scope: #206443, #200231, #199455, #194732, #197335, #136554, #140956, #201774, #191857, #201613, #198689, #198633, #121309, #164366, #203303. Most completion-directory overlaps are outside the edited files.
Evidence
Integration base:
be3c73e2becd42a8cb4bfc4aba2698ce00498a04. Pushed head:1195495e73f208c7fdccdde43096573341834760. Production source is unchanged from the reviewed92f6467aabbf; the final commit changes only the Gateway test.1195495e73f2found no actionable defects. It checked exact kill-claim rejection, acquisition-owned session release, terminal ordering, cleanup, retries, and the Gateway test migration with unchanged neighboring owners and tests supplied as source context. The review did not execute tests.git diff --check. The source-only session-identity ratchet passes against the integration base (1,555 files; 6,191 grandfathered pins).1195495e73f2; all required checks are green. Job 140392766207 passed all three queued-settlement cases (settled, rejected, and session replaced), giving red/green proof for the test-only correction. All remaining CI gates passed as well. The preceding run at92f6467aabbfcompleted: all jobs passed except queued-collector settlement and the aggregate CI gate. The test expected Stop rejection after replacement; it received success, matching the L1 owner’s confirmed admitted-Stop contract. The repair preserves cleanup rejection and strengthens replacement-state assertions. Exact execution of this case onbe3c73e2remains unverified; no inherited-failure exception or baseline-red claim is used. Earlier CI at 54503b9a passed production/test types, core lint, both UI Gateway jobs, and the lifecycle, terminal-effects, completion-runtime, and requester-wake retry suites. That evidence belongs to the previous head.PluginRuntimeCloseRetainedError, caused byNative worker execution owners have not joined:chat-goal-created-authority,chat-goal-created-yield,native-cancellation-authz, andgateway.compaction-hot-reload. The native classifier reports unknown (no matching main job). Identical failure-owner source is not baseline proof. The failure and bounded investigation remain recorded under the test-failure policy; no fix or baseline attribution is claimed.Measurements
Same engine and selectors, complete coverage, no parse failures. The base scan uses native baseline
bd459c651f12; all owned source files are byte-identical to the integration basebe3c73e2becd. The head scan is92f6467aabbf; its production files are identical at1195495e73f2.planTerminalCompletionCCcompleteTerminalEffectsCCcompleteSubagentRunAttemptCCcreateSubagentRegistryCompletionRuntimeCCcompleteCleanupBookkeepingCCpublishTerminationadapter CCThe new termination planner has CC 34 and cleanup planner CC 27. The increase in the completion planner reflects decisions moved in from its consumers. This is an ownership cutover, not a claim that all decision complexity disappeared. The original campaign baseline
f769a88c6a4had 3,281 production SLOC and score 43.34, before the intervening L1 changes.The exact PR production diff before copy detection is 771 additions / 651 deletions, mostly code movement; this does not claim 651 lines of dead code. The mechanical Gateway test repair adds 15 lines and removes 6; no test cases are added or removed.