Repository navigation
fix(daemon): explain unsafe service publication failures - #132279
Conversation
Replace free-form definition mutation details with typed, redacted reasons and shared recovery guidance for install and start/restart repair. Keep all ownership checks and stable update-recovery denial prefixes unchanged. Cover unsafe directory failure and permission-repair recovery without config or service publication before denial or SecretRef bypass afterward. Fixes #132278.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 10:30 PM ET / August 29, 2026, 02:30 UTC. ClawSweeper reviewWhat this changesThe PR replaces generic Linux Gateway service-publication failures with typed, redacted reason tags and safe recovery guidance for install and start/restart repair. Merge readinessKeep open: the PR remains necessary, and no introduced correctness defect was found. It needs normal maintainer handling after exact-head checks complete because it is maintainer-authored and carries the protected Likely related people: steipete (high, current diagnostic-contract contributor); Vincent Koc (medium, recent owner-boundary contributor). Priority: P2 Review scores
Verification
How this fits togetherGateway install and repair inspect the native service definition before configuration, token, or service-file writes. That inspection determines whether publication may proceed or must return a safe operator-facing diagnostic. flowchart LR
A[Gateway install or repair] --> B[Service definition inspection]
B --> C{Safe to modify?}
C -->|Yes| D[Config and service publication]
C -->|No| E[Typed redacted reason]
E --> F[CLI recovery guidance]
Decision needed
Why: The protected maintainer label and member authorship require explicit maintainer handling even though the patch and native proof are otherwise review-clean. Before merge
Agent review detailsSecurityNone. PR surfaceSource +30, Tests +108, Docs +21. Total +159 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single typed, allowlisted diagnostic renderer; no net-neutral alternative would preserve the required reason and artifact distinctions while eliminating free-form inspection detail. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: current main still collapses unsafe mode bits into the generic diagnostic, and the supplied disposable native-Linux scenario exercises that path. Is this the best way to solve the issue? Yes: the fix records the safe, closed reason at the systemd publication owner and passes it unchanged to one redacted renderer, rather than restoring unsafe free-form error forwarding in each CLI caller. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0f054bb3df51. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Pre-merge verification for head Maintainer decision: land this diagnostics-only repair. Exact-head CI run 33228776765 passed, including the required openclaw/ci-gate. The live head matches, the PR is mergeable/clean, and no failing check or changes-requested review remains. The initial compact-shard failure was five node scripts/run-vitest.mjs src/daemon src/cli/daemon-cli/install.integration.test.ts src/cli/daemon-cli/start-repair.test.ts src/cli/update-cli/update-command-service.integration.test.tsThe original candidate also passed Native behavior proof remains valid because production inputs are unchanged: Blacksmith Testbox run 33226287496, lease Disposition of the latest ClawSweeper review:
No accepted actionable review finding remains. No native macOS/Windows installation behavior changes; shared adapter and macOS definition-preserving activation regressions passed. The separate parser-import repair is untouched. The related Doctor preflight-ordering question remains a separately recorded investigation, not scope added to this PR. |
|
Merged via squash.
|
…2279) * fix(daemon): explain service publication authority failures Replace free-form definition mutation details with typed, redacted reasons and shared recovery guidance for install and start/restart repair. Keep all ownership checks and stable update-recovery denial prefixes unchanged. Cover unsafe directory failure and permission-repair recovery without config or service publication before denial or SecretRef bypass afterward. Fixes openclaw#132278. * test(daemon): assert typed system ownership diagnostics
Closes #132278 — unsafe service-directory permissions are hidden behind a generic installation error.
Additional instructions
This is a same-repository branch; maintainers can push fixes directly.
What Problem This Solves
Fixes an issue where users installing a managed Gateway would receive only
SERVICE_DEFINITION_UNKNOWNwhen an account-owned service-publication directory or existing ancestor was group/world-writable. The guard correctly refused the operation, but the CLI hid the reason needed to repair the directory. Start/restart repair discarded the same information.Why This Change Was Made
The publication owner now returns closed reason codes and redacted artifact categories, and the shared assertion renders allowlisted explanations and next actions. This removes free-form detail from the contract and the duplicate CLI detail-replacement paths without forwarding private paths, config/environment contents, or native errors. Existing
SERVICE_DEFINITION_SEALED:/SERVICE_DEFINITION_UNKNOWN:prefixes remain unchanged because definition-preserving update recovery recognizes them.Authority classification, owner checks, mode checks, mount/symlink protection, publication locking, and pre-config/token ordering are unchanged. There is no parser/import change, new option, dependency change, persistence/schema change, timeout increase, or guard bypass.
Production LOC: +82/-52 (net +30). Tests: +184/-76 (net +108). The production growth is the bounded diagnostic vocabulary and shared recovery renderer; the owner and CLI paths otherwise shrink. Documentation: +22/-1.
User Impact
Operators can distinguish unsafe permissions from foreign ownership, a sealed mount, a symlink, unexpected file types, or failed inspection. For unsafe permissions, the message identifies the artifact category, explains how to inspect ownership/mode locally, and permits repair guidance only for an owned, nonshared path. It does not recommend recursive chmod, taking ownership, or bypassing the check with
sudo/--force.The recovery steps are documented in Gateway install identity. This is an AI-assisted, maintainer-requested diagnostics follow-up.
Evidence
Behavior regression and sibling coverage
The new JSON and text regression cases fail on the pre-fix source because the permission reason and next action are absent, then pass with this change. All 269 tests in six files passed, covering failure/recovery, config/token non-mutation, unsafe mode bits, foreign ownership, symlinks, mounts, publication races/rollback, safe directory creation, start/restart repair, and definition-preserving update activation (including the macOS sibling).
All commands passed; the changed gate included core/test typechecks, scoped lint, dead exports, import cycles, and applicable guards. Docs: 6,975 internal links checked, zero broken links. Fresh Codex autoreview completed at the configured P0 threshold with no accepted/actionable findings.
CI-discovered sibling assertion correction
The initial PR CI run caught five system-scope ownership cases that still expected the retired raw
detailfield. Those assertions now require the exact typedsystem-owned/system-ownership-unverifiedreasons; the secret-canary and no-user-inspection assertions remain intact. This was a test-only correction, not a change to authority behavior.The expanded local run passed 1,302 tests across 39 files, with 5 platform skips, including the full daemon suite and CLI recovery siblings:
Targeted lint passed, and fresh Codex autoreview of the complete PR candidate was scoped-clean at the configured P0 threshold. Production inputs are unchanged from the native proof below. Exact-head CI is rerun for the corrected head.
Native Linux before/after proof
Provider: Blacksmith Testbox, lease
tbx_01m15hv19h0qzkts4w70y1dqne, run 33226287496. This used the real disposable OS account/home, native systemd user manager, an allowlisted process environment, and a fresh named profile—not service-manager shims.The initial prerequisite probe lacked the non-login-shell user-bus environment; correcting only that proof setup made the native query work. No manager/service was started to bypass it. The candidate was rebuilt with
pnpm build; hashes of 14 scoped owner/dependency inputs matched the local candidate before and after the build. The fingerprint was16f1947ff2f6f0b298c235d8cac3c53479899994fc6044f64eb94a1fcdc046ec; the Testbox mirror's synthetic Git SHA is not used as candidate identity.Sanitized observed result:
{ "before": { "typedPermissionReason": false, "safeNextAction": false }, "afterAt0777": { "reason": "unsafe-permissions", "artifact": "service-directory", "safeNextAction": true, "noPrivatePathInDiagnostic": true, "blockedBeforeConfigOrServiceWrites": true, "cliExitCode": 1 }, "sameInvocationAfter0700": { "authorityBlockCleared": true, "expectedUnresolvedSyntheticSecretRefReached": true, "persistedGatewayModeLocal": true, "secretRefPreserved": true, "noServiceArtifacts": true, "cliExitCode": 1 }, "proofPassed": true, "ownedProfileRemoved": true, "originalDirectoryModeRestored": true, "testboxStopped": true }The recovered CLI still exits
1intentionally: recovery means reaching the genuine unresolved-SecretRef rejection, not creating a service. Testbox wrapper exit was0; the linked long-running hydration Actions job iscancelledbecause the owned lease was explicitly stopped after proof. It is behavior evidence, not the PR's CI gate. Exact-head PR CI is tracked separately.