Repository navigation
fix: keep subagent cleanup and session maintenance responsive - #158251
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: blocked before merge. Reviewed October 2, 2026, 10:55 AM ET / 14:55 UTC (Revision 80). ClawSweeper reviewWhat this changesThis PR moves failed subagent cancellation into Gateway-owned cleanup, separates session-maintenance preparation from archive queues, and repairs failed-worker lease cleanup. Merge readiness⛔ Blocked before merge - 2 items remain The PR remains useful and has no supported blocking correctness finding. The new source-bound update and orderly-shutdown evidence resolves the previous review’s proof request; ordinary CI and landing gates remain authoritative. Priority: P1 Review scores
Verification
How this fits togetherSubagent spawning registers child runs and delivers their results through the Gateway. SQLite maintenance and worker retirement manage the sessions and database leases underneath those runs. flowchart TD
A[Child spawn] --> B[Registry acknowledgement]
B --> C[Current ownership checks]
C --> D[Completion delivery]
B --> E[Gateway cleanup]
F[Session maintenance] --> G[Database executor]
G --> H[Committed session updates]
E --> G
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep cancellation, maintenance preparation, and retirement with their existing lifecycle owners while preserving exact-child authority, committed data, and joined shutdown. Do we have a high-confidence way to reproduce the issue? Yes—the failed-registration retry and SQLite contention paths are concrete in source and have recorded production-boundary fault scenarios; this read-only review did not execute them. Is this the best way to solve the issue? Yes—the branch extends existing execution, registry, and transaction owners rather than introducing competing storage or cleanup policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 918153ea3355. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (79 earlier review cycles; latest 8 shown)
|
Return the existing false completion policy for retired stores before checking live delivery authority. Eligible delivery still requires current authority at the outbound boundary. Route preparation-fixture cleanup through the captured Gateway owner and join accepted handlers before tearing down parent state. Align session-group fixture helpers with the catalog's state directory and classify published inbound maintenance under the existing host broker test project. Verified 60 focused behavior cases, 481 project-ownership checks, three owning type graphs, 13 static checks, and two scoped independent reviews. The prior parent-fork teardown failure did not reproduce in one bounded diagnostic replay; its cause remains unresolved. All temporary diagnostics were removed.
Preserve agent-qualified child-session ownership during watched registration, and keep generation-bound claim validation in the native execution owner. Resolve current-main integration with the fs-safe 0.23 admission contract. Runtime regressions and managed reviews passed; final static checks will run after this merge commit binds their baseline to the integrated main parent.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
What Problem This Solves
Failed subagent registration can leave its caller waiting indefinitely for repeated cancellation attempts. Session maintenance can hold the archive queue while waiting for a database writer, and a failed shared worker can prevent lease cleanup and Gateway shutdown.
User Impact
An uncertain hosted registration reports its error after the first cancellation attempt while its Gateway tracks the remaining cleanup and retains the child's admission capacity. Maintenance prepares metadata through the existing database executor, leaving the archive queue available. Cleanup preserves current ownership, authored data, retention, and joined shutdown. There is no configuration or schema migration. Deployed performance gains remain unverified.
Implementation
The change uses main's immutable, ordered registry mutation owner from #163195 and removes the superseded registration writer and persistence-mode paths. Registration retains committed facts while rechecking caller authority and the original Gateway instance before activation. Completion rechecks registered authority at the final outbound handoff; a retired store's policy query returns false without authorizing delivery. Custody callbacks cannot publish cache notifications into a replacement database generation.
Uncertain registration retains the session and reports its run identifiers. Further cancellation attempts belong to the captured Gateway's existing execution tracker. Database retirement cannot release a live child's admission slot or restore expired abort authority: the exact controller's removal or Gateway shutdown settles that ownership. Provisional rollback, collector ordering, and local embedded cleanup remain joined.
Maintenance prepares outside archive and writer queues, refreshes protection, and rechecks selected rows before commit. The shared-store owner retires failed actors before releasing their original leases; genuine cleanup failures retain custody. Immutable row preparation belongs to the existing memory owner, with all callers migrated and no compatibility re-export. The spawn lifecycle emitter now owns both success and failure hooks.
Validation
Candidate
3fda29d9f1aa5ce44eac52e969c09181b68fc66a, treea96ec746aad9b28f37570407da2d789fc05f7615.The current-main integration preserves fs-safe 0.23 admission and fixes ordinary registration lookup to include its resolved child agent. The existing concurrent raw-owner regression fails before that fix and passes afterward. Five owning type graphs, 85 registry cases, and 146 state cases passed. The remaining group passed 134 cases; two unchanged error-path cases exceeded the 512-byte key limit because of the temporary directory prefix, then passed with a short private state root on identical source. The final claim-binding cleanup and recovery selection passed 45 cases (wrapper times 47.11s, 32.47s, and 60.98s). Three managed integration reviews found no unresolved actionable issues. All 33 selected static checks passed, including core types and all 27 test-type graphs. Exact-head CI failed only on three inherited main fixture/import-inventory jobs; the same failures were reproduced independently on main. Upstream commits
779c5aae5e882da47460e0a49d820b2bd3ee4254andba811fafc1844c0098fc6b3e7032ae57db6b4b51repair those causes. The failed CI result and skipped coverage are retained for native inherited-failure admission.Earlier source-bound proof:
Actual
node scripts/run-vitest.mjs run … --maxWorkers=1wrapper times: retired completion 88.00s, outbound controls 65.37s, preparation authority 106.05s, session groups 96.51s, SDK selection 111.14s, and project ownership 135.20s. These retain the existing real Gateway/worker and public SDK boundaries; current CI timing is pending.The CI parent-fork teardown admission failure remains unexplained. A bounded replay of its original 30-file selector passed all 335 cases with temporary refusal probes, which were removed afterward. That replay used Node 24.21 on macOS; CI used Node 24.19 on Linux, and its exact inter-fork ordering was unavailable. This is not a causal repair or an inherited-failure classification.
Retained limitations
The original cause of an earlier first managed-worktree acceptance failure and an earlier Linux/Node 24.19 audio-only TTS dedupe/teardown failure remains unresolved. The natural worktree-deletion failure lacked its RPC receipt, so the later controlled reproduction does not establish that original trigger. An SDK negative-control attempt lost required coordinates to redaction and remains unqualified. Interrupted resource-monitor attempts remain interrupted; their source and cleanup were reconciled before subsequent work.
Earlier worker-retirement/Gateway-shutdown proof includes 108 Linux cases and native Windows replacement behavior. CI 36956812499 passed at prior head
44ce2fd0a466eb8be193feb67f5c29b6df1ff9fc, including all five native Windows jobs. It is not current-head CI. Earlier local runtime preparation skipped package declaration generation; the final installed-cell candidate includes the completed full declaration build.