Repository navigation
fix(doctor): resolve legacy systemd unit for the target profile (#119648) - #119685
licheer-zte wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 5, 2026, 1:49 PM ET / 17:49 UTC. ClawSweeper reviewWhat this changesThe PR makes Doctor resolve same-profile legacy systemd unit names before scanning host-wide units and rejects scanned units whose names do not match the selected profile. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 7 items remain Keep this PR open: it repairs the profile-blind fallback at the right owner boundary, but a P1 path still ignores an explicit systemd-unit override and can target a different service. It also needs after-fix real systemd behavior proof before merge. Priority: P1 Review scores
Verification
How this fits togetherDoctor maps a selected OpenClaw profile to its systemd gateway unit, then uses that unit for runtime status and restart guidance. The resolver must preserve profile and explicit-unit identity so an outage diagnosis never acts on another gateway. flowchart LR
A[Doctor profile request] --> B[Profile and unit override]
B --> C[Systemd unit resolver]
C --> D{Matching target unit?}
D -->|yes| E[Runtime status and restart guidance]
D -->|no| F[Report unit not found]
E --> G[Operator action]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +65, Tests +92. Total +157 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Make an explicit OPENCLAW_SYSTEMD_UNIT disable marker-based adoption, add the override regression, and attach a redacted terminal trace showing Doctor selects only the intended unit. Do we have a high-confidence way to reproduce the issue? Yes, from source: configure a missing custom OPENCLAW_SYSTEMD_UNIT and expose a scanned matching legacy unit; the new fallback adopts that legacy unit despite the override. Is this the best way to solve the issue? No. Canonical then same-profile legacy lookup is the right repair, but the marker fallback must honor an explicit unit override rather than substituting a discovered unit. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e17bc5887707. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Closing this as a duplicate repair lane of #119674, not as fixed. Both PRs target #119648 at the same owner boundary: current/legacy profile candidates in #119674 is still blocked. Its current head must preserve the documented default-profile custom-unit discovery contract and add real multi-unit Linux Doctor/systemctl proof before merge. Closing this PR does not approve or merge #119674; it keeps one repair lane for the remaining work. Thanks @licheer-zte for the focused legacy-name analysis and regression tests. This PR and commit remain linked for credit; if code from this branch is reused, we must preserve commit authorship. |
What Problem This Solves
openclaw --profile <name> doctormisreported a stopped agent's gateway as running and recommended restarting an unrelated agent's service. Reproduction: host runs several per-profile gateway services;openclaw-lisa.service(legacy naming, pre-openclaw-gateway-rename) is stopped whileopenclaw-darlene.serviceruns. Doctor resolved the target installation by scanning everyopenclaw-*system unit and picking the first marker-owned one — Darlene's — then reported that PID as Lisa's runtime and suggestedsudo systemctl restart openclaw-darlene.service. Following that advice takes an unrelated agent offline during an outage.Why
findSystemSystemdGatewayScope(src/daemon/systemd.ts) tried only the canonical unit name (openclaw-gateway-<profile>.service) and then fell back tofindMarkerOwnedSystemSystemdUnit(), a system-wide scan with no profile filter. On multi-agent hosts that scan legitimately returns other agents' units, and the first match was treated as the target's installation. Two compounding gaps: (1) the legacyopenclaw-<profile>naming convention was never tried, and (2) the marker fallback never verified the unit belongs to the target profile.User Impact
Doctor now reports the truth in the outage scenario: a legacy-named unit is resolved as the target's own service (so
Runtime: stoppedis shown with the correct unit), and when the target's unit genuinely cannot be located, doctor refuses to guess instead of borrowing another agent's running unit. It can no longer recommend restarting a different agent's service.Evidence
src/daemon/constants.ts: addedresolveLegacyGatewaySystemdServiceName(profile)→openclaw-<profile>(named profiles) /openclaw(default), matching the pre-rename convention from the report.src/daemon/systemd.ts:findSystemSystemdGatewayScopenow tries the canonical name, then the legacy name for the same profile (skipped whenOPENCLAW_SYSTEMD_UNIToverrides the unit), before any scan;isSystemdGatewayUnitNameForProfile); unrelated units (e.g.openclaw-darlene.servicefor profilelisa) are rejected and resolution returns null — doctor then reports stopped/not-found instead of guessing. The intentional "separate gateway with a different name" case (issue Upgrade leaves stale user-level systemd unit, dueling services kill each other on Linux #79375 dueling test) is preserved.src/daemon/systemd.test.ts,src/daemon/constants.test.ts):openclaw-<profile>system unit resolves for a named profile;readSystemdServiceRuntimereads the legacy unit's ownsystemctl show(inactive →stopped, unitopenclaw-lisa.service);pnpm vitest run src/daemon/systemd.test.ts→ 145 passed;src/daemon/constants.test.ts→ 24 passed;tsgocore typecheck clean.