Skip to content

fix(update): settle only this Doctor's commands in managed custody - #164868

Merged
steipete merged 1 commit into
mainfrom
upd/upd-repair-doctor-custody-overlap
Oct 4, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-repair-doctor-custody-overlap

Conversation

@steipete

@steipete steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes openclaw update repair refusing a completed Doctor as "unsettled, data-at-risk" when another Doctor owns a native command under the same installation root.

Refs https://github.com/openclaw/openclaw/actions/runs/37191626450.

User Impact

Repair can finish without treating another Doctor's commands as its own unfinished work. It records foreign custody, owned by Doctor <PID> as an informational diagnostic. Installation replacement remains blocked while any live command claim exists.

Why This Change Was Made

Per-Doctor settlement was inspecting every command beneath the shared installation root. It now separates foreign helper custody from the completed Doctor's receipt before applying the existing ownership, alias, birth-identity, and extinction checks. Foreign claims are neither signaled nor retired; the native lease store retains its existing installation-replacement checks. A foreign claim named in this Doctor's receipt still refuses settlement.

This is a pre-existing product race, not a new failure introduced by the investigated commit window. The custody code is unchanged between 3f6c1d3a23b9 and failing main 0ed2e0c7a18d. The managed-handoff reporting change in #164782 exposed the child's existing refusal; it did not introduce the nonzero settlement decision.

Evidence

  • The owner regression uses an exited child with an empty .json.processes receipt and a second Doctor's live native command. Before the fix it fails with Native command custody for PID ... belongs to another Doctor; after the fix it passes, preserves the peer's claims and live process, and proves replacement stays blocked until the peer's owner settles it.

  • Both touched suites passed three times locally with one worker (14 tests per complete owner pass). The new process regression took 255–270 ms in the first two positive runs. Negative controls retain refusal for unknown own reservations, wrong-run claims from the same helper, and receipt identities claimed by another Doctor.

  • Importer/sibling proof includes update-managed-service-handoff-original-owner.test.ts (8 tests) and update-command-doctor-delegation.test.ts (15 tests), in addition to the touched owner suites. All passed.

  • Standalone real-Gateway E2E passed before the fix on both 685fdc1f57c4 (77.074 s test body; 244.02 s command wall) and baseline 3f6c1d3a23b9 (69.957 s test body; 186.74 s command wall). A controlled native-process reproduction produced the custody refusal on both revisions.

  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs --timed: passed locally, including production and test types, lint, ownership/storage guards, and import checks. The initial run found a nullable assertion-message type error in the new test; the corrected full run passed.

  • Independent P1 autoreview: scoped-clean, no findings.

  • Standalone cost measurements with pnpm test <file> --maxWorkers=1: update-managed-command-custody.test.ts — 4 tests, 2.003 s summed test time, 12.42 s command wall; update-doctor-process-custody.test.ts — 10 tests, 0.359 s summed test time, 7.58 s command wall. CI seconds are pending.

  • Final committed-head real-Gateway E2E passed on ebed0e654edc8cc3cc289a06447850ba8729db2a: 1/1 tests, 70.358 s test body, 188.76 s command wall. Command: pnpm test extensions/qa-lab/src/session-host-command-state.real-gateway.e2e.test.ts.

Named follow-up: QA Lab installed-package bootstrap cost in gateway-child-setup.ts. Baseline setup spent 37.17 s running real update repair, including sequential Doctors of 17.29 s and 5.03 s, before Gateway/browser work. The pre-existing 77.074 s / 69.957 s E2E test-body costs are waived for this fix; this PR does not change the harness, add retries, or raise timeouts.

All validation above is local. Auto-merge remains disabled.

Scope process settlement to the Doctor's native helper and receipt identities.
Report foreign custody without retiring its claims or weakening installation
replacement checks. Preserve mismatched receipt, alias, identity, and extinction
refusals, and cover the overlap with a real exited child and live peer command.

Refs https://github.com/openclaw/openclaw/actions/runs/37191626450.
@clawsweeper

clawsweeper Bot commented Oct 4, 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 size: S labels Oct 4, 2026
@steipete
steipete marked this pull request as ready for review October 4, 2026 10:51
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 6:56 AM ET / 10:56 UTC.

ClawSweeper review

What this changes

The PR lets a completed Doctor settle its own commands while recording another Doctor’s retained commands as informational diagnostics and preserving installation replacement safeguards.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix for a custody refusal still present on current main. No actionable introduced defect was found.

Likely related people: steipete, an unverified routing candidate based on prior work in these custody modules.

Priority: P2
Reviewed head: ebed0e654edc8cc3cc289a06447850ba8729db2a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with direct native-process evidence and preserved negative controls.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Recorded before/after native-process evidence exercises the production settlement and lease owners with an exited Doctor and a live foreign command, showing successful settlement with the peer preserved and replacement still refused. Inspected negative controls preserve ownership refusals; committed-head Gateway validation is supplemental. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded before/after native-process evidence exercises the production settlement and lease owners with an exited Doctor and a live foreign command, showing successful settlement with the peer preserved and replacement still refused. Inspected negative controls preserve ownership refusals; committed-head Gateway validation is supplemental. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduction and merge result: Read the complete introduced patch from the verified merge base to the pinned head. The raw test-merge commit records the pinned base followed by this head; its result changes only the five introduced paths.
Narrow ownership filter: Foreign-helper claims are skipped only when their executor is absent from this Doctor’s receipt. Receipt-listed foreign claims and wrong-run claims from the same helper still refuse settlement. Only validated owned leases enter the retirement list.
Settlement and final effects: The caller prepares ownership before process-group cleanup, retires claims only after extinction and zero pending reservations, and reports foreign custody through a successful step. The unchanged CLI caller throws only for unsuccessful settlement.
Findings None None.
Security None None.

How this fits together

Update repair runs Doctor to finish installation maintenance. Command custody tracks its native processes and feeds settlement results into update reporting, while the lease store separately controls installation replacement.

flowchart TD
  A[Update repair] --> B[Doctor process receipt]
  B --> C[Command custody settlement]
  D[Installation command claims] --> C
  C --> E[Settle owned commands]
  C --> F[Report foreign custody]
  D --> G[Installation replacement guard]
  E --> H[Update result]
  F --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +17, Tests +106, Docs +4. Total +127 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 35 18 +17
Tests 2 106 0 +106
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 145 18 +127

Review metrics

None.

Technical review

Best possible solution:

Keep per-Doctor settlement scoped to its receipt while the existing lease owner continues fencing installation replacement across all outstanding commands.

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

Yes, source establishes the trigger: an exited Doctor with an empty receipt encounters another helper’s command under the same roots. The supplied native-process regression reports the corresponding before-fix refusal; this review did not execute it.

Is this the best way to solve the issue?

Yes, this repairs the existing settlement owner without duplicating lease policy or weakening replacement admission.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded concurrent-Doctor race that can incorrectly refuse update repair.
  • add proof: sufficient: Contributor real behavior proof is sufficient. Recorded before/after native-process evidence exercises the production settlement and lease owners with an exited Doctor and a live foreign command, showing successful settlement with the peer preserved and replacement still refused. Inspected negative controls preserve ownership refusals; committed-head Gateway validation is supplemental. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded before/after native-process evidence exercises the production settlement and lease owners with an exited Doctor and a live foreign command, showing successful settlement with the peer preserved and replacement still refused. Inspected negative controls preserve ownership refusals; committed-head Gateway validation is supplemental. No stored-data contract changes.

Label justifications:

  • P2: This repairs a bounded concurrent-Doctor race that can incorrectly refuse update repair.
  • 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 (live_output): Recorded before/after native-process evidence exercises the production settlement and lease owners with an exited Doctor and a live foreign command, showing successful settlement with the peer preserved and replacement still refused. Inspected negative controls preserve ownership refusals; committed-head Gateway validation is supplemental. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded before/after native-process evidence exercises the production settlement and lease owners with an exited Doctor and a live foreign command, showing successful settlement with the peer preserved and replacement still refused. Inspected negative controls preserve ownership refusals; committed-head Gateway validation is supplemental. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge result: Read the complete introduced patch from the verified merge base to the pinned head. The raw test-merge commit records the pinned base followed by this head; its result changes only the five introduced paths. (ebed0e654edc)
  • Narrow ownership filter: Foreign-helper claims are skipped only when their executor is absent from this Doctor’s receipt. Receipt-listed foreign claims and wrong-run claims from the same helper still refuse settlement. Only validated owned leases enter the retirement list. (src/infra/update-managed-command-custody.ts:183, ebed0e654edc)
  • Settlement and final effects: The caller prepares ownership before process-group cleanup, retires claims only after extinction and zero pending reservations, and reports foreign custody through a successful step. The unchanged CLI caller throws only for unsuccessful settlement. (src/infra/update-doctor-process-custody.ts:293, ebed0e654edc)
  • Replacement remains independently guarded: Installation admission still checks unsettled descendants and revalidates reclamation inside its transaction. Lease retirement retains exact-row and alias checks; this PR changes neither those guards nor the stored lease format. (src/infra/update-managed-service-handoff-lease.ts:254, ebed0e654edc)
  • Direct native-process boundary evidence: The inspected regression uses an actually exited child, a real live peer process, and the production custody and SQLite lease owners. It asserts successful settlement, preservation of the peer process and claims, blocked replacement, and replacement admission after peer settlement. The captured PR body reports the intended before-fix failure and repeated after-fix passes; no tests were executed during this review. (src/infra/update-doctor-process-custody.test.ts:133, ebed0e654edc)
  • Negative ownership controls: The added controls retain refusal for an unknown own reservation, a different run using the same helper PID, and a receipt identity claimed by another Doctor, while checking that claims remain unchanged. (src/infra/update-managed-command-custody.test.ts:158, ebed0e654edc)

Likely related people:

  • steipete: 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.

@steipete
steipete merged commit d47ee98 into main Oct 4, 2026
198 checks passed
@steipete
steipete deleted the upd/upd-repair-doctor-custody-overlap branch October 4, 2026 11:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…penclaw#164868)

Scope process settlement to the Doctor's native helper and receipt identities.
Report foreign custody without retiring its claims or weakening installation
replacement checks. Preserve mismatched receipt, alias, identity, and extinction
refusals, and cover the overlap with a real exited child and live peer command.

Refs https://github.com/openclaw/openclaw/actions/runs/37191626450.
RomneyDa added a commit that referenced this pull request Oct 7, 2026
Backport the approved Doctor/update and Claude CLI fixes to the frozen 2026.9.9 cut. Preserve release-local migration prelude and recovery paths. Include the landed WhatsApp fixture synchronization repair uncovered by validation. No version, dependency, schema, or publication change.

Sources: #164868, #163369, #165837, #165596, and #166531.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Víctor Gurbani Carballo <[email protected]>
Co-authored-by: Abdel Gomez-Perez <[email protected]>
NerQuiLes pushed a commit to Xtampa-AI/openclaw that referenced this pull request Oct 11, 2026
Audit all 253 September-only commits against da0cbcc. Port only
applicable fixes and final companions, preserving October owners and
shipped upgrade contracts. Exclude September-specific waivers, schema
rollback, dependency changes, and credential-absence pass conditions.

Adapt retained ACP archive receipts without reopening retired custody;
retain SDK1.30.1 issuer fencing and explicit re-registration; exclude
standalone worker copies from beta.2 updater compatibility bridges.
Report settled Doctor release failures before the no-config early return.

Sources below are whole backports or scoped repair selections:

fix(discord): keep health inspection from blocking Gateway connections (openclaw#166736)
Source-commit: dc26366

fix: avoid foreign-listener race in Gateway acquisition proof (openclaw#166883)
Source-commit: bd0b97d

fix(ci): admit workspace package tests in Windows replay (openclaw#166895)
Source-commit: 9bc88a6

fix(release): restore beta.2 updater inventory and Podman control (openclaw#166872)
Source-commit: e203c64

fix(copilot): plugin tool calls fail from the second turn of a session (openclaw#164598)
Source-commit: c6e5ae8

fix(test): await WhatsApp inbound drain (openclaw#165842)
Source-commit: 05170cd

fix(qa-lab): keep SUT CLI in isolated launcher
Source-commit: 6681bcd

test(qa-lab): assert resolved companion CLI cwd
Source-commit: a60b458

fix(release): accept candidate-owned child evidence (openclaw#165357)
Source-commit: 500c95a

fix(acp): migrate metadata from retained sessions
Source-commit: 16398dc

fix(release): isolate first-hop service containment (openclaw#164898)
Source-commit: 85124fe

fix(release): isolate upgrade survivor scenarios (openclaw#165007)
Source-commit: aad828f

test(release): expect isolated survivor scenarios (openclaw#165009)
Source-commit: 02e7f91

fix(release): split restart auth validation (openclaw#165048)
Source-commit: 6160d9f

test: serialize PowerShell completion process suites (openclaw#166229)
Source-commit: 320e52b

fix(update): settle only this Doctor's commands in managed custody (openclaw#164868)
Source-commit: bdb44e2

fix(claude-cli): replies hang until the run times out when a background agent runs Bash (openclaw#165596)
Source-commit: 889611b

fix(whatsapp): synchronize shutdown test with durable admission (openclaw#166531)
Source-commit: 1f576e4

fix: prevent heartbeat live replies from abbreviating markers (openclaw#166777)
Source-commit: c4ed37e

fix(ci): keep full release validation within measured budgets (openclaw#166774)
Source-commit: 471f950

improve(ci): reuse Watch cache and expose shared scan build progress (openclaw#166498)
Source-commit: 66d898f

fix(e2e): normalize registry helper image modes (openclaw#163188)
Source-commit: 1a09bec

fix: MiniMax live validation misses Code Mode file reads (openclaw#163619)
Source-commit: fc23bc8

fix(test): read canonical ACP upgrade metadata
Source-commit: 46c8dd2

fix(qa): remove unavailable Telegram emoji fixture (openclaw#164956)
Source-commit: e785c56

fix(release): reconcile full validation regressions (openclaw#166200)
Source-commit: a3e349e

fix(release): unblock stable validation evidence (openclaw#166315)
Source-commit: 5ac0f82

fix(release): unblock 2026.9.9 full qualification (openclaw#166341)
Source-commit: 8aa6d7c

test(irc): await owned monitor signals (openclaw#163180)
Source-commit: 429ea8c

fix(release): unblock 2026.9.9 full validation (round 4) (openclaw#166485)
Source-commit: ccb390b

fix(release): repair Doctor teardown and FRV evidence recovery
Source-commit: 5d7fa8e

fix(release): bound FRV job reads and normalize ghost evidence
Source-commit: 1854d41

test(release): align priority fixture with bounded job pages
Source-commit: 4fd4fcc

fix(test): keep MCP validation connected after automatic pairing approval (openclaw#166849)
Source-commit: 0979efd

fix(release): address 2026.9.9 validation failures and retain diagnostics (openclaw#166962)
Source-commit: a024875

fix(release): repair fleet and CLI validation fixtures (openclaw#166977)
Source-commit: b899f42

fix: keep 2026.9.9 upgrades on state schema 19 (openclaw#166959)
Source-commit: bcfc888

fix(ui): keep passive chat viewers following incoming turns
Source-commit: 6d9689d

fix(doctor): commit transcript archive migration progress per batch and honor interruption (openclaw#165837)
Source-commit: 3a085ea

fix(doctor): restore release repair settlement
Source-commit: fab3a66

fix(release): reconcile FRV backports
Source-commit: 0c01cc6

fix(ui): refresh end geometry during interaction (openclaw#166239)
Source-commit: 5b71763

fix(ui): preserve follow intent across content growth (openclaw#166258)
Source-commit: ffcdd4d

fix(ui): gate content follow on height changes (openclaw#166301)
Source-commit: 4964263

fix(release): preserve gateway fixture close callback (openclaw#166348)
Source-commit: 64ad20a

test(ui): await collaborator smooth follow (openclaw#166285)
Source-commit: 90abf6a

Co-authored-by: Eric Curtin <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Abdel Gomez-Perez <[email protected]>
Co-authored-by: Patrick Erichsen <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation 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. size: S 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