Repository navigation
refactor: unify wake scheduling and background session ownership - #138451
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 7, 2026, 12:51 PM ET / 16:51 UTC. ClawSweeper reviewWhat this changesConsolidates background wake scheduling, retains session and database ownership across delayed work, and supplies silent heartbeat outcomes to admitted user turns across runtimes. Merge readiness⛔ Blocked before merge - 3 items remain This remains useful work: current main retains the separate heartbeat scheduler, and no merged replacement is established. The verified test merge resolves the previous integration concern; source review found no blocking introduced defect. Priority: P2 Review scores
Verification
How this fits togetherHeartbeat, cron, and system events request background agent work through the wake scheduler. Session admission and SQLite lifecycle owners determine when that work may run and which conversation state it may use. flowchart TD
A[Heartbeat and cron requests] --> C[Shared wake queue]
B[System events] --> C
C --> D[Session and database admission]
D --> E{Owner still current?}
E -->|Yes| F[Agent execution and context]
E -->|No| G[Reject stale work]
F --> H[Delivery and waiter settlement]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -12, Tests +2964, Other +3. Total +2955 across 72 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one lifecycle-owned wake queue and exact store claims, with Gateway evidence confirming session continuity and rejection of stale work on the integrated candidate. Do we have a high-confidence way to reproduce the issue? Not applicable as a single reported bug: this is a consolidation with several source-backed lifecycle regressions; no runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? Yes. Reusing one scheduler and retaining ownership at admission is a coherent repair boundary, and the patch preserves existing heartbeat entrypoints and stored formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8dde3559a551. 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 (6 earlier review cycles)
|
b10837e to
83c0491
Compare
83c0491 to
21d8b84
Compare
Carry physical session-store claims through admission and reclamation, and claim silent heartbeat context at the shared runtime boundary. Preserve current foreground maintenance, context fragments, and archive ownership. Related: #135933.
21d8b84 to
5713d88
Compare
|
Merged via squash.
|
Consolidate monitoring execution and delivery with ordinary replies, route isolated cron through the shared agent entry, and keep immediate cron retries in the canonical wake queue. Preserve quiet/alert policy, scratch ownership, cancellation, and durable delivery custody while removing duplicate runtime paths. Carry actual admission outcomes through monitoring so foreground work winning late leaves cron and exec events pending for retry. Preserve CLI/native auth and lifecycle fences for saved context and route recovery through the canonical agent/store owner. Preserve separate physical stores when reconciling exhausted recovery attempts. No new database schema, configuration, protocol, or migration requirement. Existing heartbeat public contracts remain supported. Production decreases by 56 lines in this slice and 68 across the two slices. Related: #135933, #138451.
Consolidate monitoring execution and delivery with ordinary replies, route isolated cron through the shared agent entry, and keep immediate cron retries in the canonical wake queue. Preserve quiet/alert policy, scratch ownership, cancellation, and durable delivery custody while removing duplicate runtime paths. Carry actual admission outcomes through monitoring so foreground work winning late leaves cron and exec events pending for retry. Preserve CLI/native auth and lifecycle fences for saved context and route recovery through the canonical agent/store owner. Preserve separate physical stores when reconciling exhausted recovery attempts. No new database schema, configuration, protocol, or migration requirement. Existing heartbeat public contracts remain supported. Production decreases by 56 lines in this slice and 68 across the two slices. Related: #135933, #138451.
) * refactor: share heartbeat and cron execution with reply runtime Consolidate monitoring execution and delivery with ordinary replies, route isolated cron through the shared agent entry, and keep immediate cron retries in the canonical wake queue. Preserve quiet/alert policy, scratch ownership, cancellation, and durable delivery custody while removing duplicate runtime paths. Carry actual admission outcomes through monitoring so foreground work winning late leaves cron and exec events pending for retry. Preserve CLI/native auth and lifecycle fences for saved context and route recovery through the canonical agent/store owner. Preserve separate physical stores when reconciling exhausted recovery attempts. No new database schema, configuration, protocol, or migration requirement. Existing heartbeat public contracts remain supported. Production decreases by 56 lines in this slice and 68 across the two slices. Related: #135933, #138451. * refactor: decouple heartbeat policy from reply run state * fix: retain source session ownership for bound ACP admission Keep lifecycle reset and admission in the source agent store while bound ACP execution retains its target. Update fixtures to canonical queue, store-owner, and no-send proof contracts, and register the added QA and regression coverage.
…nclaw#138451) Carry physical session-store claims through admission and reclamation, and claim silent heartbeat context at the shared runtime boundary. Preserve current foreground maintenance, context fragments, and archive ownership. Related: openclaw#135933.
…claw#139624) * refactor: share heartbeat and cron execution with reply runtime Consolidate monitoring execution and delivery with ordinary replies, route isolated cron through the shared agent entry, and keep immediate cron retries in the canonical wake queue. Preserve quiet/alert policy, scratch ownership, cancellation, and durable delivery custody while removing duplicate runtime paths. Carry actual admission outcomes through monitoring so foreground work winning late leaves cron and exec events pending for retry. Preserve CLI/native auth and lifecycle fences for saved context and route recovery through the canonical agent/store owner. Preserve separate physical stores when reconciling exhausted recovery attempts. No new database schema, configuration, protocol, or migration requirement. Existing heartbeat public contracts remain supported. Production decreases by 56 lines in this slice and 68 across the two slices. Related: openclaw#135933, openclaw#138451. * refactor: decouple heartbeat policy from reply run state * fix: retain source session ownership for bound ACP admission Keep lifecycle reset and admission in the source agent store while bound ACP execution retains its target. Update fixtures to canonical queue, store-owner, and no-send proof contracts, and register the added QA and regression coverage.
…, fixture repairs Decisions recorded on #1396 (figs, and Ronan / Emeric / Silas / Elliott): - Restore upstream openclaw#146600. Legacy attachmentsDir/attachmentsRootDir records are retired without traversal on both the async and sync removal paths; attachmentId cleanup and the retained-completion orphan guard are kept. Three fork-only tests that pinned the retired recursive delete now assert the decided behavior: legacy records retire, and every file on disk survives. - session-updates cache-only path: canonicalize the merged entry (projectCanonicalSessionEntryShape over mergeSessionEntry). #1402: 46 of 55 src/auto-reply/continuation tests belonged to no CI or Mode-B shard, because the reply config runs only as reply-subtree splits. Add an auto-reply-continuation split group, plus a guard test that every file the reply subtree include collects is scheduled. The guard fails without the fix. Fixture repairs, from running those tests for the first time: - work-dispatch.durable-3: the paths.js mock now spreads the real module. - volatile-map allowlist: rename afterClearByOperation (upstream openclaw#138451); add four upstream-owned reply-run-registry maps, with provenance. The continuation attachment payload map is deliberately not allowlisted (#1403). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fq5EX9ESA3CG9cuZxVoKAK
Related: #135933. First of two stacked slices; #139624 follows this branch. Landing is now authorized.
What Problem This Solves
Background work can wait across compaction, delivery, and session replacement. Reconstructing its owner later from a logical session key can bind that work to a different session or store. This change carries the captured session/database identity through admission and reclamation, preserving connected compactions while rejecting replacements, foreign stores, and restart-invalidated work.
A single process-owned wake queue handles heartbeat, cron-task, and system-event wakes. It owns target backoff, spacing, barriers, cancellation, waiter settlement, and handler replacement. Separate heartbeat wake lifecycle, target, and settlement modules are removed; existing SDK names remain a facade. Quiet heartbeat outcomes are claimed at the common admitted runtime boundary for built-in and native harnesses, with equivalent CLI admission behavior.
Compatibility and Integration
No new database schema, stored representation, migration requirement, user configuration option/default, Gateway wire field, or protocol version is introduced relative to main
71e3383a0ef8414891c61cadb067d42c7f909198. Existing heartbeat settings and saved state remain supported. Current main's foreground-maintenance priority, structured context fragments, async database opening, and logical agent ownership for session archival are preserved.Production: −12 lines. Removed redundant identity-publication helpers and reused the existing lifecycle types. State/logging tests have a separate type-check shard because the added regression files exceeded two existing shard caps; the cap and coverage remain unchanged.
Validation
Current candidate:
5713d882d624e62f8593c42b0273bf0cf9ba4bb4.Current-head CI passes. Fresh Testbox build and Gateway proof exits 0 on tree
2e776b74ceb56e9424859c5c3cd48ef1a00a20d5, identical to the current PR head (QA carrier0c2f25d9fca3644e122319989aeccb466d108ef6). Natural cron fired once and delivered once on both OpenClaw and Codex with live providers. A separate real-Gateway scenario with a mock provider confirmed heartbeat routing omits inbound metadata while ordinary ingress retains it. Delivery used synthetic qa-channel destinations. The owned Testbox lease is stopped.The earlier composed-stack quiet/alert and saved-outcome proof remains here; that evidence belongs to its earlier pinned tree.
The material risk remains concurrency and lifecycle ordering. The second slice removes the separate monitoring execution/delivery route.