Repository navigation
refactor: await durable subagent announcement cleanup - #161273
Conversation
Persist ordinary cleanup, retry, delivery and retirement through the existing state worker and staged publication owner. Keep source and run-generation authority current across awaited work before dependent effects. Move descendant checks to the prepared reader, remove the unused synchronous tree-reader chain, and retain real registered completion, deferred delivery and publication-race coverage. Related: #150153
|
🦞👀 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: needs maintainer review before merge. Reviewed September 29, 2026, 2:16 PM ET / 18:16 UTC (Revision 3). ClawSweeper reviewWhat this changesMoves ordinary subagent completion cleanup and descendant checks to awaited SQLite-worker operations, with tests for delivery and lifecycle races. Merge readiness✅ Ready for maintainer review Keep open. Current main still uses synchronous SQLite work in ordinary subagent cleanup, and no verified merged fixing PR supersedes this branch. This review found no concrete blocking defect in the introduced changes. Priority: P2 Review scores
Verification
How this fits togetherThe subagent registry tracks child runs after an agent delegates work. Completion enters its cleanup path, which records durable state and may wake the requester or deliver a result. flowchart LR
A[Child run finishes] --> B[Registry cleanup]
B --> C[SQLite worker]
C --> D{Current source and run?}
D -->|Yes| E[Descendant check]
E --> F[Requester delivery]
D -->|No| G[Stale work stops]
F --> H[Completed state]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +619, Tests +1798, Other +3. Total +2420 across 66 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one worker-backed registry owner for cleanup and descendant reads, with source and run-generation checks before requester effects. Do we have a high-confidence way to reproduce the issue? Yes. Current main still calls synchronous registry persistence and descendant reads, and the PR reports paired registered Stop measurements. This read-only review did not execute the scenario. Is this the best way to solve the issue? Yes. The patch uses the existing SQLite worker and prepared registry reader, with explicit source and generation checks, rather than adding another state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f70c61dba0c1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Persist ordinary cleanup, retry, delivery and retirement through the existing state worker and staged publication owner. Keep source and run-generation authority current across awaited work before dependent effects. Move descendant checks to the prepared reader, remove the unused synchronous tree-reader chain, and retain real registered completion, deferred delivery and publication-race coverage. Related: openclaw#150153
Related: #150153
What Problem This Solves
Ordinary subagent announcement cleanup still performs synchronous registry writes and descendant reads in the Gateway process.
User Impact
Completion, retry, and retirement keep their existing behavior while their registry work moves through the existing SQLite worker. No configuration or storage migration is required.
Why This Change Was Made
Cleanup now awaits acknowledged postimages before releasing reservations, retiring rows, or starting dependent effects. It retains the original source and exact run generation across those waits; unknown writes remain fenced, and a committed write is never rolled back or replayed because host publication lost ownership. Descendant checks consume the existing prepared read owner.
This is a bounded ordinary-cleanup cut. Reset/revocation persistence, unrelated sweeper retirement, and incognito transfer remain separate work.
Evidence
Matched canonical
437572e2baseline and candidate: registered Stop through required runner/cleanup settlement measured 30 → 0 host SQLite API calls across all eight counters. Durable successful completion, one ended hook, and unaffected sibling controls remain checked.The deferred-reader regression fails on canonical source with ten host API calls in the announce-read window. The candidate measures zero in both descendant-read phases, retains the parent while its child is pending, then proves the accepted continuation and one final outward delivery. This is a reader window, not a whole-announcement SQL or latency claim.
Receiving proof includes real worker acknowledgement loss, refusal, source replacement, successor and retirement races; the full lifecycle and registry owners; 98 state/cache/store cases after retiring obsolete synchronous readers; and actual registered spawn/yield continuation. Backends are synthetic where stated by the fixtures; this is not live-provider evidence.
The normal main integration passed 273 receiving cases, including the full registered Stop zero-SQL window and four actual post-plugin wake-acknowledgement races. The current owner stamps the observed hook once after settlement; successor, suppression, and source changes refuse stale publication. Fresh independent review found no actionable P0–P2 issues.
Initial CI exposed two fixture adapters that had not consumed the awaited bookkeeping contract. The existing pressure/recovery/restart assertions now pass (93 cases), as do the scripts type graph and the actual recovery-sweep benchmark. No production fallback or assertion weakening was added.
The original qualified candidate passed core/all 27 selected type graphs, all three dead-export scans, canonical lint/guards, and the production build. The integrated current-main candidate also passes the complete changed check and normal production build. The unchanged model-setup line-count warning remains visible; no cap or ignore has changed.
Latest CI run 36606597680 failed two inherited tooling fixtures on merge
11fcb7a2into main9b2da929. Independent reproduction and exact source parity establish both causes; canonical fixes are release-plan admission and immutable-parent audit fixture. The 86 fail-fast cancellations are incomplete coverage, not passes. Landing uses the explicitly authorized native pre-existing-failure process; current security and review gates remain required. Exact-head ClawSweeper review found no actionable finding.Measured test cost
One worker on the same Linux Testbox, using the canonical
node scripts/run-vitest.mjs <file> --maxWorkers=1runner. Case sums exclude shared hooks; Vitest duration includes its other phases; wall time includes wrapper and worker preparation.subagent-announcement.worker.test.tssubagent-announcement-delivery.worker.test.tssubagent-spawn.production-boundary.test.tssubagent-registry-lifecycle.test.tssubagent-registry.test.tsThe combined reader command passed scoped reads (14 cases, 0.037 s printed sum), liveness (10 cases, 10.156 s), and nested registry tracking (6 cases, 0.273 s; Vitest reports 19.737 s for that file including its hooks). Its two Vitest shards took 57.21 s and 24.83 s; total wall time was 601.790 s including the normal cold E2E-runtime build. That grouped wall time is not a per-file measurement.
The four state/cache/store files passed 98 cases in two Vitest shards (5.36 s and 10.13 s), with 54.028 s grouped wall time. Their changes remove dead-reader cases or migrate postconditions to existing owners.
The spawn-boundary file exceeds 30 seconds because it exercises actual Gateway admission, replacement, cancellation, and owned cleanup; the new case proves an accepted child batch resumes its parent through the registered dispatcher. A mocked policy helper cannot establish that composition. Other fixture-only async adapters are covered by their owning type/runtime graphs.
After normal main integration, a separate macOS receiving run used the same canonical runner with one worker: 273 cases across seven files, 463.81 s grouped wrapper time and 270.21/150.97 s Vitest shard durations. The delivery file now has nine cases with 69.656 s of printed case time, including the four added post-plugin acknowledgement races. Its real registry, session, worker transaction, and publication owners are necessary to establish that the hook cannot invalidate an admitted wake or stamp a successor; a policy mock cannot prove those boundaries. Per-file wall time was not isolated in that grouped run, and these macOS timings are not compared with the earlier Linux timings as a speedup.
The original Linux measurements precede the byte-preserving bookkeeping extraction, which has separate registered import/retirement smokes and a repeated full Stop check. No latency improvement is inferred from API counts. PR CI will provide separate exact-head evidence.