Skip to content

fix(daemon): handle multiline commands in systemd discovery - #176469

Merged
vincentkoc merged 3 commits into
mainfrom
fix/systemd-loaded-inventory-20261019
Oct 18, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
fix/systemd-loaded-inventory-20261019

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes complete Gateway service discovery failing when a loaded systemd command contains valid multiline arguments, which can block build and update safety checks.

User Impact

Service discovery preserves multiline and property-looking argument text and inspects every loaded command. Private-socket managers, including the default root route, require native transport support: disabling native support or lacking its helper reports inspection unavailable. It never silently selects another manager.

Why This Change Was Made

The inventory owner now reads typed D-Bus properties through one retained native connection per scope. It pins the selected manager before enumeration and verifies identity before publishing, including an empty result. This removes the human-readable record parser and redundant command re-query.

Broker routes retain typed CLI compatibility when native support is explicitly disabled or its helper is unavailable before connection ownership. Access, identity, deadline, malformed-response and cleanup failures remain terminal. The shared CLI query and existing command-marker owner keep those decisions in one place.

Production delta: +390/-197, net +193 lines, needed for typed framing and retained manager identity. Tests: +474/-45, net +429. One obsolete mock baseline entry is removed.

Evidence

  • 108 tests passed across the five affected systemd test files on integration commit 6a8a28a238a86fc2671d7fa635b46213105b9be1. These covered the original efc01cd inventory implementation. The subsequent correction preserves cleanup ordering while moving it outside finally, records the cleanup cause, and renames a test parameter; fresh hosted CI covers that exact head.
  • Live complete inventory passed for 3 user and 101 system units, including 13 multiline argument values.
  • Source review found no remaining actionable findings. Root/private, user, machine and broker routes, deadlines, manager replacement, maintenance classification and joined cleanup are covered.
  • Full integration build passed on 6a8a28a in 500 seconds, before the small cleanup-flow correction, with the same dependency and build inputs. The first attempt hit the proof container's 12 GiB memory cap; a build-only retry passed after setting the existing build-owned V8 budget to 4,352 MiB. No tests were replayed. The old-head CI identified one obsolete mock baseline entry and four lint errors; both are corrected. Formatting, privacy, diff and native staged line-cap checks passed. No qualified local workspace dependencies were available for a new runtime/type-aware lint run; exact-head hosted CI is required before landing.

Named follow-up: artifact ownership checks for completed wrapper services need a credential-free observation of process and pending-job occupancy. Unknown wrapper locations currently remain conservative refusals; this transport repair preserves that boundary.

Retained integration build trace

Selected original build output from 6a8a28a, before the small cleanup-flow correction:

[proof resume: 6a8a28a238a8 build-only heap4352 after OOM]
[build-all] native-protocol
[build-all] native-protocol done in 187ms
[build-all] write-build-info
[build-all] write-build-info done in 272ms
[build-all] write-cli-startup-metadata (cache restored)
[build-all] write-cli-startup-metadata done in 6.88s
6a8a28a238a86fc2671d7fa635b46213105b9be1
0814f3b29fb9ba6270a1d03c003e19979030d5f8

The controller's corresponding terminal receipt:

{"kind":"proof-phase-result","utc":"2026-10-18T20:51:45.349493+00:00","phase":"full-build","exit":0,"elapsedSeconds":500.02406036900356,"summary":[],"failedTestFiles":[],"errorCategories":[],"errorCodes":[],"lastBuildPhase":"phase","childJoined":true,"privateLogCapped":false}

The retained log has no separate command banner or fence-admission line. These are selected build-entrypoint and terminal records, not a production update trace. Fresh CI owns verification of the corrected head.

Review rank-up disposition: the requested inventory-admission trace was not retained by the completed build, whose normal output does not print that observation. An additional trace run is skipped to avoid repeating completed private-host proof solely for logging. The live inventory result, boundary regressions, retained build and exact-head CI remain distinct evidence; the build receipt is not claimed to prove inventory admission or production recovery.

Read complete loaded-unit properties through one pinned native manager connection. Keep typed CLI inspection for supported broker routes, and refuse private-manager substitution when native inspection is unavailable.

Preserve multiline argv, manager and bus identity across enumeration, bounded cleanup, and conservative classification of multiple ExecStart commands. Targeted runtime tests and build remain pending remote qualification.
@vincentkoc vincentkoc self-assigned this Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 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 18, 2026 20:53
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL labels Oct 18, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reads loaded systemd commands through typed transport while preserving manager identity and multiline arguments.

Example: A loaded worker runs python3 with an argument containing a newline followed by Id=hidden.service.

  • Before: Display-text parsing can interpret argument content as service properties and fail complete Gateway discovery.
  • After: The argument remains command data, and each service retains its separately read identity.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent repair with no actionable findings; targeted source coverage is stronger than the retained production-entry-point evidence.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor-proof gate is exempt for this maintainer-authored PR; reported live inventory exercises the changed owner, while the retained build receipt does not demonstrate inventory admission and predates the cleanup correction.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An unrelated loaded service with multiline arguments can make complete Gateway discovery fail and obstruct build or update safety checks.
Reason: The defect is concrete, and the maintainer-authored direction explicitly accepts the native-support requirement for private-manager routes.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current discovery failure, and the reviewed head has no actionable introduced findings; exact-head CI remains pending.

Priority: P2
Reviewed head: 3a5cb0738156c0c50e93d8da775ec10a95b21ddb

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show the multiline inventory through a build or update entry point, a latest-stable upgrade, or the added regression failing on the base.
Agent review details

How this fits together

Linux service discovery combines unit files and loaded-manager observations into Gateway candidates consumed by build and update safety checks.

flowchart TD
A[Build and update checks] --> B[Gateway service discovery]
B --> C[Loaded unit inventory]
C --> D[Retained native connection]
C --> E[Typed broker CLI adapter]
D --> F[Selected systemd manager]
E --> F
C --> G[Command classification]
Loading

Technical review

Best possible solution:

Retain typed inventory in its existing owner, shared CLI decoding, conservative classification, and joined cleanup.

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

Current-main property framing exposes the multiline failure directly, and the added regression supplies property-looking argument content; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Typed reads fix the framing defect at the inventory owner, reuse existing transport owners, and eliminate the redundant maintenance-command query without relaxing conservative discovery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Loaded inventory framing changes intended behavior with a stated reason (8ff319f: Complete loaded-service discovery supports artifact safety checks; scoped symbol history identifies the parser addition. Older follow-history traversal encountered the documented local object limit.)
  • Maintenance-command exclusion keeps the original intent (fix(daemon): exclude maintenance commands from Gateway discovery #170462: Recognized maintenance commands should not be treated as Gateway servers, while selected services and ambiguous wrappers remain guarded.)
  • Typed CLI compatibility keeps the original intent (fix(daemon): install the Gateway on systemd 239 with legacy busctl output #146022: Older systemd versions need counted typed output when the exact JSON-option diagnostic establishes incompatibility; deadlines and authority checks must remain enforced.)
  • Manager identity and inspection clocks keeps the original intent (fix(daemon): retain authenticated systemd manager inspection #145597: Inspection must retain the authenticated manager rather than adopt another manager after transport loss; later shared-clock work excludes only synchronous authority checks.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current main still has the parsing failure: Current main splits human-readable property output on physical lines and blank blocks, allowing multiline ExecStart arguments to disrupt property framing. (src/daemon/systemd-loaded-unit-inventory.ts:75, bf9843cf9550)
  • Pinned change and cleanup correction: The introduced diff replaces display parsing with typed properties; the subsequent correction joins connection cleanup before rethrowing inspection failures and records cleanup as the aggregate cause. (src/daemon/systemd-loaded-unit-inventory.ts:264, 3a5cb0738156)
  • Maintenance classification intent preserved: The merged fix(daemon): exclude maintenance commands from Gateway discovery #170462 excluded recognized maintenance commands while retaining selected services and ambiguous wrappers; this PR preserves that distinction using every captured executable. (src/daemon/inspect-markers.ts:133, 8e354275a38f)
  • Accepted compatibility tradeoff: The maintainer-authored body explicitly accepts unavailable inspection when private-manager routes lack native support, retaining CLI compatibility only for broker routes rather than substituting a different manager. (src/daemon/systemd-loaded-unit-inventory.ts:136, 3a5cb0738156)
  • Validation identity and limits: The body reports targeted tests and live inventory on the earlier integration implementation. Its retained terminal receipt proves a completed integration build, but does not display inventory admission through the build or update path. (3a5cb0738156)
  • Exact-head gate remains pending: The exact-head status endpoint reports the CI gate pending; dependency and security-sensitive review statuses pass, and the inspected check pages show no failed conclusion. (3a5cb0738156)

Likely related people:

  • Peter Steinberger: Raw commit 5e8fbaf adds src/daemon/systemd-exec.ts:361 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5e8fbaf8b422; files: src/daemon/systemd-exec.ts)

PR surface

Source +193, Tests +429, Other -1. Total +621 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 390 197 +193
Tests 2 474 45 +429
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 9 864 243 +621

Review metrics

Metric Value Why it matters
Production versus test changes Production +390/-197; tests +474/-45 Production growth supports typed framing and retained manager identity while removing the display parser and duplicate command query; tests cover distinct framing, routing, identity, deadline, and cleanup failures.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Valid loaded command arguments can prevent complete service discovery used by build and update checks.
  • merge-risk: 🚨 compatibility: Private-manager inspection now requires native support; the maintainer-authored body explicitly accepts this behavior to avoid selecting another manager.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Optional confidence improvement: attach redacted terminal output showing multiline inventory through the build or update entry point, preserving its commit identity.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-18T21:09:23.154Z sha efc01cd :: needs maintainer review before merge. :: none

Reviewed October 18, 2026, 5:19 PM ET / 21:19 UTC (Revision 2).

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 3a5cb0738156c0c50e93d8da775ec10a95b21ddb. This removes the obsolete closed-mock baseline and resolves the reported cleanup-flow/shadowing lint errors. Existing integration proof retains its original commit identity; fresh hosted CI is running for the corrected head.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) October 18, 2026 21:22
@vincentkoc
vincentkoc merged commit baec69e into main Oct 18, 2026
159 checks passed
@vincentkoc
vincentkoc deleted the fix/systemd-loaded-inventory-20261019 branch October 18, 2026 21:22
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

obviyus added a commit that referenced this pull request Oct 18, 2026
## What Problem This Solves

Fixes: Knip `deadcode:exports` on main reports four exports that recent refactors left without a consumer. #176447 does not cover them.

## User Impact

No user-visible change.

## Why This Change Was Made

- `src/cron/service.test-harness.ts: createCronServiceStateWithJobs`: #175975 removed its last callers, so it is deleted.
- `extensions/copilot/src/attempt.test-support.ts: createStubToolBridge`: #176003 added an exported copy that nothing imports, so it is deleted. The file is back to its state before #176003.
- `src/daemon/inspect-markers.ts: classifyGatewayCommand`: #176469 removed the only outside import, so it is now module-private.
- `src/gateway/server-cron.events.test-support.ts: CRON_WAIT_TIMEOUT_MS`: #176399 removed the last outside caller, so it is now module-private.

No ignores were added.

## Evidence

- `pnpm run deadcode:exports` on this branch, diffed against main `48439195832`: only these four entries disappear.
- `extensions/copilot/src/attempt.test.ts` and `src/daemon/inspect.test.ts` pass in full. `oxfmt` and `oxlint` are clean.

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

* fix(systemd): inspect loaded commands through typed transport

Read complete loaded-unit properties through one pinned native manager connection. Keep typed CLI inspection for supported broker routes, and refuse private-manager substitution when native inspection is unavailable.

Preserve multiline argv, manager and bus identity across enumeration, bounded cleanup, and conservative classification of multiple ExecStart commands. Targeted runtime tests and build remain pending remote qualification.

* test: remove obsolete systemd mock baseline entry

* fix(systemd): preserve inventory errors after joined cleanup
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…6562)

## What Problem This Solves

Fixes: Knip `deadcode:exports` on main reports four exports that recent refactors left without a consumer. openclaw#176447 does not cover them.

## User Impact

No user-visible change.

## Why This Change Was Made

- `src/cron/service.test-harness.ts: createCronServiceStateWithJobs`: openclaw#175975 removed its last callers, so it is deleted.
- `extensions/copilot/src/attempt.test-support.ts: createStubToolBridge`: openclaw#176003 added an exported copy that nothing imports, so it is deleted. The file is back to its state before openclaw#176003.
- `src/daemon/inspect-markers.ts: classifyGatewayCommand`: openclaw#176469 removed the only outside import, so it is now module-private.
- `src/gateway/server-cron.events.test-support.ts: CRON_WAIT_TIMEOUT_MS`: openclaw#176399 removed the last outside caller, so it is now module-private.

No ignores were added.

## Evidence

- `pnpm run deadcode:exports` on this branch, diffed against main `7451c5780e5`: only these four entries disappear.
- `extensions/copilot/src/attempt.test.ts` and `src/daemon/inspect.test.ts` pass in full. `oxfmt` and `oxlint` are clean.

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

gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant