Skip to content

fix(snapshot): stop restores from restarting sibling gateways - #112

Merged
hannesrudolph merged 2 commits into
openclaw:mainfrom
hannesrudolph:fix/targeted-snapshot-restore
Aug 26, 2026
Merged

fix(snapshot): stop restores from restarting sibling gateways#112
hannesrudolph merged 2 commits into
openclaw:mainfrom
hannesrudolph:fix/targeted-snapshot-restore

Conversation

@hannesrudolph

@hannesrudolph hannesrudolph commented Aug 26, 2026

Copy link
Copy Markdown
Member

Closes #111

What Problem This Solves

Fixes an issue where restoring one OCM environment could restart unrelated
running gateways when their persisted supervisor specifications had latent
drift.

This affected both direct snapshot restores and automatic rollback after a
failed upgrade. A target-scoped recovery could therefore interrupt unrelated
agent conversations and channel delivery.

Why This Change Was Made

When the shared supervisor daemon is already running, snapshot restore now
reconciles only the restored environment. Unrelated persisted child
specifications, skip entries, restart requests, and running processes are
preserved.

The stopped-daemon safety boundary remains unchanged: starting a stopped shared
daemon still performs full-fleet reconciliation before activation, so stale
sibling definitions are not launched.

User Impact

Operators can restore or automatically roll back one environment without
restarting sibling gateways. The restored target still receives its snapshot
state and converges normally.

Evidence

Production failure

During a failed Main upgrade rollback on August 26, 2026:

  • OCM restored Main's checkpoint.
  • The rollback path performed a fleet-wide supervisor sync.
  • The daemon logged reloading rescue.
  • Rescue was stopped at 10:50:29 AM MDT and replaced at 10:50:42 AM MDT.
  • Main was the selected rollback target; Rescue was unrelated.

OCM did not retain the exact Rescue specification field that differed. The
causal rollback path and sibling reload are directly recorded.

Regression coverage

Real-daemon tests introduce latent sibling specification drift and verify that
both restore paths preserve the sibling PID and persisted specification:

  • direct snapshot restore
  • automatic rejected-upgrade rollback

The tests also verify that the selected environment restores and converges
correctly.

Validation

  • cargo fmt --all -- --check
  • cargo test --test daemon_runtime_tests --locked -- --test-threads=1
    • 33 passed
  • cargo test --test env_snapshot_tests --locked -- --test-threads=1
    • 36 passed
  • cargo test --test upgrade_command_tests --locked -- --test-threads=1
    • 49 passed
  • cargo check --workspace --all-targets --locked
  • cargo build --release --locked
  • cargo test --all-targets --locked -- --test-threads=1 --skip bin_wrapper_runs_with_an_overridden_home

The skipped wrapper test requires rustup; this host uses Homebrew Rust and
does not have rustup. Every executed test passed, and all GitHub CI checks are
green.

Worked on by

  • Hannes Rudolph

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 3:48 PM ET / 19:48 UTC.

ClawSweeper review

What this changes

The PR makes snapshot restore and rollback refresh only the restored environment in the shared supervisor, with regressions that preserve unrelated gateways.

Regression provenance

Possible regression — probable (reproduction; reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this member-authored PR open for normal merge review. It narrowly fixes the source-proven recovery isolation bug with real-daemon regressions for both direct restore and failed-upgrade rollback.

Priority: P1
Reviewed head: 65a293b79afdce5622b4f0f3ca843a5ab72fdca7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow reuse of established targeted synchronization with realistic daemon regressions; pending platform CI is the remaining merge check.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The PR is authored by a repository member; its body nevertheless reports after-fix real-daemon regression runs for both recovery paths.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is authored by a repository member; its body nevertheless reports after-fix real-daemon regression runs for both recovery paths.
Evidence reviewed 4 items Targeted restore paths: All three snapshot-recovery paths capture the target environment name and call the targeted supervisor synchronizer after restore or rollback.
Existing target-merge semantics: The targeted synchronizer merges refreshed target state with persisted non-target children, skipped entries, and restart requests; it was introduced by the merged sibling-preservation work.
Stopped-daemon safeguard: Daemon activation still performs a full synchronization before installation when it is not running, preserving the fleet-wide safety boundary.
Findings None None.
Security None None.

Live Verification

Command: cargo test --test daemon_runtime_tests --locked snapshot_restore_preserves_running_sibling_despite_unrelated_drift -- --test-threads=1

Result: FAIL (failed) — execution before step 1 run: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

Assertions:

  • FAIL expect_output: test snapshot_restore_preserves_running_sibling_despite_unrelated_drift ... ok
  • FAIL expect_output: test failed_upgrade_rollback_preserves_running_sibling_despite_unrelated_drift ... ok

How this fits together

OCM restores one environment’s snapshot or upgrade state and then reconciles it with the shared gateway supervisor. The supervisor’s persisted child specifications control whether running gateway processes are retained or restarted.

flowchart LR
A[Snapshot restore or failed upgrade] --> B[Restore target environment]
B --> C[Targeted supervisor sync]
C --> D{Supervisor daemon running?}
D -->|Yes| E[Update target child only]
D -->|No, later activation| F[Full fleet reconciliation]
E --> G[Sibling gateways retained]
F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Recovery-path supervisor synchronization can affect live gateway availability; the pending macOS and Ubuntu jobs should pass before merge.
  • Complete next step (P2) - Normal PR review: no discrete repair is needed; await completion of the pending platform checks.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Focused code and regression coverage 7 production lines changed; 404 test lines added across 2 files The implementation is narrow while daemon-backed cases cover direct restore and failed-upgrade rollback.

Merge-risk options

Maintainer options:

  1. Confirm recovery isolation on CI (recommended)
    Wait for the macOS and Ubuntu test jobs to complete successfully, confirming that target restore cannot interrupt an unrelated running gateway.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require the pending macOS and Ubuntu test jobs to pass on this head.

Technical review

Best possible solution:

Merge after the platform test jobs confirm the targeted-recovery regressions and existing stopped-daemon full-sync behavior.

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

Yes—source and two daemon-backed regression scenarios establish a concrete path: restore one environment while a sibling has latent supervisor-spec drift and verify its runtime state remains unchanged.

Is this the best way to solve the issue?

Yes—the patch reuses the established target-only supervisor merge rather than adding a parallel mechanism, while retaining full synchronization for later stopped-daemon activation.

AGENTS.md: not found in the target repository.

Codex review notes: model internal, reasoning high; reviewed against cd8decaf04f2.

Labels

Label changes:

  • add P1: A failed upgrade or target snapshot restore can restart an unrelated gateway and interrupt active channel delivery.
  • add merge-risk: 🚨 message-delivery: Recovery-path synchronization determines whether unrelated gateways remain available for ongoing conversations.
  • add merge-risk: 🚨 availability: Incorrect reconciliation could restart or stop a sibling gateway process.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is authored by a repository member; its body nevertheless reports after-fix real-daemon regression runs for both recovery paths.

Label justifications:

  • P1: A failed upgrade or target snapshot restore can restart an unrelated gateway and interrupt active channel delivery.
  • merge-risk: 🚨 message-delivery: Recovery-path synchronization determines whether unrelated gateways remain available for ongoing conversations.
  • merge-risk: 🚨 availability: Incorrect reconciliation could restart or stop a sibling gateway process.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is authored by a repository member; its body nevertheless reports after-fix real-daemon regression runs for both recovery paths.

Evidence

What I checked:

  • Targeted restore paths: All three snapshot-recovery paths capture the target environment name and call the targeted supervisor synchronizer after restore or rollback. (src/env/snapshots.rs:197, 65a293b79afd)
  • Existing target-merge semantics: The targeted synchronizer merges refreshed target state with persisted non-target children, skipped entries, and restart requests; it was introduced by the merged sibling-preservation work. (src/supervisor/mod.rs:321, 035686953c68)
  • Stopped-daemon safeguard: Daemon activation still performs a full synchronization before installation when it is not running, preserving the fleet-wide safety boundary. (src/supervisor/mod.rs:480, 65a293b79afd)
  • Daemon-backed regressions: The added tests inject sibling desired-spec drift, perform direct restore and failed-upgrade rollback, and assert the sibling spec, PID, binding, stop marker, and start count remain unchanged. (tests/daemon_runtime_tests.rs:521, 65a293b79afd)

Likely related people:

  • hannesrudolph: Introduced the merged targeted supervisor preservation work and authored this snapshot extension. (role: recent area contributor; confidence: high; commits: 035686953c68, 65a293b79afd; files: src/supervisor/mod.rs, src/env/snapshots.rs, tests/daemon_runtime_tests.rs)
  • Shakker: History shows the largest contribution volume across the supervisor, snapshot, and daemon-runtime test surfaces. (role: major adjacent contributor; confidence: medium; commits: 7e110ae25c82, a1a96398f837; files: src/supervisor/mod.rs, src/env/snapshots.rs, tests/daemon_runtime_tests.rs)
  • Jason (Json): Authored the merged atomic snapshot-restore implementation extended by this change. (role: snapshot feature contributor; confidence: medium; commits: 5971574bd605; files: src/env/snapshots.rs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the in-progress macOS and Ubuntu test jobs complete successfully.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@hannesrudolph hannesrudolph changed the title fix(snapshot): preserve sibling gateways on restore fix(snapshot): stop restores from restarting sibling gateways Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(snapshot): stop restores from restarting sibling gateways This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@hannesrudolph

Copy link
Copy Markdown
Member Author

Thanks for the review. A few factual clarifications for the current head 2eb4c5d9f86d1babe6b0a392a8235adc79d37a58:

  • The review identified no actionable code or security findings.
  • The reported Live Verification: FAIL was not a Rust test failure. ClawSweeper stopped during its generic setup step when Corepack attempted to download pnpm, before the requested cargo test command or either assertion ran.
  • Both named real-daemon regressions passed locally, and all CI checks passed on the reviewed code head 65a293b.
  • The two listed remaining items are process gates—platform CI completion and normal maintainer review—not defects in the patch.
  • Current head 2eb4c5d adds only the repository PR template and rewrites the PR description; the production fix is unchanged. Current CI is green except for the macOS test job, which is still running.

Please reflect those distinctions in the fresh review of 2eb4c5d so setup failure is not presented as a failed behavioral test.

@hannesrudolph
hannesrudolph merged commit c4365f1 into openclaw:main Aug 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed upgrade rollback reloads unrelated supervised gateways

1 participant