Skip to content

refactor: await durable subagent announcement cleanup - #161273

Merged
steipete merged 2 commits into
mainfrom
codex/subagent-announcement-current-20260929
Sep 29, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/subagent-announcement-current-20260929

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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 437572e2 baseline 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 11fcb7a2 into main 9b2da929. 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=1 runner. Case sums exclude shared hooks; Vitest duration includes its other phases; wall time includes wrapper and worker preparation.

File Cases Printed case sum Vitest duration Wall
subagent-announcement.worker.test.ts 16 27.135 s 32.00 s 61.421 s
subagent-announcement-delivery.worker.test.ts 5 11.134 s 17.32 s 50.000 s
subagent-spawn.production-boundary.test.ts 23 62.476 s 103.83 s 106.151 s
subagent-registry-lifecycle.test.ts 204 28.470 s 39.52 s 80.939 s
subagent-registry.test.ts 115 3.254 s 7.68 s 37.387 s

The 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.

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
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: XL labels Sep 29, 2026
@steipete
steipete marked this pull request as ready for review September 29, 2026 16:14
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 2:16 PM ET / 18:16 UTC (Revision 3).

ClawSweeper review

What this changes

Moves 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
Reviewed head: 1bd5a6fb0ece0429b76084fd17d61b8bbe5dee5e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Scoped worker-boundary evidence and substantial race coverage support the patch, with no concrete blocking finding found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR reports paired registered Stop measurements, and its tests exercise the production registry with a real SQLite-worker client under lost acknowledgement, successor, revocation, and source-change scenarios; requester turns use synthetic backends. No stored-data format changes were found.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports paired registered Stop measurements, and its tests exercise the production registry with a real SQLite-worker client under lost acknowledgement, successor, revocation, and source-change scenarios; requester turns use synthetic backends. No stored-data format changes were found.
Evidence reviewed 10 items Current main still has the synchronous path: The fetched main revision matches the pinned base in the central cleanup and reader files; cleanup still calls synchronous persistence and descendant counting.
Introduced worker publication boundary: Cleanup mutations are staged and published through the existing asynchronous registry writer after source and row checks.
Introduced prepared descendant read: The cleanup reader now awaits a prepared run snapshot and checks current authority around consumption.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +619, Tests +1798, Other +3. Total +2420 across 66 files.

View PR surface stats
Area Files Added Removed Net
Source 24 1483 864 +619
Tests 41 2704 906 +1798
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 1 +3
Total 66 4191 1771 +2420

Review metrics

Metric Value Why it matters
Net code growth by role production +622 lines; tests and support +1,798 lines The awaited ownership cut adds production coordination, while boundary coverage accounts for most of the growth.

Technical review

Best 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.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR reports paired registered Stop measurements, and its tests exercise the production registry with a real SQLite-worker client under lost acknowledgement, successor, revocation, and source-change scenarios; requester turns use synthetic backends. No stored-data format changes were found.

Label justifications:

  • P2: This is a bounded Gateway responsiveness improvement to an existing subagent path.
  • merge-risk: 🚨 session-state: Cleanup now publishes durable run state across awaits, where stale publication could affect the wrong run.
  • merge-risk: 🚨 message-delivery: Delivery receipts and requester wakes depend on the new acknowledgement ordering.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports paired registered Stop measurements, and its tests exercise the production registry with a real SQLite-worker client under lost acknowledgement, successor, revocation, and source-change scenarios; requester turns use synthetic backends. No stored-data format changes were found.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports paired registered Stop measurements, and its tests exercise the production registry with a real SQLite-worker client under lost acknowledgement, successor, revocation, and source-change scenarios; requester turns use synthetic backends. No stored-data format changes were found.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Mitchell Etzel: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-29T16:22:47.134Z sha bd06e59 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-29T17:50:49.871Z sha 1bd5a6f :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 29, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 29, 2026
@steipete
steipete merged commit 969ae09 into main Sep 29, 2026
145 of 235 checks passed
@steipete
steipete deleted the codex/subagent-announcement-current-20260929 branch September 29, 2026 18:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant