Repository navigation
fix: keep subagent results owed after a Gateway restart - #200823
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 Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves owed subagent results after ownership changes and lets the registry recover obsolete requester-settle restart markers. Example: The requester agent:main:dashboard:restart-hub restarts with the marker announce:requester-settle:main:retired-cohort:yield-1 and a captured child result.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses two restart handoff failures still present on main, and no introduced correctness defect was identified. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe subagent registry retains child results and completion wakes; Gateway startup restores custody before the lifecycle owner delivers those results to requester sessions. flowchart TD
A[Finished child result] --> B[Persisted subagent registry]
C[Gateway restart] --> D[Fresh requester custody]
B --> D
D --> E[Registry completion wake]
E --> F[Requester conversation]
Technical reviewBest possible solution: Keep recovery in the existing registry owner, preserve successor-owned obligations, and suppress duplicate restart continuations. Do we have a high-confidence way to reproduce the issue? Current-main source exposes both failure paths, and the PR reports red-on-base regressions for native ownership turnover and obsolete-marker startup; this read-only review ran no target code. Is this the best way to solve the issue? The patch is the smallest complete repair found: extend the existing ownership-handoff catch, delete its obsolete failure path, and classify registry-owned restart continuations without exact old cohort matching. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0c19bcdf2939. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -40, Tests +19, Docs 0, Other 0. Total -21 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. Review metrics
LabelsLabel changes:
Label justifications:
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 17, 2026, 6:08 PM ET / 23:08 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Backport #200823 to the temporary beta preparation target. (cherry picked from commit 66273da) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a9614c5480d00481dc132e62b7f217598a2964db)
What Problem This Solves
After a Gateway restart, an idle requester can lose finished subagent results when a restored settle attempt loses ownership. An obsolete requester-settle restart marker can also try to resume under unrecoverable operator authority, even though the registry already retains the continuation.
User Impact
Recovered results remain owed to their current registry owner and reach the requester. Restart clears obsolete settle markers through the existing registry handoff. Real Stop, supersession, restart drain, and operator-authority checks retain their existing behavior; there are no protocol, schema, or configuration changes.
Why This Change Was Made
The native completion owner rejects stale execution/cohort mutations in
subagent-completion-admission.store.ts:333and:608. The lifecycle wake catch treated only the narrower progress-change subclass as a handoff; the parent source-change rejection fell through to failed settlement (subagent-registry-lifecycle-wake.ts:529, fixed). It now yields without failing or writing a rejection notice for work belonging to the current owner, using the existing attempt-local cleanup.The registry's restart classification required the old settle run's exact cohort/retry ID (
subagent-registry-read.ts:213, fixed). Recovery can change that ID while retaining the same requester obligation. Classification now recognizes the registry-owned wake after fresh custody recovery, so the existing startup path clears the marker instead of admitting a competing old operator turn. Recovery remains owned by the registry; the Gateway admission and delivery classifier are unchanged.The observed several-minute spacing cannot be uniquely attributed without the retired rows' deadlines. Existing terminal-descendant delivery grace is five minutes (
subagent-announce.requester-settle-descendants.ts:65-75), retry backoff caps at five minutes (subagent-registry-helpers.ts:41-54), and restored preparation permits two concurrent admissions (subagent-registry-lifecycle.ts:82,410-429). This change leaves those budgets and timers intact.Evidence
The native SQLite/lifecycle regression reopens restored completion state, changes execution ownership, and exercises a coherent overlapping cohort. On the original production code, the refused attempt marks owed delivery failed or tries to settle its successor's cohort. With the fix, both obligations remain pending until the current owner delivers them; already-delivered bookkeeping still survives cleanup.
The real subprocess Gateway regression interrupts a subagent wait during drain, restores an idle requester with an obsolete settle marker whose operator source is unavailable, receives the actual child result, and verifies another restart does not replay that marker. On base it enters principal admission and emits
Queued operator authority cannot be recovered; the fixed case passes without that competing turn.pnpm test src/agents/subagents/completion/subagent-completion-admission.requester-wake.test.ts --maxWorkers=1 -t 'retains restored completion custody': base 2 failed, 1 passed (expected 'failed' to be 'pending'and the native owner rejection), fix 3 passed (34.22s red / 33.06s green wall time). The unfiltered final suite is green: 43 passed, 198.8s wall time including cold compilation, about 59s test time. The existing file proves native commit/reopen, receipt reconciliation, and lifecycle ownership through actual SQLite workers.pnpm test test/gateway-subagent-completion-restart.e2e.test.ts --maxWorkers=1 -t stale-settle-requesteris red on base. The fixed case passed within the full ten-case file run (16.4 seconds test time). Full file wall time was 353.1s including the runtime build; Vitest took 213.2s.announcingandannouncing-crashfailures reproduce with both production files restored to basee1e108c7e4711959b287aff7acab1ac085ea2533: the shutdown checkpoint observes already-consumed delivery instead of pending, and committed public-input replay reportsInput completion retry conflicts with the committed input. They remain investigated failures, not passing proof; the latter's underlying replay defect is unresolved here.pnpm buildpassed (3m42s build phases); targeted core/root typechecks, lint, format, and line ratchets passed.pnpm test src/agents/subagents/ --maxWorkers=2: 2,366 passed, 1 existing skip; 166 files passed and 1 skipped across six shards (1,200.39s wall time).The ownership test covers the native refusal and retained obligation; the subprocess test covers actual drain/recovery delivery. Neither asserts production's exact 35ms abort timing. The added process case needs startup, shutdown, database restore, actual requester delivery, and a second restart; those lifecycle boundaries cannot be proved by an admission helper test alone. Earlier-head CI run 44189485399, attempt 1, reports the same two existing restart cases in
checks-node-changed-3(630 seconds). Its tested merge is1f43d30753f6dcd2a01185ee0b533af2918ce276with baseline807ecef42f00361361abd5e28fdf0fd20332225d. The two local baseline reproductions qualify these failures for native inherited-failure review under the scoped landing instruction; CI remains failed. The fixture adds the new variant, but the original announcing branches and native completion store/replay guard are unchanged. That run also found a PR-caused stale session-identity allowlist count after the deleted failure path (3 actual references became 2); the native prune operation shrank that entry and its ratchet passes. A new push must complete current-head CI. Review, security, and protected-writer checks stay required.Final-head CI 44194338092, attempt 1, completed all 64 jobs: the corrected baseline ratchet and security check pass. Its only independent failure is
checks-node-changed-3(621s), containing exactly the same two baseline restart cases; the new stale-settle-requester case passes in 23.919s. CI tested merge84dabb64361951a9a1ab0333d639ca13f8327a10against baseline93d84036cc7d7f7ead065a1f1eeaa6ef56735ff7. Native inherited-failure evidence retains the actual checkout, both baseline reproductions, unchanged native completion/replay source objects, and the disclosed fixture diff. CI is failed; these two existing defects are not claimed fixed here.