Skip to content

fix(update): bound service stop and report the serving version when managed activation fails - #186792

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1930
Oct 28, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1930

Conversation

@steipete

@steipete steipete commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Managed activation could wait indefinitely for ordinary systemctl stop, then send a failure notice without identifying the failed phase or the version still serving. Aggregated stop failures could also lose the maintenance holder during public diagnostic projection.

Refs #186754. Thanks @ndirazar for the report and timings.

User Impact

User and system unit stops now receive the effective service stop timeout plus five seconds of grace. Unavailable or infinite policy uses the finite Gateway stop budget with a warning. Timeout returns systemd-inspection-deadline-exceeded through the existing recovery path. Operator service policy is preserved.

Restart preparation explicitly says the update is incomplete. Final failures describe the phase in plain language, retain the reason code in parentheses, and include the recorded next action. Before activation, a serving observation identifies the current version still running; after activation, only verified recovery identifies the previous version still serving. Maintenance failure facts retain the recorded holder information after removing the typed database path before redaction; no holder command or phase is synthesized when the claim does not record one.

Why This Change Was Made

The ordinary stop dispatcher omitted its command timeout. The existing effective-policy reader now has one shared, read-only owner used by policy refresh, drain, and native stop. A dedicated stop-error producer preserves native reason codes and maintenance causes. The notice producer consumes the existing run record; recovery authority, claim formats, and SQLite schemas are unchanged.

The reported ~33-minute activation is consistent with the pre-#173788 30-minute drain budget plus surrounding work. #173788 merged on 2026-10-16, after the 2026.10.8 cut. This PR does not identify the historical maintenance holder or claim that releasing updater-owned custody repairs that incident. The installed updater must contain the stop-command repair; a new candidate cannot change an older driver already running.

Evidence

  • CI repair after 8d607db818a5: reproduced the services test-type error and the three handoff-notice failures. The stop-test guard now explicitly has a () => void mock signature, with no cast. Failure phases render as human phrases (for example, “before the update started” and “while activating”), with reason codes preserved in parentheses. A handoff refusal uses the recorded running version only while the ledger shows activation has not started; later failures still require recorded recovery. Both notice forms retain terminal-replay recognition.

  • Follow-up proof: OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/daemon/systemd-user-transport.test.ts src/gateway/server-methods/update-handoff-failure.test.ts --maxWorkers=1 — 59/59 passed, 94.53 s. The same pair plus src/gateway/update-run-notice.test.ts and src/infra/update-run-notice.test.ts, with OPENCLAW_VITEST_RUNTIME=bun, passed 83/83, 95.49 s, using the pinned Bun fork. The unchanged persisted-notice and unit inputs also passed on Node (16 and 8 cases); the expanded persisted table covers every failed phase and both terminal-replay forms. Persisted-notice test time was 38.39 s on Node and 25.02 s on Bun; it exercises isolated session persistence and replay. No individual test exceeded 30 s. All commands used isolated HOME and OPENCLAW_STATE_DIR under the worktree.

  • Follow-up consumer/static gates: all 147 tests in eight remaining direct/one-barrel notice-consumer files passed on Node, 284.29 s including the required runtime build. node scripts/run-tsgo.mjs -p <config> --incremental passed for test/tsconfig/tsconfig.core.test.services.json, tsconfig.core.test.gateway-methods.json, and tsconfig.core.test.gateway-root.json. Focused core oxlint, oxfmt, and diff checks passed. Test-line ratchet: 6,301,950 / 6,302,000 (PR net −2); mock-export ratchet: 6,561, unchanged by this follow-up. The fresh Codex autoreview attempt hit the same required temporary-directory isolation failure; no bypass or completed independent-review claim.

  • Pre-fix regressions: five extended systemd stop cases failed because dispatch had no timeout; the final persisted-notifier test failed four cases against the base renderer. The real child-held maintenance case also failed before the diagnostic repair because its failure fact omitted the holder PID.

  • Final update-owner/consumer run: 251 tests in 18 files passed, five shards, 654.28 s including a 79.9 s runtime build. Persisted notices covered verified and unverified recovery, live session replacement, and terminal-notice replay. Modified-file test-time sums: notices 10.69 s, update RPC 24.10 s, maintenance contention 9.61 s, post-update recovery 85.46 s; no new individual test exceeded 30 s.

  • Final native stop/Doctor fixture command: node scripts/run-vitest.mjs src/daemon/systemd-user-transport.test.ts src/cli/update-cli/update-command-service-stop-deadline.test.ts src/commands/doctor-maintenance.native-identity.test.ts --maxWorkers=1 — 41/41 passed, 46.45 s. Read-only policy queries are distinguished from effects in the native identity/deadline fixtures.

  • Real subprocess proof with a synthetic manager: isolated HOME and OPENCLAW_STATE_DIR under .artifacts/stop-proof, task-owned fake systemctl first in PATH, then node --import ./scripts/tsx.mjs .artifacts/stop-proof/live.mts. The fixture reports a 10 ms stop policy and executes a real sleep 120 for stop. It timed out in 5034.46 ms; native reason, managed-update reason, and first failure-fact code were all systemd-inspection-deadline-exceeded; no successful mutation was reported. This is actual subprocess timeout evidence, not a live Linux/systemd deployment.

  • Core and update-test typechecks, focused oxlint/oxfmt, Madge (zero cycles), diff checks, test-line and mock-export ratchets passed. Test lines are net −2; four incomplete-mock exceptions were removed using the ratchet's shrink-only operation. Production delta: +182/−36 (net +146). The shared policy reader replaces the prior reader rather than adding a second policy owner.

  • Used focused gates per the lane budget; full check:changed and its SQLite inventory were not run. Codex autoreview could not pass its required isolated temporary-directory preflight, so no completed independent review is claimed; lead review remains required.

Additional local consumer findings and proof limits

A broader systemd consumer run completed 939 passing tests, 13 failures, and 16 existing skips. Seven failures came from fixtures treating the new read-only policy query as a mutation; those fixtures were repaired and the final 41-test run above is green.

The remaining findings were two generation-recovery assertions in update-command-service.integration.test.ts, three Darwin definition-repair assertions in install.definition-repair.test.ts, and an owned-pending Bun SQLite-library probe failure in update-command-run-service-ownership.test.ts. The two generation cases later passed alone and in the original full 68-case file; that passing replay is not presented as a fix or inherited-failure proof. A separate broad SQLite discovery run found a pin-migration-pending recovery assertion in update-command-original-service.test.ts; that fixture bypasses the changed native stop path. These findings are recorded as unresolved, not reported green or repaired by this PR.

The broad SQLite sweep was ended when simplification removed the shared-state message edit from this PR. All remaining direct/one-barrel update consumers were exercised, reusing the unchanged rollback/split-installation observations. The pre-existing database rollback table recorded 326.95 s of test time (slowest Git case 62.02 s); the split-installation table recorded 299.34 s (slowest case 25.30 s). Those fixtures perform real snapshot, delegated Doctor, rollback, and HTTP verification work. No timeouts, retries, or assertions were weakened to hide their cost or failures. PostgreSQL cases retained their existing environment-gated skips.

Resolve the selected systemd stop policy and bound the native command with a five-second grace. Preserve native timeout and maintenance-holder diagnostics through managed recovery, and report the verified previous serving version with failure phase, reason, and next action in requester notices. Refs #186754. Thanks @ndirazar for the report.
@clawsweeper

clawsweeper Bot commented Oct 28, 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 gateway Gateway runtime cli CLI command changes commands Command implementations size: L labels Oct 28, 2026
@steipete
steipete marked this pull request as ready for review October 28, 2026 14:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-10-28T14:55:54.923274Z efc23cc 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR bounds ordinary systemd stops, preserves stop-failure diagnostics, and reports verified recovery details in update notices.

Example: A managed update fails during activation after recovery verifies version 2026.10.4.

  • Before: The requester receives a generic update-failure notice without the serving version or failed phase.
  • After: The notice identifies 2026.10.4 as still serving and includes the failed phase, reason, and recorded next action.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with no definite introduced bug, supported by boundary regressions and subprocess evidence but incomplete product-flow validation.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A managed update can wait indefinitely during service stop and then leave its requester unsure which version remains available.
Reason: The maintainer-authored direction matches confirmed source defects and the linked discussion while explicitly leaving unexplained incident details open.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs confirmed service-stop and failure-notice gaps on current main, while leaving the historical maintenance holder unidentified.

Priority: P1
Reviewed head: 8d607db818a56571c36701ec6cdbeb719d853a11

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supplied evidence lacks a latest-stable Linux upgrade followed by the fixed installed updater's bounded stop failure, verified recovery, and delivered requester notice with settings and data preserved.
Agent review details

How this fits together

The update CLI delegates service stopping to the daemon lifecycle owner, records failures and recovery observations, and passes those records to Gateway notification delivery.

flowchart TD
  A[Update request] --> B[Update executor]
  B --> C[Systemd lifecycle owner]
  D[Effective unit policy] --> C
  C --> E[Native stop command]
  E --> F[Recovery and run record]
  F --> G[Requester notice]
Loading

Technical review

Best possible solution:

Retain the shared lifecycle and diagnostic owners while bounding native stops and rendering only recorded recovery facts.

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

Current main visibly supplies no timeout to ordinary native stops and renders generic failure notices; supplied regressions support those defects, but the historical maintenance refusal remains unconfirmed.

Is this the best way to solve the issue?

The patch targets the existing owners, preserves operator policy and recovery checks, and avoids claiming to fix the unidentified maintenance contention.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +119, Tests -1, Docs +11, Other -4. Total +125 across 22 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 155 36 +119
Tests 12 241 242 -1
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 4 -4
Total 22 407 282 +125

Review metrics

Metric Value Why it matters
Production versus test changes Production +155/−36; tests +241/−242 Production growth implements bounded dispatch, diagnostic preservation, and recorded recovery notices while replacing the previous policy reader; tests consolidate existing fixtures.

Labels

Label changes:

  • add P1: The repair addresses an unbounded stop in the managed update workflow associated with a reported official-release update failure.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The repair addresses an unbounded stop in the managed update workflow associated with a reported official-release update failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Provide the Linux installed-updater recovery and upgrade evidence identified above.
  • Classify the exact-head typecheck failure from its diagnostic and repair it if caused by this diff.

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 October 28, 2026, 10:18 AM ET / 14:18 UTC.

Describe failed phases in plain language and show the recorded current version when a refused handoff leaves the Gateway running. Keep verified recovery and terminal notice replay intact, and type the stop-test guard as void.

Refs #186754. Thanks @ndirazar.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efc23ccd80

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

[...FAILED_PHASE_DESCRIPTIONS.values(), UNKNOWN_FAILED_PHASE].some(
(description) =>
failure.startsWith(`Update failed ${description} (`) &&
/\([a-z0-9-]+\)\.$/u.test(failure),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize underscore-bearing reason codes when replaying notices

For failures such as owner_required (emitted by update.run), this regex rejects the terminal notice produced by renderUpdateRunSummary itself. If the transcript append succeeds but recording delivery is interrupted, and recovery diagnostics change before the retry, appendUpdateRunFinishedNotice regenerates the message instead of replaying the admitted bytes. The transcript owner then rejects the differing text under the same idempotency key, preventing the delivery receipt from settling. Match the actual stored reason vocabulary, including underscores, and cover this renderer-to-recognizer round trip.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 473d221 into main Oct 28, 2026
133 of 134 checks passed
@steipete
steipete deleted the upd/upd-l1930 branch October 28, 2026 15:15
steipete added a commit that referenced this pull request Oct 28, 2026
Keep selected-manager policy in the shared timeout reader while retaining the permission check before drain and #186792's bounded native stop with its recorded reason.

Correct the immutable-service fixture's procfs PID so its changed-process guard is exercised without weakening the assertion.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…anaged activation fails (openclaw#186792)

A managed update on a systemd user Gateway spent 33 minutes in activation and then failed to stop the Gateway, while the requester had only been told it was restarting. The plain systemctl stop is now bounded by the effective stop timeout, a timeout records its reason and falls through to recovery, the final failure notice describes the failed phase in plain words with its reason code and names the version still serving when that is verified, and the offline-maintenance holder survives redaction in the reason. The 33-minute activation matches the pre-openclaw#173788 drain budget. Refs openclaw#186754. Thanks @ndirazar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

1 participant