Repository navigation
[Fix] Preflight runtime SecretRefs before config writes - #84454
Conversation
|
Codex review: needs maintainer review before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. Source inspection shows current main commits root/include writes before runtime refresh can reject unresolved active SecretRefs, and the existing gateway-auth integration test expects the bad SecretRef to remain persisted after the refresh failure. PR rating Rank-up moves:
What the crustacean ranks mean
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. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land a rebased version after maintainers accept fail-closed SecretRef preflight as the config-write contract and verify the linked daemon-invalid setup path plus root/include rollback behavior. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main commits root/include writes before runtime refresh can reject unresolved active SecretRefs, and the existing gateway-auth integration test expects the bad SecretRef to remain persisted after the refresh failure. Is this the best way to solve the issue? Mostly yes, if maintainers accept the fail-closed contract. Preflight plus snapshot reuse and rollback is the narrow code path; a strict-mode/default-compat split would be safer only if write-first behavior must remain supported. Label changes:
Label justifications:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 23c58081d062. |
|
ClawSweeper PR egg ✨ Hatched: 🌱 uncommon Tiny Proofling Hatch commandComment Hatchability rules:
Rarity: 🌱 uncommon. What is this egg doing here?
|
d6c7ef6 to
dda1e4f
Compare
68b79a2 to
8c86f6e
Compare
|
Maintainer verification for rebased head Behavior addressed: config writes now preflight active runtime SecretRefs before persistence, reuse the prepared runtime snapshot during refresh, and roll back root/include writes plus unchanged env mutations on post-commit refresh failure. Real environment tested: local OpenClaw source checkout on macOS plus fresh GitHub CI for the rebased PR head. Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: branch rebased cleanly on current What was not tested: no live external provider credentials or full managed gateway restart were run locally; coverage here is focused source behavior, build/type/lint proof, autoreview, and fresh PR CI. |
b261411 to
e60dfca
Compare
|
Final maintainer verification for head Behavior addressed: config writes preflight active runtime SecretRefs before root/include persistence, reuse the prepared runtime snapshot during refresh, and roll back unchanged file/env state on post-write refresh failure. Real environment tested: local OpenClaw source checkout on macOS plus fresh PR CI for the final rebased head. Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: PR is cleanly mergeable against current What was not tested: no live external provider credentials or full managed gateway restart were run locally; coverage is focused source behavior, build/type/lint proof, autoreview, and fresh PR CI. |
steipete
left a comment
There was a problem hiding this comment.
Approved after rebase, changelog credit, local focused proof, clean autoreview, and fresh green CI on e60dfca80ccc1e24158bbd18989116cd14d7eb4e.
* fix(config): preflight runtime secret refs before writes * fix(config): restore include rollback env * docs(changelog): note SecretRef config preflight --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(config): preflight runtime secret refs before writes * fix(config): restore include rollback env * docs(changelog): note SecretRef config preflight --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(config): preflight runtime secret refs before writes * fix(config): restore include rollback env * docs(changelog): note SecretRef config preflight --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
Motivation
Config writes should not leave daemon-unpreparable SecretRefs on disk. If the active runtime already knows a write cannot resolve required SecretRefs, the write should fail before commit; if refresh fails after commit, rollback should restore both file bytes and config-injected env state.
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
openclaw.json, includedmodels.json5, includedenv.json5, productionprepareSecretsRuntimeSnapshot(),activateSecretsRuntimeSnapshot(),writeConfigFile(),createConfigIO(), andreplaceConfigFile().node --import tsx --input-type=modulewith an inline script that executed four real write scenarios: active gateway-auth SecretRef root write, active model-provider request SecretRef include write, root refresh-failure rollback withenv.vars, and include refresh-failure rollback with includedenv.vars.{ "allPassed": true, "results": { "rootSecretRefPreflightBlocked": true, "rootSecretRefNamesMissingEnv": true, "rootFileUnchangedAfterSecretRefPreflight": true, "rootRuntimeSnapshotPreserved": true, "rootSourceRefPreserved": true, "includeSecretRefPreflightBlocked": true, "includeSecretRefNamesMissingEnv": true, "includeFileUnchangedAfterSecretRefPreflight": true, "rootRefreshFailureSurfaced": true, "rootRefreshSawWrittenEnv": true, "rootRefreshRollbackRestoredFile": true, "rootRefreshRollbackRestoredEnv": true, "includeRefreshFailureSurfaced": true, "includeRefreshSawWrittenEnv": true, "includeRefreshRollbackRestoredFile": true, "includeRefreshRollbackRestoredEnv": true } }active SecretRef resolution failedbefore file bytes changed; active runtime config/source snapshots stayed on the previous good values; synthetic refresh failures surfaced as runtime refresh errors; root and included files returned to original bytes; config-injected env vars were removed after successful rollback.Root Cause
Regression Test Plan
src/config/io.write-config.test.tssrc/config/mutate.test.tssrc/secrets/runtime.gateway-auth.integration.test.tssrc/secrets/runtime-request-secret-refs.test.tsUser-visible / Behavior Changes
Config writes that would leave the active daemon unable to resolve required SecretRefs now fail before persistence. Refresh failures after persistence roll back unchanged root/include writes and restore config-injected env mutations when safe.
Security Impact (required)
Yes/No) NoYes/No) YesYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: unresolved active SecretRefs are blocked before disk writes, preflighted SecretRef snapshots are reused for refresh, and rollback removes stale env-injected secret values when they are still unchanged.Repro + Verification
Environment
env.vars, top-levelmodelsinclude, and top-levelenvincludeSteps
models.json5, then attempt an include mutation that changes it to a missing env SecretRef.env.vars.env.varswrite.Expected
Actual
true.Verification
git merge-tree HEAD upstream/main | rg -n "CONFLICT|Auto-merging|docs/.generated|<<<<<<<|>>>>>>>|=======": passed, no output.node scripts/run-vitest.mjs src/secrets/runtime.gateway-auth.integration.test.ts src/secrets/runtime-request-secret-refs.test.ts src/config/runtime-snapshot.test.ts src/config/io.write-config.test.ts src/config/mutate.test.ts src/gateway/server-methods/config.test.ts src/gateway/server-methods/config.shared-auth.test.ts: passed, 9 files / 102 tests.node --import tsx --input-type=modulereal behavior proof script: passed, JSON output above.pnpm changed:lanes --base upstream/main --head HEAD --json: core + coreTests + docs only.pnpm plugin-sdk:api:check: passed.pnpm tsgo:core: passed.pnpm tsgo:test:src: passed.pnpm format:check src/config/io.ts src/config/io.write-config.test.ts src/config/mutate.ts src/config/mutate.test.ts src/config/runtime-snapshot.ts src/gateway/server-startup-config.ts src/secrets/runtime.ts src/secrets/runtime-request-secret-refs.test.ts src/secrets/runtime.gateway-auth.integration.test.ts: passed.node scripts/run-oxlint.mjs src/config/io.ts src/config/io.write-config.test.ts src/config/mutate.ts src/config/mutate.test.ts src/config/runtime-snapshot.ts src/gateway/server-startup-config.ts src/secrets/runtime.ts src/secrets/runtime-request-secret-refs.test.ts src/secrets/runtime.gateway-auth.integration.test.ts --quiet: passed, 0 warnings / 0 errors.pnpm build: passed.git diff --check upstream/main...HEAD: passed.Performance accounting
N/A. This PR changes failure ordering and rollback correctness, not a latency or throughput path.
AI-assisted disclosure
AI-assisted. I verified the behavior with source-backed tests and the real runtime proof above.
Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) YesYes/No) NoRisks and Mitigations