Skip to content

fix(daemon): recovery hints target the wrong profile or container - #130216

Merged
steipete merged 2 commits into
mainfrom
codex/onboarding-systemd-profile-hints
Aug 26, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/onboarding-systemd-profile-hints

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130214

What Problem This Solves

Fixes an issue where Linux users diagnosing a gateway without an available systemd user service would receive a recovery command for the default gateway instead of their selected profile or container. Copying the suggested command could therefore start the wrong gateway.

Why This Change Was Made

The shared systemd-hint owner now receives the same service environment that already drives doctor and gateway-status diagnostics. It resolves container context and formats the command from that one canonical environment; existing callers without an explicit environment continue to use their current process environment.

This removes duplicated container detection from both callers and deletes the resulting obsolete CLI helper re-export instead of preserving a test-only production seam. Existing WSL and headless-server behavior and container-over-profile precedence remain unchanged. Production delta: +6/-10, net -4 lines.

User Impact

Recovery hints now remain copy-pasteable for openclaw --profile blue gateway and openclaw --container sandbox gateway, including when both settings are present. No service, authentication, configuration, or persistence behavior changes.

Evidence

  • Added one table-driven production-boundary regression covering profile, container, and container-over-profile precedence. All three cases failed against the unmodified code before the fix.
  • Passed 256 exact-head owner and sibling tests across eight suites covering systemd hints, doctor formatting, gateway-status rendering, daemon responses, service environments, and doctor repair policy; one existing unrelated test is skipped.
  • Reproduced the exact hosted dependency/export failure and passed the full pnpm deadcode:full gate locally after removing the obsolete re-export.
  • Passed the actual repository formatter, configured lint rule, and whitespace checks.
  • Independent source-level review verified all five production callers; a fresh Codex autoreview found no actionable issues.
  • Reproduced the operator-visible production formatter with isolated profile/container environments; no user state, services, provider credentials, or external systems were touched.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 1:23 PM ET / 17:23 UTC.

ClawSweeper review

What this changes

The PR passes each daemon diagnostic’s service environment to the shared Linux systemd recovery-hint formatter so displayed gateway commands retain the selected profile or container.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for ordinary maintainer review. Current main and the latest release still render the foreground recovery command without the caller-provided environment; this focused change moves that context into the shared hint owner and has no actionable patch defect.

Priority: P2
Reviewed head: 97aed08416a3984625ada98a0d4e467e31038adb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative production repair with source-backed caller and formatter coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records a targeted formatter reproduction.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records a targeted formatter reproduction.
Evidence reviewed 7 items Current-main defect: Current main calls the command formatter without the service environment, so a profile or container held only by the diagnosed service is omitted from the displayed foreground command.
Canonical formatting contract: The existing command formatter accepts an environment, emits a valid container first, otherwise emits the normalized profile, and avoids duplicate flags.
Shared-owner repair: The branch gives the shared renderer the service environment for both container detection and command formatting, replacing caller-side container booleans.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/commands/doctor-format.test.ts src/daemon/systemd-hints.test.ts

Result: PASS (completed)

$ node --import tsx scripts/test-projects.mts src/commands/doctor-format.test.ts src/daemon/systemd-hints.test.ts
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130216-k9YAZn/target

 ✓  unit-fast  src/daemon/systemd-hints.test.ts (5 tests) 7ms
 ✓  unit-fast  src/commands/doctor-format.test.ts (11 tests) 8ms

 Test Files  2 passed (2)
      Tests  16 passed (16)
   Start at  17:23:58
   Duration  803ms (transform 611ms, setup 180ms, import 634ms, tests 15ms, environment 0ms)

[test] passed 1 Vitest shard in 10.21s
$ node --import tsx scripts/test-projects.mts src/commands/doctor-format.test.ts src/daemon/systemd-hints.test.ts
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130216-k9YAZn/target

 ✓  unit-fast  src/daemon/systemd-hints.test.ts (5 tests) 6ms
 ✓  unit-fast  src/commands/doctor-format.test.ts (11 tests) 9ms

 Test Files  2 passed (2)
      Tests  16 passed (16)
   Start at  17:24:09
   Duration  464ms (transform 201ms, setup 62ms, import 318ms, tests 15ms, environment 0ms)

[test] passed 1 Vitest shard in 9.82s

Assertions:

  • NOT OBSERVED expect_output: preserves the active target in systemd recovery commands — command exited successfully; expected output was not observed in the captured pane

How this fits together

Doctor and gateway status inspect a gateway service and render recovery guidance when systemd user services are unavailable. The shared hint formatter turns that service context into the command an operator is asked to run next.

flowchart LR
A[Doctor or gateway status] --> B[Service environment]
B --> C[Systemd unavailable diagnosis]
C --> D[Shared recovery hint formatter]
D --> E[Target-aware gateway command]
E --> F[Operator recovery]
Loading

Before merge

  • Complete next step (P2) - This is an open, maintainer-authored implementation PR with no concrete repair finding; it should proceed through ordinary maintainer review.
Agent review details

Security

None.

PR surface

Source -4, Tests +14. Total +10 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 6 10 -4
Tests 4 32 18 +14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 38 28 +10

Review metrics

Metric Value Why it matters
Production versus test LOC production +6/-10 (net -4); tests +32/-18 (net +14) The bug fix reduces production surface while adding focused behavior coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-format.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #130214
Summary: This PR is the explicit candidate repair for the linked recovery-command bug.

Members:

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

Technical review

Best possible solution:

Land the single canonical environment-aware formatter path with the focused profile/container regression coverage.

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

Yes, source-reproducible: current main’s shared hint formats the foreground command without the diagnosed service environment, while the command formatter already defines profile/container preservation when that environment is supplied.

Is this the best way to solve the issue?

Yes. Resolving the target in the shared hint formatter reuses the existing command-formatting contract and removes duplicated caller-side container interpretation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Misleading Linux recovery guidance can direct an operator at the default gateway, but the affected path is bounded and has a focused repair.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records a targeted formatter reproduction.

Label justifications:

  • P2: Misleading Linux recovery guidance can direct an operator at the default gateway, but the affected path is bounded and has a focused repair.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records a targeted formatter reproduction.

Evidence

What I checked:

  • Current-main defect: Current main calls the command formatter without the service environment, so a profile or container held only by the diagnosed service is omitted from the displayed foreground command. (src/daemon/systemd-hints.ts:42, 447895981826)
  • Canonical formatting contract: The existing command formatter accepts an environment, emits a valid container first, otherwise emits the normalized profile, and avoids duplicate flags. (src/cli/command-format.ts:13, 97aed08416a3)
  • Shared-owner repair: The branch gives the shared renderer the service environment for both container detection and command formatting, replacing caller-side container booleans. (src/daemon/systemd-hints.ts:40, 97aed08416a3)
  • Caller coverage: Doctor passes its resolved environment into the renderer, while status passes the diagnosed service command environment rather than ambient process state. (src/commands/doctor-format.ts:56, 97aed08416a3)
  • Regression coverage: The added table test covers profile, container, and container-over-profile precedence at the Doctor formatting boundary. (src/commands/doctor-format.test.ts:61, 97aed08416a3)
  • History provenance: Blame ties the pre-fix command line to the current main ancestry; history shows the headless-hint behavior originated in the earlier daemon-hints work. (src/daemon/systemd-hints.ts:42, 762fed1f9029)

Likely related people:

  • steipete: Recent history covers the daemon container-context and systemd-hint surface, and the current patch continues that ownership path. (role: recent area contributor; confidence: high; commits: 67dc60756ac3, 97aed08416a3; files: src/daemon/systemd-hints.ts, src/daemon/container-context.ts, src/cli/command-format.ts)
  • chocobo9: Authored the headless-systemd recovery hints whose container suppression and foreground command are being preserved. (role: introduced adjacent recovery behavior; confidence: medium; commits: 762fed1f9029; files: src/daemon/systemd-hints.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Reviewed the latest ClawSweeper result: no code or security findings remain. The stored-data warning is a false positive from the doctor test path: this PR changes diagnostic text formatting and its tests only; it introduces no schema, persistence, migration, authentication, or service-execution change. The existing formatter remains the owner of profile/container precedence.

All 256 focused owner/sibling tests and the full dependency/export check passed. The remaining hosted lint jobs ended with an explicit runner shutdown signal, not a lint diagnostic. Those interrupted jobs are being rerun on the unchanged reviewed commit now that GitHub Actions has recovered; landing still waits for the required CI gate.

@steipete
steipete merged commit 8585e7e into main Aug 26, 2026
697 of 707 checks passed
@steipete
steipete deleted the codex/onboarding-systemd-profile-hints branch August 26, 2026 19:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…enclaw#130216)

* fix(daemon): preserve profile context in systemd recovery hints

* fix(cli): remove obsolete daemon container helper export
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 gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Linux gateway recovery command loses the selected profile or container

1 participant