Skip to content

fix(doctor): reclaim captures beside unrelated runtime processes - #160158

Merged
steipete merged 9 commits into
mainfrom
upd/upd-census-unrelated-bun
Sep 29, 2026
Merged

steipete merged 9 commits into
mainfrom
upd/upd-census-unrelated-bun

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #159950

What Problem This Solves

openclaw doctor --fix leaves abandoned plugin captures and updater runtimes behind when an unrelated Bun or Node process uses unfamiliar launcher syntax.

User Impact

Readable foreign process evidence permits cleanup. Positive custody references and unresolved inspection preserve live artifacts and report a warning. Updates remain best effort; no configuration, schema, dependency, or CLI changes are required.

Why This Change Was Made

The census owns one closed result: holder, non-holder, or unresolved. Missing argv, cwd, script, package, or module evidence cannot authorize Doctor cleanup. Raw cwd/argv references and resolved artifact paths take precedence over foreign-process exclusions and foreign package identity. The existing verified foreign-UID exemption remains in force when there is no positive custody reference.

One runtime parser supplies script position and possible custody operands to all callers. Shared package inspection replaces nested custody conversions. Bun tasks take precedence over same-named files; ordinary Bun loader mappings and known Node scalar options retain their meanings. Opaque module references remain conservative.

The semantic rebase preserves main's strict package-identity admission: enabling a task still needs a regular canonical entrypoint and its verified package root. Executable names, retitles, service markers, and cleanup hints cannot provide that authority. Ordinary Gateway discovery and stale-lock recovery retain their existing command-identity contract.

Rebased onto baf2edda0d31e48fdb644daae9b802df1e9bf65b after #151674 moved service-command markers into inspect-markers.ts. The parser caller adaptation moved with its owner; inspect.ts has no duplicate parser call. git range-diff shows this file move is the only change made by the rebase. #160292 was still unmerged immediately before the rebase and is not included.

The subsequent P1 review found that built-in Node test reporters were incorrectly treated as unresolved module references. The parser now recognizes the original built-in reporters (spec, dot, tap), verified against Node v18.15.0 source, while custom and version-dependent names remain conservative. Four census regressions failed before the fix and passed afterward. The existing Node executable-name check was simplified without changing its accepted names; its six existing tests pass.

Thanks @Marvinthebored for the report and Bun reproduction in #159951.

Evidence

  • Existing unreadable-manifest, cwd-timeout/partial-batch, same/unknown-UID argv, holder, foreign-process, and registered Doctor regressions remain in place.
  • New regressions failed before their repairs: three Bun task/precedence cases; six cwd, equals-form path and resolved-alias cases; three bare module cases; and the ordinary Bun loader mapping. The Node memory-option control remains green.
  • Current-head Testbox proof passed: 589 tests across 20 focused files, 3× (57.82 s, 50.76 s, 49.32 s wall); all 35 discovered import-consumer inputs in their discovery order (83.96 s, existing Linux platform skips retained); and node scripts/check-changed.mjs, including production types, all 26 test-type graphs, formatting, lint (0 warnings/errors), and static guards. Longest individual test observed: 4.305 s. No flaky or slow test-time violations encountered.
  • Fresh direct-route Codex review of the final full candidate: scoped-clean at P1, exit 0. The accepted built-in-reporter finding was fixed and independently re-reviewed.
  • Current-head local single-file proof: census 91 tests, runner wall 32.46 s (Vitest 28.35 s, 97% transform and 1% tests); runtime-name checks six tests, runner wall 1.44 s (Vitest 365 ms). All passed. Four built-in-reporter regressions failed before the repair with the expected unresolved-module veto. Hosted CI timing was not collected.
  • The first bounded retry obtained a worker within the 15-minute queue limit; no second attempt or validation exception was needed. Blacksmith Testbox lease tbx_01m3m5a57egas0g80pn92bhnd9 (coral-crab-3c1c), hydration run. The wrapper verified source head 60605b5913acca3ec368ca313ec843125c7ee879 and tree d73e7e4a7a8f1bad4488da88d1eb5137881a09e0; all ten changed-file hashes matched before execution. Command receipt: command=35m37.022s exit=0, runStatus=succeeded. A post-run provider portal-sync warning did not change the recorded successful command result. No required remote proof gap remains.

The published 2026.9.6 updater cell and native macOS cwd batch proof belong to earlier head 000a54be; they are historical integration evidence, not proof of this candidate's changed classification. Current-head proof and any remote validation gap are listed explicitly above; earlier registered Doctor, service-admission and consumer results are not represented as current-head proof. Hosted CI was not used for proof.

Per-file production budget

Compared with rebase base baf2edda0d31e48fdb644daae9b802df1e9bf65b:

File + / − Why essential
src/daemon/runtime-binary.ts 71 / 45 One parser owns script positions and module/ambiguous operands.
src/infra/gateway-process-argv.ts 181 / 45 Shared package/path evidence, bounded cwd reads, and preserved mutation admission.
src/infra/openclaw-process-census.ts 109 / 22 Closed custody decision; positive references and unresolved evidence veto cleanup.
src/daemon/inspect-markers.ts 1 / 1 Consumes the canonical parser's position.
src/daemon/service-env-merge.ts 1 / 1 Consumes the canonical parser's position.
src/daemon/service-layout.ts 1 / 1 Consumes the canonical parser's position.
Production total 364 / 115 +249 net; cap +250.
Tests / docs + / − Why essential
src/infra/openclaw-process-census.test.ts 303 / 24 Custody, unreadability, task, flag, alias and UID regressions.
src/infra/gateway-process-argv.test.ts 19 / 2 Preserves ordinary command identity and package-failure behavior.
src/flows/doctor-plugin-source-captures.test.ts 27 / 5 Exercises preservation and cleanup through the registered Doctor flow.
docs/cli/doctor/checks.md 1 / 0 Documents the cleanup evidence and warning behavior.

Removed repeated argv walks, operand-index plumbing, nested custody transport and conversion adapters. No new single-caller helper remains outside the closed classifier itself.

Validated head: 60605b5913acca3ec368ca313ec843125c7ee879. Auto-merge is off.

@clawsweeper

clawsweeper Bot commented Sep 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.

@steipete
steipete marked this pull request as ready for review September 28, 2026 05:34
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 29, 2026, 9:46 AM ET / 13:46 UTC (Revision 11).

ClawSweeper review

What this changes

The branch changes Doctor’s process census and shared Node/Bun argument parsing so it can reclaim abandoned plugin captures and updater runtimes beside unrelated processes, and adds tests and documentation.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 8 items remain

Keep this PR open. Current main still has the reported Doctor cleanup gap, but this branch introduces a regression for manifest-free foreign scripts and lacks current-head proof of the cleanup authority boundary.

Priority: P2
Reviewed head: 6ca0c654c13e11125185df3ff06e94e8c6096954

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The branch has substantial focused validation, but a carried-forward compatibility defect and missing current-head final-effect proof prevent merge confidence.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: Authority-chain proof required: current-candidate tests reach the registered Doctor cleanup and real filesystem removal, but inject the changed macOS process and cwd observations. Native allowed and same-user forbidden final effects and the published v2026.9.6 updater cell are evidenced only for an earlier classifier head. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: current-candidate tests reach the registered Doctor cleanup and real filesystem removal, but inject the changed macOS process and cwd observations. Native allowed and same-user forbidden final effects and the published v2026.9.6 updater cell are evidenced only for an earlier classifier head. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Current-main behavior: Main rejects an unfamiliar runtime option such as the reported Bun --silent flag before it can classify the unrelated process.
Introduced compatibility regression: With inspectPackage enabled, the new condition sends a resolved, non-candidate foreign script into package-identity lookup; an absent manifest returns unclassified instead of other.
Previous behavior: Main classified a resolved script whose path did not match an OpenClaw entrypoint as other without reading a package manifest.
Findings 1 actionable finding [P1] Preserve cleanup beside manifest-free foreign scripts
Security Needs attention Prove holder refusal at the final cleanup effect: The classifier may now return non-holder for unfamiliar launchers. Injected process records exercise Doctor cleanup, but no current-head native trace establishes that a same-user process holding an artifact is rejected before removal.

How this fits together

Doctor finds abandoned plugin captures and updater runtimes during maintenance. Its process census reads live commands, working directories, and package evidence before cleanup preserves or removes those artifacts.

flowchart LR
A[Doctor maintenance] --> B[Abandoned artifacts]
B --> C[Host process census]
C --> D[Command and directory evidence]
D --> E{Holder or unresolved?}
E -->|Yes| F[Keep artifacts and warn]
E -->|No| G[Remove artifacts]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: current-candidate tests reach the registered Doctor cleanup and real filesystem removal, but inject the changed macOS process and cwd observations. Native allowed and same-user forbidden final effects and the published v2026.9.6 updater cell are evidenced only for an earlier classifier head. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve cleanup beside manifest-free foreign scripts (P1) - A readable same-user node /tmp/foreign.js without package.json now enters package lookup and becomes unclassified, so Doctor skips capture and runtime cleanup. Main returned other for a resolved non-candidate script. The added Doctor cases all create a manifest; this finding was raised in the prior review and remains at this head.
  • Resolve security concern: Prove holder refusal at the final cleanup effect - The classifier may now return non-holder for unfamiliar launchers. Injected process records exercise Doctor cleanup, but no current-head native trace establishes that a same-user process holding an artifact is rejected before removal.
  • Resolve merge risk (P1) - An ordinary same-user Node script without a package manifest can now make Doctor skip capture and retained-runtime cleanup on upgrade.
  • Resolve merge risk (P1) - The changed census can authorize filesystem removal, but current-head evidence does not show native macOS rejection of the nearest same-user holder before that final effect.
  • Resolve merge risk (P1) - The required published v2026.9.6 updater × current-candidate cell is not shown; the cited updater result belongs to an earlier classifier head.
  • Complete next step (P2) - Repair manifest-free foreign-script classification, then provide current-head native allowed and same-user holder final-effect evidence and the published-updater compatibility cell before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Preserve cleanup beside manifest-free foreign scripts — src/infra/gateway-process-argv.ts:251
  • [medium] Prove holder refusal at the final cleanup effect — src/infra/openclaw-process-census.ts:56
Agent review details

Security

Needs attention: The diff changes the process-custody decision that permits deletion; current-head native proof of the nearest same-user holder refusal is still needed.

PR surface

Source +249, Tests +318, Docs +1. Total +568 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 364 115 +249
Tests 3 349 31 +318
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 714 146 +568

Review metrics

Metric Value Why it matters
Net code growth production +249, tests +318 lines The PR body accounts for production growth as a shared parser and custody classifier; its size makes boundary proof material.

Stored data model

Persistent data-model change detected: serialized state: src/infra/gateway-process-argv.ts, unknown-data-model-change: src/infra/gateway-process-argv.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #159950
Summary: The open issue reports the Bun-triggered Doctor cleanup failure this PR aims to fix; the earlier narrow PR closed without merging, while the separate process-census PR addresses update recovery.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Repair and prove custody (recommended)
    Restore cleanup beside manifest-free foreign scripts, then capture current-head native allowed and same-user holder final effects and a published-updater result.
  2. Pause the cleanup change
    Keep the PR open without merging if the process-custody boundary cannot be demonstrated on the current candidate.

Technical review

Best possible solution:

Keep positive artifact and owner vetoes, restore the prior classification of resolved foreign scripts that have no OpenClaw evidence, and prove both native custody outcomes through Doctor and the shipped updater.

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

Yes. A readable standalone node script without package.json follows the introduced package lookup to an unclassified census result; this review traced that path but did not execute the PR.

Is this the best way to solve the issue?

No. The shared census is the right owner, but its package lookup should not veto an otherwise resolved foreign script with no OpenClaw evidence.

Full review comments:

  • [P1] Preserve cleanup beside manifest-free foreign scripts — src/infra/gateway-process-argv.ts:251
    A readable same-user node /tmp/foreign.js without package.json now enters package lookup and becomes unclassified, so Doctor skips capture and runtime cleanup. Main returned other for a resolved non-candidate script. The added Doctor cases all create a manifest; this finding was raised in the prior review and remains at this head.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 099380708f99.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The reported defect persistently delays cleanup during Doctor and updates, with a limited operational blast radius.
  • merge-risk: 🚨 compatibility: The introduced package check makes a previously accepted manifest-free foreign process stop cleanup.
  • merge-risk: 🚨 security-boundary: The new custody classification controls whether Doctor removes filesystem artifacts, and current-head native forbidden-holder proof remains absent.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: current-candidate tests reach the registered Doctor cleanup and real filesystem removal, but inject the changed macOS process and cwd observations. Native allowed and same-user forbidden final effects and the published v2026.9.6 updater cell are evidenced only for an earlier classifier head. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Prove holder refusal at the final cleanup effect — src/infra/openclaw-process-census.ts:56
    The classifier may now return non-holder for unfamiliar launchers. Injected process records exercise Doctor cleanup, but no current-head native trace establishes that a same-user process holding an artifact is rejected before removal.
    Confidence: 0.88

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Restore cleanup beside a resolved standalone foreign Node script without weakening holder or unresolved-evidence protection.
  • Add redacted current-head native macOS allowed and same-user holder final-effect traces, plus a published v2026.9.6 updater result; update the PR body to trigger re-review, or ask a maintainer to comment @clawsweeper re-review if it does not run.

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.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-28T10:51:48.442Z sha 1812449c0345ca40536ec1778b5254006449a419 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T12:46:35.818Z sha 1812449c0345ca40536ec1778b5254006449a419 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T13:35:10.433Z sha 8828248 :: needs real behavior proof before merge. :: [P1] Preserve cleanup beside standalone foreign Node scripts
  • reviewed 2026-09-28T14:38:46.005Z sha 8828248 :: needs real behavior proof before merge. :: [P1] Preserve cleanup beside standalone foreign Node scripts
  • reviewed 2026-09-28T14:54:22.714Z sha 60605b5 :: needs real behavior proof before merge. :: [P1] Preserve cleanup beside standalone foreign Node scripts
  • reviewed 2026-09-29T04:33:48.047Z sha 436626d :: needs real behavior proof before merge. :: [P1] Preserve cleanup beside standalone foreign Node scripts
  • reviewed 2026-09-29T09:29:14.392Z sha b7fd7e3 :: needs real behavior proof before merge. :: [P1] Preserve cleanup beside manifest-free foreign scripts
  • reviewed 2026-09-29T11:51:26.989Z sha b752d52 :: needs real behavior proof before merge. :: [P1] Preserve cleanup beside manifest-free foreign scripts

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L and removed size: M labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 28, 2026
@steipete
steipete force-pushed the upd/upd-census-unrelated-bun branch from 1812449 to 8828248 Compare September 28, 2026 13:26
Keep unreadable process arguments conservative while treating unfamiliar readable launcher syntax as insufficient evidence of custody. Preserve capture and retained-runtime references in argv, option values, and cwd, using one batched macOS cwd probe.

Thanks @Marvinthebored for the report and reproduction in #159950.
Keep the cleanup veto for relative or unresolved entrypoints when cwd inspection fails. Reuse the canonical entrypoint path classifier so unfamiliar launcher flags cannot hide explicit OpenClaw paths, while unrelated Bun processes with readable cwd remain clear.
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 28, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 28, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 28, 2026
@steipete
steipete force-pushed the upd/upd-census-unrelated-bun branch from 8828248 to 60605b5 Compare September 28, 2026 14:45
@steipete
steipete enabled auto-merge (squash) September 28, 2026 14:54
@steipete
steipete merged commit f7462d5 into main Sep 29, 2026
189 of 196 checks passed
@steipete
steipete deleted the upd/upd-census-unrelated-bun branch September 29, 2026 15:49
@steipete

Copy link
Copy Markdown
Contributor Author

Landed as f7462d5 under the pre-existing-red rule. The remaining CI failures on head 6ca0c65 were all current main reds from #161124 (also failing on main's hourly): src/gateway/server-restart-sentinel.test.ts, src/gateway/github-shared-publication-events.test.ts, src/gateway/server.sessions.list-changed.test.ts, src/gateway/github-publication-personal-pending.test.ts. None of those files are touched by this PR; every other lane passed, with no cancelled jobs.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…nclaw#160158)

The process census treated unfamiliar-but-readable argv as a failed inspection, so an unrelated `bun run --silent` process vetoed Doctor's legacy plugin-capture and retained-runtime cleanup. The census now returns a closed holder | non-holder | unresolved result: only positive evidence of foreignness permits cleanup, and every unresolved evidence source (unreadable argv/cwd/package identity, batch timeout) keeps the veto.

Closes openclaw#159950. Replaces openclaw#159951 (thanks @Marvinthebored for the finding).

Landed under the pre-existing-red rule: remaining CI failures are current main reds from openclaw#161124 (server-restart-sentinel, github-shared-publication-events, server.sessions.list-changed, github-publication-personal-pending).
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 gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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.

[Bug]: doctor --fix skips cleanup while an unrelated bun run --silent process is running

1 participant