Skip to content

fix(status): resolve installed service state from the service's own environment - #187901

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1976
Oct 29, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1976

Conversation

@steipete

@steipete steipete commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Follow-up to #187886; related to #187878. Installed-service diagnostics still inherited missing state selectors from the inspecting CLI after the core Doctor migration fix landed.

User Impact

Gateway status reads the installed service's config and runtime intent, prints its journal/log guidance, and lets Doctor scan its updater context without borrowing an isolated CLI's state selectors.

Why This Change Was Made

Reuse mergeGatewayServiceEnv for the remaining direct environment merges. The shared helper now follows #187886's approach: clear the caller's four OpenClaw home/state/profile/config selectors, then overlay the installed service environment. Existing HOME fallback, Windows command-line profile handling, and native supervisor selection stay with their existing owners.

The identity producer in run-main-service-installation.ts and both of #187886's regression files are unchanged from main. The original migration fix and tests have been removed from this PR. Thanks @shakkernerd for the report and the landed identity-producer fix.

Evidence

New sibling regressions fail against current main at c77b791cf4fca27afe64a6da4ee9ba22f5133a28: 7 failures across 5 files, each at the intended selector leak.

Consumer Failure reproduced on main
Shared service-environment helper Caller state survives an installed definition with absent/empty environment on macOS, Linux, and Windows
Status gathering Installed service config resolves to the isolated caller config
Runtime-intent projection Caller home/state/config selectors reach the service intent reader
Printed status Journal guidance names the isolated caller's systemd profile
Doctor platform notes Installed-service updater scanning receives caller selectors

After the sibling-only fix:

  • 476 passed, 16 platform-skipped across ten selected Vitest lanes in 103.55 s. Selection includes 26 direct/barrel consumer test files plus native process-environment, update service-selection, and both unchanged fix: keep unrelated services from blocking isolated Doctor migrations #187886 identity suites. Linux self-service cases remain platform-skipped locally.
  • Live compiled production CLI: gateway status --runtime-intent-only with private temporary HOME/state/config and a synthetic unloaded LaunchAgent. Result: exit 0, service runtime intent known. A deliberately unsupported isolated caller runtime-pin store remained at schema 99, proving it was not used as the installed service's store. No service was started or restarted. The live invocation took 5.438 s of test time; shared compiler preparation took 25.4 s. The first standalone cached-fixture attempt failed on a cleaned-up absolute module path; proof was completed under the active supported CLI harness.
  • Core and targeted CLI/services/Doctor test typechecks, touched-file oxlint, oxfmt, git diff --check, and Madge pass (0 cycles).
  • Both ratchets pass: max-lines 404 grandfathered suppressions, OpenClaw env names 458/458; test lines 6,277,555 / 6,327,226, slack 49,671. No baseline changes.
  • Local autoreview of the complete sibling diff against c77b791cf4fc: scoped-clean at P0–P2. Simplification keeps the existing shared helper as the sole sibling projection owner. Production +26/−20 (net +6 LOC); tests +90/−3 (net +87); docs +5.
  • SQLite inventory/full check:changed remains omitted under the campaign's local gate budget. PR CI is the broad proof; no merge requested.

@clawsweeper

clawsweeper Bot commented Oct 29, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations size: S labels Oct 29, 2026
@steipete
steipete marked this pull request as ready for review October 29, 2026 21:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T21:47:56.397813Z 8f89cb2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR reconstructs installed Gateway state from the service’s environment instead of inheriting the inspecting CLI’s state selectors.

Example: A 2026.10.9 CLI repairs isolated state while an unrelated 2026.7.1-2 LaunchAgent records only HOME.

  • Before: The older service inherits the isolated database path, so Doctor refuses its migration.
  • After: The service resolves its separate database, allowing Doctor’s backed-up isolated migration.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The reported production CLI evidence is useful, but the introduced shared-profile migration bypass blocks this patch.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports compiled production Doctor runs for separate and explicitly shared databases, with migration, backup, and refusal outcomes.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor refuses to repair isolated state because it incorrectly identifies an unrelated older Gateway as using that database.
Reason: The maintainer-authored direction restores the intended state-selection boundary, although main already contains the central repair.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open for maintainer handling: the central Doctor bug is fixed on main, but this PR has a reported merge conflict and an introduced profile-selection defect that can bypass the older-service migration guard.

Priority: P2
Reviewed head: 1cb82bb0feb244834de503dda313ed28769f4e79

Before merge

  • Apply non-Windows service argument profiles before resolving state (P1) - On macOS or Linux, let an older service run node /old/openclaw.mjs --profile=service gateway with only HOME=/home/example saved, and run the newer Doctor against /home/example/.openclaw-service. Previously the caller’s matching state selector kept the shared database protected. This call now clears that selector, while mergeGatewayServiceEnv applies argv profiles only on Windows, so the service is incorrectly assigned /home/example/.openclaw/state/openclaw.sqlite. The unchanged equality-based migration guard then allows migration of the database the older service actually uses. Apply the existing entrypoint/profile parsers before resolving identity and retain a shared-argv-profile regression; the merged repair at fix: keep unrelated services from blocking isolated Doctor migrations #187886 already provides that path.
  • Complete next step - Resolve GitHub’s reported merge conflict against the merged installation-identity repair.

Findings

  • [P1] Apply non-Windows service argument profiles before resolving state — src/cli/run-main-service-installation.ts:105
Agent review details

How this fits together

CLI startup and diagnostics project installed service metadata into config and database identities consumed by Doctor, status, update admission, and the existing migration guard.

flowchart TD
  A[CLI environment] --> C[Service environment projection]
  B[Installed service command] --> C
  C --> D[Config and database identity]
  D --> E[Migration guard]
  E --> F[Doctor migration or refusal]
  D --> G[Status and update diagnostics]
Loading

Technical review

Best possible solution:

Preserve main’s merged installation-identity repair and its argument-profile protection, carrying forward only the distinct shared diagnostic improvements.

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

The pinned source establishes both the original selector-inheritance failure and the introduced argument-profile omission; current main fixes the original report, and no target code was executed during this review.

Is this the best way to solve the issue?

Correcting the existing environment owner is appropriate, but its consumers need the service’s effective command-line profile as well as its saved environment.

Full review comments:

  • [P1] Apply non-Windows service argument profiles before resolving state — src/cli/run-main-service-installation.ts:105
    On macOS or Linux, let an older service run node /old/openclaw.mjs --profile=service gateway with only HOME=/home/example saved, and run the newer Doctor against /home/example/.openclaw-service. Previously the caller’s matching state selector kept the shared database protected. This call now clears that selector, while mergeGatewayServiceEnv applies argv profiles only on Windows, so the service is incorrectly assigned /home/example/.openclaw/state/openclaw.sqlite. The unchanged equality-based migration guard then allows migration of the database the older service actually uses. Apply the existing entrypoint/profile parsers before resolving identity and retain a shared-argv-profile regression; the merged repair at fix: keep unrelated services from blocking isolated Doctor migrations #187886 already provides that path.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c77b791cf4fc; fix evidence: commit c77b791cf4fc, main fix timestamp 2026-10-29T21:20:53Z.

Provenance checked

  • Installed-service migration guard keeps the original intent (4757389: Prevent a newer CLI from advancing databases still used by an older managed Gateway.)
  • Linux own-service identity keeps the original intent (2f47962: Use native PID, manager, unit, and cgroup agreement to identify the running Gateway rather than an unrelated service definition.)
  • Shared service-environment projection changes intended behavior with a stated reason (244d441: Project registered service environment and Windows argument profiles while preserving the caller’s supervisor transport and account context.)
  • Status environment selection keeps the original intent (afa4977: Keep externally supervised or non-default CLI contexts from being retargeted to an unrelated native Gateway service.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4757389 adds src/cli/run-main-service-installation.ts:21 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4757389e1e60; files: src/cli/run-main-service-installation.ts)

PR surface

Source +15, Tests +68, Docs +5. Total +88 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 35 20 +15
Tests 4 75 7 +68
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 115 27 +88

Root-cause cluster

Relationship: partial_overlap
Canonical: #187878
Summary: The central installation-identity defect is already repaired; this PR additionally changes shared environment projection and diagnostic consumers.

Members:

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

Labels

Label changes:

  • add P2: The remaining work concerns a limited service-selection workflow; the original isolated-state failure already has a merged repair.
  • add merge-risk: 🚨 compatibility: The introduced profile omission can permit a newer CLI to advance a database still used by an older Gateway, leaving that Gateway unable to open it.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🐚 platinum hermit and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The remaining work concerns a limited service-selection workflow; the original isolated-state failure already has a merged repair.
  • merge-risk: 🚨 compatibility: The introduced profile omission can permit a newer CLI to advance a database still used by an older Gateway, leaving that Gateway unable to open it.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🐚 platinum hermit and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 29, 2026, 5:32 PM ET / 21:32 UTC.

Follow up on #187886 by applying its four-selector clearing approach in mergeGatewayServiceEnv and reusing that helper for status config, runtime intent, log guidance, and Doctor updater scans. Keep the landed identity producer and migration regressions unchanged.

Related: #187886, #187878. Thanks @shakkernerd for the original report and identity-producer fix.
@steipete steipete changed the title fix(doctor): resolve installed service state from the service's own environment fix(status): resolve installed service state from the service's own environment Oct 29, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f89cb288d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +69 to +72
OPENCLAW_HOME: undefined,
OPENCLAW_STATE_DIR: undefined,
OPENCLAW_PROFILE: undefined,
OPENCLAW_CONFIG_PATH: undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore command-line profiles in the POSIX service projection

On Linux/macOS, an installed service can select its profile through openclaw.mjs --profile work gateway without declaring OPENCLAW_PROFILE in its environment. Clearing the caller's selectors now makes an inspecting openclaw --profile work gateway status resolve that service's config to ~/.openclaw/openclaw.json instead of ~/.openclaw-work/openclaw.json, because the subsequent argv-profile projection only runs on Windows. resolveGatewayLifecycleContext also consumes this helper, so restart health checks can use the wrong configuration and port. Project the installed command's POSIX profile after clearing the caller selectors, as inspectCliGatewayServiceInstallation already does in src/cli/run-main-service-installation.ts.

Useful? React with 👍 / 👎.

shakkernerd added a commit that referenced this pull request Oct 30, 2026
Restore the scheduled-task stop fixture’s exact installed-service environment assertion while preserving its process identity and termination controls.

Refs #187901.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…nvironment (openclaw#187901)

openclaw#187886 stopped the installed-service identity producer from inheriting the caller's state selectors. Gateway status gathering, projection and printing, Doctor platform notes, and the service environment merge still merged the CLI's OPENCLAW_HOME / OPENCLAW_STATE_DIR / OPENCLAW_PROFILE / OPENCLAW_CONFIG_PATH into an unrelated installed service's identity, so they could report an isolated CLI's state as belonging to that service. They now use the same selector-clearing approach and existing merge helper; a positively identified own service keeps its live environment.

Follow-up to openclaw#187886 for openclaw#187878. Thanks @shakkernerd.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…law#187967)

Restore the scheduled-task stop fixture’s exact installed-service environment assertion while preserving its process identity and termination controls.

Refs openclaw#187901.
RomneyDa added a commit that referenced this pull request Oct 30, 2026
Restore the scheduled-task stop fixture’s exact installed-service environment assertion while preserving its process identity and termination controls.

Refs #187901.

(cherry picked from commit 0078d6a)
Co-authored-by: RomneyDa <[email protected]>
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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant