Repository navigation
fix(heartbeat): serialize wake lifecycle state - #116351
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 30, 2026, 7:42 AM ET / 11:42 UTC. ClawSweeper reviewWhat this changesThis PR splits heartbeat wake coordination into contracts, target-ordering, and lifecycle helpers so one canonical session is serialized, global immediate wakes create ordered barriers, and runner shutdown aborts active wake work. Merge readinessKeep this PR open for maintainer review. It addresses credible heartbeat scheduling and shutdown races with focused concurrency regressions and no concrete patch defect identified from the supplied final diff, but it carries the protected Priority: P1 Review scores
Verification
How this fits togetherHeartbeat wake requests arrive from timers, tasks, manual commands, and Gateway events, then the heartbeat coordinator decides their target ordering before a runner starts provider-backed work. This PR changes the coordinator’s session identity, barrier ordering, and cancellation propagation so active work is stopped safely when the runner or handler lifecycle ends. flowchart LR
A[Timers, tasks, manual requests, and events] --> B[Heartbeat wake requests]
B --> C[Canonical session target grouping]
C --> D[Global barrier ordering]
D --> E[Abortable wake lifecycle]
E --> F[Heartbeat runner]
F --> G[Provider-backed heartbeat turn]
G --> H[Session result or shutdown]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +193, Tests +253. Total +446 across 8 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the bounded coordinator refactor only after maintainer review confirms its target identity and generation-cancellation semantics against the current merge result, retaining the focused regressions as the contract for future scheduler changes. Do we have a high-confidence way to reproduce the issue? Do we have a high-confidence way to reproduce the issue? Source-reproducible with medium confidence: the added focused tests encode the reported duplicate-target, barrier, and cancellation races, but this read-only review did not independently execute a failing current-main reproduction. Is this the best way to solve the issue? Is this the best way to solve the issue? Yes, provisionally: serialization and cancellation belong at the shared heartbeat wake coordinator rather than in individual callers, and the extracted target and lifecycle helpers make those invariants explicit. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against fb6545738564. 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 (3 earlier review cycles) |
|
Merged via squash.
|
* origin/main: (99 commits) docs(automation): rename scheduled-tasks feature wording to Automations (#114855) feat(ui): finish cron -> Automations rename in visible strings (#114853) feat(cli): add openclaw automations alias and reword cron display prose (#114854) feat(agents): rename scheduler agent tool cron -> automations (#114841) fix(tui): preserve session state across switches and reconnects (#116399) feat(agents): report CLI command outcomes in channel progress fix(cli): preserve explicit option intent (#116389) fix(release): trust update restart harness (#116301) test(reef): remove false-green live guard smoke (#116393) test(comfy): evaluate live guards after setup (#116388) fix(heartbeat): serialize wake lifecycle state (#116351) test: remove redundant extension boundary wrapper (#116385) fix(test): bound Testbox agentic and extension suites (#115696) fix(ui): show the correct Threads page size (#116349) test(discord): align progress timing expectations (#116377) feat(ui): add composable skill references (#116330) fix(qa): prevent Slack cleanup from stalling profile runs (#116361) fix(ci): validate frozen release candidates faithfully (#116357) improve(ci): fail_fast option for release validation, off by default (#116352) fix(agents): compare shell tool names case-insensitively and stop re-parsing tool labels ...
* fix(heartbeat): serialize wake lifecycle state * style(heartbeat): format wake scheduler * refactor(heartbeat): split wake coordination * refactor(heartbeat): extract wake contracts
What Problem This Solves
Fixes three heartbeat lifecycle races: the same canonical session could run concurrently when callers supplied different agent/session tuple shapes, an unscoped immediate wake could overlap or starve behind targeted work instead of acting as a barrier, and stopping the heartbeat runner did not cancel active provider work.
Why This Change Was Made
Heartbeat scheduling now derives one session-first target identity, gives immediate global wakes an enqueue cutoff that separates pre-barrier from post-barrier work, and tears down active work by handler generation so stale disposers cannot cancel replacements. This is an AI-assisted change from a maintainer QA campaign.
User Impact
Operators no longer get duplicate concurrent turns for one session, global wake requests cannot be indefinitely postponed by newer targeted work, and Gateway shutdown stops active heartbeat turns before their dependencies disappear.
Evidence
0cycles, remotecheck:changedgreen, autoreview clean at0.98; exact-head CI: https://github.com/openclaw/openclaw/actions/runs/30539267063check:changed: passed core/coreTests formatting, typecheck, lint, dead-export, architecture, storage, and boundary guards.