Skip to content

[Fix] Preflight runtime SecretRefs before config writes - #84454

Merged
steipete merged 3 commits into
openclaw:mainfrom
samzong:fix/config-secretref-preflight
May 24, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
samzong:fix/config-secretref-preflight

Conversation

@samzong

@samzong samzong commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: bottom/CLI config mutation paths could persist config that the active daemon runtime could not prepare, especially unresolved active SecretRefs, leaving the next runtime refresh or startup to fail after the bad config was already on disk.
  • Solution: preflight the exact source config against the active runtime refresh handler before committing root or single-file include writes, then pass the preflighted result into refresh so SecretRefs are not resolved twice.
  • Rollback hardening: if a post-commit runtime refresh still fails, roll back unchanged root/include writes and restore env mutations that were injected by the post-write read when they are still unchanged.
  • Scope boundary: no config schema change, no SecretRef syntax change, no plugin validation policy change, and no external provider credential behavior change beyond failing before persistence.

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)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior addressed: active runtime SecretRef failures are blocked before root and include config writes persist, and refresh-failure rollback restores root/include files plus env mutations.
  • Real environment tested: local OpenClaw source checkout on macOS in this branch, using real temporary openclaw.json, included models.json5, included env.json5, production prepareSecretsRuntimeSnapshot(), activateSecretsRuntimeSnapshot(), writeConfigFile(), createConfigIO(), and replaceConfigFile().
  • Exact steps or command run after this patch: node --import tsx --input-type=module with 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 with env.vars, and include refresh-failure rollback with included env.vars.
  • Evidence after fix: terminal output copied from the command:
{
  "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
  }
}
  • Observed result after fix: unresolved active SecretRefs failed with active SecretRef resolution failed before 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.
  • What was not tested: full managed gateway restart, live external provider credentials, and OS package install/update flows.
  • Before evidence: PR review found the previous proof only exercised a narrow temp include rollback case and did not prove the broader SecretRef preflight behavior or the root/include rollback surface.

Root Cause

  • Root cause: runtime snapshot refresh was treated as post-write follow-up for bottom/CLI config mutations, so daemon-unpreparable active SecretRefs could be written before refresh failed.
  • Secondary gap: root writes had env restoration around rollback, but single-file include writes did not restore env mutations from the post-write read.
  • Missing detection / guardrail: tests covered gateway startup preflight and include file rollback separately, but not the bottom/CLI writer proving active runtime SecretRefs before persistence.

Regression Test Plan

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target tests or files:
    • src/config/io.write-config.test.ts
    • src/config/mutate.test.ts
    • src/secrets/runtime.gateway-auth.integration.test.ts
    • src/secrets/runtime-request-secret-refs.test.ts
  • Scenario the tests lock in: root and single-file include config writes call active runtime preflight before committing, preserve the previous runtime snapshot/source on failure, reuse preflighted runtime SecretRef snapshots during refresh, and roll back file/env state on refresh failure.
  • Why this is the smallest reliable guardrail: the regression lives at the config writer/runtime refresh boundary, so the tests exercise that boundary directly without requiring a full gateway restart.
  • If no new test is added, why not: N/A

User-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)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) Yes
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, 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

  • OS: macOS
  • Runtime/container: local Node.js checkout through repo scripts
  • Model/provider: N/A
  • Integration/channel (if any): active secrets runtime and config writer/runtime refresh boundary
  • Relevant config (redacted): temporary configs with gateway auth SecretRef, model provider request SecretRef, root env.vars, top-level models include, and top-level env include

Steps

  1. Activate a production secrets runtime snapshot with a resolvable gateway auth SecretRef, then attempt a root config write that changes it to a missing env SecretRef.
  2. Activate a production secrets runtime snapshot with a resolvable model provider request SecretRef loaded from an included models.json5, then attempt an include mutation that changes it to a missing env SecretRef.
  3. Force a root post-commit runtime refresh failure after a config write with env.vars.
  4. Force an include post-commit runtime refresh failure after an included env.vars write.
  5. Assert file bytes, runtime snapshot/source, surfaced errors, and env state after each failure.

Expected

  • Active SecretRef failures are rejected before persistence.
  • The previous runtime snapshot/source remains active after failed preflight.
  • Refresh failures roll back unchanged root/include writes.
  • Env mutations injected by the failed post-write read are restored when unchanged.

Actual

  • All four behavior scenarios passed with every assertion in the JSON proof output set to 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=module real 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

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) Yes
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: no user action required; failed writes now fail earlier or roll back more completely.

Risks and Mitigations

  • Risk: env restoration could overwrite a concurrent env update.
    • Mitigation: restoration only touches keys whose current value still matches the value captured immediately after the post-write read.
  • Risk: preflight could resolve expensive SecretRefs twice.
    • Mitigation: refresh receives and reuses the preflighted runtime snapshot when it matches the source config.

@samzong
samzong requested a review from a team as a code owner May 20, 2026 05:36
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL proof: supplied External PR includes structured after-fix real behavior proof. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • 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.

Summary
The branch adds runtime SecretRef preflight before root and single-file include config writes, reuses the prepared snapshot during refresh, and rolls back file/env state on post-commit refresh failure.

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
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Summary: The PR has strong targeted proof and no definite blocking code finding, with remaining confidence gated on maintainer acceptance of the compatibility/auth-provider contract.

Rank-up moves:

  • Run the linked daemon-invalid provider setup or an equivalent managed gateway restart proof on the final rebased head.
  • Have the config/secrets owners explicitly accept the fail-closed runtime SecretRef write contract.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
Sufficient (terminal): The PR body includes terminal output from a local source checkout exercising real temporary config/include files and production runtime SecretRef helpers after the patch.

Risk before merge

  • Merging changes unresolved active SecretRefs from post-commit refresh failure/LKG behavior to pre-commit rejection, which can intentionally stop setup or repair flows that previously wrote config first.
  • The patch touches config mutation, runtime secrets refresh, plugin install index rollback, and process env restoration, so fresh-write, upgrade, and repair paths need owner acceptance beyond unit-level proof.
  • The PR body explicitly did not test a full managed gateway restart, live external provider credentials, or OS package install/update flows, leaving the linked daemon-invalid provider setup path as the main proof gap.
  • The new preflight/preflightResult contract is internal-looking but crosses exported config/runtime helper types used by multiple internal callers, so owners should accept that API shape before merge.

Maintainer options:

  1. Prove setup and upgrade writes before merge (recommended)
    Run or review focused root/include SecretRef preflight proof plus the linked daemon-invalid provider setup scenario on the current head before merging.
  2. Accept fail-closed SecretRef writes
    Maintainers can explicitly accept that active unresolved SecretRefs now block config persistence rather than relying on post-write last-known-good behavior.
  3. Pause for a compatibility contract
    Pause this PR if existing write-first behavior must remain the default until a narrower strict mode or repair-flow design is chosen.

Next step before merge
Needs maintainer judgment on fail-closed config write semantics and final upgrade/setup proof, not a narrow automated repair pass.

Security
Cleared: The diff changes secrets/config refresh ordering but does not add dependencies, broaden permissions, or introduce a concrete supply-chain or credential exposure issue.

Review details

Best 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:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from a local source checkout exercising real temporary config/include files and production runtime SecretRef helpers after the patch.
  • add rating: 🐚 platinum hermit: Current PR rating is 🐚 platinum hermit because proof is 🦞 diamond lobster, patch quality is 🐚 platinum hermit, and The PR has strong targeted proof and no definite blocking code finding, with remaining confidence gated on maintainer acceptance of the compatibility/auth-provider contract.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The PR addresses a linked auth-provider regression that can leave the gateway crash-looping and unreachable after a daemon-invalid SecretRef is persisted.
  • merge-risk: 🚨 compatibility: The diff intentionally changes config writes from write-then-refresh-fail to pre-commit rejection, which can break existing setup or repair flows that relied on write-first behavior.
  • merge-risk: 🚨 auth-provider: The changed path resolves and reuses SecretRef snapshots for gateway auth and model-provider request credentials, so provider credential behavior is directly affected.
  • rating: 🐚 platinum hermit: Current PR rating is 🐚 platinum hermit because proof is 🦞 diamond lobster, patch quality is 🐚 platinum hermit, and The PR has strong targeted proof and no definite blocking code finding, with remaining confidence gated on maintainer acceptance of the compatibility/auth-provider contract.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes terminal output from a local source checkout exercising real temporary config/include files and production runtime SecretRef helpers after the patch.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from a local source checkout exercising real temporary config/include files and production runtime SecretRef helpers after the patch.

What I checked:

  • Current root writes commit before runtime refresh: On current main, the exported writer calls io.writeConfigFile before the canonical read and finalizeRuntimeSnapshotWrite, so an active runtime SecretRef refresh failure happens after disk persistence. (src/config/io.ts:2487, 23c58081d062)
  • Current include writes commit before runtime refresh: On current main, the single top-level include fast path writes the include file before re-reading and finalizing the runtime snapshot, matching the persistence-before-refresh gap this PR targets. (src/config/mutate.ts:292, 23c58081d062)
  • Current test documents the old persisted-bad-ref behavior: The existing gateway auth integration test expects a missing active gateway SecretRef to fail refresh while leaving the missing SecretRef persisted on disk, which is the behavior the PR intentionally changes. (src/secrets/runtime.gateway-auth.integration.test.ts:102, 23c58081d062)
  • PR root write fix path: The PR diff adds a pre-commit runtime preflight hook before root file replacement, passes the preflighted result into refresh, and attempts unchanged-file/env rollback when post-commit refresh still fails. (src/config/io.ts, 68b79a28499b)
  • PR include write fix path: The PR diff preflights single-file include writes before writing the include file and adds rollback/env restoration around the include post-write read and refresh path. (src/config/mutate.ts, 68b79a28499b)
  • Real behavior proof supplied: The PR body includes copied terminal JSON from a local source checkout exercising root SecretRef preflight, include SecretRef preflight, root refresh rollback, and include refresh rollback with production runtime helpers and real temporary config files. (68b79a28499b)

Likely related people:

  • steipete: Recent GitHub commit history shows repeated work on config write independence, serialized config mutation writes, secrets startup, and runtime config revision plumbing across the touched config/secrets paths. (role: recent area contributor; confidence: high; commits: 2bb448908daf, 0177a4b6c9cc, 2e983e47dfdd; files: src/config/io.ts, src/config/mutate.ts, src/secrets/runtime.ts)
  • samzong: Recent merged history includes gateway startup auth SecretRef preflight snapshot reuse and startup trace work on the same gateway/secrets startup surface, separate from authoring this PR. (role: recent adjacent contributor; confidence: medium; commits: dd32c5307faa, 1d121c1f08a6, 0177a4b6c9cc; files: src/gateway/server-startup-config.ts, src/secrets/runtime.ts)
  • vincentkoc: Recent commits touched include-write and plugin-validation skip behavior in the config mutation path, which is one of the central paths changed by this PR. (role: adjacent config/include contributor; confidence: medium; commits: 6920ec6c54d1, f78434985af9; files: src/config/mutate.ts, src/config/io.ts)
  • giodl73-repo: Recent config write response and doctor-lint work touched the same root writer and mutation surfaces that this PR now changes. (role: adjacent config writer contributor; confidence: medium; commits: abf59205fcbd, 9a5f2f61e76f; files: src/config/io.ts, src/config/mutate.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 23c58081d062.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🌱 uncommon Tiny Proofling

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🌱 uncommon.
Trait: finds missing screenshots.
Image traits: location merge queue dock; accessory tiny test log scroll; palette moonlit blue and soft silver; mood mischievous; pose standing beside its cracked shell; shell woven fiber shell; lighting moonlit rim light; background miniature CI buoys.
Share on X: post this hatch
Copy: My PR egg hatched a 🌱 uncommon Tiny Proofling in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@samzong samzong changed the title [Fix] Restore include rollback env [Fix] Preflight runtime SecretRefs before config writes May 20, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 20, 2026
@samzong
samzong force-pushed the fix/config-secretref-preflight branch from d6c7ef6 to dda1e4f Compare May 20, 2026 05:57
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 20, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels May 21, 2026
@steipete steipete self-assigned this May 24, 2026
@steipete
steipete force-pushed the fix/config-secretref-preflight branch from 68b79a2 to 8c86f6e Compare May 24, 2026 02:24
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 24, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer verification for rebased head 8c86f6ed0b171c2db62e63cb3f494fc541284a81.

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:

  • git rebase origin/main
  • pnpm plugin-sdk:api:gen
  • 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
  • pnpm plugin-sdk:api:check
  • pnpm tsgo:core
  • pnpm tsgo:test:src
  • 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
  • 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
  • git diff --check origin/main...HEAD
  • pnpm changed:lanes --base origin/main --head HEAD --json
  • pnpm build
  • /Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main
  • git push https://github.com/samzong/openclaw.git HEAD:fix/config-secretref-preflight --force-with-lease=fix/config-secretref-preflight:68b79a28499bdd697c9c39fb167de659bf61a770

Evidence after fix:

  • Focused Vitest: 9 files / 102 tests passed.
  • Plugin SDK API baseline check: passed after regenerating the rebased hash.
  • tsgo:core: passed.
  • tsgo:test:src: passed.
  • Format check: passed.
  • Oxlint on touched files: passed.
  • git diff --check: passed.
  • Build: passed.
  • Autoreview: clean, no accepted/actionable findings.
  • Fresh CI on 8c86f6ed0b171c2db62e63cb3f494fc541284a81: green. Key runs: CI 26349623236, CodeQL 26349623237, CodeQL Critical Quality 26349623234, Real behavior proof 26349629595, Workflow Sanity 26349623235, OpenGrep PR Diff 26349623232.

Observed result after fix: branch rebased cleanly on current origin/main; the prior merge conflict was resolved by regenerating docs/.generated/plugin-sdk-api-baseline.sha256; GitHub now reports all checks passing.

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.

@steipete
steipete force-pushed the fix/config-secretref-preflight branch from b261411 to e60dfca Compare May 24, 2026 02:33
@steipete

Copy link
Copy Markdown
Contributor

Final maintainer verification for head e60dfca80ccc1e24158bbd18989116cd14d7eb4e.

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:

  • 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
  • pnpm plugin-sdk:api:check
  • pnpm tsgo:core
  • pnpm tsgo:test:src
  • 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
  • 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
  • git diff --check origin/main...HEAD
  • pnpm changed:lanes --base origin/main --head HEAD --json
  • pnpm build
  • /Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main
  • git diff --check after changelog conflict resolution

Evidence after fix:

  • Focused Vitest: 9 files / 102 tests passed.
  • Plugin SDK API baseline check, core/test typecheck, format, oxlint, diff-check, changed-lanes, and build passed locally.
  • Autoreview: clean, no accepted/actionable findings.
  • Fresh CI on final head e60dfca80ccc1e24158bbd18989116cd14d7eb4e: all checks passing. Key runs: CI 26349787822, CodeQL 26349787788, CodeQL Critical Quality 26349787802, Real behavior proof 26349787172, Workflow Sanity 26349787801, OpenGrep PR Diff 26349787789.

Observed result after fix: PR is cleanly mergeable against current main; final conflict was changelog-only busy-main churn and both entries were preserved.

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 steipete 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.

Approved after rebase, changelog credit, local focused proof, clean autoreview, and fresh green CI on e60dfca80ccc1e24158bbd18989116cd14d7eb4e.

@steipete
steipete merged commit 31145e0 into openclaw:main May 24, 2026
99 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* 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]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* 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]>
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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]: model-assisted Moonshot/Kimi setup can write a daemon-invalid secret reference and crash-loop the gateway

2 participants