Skip to content

fix(daemon): preserve file-backed gateway auth secrets across service regeneration - #120458

Merged
steipete merged 1 commit into
mainfrom
codex/verify-111578-service-env
Aug 8, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/verify-111578-service-env

Conversation

@steipete

@steipete steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

In-place updates (brew upgrade, openclaw gateway install reinstall) regenerate the managed launchd service-env file and drop OPENCLAW_GATEWAY_AUTH_TOKEN while preserving channel tokens. The gateway then fails startup with SecretRefResolutionError — recurring even after the 2026.7.1 fix for the same class.

Fixes symptom 1 of #111578 (reported by @tlopez80-a11y). Symptom 2 (CLI auth outside the LaunchAgent's sourced env) is intentional fail-closed per docs; a design proposal (scoped paired-device auth) is escalated separately.

Why This Change Was Made

Root cause: the install planner unconditionally excluded gateway.auth.token/gateway.auth.password from the service-env plan (NON_PERSISTED_CONFIG_SECRET_ENV_TARGET_IDS) before existing file-backed values were even considered — so every regeneration deleted the entry by design. The recurrence was structural, not a missed edge case.

Security calibration (maintainer decision, recorded inline): gateway ingress secrets are still never newly materialized into supervisor metadata — fresh installs and mismatched/inactive refs get nothing. But when the existing service-env file already carries an active, matching, file-backed auth ref, regeneration preserves it: deleting it protects nothing (the same file retains channel tokens) while breaking gateway startup on every update — the worst outcome class.

Also forward-ports two release-branch-only commits to main (same owner surface, previously missing from main entirely): 45b6793ebfe1c "preserve runtime env during service refresh" (origin 75a613587cd9) and 8b85caff51143 "expose service env helper through owner module" — without these, next month's train would regress the update path.

User Impact

Updating OpenClaw no longer bricks gateway startup for operators using gateway.auth.token as a file-backed SecretRef.

Evidence

  • Real fixture repro: plist + service-env parse → plan → stageLaunchAgent → emitted-file reread; before the fix the regenerated plan retained Telegram tokens but dropped OPENCLAW_GATEWAY_AUTH_TOKEN; after, both survive. Coverage includes permissions, plist secrecy, token/password symmetry, mismatched/inactive refs dropped, dotenv precedence, and fresh-install non-materialization.
  • Focused suites: 328 tests green (re-verified independently after review). pnpm tsgo:core + tsgo:core:test pass; deadcode scans clean; git diff --check clean.
  • Codex autoreview (gpt-5.6-sol, high): clean three times (worker, independent re-review, coordinator pass on frozen diff — 0.98).
  • Forward-port faithfulness verified by independent diff comparison against the release commits.
  • Production +98/−46; tests +467/−1.

@steipete
steipete marked this pull request as ready for review August 8, 2026 04:19
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations labels Aug 8, 2026
@steipete
steipete merged commit e9d3cf1 into main Aug 8, 2026
66 of 67 checks passed
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 8, 2026
@steipete
steipete deleted the codex/verify-111578-service-env branch August 8, 2026 04:19
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 8, 2026
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 maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant