Repository navigation
refactor: await initial requester yield and cohort handoff - #160778
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 29, 2026, 6:56 AM ET / 10:56 UTC (Revision 5). ClawSweeper reviewWhat this changesMoves initial requester yield, child handoff, and cold subagent restoration to awaited SQLite workers while preserving requester identity and recovery. Merge readiness⛔ Blocked before merge - 3 items remain Current main still performs synchronous SQLite work during initial requester yield and registry restoration. This PR addresses that distinct path, and the reviewed changes show no verified blocking code defect. Priority: P2 Review scores
Verification
How this fits togetherThe subagent registry stores child-run state and wakes the requester when children settle. Gateway turns feed it; persisted rows support recovery, and settled results flow back to the requester. flowchart LR
A[Requester turn] --> B[Yield or child completion]
B --> C[Subagent registry]
C --> D{Caller and rows current?}
D -->|Yes| E[SQLite worker handoff]
D -->|No| F[Refuse stale work]
E --> G[Recovery and requester wake]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one registry worker responsible for durable handoff and restoration, with current requester authority at each effect and measured resource bounds for populated registries. Do we have a high-confidence way to reproduce the issue? Yes at the source level: current main calls synchronous persistence during initial yield and a synchronous full-registry load during restoration. The reviewer did not execute a fresh timing reproduction. Is this the best way to solve the issue? Yes: the branch reuses the registry writer and state-read worker while retaining the original requester checks. The remaining validation is the resource cost of the changed path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 92a7977173fb. LabelsLabel changes:
Label 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 (4 earlier review cycles)
|
958e43f to
068615f
Compare
60b235c to
ae6a4e8
Compare
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after #160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after #160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after openclaw#160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
* fix: retain shared-state snapshots through worker failures Keep preparation, query, and cleanup under the existing read owner. Retain native child custody across disposable Worker loss, preserve admitted source identities, and join cleanup before releasing the original directory. Preserve existing schema, retention, SDK, and exact-native backup contracts. * fix: preserve native wrapper imports and callback type contracts * fix(tooling): retain dynamic snapshot cleanup dependencies * fix(test): prepare package contract workers before tests Prepare the Memory Core facade’s compiled worker dependencies through the existing runner owner before Vitest starts. Keep the runtime export assertion and its deadline unchanged. Extend the actual pre-spawn lifecycle cases to cover direct and project-selected contract tests, including exclusions. Validation: causal preparation-order failure, 35 artifact-owner cases, 19 unchanged package-contract cases, changed-file checks, and independent review. * fix(sqlite): retain original snapshot cleanup across reloads Carry the original complete-removal operation into re-imported callers instead of treating it as token retirement followed by another pathname deletion. Preserve both original and current reader fences, native join, and retry against the original cleanup owner. Remove the retired async registration path. Exercise real replacement bytes and target loss, and inject Cron copy/removal failures in the actual workers. Both original regressions fail; the correction passes 35 Node cases, the canonical Bun lifecycle case, types, lint, export checks, and independent reviews. * test(agents): share queued-registration context captures Expose the read-context capture through the same synthetic source owner as the existing writer capture. This lets the uncertain-kill case finish canonical restoration instead of leaving its failed cleanup to contaminate subsequent registration cases. * test(agents): run entry settlement with host broker Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after #160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
Observe gated operation rejections before advancing acknowledgement gates, then directly await every rejects matcher. An earlier setup failure no longer leaves a detached matcher promise. Require the unknown-write outcome in both restoration refusals so an unrelated fixture error cannot satisfy the custody assertion. This completes the changed-lane repair after #160778 alongside main's run-entry broker routing (7e1de91), shared read-context fixture (9e4f201), and logical requester yield authority repair (81547a2). The existing production fixes and all protected test expectations remain. All three reported files fail on 2291fe8 and pass at 437572e~1 on Blacksmith Testbox, Node 24.19.0/Linux. Canonical main a34353a plus this patch passes all 96 tests three times (145.80s, 68.82s, 68.10s), and 1,220 owning-suite cases in 211.49s. The existing opt-in 5,000-session benchmark remains skipped. The 62-case queued registration file takes 23.25s cold, then 10.94s and 9.26s in Vitest. Full check:changed for the final three-file diff passes in 281.28s. Proof: https://github.com/openclaw/openclaw/actions/runs/36587966134
…160778) * fix(agents): await initial requester handoffs through registry worker * fix(agents): keep followup authority in its type contract
Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after openclaw#160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
…160946) * fix: retain shared-state snapshots through worker failures Keep preparation, query, and cleanup under the existing read owner. Retain native child custody across disposable Worker loss, preserve admitted source identities, and join cleanup before releasing the original directory. Preserve existing schema, retention, SDK, and exact-native backup contracts. * fix: preserve native wrapper imports and callback type contracts * fix(tooling): retain dynamic snapshot cleanup dependencies * fix(test): prepare package contract workers before tests Prepare the Memory Core facade’s compiled worker dependencies through the existing runner owner before Vitest starts. Keep the runtime export assertion and its deadline unchanged. Extend the actual pre-spawn lifecycle cases to cover direct and project-selected contract tests, including exclusions. Validation: causal preparation-order failure, 35 artifact-owner cases, 19 unchanged package-contract cases, changed-file checks, and independent review. * fix(sqlite): retain original snapshot cleanup across reloads Carry the original complete-removal operation into re-imported callers instead of treating it as token retirement followed by another pathname deletion. Preserve both original and current reader fences, native join, and retry against the original cleanup owner. Remove the retired async registration path. Exercise real replacement bytes and target loss, and inject Cron copy/removal failures in the actual workers. Both original regressions fail; the correction passes 35 Node cases, the canonical Bun lifecycle case, types, lint, export checks, and independent reviews. * test(agents): share queued-registration context captures Expose the read-context capture through the same synthetic source owner as the existing writer capture. This lets the uncertain-kill case finish canonical restoration instead of leaving its failed cleanup to contaminate subsequent registration cases. * test(agents): run entry settlement with host broker Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after openclaw#160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
Observe gated operation rejections before advancing acknowledgement gates, then directly await every rejects matcher. An earlier setup failure no longer leaves a detached matcher promise. Require the unknown-write outcome in both restoration refusals so an unrelated fixture error cannot satisfy the custody assertion. This completes the changed-lane repair after openclaw#160778 alongside main's run-entry broker routing (bc7a63e), shared read-context fixture (4501bde), and logical requester yield authority repair (aaa5b05). The existing production fixes and all protected test expectations remain. All three reported files fail on 4adeaef and pass at 742df3d~1 on Blacksmith Testbox, Node 24.19.0/Linux. Canonical main e81e2b7 plus this patch passes all 96 tests three times (145.80s, 68.82s, 68.10s), and 1,220 owning-suite cases in 211.49s. The existing opt-in 5,000-session benchmark remains skipped. The 62-case queued registration file takes 23.25s cold, then 10.94s and 9.26s in Vitest. Full check:changed for the final three-file diff passes in 281.28s. Proof: https://github.com/openclaw/openclaw/actions/runs/36587966134
…hermetic - subagent-registry.ts: restore upstream's plain public restoreOnce wrapper. 2273ef6 had wrapped it with purgeExpiredDelegateArtifacts(), which opened state, quarantine and schema-contract stores on every public registry call, including the requester-yield path. Upstream's sessions.initial-transfer-custody test (437572e, openclaw#160778) requires that path to construct no SQLite; it failed 3/13. - The purge only garbage-collects expired rows, and every read already enforces retention_deadline <= now. - It still runs at gateway maintenance (startup and interval), in initSubagentRegistry, on bootstrap-pending and on the sweeper tick. - Flagged for review. - artifacts.delegate-claims.test.ts (ours): - It mocked only visitSessionMessagesAsync, but upstream moved artifact reads onto the transcript worker, so the fixture never reached the handler. The test instead opened the shared /tmp/openclaw-agent.sqlite through a fixed /tmp store path. - It now uses withArtifactFixtureReader, as sibling artifact tests do, with a private mkdtemp dir. - It asserts the fixture reader is actually used. Both found by a mechanical sweep of 106 continuation test files that were never in the designation sweep (1166 passed; these were the only real failures). Refs #1408 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fq5EX9ESA3CG9cuZxVoKAK
…160946) * fix: retain shared-state snapshots through worker failures Keep preparation, query, and cleanup under the existing read owner. Retain native child custody across disposable Worker loss, preserve admitted source identities, and join cleanup before releasing the original directory. Preserve existing schema, retention, SDK, and exact-native backup contracts. * fix: preserve native wrapper imports and callback type contracts * fix(tooling): retain dynamic snapshot cleanup dependencies * fix(test): prepare package contract workers before tests Prepare the Memory Core facade’s compiled worker dependencies through the existing runner owner before Vitest starts. Keep the runtime export assertion and its deadline unchanged. Extend the actual pre-spawn lifecycle cases to cover direct and project-selected contract tests, including exclusions. Validation: causal preparation-order failure, 35 artifact-owner cases, 19 unchanged package-contract cases, changed-file checks, and independent review. * fix(sqlite): retain original snapshot cleanup across reloads Carry the original complete-removal operation into re-imported callers instead of treating it as token retirement followed by another pathname deletion. Preserve both original and current reader fences, native join, and retry against the original cleanup owner. Remove the retired async registration path. Exercise real replacement bytes and target loss, and inject Cron copy/removal failures in the actual workers. Both original regressions fail; the correction passes 35 Node cases, the canonical Bun lifecycle case, types, lint, export checks, and independent reviews. * test(agents): share queued-registration context captures Expose the read-context capture through the same synthetic source owner as the existing writer capture. This lets the uncertain-kill case finish canonical restoration instead of leaving its failed cleanup to contaminate subsequent registration cases. * test(agents): run entry settlement with host broker Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after openclaw#160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
…160946) * fix: retain shared-state snapshots through worker failures Keep preparation, query, and cleanup under the existing read owner. Retain native child custody across disposable Worker loss, preserve admitted source identities, and join cleanup before releasing the original directory. Preserve existing schema, retention, SDK, and exact-native backup contracts. * fix: preserve native wrapper imports and callback type contracts * fix(tooling): retain dynamic snapshot cleanup dependencies * fix(test): prepare package contract workers before tests Prepare the Memory Core facade’s compiled worker dependencies through the existing runner owner before Vitest starts. Keep the runtime export assertion and its deadline unchanged. Extend the actual pre-spawn lifecycle cases to cover direct and project-selected contract tests, including exclusions. Validation: causal preparation-order failure, 35 artifact-owner cases, 19 unchanged package-contract cases, changed-file checks, and independent review. * fix(sqlite): retain original snapshot cleanup across reloads Carry the original complete-removal operation into re-imported callers instead of treating it as token retirement followed by another pathname deletion. Preserve both original and current reader fences, native join, and retry against the original cleanup owner. Remove the retired async registration path. Exercise real replacement bytes and target loss, and inject Cron copy/removal failures in the actual workers. Both original regressions fail; the correction passes 35 Node cases, the canonical Bun lifecycle case, types, lint, export checks, and independent reviews. * test(agents): share queued-registration context captures Expose the read-context capture through the same synthetic source owner as the existing writer capture. This lets the uncertain-kill case finish canonical restoration instead of leaving its failed cleanup to contaminate subsequent registration cases. * test(agents): run entry settlement with host broker Route the existing run-entry suite through the database worker inventory so asynchronous requester settlement can use the host broker. The embedded thread lane failed five cases after openclaw#160778. All 32 cases pass through normal infra fork routing. Scoped formatting, lint and independent P2 review pass.
What Problem This Solves
Durable initial requester yield, spawned-child handoff, and cold registry restoration still perform SQLite work on the Gateway thread.
User Impact
These flows await the existing database worker while retaining the original caller and session authority. An unfinished handoff cannot report success or repeat a committed write. Existing stores need no migration or operator action; configuration, defaults, schema, retention, and public APIs are unchanged.
Why This Change Was Made
The initial handoff uses the existing registry writer and pending publication episode. Cohort preparation retains the requester-turn marker through host promotion, then releases it in a second acknowledged write before scheduling the wake. This extra write preserves recovery across interruption without treating a durable marker as permission to act. Cold restoration reads fresh complete rows through the existing state worker; session authority is captured before restoration and retained through completion or cleanup.
This composes with merged #160203 and #160472, including unreadable-acknowledgement recovery and surviving-sibling retry handoff. It also preserves #160858’s maintenance projection and descendant-snapshot contracts in the same state read/cache owner; full restoration rejects compact maintenance replies. Process-held incognito authority acquisition remains with its existing native owner pending the separate namespace migration.
Evidence
Canonical receiving proof on Node 24.19.0/Linux passes 21 registered initial-transfer/restart cases, 318 registry/lifecycle cases, 60 receipt/retry cases, 23 persistence-resume cases, and 77 authority/caller cases. Controls cover replaced sources and runtime owners, uncertain acknowledgements, opposite settlement claims, prepared-cohort restart, child completion during promotion, and concurrent authority preparation. The newly canonical unreadable-receipt test failed before its missing restore join was added, then passed with the original assertions and cleanup.
An isolated WebSocket Gateway proof publicly creates an explicit non-main requester and linked child, verifies the child's returned key/session ID/parent, invokes the real registered initial-yield and cohort writers, checks durable intent before the yield callback and acknowledged marker release, then reads the original requester identity through public
sessions.describe. This proof-only capsule passed again on the combined source in 50.166 seconds after a fresh 385.888-second build; it does not claim an OS-process restart or external provider delivery.The durable initial-flow windows assert zero calls across all eight observed host SQLite APIs; the retained predecessor window made 26 calls. Setup, later wake work, and cleanup are excluded. This is not a whole-Gateway or wall-time performance claim. The latest separate one-worker file invocations took 51.872 seconds for eight send/yield cases and 51.190 seconds for thirteen custody cases, including transforms and worker preparation. Real workers protect acknowledgement, physical-source and recovery boundaries that the separate mocked policy fixtures cannot prove; no timeout or retry budget increased.
CI run 36543522334 exposed a type-import cycle and cancelled the remaining coverage. The correction places the existing followup authority signature in its type leaf, preserving the runtime factory unchanged. Original Madge RED, corrected full architecture check, owning types/lint and fresh P2 review pass; type-erased JavaScript is identical, so the completed build/public/runtime evidence remains applicable. Cancelled jobs are not counted as passing CI or per-file CI timing. The next run, 36549290827, failed the CI planner’s two Gateway-recipient timing cases; its failure and cancelled coverage are retained separately. The timing owner independently reproduced that defect and canonical 0c8e56c fixes it. This PR does not duplicate that repair; the next exact-head CI is accounted for below.
Core and affected test types, typed lint for all affected source files, full script lint, formatting and selected repository guards pass. The fresh build and eight selected built-runtime receipt/recovery cases pass; seventeen unrelated E2E cases were intentionally unselected. The advisory temp-directory report covers the actual staged scope with no findings.
The material #160858 integration was reviewed and requalified on exact 26dffe7 plus this PR: all 24 selected phases passed with unchanged source, including the 21 initial-flow cases, 85 shared read/cache/maintenance/descendant cases, affected types/lint, both cycle checks, fresh build and public handoff. Earlier unchanged caller/receipt/recovery evidence remains applicable. Fresh independent review found no actionable P0–P2 issue.
Current-head CI 36557432686 completed with 58 successful, 79 cancelled, 19 skipped and two failed jobs (one root plus the aggregate). The root has four session-cleanup fixture failures, independently reproduced on an unchanged main baseline in the exact 24-file/two-worker group. Source comparison binds that baseline to the tested merge. The fixtures use a host-only temporary trigger, mutate canonical rows with raw SQL, and terminate shared workers before their lifecycle owner; their separate repair remains with its owner. Failed and cancelled coverage stays nonpassing. Landing uses the explicitly authorized native pre-existing-failure route with current security, review, source and admin-authority checks.