Skip to content

feat(update): recover failed updates with bounded repair - #139495

Merged
steipete merged 15 commits into
mainfrom
steipete/update-repair-integration
Sep 6, 2026
Merged

steipete merged 15 commits into
mainfrom
steipete/update-repair-integration

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #124396 (transactional update flow), #137580 (update outage), #136997 (no-op update restart).

PR D (#138839) has landed. This branch is based on main and the diff is now E-only: it connects the bounded repair capability from #138738 to transactional updates.

What Problem This Solves

Resolves a problem where a candidate that fails validation, or an activated installation that cannot safely roll back after verification fails, has no bounded repair attempt in the update flow. Managed updates also need to deliver the activating notice before parking the serving Gateway and report completed handoffs without a misleading failure excerpt.

Why This Change Was Made

The deterministic update orchestrator invokes bounded repair using the operator's configured inference. Before activation, the candidate-rehearsal owner supplies disposable configuration, state, workspace, home, and temporary paths shared by repair and validation. Candidate-root repairs can proceed to activation, but configuration changes are not promoted: repair-requires-config-change reports the changed top-level keys for operator action. After activation, inference runs in a candidate-owned IPC worker, while the parent retains service ownership, validation, cancellation, and transaction settlement.

Both repair paths carry the requester predicate owned by src/infra/update-requester-authority.ts. It is revalidated before tool effects, including after pending inference, and a revoked requester stops with requester-revoked. Rehearsal environment overrides are limited to isolation paths and pass through the existing host-env sanitizer; executable lookup and inherited credentials remain host-owned.

Recovery returns through the shared restart step so a repaired candidate continues plugin convergence. Failed repair preserves rollback refusal reasons; repair of a restored previous generation remains a rollback outcome. Windows settlement uses the current service-stop owner. The helper's before-park marker waits for the activating notice, and completed handoff steps no longer carry an Exit code: unknown failure excerpt.

User Impact

CLI, chat, Control UI, and unattended update runs can attempt bounded repair while the orchestrator retains installation and service lifecycle authority. A rejected staged candidate leaves serving configuration and state unchanged. Revoked chat authority cannot retain repair tool access. Operators see attempts and precise stop reasons in the ledger, reports, and notices, with openclaw doctor --fix or openclaw triage guidance when configuration needs an operator change.

No new config keys or schema changes.

Evidence

The CI repair declares the helper lifecycle suite's runtime prerequisite and preserves config/plugin load errors while denying effects; regressions reproduce both failures, and extracting database-context inspection and Windows error composition keeps the updater within the existing lint limit.

The two ClawSweeper P1 findings are repaired at their owners:

  • Staged isolation: src/infra/update-candidate-rehearsal.ts and src/cli/update-cli/update-command-repair.ts; staged CLI repair isolation > discards config and doctor repairs without changing serving files verifies live-file bytes, inode, and mtime remain unchanged and reports repair-requires-config-change. Its sibling keeps candidate-root repairs eligible for activation protects activation of a candidate-only repair.
  • Requester authority: src/infra/update-requester-authority.ts, carried through the CLI repair and candidate worker. The built-helper lifecycle cases guards validating/verifying repair effects with the current chat requester (revoked=false/true) exercise both paths. Allowed runs record repair and execute the second spawn, command, and write. Revocation while inference is pending prevents those second effects and records requester-revoked.

The exact-head CI failures were traced to two owners. The helper test-support cycle is removed by a shared leaf contract; both import-cycle checks reproduced the original failure and pass after the fix. Both Opengrep OSS and Scan changed paths reported the same openclaw-skill-env-host-injection finding in the repair runtime. The saved scan log's update-cli.test.ts entries are timeout warnings, not a credential finding. The new repair rehearsal environment > keeps disposable selectors but rejects hostile overrides before child execution regression fails on the old runtime when a synthetic loader override reaches a real child; it passes with the sanitizer and restricted overrides. The helper recorder uses explicit Node arguments for its exact relay/anchor workers, so the proof remains observable after NODE_OPTIONS is scrubbed. Requester checks use the same stable built daemon entry as production, avoiding source-plugin compilation inside the test deadline. No assertion or timeout was weakened, and no scanner suppression, baseline, or allowlist was changed.

Earlier local proof: the 49-file focused run passed 1,348 tests with one platform skip. All four built-helper allowed/revoked cases passed in both the focused harness run and the broader suite. Full pnpm check:changed, all three Knip export scans, and both import-cycle checks passed. pnpm build passed before and after the main rebase with zero [INEFFECTIVE_DYNAMIC_IMPORT] warnings. Branch and final-candidate Codex reviews were clean at P0/P1.

The earlier repair E2E run passed both staged-isolation cases and the existing validating case. The existing verifying case failed its expected repair-summary assertion: the repaired marker and successful oracle were present, but supervisor cleanup returned service child cleanup identity lost: write EPIPE, replacing the final summary. The same failure appeared again during global cleanup. This is the separate suspected EPIPE race documented in #139887, not an all-assertions-passing EPERM-only teardown. No assertion, timeout, or process-supervisor code was changed to conceal it. CI passed for d4b18e843258 (run 34027969226).

Historical campaign-branch proof, not rerun here: run 9 at source 8a4db45aff4 passed 90 assertions across seven scenarios (preflight, success, webchat, noop, poison, canary, rollback), with mechanicsPass=true. The poisoned canary attempted repair while preserving the serving old PID; the poison-download E500 failed before repair. Acknowledgement, activating, verifying, and terminal notices were observed.

The macOS process-supervisor teardown limitation is tracked separately in #139887. Its standalone reproduction does not require repair code. Linux CI remains the arbiter for that cleanup path; the repair changes do not weaken teardown assertions or alter src/process/*.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations size: XL maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 23:09
@steipete steipete closed this Sep 5, 2026
@steipete steipete reopened this Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 7:01 AM ET / 11:01 UTC.

ClawSweeper review

What this changes

Adds bounded model-assisted recovery to failed updates, with disposable candidate repair, updater-controlled service recovery, and operator-visible attempt reports.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open as useful, maintainer-owned work. The earlier isolation and requester-authority findings are addressed, and no remaining blocking defect was established. The previous generic compatibility warning does not identify an additional unresolved contract change.

Priority: P2
Reviewed head: d4b18e843258254f95777d49c8eb4e58854eb525

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful integration with meaningful production-boundary proof and repaired prior findings; no additional blocking patch defect was found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Reported built-helper runs exercise the production repair entrypoint and real local HTTP inference client in both phases: allowed requesters produce later spawn/write effects, while revocation during pending inference prevents them. Staged-isolation runs preserve serving files and reject config promotion; the separately disclosed macOS EPIPE failure is not counted as a passing case.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Reported built-helper runs exercise the production repair entrypoint and real local HTTP inference client in both phases: allowed requesters produce later spawn/write effects, while revocation during pending inference prevents them. Staged-isolation runs preserve serving files and reject config promotion; the separately disclosed macOS EPIPE failure is not counted as a passing case.
Evidence reviewed 10 items Pinned introduction and review continuity: The local merge-base-to-head diff supplies all 95 introduced paths, overcoming the supplied file-list truncation. HEAD matches the previous completed review revision; its empty findings and historical compatibility next step were evaluated against current source. The stale test merge was not used to infer removals.
Automatic integration remains absent on inspected main: Current main’s candidate callback returns failed validation steps without invoking bounded repair. The merged prerequisite #138839 explicitly leaves automatic repair integration to subsequent work, so it does not supersede this PR.
Existing repair owner and historical routing: Main history identifies the standalone configured-inference repair work at d12357e, authored by Peter Steinberger. Its recorded commit message explicitly separates later updater integration. This also corrects the PR body’s unrelated prerequisite link to #138738; the repair history names #138673.
Findings None None.
Security None None.

How this fits together

OpenClaw’s updater receives CLI or Gateway update requests, validates a candidate installation, and controls activation and recovery. Repair uses configured inference, while independent checks determine whether the installation can proceed or must report failure.

flowchart TD
  A[CLI or Gateway update request] --> B[Stage and validate candidate]
  B --> C{Validation passes}
  C -->|No| D[Bounded repair in disposable state]
  D --> B
  C -->|Yes| E[Activate and verify installation]
  E --> F{Recovery needed}
  F -->|Yes| G[Rollback or bounded installed repair]
  F -->|No| H[Record verified outcome]
  G --> H
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test growth Production net +1,905 lines; tests and test support net +3,300; tooling net +4 Production growth implements repair orchestration, isolated execution and lifecycle ownership; the larger validation surface covers their failure boundaries.
Requester authority scenarios 4 allowed/revoked scenarios across 2 repair phases The proof checks actual later spawn, command and file effects after authorization changes during inference.

Stored data model

Persistent data-model change detected: migration/backfill/repair: scripts/lib/vitest-build-prerequisites.mts, migration/backfill/repair: src/cli/update-cli/update-command-execution.ts, migration/backfill/repair: src/cli/update-cli/update-command-post-update.ts, migration/backfill/repair: src/cli/update-cli/update-command-repair-service.ts, migration/backfill/repair: src/cli/update-cli/update-command-repair.ts, migration/backfill/repair: src/infra/runtime-process-entrypoints.ts, and 10 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep repair inside the existing updater lifecycle, with disposable pre-activation state, current requester checks at effects, and independent verification deciding every recovery outcome.

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

Not applicable as a new recovery capability; current main’s validation callback establishes the missing integration, and the supplied boundary runs exercise repaired and revoked outcomes.

Is this the best way to solve the issue?

Yes. Reusing the existing repair loop while retaining deterministic validation, isolated rehearsal and updater-owned lifecycle control is a coherent extension; the prior concrete findings are addressed.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9c56ee41de73.

Labels

Label justifications:

  • P2: This is a bounded recovery improvement for failed updates, with no newly established urgent regression.
  • 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. Sufficient (terminal): Reported built-helper runs exercise the production repair entrypoint and real local HTTP inference client in both phases: allowed requesters produce later spawn/write effects, while revocation during pending inference prevents them. Staged-isolation runs preserve serving files and reject config promotion; the separately disclosed macOS EPIPE failure is not counted as a passing case.
  • proof: sufficient: Contributor real behavior proof is sufficient. Reported built-helper runs exercise the production repair entrypoint and real local HTTP inference client in both phases: allowed requesters produce later spawn/write effects, while revocation during pending inference prevents them. Staged-isolation runs preserve serving files and reject config promotion; the separately disclosed macOS EPIPE failure is not counted as a passing case.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-06T01:56:11.178Z sha ffdc2a6ee078201fccd8919e066e4ee32cec8a9c :: needs real behavior proof before merge. :: [P1] [P1] Keep staged repair commands off the serving installation's state | [P1] [P1] Revalidate the chat requester before repair tool effects
  • reviewed 2026-09-06T02:22:57.806Z sha ce6c31b :: needs real behavior proof before merge. :: [P1] [P1] Keep staged repair commands off live installation state | [P1] [P1] Revalidate the chat requester before repair tool effects
  • reviewed 2026-09-06T02:41:07.162Z sha ce6c31b :: needs real behavior proof before merge. :: [P1] Keep staged repair commands off live configuration and state | [P1] Revalidate the chat requester before repair tool effects
  • reviewed 2026-09-06T07:29:29.570Z sha 46d540e :: blocked before merge. :: none
  • reviewed 2026-09-06T08:47:59.337Z sha d09aed8 :: blocked before merge. :: none
  • reviewed 2026-09-06T09:52:04.393Z sha e8504dcbde52e81c2848c38554e0544bb59e2b00 :: blocked before merge. :: none
  • reviewed 2026-09-06T10:05:00.272Z sha ec44c83 :: blocked before merge. :: none
  • reviewed 2026-09-06T10:42:52.367Z sha d4b18e8 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 6, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 6, 2026
@steipete
steipete force-pushed the steipete/update-repair-integration branch from ee7e4c6 to b39ca93 Compare September 6, 2026 01:23
@steipete steipete closed this Sep 6, 2026
@steipete steipete reopened this Sep 6, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 6, 2026
@steipete
steipete force-pushed the steipete/update-repair-integration branch from ffdc2a6 to f452852 Compare September 6, 2026 02:10
The regression "settles Windows recovery after candidate repair and plugin activation" failed for both terminal outcomes because the latest suspension retained signal listeners and an exit gate. Resolve the same current stop for restoration, plugin maintenance, and final settlement. Both cases and 103 surrounding tests now pass.
Run pre-activation repair against a disposable rehearsal shared by every
turn and oracle. Reject required config edits without promoting copies,
then independently validate surviving candidate changes before activation.

Carry the admitted chat requester's command-owner predicate into both
repair paths and revalidate it immediately before tool effects. Record
requester revocation and the repair target class in the update ledger.

Add observable helper authority, staged isolation, and activation
regressions. Preserve installation-scoped recovery guidance.

Refs #139495
Read core config before staging and for command-owner policy checks.
Skipping plugin validation still materializes metadata and reads the
serving SQLite index, changing WAL shared-memory read marks even when
config observation is disabled. Load full metadata under the disposable
target instead.

Resolve the helper fixture's packaged snapshot worker from its canonical
runtime entrypoint descriptor.

Both staged-isolation cases and all four requester-effect cases pass their
assertions. The E2E process still fails teardown on the existing service
child cleanup identity error; that upstream blocker remains visible.
Load the spawn recorder through explicit arguments for the owned relay and anchor. Use the production daemon entry for requester checks so source plugin compilation does not consume the fixture deadline.
@steipete
steipete force-pushed the steipete/update-repair-integration branch from e8504dc to ec44c83 Compare September 6, 2026 09:58
@steipete
steipete merged commit 76bf977 into main Sep 6, 2026
188 checks passed
@steipete
steipete deleted the steipete/update-repair-integration branch September 6, 2026 11:13
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to ylcn91/openclaw that referenced this pull request Sep 6, 2026
* origin/main: (47 commits)
  ci: record CPU time for Node test jobs (openclaw#140054)
  test(crabbox): consolidate wrapper boundary coverage (openclaw#140058)
  fix(test): keep native filesystem access checks portable (openclaw#140047)
  fix: preserve models when OAuth preparation fails (openclaw#139951)
  feat(update): recover failed updates with bounded repair (openclaw#139495)
  refactor(plugins): share managed npm package traversal (openclaw#140040)
  chore(ui): refresh control ui locales (openclaw#140059)
  refactor(auth): share profile failure state reset (openclaw#140049)
  fix(cron): surface skipped on-exit payloads when jobs are busy (openclaw#139987)
  fix(codex): preserve exec-server WebSocket backpressure under Bun (openclaw#140048)
  fix(agents): ground exec approvals in tool results (openclaw#140043)
  refactor(policy): reuse authored policy value helpers (openclaw#140019)
  docs: keep ClawSweeper status inspection read-only (openclaw#139958)
  fix: reduce task maintenance stalls with large histories (openclaw#140038)
  fix(code-mode): identify unawaited promise output (openclaw#140028)
  fix(test): release memory search fixtures after failed phases (openclaw#140013)
  test(gateway): isolate Serve hello lifecycle fixtures (openclaw#140044)
  fix(microsoft-foundry): bound Entra token retention across accounts (openclaw#127216)
  fix(process): preserve the cause of cleanup observation failures (openclaw#140015)
  fix: clear Side chat when its parent conversation is deleted (openclaw#139974)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…9495)

* feat(update): integrate bounded repair and harden activation ownership

Run bounded candidate validation repair before activation and verification
repair when rollback cannot recover. Keep service authority with the
orchestrator, record attempts live, and use a fresh candidate worker after
activation. Preserve Windows suspension and compensation through terminal
verification, including cancellation at native mutation boundaries.

Preserve restored runtime identity through failed rollback verification and
report repair of the previous release as rolled back, keeping the update
failure and nonzero exit. Close native staging and Git promotion races. Share run
vocabularies and validation shapes, make ledger redaction precise and JSON
bounding non-mutating, and improve failure reasons, reports, phase visibility,
and unattended-repair documentation.

Validation: full changed-file gate including Knip, full build, focused
integration and native repair E2E, UI E2E, and Codex P0/P1 autoreview.
The explicitly protected lifecycle test remains unchanged; its source
loading exceeds the 30-second harness deadline even with fresh dist.

(cherry picked from commit d37a9418d9468c3e0894fd6d3cebf74b9c6051f4)

* fix(update): await origin notice before managed activation

Connect transferred helper activation to the serving gateway notice callback over the existing control pipe, with a ten-second bound before service parking. Preserve helper-owned cancellation and activation checks.

Record failure excerpts only for failed steps, so completed managed handoffs no longer report an unknown exit code. Cover internal transcript custody with the real helper and bounded simulated service-manager flows.

(cherry picked from commit 8a4db45aff48f6fc7b44add16e5756505450e26f)

* refactor(update): share repair budgets and validation cleanup

* fix(update): preserve transaction outcomes through repair

* refactor(update): remove unused package activation flags

* fix(update): settle the current Windows recovery owner

The regression "settles Windows recovery after candidate repair and plugin activation" failed for both terminal outcomes because the latest suspension retained signal listeners and an exit gate. Resolve the same current stop for restoration, plugin maintenance, and final settlement. Both cases and 103 surrounding tests now pass.

* fix(update): align shared types and repair test ownership

* docs(update): place fallback scope beside candidate staging

* fix(update): isolate staged repair and enforce requester authority

Run pre-activation repair against a disposable rehearsal shared by every
turn and oracle. Reject required config edits without promoting copies,
then independently validate surviving candidate changes before activation.

Carry the admitted chat requester's command-owner predicate into both
repair paths and revalidate it immediately before tool effects. Record
requester revocation and the repair target class in the update ledger.

Add observable helper authority, staged isolation, and activation
regressions. Preserve installation-scoped recovery guidance.

Refs openclaw#139495

* fix(update): defer plugin metadata until repair isolation

Read core config before staging and for command-owner policy checks.
Skipping plugin validation still materializes metadata and reads the
serving SQLite index, changing WAL shared-memory read marks even when
config observation is disabled. Load full metadata under the disposable
target instead.

Resolve the helper fixture's packaged snapshot worker from its canonical
runtime entrypoint descriptor.

Both staged-isolation cases and all four requester-effect cases pass their
assertions. The E2E process still fails teardown on the existing service
child cleanup identity error; that upstream blocker remains visible.

* fix(update): sanitize rehearsal env and remove helper cycle

* test(update): preserve repair proof across env sanitization

Load the spawn recorder through explicit arguments for the owned relay and anchor. Use the production daemon entry for requester checks so source plugin compilation does not consume the fixture deadline.

* fix(update): preserve requester errors and prepare helper tests

* test(update): follow the shared stdin write contract

* refactor(update): separate admission and failure reporting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

2 participants