Skip to content

fix: updates survive interrupted heartbeat runs - #195656

Merged
roboclaw-bot merged 3 commits into
mainfrom
roboclaw/pt-heartbeat-interrupted-run
Nov 9, 2026
Merged

roboclaw-bot merged 3 commits into
mainfrom
roboclaw/pt-heartbeat-interrupted-run

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes updates failing in post-install Doctor when Gateway shutdown leaves a legacy heartbeat run marker.

User Impact

Interrupted heartbeat runs can migrate during updates. Live or unproved work remains pending with a warning. Notification-producing recovery now converges through the next Gateway cron startup instead of repeatedly deferring or quarantining the legacy job. No schema, protocol, or config option changes.

Why This Change Was Made

Doctor revalidates its held offline maintenance owner and uses cron's existing recovery kernel. Ordinary interrupted runs settle before conversion. When recovery needs live notification dispatch, only that recovery attempt rolls back to its savepoint; Doctor still commits the ordinary payload conversion with the original run marker, history, and receipt intact. Gateway startup can then decode the row and use its normal recovery and notification path. Both fresh conversion and resumed config retirement retain the pending execution facts when they disable the monitor, so startup restores its recorded result without re-enabling it.

The live/unproved refusal remains update-advisory because its conversion transaction and config writer do not commit. Lost maintenance authority and integrity failures retain their existing failure behavior. The candidate contains the repair; published updater parents need no new marker.

Evidence

  • Deep10 Windows cell: 2026.9.3 → candidate, installed-schtasks, FAIL, activating / post-install Doctor, natural updater exit 1 after 301,480 ms. Original production source: a35b92ce. Windows run 42555488755. Receipt names: deep10/windows/2026.9.3/verified.json, deep10/windows/2026.9.3/doctor.stderr-tail.txt, deep10/windows/2026.9.3/exception.json, deep10/windows/source-owner-audit.md; report: deep10.md, Windows section. The retained evidence does not establish whether the run was live or abandoned.
  • The update-Doctor table covers stopped, live, unproved, notification-producing, disable-during-conversion, and disable-during-resumed-cutover cases. The last two preserve the pending marker through disablement, then check the restored last-run timestamp/status/error/duration, a ten-failure counter, one unchanged history entry, disabled state, and no quarantine after startup. General config preflight and native service transport remain fixtures; a full native Windows upgrade is unverified.
  • CI run 42560047339, job 128974686985 failed in the PR's live-owner fixture: runtime-pin migration was seeded after acquiring live Gateway custody. The seed now runs before acquisition; the live lock and refusal/warning assertions are retained.
  • Touched-file typecheck, lint, formatting, and git diff --check: pass. Local runtime execution/base-red replay were withheld because the worktree has no compiled-worker cache and cold compilation is prohibited on the production host. Runtime proof comes from the exact-head CI result below; no local runtime pass is claimed.
  • Prior-head CI job 128983146071 passed all four PT2 cases at 15a64839b6b5; it is baseline evidence, not proof of the new disablement cases. Exact-head PT3 CI job 128991072735, checks-node-changed-compact-large-25: PASS. Its log confirms all six heartbeat cases passed, including fresh disablement (6.640 s) and resumed disablement (6.837 s); all three planned invocations completed with zero failures. Other CI status remains separate from this focused proof.
  • Fresh Codex autoreview, P0–P2, complete PT3 candidate against 15a64839b6b5aa6066ffbddec86ed7a04d5e994e with full conversion/retirement/test context: scoped-clean, no actionable findings. Full package-upgrade proof remains outside that static assessment. No hosted re-review request or comments were posted.
  • Simplification: no change to ordinary cron edit policy or recovery ownership. The two Doctor finalizer callers preserve the existing three execution facts until cron settles them. PT3 adds 18 production lines and 36 regression lines; the full PR adds 150 production lines and 266 regression lines. Separate allocations grant exactly 136 + 94 + 36 test lines; the shared scalar is unchanged.

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: M labels Nov 9, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR recovers interrupted legacy heartbeat runs during Doctor migration and reports safe deferrals as update warnings.

Example: An offline Gateway leaves automation interrupted-monitor with a persisted runningAtMs marker.

  • Before: Doctor rejects the marker and fails the update.
  • After: Doctor uses cron recovery to record the interruption, clear the marker, and convert the job to an ordinary automation.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair has clear value, but the recovery loop, diff-caused test failure, and missing upgrade proof prevent a pass.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An update fails in post-install Doctor after Gateway shutdown leaves a legacy heartbeat run marked as running.
Reason: Recovering abandoned work through existing maintenance and cron owners has clear value, and the collaborator-authored PR establishes the repair direction.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR addresses a current update failure, but its notification deferral cannot complete through Gateway recovery, and an added test causes the required CI shard to fail.

Priority: P1
Reviewed head: 4a9dd82d4190dfe766e202c23957671b01be9117

Before merge

  • Provide a recovery path that can consume the retained heartbeat row (P2) - When recovery produces a notification—for example, replaying a finalized recurring failure that reaches the ten-failure auto-disable threshold—this branch rolls back and tells the operator to restart Gateway. The row still has payload.kind=heartbeat, which persisted-shape.ts rejects; run-recovery.worker.ts therefore excludes it from the jobs passed to recoverCronJobInDatabase. Restarting cannot clear that job's marker or emit its job notification, and the next Doctor pass defers again. Complete the conversion with a supported notification handoff, or provide a recovery operation that actually accepts this retained legacy row.
  • Seed runtime-pin migration before acquiring the live Gateway lock (P2) - In the live-owner table case, acquireGatewayLock runs before this seed call. seedCompletedRuntimePinMigration then attempts exclusive migration custody and fails against the fixture's live owner, so the test never exercises runDoctor or its successful warning result. The exact-head failed CI shard reports this call at line 263. Move the seed before acquiring live custody while retaining the live lock through the refusal assertions.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Provide a recovery path that can consume the retained heartbeat row — src/commands/doctor-heartbeat-run-recovery.ts:78-82
  • [P2] Seed runtime-pin migration before acquiring the live Gateway lock — src/flows/doctor-health.legacy-update.test.ts:262-263

Tests

  • Missing end-to-end proof: Supply a shipped Doctor/update run covering recovery, notification preservation, unchanged config on deferral, repeat execution, and upgrade from latest stable; base-red/head-green regression evidence is also absent.
Agent review details

How this fits together

Update invokes candidate Doctor, which holds maintenance custody while converting legacy heartbeat configuration and stored jobs into ordinary Automations.

flowchart TD
  A[Update command] --> B[Candidate Doctor]
  B --> C[Offline maintenance custody]
  C --> D[Heartbeat migration]
  D --> E[Cron recovery kernel]
  E --> F[Stored jobs and run history]
  D --> G[Config cutover]
  B --> H[Update result and warnings]
Loading

Technical review

Best possible solution:

Keep recovery in cron and conversion in Doctor, provide a working notification handoff, and initialize migration fixtures before acquiring live Gateway custody.

Do we have a high-confidence way to reproduce the issue?

Current main deterministically rejects runningAtMs during heartbeat conversion without distinguishing an abandoned marker from live work; source inspection establishes that path, while no local runtime reproduction was performed.

Is this the best way to solve the issue?

Reusing cron recovery under existing maintenance custody is the right repair boundary, but the notification handoff and fixture ordering need correction.

Full review comments:

  • [P2] Provide a recovery path that can consume the retained heartbeat row — src/commands/doctor-heartbeat-run-recovery.ts:78-82
    When recovery produces a notification—for example, replaying a finalized recurring failure that reaches the ten-failure auto-disable threshold—this branch rolls back and tells the operator to restart Gateway. The row still has payload.kind=heartbeat, which persisted-shape.ts rejects; run-recovery.worker.ts therefore excludes it from the jobs passed to recoverCronJobInDatabase. Restarting cannot clear that job's marker or emit its job notification, and the next Doctor pass defers again. Complete the conversion with a supported notification handoff, or provide a recovery operation that actually accepts this retained legacy row.
    Confidence: 0.97
  • [P2] Seed runtime-pin migration before acquiring the live Gateway lock — src/flows/doctor-health.legacy-update.test.ts:262-263
    In the live-owner table case, acquireGatewayLock runs before this seed call. seedCompletedRuntimePinMigration then attempts exclusive migration custody and fails against the fixture's live owner, so the test never exercises runDoctor or its successful warning result. The exact-head failed CI shard reports this call at line 263. Move the seed before acquiring live custody while retaining the live lock through the refusal assertions.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 594190c75e5d.

Provenance checked

  • Running heartbeat conversion changes intended behavior with a stated reason (ec5d369: Preserve the execution boundary when transferring legacy heartbeat jobs into ordinary Automations.)
  • Successful deferred-update warnings changes intended behavior with a stated reason (581f691: Allow safe maintenance deferrals while keeping incomplete writes, unreadable state, and lost authority fatal.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/flows/doctor-health.legacy-update.test.ts --maxWorkers=1
  • pnpm test src/commands/doctor-heartbeat-cadence-migration.test.ts --maxWorkers=1
  • Verify base-red/head-green coverage for notification recovery and all three custody outcomes.
  • Exercise shipped Doctor/update from latest stable and the reported older Windows release, preserving configuration, job identity, history, notifications, and repeat-run behavior.
  • Run touched-file typecheck, lint, formatting checks, and git diff --check.

What I checked:

PR surface

Source +110, Tests +136, Docs +7, Other +3. Total +256 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 117 7 +110
Tests 1 137 1 +136
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 6 264 8 +256

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression changes Production +117/-7; tests +137/-1 The production growth adapts the existing recovery kernel and warning path; the tests target three distinct custody outcomes.

Labels

Label changes:

  • add P1: A persisted legacy run marker can fail the post-install Doctor step and interrupt an otherwise supported update.
  • add merge-risk: 🚨 compatibility: A retained legacy job requiring a startup notification cannot complete migration through the Gateway restart recommended by the patch.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: A persisted legacy run marker can fail the post-install Doctor step and interrupt an otherwise supported update.
  • merge-risk: 🚨 compatibility: A retained legacy job requiring a startup notification cannot complete migration through the Gateway restart recommended by the patch.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 8, 2026, 11:25 PM ET / November 9, 2026, 04:25 UTC.

@roboclaw-bot
roboclaw-bot merged commit 92798ae into main Nov 9, 2026
153 checks passed
@roboclaw-bot
roboclaw-bot deleted the roboclaw/pt-heartbeat-interrupted-run branch November 9, 2026 05:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
* fix: updates survive interrupted heartbeat runs

* fix: make heartbeat recovery notifications converge

* fix: retain heartbeat recovery when migration disables jobs

---------

Co-authored-by: roboclaw-bot <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…aw#194058)

Failed-update triage now captures the operator's environment before managed candidate admission, so a coding agent installed only on the operator's PATH is still offered when the Gateway service's PATH differs. Restores the operator-environment contract from openclaw#134490 and keeps the launch confirmation from openclaw#143139.

Proof: shipped CLI on isolated Linux (Crabbox) with a running systemd Gateway: accept launches the operator-only agent, decline starts nothing, base 18bee8e reports no agent found; published 2026.11.1 upgrades to the fix with settings intact.

Co-authored-by: TorstenW <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: steipete <[email protected]>

(cherry picked from commit 7c702c3)

Release adaptation: Capture invoking operator env before candidate admission, forward to interactive triage only; preserve latest target selectors, confirmation and lease cleanup ordering. Exact three authorized production paths plus real lifecycle regression.

Follow-up dispositions: ad4863d fix: preserve the running installation when an agent updates its Gateway (openclaw#201570); dc73ec0 fix: let updates finish when another tool briefly reads OpenClaw's databases (openclaw#202541); d07b530 fix: clarify PostgreSQL schema upgrades for Git installs (openclaw#202098); e60ea9f test(update): add a Git release upgrade-survivor scenario (openclaw#201956); 2ef6f7b fix(update): build and serve Git releases outside node_modules (openclaw#201917); dbc1aa0 fix: keep the openclaw command and Gateway working after updating a pnpm install (openclaw#201735); f5e7641 fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts (openclaw#201600); 2183caf fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database (openclaw#201463); 47e8649 fix: explain why Doctor cannot restore a scheduled job’s account (openclaw#201550); 8f2cfd4 fix: remove updater-only restrictions from agent maintenance guidance; cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 24cb734 fix: keep carried-over scheduled jobs running after updates (openclaw#200653); d1276e1 feat(doctor): check OpenClaw ID member roles and honor an optional roles default (openclaw#197785); 0a39956 fix: finish updates when another tool reads OpenClaw's databases during the update (openclaw#201330); ea1c9d5 fix(update): settle remounted package publications before admission (openclaw#201336); 66b5212 fix(update): isolate malformed retained-install markers (openclaw#201199); 7e79c83 fix: let the next update finish a killed source checkout update (openclaw#201009); d905d8a fix: let the next update finish a killed update after the machine restarted (openclaw#200994); fdf0c95 fix: let the next update finish a killed update that had already installed the new version (openclaw#200866); 0c19bcd chore(release): close out 2026.11.5 on main (openclaw#200577); a1940e0 fix(matrix): keep explicit recovery available during deferred migration (openclaw#200805); 18b4776 improve: explain package baseline drift during updates (openclaw#200802); 1ad4cad fix(doctor): reclaim macOS updater runtimes blocked by non-updater processes (openclaw#200732); 427c857 fix: keep one missing archived transcript from blocking every update (openclaw#200733); 802e3f7 fix(update): keep valid cold archives from blocking updates (openclaw#200659); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); 3afe212 fix: let Doctor publish unchanged plugin migrations in any order (openclaw#200658); f65e4db fix(doctor): reclaim runtimes blocked by unrelated Linux processes (openclaw#200657); dab086c fix(update): let candidate Doctor read plugin dependencies from the staged package (openclaw#200595); 3447bee fix(update): keep updates going when the predecessor writes during its stop (openclaw#200569); 0ce9c77 fix: let the next update settle a package publication that a killed update left behind (openclaw#200550); ae31ea3 fix(update): repair handoffs in the journal-pinned lease store (openclaw#200532); 74020ea fix: continue updates when initial SQLite capture is stale (openclaw#200328); 6747b1e feat(update): run Git checkout installs from releases behind the release link (openclaw#199706); e3f8a67 fix(state): keep completed retained agent stores out of startup upgrade (openclaw#200284); 3c512c5 fix(gateway): move managed update lease operations off the main thread (openclaw#200169); ea69fcb chore(release): close out 2026.11.4 on main (openclaw#199956); 618bf31 fix(state): bound startup upgrade copies and pruning to owned state (openclaw#199929); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); 5dbf569 fix(update): plugin failures never fail an update or Gateway health; 764761e fix(update): refuse missing host prerequisites in one line and record a cause per attempt; 4c4fef4 fix(ui): update dialog claims installation before progress is confirmed (openclaw#199254); 136e1f6 fix(update): retrying an update from a dev checkout is refused after a killed update (openclaw#198673); 3bd03da fix(update): avoid duplicate database copies while the Gateway is stopped (openclaw#198148); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); e333f7e chore(ci): drop retired test-lines allocation records (3/3) (openclaw#197657); fd6fa47 fix: converge Gateway updates with environment-only service overrides (openclaw#196371); 7cf5e75 fix: clarify split-install updates and blocked Doctor repairs (openclaw#196342); 6ff8c86 fix(update): retain lazy sqlite catalog generation (openclaw#197095); 930e1f7 fix: keep stable updates and recovery free of premature migrations (openclaw#196474); a15f737 fix: preserve external plugin data during update rehearsal (openclaw#196301); 92798ae fix: updates survive interrupted heartbeat runs (openclaw#195656); c1e55e2 fix(update): restore LaunchAgent registration after repair contention (openclaw#195406); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685); 689cfc8 fix(update): reclaim dead closing triage repair leases (openclaw#194503); 86bc89e fix(doctor): keep standing Codex parameter advice out of retirement blockers (openclaw#193650); 691bc8d fix(backup): read the backup engine without copying the live database (openclaw#194234); 000542f fix(backup): backups and updates fail on slow storage when a header probe batch misses its deadline (openclaw#194239); 31a65d5 fix(update): skip --no-lazy-fetch on Git versions without it (openclaw#194198); e45e99d fix(update): preserve dev update sources in tag-only Git clones (openclaw#193109)

Validation: Baseline2 intended operator-agent failures/32 controls passed; candidate34/34passed (194058-green.log). Accept launches synthetic operator-only CLI with expected env, decline starts nothing. Isolated updater flow, not live systemd/upgrade qualification.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 6689fd575ada8fe40a9593784deac18ec73041cd)
(cherry picked from commit 92e7a9fa223b0dc35801f25f70be90b472d9a6b7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant