Skip to content

fix(doctor): unblock cleanup when foreign system cwd is unreadable - #166335

Merged
vincentkoc merged 9 commits into
mainfrom
fix/foreign-nonruntime-cwd-20261006
Oct 7, 2026
Merged

vincentkoc merged 9 commits into
mainfrom
fix/foreign-nonruntime-cwd-20261006

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: Doctor and update runtime cleanup retain every temporary candidate when an unrelated system process has an unreadable working directory.

User Impact

Cleanup can proceed past a positively identified foreign-user, non-runtime process such as systemd. Processes with retained-runtime references, OpenClaw markers, unknown ownership, or ambiguous runtime arguments still block cleanup. No configuration, migration, or manual cleanup is required.

Why This Change Was Made

The process census rejected missing working directories before checking whether an inspected process could be an OpenClaw runtime. The narrow exception now applies only after retained-artifact and OpenClaw identity checks, and only when ownership is positively foreign and argument parsing definitively excludes a runtime. Same-user and unknown-owner handling is unchanged.

Evidence

  • The regression failed on the unchanged implementation. pnpm test src/infra/openclaw-process-census.test.ts --maxWorkers=1 --reporter=dot passed 98/98 tests: 19.79 s wall time, 17.29 s reported test-run duration, including 15.362 s cold compilation. Hosted CI cost is not yet measured.
  • pnpm format:check for both changed files, node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/infra/openclaw-process-census.ts src/infra/openclaw-process-census.test.ts, and git diff HEAD^ HEAD --check passed.
  • Independent review found no blocking issue at signed commit 5484773df113a1b60f412215214ecab7edba5a24.
  • This is source-level regression proof, not a claim that a running updater was modified or that live cleanup has completed.
  • The first trusted Linux allocation attempt timed out after 15 minutes while still queued, before candidate execution. No package build or integration test ran in that allocation; this was an infrastructure block, not a regression-test failure. The task-owned allocation was stopped through its native lifecycle.
  • Package Acceptance run 37554681010, attempt 1 passed package integrity, npm 12 installation and the published-driver update cell for exact candidate 5484773df113a1b60f412215214ecab7edba5a24. Published driver 2026.9.8 updated to candidate 2026.9.8; the sole lane passed in 630 s. Native assertions verified the finished update, readiness HTTP 200, running version, durable and incognito state preservation, and fixture service stop.
  • Native cleanup acceptance run 37564827178, attempt 1 passed resolver, package integrity, npm 12 installation, and the real non-container cleanup test using the same immutable 5484773df113a1b60f412215214ecab7edba5a24 package. The independently reviewed harness was 2ebfe578918dd4f6b340e6ce07d70a633280fcbd. The test verified a separate non-root inspector, foreign system-process ownership with an unreadable cwd, retention while an exact owned holder remained live, and native Doctor removal plus actual absence after that holder settled. The unrelated sentinel survived and fixture cleanup completed. The selected npm job took 131 s; Docker and Telegram lanes were not repeated.
  • Current product-only head c0b6ce45d346a21c3a37b747ac292b6f248c5248 has exactly the same complete Git tree as 5484773. A signed forward commit removed only the optional validation-harness changes from this PR; their source/history remains retained for separate follow-up, including its unresolved analyzer-model qualification. No security finding was dismissed. The unit and integration evidence above is reused by exact input equality; it is not a claim that older CI belongs to the current head.
  • Independent exact-head review is READY. Current-head CI, security, and native landing gates still apply. This PR does not perform live cleanup or deployment.

Allow retained-runtime cleanup to continue when a process with a positively foreign UID has readable non-runtime arguments but an unavailable working directory. Preserve explicit retained-runtime references, OpenClaw identity and service markers, and fail-closed handling for same or unknown owners and runtime ambiguity.
@vincentkoc vincentkoc self-assigned this Oct 6, 2026
@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.

@vincentkoc
vincentkoc marked this pull request as ready for review October 6, 2026 23:05
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 11:17 PM ET / October 7, 2026, 03:17 UTC (Revision 6).

ClawSweeper review

What this changes

Doctor and update cleanup can ignore positively foreign-user, non-runtime processes whose working directories are unreadable while preserving checks for live OpenClaw holders.

Merge readiness

✅ Ready for maintainer review

This repair remains necessary on current main. No blocking patch defect was found, and the successful native acceptance evidence resolves the previous review’s cleanup-proof request.

Priority: P2
Reviewed head: c0b6ce45d346a21c3a37b747ac292b6f248c5248

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with meaningful negative controls, installed native cleanup evidence, and published-driver upgrade coverage.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The installed native Doctor acceptance exercises the changed census through real cleanup on a non-container Linux host: denied foreign cwd no longer blocks removal, the exact live holder prevents deletion, and settlement permits removal while preserving a sentinel. Published-driver upgrade evidence covers installation and state preservation. Current head has the identical tested product tree; no stored-data contract changes require migration.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The installed native Doctor acceptance exercises the changed census through real cleanup on a non-container Linux host: denied foreign cwd no longer blocks removal, the exact live holder prevents deletion, and settlement permits removal while preserving a sentinel. Published-driver upgrade evidence covers installation and state preservation. Current head has the identical tested product tree; no stored-data contract changes require migration.
Evidence reviewed 8 items Pinned introduced repair: The introduced delta adds a narrow exception requiring missing cwd, non-OpenClaw identity, definitively non-runtime arguments, and known unequal UIDs. Retained-artifact and OpenClaw holder checks run first.
Still needed on current main: Fetched main still rejects unavailable cwd before excluding a definitively non-runtime process; it does not contain this exception. The latest release uses an older census implementation and does not establish that this repair has shipped.
Regression and conservative controls: Added cases cover foreign, same, and unknown ownership; ambiguous Node/Bun/tsx runtime arguments; retained-runtime paths; and OpenClaw markers. The captured body reports a pre-fix failure and 98/98 passing tests in 19.79 seconds after repair. Tests were inspected, not executed during this read-only review.
Findings None None.
Security None None.

How this fits together

The process census checks whether running processes could still hold temporary OpenClaw artifacts. Doctor and update cleanup consume its result before removing abandoned runtime directories.

flowchart TD
  A[Host process records] --> B[Process census]
  B --> C[Retained artifact and OpenClaw checks]
  C --> D[Runtime arguments and ownership]
  D --> E[Holder or unresolved evidence]
  D --> F[Verified non-holder]
  E --> G[Preserve temporary runtime]
  F --> H[Guarded cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +12, Tests +55. Total +67 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 1 +12
Tests 1 55 0 +55
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 68 1 +67

Review metrics

None.

Technical review

Best possible solution:

Keep cleanup conservative for possible runtime holders while allowing confirmed foreign system processes to stop vetoing abandoned-runtime removal.

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

Yes: current main rejects a foreign system process with readable non-runtime arguments and unavailable cwd. Source establishes that path; this reviewer did not execute it.

Is this the best way to solve the issue?

Yes: the exception belongs in the existing census owner and preserves ambiguity, holder, ownership, and final cleanup safeguards.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The installed native Doctor acceptance exercises the changed census through real cleanup on a non-container Linux host: denied foreign cwd no longer blocks removal, the exact live holder prevents deletion, and settlement permits removal while preserving a sentinel. Published-driver upgrade evidence covers installation and state preservation. Current head has the identical tested product tree; no stored-data contract changes require migration.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This bounded cleanup defect retains temporary runtime artifacts without preventing the demonstrated update from completing.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The installed native Doctor acceptance exercises the changed census through real cleanup on a non-container Linux host: denied foreign cwd no longer blocks removal, the exact live holder prevents deletion, and settlement permits removal while preserving a sentinel. Published-driver upgrade evidence covers installation and state preservation. Current head has the identical tested product tree; no stored-data contract changes require migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The installed native Doctor acceptance exercises the changed census through real cleanup on a non-container Linux host: denied foreign cwd no longer blocks removal, the exact live holder prevents deletion, and settlement permits removal while preserving a sentinel. Published-driver upgrade evidence covers installation and state preservation. Current head has the identical tested product tree; no stored-data contract changes require migration.

Evidence

What I checked:

  • Pinned introduced repair: The introduced delta adds a narrow exception requiring missing cwd, non-OpenClaw identity, definitively non-runtime arguments, and known unequal UIDs. Retained-artifact and OpenClaw holder checks run first. (src/infra/openclaw-process-census.ts:67, c0b6ce45d346)
  • Still needed on current main: Fetched main still rejects unavailable cwd before excluding a definitively non-runtime process; it does not contain this exception. The latest release uses an older census implementation and does not establish that this repair has shipped. (src/infra/openclaw-process-census.ts:67, 8fffecae0861)
  • Regression and conservative controls: Added cases cover foreign, same, and unknown ownership; ambiguous Node/Bun/tsx runtime arguments; retained-runtime paths; and OpenClaw markers. The captured body reports a pre-fix failure and 98/98 passing tests in 19.79 seconds after repair. Tests were inspected, not executed during this read-only review. (src/infra/openclaw-process-census.test.ts:517, c0b6ce45d346)
  • Proof inputs match current product tree: The original tested product commit and current head both resolve to tree 4295473c0cbb888387d470d2569bfc37caa2ad93. Their complete-tree diff is empty, supporting reuse of product behavior evidence without attributing older CI to the current head. (c0b6ce45d346)
  • Installed native Doctor acceptance: GitHub confirms successful native cleanup step and overall run https://github.com/openclaw/openclaw/actions/runs/37564827178. The pinned harness checks the installed candidate SHA, a non-root inspector facing foreign PID 1 with denied cwd, retention of the exact live holder, removal and actual absence after settlement, and preservation of an unrelated sentinel. These assertions match the captured body’s observed results and resolve the previous rank-up request. Raw log retrieval was blocked by the reviewer network allowlist; the successful step and pinned assertions were independently inspected. (scripts/e2e/retained-runtime-cleanup-native.sh:302, 2ebfe578918d)
  • Published-driver upgrade evidence: GitHub confirms successful Package Acceptance run https://github.com/openclaw/openclaw/actions/runs/37554681010 at the identical product-tree commit. The captured body records published driver 2026.9.8 updating to the candidate, readiness HTTP 200, and preservation of durable and incognito state. (5484773df113)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-06T23:11:02.067Z sha 5484773 :: needs changes before merge. :: none
  • reviewed 2026-10-07T00:57:47.731Z sha 5484773 :: blocked before merge. :: none
  • reviewed 2026-10-07T01:38:55.761Z sha 5484773 :: needs changes before merge. :: none
  • reviewed 2026-10-07T02:07:12.887Z sha a3e3f8e :: needs changes before merge. :: none
  • reviewed 2026-10-07T02:56:40.918Z sha 5e3106d :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 7, 2026
Add an opt-in native-cleanup Package Acceptance profile that reuses an integrity-checked candidate and npm 12 install without Docker, live, Telegram, or preparation lanes.

Require a real non-root Linux permission boundary, retain the runtime while an owned holder is alive, then verify abandoned-runtime removal and unrelated sentinel preservation after that exact holder settles. Bound tooling fixture spawns and use the compatible Darwin shell for their heredocs.
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M and removed size: S labels Oct 7, 2026
Retain the independently validated harness in parent history for follow-up. Restore the product tree exactly to 5484773; published-driver and native-host cleanup proof remain bound to that immutable package.
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed scripts Repository scripts size: XL labels Oct 7, 2026
@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Oct 7, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Oct 7, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) October 7, 2026 03:21
@vincentkoc
vincentkoc merged commit d1b8902 into main Oct 7, 2026
135 checks passed
@vincentkoc
vincentkoc deleted the fix/foreign-nonruntime-cwd-20261006 branch October 7, 2026 03:22
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…penclaw#166335)

* fix(doctor): unblock cleanup when foreign system cwd is unreadable

Allow retained-runtime cleanup to continue when a process with a positively foreign UID has readable non-runtime arguments but an unavailable working directory. Preserve explicit retained-runtime references, OpenClaw identity and service markers, and fail-closed handling for same or unknown owners and runtime ambiguity.

* test(ci): add native retained-runtime cleanup acceptance

Add an opt-in native-cleanup Package Acceptance profile that reuses an integrity-checked candidate and npm 12 install without Docker, live, Telegram, or preparation lanes.

Require a real non-root Linux permission boundary, retain the runtime while an owned holder is alive, then verify abandoned-runtime removal and unrelated sentinel preservation after that exact holder settles. Bound tooling fixture spawns and use the compatible Darwin shell for their heredocs.

* fix(ci): bind native cleanup to defining workflow

* fix(ci): validate serialized defining workflow identity

* test(update): isolate native cleanup acceptance account

* fix(ci): isolate workflow identity and cleanup lifetime

* fix(ci): read checkout identity from defining job

* fix(ci): preserve native launcher when isolating cleanup fixture

* fix(ci): keep cleanup validation harness outside runtime repair

Retain the independently validated harness in parent history for follow-up. Restore the product tree exactly to 5484773; published-driver and native-host cleanup proof remain bound to that immutable package.
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
…166335)

* fix(doctor): unblock cleanup when foreign system cwd is unreadable

Allow retained-runtime cleanup to continue when a process with a positively foreign UID has readable non-runtime arguments but an unavailable working directory. Preserve explicit retained-runtime references, OpenClaw identity and service markers, and fail-closed handling for same or unknown owners and runtime ambiguity.

* test(ci): add native retained-runtime cleanup acceptance

Add an opt-in native-cleanup Package Acceptance profile that reuses an integrity-checked candidate and npm 12 install without Docker, live, Telegram, or preparation lanes.

Require a real non-root Linux permission boundary, retain the runtime while an owned holder is alive, then verify abandoned-runtime removal and unrelated sentinel preservation after that exact holder settles. Bound tooling fixture spawns and use the compatible Darwin shell for their heredocs.

* fix(ci): bind native cleanup to defining workflow

* fix(ci): validate serialized defining workflow identity

* test(update): isolate native cleanup acceptance account

* fix(ci): isolate workflow identity and cleanup lifetime

* fix(ci): read checkout identity from defining job

* fix(ci): preserve native launcher when isolating cleanup fixture

* fix(ci): keep cleanup validation harness outside runtime repair

Retain the independently validated harness in parent history for follow-up. Restore the product tree exactly to 5484773; published-driver and native-host cleanup proof remain bound to that immutable package.

(cherry picked from commit d1b8902)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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