Skip to content

fix(update): interrupted updates hang on a healthy Gateway and large-state admission times out - #193263

Merged
steipete merged 7 commits into
mainfrom
codex/g43-update-recovery-wait
Nov 5, 2026
Merged

steipete merged 7 commits into
mainfrom
codex/g43-update-recovery-wait

Conversation

@steipete

@steipete steipete commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: an update interrupted with Ctrl-C or SIGTERM while verifying the restarted Gateway can sit for up to the update deadline printing service=unknown ... health=ready, even though the Gateway is healthy. Also fixes: on large state databases, candidate admission times out at a fixed 120 s and silently falls back to the installed updater's older checks.

User Impact

User impact: an interrupted update now exits within seconds and leaves a healthy Gateway running, with the interruption reported instead of an apparent hang. Installs with a large state database now get the target release's own admission checks, as small installs do. No config, schema, or protocol change.

Why This Change Was Made

A signal stops the update's forward command scope so its children end. Readiness polling kept running in that scope, so every new systemctl died at spawn, the unit read as unknown, and health=ready could never satisfy the managed-service requirement. waitForGatewayHealthyRestart now honours the enclosing scope's cancellation; the existing recovery path takes over from there.

Candidate admission passed prepared.timeoutMs, unset by default, so it used a fixed 120 s even though the step budget is 30 minutes. It now uses the inspection allowance derived from measured SQLite bytes, the same owner the rehearsal uses, capped by the step deadline. An explicit --timeout is unchanged. A candidate that hangs now takes longer to fall back; the Gateway is still serving during admission, so I accepted that.

The installed updater runs the first hop, so hops driven by a published updater keep today's behavior until a release containing this fix is the driver.

Evidence

Native proof on Crabbox AWS Linux (c7a.8xlarge), systemd Gateway, process-group SIGTERM:

Scenario Before (main 5375b69c89b) After
SIGTERM at Phase: verifying, small state still polling 900+ s after the signal, killed by the lane; service=unknown 30 times while systemd said active/running exit 143 in 11 s, /readyz ready, 0 service=unknown lines
SIGTERM at Phase: verifying, 3 GB state not run on main at this exact point exit 143 in 35 s, /readyz ready, 0 service=unknown lines
3 GB state update, admission fell back after 120 s (Admission fallback: timeout) completed in about 187 s, Update safety checks ran in the candidate updater
3 GB state update, total rc=0, 1647 s, downtime 857 s rc=0, 1770 s, downtime 888 s

The diagnostic that identified the cause, from a patched driver: systemctl --user status: signal; Command was terminated.

Total time rises because admission now finishes instead of being abandoned. Timing comes from single runs and is not a clean A/B. Native proof ran on 6217c196307; later commits change only docs and tests.

Tests:

  • The cancellation regression fails with the fix reverted (promise resolved ... instead of rejecting) and passes with it.
  • The admission budget test covers measured growth and the step-deadline cap.
  • 98 tests across the restart-health, admission, and snapshot suites pass.
  • $autoreview is scoped-clean and an independent Codex review returned NO FINDINGS.

Gaps:

  • Proof ran on Linux only. The cancellation check is platform-neutral, but it was not exercised on Windows or macOS.
  • The admission budget test is at the helper; the caller wiring is proven by the native lane.
  • The interrupted run still logs a generic Failed to reconcile gateway service ... AbortError warning before recovery reports the interruption.
  • A signal during update Doctor is unchanged: it exits in about 25 s but leaves the Gateway stopped with rollback-state-unverified, on main and with this fix. openclaw update repair exits 0 and names openclaw gateway start. That cause is not traced here.

Test lines: this adds a justified net 10 lines, recorded in config/test-lines-allocations/update-interrupted-readiness-admission-budget.txt.

@clawsweeper

clawsweeper Bot commented Nov 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 cli CLI command changes size: S labels Nov 5, 2026
@steipete
steipete marked this pull request as ready for review November 5, 2026 06:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T10:02:36.879770Z 736ed60 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR cancels interrupted Gateway readiness polling and sizes candidate admission timeouts from measured SQLite state.

Example: SIGTERM arrives while an update verifies a healthy systemd Gateway.

  • Before: The reported baseline kept polling for more than 900 seconds with service=unknown.
  • After: The reported fixed run exited 143 after 11 seconds while /readyz remained ready.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful native behavior evidence supports a narrow production repair, but the introduced test type error prevents a clean patch verdict.
Proof confidence 🐚 platinum hermit (4/6) The ordinary contributor proof gate is inapplicable to this maintainer-authored PR; its self-contained Linux report nevertheless exercises process-group SIGTERM during real update verification and candidate admission against 3 GB of existing state.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Interrupted updates appear hung despite a healthy Gateway, and large installations abandon the candidate release’s admission checks.
Reason: Both symptoms have source-backed causes and native observations; the maintainer-authored direction accepts the increased fallback allowance.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR: both updater defects remain on current main, and the proposed production fixes are focused, but the test refactor introduces a type error.

Priority: P2
Reviewed head: e420aaad36c145fb38aa6746e175c5a71a51f6c5

Before merge

  • Preserve the port fixture’s PortUsage status type (P2) - Extracting this object removes contextual typing, so its mutable status property becomes string. The port-inspection branch then passes stalled(portBusy), returning Promise<{ status: string; ... }>, to a mock requiring Promise<PortUsage>. That is a compile-time error because PortUsage.status only accepts "free", "busy", or "unknown". Annotate the fixture as PortUsage or reuse the existing portUsage helper; keep the delayed-read assertions intact.

Findings

  • [P2] Preserve the port fixture’s PortUsage status type — src/cli/daemon-cli/restart-health-deadline.test.ts:77

Tests

  • Missing end-to-end proof: Native evidence covers Linux; macOS and Windows cancellation behavior and an explicitly identified latest-stable upgrade preserving settings were not demonstrated.
Agent review details

How this fits together

The installed updater supervises candidate admission and Gateway restart verification, consuming state measurements, service observations, and cancellation signals to produce admission or recovery results.

flowchart TD
  A[Update CLI] --> B[Installed updater]
  B --> C[Measured SQLite inspection budget]
  C --> D[Candidate admission]
  B --> E[Gateway readiness owner]
  F[Command scope cancellation] --> E
  E --> G[Existing recovery and reporting]
Loading

Technical review

Best possible solution:

Retain the existing cancellation and inspection-budget owners, and repair the port fixture’s type without changing production behavior.

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

Current-main source supports both failure paths, and the author supplies comparative native Linux results; this read-only review did not execute the reproduction.

Is this the best way to solve the issue?

The production approach restores cancellation and measured-budget invariants through existing owners without adding another lifecycle or admission path.

Full review comments:

  • [P2] Preserve the port fixture’s PortUsage status type — src/cli/daemon-cli/restart-health-deadline.test.ts:77
    Extracting this object removes contextual typing, so its mutable status property becomes string. The port-inspection branch then passes stalled(portBusy), returning Promise<{ status: string; ... }>, to a mock requiring Promise<PortUsage>. That is a compile-time error because PortUsage.status only accepts "free", "busy", or "unknown". Annotate the fixture as PortUsage or reuse the existing portUsage helper; keep the delayed-read assertions intact.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Readiness cancellation keeps the original intent (2b12538: Share a bounded observation deadline and retain cleanup ownership during interrupted-update reconciliation.)
  • Candidate admission timeout changes intended behavior with a stated reason (acffa76: Allow the candidate release to judge admission while retaining installed checks as a fallback.)
  • State measurement and inspection allowance keeps the original intent (7cf2696: Reuse the snapshot owner's measured state inventory for pre-staging capacity assessment.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cli/daemon-cli/restart-health-deadline.test.ts --maxWorkers=1
  • node scripts/run-tsgo-core-test-shards.mjs --stripe 3/5 --concurrency 2
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3a31156 adds src/cli/daemon-cli/restart-health.ts:333 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3a3115677c54; files: src/cli/daemon-cli/restart-health.ts)
  • SunnyShu: Raw commit 2b12538 adds src/cli/daemon-cli/restart-health.ts:118 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2b125389c8b0; files: src/cli/daemon-cli/restart-health.ts)
  • Jason (Json): Raw commit cb156d0 adds src/cli/update-cli/update-command-candidate-admission.ts:110 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: cb156d027f02; files: src/cli/update-cli/update-command-candidate-admission.ts)

PR surface

Source +28, Tests +12, Docs +12, Other +2. Total +54 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 30 2 +28
Tests 4 53 41 +12
Docs 2 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 10 97 43 +54

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
Default candidate admission allowance 120 seconds → 300 seconds minimum; measured growth capped by the update step allowance The longer fallback delay is a concrete operational change explicitly accepted in the maintainer-authored description.

Labels

Label changes:

  • add P2: Interrupted updates and large-state admission have concrete failures, with limited triggers and a focused repair.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Interrupted updates and large-state admission have concrete failures, with limited triggers and a focused repair.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • 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 5, 2026, 2:08 AM ET / 07:08 UTC.

@steipete
steipete enabled auto-merge (squash) November 5, 2026 10:16
@steipete
steipete merged commit 57f8e4b into main Nov 5, 2026
123 checks passed
@steipete
steipete deleted the codex/g43-update-recovery-wait branch November 5, 2026 10:27
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

tideclaw-bot pushed a commit that referenced this pull request Nov 6, 2026
…state admission times out (#193263)

* fix(update): size candidate admission to measured state

* fix(update): stop waiting on a cancelled readiness scope

* docs(update): describe interrupted readiness and admission allowance

* test(update): trim interrupted readiness and admission coverage

* test(update): restore running-service requirement in the cancellation regression

* test(update): type the stalled port fixtures with the shared helper

Backport-source: 57f8e4b
Backport-scope: Use inherited process cancellation; calculate bounded default admission timeout only when unspecified. Adapt source size.bytes to C1 capacity.sqliteBytes; preserve explicit timeout, step cap, fallback and currentness.

Adapted production backport for release/2026.11.2. Upstream validation descriptions refer to source history; candidate regression coverage and remote qualification are tracked separately.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…state admission times out (openclaw#193263)

* fix(update): size candidate admission to measured state

* fix(update): stop waiting on a cancelled readiness scope

* docs(update): describe interrupted readiness and admission allowance

* test(update): trim interrupted readiness and admission coverage

* test(update): restore running-service requirement in the cancellation regression

* test(update): type the stalled port fixtures with the shared helper
RomneyDa added a commit that referenced this pull request Nov 17, 2026
…193263)

Backport command-scope cancellation and measured-state admission budgets to
the stable update owners. Preserve explicit timeouts and existing authority
checks; retain existing interruption recovery documentation.

(cherry picked from commit 57f8e4b)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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