Repository navigation
fix(cron): keep descendant reads off the Gateway thread - #160508
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: needs maintainer review before merge. Reviewed September 28, 2026, 4:06 PM ET / 20:06 UTC (Revision 7). ClawSweeper reviewWhat this changesThe branch moves scheduled-run descendant checks and follow-up reads through the subagent registry’s SQLite read worker, updates wait handling and tests, and documents the worker boundary. Merge readiness✅ Ready for maintainer review Keep open. Current main and the latest release still use synchronous Cron descendant reads, while this branch has credible real-worker proof and no established introduced defect. Priority: P2 Review scores
Verification
How this fits togetherScheduled Cron runs can spawn child agents whose state is kept in the subagent registry. Cron reads that state to decide whether to wait, use a child reply, or deliver its own result. flowchart LR
A[Scheduled Cron run] --> B[Agent response]
B --> C[Subagent registry]
C --> D[SQLite read worker]
D --> E[Descendant status and replies]
E --> F[Wait or settle delivery]
F --> G[Outbound result]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +50, Tests +367, Docs +10. Total +427 across 18 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the registry-owned worker snapshot for Cron observations while preserving existing settlement rules and the separate lifecycle deletion guards. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source still routes Cron descendant reads through synchronous registry readers, and the PR records a real-worker regression that made six host SQLite calls before the change; this read-only review did not run it. Is this the best way to solve the issue? Yes. Reusing the registry snapshot owner removes the synchronous Cron adapter without adding configuration, a stored format, or a competing registry owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3775359ab87d. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
Addressing the two timing-reporting items in the completed review: the PR body now records the retained command/shard wall times, RSS where measured, fixture-rerun composition, and cold-compiler limits. Standalone single-worker wall times were not measured for every file. I am retaining the completed causal, lifecycle, and sibling proof rather than rerunning passing suites solely for a timing inventory. The real-worker boundary needs actual SQLite/worker execution; the grouped timings also include inherited compiler/import and outbound-adapter costs. No overall speedup is claimed from these noncomparable invocations. This is the maintainer disposition of those reporting requests, not a claim that the bot changed its blocked-readiness text. The review found no code or security defect. CI, security, exact-head preparation, and native admission remain enforced; CI duration will be recorded after the active exact-head run finishes. |
Integrate one fixed main revision for the real interim-retry test conflict. Preserve the canonical fixture cleanup and the paired descendant-state and cancellation-during-observation controls; production migration postimages remain unchanged. Validation: 24 receiving fixture and real-worker cases, Cron types, lint, formatting, qaRuntime build and fresh full-candidate review. Prior-head CI attribution remains historical and will not qualify the replacement head.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Recover the focused clock repair from f46483c (#160182), whose performance work was superseded while this validated fixture fix remained unmerged. Fake debounce timers and real publication budgets could deadlock the held-generation drain and cascade through the rest of the CI shard. Bind the fixture's performance clock to fake Date and restore it before the real-I/O case and at test completion. Production budgets and assertions stay unchanged. Validation: a finite CPU workload reproduces the original test/hook timeout on CI's pinned Bun and passes both churn variants after the repair. The normal owner/sibling suites pass 41 cases; the original CI selection passes 452 cases across 27 files. Complete changed checks and independent Codex P0-P2 review pass. Testbox proof: run 36476506157. Related: #160508, #160182 Co-authored-by: Vincent Koc <[email protected]>
Recover the focused clock repair from f46483c (openclaw#160182), whose performance work was superseded while this validated fixture fix remained unmerged. Fake debounce timers and real publication budgets could deadlock the held-generation drain and cascade through the rest of the CI shard. Bind the fixture's performance clock to fake Date and restore it before the real-I/O case and at test completion. Production budgets and assertions stay unchanged. Validation: a finite CPU workload reproduces the original test/hook timeout on CI's pinned Bun and passes both churn variants after the repair. The normal owner/sibling suites pass 41 cases; the original CI selection passes 452 cases across 27 files. Complete changed checks and independent Codex P0-P2 review pass. Testbox proof: run 36476506157. Related: openclaw#160508, openclaw#160182 Co-authored-by: Vincent Koc <[email protected]>
* refactor(cron): use database workers for session retention cleanup Move continuation and reaper planning and ordinary deletion through the existing reclamation worker while retaining live parent authority and fresh durable descendant and maintenance checks before commit. Preserve native mutation custody, cold validation proof, and publication ordering. Carry session-absence authority through receipt cleanup. Follow-up to #160508. * fix(sessions): keep worker plan contracts independent of implementations * fix(sessions): preserve SDK deletion state environment Forward the existing SDK env option through lifecycle source capture, while excluding it from cloneable deletion plans. Keep the physical database ownership guard and all existing plugin assertions. Run the SDK session-store tests in the existing host-broker worker group. The original six-file Codex group passes all 24 cases, including both CI failures; all 26 SDK session-store cases also pass. Core types, scoped lint, SDK exports, line caps, and fresh Codex review pass. * test(sessions): complete worker cleanup test routing Route the conversation SDK deletion suite through the existing shared-state host broker and import the reclamation runtime from its current owner. Compare the archive destination by physical path on Windows while retaining transcript contents and exact disk-accounting assertions. The exact preceding CI exposed all three gaps. Focused runtime and routing proof passes 504 cases with one Linux-only case skipped locally; affected types and independent review pass. Windows CI remains platform proof. * test(sessions): route remaining deletion consumers through broker Complete the explicit core and plugin worker test registrations for real permanent-deletion consumers. Preserve all archive and lifecycle assertions. Control the clock only in the held-response Mattermost identity race: the real five-second backfill deadline previously settled before cold worker deletion committed. Keep the separate real deadline test unchanged. Proof: 19 package cases, 185 unchanged Codex cases and 20 final Mattermost cases, routing control, extension types, lint and fresh independent review. * test(subagents): join retained cleanup before restart assertions Wait for the existing admitted-work fixture to settle before polling row removal, so asynchronous deletion cannot leave a restart fence contaminating later cases. Preserve the original assertions, poll and timeout. Route Feishu Doctor through the existing host broker for real SDK deletion. Proof: original four-case sequence failed then passed after the one-statement reorder; all 43 recovery/steer and 19 Feishu cases pass, with affected types, lint, formatting and fresh independent review.
…aw#160858) * refactor(cron): use database workers for session retention cleanup Move continuation and reaper planning and ordinary deletion through the existing reclamation worker while retaining live parent authority and fresh durable descendant and maintenance checks before commit. Preserve native mutation custody, cold validation proof, and publication ordering. Carry session-absence authority through receipt cleanup. Follow-up to openclaw#160508. * fix(sessions): keep worker plan contracts independent of implementations * fix(sessions): preserve SDK deletion state environment Forward the existing SDK env option through lifecycle source capture, while excluding it from cloneable deletion plans. Keep the physical database ownership guard and all existing plugin assertions. Run the SDK session-store tests in the existing host-broker worker group. The original six-file Codex group passes all 24 cases, including both CI failures; all 26 SDK session-store cases also pass. Core types, scoped lint, SDK exports, line caps, and fresh Codex review pass. * test(sessions): complete worker cleanup test routing Route the conversation SDK deletion suite through the existing shared-state host broker and import the reclamation runtime from its current owner. Compare the archive destination by physical path on Windows while retaining transcript contents and exact disk-accounting assertions. The exact preceding CI exposed all three gaps. Focused runtime and routing proof passes 504 cases with one Linux-only case skipped locally; affected types and independent review pass. Windows CI remains platform proof. * test(sessions): route remaining deletion consumers through broker Complete the explicit core and plugin worker test registrations for real permanent-deletion consumers. Preserve all archive and lifecycle assertions. Control the clock only in the held-response Mattermost identity race: the real five-second backfill deadline previously settled before cold worker deletion committed. Keep the separate real deadline test unchanged. Proof: 19 package cases, 185 unchanged Codex cases and 20 final Mattermost cases, routing control, extension types, lint and fresh independent review. * test(subagents): join retained cleanup before restart assertions Wait for the existing admitted-work fixture to settle before polling row removal, so asynchronous deletion cannot leave a restart fence contaminating later cases. Preserve the original assertions, poll and timeout. Route Feishu Doctor through the existing host broker for real SDK deletion. Proof: original four-case sequence failed then passed after the one-statement reorder; all 43 recovery/steer and 19 Feishu cases pass, with affected types, lint, formatting and fresh independent review.
What Problem This Solves
Cron jobs still performed synchronous SQLite reads on the Gateway thread when checking descendant work, waiting for child summaries, or deciding whether delivery could proceed.
User Impact
Cron descendant observations now await the existing database read worker, keeping the host responsive during those reads. Pending descendants, successor runs, cancellation, and completion-delivery settlement retain their existing behavior. No configuration, schema, retention, or update changes are required.
Why This Change Was Made
The private Cron runtime adapter uses the existing registry snapshot owner and descendant query policies. Freshness and active-execution facts share one consuming frame, and run draining awaits a fresh observation at each refresh. Failed admission does not become an empty descendant set. The obsolete internal synchronous list adapter is removed.
Reaper and continuation deletion guards remain assigned to the separate lifecycle-writer migration: an earlier asynchronous observation cannot replace a current transaction guard.
Evidence
The actual Cron fallback failed on the original implementation with six host SQLite calls (two prepares, three gets, one all). With the migration, all eight observed host SQLite operation counters stay zero while a real worker reply is held, an event-loop turn proceeds, and the correct child answer returns after release.
The retained and rerun proof covers 344 unique cases, including committed update/delete/successor publication, another requester's ownership, close/source replacement/caller cancellation, freshness, yielded work, and queued delivery. CI correctly caught an introduced exported-name collision at
e87cb3de; the private async operation is nowhasUnsettledCronDescendants. All 227 affected runtime cases passed again, including all 14 worker cases, while the 117 unaffected cases retain their prior passing proof. The failed export guard, affected types, and lint pass after the correction. Independent full and delta reviews found no actionable P0–P2 issue.The original candidate passed production types, all 26 core test type graphs, selected static guards, and full
pnpm build. The private binding correction additionally passed core/Cron types and the maintainedpnpm build qaRuntimeprofile; the full declaration build was not repeated for this identifier-only delta.The old auto-merge request was explicitly retired before head replacement, with its native outcome retained. A real later conflict in the interim-retry fixture was resolved against one fixed main revision,
01747d9b2b11. The canonical fixture cleanup is preserved, including the paired descendant observation and cancellation-during-await controls. All production postimages remain identical to the prior reviewed head. The receiving composition passed all 24 fixture/real-worker cases, Cron types, type-aware lint, formatting,qaRuntime, and a fresh full candidate review.Current head is
0c3b6d2b1065ddd719a3e4e548b915f4ae193f15. Exact-head CI 36464397184 completed with 163 successful jobs, 21 skipped jobs, one deadline-cancelled Node job, and its failed aggregate gate. Earlier export, UI, and heartbeat failures remain historical failures; their exception evidence is not reused for this head.The remaining Node job first timed out in the unchanged
session-change-event.test.tsheld-generation fixture. It awaits publication draining before advancing fake timers, while the publication budget reads a real clock and may yield to fakesetImmediate. The exact tested merge829eb7acand baseline5117d94bhave identical fixture, Gateway/UI/plugin, harness, and dependency inputs. The synthetic projection does not enter the changed Cron or run-wait paths; its imported live-registry accessors are unchanged. Independent source inspection supports the pre-existing-failure attribution. No baseline runtime reproduction is claimed here.The log retains 408 passing case lines and 18 failing cases, including subsequent cleanup timeouts and a later unexpected-broadcast assertion. GitHub reports the one-hour deadline in its check annotations and records the job as cancelled. The uncompleted shard coverage remains unproven; CI is not presented as green. The exact-head review keeps
tests.result=failand the current run/attempt attribution for the explicitly authorized exception. The current hosted code review completed with no findings, security issues, or before-merge items. Native admission still revalidates current authority, reviews, security, source evidence, and the exact prepared head.Measured proof cost and timing-review disposition
These are retained command and shard measurements, not invented standalone single-worker wall times for every file.
qaRuntimeprofile passed.qaRuntimeprofile passed./sidetimeout, then cleanup/fork retirement; failed.The real-worker test protects SQL placement, publication freshness, and lifecycle refusal; a mock cannot establish those boundaries. Compiler/import and inherited sibling costs are included above. Different case counts and cache states prevent a valid whole-command before/after speed comparison. Test-support files have no independent executable wall time.
The initial hosted review found no code or security defect; its two before-merge items requested additional per-file timing reporting. The maintainer disposition retains the completed causal and sibling proof, reports actual costs and limits, and avoids repeating passing suites solely for a timing inventory. The prior
19ahosted review completed at 16:14:18 UTC with no findings, security issues, or before-merge items. Current admission still verifies the exact head, review, security, and attributed CI exception.