Skip to content

fix(doctor): preserve sandboxed and live profile diagnostics - #174147

Merged
steipete merged 4 commits into
mainfrom
fix/standalone-doctor-followups
Oct 16, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/standalone-doctor-followups

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Sandboxed standalone Doctor could exit successfully without reporting its selected SQLite library, then log a spawn-broker cleanup failure. Doctor also requested offline state ownership for an already completed runtime-pin migration while Gateway was running.

Related: #173154, #172703.

User Impact

Doctor reports its selected SQLite library independently of host-service repair. Darwin Bun can verify process retirement inside the documented macOS sandbox without executing /bin/ps or adding a sandbox allowance. Doctor diagnoses an already migrated profile while its Gateway runs. Pending migration still requires exclusive ownership and now names the same-profile stop, doctor --fix, and restart sequence.

Why This Change Was Made

The database contribution owns the SQLite diagnostic. Darwin Bun obtains numeric process facts from public libproc through built-in FFI; proc-safe still owns exact argv inspection. Missing or incomplete observations remain errors. The native source is included in the PR wrapper inventory because those tools also use the process supervisor.

A completed migration receipt for the same source returns before offline custody; actual work rechecks under custody. Pending migration is deliberately not deferred: config normalization must not discard legacy fields before their state import. The manual standalone verifier tolerates terminal-panel wrapping while still asserting the selected library path and rejecting cleanup failures.

Evidence

  • Owner regressions pass: database diagnostics 7, Gateway flow 36, process ownership 31, native census 8, runtime-pin migration 10. The migration regression holds a real Gateway ownership lease. Narrow pnpm test <file> --maxWorkers=1 wall times: 3.36s, 90.85s, 6.71s, 8.19s, and 121.32s respectively; cold worker compilation dominates the two longer runs.
  • Wrapper closure and older-wrapper startup: 21 tests pass. A local provisioner case timed out under Bun; the exact case passed under Node (91.28s including preparation), and the prior exact-head CI passed all Node test jobs. No timeout or assertion was weakened.
  • Full production build passes (338.81s), as do core production/test typechecks, targeted lint/format, and the corrected mock-export ratchet.
  • Developer-ID-signed JIT arm64 standalone: strict signatures verify on the executable and 33 native files. Under the unchanged desktop sandbox, both no-respawn and normal-respawn Doctor exit 0, report bundled SQLite 3.53.4 with extension loading enabled, and emit no broker/census cleanup failure. Removing local IPC exits 1 without Doctor completion.
  • Signed standalone and loose CLI live proof both pass: pending migration reports the stop/fix/restart instruction, offline fix succeeds, and subsequent live Doctor exits 0 while Gateway remains healthy. Synthetic isolated state only. The standalone artifact was removed after preserving its manifest and proof.
  • Signed runtime proof is at 29950821e918286affb53ee1fe4d62ac947c96f8. The final follow-up only normalizes the manual verifier's whitespace assertion; product/runtime/build inputs are unchanged.
  • Independent Codex P0–P2 reviews are scoped clean for the implementation and each follow-up.

Final-head CI is green: run 38897059351, head 9ca6385c7489d26878574ef3697197d8b08adb32. Native workflow merged this head as 6d50f72d970c86c02a97b20583e30b9487a48e4d; no inherited-failure exception was needed.

Earlier CI caught a missing PR-wrapper inventory entry, which was fixed and rechecked. An earlier run also hit an inherited assertion-baseline shrink in src/media/media-facts.ts; it was independently reproduced on that run's main baseline. The final run passed. The PR-context check was corrected by restoring the required Evidence heading after the proof update.

Report the Doctor process SQLite selection independently of host-service
repair. Read Darwin Bun process groups through libproc so sandboxed broker
cleanup retains its census without executing setuid ps.

Consume completed same-source runtime-pin migration receipts before offline
custody. Keep pending migrations exclusive and name the same-profile
stop, repair, and restart sequence.
@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@steipete
steipete marked this pull request as ready for review October 16, 2026 11:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T11:59:11.618725Z 9ca6385 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts commands Command implementations size: M labels Oct 16, 2026
@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. 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 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR restores SQLite diagnostics, adds native Darwin Bun process census support, and avoids reacquiring offline ownership for completed runtime-pin migrations.

Example: Run openclaw doctor --non-interactive against an already migrated profile whose Gateway is running.

  • Before: The runtime-pin migration requests exclusive ownership and reports a lock failure.
  • After: Doctor reads the completed same-source receipt and leaves the running Gateway's ownership intact.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and owner tests support correctness, while upgrade compatibility and complete CI attribution remain unsettled.
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: Complete
User problem: Doctor omits its selected SQLite library in isolated installs, reports sandboxed cleanup failures, and unnecessarily requests offline ownership for migrated live profiles.
Reason: The maintainer-authored direction restores existing diagnostic and ownership contracts without adding configuration or changing the persistent format.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR fixes source-confirmed Doctor defects that remain on current main; no discrete introduced correctness defect was found.

Priority: P2
Reviewed head: 29950821e918286affb53ee1fe4d62ac947c96f8

Before merge

  • 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: Current-change CLI evidence should cover a v2026.10.4 profile upgrade with data and runtime intent intact, then completed-receipt diagnosis while Gateway runs and pending-migration refusal.
Agent review details

How this fits together

Doctor consumes configuration, migration receipts, and process observations to produce diagnostics and perform admitted repairs; the process supervisor supplies cleanup evidence to its existing consumers.

flowchart TD
 CLI[Doctor CLI] --> DB[Database diagnostics]
 CLI --> Migration[Runtime pin migration]
 Migration --> Receipt[Local migration receipt]
 Migration --> Custody[Exclusive state ownership]
 CLI --> Cleanup[Process cleanup]
 Cleanup --> Census[Darwin native census]
Loading

Technical review

Best possible solution:

Keep diagnostics with their database owner and preserve exclusive custody only for migrations that still have work.

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

Current-main source shows the service-dependent SQLite diagnostic, completed-receipt check behind exclusive custody, and Darwin ps dependency; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch fixes the owning boundaries directly, removes the old diagnostic location, and preserves pending-migration exclusion and cleanup uncertainty.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • SQLite selection diagnostic keeps the original intent (757e482: Selected extension-capable SQLite should be visible at Gateway startup and in Doctor.)
  • Runtime-pin migration custody keeps the original intent (b87a1ab: Copy exact runtime intent under exclusive custody and use completed same-source receipts to prevent repeated shared writes.)
  • Process-group census keeps the original intent (2d345fa: Cleanup must retain process-tree evidence and distinguish unavailable inspection from confirmed retirement.)
  • Standalone Doctor qualification keeps the original intent (3bfccdb: Qualify relocated signed artifacts through normal CLI respawn, isolated profiles, broker IPC, and cleanup settlement.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Verified introduced patch: Reviewed the pinned introduction diff, including removal of the service-dependent diagnostic, the receipt shortcut, native census implementation, tests, documentation, and wrapper source registration. (29950821e918)
  • Completed migration shortcut preserves write custody: Only a complete receipt matching the selected source returns before custody; pending work retains exclusive ownership and rechecks completion after acquisition. (src/infra/state-migrations.daemon-runtime-pins.ts:22, 29950821e918)
  • Current main still requires the repair: Fetched main checks the completed receipt only inside the exclusive migration lock and still uses ps for Darwin process enumeration. (src/infra/state-migrations.daemon-runtime-pins.ts:40, 8858de49e356)
  • Native census remains conservative: The adapter rejects incomplete observations, skips only ESRCH disappearances, closes the native library, and preserves existing group and process-identity checks at cleanup consumers. (src/process/supervisor/darwin-bun-process-census.ts:82, 29950821e918)
  • Native ABI contract: The patch directly consumes Darwin's proc_bsdshortinfo ABI; Apple's header confirms the field order used for PID, parent, group, state, and effective UID. (bsd/sys/proc_info.h, f6217f891ac0)
  • Supplied validation: The complete PR body reports owner regression passes and a native Seatbelt census observation, while explicitly leaving signed standalone and live-Gateway qualification pending; no current-change runtime artifact is linked. (29950821e918)

Likely related people:

  • Peter Steinberger: Raw commit b87a1ab adds src/infra/state-migrations.daemon-runtime-pins.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b87a1abdad51; files: src/infra/state-migrations.daemon-runtime-pins.ts)

PR surface

Source +135, Tests +220, Docs +18, Other +7. Total +380 across 15 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 148 13 +135
Tests 6 241 21 +220
Docs 2 19 1 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 2 8 1 +7
Total 15 416 36 +380

Review metrics

Metric Value Why it matters
Production versus test changes Production TypeScript +148/-13; tests and test support +241/-21. The native platform adapter accounts for most production growth; the tests cover native observation failures and migration custody with retained data.

Labels

Label changes:

  • add P2: The changes repair bounded Doctor and macOS standalone diagnostic workflows without establishing an urgent core-runtime outage.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: The changes repair bounded Doctor and macOS standalone diagnostic workflows without establishing an urgent core-runtime outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

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 16, 2026, 7:40 AM ET / 11:40 UTC.

@steipete
steipete merged commit 6d50f72 into main Oct 16, 2026
147 of 149 checks passed
@steipete
steipete deleted the fix/standalone-doctor-followups branch October 16, 2026 12:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…w#174147)

* fix(doctor): preserve sandboxed and live profile diagnostics

Report the Doctor process SQLite selection independently of host-service
repair. Read Darwin Bun process groups through libproc so sandboxed broker
cleanup retains its census without executing setuid ps.

Consume completed same-source runtime-pin migration receipts before offline
custody. Keep pending migrations exclusive and name the same-profile
stop, repair, and restart sequence.

* test(process): preserve exports in Darwin census mock

* fix(tooling): include Darwin census in PR wrapper sources

* test(standalone): accept wrapped SQLite diagnostics
RomneyDa pushed a commit that referenced this pull request Oct 30, 2026
* fix(process): backport native Darwin group inspection

Backport the process census and supervisor tests from #174147. The independent Doctor diagnostics and runtime-pin migration changes are excluded.

(cherry picked from commit 6d50f72)

* refactor(process): backport the shared Darwin inspection owner

Backport the process owner, SDK exports, Codex consumer and their tests from #174284. The independent credential detection and onboarding changes are excluded. Preserve the release branch's unrelated diagnostic documentation.

(cherry picked from commit 4959773)

* refactor(process): share native macOS census across runtimes

Backport #175368. Retain fs-safe 0.26.5 and adapt native census fixtures to the release branch. Carries the approved DarwinProcess uid-to-owner SDK migration; the following package pin completes the exit-window repair.

(cherry picked from commit f236b19)

* fix(codex): retry post-kill observations through the native exit window

Backport #176576. Keep custody while retrying observations after our own SIGKILL within the existing containment deadline.

(cherry picked from commit 5f94dfb)

* fix(process): preserve macOS cleanup while unrelated processes exit

Backport #176612. Pin proc-safe 0.4.2 and its exact native package exclusions, retain the real exiting-process regression, and align the SDK summary with native inspection on both runtimes. Retain the release branch's other dependency pins and exemptions.

(cherry picked from commit 727c607)

* test(process): reuse the process group inspection helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant