Skip to content

fix(systemd): honor effective drop-in configuration - #129170

Merged
steipete merged 3 commits into
mainfrom
steipete/kind-allen-2aee11
Aug 25, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/kind-allen-2aee11

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #128929
Related: #128604

What Problem This Solves

Fixes an issue where Linux operators using systemd drop-ins could get an internally inconsistent service view: OpenClaw observed the manager-loaded ExecStart but still used base-file working-directory and environment metadata. Status, doctor, start repair, reinstall, and updater flows could therefore diagnose or rewrite the wrong service definition.

It also resolves the pending-reload ambiguity reported in #128929. OpenClaw continues to report the configuration the systemd user manager has actually loaded, while clearly warning when newer unit or drop-in files are waiting for daemon-reload.

Why This Change Was Made

The systemd reader now obtains one structured manager snapshot for ExecStart, WorkingDirectory, Environment, EnvironmentFiles, and UnsetEnvironment, plus FragmentPath, DropInPaths, and NeedDaemonReload. The OpenClaw-managed base definition is retained separately for writes, while loaded drop-in provenance identifies operator-owned launcher and environment directives, including equal-valued overrides and source-specific empty resets.

Mutation paths use the managed definition and fail closed when a rewrite would be ineffective or could adopt operator-owned values. Manager calls still share one total deadline, but each call reserves a fair portion so a slow successful lookup cannot starve later property reads. The neighboring effective After/Wants/RestartUSec/KillMode audit is intentionally unchanged.

User Impact

  • openclaw gateway status reports the command, working directory, and unit-defined environment systemd has actually loaded.
  • Status prints Systemd reload: pending when on-disk unit changes have not been loaded yet.
  • Doctor and start repair no longer claim to fix launcher or environment state still controlled by an operator drop-in.
  • Forced installs warn when a launcher drop-in remains effective.
  • Update-time metadata refresh does not persist drop-in-only or removed credentials into the managed base service.
  • Environment-only customizations remain supported, and unrelated drop-ins do not block valid repairs.

Thanks @aniruddhaadak80 for reporting the pending-reload and deadline behavior in #128929.

AI-assisted: yes. The implementation, tests, Docker proof, and review findings were inspected and verified by the maintainer.

Evidence

  • Focused Vitest suite: 467 tests passed; one existing test skipped across systemd, service audit, doctor, install/start/status, node daemon, and updater coverage.
  • node scripts/check-changed.mjs -- <23 changed files>: all selected formatting, lint, production/test typecheck, architecture, dead-export, import-cycle, docs, and repository guards passed.
  • pnpm build: passed. The only warnings were the existing Control UI ineffective-dynamic-import warnings.
  • Fresh P0-P2 autoreview: no accepted/actionable findings.
  • Real Docker proof: Node 24 Bookworm container running a real systemd user manager and the built OpenClaw CLI. Verified:
    • manager-loaded base state;
    • pre-daemon-reload CLI JSON and text report the loaded command plus reloadPending/Systemd reload: pending;
    • effective drop-in command, working directory, inline environment, environment files, and UnsetEnvironment behavior after reload;
    • equal-valued drop-in ownership;
    • forced-install surviving-override warning;
    • no-drop-in canonical behavior;
    • manager-offline coherent fallback with unknown provenance.
  • Production LOC: +695/-190 (net +505). Tests: +969/-96 (net +873). Docs: +6/-4 (net +2). The production growth establishes the structured manager contract, separates effective and managed ownership, and protects every service mutation path from ineffective rewrites or credential adoption; a local fragment-only parser cannot reproduce systemd’s loaded drop-in semantics safely.

Read one coherent manager-loaded service snapshot while retaining the managed base definition for repairs. Track drop-in ownership, surface pending daemon reloads, and keep update and doctor rewrites from adopting operator-owned values.

Closes #128929
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 25, 2026 08:47
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations size: XL maintainer Maintainer-authored PR labels Aug 25, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 4:54 AM ET / 08:54 UTC.

ClawSweeper review

What this changes

The PR makes Linux gateway-service handling distinguish systemd’s loaded effective unit from OpenClaw’s managed base unit, including drop-ins and pending reload state.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review: this active maintainer-labeled PR has no concrete correctness finding in the inspected reader, caller, redaction, and regression-test paths.

Priority: P2
Reviewed head: dabc155a0d75d3600afff8f3c16b9d726c11b43b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has coherent owner-boundary handling and focused regression coverage, with no actionable defect found in this review.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated real Docker/systemd evidence is supporting context.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated real Docker/systemd evidence is supporting context.
Evidence reviewed 6 items Effective service reader: The reader makes three bounded systemd manager calls, validates the returned shapes, and retains a separate managed definition for writes.
Systemd D-Bus contract: The direct systemd interface contract matches the new Environment, EnvironmentFiles, UnsetEnvironment, and NeedDaemonReload signatures used by the reader.
Reader boundary coverage: Regression coverage exercises effective command, working directory, environment files, UnsetEnvironment, ownership, deadline allocation, and pending-reload handling.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/daemon/systemd.test.ts

Result: FAIL (failed) — execution before step 1 run: live-proof package manager pnpm is unavailable after its official installer (curl -fsSL https://get.pnpm.io/install.sh | sh -): command failed without output

live-proof package manager pnpm is unavailable after its official installer (curl -fsSL https://get.pnpm.io/install.sh | sh -): command failed without output

Assertions:

  • FAIL expect_output: Tests

How this fits together

Gateway status, doctor, installation, start repair, and updates all consume service metadata. On Linux, systemd merges a base unit with drop-ins, so the service reader must preserve both the effective runtime view and the OpenClaw-owned write target.

flowchart LR
  A[Managed base unit] --> C[Systemd user manager]
  B[Operator drop-ins] --> C
  C --> D[Effective service snapshot]
  A --> E[Managed base snapshot]
  D --> F[Status and diagnostics]
  D --> G[Repair safety checks]
  E --> H[Install and update writes]
Loading

Before merge

  • Resolve merge risk (P1) - This changes the source of truth used by existing Linux status, doctor, install, start-repair, and update flows; exact-head checks should retain coverage for upgrades with operator-owned drop-ins and credentials.
  • Complete next step (P2) - This active maintainer-owned, maintainer-labeled PR needs normal exact-head review rather than a replacement repair job.
Agent review details

Security

None.

PR surface

Source +505, Tests +873, Docs +2. Total +1380 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 12 695 190 +505
Tests 9 969 96 +873
Docs 3 6 4 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 24 1670 290 +1380

Review metrics

Metric Value Why it matters
Production versus test scope production +505 net; tests +873 net; docs +2 net The larger production change establishes a shared effective-versus-managed service contract across service mutation paths.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/cli/daemon-cli/start-repair.ts, migration/backfill/repair: src/commands/doctor-gateway-services.ts, serialized state: src/daemon/systemd.test.ts, unknown-data-model-change: src/cli/daemon-cli/start-repair.ts, unknown-data-model-change: src/commands/doctor-gateway-services.test.ts, unknown-data-model-change: src/commands/doctor-gateway-services.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #128929
Summary: This PR explicitly targets the pending-reload and effective-systemd-state behavior reported by the canonical issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Confirm drop-in upgrade behavior (recommended)
    Before merge, retain exact-head validation that a managed base rewrite preserves operator drop-ins and does not persist drop-in-only credentials.

Technical review

Best possible solution:

Land one canonical effective-versus-managed service snapshot contract after exact-head CI confirms that writes preserve the managed base and never adopt drop-in-only values.

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

Yes, from source and focused tests: a loaded systemd drop-in can differ from the managed base, and the reader tests cover effective state, reload-pending state, and manager-call deadlines.

Is this the best way to solve the issue?

Yes: reading one manager-loaded snapshot while retaining the base unit as the sole write target is the narrowest maintainable way to avoid mixing effective and managed state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 24898ba8940e.

Labels

Label changes:

  • add P2: This repairs a bounded Linux gateway-service diagnostic and repair correctness problem.
  • add merge-risk: 🚨 compatibility: Existing systemd installations with drop-ins can see different status and repair decisions under the new ownership model.
  • add merge-risk: 🚨 auth-provider: The service-environment changes deliberately handle gateway and provider credentials and must not adopt operator-owned values.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated real Docker/systemd evidence is supporting context.

Label justifications:

  • P2: This repairs a bounded Linux gateway-service diagnostic and repair correctness problem.
  • merge-risk: 🚨 compatibility: Existing systemd installations with drop-ins can see different status and repair decisions under the new ownership model.
  • merge-risk: 🚨 auth-provider: The service-environment changes deliberately handle gateway and provider credentials and must not adopt operator-owned values.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated real Docker/systemd evidence is supporting context.

Evidence

What I checked:

  • Effective service reader: The reader makes three bounded systemd manager calls, validates the returned shapes, and retains a separate managed definition for writes. (src/daemon/systemd-service-files.ts:89, dabc155a0d75)
  • Systemd D-Bus contract: The direct systemd interface contract matches the new Environment, EnvironmentFiles, UnsetEnvironment, and NeedDaemonReload signatures used by the reader. (src/daemon/systemd-service-files.ts:137, dabc155a0d75)
  • Reader boundary coverage: Regression coverage exercises effective command, working directory, environment files, UnsetEnvironment, ownership, deadline allocation, and pending-reload handling. (src/daemon/systemd.test.ts:1425, dabc155a0d75)
  • Mutation and credential safety: Install, doctor, and update callers use the managed definition for writes, block operator-owned overrides, and omit managed metadata from JSON status output. (src/commands/doctor-gateway-services.ts:755, dabc155a0d75)
  • Current implementation provenance: The central reader lines are attributed to the current PR head author in local blame. (src/daemon/systemd-service-files.ts:89, dabc155a0d75)
  • Baseline retrieval limitation: The checkout supplied the PR head, but fetching the base/current-main objects required by its promisor remote failed because GitHub DNS was unavailable; no independent base-diff or release-history claim is made.

Likely related people:

  • steipete: Current central reader lines blame to Peter Steinberger, and local history identifies the same author on the PR head and prior systemd work. (role: recent area contributor; confidence: high; commits: dabc155a0d75, 904375f39eb5; files: src/daemon/systemd-service-files.ts, src/daemon/service-types.ts)

Rank-up moves

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

  • Keep the stated real-systemd Docker proof and exact-head CI as the final upgrade-safety confirmation.

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

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 4da871904617b8f1e0d6181bac75428312d19518:

  • Focused Vitest coverage passed: 467 tests, with one pre-existing skipped test, across the systemd reader, service audit, doctor, daemon install/start/status, node daemon, and updater paths.
  • The exact Linux doctor CI file group passed locally with CI=1 OPENCLAW_VITEST_MAX_WORKERS=3; the original failed merge-commit group then passed 20/20 bounded stress runs. The test contract was corrected so Linux ownership behavior is explicit rather than relying on the maintainer's macOS platform.
  • node scripts/check-changed.mjs -- <changed paths> passed every selected formatting, lint, production/test typecheck, docs, architecture, dead-export, import-cycle, and repository-policy guard.
  • pnpm build passed. Only the existing Control UI ineffective-dynamic-import warnings were emitted.
  • Real Docker behavior proof passed in Node 24 Bookworm with a real systemd user manager and the built OpenClaw CLI: pre-reload JSON/text visibility, effective command/directory/environment/drop-in state, EnvironmentFile and UnsetEnvironment precedence, equal-valued ownership, force-install warning, canonical no-drop-in state, and manager-offline fallback.
  • Fresh P0-P2 Codex autoreview: no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/32830849415 — green, pending=0.
  • ClawSweeper's rank-up move is satisfied: exact-head CI is green and the real-systemd Docker proof is retained in the PR evidence. The ClawSweeper live worker's pnpm bootstrap failure is not a product/test failure.
  • Production LOC +695/-190 (net +505); tests +969/-96 (net +873); docs +6/-4 (net +2). The production growth establishes the manager-effective versus managed-base ownership contract across every service mutation path.

Native review artifacts validate as READY FOR /prepare-pr, issueValidation.status=valid, behavioral sweep pass, and zero findings.

@steipete
steipete merged commit fda20a6 into main Aug 25, 2026
228 checks passed
@steipete
steipete deleted the steipete/kind-allen-2aee11 branch August 25, 2026 09:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
* fix(systemd): honor effective drop-in configuration

Read one coherent manager-loaded service snapshot while retaining the managed base definition for repairs. Track drop-in ownership, surface pending daemon reloads, and keep update and doctor rewrites from adopting operator-owned values.

Closes openclaw#128929

* fix(systemd): expose reload status in service snapshot

* test(systemd): cover Linux doctor ownership
obviyus added a commit that referenced this pull request Nov 22, 2026
… bus (#203769)

Related: #203735

## What Problem This Solves

The first update of an npm, pnpm, or Bun global install can fail on Linux when no Gateway service is installed and the systemd user bus is unavailable. Containers, WSL without systemd, and Gateways started by hand or by another supervisor should not need a systemd session to prepare an update.

## User Impact

These installs can prepare their next release without a service manager. A detected installed unit still requires effective inspection and retains the existing session-repair instructions when the bus is unavailable. No flags, retries, states, or service-reader behavior change.

## Why This Change Was Made

`src/update/convert-service.ts:23` requested `readCommand(..., { requireEffective: true })` before checking whether there was a definition to rebind. The systemd reader deliberately queries the manager even without a local base file because global and loaded fragments can exist (`src/daemon/systemd-service-files.ts:578-590,657-675`; introduced by #129170). Changing that reader would break valid inspection.

Conversion now consumes the existing `hasInstalledDefinition` operation before requesting the effective command. Only this conversion caller changes; status, install/uninstall, Doctor, lifecycle, node-service inspection, and update admission retain their existing discovery and refusal behavior. Production delta: +3 lines. Tests: +53/-2 lines.

Accepted edge case: the existing Linux definition probe scans `~/.config/systemd/user` (current/legacy profile or explicit unit identity), `/etc/systemd/system`, `/usr/lib/systemd/system`, `/lib/systemd/system`, and marker-owned system units in those system directories. The manager reader can also load global user fragments such as `/etc/systemd/user` and alternate XDG/runtime/custom load paths. This PR does not expand shared discovery. An undetected unit is not rewritten: its standard old package entry still reaches the launcher after `markForwarding` writes `.openclaw-launcher` (`src/update/run.ts:365,416-426`). Both `openclaw.mjs` and `src/index.ts:35-40` use `release-launcher-forward.mjs:13-41`, which reads that marker and imports the resident launcher. This is the same retained-entry route used by system-owned definitions and the documented next-start contract (`docs/install/updating.md:31-41`).

## Evidence

- Base `42f8c5bcb9f51973338a3d26c0e75fe7c6be65d7`: focused regression fails with `systemd-user-bus-unavailable` for no unit/no bus; the installed-unit refusal passes. This used the real Linux service adapter and native-command failure fixture, not a mocked presence answer.
- Green (vitest-source): one `ocx test` call passed all 261 tests in 10 files, including conversion, package preparation, and the existing systemd reader/transport/mutation suites (165.95s runner time). Conversion file: 4 tests, 8.47s wall; absent-unit case 23ms, installed-unit refusal 14ms. CI time is not yet available.
- `pnpm check:changed`: core/test typechecks, touched-file lint/format, and the other guards passed. The command exits 1 on its repository-wide Knip dead-export scan in untouched CLI/cron/gateway/update files (including `LAUNCHER_FORMAT`, `InstallKind`, and old update-CLI test helpers). This PR changes none of those exports.
- Full candidate build (`ocx build --dts`) passed: build phase 389s, followed by canonical packing and tarball integrity/import-graph checks (48s checker). Build emitted unrelated Control UI asset-budget warnings.
- Linux proof candidate is local merge `121bbb9a73aca806edfc8dc0f0efd1ff336ef39a`, containing PR head `e6ef2df3aa04ec10d4bfb274ac4d6ca71b2964ef` plus `main` at `58a3c7e9a8f2bd47369edd7a3af68df122ecf5c3` (#203735); the proof merge is not pushed. Tarball SHA-256: `65884047f686abcc53b22c52adfecaf9fc716d525386de618426c697aacf01f9`.
- **Linux next-start proof PASS** on OrbStack Docker 29.8.2, Linux arm64, Node 24.22.1, uid 1001. A clean npm global install had no Gateway unit, no `busctl`/`systemctl`, no systemd boot, and no user bus. `update --tag file:<same-survivor-fixture.tgz> --yes --no-restart --json` exited 0 in 74.997s. Starting the **old package's direct `dist/index.js`** entry once reached `/readyz` in 5.513s (`ready:true`, `coreReady:true`, no failing checks; CPU advisory reported). RPC verified serving `2026.11.7-first-hop.0` / build `121bbb9`. Read-only SQLite inspection recorded exactly one `update_runs` row: `fb46f568-899d-4b76-bfbe-c1919ba2c7f4`, `finished/succeeded`, reason null, `verification.booted=true`, candidate running version/build verified. No live providers were used.
- Persisted successful-run timings (overlapping spans, not additive): requested 15.715s; staging 54.372s; prepare:pack 82.932s; prepare:install 34.103s; validating 2.544s; plugins 1.811s; activating 26.654s. Row lifetime 99.285s; isolated install/config 43.160s; proof core wall 144.681s (outer Docker command 149.17s). No pre-existing serving Gateway, so no update outage is claimed.
- **Requested `package-installed-recovery` scenario FAIL: harness asserts the retired legacy displacement hook** (`scripts/e2e/lib/upgrade-survivor/installed-recovery.mjs:128`). Its update now exits **0** in 74.453s, then the harness rejects that success because no legacy displacement interruption occurs. Returned ledger row `1a75c2e7-7841-449a-9b83-638e1c19f414` is `activating/running`, reason null, candidate recorded: the expected pending state for `--no-restart` (`src/update/cli.ts:273-275`). Completed phases: requested 14.754s, staging 54.164s, validating 3.006s, plugins 2.161s; prepare/activation spans were still open in that snapshot. Outer scenario wall 145.86s. No recovery cuts passed; the harness is unchanged. The separate next-start proof above closes the real activation/serving contract.
- Local ClawSweeper review on pushed head `e6ef2df3aa04ec10d4bfb274ac4d6ca71b2964ef`: complete, **patch is correct**, zero code findings, security cleared. Its synthetic local-range context did not include this PR's execution evidence and therefore marked real-behavior proof missing; the red/green receipts and successful Linux next-start/SQLite/RPC proof above supply that evidence. No code repair was requested.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 23, 2026
… bus (openclaw#203769)

Related: openclaw#203735

## What Problem This Solves

The first update of an npm, pnpm, or Bun global install can fail on Linux when no Gateway service is installed and the systemd user bus is unavailable. Containers, WSL without systemd, and Gateways started by hand or by another supervisor should not need a systemd session to prepare an update.

## User Impact

These installs can prepare their next release without a service manager. A detected installed unit still requires effective inspection and retains the existing session-repair instructions when the bus is unavailable. No flags, retries, states, or service-reader behavior change.

## Why This Change Was Made

`src/update/convert-service.ts:23` requested `readCommand(..., { requireEffective: true })` before checking whether there was a definition to rebind. The systemd reader deliberately queries the manager even without a local base file because global and loaded fragments can exist (`src/daemon/systemd-service-files.ts:578-590,657-675`; introduced by openclaw#129170). Changing that reader would break valid inspection.

Conversion now consumes the existing `hasInstalledDefinition` operation before requesting the effective command. Only this conversion caller changes; status, install/uninstall, Doctor, lifecycle, node-service inspection, and update admission retain their existing discovery and refusal behavior. Production delta: +3 lines. Tests: +53/-2 lines.

Accepted edge case: the existing Linux definition probe scans `~/.config/systemd/user` (current/legacy profile or explicit unit identity), `/etc/systemd/system`, `/usr/lib/systemd/system`, `/lib/systemd/system`, and marker-owned system units in those system directories. The manager reader can also load global user fragments such as `/etc/systemd/user` and alternate XDG/runtime/custom load paths. This PR does not expand shared discovery. An undetected unit is not rewritten: its standard old package entry still reaches the launcher after `markForwarding` writes `.openclaw-launcher` (`src/update/run.ts:365,416-426`). Both `openclaw.mjs` and `src/index.ts:35-40` use `release-launcher-forward.mjs:13-41`, which reads that marker and imports the resident launcher. This is the same retained-entry route used by system-owned definitions and the documented next-start contract (`docs/install/updating.md:31-41`).

## Evidence

- Base `b78a49f86a6be01b0b8fdd09d42882206a22f95d`: focused regression fails with `systemd-user-bus-unavailable` for no unit/no bus; the installed-unit refusal passes. This used the real Linux service adapter and native-command failure fixture, not a mocked presence answer.
- Green (vitest-source): one `ocx test` call passed all 261 tests in 10 files, including conversion, package preparation, and the existing systemd reader/transport/mutation suites (165.95s runner time). Conversion file: 4 tests, 8.47s wall; absent-unit case 23ms, installed-unit refusal 14ms. CI time is not yet available.
- `pnpm check:changed`: core/test typechecks, touched-file lint/format, and the other guards passed. The command exits 1 on its repository-wide Knip dead-export scan in untouched CLI/cron/gateway/update files (including `LAUNCHER_FORMAT`, `InstallKind`, and old update-CLI test helpers). This PR changes none of those exports.
- Full candidate build (`ocx build --dts`) passed: build phase 389s, followed by canonical packing and tarball integrity/import-graph checks (48s checker). Build emitted unrelated Control UI asset-budget warnings.
- Linux proof candidate is local merge `121bbb9a73aca806edfc8dc0f0efd1ff336ef39a`, containing PR head `e6ef2df3aa04ec10d4bfb274ac4d6ca71b2964ef` plus `main` at `bcdc3cc5b5b87c50fc656052009603d526db7b37` (openclaw#203735); the proof merge is not pushed. Tarball SHA-256: `65884047f686abcc53b22c52adfecaf9fc716d525386de618426c697aacf01f9`.
- **Linux next-start proof PASS** on OrbStack Docker 29.8.2, Linux arm64, Node 24.22.1, uid 1001. A clean npm global install had no Gateway unit, no `busctl`/`systemctl`, no systemd boot, and no user bus. `update --tag file:<same-survivor-fixture.tgz> --yes --no-restart --json` exited 0 in 74.997s. Starting the **old package's direct `dist/index.js`** entry once reached `/readyz` in 5.513s (`ready:true`, `coreReady:true`, no failing checks; CPU advisory reported). RPC verified serving `2026.11.7-first-hop.0` / build `121bbb9`. Read-only SQLite inspection recorded exactly one `update_runs` row: `fb46f568-899d-4b76-bfbe-c1919ba2c7f4`, `finished/succeeded`, reason null, `verification.booted=true`, candidate running version/build verified. No live providers were used.
- Persisted successful-run timings (overlapping spans, not additive): requested 15.715s; staging 54.372s; prepare:pack 82.932s; prepare:install 34.103s; validating 2.544s; plugins 1.811s; activating 26.654s. Row lifetime 99.285s; isolated install/config 43.160s; proof core wall 144.681s (outer Docker command 149.17s). No pre-existing serving Gateway, so no update outage is claimed.
- **Requested `package-installed-recovery` scenario FAIL: harness asserts the retired legacy displacement hook** (`scripts/e2e/lib/upgrade-survivor/installed-recovery.mjs:128`). Its update now exits **0** in 74.453s, then the harness rejects that success because no legacy displacement interruption occurs. Returned ledger row `1a75c2e7-7841-449a-9b83-638e1c19f414` is `activating/running`, reason null, candidate recorded: the expected pending state for `--no-restart` (`src/update/cli.ts:273-275`). Completed phases: requested 14.754s, staging 54.164s, validating 3.006s, plugins 2.161s; prepare/activation spans were still open in that snapshot. Outer scenario wall 145.86s. No recovery cuts passed; the harness is unchanged. The separate next-start proof above closes the real activation/serving contract.
- Local ClawSweeper review on pushed head `e6ef2df3aa04ec10d4bfb274ac4d6ca71b2964ef`: complete, **patch is correct**, zero code findings, security cleared. Its synthetic local-range context did not include this PR's execution evidence and therefore marked real-behavior proof missing; the red/green receipts and successful Linux next-start/SQLite/RPC proof above supply that evidence. No code repair was requested.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

[Bug]: Reported ExecStart prefers stale systemd manager state until daemon-reload, and shared D-Bus deadline starves property reads

1 participant