Repository navigation
fix(agents): persist terminal cleanup revocation before reset - #146565
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 September 12, 2026, 8:18 PM ET / September 13, 2026, 00:18 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch persists completed subagents’ cleanup revocation before session reset and replaces cached reconciliation reads with scoped reads and cleanup identity fences. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain This remains useful, protected maintainer work that current main does not implement. The previously reported read-failure isolation defect remains unresolved in the pinned head. Priority: P2 Review scores
Verification
How this fits togetherThe subagent registry tracks delegated work, retained results, and delayed cleanup. Gateway session reset must retire old cleanup authority before publishing a replacement session generation. flowchart TD
A[Session reset request] --> B[Gateway reset owner]
B --> C[Validate current session]
C --> D[Persist cleanup revocation]
D --> E[Publish reset generation]
F[Delayed cleanup retry] --> G[Check suppression and session identity]
D --> G
G --> H[Delete original or preserve successor]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +45, Tests +833, Docs +7. Total +885 across 15 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve durable revocation and successor identity fences while deferring unreadable children individually, so healthy siblings continue and failed reads never authorize cleanup. Do we have a high-confidence way to reproduce the issue? Yes, from source: an expired cleanup candidate with malformed persisted session JSON throws during identity capture before healthy recovery candidates run. No execution reproduction was performed in this read-only review. Is this the best way to solve the issue? The durable owner-level revocation is appropriate and its fail-closed tradeoff is documented; the branch is not ready while strict reconciliation read failures can escape across unrelated runs. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 292e1618d9ce. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
24e956f to
f1912fb
Compare
|
Merged via squash.
|
…aw#146565) * fix(agents): reconcile subagents through scoped session owner * fix(agents): persist terminal cleanup revocation before reset
…nts_wait forever - Reject sessions_yield from a Swarm collector turn before any claim source runs, so no durable yield intent is recorded against a child row, and return a diagnostic telling the model to finish the turn so its collected result is recorded for whoever waits on the run. This admission layer only sees turns whose tool factory is given collector context. - Settle a yielded terminal for a run with collect === true as an ordinary ok terminal on both the lifecycle-event path and the agent.wait observer path. A collector is read by an explicit wait and never receives a requester continuation, so a parked collector row has no wake source at all and its waiter blocks until the operator gives up. - Keep a result the collector already captured through structured_output; a collector that captured nothing keeps the existing "structured_output was not called" diagnostic instead of having a valid result overwritten. - Settle as ok rather than a cancellation: a yielded terminal can also look aborted, and any other settlement would reintroduce the false cancellation notice from openclaw#92448. - Leave every non-collector yielded terminal on the shipped markSubagentRunPausedAfterYield path. The documented sub-agent self-yield-for-external-work contract preserved in openclaw#125850 is unchanged; openclaw#141474 carries clawsweeper:needs-product-decision for that arm. - Write no pauseReason on the settle path, so downstream pauseReason === "sessions_yield" guards, openclaw#146248 retention, and the paused-run adoption added by openclaw#146667 are untouched: they select paused rows, which a settled collector never becomes. - Document the collector rule in the sessions_yield and Swarm docs, qualified to demonstrated behavior rather than universal tool hiding: the tool is withheld where collector context reaches the tool factory, such as the embedded runner; a CLI-backed collector turn through the Gateway tool resolver can still be offered it and receive a successful yielded result; and in every case the terminal settle is what resolves the waiter. - Repoint the yielded-continuation reset case added by openclaw#146565 at an ordinary announcing sub-agent fixture, with every assertion unchanged, because a yielded collector is now settled at its terminal and is no longer a continuation to preserve. Add a sibling case pinning that contract: a yielded collector completes with no pauseReason and a frozen collectorCompletion, and sessions.reset then revokes its cleanup as a completed run. - Await the durable cleanup mark of the settled collector in that reset case, not the residual-roots deadline. Its cleanup: "delete" work is dispatched detached and takes 0.5 s to 3.9 s locally depending on whether the SQLite reclamation worker starts cold, so the one-second vi.waitFor inside settleSubagentRegistryPersistenceWork could observe a live registry root under CI load. The guard and every assertion are unchanged. Related: openclaw#141474
Split from #130741. Prerequisite: #146542.
What Problem This Solves
A completed collector can retain a cleanup retry after an earlier deletion failed. Resetting its session between retries could publish a successor that the old cleanup later deletes.
User Impact
Reset durably revokes completed runs' session cleanup before publishing the new session generation. Active and yielded continuations remain eligible, and collector results and task outcomes keep their normal retention.
Why This Change Was Made
The existing lifecycle owner persists its existing suppression flag from the reset owner's synchronous commit guard. Registry hydration and strict persistence failure block reset; a pending completion capture also asks the caller to retry. A later reset failure or Gateway stop cannot restore old cleanup authority, so the original session may remain with cleanup disabled after revocation was saved. This is the accepted fail-closed outcome. Retained kill claims cannot undo revocation.
The reset owner keeps canonical agent/session selection and existing post-wait authority checks. No new schema or persistent field is introduced.
Evidence
Sixteen concrete assertions failed before repair, with five controls passing; all 21 new cases pass afterward. The complete 314 tests across nine files pass, including reset/global aliases, real boundary and archive cases. The normal build, full canonical gate and independent P1 review pass. The reviewed eight-file source remains byte-identical through the patch-identical base refresh.
Write-failure and reopen tests use isolated real SQLite state; they are not an OS-kill crash experiment. The broader real-provider and 500 ms responsiveness work remains tracked in #130741.