Repository navigation
refactor(heartbeat): run outcome queries in the agent database worker - #147463
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 20, 2026, 3:56 AM ET / 07:56 UTC (Revision 13). ClawSweeper reviewWhat this changesMoves disk-backed heartbeat outcome storage and next-user context claims into the shared agent database worker, with matching test routing and asynchronous fixture cleanup. Merge readiness✅ Ready for maintainer review This remains useful: current main retains caller-thread heartbeat queries, and the merged queue-admission repair does not replace this worker migration. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherHeartbeat outcomes preserve silent background progress for the next user turn. The store accepts outcomes and claim requests, coordinates access to the agent database, and returns bounded model context. flowchart TD
A[Silent heartbeat outcome] --> C[Heartbeat outcome store]
B[Next user turn] --> C
C --> D{Database kind}
D -->|Disk| E[Shared agent worker and live admission]
D -->|Incognito| F[Existing in-memory owner]
E --> G[Stored outcome and single-run claim]
F --> G
G --> H[Bounded model context]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +145, Tests +162, Other +1. Total +308 across 22 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Use the canonical agent worker for disk-backed heartbeat operations while preserving existing data, FIFO ordering, live authority, and incognito ownership. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction: this is a worker migration, and current-main source directly confirms the remaining caller-thread queries. Is this the best way to solve the issue? Yes. Reusing the landed worker owner and preserving the existing query and storage contracts is a focused, maintainable cutover. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ef79fd7adfab. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
6ab4e10 to
32ad14b
Compare
32ad14b to
158645c
Compare
c325151 to
9a81724
Compare
…rker Move file-backed persistence and next-user claims onto the canonical agent SQLite worker while preserving FIFO order, captured inputs, claim retries, and live transaction and commit authority. Capture lifecycle before queueing so file-backed work cannot reopen a retired owner. Keep incognito on its sole in-memory owner; cold bootstrap and coordination remain separate native work. Let the foundation own permission repair. Route actual worker consumers through the existing forked test lane and await scoped fixture drainage before deleting state directories. Related: #144592 Depends on: #153150
d0744c3 to
be5de88
Compare
|
Merged via squash.
|
…openclaw#147463) * refactor(heartbeat): execute outcome queries in the agent database worker Move file-backed persistence and next-user claims onto the canonical agent SQLite worker while preserving FIFO order, captured inputs, claim retries, and live transaction and commit authority. Capture lifecycle before queueing so file-backed work cannot reopen a retired owner. Keep incognito on its sole in-memory owner; cold bootstrap and coordination remain separate native work. Let the foundation own permission repair. Route actual worker consumers through the existing forked test lane and await scoped fixture drainage before deleting state directories. Related: openclaw#144592 Depends on: openclaw#153150 * test(heartbeat): route worker consumers and join requester settlement * test(heartbeat): exclude worker consumers from auto-reply core * test(heartbeat): route moved durable context cases through worker owner
Related: #144592. Builds on the foundation in #153150 and fixture isolation in #153286, both landed on
main. This PR targetsmain. Shared fixture fixes are now covered on main by #153338 and #153296; neither remains in the focused merge diff.What Problem This Solves
Silent heartbeat outcomes and next-user claims perform their heartbeat queries on the Gateway thread even though callers await the API.
User Impact
File-backed heartbeat persistence and claims execute on the canonical agent database worker while preserving bounded context, claim retries, FIFO ordering, and current run authority. Existing outcome rows remain readable across upgrades and rollback; there are no schema, retention, permission, config, or external SDK changes.
Why This Change Was Made
The consumer binds complete heartbeat operations to the existing worker connection and captures file-backed database lifecycle before queueing, so queued work cannot reopen an agent after close. The foundation owns commit permission repair and worker retirement. Incognito keeps its sole in-memory owner and admission queue. Cold bootstrap, custom-store target resolution, coordination SQL, and close remain host-owned; this is not an all-SQL-off-thread claim.
Real worker consumers now run in the existing fork test lane, with their previous routes removed from both focused and full-suite selection while preserving watch ownership. Fixture cleanup awaits owned agent/state paths before deletion. The terminal-cleanup fixture joins its real requester-settlement dependency and restores its test overrides even when an assertion fails.
Evidence
On the landed-foundation composition, 199 consumer tests, 974 routing controls, and the nested MCP retention test passed. The complete 137-case shared suite was replayed in its original order after reproducing its first cleanup failure. Active, revoked, and replaced ownership checks pass unchanged. The nested test retains its fresh module cache, single-worker ordering, shared scope, and original 180-second deadline. Types, lint, repository guards, growth/assertion checks, and fresh independent review through P2 passed.
Real SQLite regression proof fails on original caller-thread heartbeat SQL and passes with the worker consumer. Genuine incognito evidence checks the canonical key, symbol database identity, empty native filename, and absent disk files. Permission controls preserve rollback on authority or permission refusal; all 40 exact export-policy guards passed.
Retained ordinary-build and compiled proof calibrates all eight native SQLite methods, exercises actual next-user context, and records zero caller SQLite calls for warm persistence and claims. Every measured application phase records zero caller-thread
Atomics.wait; the late-bound backend matches its build artifact hash. FIFO retries retain one coordinator call, cold bootstrap/close work stays explicit, and durable readback matches the claimed outcome. These results retain their original source bindings. The three persistence/kernel/backend production modules remain unchanged; the runtime registry preserves both main's workspace-memory worker and the heartbeat worker. The prior composition passed exact-head hosted CI; the actual-main Boards carry has now passed its own run.The cached-filtered full-suite ownership audit now reports no missing or duplicate tests, and all 24 dispatch-recovery cases pass solely under the database-worker project. The final CI repair uses the canonical registry exclusion in auto-reply-core; its root types, typed lint, formatting, and independent P2 review pass. The unrelated exec notification-prefix flake is repaired separately in #153338 and consumed here unchanged.
The current-main reconciliation retains both worker descriptors unchanged. Fresh worker/entrypoint controls (24 cases) and the full-suite ownership invariant pass after that union; dependency manifests are unchanged. Packaging remains covered by the new exact-head CI run.
The subsequent test-registry union keeps all three outbound-loopback routes from #153076 and all nine Heartbeat routes. All 318 project-configuration and worker-registry controls pass afterward; this carry leaves the reviewed Heartbeat production files unchanged.
The ACK worker fixture cleanup was reviewed separately in #153367 and is now covered by #153296 on main. The merge preserves the complete canonical fixture, including explicit null/undefined rejection after deletion and the claimless no-op assertion. All four composed worker cases passed; no delivery authority or production changes are included in that fixture repair.
Prior hosted CI completed successfully with 156 jobs finished and no failures for commit
c32515101310e93363ec03ac9cff9af645a3a7c5: CI run. The observer joined successfully; no failed-job rerun was used.The latest main reconciliation preserves main’s active-node reset inside the asynchronous CLI fixture cleanup, including the awaited database cleanup. The former-fast routing map retains both main’s isolated cleanup owner and Heartbeat’s private-transcript owner. The three Heartbeat production modules are byte-identical to the prior green head; the worker descriptor remains additive. Independent review through P2 accepted the complete composed branch.
For the two test-conflict resolutions, all 1,302 routing/project controls and all 185 CLI preparation and fixture cases passed; selected type, lint, and repository checks passed. The subsequent descriptor union preserves main’s workspace-skills worker and the Heartbeat worker unchanged. Another 330 worker-launch, routing, and full-suite ownership controls passed on that final carry. The earlier green run is retained as historical evidence; the previous successor has its own successful hosted run.
Current-main CI exposed three moved CLI durable-context cases still routed to a threaded test project. The normal wrapper reproduced the same three host-owner admission failures while eight sibling cases passed. Adding the file to the canonical database-worker registry moves it into the existing fork project and removes its former route through the shared exclusion. All 11 unchanged cases now pass, along with 319 registry/full-suite ownership controls. Independent review through P2 accepted this one-line routing repair; no production guard, mock, assertion, timeout, or baseline changed.
Prior hosted CI completed successfully with 156 jobs finished and no failures for commit
d0744c3fe74f7e0b9ad419386d75e1c6003db100: CI run. The exact-head observer joined successfully, and the completed review reports no findings or before-merge blockers.The actual-main carry onto landed Boards #153159 preserves both worker descriptors, including every existing source and packaged path. The seven Boards and Heartbeat production modules remain byte-identical to their qualified owners. All 35 focused worker and registry controls pass, the full-suite ownership audit passes, and fresh independent review through P2 is clean. Earlier runtime/build evidence retains its original source bindings; this additive registry carry passed exact-head CI.
The actual-main Boards carry completed CI run 35495824797 successfully at
be5de88a606337731f8ad190b664031bc1a3baeb, with 156 jobs finished and no failures. The exact-head observer joined cleanly.