Skip to content

fix(update): prevent Doctor service inspection from restarting its timeout - #166000

Merged
steipete merged 20 commits into
openclaw:mainfrom
dankarization:fix/upstream-doctor-deadline-20261006
Oct 25, 2026
Merged

steipete merged 20 commits into
openclaw:mainfrom
dankarization:fix/upstream-doctor-deadline-20261006

Conversation

@dankarization

@dankarization dankarization commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Doctor receiving a fresh timeout after update preparation or maintenance admission has already spent part of the updater's allowance.

User Impact

An update's Doctor phase now includes preparation and service inspection in its timeout. If a native service stop has already begun, it still settles and restores the service safely before reporting failure. There are no new CLI options or configuration changes.

Why This Change Was Made

The finalization owner captures the deadline before custody preparation and carries the remaining allowance through the private Doctor worker input. Each process translates that handoff once to its monotonic clock. Forward admission checks the remaining budget; settlement and restoration keep their existing authority. This also preserves the current worker decoder and native command-gate contracts.

Original fix by @dankarization (Daniil Karpenko). The integration removes the unrelated subagent-test change and keeps restoration refusal reporting in the existing restoration module.

Evidence

  • Current-main regression: advancing the clock during custody preparation let the child run past the finalization budget (1 failed, 17 skipped). The same regression is included in the fixed lifecycle suite.
  • Focused regressions: 221 passing tests across six suites; another 33 passing consumer checks cover finalization, installation, executor settlement, and restoration refusal. After main integration, all 46 maintenance settlement tests passed again (runner exit 0). After the final main integration, the original deadline regression passed again (1 passed, 17 skipped; runner exit 0).
  • Targeted lint, format, and documentation checks pass. Full, extraction, and correction P0–P2 reviews are scoped-clean. CI exposed one environment type error after extraction and three stale full-timeout assertions; both are corrected, with all five selected CI cases passing locally.
  • Production +241/-67 lines; tests +414/-10; documentation +7/-0. The necessary growth carries one deadline through the existing process and native-stop boundaries instead of adding a competing timeout owner.
  • Inspected the contributor's packaged CLI cancellation/upgrade proof: the 45-second run timed out and restored a healthy Gateway; the 90-second control succeeded. That historical proof does not validate this integrated head or prove cancellation of an already admitted SQLite writer.
  • No fresh local service/upgrade live test: it would require a new service harness; the existing Gateway and user state were not touched. Exact-head PR CI supplies the broad integration/type proof.

@clawsweeper

clawsweeper Bot commented Oct 6, 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 cli CLI command changes commands Command implementations size: S labels Oct 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR carries Doctor’s remaining timeout through preparation, maintenance admission, worker startup, and native service-stop admission.

Example: Doctor receives a 5-second allowance, and custody preparation consumes all 5 seconds.

  • Before: The child receives another full allowance and can begin additional work.
  • After: The expired allowance prevents new work while an already admitted stop retains settlement and restoration.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The inspected patch has no actionable correctness finding, but historical live evidence does not establish the materially changed integrated path.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Update preparation can consume Doctor’s allowance without reducing the time granted to subsequent Doctor work.
Reason: The existing timeout contract should bound preparation and forward admission while preserving safe recovery for effects already admitted.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR addresses a current deadline-accounting defect, and both previously reported fixture regressions are corrected.

Priority: P2
Reviewed head: 16656252e86eba010f5eb07ef04b28572576f85d

Before merge

  • Add real behavior proof - The inspected historical CLI and native-adapter receipts prove cancellation/restoration and an upgrade on earlier revisions, but later integration changes deadline capture, monotonic translation, and worker handoff. Supply redacted CLI output or logs for the integrated behavior showing preparation consuming the allowance, refusal before a new native stop, and recovery after an already admitted stop; include an upgrade from v2026.10.7 preserving existing settings and data. Redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • 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

None.

Tests

  • Missing end-to-end proof: The integrated deadline path needs shipped-CLI preparation-expiry and admitted-stop recovery evidence, plus a latest-stable upgrade preserving settings and data.
Agent review details

How this fits together

The updater prepares managed-service custody, delegates Doctor to a fresh process, and receives maintenance results before continuing or recovering the Gateway.

flowchart TD
  A[Update CLI] --> B[Finalization deadline]
  B --> C[Custody preparation]
  B --> D[Doctor worker]
  D --> E[Maintenance admission]
  E --> F[Native service stop]
  F --> G[Settlement and restoration]
Loading

Technical review

Best possible solution:

Preserve one deadline across the existing updater and Doctor owners while keeping admitted-stop settlement and restoration outside forward-work expiry.

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

Current-main source starts the phase deadline after custody preparation and gives Doctor a fresh timeout; the added regression exercises preparation exceeding the allowance, but no code was executed during this read-only review.

Is this the best way to solve the issue?

The patch repairs the existing deadline owners and native admission path without adding a competing timer, public option, or persistent storage model.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Finalization deadline ownership keeps the original intent (bff6c68: Bound executable finalization phases and provide terminal diagnostics when a phase stalls.)
  • Fresh Doctor supplied allowance keeps the original intent (8713e5e: Prevent post-activation Doctor from waiting indefinitely when its caller supplies a finite allowance.)
  • Maintenance contention and restoration keeps the original intent (ec38f53: Wait for other processes’ agent databases to close before update-time maintenance, using existing ownership and recovery paths.)
  • Native service settlement keeps the original intent (0b3de8a: Recheck the original owner before stopping the Gateway and retain accepted work through settlement.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit bff6c68 adds src/cli/update-cli/update-finalization-lifecycle.ts:93 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bff6c68fb0a3; files: src/cli/update-cli/update-finalization-lifecycle.ts)
  • Dallin Romney: Raw commit ec38f53 adds src/commands/doctor-maintenance.ts:355 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ec38f535d3d5; files: src/commands/doctor-maintenance.ts)

PR surface

Source +174, Tests +404, Docs +7. Total +585 across 31 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 21 241 67 +174
Tests 9 414 10 +404
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 31 662 77 +585

Review metrics

Metric Value Why it matters
Production versus tests Production +241/-67; tests +414/-10 Growth carries the existing deadline across process and native-effect boundaries, with distinct preparation, admission, expiry, and restoration regressions.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This fixes bounded update/Doctor behavior when preparation consumes an existing allowance, with limited impact on ordinary successful updates.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Extend the linked CLI receipts to cover the integrated deadline behavior and latest-stable upgrade.

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.

History

Review history (18 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-07T15:00:55.608Z sha 7c6144c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T22:19:26.754Z sha 7c6144c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T05:12:37.183Z sha 7c6144c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T18:23:45.903Z sha 6bb9c07 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T19:57:16.475Z sha e7ad0a9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T22:21:52.308Z sha fe68442 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-15T11:28:18.653Z sha 84170af :: needs maintainer review before merge. :: none
  • reviewed 2026-10-25T04:01:02.613Z sha 146be06 :: needs real behavior proof before merge. :: [P2] Update the delegation fixture for the remaining timeout | [P2] Update package consumers for preparation time in the budget

Reviewed October 25, 2026, 12:22 AM ET / 04:22 UTC (Revision 19).

@dankarization
dankarization marked this pull request as ready for review October 6, 2026 08:39
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: L and removed size: M labels Oct 7, 2026
@dankarization

dankarization commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed the native stop-dispatch deadline gap in 99bb7118835ad3078bbbeda828e3fa87d467c976.

The original product demonstrably dispatched systemctl --user stop after transport preparation expired the admitted Doctor deadline. The regression failed on that forbidden native command; its positive late-stop receipt/restoration case passed. The exact patch was restored, and 17/17 selected tests passed (2 new stop cases, 6 retained-cleanup, 9 authority-runner), with unchanged timeouts. Native green wall time was 293.48 s including fresh worker preparation. Independent native P0–P2 review was scoped-clean; normal hooks preserved the tested bytes.

The fix propagates the existing beforeEffect guard through actual systemd preparation and retained gate input admission. Post-effect settlement and restoration continue to use ownership-only authority. The unchanged upstream terminal test correction 1d10375ee563bfaa203e9aad7fe88275adedd3a6 is also retained.

This is scoped regression proof, not published-driver expiry/recovery acceptance. The real package/installed-candidate cell and current-head hosted CI remain pending. The repeated legacy migration CI timeout has no established cause or fix; it is not labeled a flake. Production state was untouched.

Test-only CI follow-up: current public head 7c6144c08cf767b8cbd53ab30efef7079d965823 corrects the duplicate support import reported by job112835462442 in run37633544131. The initial side-effect fixture registration remains first; the fixture export lookup uses the existing sibling's top-level dynamic import pattern. Production bytes and all test bodies/assertions are unchanged. Pinned native core lint passed with 0 warnings/0 errors (196.0 s), formatting/whitespace/normal hooks passed. The 17-case runtime proof remains at99bb711; no new runtime result is claimed for this import-only change. New exact-head CI remains pending.

Exact-head hosted CI update: 7c6144c08cf767b8cbd53ab30efef7079d965823 CI37636557117 completed success. Recorded latest100 check snapshot: 69 SUCCESS /30 SKIPPED /1 NEUTRAL, no pending/failures; complete pagination likewise has no pending/failed check records. Product bytes and regression bodies/assertions are identical to99bb711’s independently reviewed17/17 native result. Published-driver candidate expiry, writer settlement and actual restoration/readyz proof remain pending a canonical package; no proof-sufficient label or live acceptance is requested.

@clawsweeper clawsweeper Bot added the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Oct 13, 2026
@clawsweeper clawsweeper Bot removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 25, 2026
Pass the already-validated service environment into the restoration reporter.
Check the remaining Doctor allowance in native settlement and package tests,
including preparation time. Integrate current main without changing the
original deadline regression.
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 25, 2026
@steipete
steipete merged commit a200356 into openclaw:main Oct 25, 2026
145 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

steipete added a commit that referenced this pull request Oct 25, 2026
Windows service simulations under Bun searched for Windows Node executable
names on POSIX after #148857 added real SQLite header probes. Extend the
fixture's existing host-platform scope to that synchronous probe, preserving
its real child process and file reads.

The three candidate-activation failures reproduce on main and before #166000;
the running-service case passes before #148857. Keep production behavior,
Doctor deadlines, and all service-ordering assertions unchanged.

Validation: all 14 candidate-activation tests pass under Bun; update-test
typecheck, focused lint, formatting, and Codex autoreview through P2 pass.
steipete added a commit that referenced this pull request Oct 25, 2026
…et and host ports (#183578)

The requester-revoked package receipt test pinned Doctor's timeout to the full budget although #166000 passes the remaining admitted budget, so it failed whenever setup consumed time (seen on #183279 CI). The native systemd stop fixture inspected the host's real Gateway port; it now stubs port inspection like the rest of its service boundary.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…meout (openclaw#166000)

* fix(update): prevent Doctor service inspection from restarting its timeout

* fix(update): honor doctor deadline before predecessor stop

* fix(doctor): recheck expiry before final service stop

* test(update): repair Doctor deadline CI regressions

* test(update): prune retired Doctor mock exemption

* test(update): align Doctor diagnostics with structured warnings

* test(update): preserve ordered recovery guidance assertion

* fix: prevent Doctor service stops after the admitted deadline

* test: preserve Doctor fixtures without duplicate imports

* test(update): account for custody within Doctor deadline

* test(update): remove redundant Doctor deadline helper suite

* test(subagents): settle detached cleanup owner before timer assertions

Join existing Gateway root work after retry callbacks and before fixture teardown; preserve bounded retry and zero-timer assertions. Include pending timer diagnostics. Focused full file247 tests and lint passed; original CI timer race did not reproduce locally.

* fix(update): retain explicit Doctor budget across post-plugin checks

Co-authored-by: Daniil Karpenko <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
Windows service simulations under Bun searched for Windows Node executable
names on POSIX after openclaw#148857 added real SQLite header probes. Extend the
fixture's existing host-platform scope to that synchronous probe, preserving
its real child process and file reads.

The three candidate-activation failures reproduce on main and before openclaw#166000;
the running-service case passes before openclaw#148857. Keep production behavior,
Doctor deadlines, and all service-ordering assertions unchanged.

Validation: all 14 candidate-activation tests pass under Bun; update-test
typecheck, focused lint, formatting, and Codex autoreview through P2 pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…et and host ports (openclaw#183578)

The requester-revoked package receipt test pinned Doctor's timeout to the full budget although openclaw#166000 passes the remaining admitted budget, so it failed whenever setup consumed time (seen on openclaw#183279 CI). The native systemd stop fixture inspected the host's real Gateway port; it now stubs port inspection like the rest of its service boundary.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…meout (#166000)

* fix(update): prevent Doctor service inspection from restarting its timeout

* fix(update): honor doctor deadline before predecessor stop

* fix(doctor): recheck expiry before final service stop

* test(update): repair Doctor deadline CI regressions

* test(update): prune retired Doctor mock exemption

* test(update): align Doctor diagnostics with structured warnings

* test(update): preserve ordered recovery guidance assertion

* fix: prevent Doctor service stops after the admitted deadline

* test: preserve Doctor fixtures without duplicate imports

* test(update): account for custody within Doctor deadline

* test(update): remove redundant Doctor deadline helper suite

* test(subagents): settle detached cleanup owner before timer assertions

Join existing Gateway root work after retry callbacks and before fixture teardown; preserve bounded retry and zero-timer assertions. Include pending timer diagnostics. Focused full file247 tests and lint passed; original CI timer race did not reproduce locally.

* fix(update): retain explicit Doctor budget across post-plugin checks

Co-authored-by: Daniil Karpenko <[email protected]>

(cherry picked from commit a200356)

Co-authored-by: RomneyDa <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 28, 2026
…meout (#166000)

* fix(update): prevent Doctor service inspection from restarting its timeout

* fix(update): honor doctor deadline before predecessor stop

* fix(doctor): recheck expiry before final service stop

* test(update): repair Doctor deadline CI regressions

* test(update): prune retired Doctor mock exemption

* test(update): align Doctor diagnostics with structured warnings

* test(update): preserve ordered recovery guidance assertion

* fix: prevent Doctor service stops after the admitted deadline

* test: preserve Doctor fixtures without duplicate imports

* test(update): account for custody within Doctor deadline

* test(update): remove redundant Doctor deadline helper suite

* test(subagents): settle detached cleanup owner before timer assertions

Join existing Gateway root work after retry callbacks and before fixture teardown; preserve bounded retry and zero-timer assertions. Include pending timer diagnostics. Focused full file247 tests and lint passed; original CI timer race did not reproduce locally.

* fix(update): retain explicit Doctor budget across post-plugin checks

Co-authored-by: Daniil Karpenko <[email protected]>

(cherry picked from commit a200356)

Co-authored-by: RomneyDa <[email protected]>

Candidate test-only adaptation: make Doctor preparation consume a deterministic 125ms of its existing 1000ms monotonic budget; require exactly 875ms at dispatch while preserving refusal receipts and unbounded method-switch coverage.
RomneyDa pushed a commit that referenced this pull request Oct 28, 2026
…meout (#166000)

* fix(update): prevent Doctor service inspection from restarting its timeout

* fix(update): honor doctor deadline before predecessor stop

* fix(doctor): recheck expiry before final service stop

* test(update): repair Doctor deadline CI regressions

* test(update): prune retired Doctor mock exemption

* test(update): align Doctor diagnostics with structured warnings

* test(update): preserve ordered recovery guidance assertion

* fix: prevent Doctor service stops after the admitted deadline

* test: preserve Doctor fixtures without duplicate imports

* test(update): account for custody within Doctor deadline

* test(update): remove redundant Doctor deadline helper suite

* test(subagents): settle detached cleanup owner before timer assertions

Join existing Gateway root work after retry callbacks and before fixture teardown; preserve bounded retry and zero-timer assertions. Include pending timer diagnostics. Focused full file247 tests and lint passed; original CI timer race did not reproduce locally.

* fix(update): retain explicit Doctor budget across post-plugin checks

Co-authored-by: Daniil Karpenko <[email protected]>

(cherry picked from commit a200356)

Co-authored-by: RomneyDa <[email protected]>

Candidate test-only correction: inject transport expiry only while the real native stop is preparing, not during preceding discovery. Retain the initial stop/no-dispatch contract, cover both wall-clock directions and an already-expired pre-stop deadline.
RomneyDa pushed a commit that referenced this pull request Oct 28, 2026
…meout (#166000)

* fix(update): prevent Doctor service inspection from restarting its timeout

* fix(update): honor doctor deadline before predecessor stop

* fix(doctor): recheck expiry before final service stop

* test(update): repair Doctor deadline CI regressions

* test(update): prune retired Doctor mock exemption

* test(update): align Doctor diagnostics with structured warnings

* test(update): preserve ordered recovery guidance assertion

* fix: prevent Doctor service stops after the admitted deadline

* test: preserve Doctor fixtures without duplicate imports

* test(update): account for custody within Doctor deadline

* test(update): remove redundant Doctor deadline helper suite

* test(subagents): settle detached cleanup owner before timer assertions

Join existing Gateway root work after retry callbacks and before fixture teardown; preserve bounded retry and zero-timer assertions. Include pending timer diagnostics. Focused full file247 tests and lint passed; original CI timer race did not reproduce locally.

* fix(update): retain explicit Doctor budget across post-plugin checks

Co-authored-by: Daniil Karpenko <[email protected]>

(cherry picked from commit a200356)

Co-authored-by: RomneyDa <[email protected]>

Candidate test-only correction: inject transport expiry only while the real native stop is preparing, not during preceding discovery. Retain the initial stop/no-dispatch contract, cover both wall-clock directions and an already-expired pre-stop deadline.

Candidate parent-environment follow-up: pin predecessor build identity and read-only listener discovery so an ambient dist artifact cannot trigger the native-dispatch expiry fault before stop. Preserve actual native transport, initial stop, expired-deadline refusal, no-dispatch, receipt and restoration assertions. Add discovery assertions and fail forbidden fixture dispatch immediately. Test-only delta; no production authority or deadline changes.
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 P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants