Skip to content

fix(daemon): scope systemd unit resolution to the active profile - #119674

Merged
steipete merged 19 commits into
openclaw:mainfrom
SebTardif:fix/119648-doctor-profile-service-identity
Sep 25, 2026
Merged

steipete merged 19 commits into
openclaw:mainfrom
SebTardif:fix/119648-doctor-profile-service-identity

Conversation

@SebTardif

@SebTardif SebTardif commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Systemd discovery could report another profile's Gateway as the selected service, and Doctor cleanup could act on a different unit after the originally inspected unit disappeared. Restricting discovery to conventional filenames alone would also lose existing default-profile installations that use arbitrary custom system-unit names.

User Impact

Status and Doctor inspect the selected profile, preserve existing default-profile custom system units, and keep cleanup attached to the unit the operator confirmed. Strict reads of a legacy user unit retain its actual identity; current and legacy names remain candidates for competing managers, with effective identity checked before duplicate cleanup.

Why This Change Was Made

This change keeps canonical, legacy, and explicit unit selection scoped to the requested identity. When no user unit or explicit selector takes precedence, default-profile discovery uses the existing effective-command inspector to recognize a custom Gateway system unit. The inspected service's own command and environment determine its identity; the invoking process cannot manufacture a match. Named-profile, foreign-state, foreign-account, and Node services are excluded, and multiple matching custom units remain an ambiguity error.

Command inspection, lifecycle ownership checks, and Doctor cleanup consume the selected unit. Cleanup remains bound to the confirmed user unit. Doctor checks both loaded commands against the selected profile, home, state/config paths, and port, then rechecks the units and the system unit’s active/enabled state after confirmation. Different or unverifiable identities preserve the user unit. OPENCLAW_SYSTEMD_UNIT continues to select custom units explicitly, including template-backed instances. An opaque wrapper still requires an explicit selector.

Thanks to @SebTardif (Sebastien Tardif) for the original fix and systemd behavior coverage.

Closes #119648.

Evidence

The current signed head is 023c23f3579bae93453aaf30916cf93ab202f067 (tree 9ace1aa883d720528cdb6b561181d802fb1fac7a). It incorporates fixed main 3e63b56ed82e34bf1ee90da6ae56e994f57ec011 to consume the canonical repairs for its failed CI gates. The merge has no overlapping feature paths; all 27 feature files retain their reviewed b8adbe24 bytes. The task-owned dependency installation was reconciled with the incoming main lockfile using the normal frozen install.

A fresh review exposed an additional duplicate-cleanup defect: conventional or legacy filenames could reach removal even when the effective system unit belonged to another account, profile, state/config, or port. The real Doctor entrypoint reproduced ten unsafe uninstall requests, while five valid controls passed. The correction passed 388 service/Doctor tests. A supported Compose-style environment-port case then reproduced a compatibility gap; reusing the existing Gateway parser fixed it, with all 56 config-path tests and 16 Doctor identity cases passing. Native transport and the final uninstall boundary are mocked in these tests; they are not a new live systemd claim. The 16-case Doctor regression cost is 354 ms in test bodies and 30.22 seconds wrapper wall with pnpm test src/commands/doctor-gateway-dueling.identity.test.ts --maxWorkers=1; import transformation dominates, and the fixture adds no Gateway boot or real-time polling.

The composed source passed 621 focused tests across six maintained Vitest shards (365.71 seconds wrapper wall), including both original task-pagination cases and both real queued-collector exact modes. Full-import Madge reports zero cycles. The complete maintained changed-file checks passed, including core typing, all 25 core-test type graphs, formatting, scoped lint, export scans, ratchets, and all selected guards. Independent P2 review of the feature is complete with no accepted actionable finding remaining; a separate source review found no integration defect in the incoming service and CLI changes. The established OS-account-bound default-install and legacy-config behavior is preserved. The former two full-import cycles were fixed canonically in 818b0092; the earlier runtime-only cycle pass was not substituted for that failed full-import gate.

  • An earlier fixed-main composition, before the current 7338 integration, passed 638 focused tests, the complete changed-file checks (including all 25 core-test type graphs), and full-import Madge with zero cycles.
  • Follow-up regression tests first reproduced cross-name dueling discovery, rejection of the selected legacy user unit by the real peer query owner, and definition inspection using the wrong canonical backup path. After the repairs, 312 service/peer/operation tests and 113 definition/custody tests passed. Native broker/process responses are mocked in the new user-unit regression; this is not a live Linux claim. New test body cost was 37 ms; worker compilation is reported separately by the maintained runner.
  • The leaf load-state owner removes the prior all-import cycle. The final selected-unit repair leaves the original operation environment, peer lifetime, and retargeting refusal intact; definition inspection uses the same selected unit name and path.

The real Linux systemd upgrade payload passed on ancestor aa5759da1a15b1821dcac7a4ac3c87ef4bd06b2d (tree d22262757de6174fa4dffd66d9d185a82693011b): provider exit 0 and returned native, service-cell, and slice receipts each recorded success: true. The allocation workflow ended cancelled during cleanup and is not claimed green. All task-owned services, account, and lease were cleaned up. Evidence archive SHA-256: 08d8711460e7200f6ba080059349e3740978ff11ba9f9ce516132f10008777ba; candidate package SHA-256: 88cb392760536493f4b21dbb7f1673a98835e69bc50fdbc4b7435eb8a20f3ad3.

That package proof remains attributed to its exact ancestor. The subsequent load-state move had a bounded in-memory ESM-equivalence check, not whole-bundle or initialization-order proof. The fixed-main integration and new user-unit corrections have their own source tests and review; no rebuilt final package is implied.

Published updater proof

The successful cell used the unchanged published 2026.9.5 updater and a locally packaged candidate. This is an operator-controlled downtime flow:

  1. Start a custom default-profile system unit and a separate peer-profile system unit. Verify both are healthy and record the published driver's actual selected custom unit.
  2. As the operator, stop only the custom default unit; verify it is inactive with no remaining service cgroup while the peer's PID, invocation, and unit bytes remain unchanged.
  3. Run the installed published CLI's update --yes --no-restart --tag <candidate.tgz> --json. It exits successfully, installs the distinct candidate build, and completes migration. All 12,772 regular candidate package files match the archive; the lifecycle marker is verified separately as consumed by installation. The default service stays stopped and the peer stays unchanged.
  4. Candidate status selects the custom system unit. A non-root gateway restart --json refuses before mutation and names the exact sudo systemctl restart <custom-unit> command.
  5. As the operator, start that exact custom unit. It acquires a new PID and invocation, both Gateways pass readiness checks, and the peer retains its original PID, invocation, and unit bytes.

The proof did not inject a selector or modify the published updater. Published 2026.9.5's fallback uses the first marker-owned unit; the fixture recorded its actual selection. Semantic peer exclusion is a candidate behavior claim.

Data model compatibility

This patch changes service discovery and repair targeting, not a storage schema or persisted configuration format. Existing service unit names, profiles, and state locations remain the inputs. At the recorded aa5759 ancestor, the unchanged published 2026.9.5 updater exercised that candidate's existing migrations and finalization against the synthetic installed state; the default Gateway then started from that state and the peer continued running throughout.

Sanitized fields from the actual returned updater and fixture receipts:

published updater: status=ok, mode=npm, exitCode=0
Checking data migrations: exitCode=0
Checking configuration: exitCode=0
Checking Gateway startup: exitCode=0
post-install Doctor: exitCode=0
candidate regular archive files byte-compared: 12772
peer PID, invocation, and authored unit bytes: unchanged
candidate status: selected the custom system unit
non-root restart: refused before mutation with the exact sudo command
operator startup: new default invocation; both readiness checks passed
fixture cleanup: success=true

The updater recorded configuration normalization and its pre-update backup. The fixture verified unchanged authored unit bytes and peer process identity; it did not assert that migrated configuration bytes were unchanged or exercise an exhaustive historical session-data corpus.

Compatibility limits and retained observations

  • With an existing user unit, arbitrary differently named custom system units are not classified as dueling. This preserves the established protection for intentional secondary Gateways: default account/profile/state alone does not prove equal commands or ports and must not authorize removal of the user unit. Marked custom services can also evade the generic extra-service diagnostic; that inherited diagnostic gap is not claimed fixed here.
  • Published 2026.9.4 refused this custom system-unit installation during managed-service preflight, before package installation. Its installed strict inspection path does not support this case; a candidate-side change cannot repair that already-running driver. This cell did not succeed.
  • A separate 2026.9.5 live --no-restart attempt reached candidate migration but encountered the running default Gateway's lifecycle coordinator. The updater rolled the package back and restored readiness; both service PIDs, invocations, and unit bytes remained unchanged. The positive cell above therefore explicitly stops the default service before updating.
  • The correct system-unit restart refusal still includes inherited generic install/user-unit hints. Those hints predate this change; the actual refusal and lack of service mutation were verified. They remain a separate UX follow-up.
  • Remote hydration and source-reconciliation resource peaks occurred before observation. The later build and fixture ran in a task-owned memory-limited slice with no OOM events; sampled resource observations do not establish an exhaustive lifetime peak.

The native cell used Node 24.19.0; local targeted checks used Node 24.21.0. No live operator configuration, credentials, or services were used.

The earlier aa5759 CI run 36004101271 reported the full-import daemon dependency cycle corrected above and a separate Codex shared-client lifetime assertion. The runtime-only import-cycle pass did not establish that the full-import gate passed; that earlier correction had its own passing full-import check. The separate Codex assertion is not claimed fixed here, and neither failed job was rerun unchanged.

The prior a2a4cc49 CI run 36055307651 failed when recreating an agent database after deletion. Its accepted auto-merge request was retired before replacing the head. The canonical fix landed in #157631, whose Gateway proof and this candidate’s two local Gateway cases pass. The original failed head was not rerun unchanged. Current-head CI remains the landing gate.

A later CI run 36074193357 reported an empty restricted task page in the Gateway performance fixture. The unmodified local file passed, so the exact CI cause is not established. The 00ce9b65 test-only follow-up adopted the existing fixture-owner correction: reset the task registry before Gateway startup, then reload live task fixtures through the captured-source async owner rather than closing shared state. All page, visibility, timing, and persisted-task assertions remain. Both helper consumers pass (3 tests), along with Gateway test typing, lint, formatting, ratchets, and scoped-clean P2 review. Production authorization and service behavior are unchanged.

The 00ce9b65 CI run 36076521530 later rejected the third task page after chat settled. The exact failed merge was replayed with the original four-plan job, compiler inputs, and worker count; both four-CPU and two-CPU diagnostic runs passed 4,286 tests each. A separate held-chat timing control also preserved the cursor. The diagnostic instrumentation can affect timing, and the original cause remains unproved. No cursor validity, count, latency, or retry assertion was weakened. The current service correction is a separate causally demonstrated fix, not a claimed repair of that intermittent CI result.

The b8adbe24 CI run 36090908792 completed with five failures: raw-DDL rationale placement, an additive-schema index fixture, the QA native-fork route, queued-collector cancellation publication, and config publication after a delayed watcher echo. This fixed-main integration includes their canonical repairs (af545bf3, cb3e6df6, 63d299c3, d65bc76d, and #157906), plus the archive bootstrap correction a759f770. The cancellation repair protects the matching cleanup/publication invariant and retains the real exact-mode test; the original CI race was not independently captured here. The closed alternative #157927 was not layered into this branch. No failed-head job was rerun unchanged.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Aug 5, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 3:07 AM ET / 07:07 UTC (Revision 23).

ClawSweeper review

What this changes

The branch makes Linux Gateway status, service controls, and Doctor select systemd units by profile and inspected service identity, supports legacy and custom unit names, and binds duplicate cleanup to the unit the operator confirmed.

Merge readiness

⛔ Blocked before merge - 4 items remain

Current main still has the fallback that can select an unrelated systemd unit, so this PR remains necessary. The reviewed branch addresses that failure, and the earlier actionable findings are repaired. One upgrade tradeoff still needs explicit maintainer acceptance: an existing default-profile custom unit with an opaque launcher now requires an explicit unit selector.

Priority: P1
Reviewed head: 023c23f3579bae93453aaf30916cf93ab202f067
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Real systemd and updater traces support the main behavior, while the remaining compatibility choice prevents a clean merge verdict.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body records after-fix runs through production systemd discovery and service controls against a real Linux systemd manager, with selected units changing state and an unrelated profile’s PID unchanged; a published-updater run also exercises an ancestor candidate. The final Doctor identity guard has source and mocked-boundary coverage, and no rebuilt final package is claimed. No stored-data format changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body records after-fix runs through production systemd discovery and service controls against a real Linux systemd manager, with selected units changing state and an unrelated profile’s PID unchanged; a published-updater run also exercises an ancestor candidate. The final Doctor identity guard has source and mocked-boundary coverage, and no rebuilt final package is claimed. No stored-data format changes.
Evidence reviewed 7 items Current-main defect: Current main still returns the first marker-owned system unit and uses it as the target when the canonical unit is absent; the reported wrong-profile selection remains possible.
Introduced selection boundary: The PR probes profile-specific names and inspects custom default-profile units before selection; an unidentifiable launcher raises guidance to set OPENCLAW_SYSTEMD_UNIT.
Doctor cleanup boundary: Doctor rechecks both selected units and system-unit availability after confirmation, then passes the confirmed user target into removal.
Findings None None.
Security None None.

How this fits together

OpenClaw’s daemon adapter turns a selected profile and service environment into a systemd unit for Gateway status and lifecycle commands. Doctor uses the same discovery to diagnose competing units and, after confirmation, remove a redundant user unit.

flowchart LR
  A[Selected profile and environment] --> B[Systemd unit discovery]
  C[User and system unit files] --> B
  B --> D{Identity verified?}
  D -->|Yes| E[Selected unit]
  D -->|No| F[Refusal or explicit selector guidance]
  E --> G[Gateway status and controls]
  E --> H[Doctor confirmation and cleanup]
Loading

Decision needed

Question Recommendation
May default-profile custom systemd units with opaque launchers require OPENCLAW_SYSTEMD_UNIT after this upgrade? Accept explicit selection: Keep safe discovery and require affected operators to set OPENCLAW_SYSTEMD_UNIT, with direct CLI and documentation guidance.

Why: The prior marker-first behavior could select another profile’s unit, while safe automatic ownership cannot be established from an opaque launcher. Choosing that compatibility boundary requires maintainer intent.

Before merge

  • Resolve merge risk (P1) - An existing default-profile custom system unit launched through an opaque wrapper can stop being discovered after upgrade. Status and lifecycle commands then require the operator to set OPENCLAW_SYSTEMD_UNIT; the current head documents that recovery, but explicit maintainer acceptance of the compatibility change is still missing.
  • Complete next step (P2) - Have the service owner explicitly accept or revise the opaque custom-unit upgrade behavior before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +468, Tests +1191, Docs +4. Total +1663 across 27 files.

View PR surface stats
Area Files Added Removed Net
Source 15 789 321 +468
Tests 11 1381 190 +1191
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 27 2174 511 +1663

Review metrics

Metric Value Why it matters
Production and test line delta production +789/-321, tests +1381/-190, docs +4 The production growth covers discovery, selected-unit propagation, and guarded Doctor cleanup; the substantial regression coverage exercises those boundaries.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-gateway-dueling.ts, migration/backfill/repair: src/commands/doctor-gateway-services.ts, unknown-data-model-change: src/commands/doctor-gateway-dueling.ts, unknown-data-model-change: src/commands/doctor-gateway-services.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #119648
Summary: The open issue describes the wrong-profile systemd selection this PR is intended to fix; the smaller alternative PR closed without merging.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept explicit recovery (recommended)
    Accept the opaque-wrapper upgrade change after confirming the CLI refusal gives the exact selector action.
  2. Defer for ownership metadata
    Keep the PR open while defining a reliable way for opaque custom units to identify their owning installation.

Technical review

Best possible solution:

Keep profile-safe discovery and the explicit-selector escape hatch, make the recovery command clear at the refusal point, and land after the service owner accepts the opaque-wrapper upgrade tradeoff.

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

Yes. Current-main source still selects the first marker-owned system unit when the expected profile unit is missing, matching the reported multi-profile wrong-service path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes for the reported misrouting: selection now follows the profile and the inspected unit through its callers. The opaque-wrapper upgrade behavior remains a maintainer compatibility choice.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Wrong-profile service selection can mislead outage diagnosis and target an unrelated Gateway during service control.
  • merge-risk: 🚨 compatibility: Opaque custom systemd units previously reached by marker-first discovery may require an explicit selector after upgrade.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body records after-fix runs through production systemd discovery and service controls against a real Linux systemd manager, with selected units changing state and an unrelated profile’s PID unchanged; a published-updater run also exercises an ancestor candidate. The final Doctor identity guard has source and mocked-boundary coverage, and no rebuilt final package is claimed. No stored-data format changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records after-fix runs through production systemd discovery and service controls against a real Linux systemd manager, with selected units changing state and an unrelated profile’s PID unchanged; a published-updater run also exercises an ancestor candidate. The final Doctor identity guard has source and mocked-boundary coverage, and no rebuilt final package is claimed. No stored-data format changes.

Evidence

What I checked:

  • Current-main defect: Current main still returns the first marker-owned system unit and uses it as the target when the canonical unit is absent; the reported wrong-profile selection remains possible. (src/daemon/systemd-scope.ts:190, 04fb3c8e35b3)
  • Introduced selection boundary: The PR probes profile-specific names and inspects custom default-profile units before selection; an unidentifiable launcher raises guidance to set OPENCLAW_SYSTEMD_UNIT. (src/daemon/systemd-scope.ts:341, 023c23f3579b)
  • Doctor cleanup boundary: Doctor rechecks both selected units and system-unit availability after confirmation, then passes the confirmed user target into removal. (src/commands/doctor-gateway-dueling.ts:110, 023c23f3579b)
  • Upgrade guidance: The new documentation says operators must set OPENCLAW_SYSTEMD_UNIT when a wrapper makes a custom unit’s identity unclear. Public docs: docs/cli/gateway/restart-and-supervision.md. (docs/cli/gateway/restart-and-supervision.md:126, 023c23f3579b)
  • Real systemd and updater proof: The captured PR body reports a privileged Linux systemd run in which canonical, legacy, custom, and template-backed selections controlled the intended unit while an unrelated unit kept its PID. It also reports a published 2026.9.5 updater installing an ancestor candidate and completing the custom-unit recovery flow. The later identity guard has source and mocked-boundary coverage; the body does not claim a rebuilt final package or a new live systemd run for that guard. (023c23f3579b)
  • Maintainer review context: A maintainer’s round-two review found the earlier name-collision and selected-unit findings repaired and identified updater handoff as a separate pre-existing issue. The current review projection has no outstanding line-level finding but records the opaque custom-unit compatibility question.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Obtain explicit maintainer acceptance of the opaque custom-unit upgrade behavior and confirm the CLI refusal gives an actionable selector command.

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.

History

Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T04:03:10.489Z sha afbdd7c :: blocked before merge. :: none
  • reviewed 2026-09-20T04:18:53.391Z sha dd40c0e :: blocked before merge. :: none
  • reviewed 2026-09-24T13:36:22.091Z sha aa5759d :: blocked before merge. :: none
  • reviewed 2026-09-24T16:55:08.399Z sha 2ebe861 :: blocked before merge. :: none
  • reviewed 2026-09-24T20:37:46.502Z sha a2a4cc4 :: blocked before merge. :: none
  • reviewed 2026-09-24T23:51:16.346Z sha 6fc6707 :: blocked before merge. :: none
  • reviewed 2026-09-25T00:34:11.742Z sha 00ce9b6 :: blocked before merge. :: none
  • reviewed 2026-09-25T03:44:35.316Z sha b8adbe2 :: blocked before merge. :: none

@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed Claw P1: OPENCLAW_SYSTEMD_UNIT is honored again for installed unit discovery (Node openclaw-node and custom units), while profile isolation still refuses unrelated profile units. Head after push includes focused discovery coverage for the override paths.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Prior re-review ack for head fa2217e still shows "picked this up" without a durable review. P1 fix is on head: OPENCLAW_SYSTEMD_UNIT is honored for installed unit discovery (Node openclaw-node / custom), while profile isolation still refuses unrelated profile units. Focused discovery tests cover the override paths.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 5, 2026
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed Claw default-profile P1: marker-owned system unit discovery is candidate-only for every profile, including default. Unrelated named-profile units (e.g. openclaw-darlene) and arbitrary custom units are no longer adopted when the default gateway unit is absent. Bare openclaw remains a known default legacy name; custom units still use OPENCLAW_SYSTEMD_UNIT. Added regression tests for default-versus-named isolation.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Head is now f49cd29 (after default-profile candidate-only fix). Prior re-review ack did not produce a durable review on this head. Please re-review: marker scan is candidate-only for every profile including default; regressions cover default vs openclaw-darlene and arbitrary custom units.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body with stronger real behavior proof on the current head.

Refreshed ## Evidence and ## Real behavior proof with exact-head production boundary output: resolveGatewaySystemdServiceNameCandidates + findInstalledSystemdGatewayScope against real temp unit files (profile isolation, OPENCLAW_SYSTEMD_UNIT, legacy default). No Linux systemctl multi-unit lab in this pass.

Local check-proof.mjs: PR context PASS.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 19, 2026
@SebTardif
SebTardif force-pushed the fix/119648-doctor-profile-service-identity branch from f49cd29 to 75941a3 Compare August 24, 2026 18:56
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 24, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Sep 20, 2026
SebTardif and others added 3 commits September 19, 2026 20:56
Keep over-cap doctor and systemd suites from growing. The confirmed-unit
refusal still lives next to other systemd cleanup coverage.

Signed-off-by: Sebastien Tardif <[email protected]>
Move maybeResolveDuelingSystemdGatewayScopes to a sibling module so the
line-cap ratchet does not treat the confirmed-unit target as growth.

Signed-off-by: Sebastien Tardif <[email protected]>
Integrate the reviewed service identity repair with the fixed main base.
Inspect custom system units through the existing effective service owner,
preserve unrelated profiles and ambiguous-selection refusals, and retain
one inspection deadline through discovery and status.

Co-authored-by: Sebastien Tardif <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 24, 2026
Keep load-state inspection below the platform service facade and share its
existing isLoaded capability from the service types owner. This removes the
all-import cycle while preserving default arguments, refusal handling, and
both caller flows.

Co-authored-by: Sebastien Tardif <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 24, 2026
steipete and others added 2 commits September 24, 2026 13:25
Integrate fixed main54 while retaining profile-scoped discovery and custom
system-unit preservation. Carry the discovered user unit into peer admission
and definition inspection without changing the operation's original selector
or weakening its retargeting checks. Recognize current and legacy names for
the same profile as competing user/system managers.

Co-authored-by: Sebastien Tardif <[email protected]>
@steipete
steipete enabled auto-merge (squash) September 24, 2026 21:04
@steipete
steipete disabled auto-merge September 24, 2026 23:20
steipete and others added 4 commits September 24, 2026 16:43
Carry fixed main 6f60b82 with the joined database-drain repair from openclaw#157631.
The existing service identity patch is unchanged. Reuse the canonical type-only
npm-pack import correction from openclaw#157659 so the composed core graph typechecks.

Co-authored-by: Sebastien Tardif <[email protected]>
Co-authored-by: Jason (Json) <[email protected]>
Initialize the registry before Gateway startup so reset cannot close the
captured shared-state source. Reload later task fixtures through the existing
async owner and retain main's persisted-task assertions.

Preserve page, visibility, timing, and cleanup expectations. The earlier CI
empty-page result did not reproduce in the unmodified local test; this fixes
the verified fixture lifetime violation without weakening production guards.
Compare both loaded commands' actual profile, home, state/config paths, and
port before treating known user/system unit names as a duplicate installation.
Retain account inspection and recheck ownership after operator confirmation.
Reuse the existing Gateway environment-port parser for Compose host:port values.
Preserve default custom-unit discovery and its legacy configuration contract.

Integrate fixed main 7338f79.

Co-authored-by: Sebastien Tardif <[email protected]>
Carry fixed main 3e63b56 after
attributed CI failures. Preserve the reviewed service repair byte-for-byte;
consume the canonical cancellation publication, config watcher, archive,
QA fork, additive-schema fixture, and import-cycle repairs.

The earlier task-cursor timing failure remains unexplained; this integration
does not weaken cursor, page-count, latency, or authority assertions.

Co-authored-by: Sebastien Tardif <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Maintainer decision for 023c23f3579bae93453aaf30916cf93ab202f067: accept the documented explicit-selection requirement for custom systemd units whose opaque launcher prevents reliable installation identification. The old first-marker fallback can target another Gateway, so restoring that fallback would reintroduce the reported defect. Inspectable default-profile custom installations remain supported automatically; opaque wrappers use the existing OPENCLAW_SYSTEMD_UNIT selector.

I verified the refusal in systemd-scope.ts explicitly says Systemd Gateway launcher identity is unknown. Set OPENCLAW_SYSTEMD_UNIT. The install-identity documentation explains the same recovery. For example, an operator can run OPENCLAW_SYSTEMD_UNIT=my-gateway.service openclaw gateway status --deep for their existing custom unit; normal account/profile and lifecycle ownership checks still apply. This accepts the bounded upgrade tradeoff without adding an option or manufacturing identity from the invoking CLI's environment.

The Doctor-path classification does not introduce a persisted-format or schema change. The PR's data-model section records the unchanged published 2026.9.5 updater's migration/finalization and custom-unit recovery evidence on the exact ancestor package, including the operator-stop/start boundary and peer retention. It does not claim a rebuilt final package. The current composition has its separate passing 621-test integration run, complete changed-file checks, and full-import Madge result; current-head CI remains required.

@steipete
steipete merged commit d8b5ea0 into openclaw:main Sep 25, 2026
208 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

steipete added a commit that referenced this pull request Sep 25, 2026
* fix(doctor): report remaining systemd units after cleanup

The confirmed unit's disable result does not establish that no other
canonical or legacy user unit remains. Consult the existing scoped
installation discovery passively after cleanup and report remaining or
unverifiable state without deleting another unit.

Keep the successful removal distinct from a later inspection failure, and
limit clean wording to the supported matching installed-unit search.

Add causal Doctor-boundary regressions for a surviving alias and failed
post-cleanup inspection. Native transport and uninstall are mocked; the
selected synthetic file is actually removed and legacy bytes stay intact.

Follow-up to #119674.

* test(doctor): distinguish readers from staging workers

Reuse the canonical startup pending-read correction while preserving selected-unit reporting and cleanup scope.

(cherry picked from commit 9b90a98)

* fix(models): integrate canonical discovery provenance repair

Compose the qualified catalog correction from #158113, including explicit static and advisory outcomes and exact auth-provenance expectations. Include its existing first-discovery retention prerequisite; preserve the independent Doctor reporting change.

Canonical commits: aef8743, 5d9c2d7, 36def8b.

* fix(ci): finish canonical catalog and Doctor integration

Preserve the landed Doctor mock lifetime cleanup while composing the catalog loader type leaf and generated non-live catalog outcome correction. Reader and staging assertions, strict live discovery, and custom callbacks remain unchanged.

Canonical commits: cbff337, 9adf333, 4f1acb7.

* fix(ci): withdraw catalog inference detour

Restore the task-created catalog changes to fixed canonical main168d454d while preserving scoped outcome handling from #158139 and the real HTTP fixture correction from #158115. Keep the service-reporting repair and canonical pending-read assertions unchanged.

The previous inference changes introduced a compatibility and native augmentation regression. Their failure history remains documented; the separate legacy-retention repair is not a dependency of this feature.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…nclaw#119674)

* fix(daemon): scope systemd unit resolution to the active profile

Doctor on multi-agent Linux hosts must not adopt the first openclaw
marker unit. Probe current plus legacy names for the active profile,
and honor OPENCLAW_SYSTEMD_UNIT for Node and custom units.

Closes openclaw#119648

Replayed onto origin/main cfcc681.

Signed-off-by: Sebastien Tardif <[email protected]>

* fix(daemon): reject colliding systemd legacy names and carry selected unit

Drop legacy candidates that identify Node or another profile gateway.
Pass the discovered unit into ownership checks, command inspection, and
duplicate cleanup so start/restart cannot target the wrong service.

Signed-off-by: Sebastien Tardif <[email protected]>

* fix(daemon): keep default-profile systemd template identity

Accept [email protected] and [email protected] as instances of
the legacy openclaw candidate so marker lookup still finds main's
system templates. Named-profile units stay candidate-exact.

Signed-off-by: Sebastien Tardif <[email protected]>

* test(daemon): extract systemd identity coverage from over-cap file

Move profile-identity cases out of systemd.test.ts so the line-cap
ratchet does not grow the grandfathered file.

Signed-off-by: Sebastien Tardif <[email protected]>

* test(daemon): settle extra systemd probes in identity ownership case

The extracted ownership test used a one-shot execFile mock. Compact CI
called systemctl again before the ownership check and failed closed.

Signed-off-by: Sebastien Tardif <[email protected]>

* test(daemon): keep exec-backed identity cases on the systemd mock

Discovery-only profile cases stay in systemd-scope.identity.test.ts.
Lifecycle inspect/uninstall/ownership stay in systemd.test.ts so compact
shards do not hit a real user bus. Parser cases move to systemd-unit.test.ts.

Signed-off-by: Sebastien Tardif <[email protected]>

* ci: retrigger after compact-large sessions-reset flake

Signed-off-by: Sebastien Tardif <[email protected]>

* fix(daemon): keep explicit systemd template instance selection

[email protected] with only
[email protected] installed now resolves the backing template while
keeping the requested instance for inspection and control.

Signed-off-by: Sebastien Tardif <[email protected]>

* fix(daemon): keep doctor systemd cleanup on the confirmed unit

Doctor confirmation names the inspected user unit. If that file
disappears before removal, do not fall back to a leftover legacy
unit such as openclaw-lisa.service.

Signed-off-by: Sebastien Tardif <[email protected]>

* test(daemon): move systemd cleanup target-change cases to a sibling file

Keep over-cap doctor and systemd suites from growing. The confirmed-unit
refusal still lives next to other systemd cleanup coverage.

Signed-off-by: Sebastien Tardif <[email protected]>

* refactor(doctor): extract dueling systemd cleanup from the over-cap file

Move maybeResolveDuelingSystemdGatewayScopes to a sibling module so the
line-cap ratchet does not treat the confirmed-unit target as growth.

Signed-off-by: Sebastien Tardif <[email protected]>

* fix(daemon): isolate service load-state inspection contracts

Keep load-state inspection below the platform service facade and share its
existing isLoaded capability from the service types owner. This removes the
all-import cycle while preserving default arguments, refusal handling, and
both caller flows.

Co-authored-by: Sebastien Tardif <[email protected]>

* test(daemon): track legacy unit fixture cleanup

* test(gateway): preserve task fixture database lifetime

Initialize the registry before Gateway startup so reset cannot close the
captured shared-state source. Reload later task fixtures through the existing
async owner and retain main's persisted-task assertions.

Preserve page, visibility, timing, and cleanup expectations. The earlier CI
empty-page result did not reproduce in the unmodified local test; this fixes
the verified fixture lifetime violation without weakening production guards.

---------

Signed-off-by: Sebastien Tardif <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Jason (Json) <[email protected]>
Co-authored-by: Sebastien Tardif <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…58034)

* fix(doctor): report remaining systemd units after cleanup

The confirmed unit's disable result does not establish that no other
canonical or legacy user unit remains. Consult the existing scoped
installation discovery passively after cleanup and report remaining or
unverifiable state without deleting another unit.

Keep the successful removal distinct from a later inspection failure, and
limit clean wording to the supported matching installed-unit search.

Add causal Doctor-boundary regressions for a surviving alias and failed
post-cleanup inspection. Native transport and uninstall are mocked; the
selected synthetic file is actually removed and legacy bytes stay intact.

Follow-up to openclaw#119674.

* test(doctor): distinguish readers from staging workers

Reuse the canonical startup pending-read correction while preserving selected-unit reporting and cleanup scope.

(cherry picked from commit 9b90a98)

* fix(models): integrate canonical discovery provenance repair

Compose the qualified catalog correction from openclaw#158113, including explicit static and advisory outcomes and exact auth-provenance expectations. Include its existing first-discovery retention prerequisite; preserve the independent Doctor reporting change.

Canonical commits: aef8743, 5d9c2d7, 3cb4c86.

* fix(ci): finish canonical catalog and Doctor integration

Preserve the landed Doctor mock lifetime cleanup while composing the catalog loader type leaf and generated non-live catalog outcome correction. Reader and staging assertions, strict live discovery, and custom callbacks remain unchanged.

Canonical commits: a9db992, 9adf333, 4f1acb7.

* fix(ci): withdraw catalog inference detour

Restore the task-created catalog changes to fixed canonical main168d454d while preserving scoped outcome handling from openclaw#158139 and the real HTTP fixture correction from openclaw#158115. Keep the service-reporting repair and canonical pending-read assertions unchanged.

The previous inference changes introduced a compatibility and native augmentation regression. Their failure history remains documented; the separate legacy-retention repair is not a dependency of this feature.
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

doctor: misidentifies stopped agent's service as another running agent's, recommends restarting wrong service

2 participants