Repository navigation
fix(systemd): honor effective drop-in configuration - #129170
Conversation
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
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 4:54 AM ET / 08:54 UTC. ClawSweeper reviewWhat this changesThe 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 provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherGateway 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +505, Tests +873, Docs +2. Total +1380 across 24 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready proof for exact head
Native review artifacts validate as |
|
Merged via squash.
|
* 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
… 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]>
… 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]>
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
ExecStartbut 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, andUnsetEnvironment, plusFragmentPath,DropInPaths, andNeedDaemonReload. 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/KillModeaudit is intentionally unchanged.User Impact
openclaw gateway statusreports the command, working directory, and unit-defined environment systemd has actually loaded.Systemd reload: pendingwhen on-disk unit changes have not been loaded yet.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
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.daemon-reloadCLI JSON and text report the loaded command plusreloadPending/Systemd reload: pending;UnsetEnvironmentbehavior after reload;