Skip to content

fix(doctor): unblock runtime cleanup after systemd re-exec - #178117

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1711
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1711

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes update recovery getting stuck on retained runtimes when a Linux systemd user manager re-execs with --deserialize=<fd> and its (sd-pam) child has an unreadable working directory.

Fixes #177876.

User Impact

Doctor can reclaim abandoned updater runtimes and release their recovery-journal hardlinks so updating can continue. Actual runtime holders and unverified processes remain protected. No new settings, schema changes, or operator actions are introduced.

Why This Change Was Made

The process-census owner required exactly two argv entries, so the legitimate deserialization argument also defeated its same-UID PAM-child exemption. The existing predicate now accepts one optional numeric deserialization argument while retaining the exact executable paths, account checks, parent relationship, and artifact-custody checks. Both Doctor cleanup and update repair consume that same owner.

This independently reimplements the fix and consolidates the existing systemd test coverage. Supersedes #177911, thanks @sunlit-deng.

Evidence

  • Red on base 578578cdeca99cfea9d32df2ee6c46197a3c22aa: both deserialized-manager cases failed with manager/PAM PIDs and unavailable-cwd warnings; the standard-manager case passed. The run took 357.11 seconds overall, with 257.5 seconds spent preparing the shared worker bundle.
  • Focused and sibling run: 312 tests passed across 11 files in 264.60 seconds overall; one Windows-only native test/file skipped on macOS. The changed census file passed all 120 tests in 467 ms. Shared worker preparation took 100.4 seconds; no individual test exceeded 30 seconds. After compacting the malformed-argument fixture, the final census-only rerun passed all 120 tests in 638 ms (44.94 seconds overall, dominated by transform/preparation).
  • Targeted production and infra-test typechecks passed (tsconfig.core.json and test/tsconfig/tsconfig.core.test.infra.json). Oxlint passed on both changed TypeScript files, oxfmt and git diff --check passed, and the Madge import-cycle check reported zero cycles. The census file stays below the existing 1,000-line lint limit without a suppression or baseline edit.
  • A broader test-type selection encountered inherited failures: gateway-root has 726 test roots and plugins-platform 727 against the advisory 720 limit; ui/src/e2e/session-scoped-delivery.e2e.test.ts:103 reports TS2367. These files and inventories are unchanged. Full check:changed was not run because its SQLite inventory stalls locally; focused checks and PR CI provide the selected proof.
  • Live Linux/systemd proof is blocked. Local Docker answered image/version/list queries, but docker run --rm --network none node:26-bookworm sh -c 'command -v systemd || true; ls -l /sbin/init 2>/dev/null || true; node --version' never created a container or produced output after more than five minutes. The task-owned client was stopped; no shared service was restarted. The census regression uses synthetic Linux procfs observations, not a live systemd manager.
  • Independent Codex review was attempted but failed authentication and produced no verdict. Maintainer review is still needed.
  • Delta: production +5/-5 (net 0), tests +7/-4 (net +3), documentation +5/-0. Duplicate standard-manager custody rows moved into the existing manager/PAM table; malformed deserialization stays covered by the custody table. No changelog edit; the behavior, issue reference, and contributor credit above provide release-note context.
Focused command
HOME="$PWD/.artifacts/home" OPENCLAW_STATE_DIR="$PWD/.artifacts/state" \
node scripts/run-vitest.mjs \
  src/infra/openclaw-process-census.missing-command.test.ts \
  src/infra/windows-process-census.native.test.ts \
  src/infra/openclaw-process-census.test.ts \
  src/infra/update-retained-runtime.test.ts \
  src/plugins/plugin-source-capture-directory.test.ts \
  src/plugins/plugin-source-capture-recovery.test.ts \
  src/flows/doctor-plugin-source-captures.test.ts \
  src/flows/doctor-retained-runtime.settlement.test.ts \
  src/flows/doctor-retained-runtime.test.ts \
  src/infra/update-managed-service-handoff-recovery.test.ts \
  src/cli/update-cli/update-repair-handoff.test.ts \
  src/infra/update-managed-service-handoff-cleanup-repair.test.ts \
  --maxWorkers=1 --reporter=default

Recognize a standard systemd user manager with a numeric deserialize fd so
its protected PAM child does not block abandoned updater runtime cleanup.
Preserve account, parent, and artifact-custody checks in the census owner
shared by Doctor and update repair.

Fixes #177876.

Co-authored-by: sunlit-deng <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 20, 2026
@steipete
steipete marked this pull request as ready for review October 20, 2026 05:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T05:52:36.529646Z 60c7e6b Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60c7e6b802

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +34 to +36
argv.length <= 3 &&
argv[1] === "--user" &&
argv.slice(2).every((arg) => /^--deserialize=\d+$/u.test(arg)) &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Accept systemd's split deserialize form

On hosts running systemd 249, the upstream re-exec path emits four argv elements—--user, --deserialize, and the fd separately (systemd v249 source). The new argv.length <= 3 check and --deserialize=\d+ matcher therefore reject that legitimate manager, so it and its (sd-pam) child remain unverified when their cwd is unreadable and continue blocking Doctor cleanup/update repair. Accept the split --deserialize, <fd> representation as well as the newer equals form.

AGENTS.md reference: AGENTS.md:L75-L76

Useful? React with 👍 / 👎.

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 size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 2026.10.5 Doctor runtime cleanup blocked by sd-pam with systemd --user --deserialize

1 participant