Skip to content

fix(secrets): keep unaffected owners live during reload failures - #110779

Merged
steipete merged 27 commits into
mainfrom
fix/secrets-degraded-postmerge
Jul 18, 2026
Merged

steipete merged 27 commits into
mainfrom
fix/secrets-degraded-postmerge

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #101265
Follow-up to #109792

What Problem This Solves

Fixes an issue where users reloading configuration with one temporarily unavailable SecretRef could lose unrelated resolved credentials, publish stale degraded state, or accept an unsafe config write while the reload transaction was still unsettled.

Why This Change Was Made

Secret reload degradation is now isolated by owner and bound to canonical reference, provider, and complete owner-config contracts. Publication and rollback use activation lineage and compare-and-swap ownership; config writes reject unsafe degraded transitions; provider-auth descendants and web-tool owners preserve only unchanged last-known-good state. Existing plugin SDK callers that omit the new owner contract remain compatible and conservatively start cold.

User Impact

Operators can reload around a temporary secret-provider outage without unrelated channels, providers, web tools, or auth profiles losing healthy credentials. Changed owners still fail closed, and recovery/status warnings reflect only committed runtime state.

Evidence

  • Updated scratch autoreview scanner: full branch review clean against current origin/main at e34ee002e8a2 (confidence 0.78).
  • Exact-head Blacksmith changed gate green: all core/core-test/extension/extension-test typechecks; full core and extension lint; formatting; generated Plugin SDK API baseline; SDK surface/export/boundary guards; database-first and runtime import-cycle guards. Run: https://github.com/openclaw/openclaw/actions/runs/29649394411
  • Focused gateway/reload matrices: 155/155 passing; legacy owner compatibility: 1/1 passing; final startup/source-recovery matrix after helper ownership refactor: 47/47 passing.
  • Regression coverage includes equivalent SecretRef syntax canonicalization, legacy plugin owner contracts, source-only lineage recovery, deferred descendant publication, config-write rejection, provider-auth scoped refresh, and web-owner retention.

@steipete
steipete requested a review from a team as a code owner July 18, 2026 15:37
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: msteams Channel integration: msteams gateway Gateway runtime commands Command implementations size: XL maintainer Maintainer-authored PR labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. 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 Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 12:55 PM ET / 16:55 UTC.

Summary
The branch changes SecretRef reloads to refresh healthy owners, preserve unchanged failed owners as stale last-known-good state, and keep changed or new failed owners cold across Gateway, provider-auth, config-write, and status paths.

PR surface: Source +1037, Tests +1739, Docs -2, Generated 0. Total +2774 across 53 files.

Reproducibility: no. high-confidence live reproduction is included. The inline review provides a source-level path: an auth profile with keyRef or tokenRef, ignored plaintext credentials, and a transient SecretRef failure can distinguish stale retention from cold failure.

Review metrics: 1 noteworthy metric.

  • Credential-owner surfaces: 2 owner states changed: cold and stale. The new stale state changes whether existing credentials remain usable during a transient reload failure.

Stored data model
Persistent data-model change detected: migration/backfill/repair: docs/cli/doctor.md, migration/backfill/repair: src/commands/doctor-gateway-health.test.ts, serialized state: src/gateway/server.config-patch.test.ts, vector/embedding metadata: src/gateway/server-startup-config-helpers.ts, vector/embedding metadata: src/secrets/runtime-web-tools.test.ts, vector/embedding metadata: src/secrets/runtime-web-tools.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Normalize the auth-profile owner contract and cover the ignored-plaintext outage case.
  • [P1] Add redacted live Gateway proof for healthy, stale, and cold reload outcomes.
  • Request a fresh review after updating the PR body.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Tests and CI listed in the PR body are supplemental only; add redacted after-fix Gateway terminal output, logs, or a linked artifact proving healthy refresh, unchanged-owner stale retention, and changed-owner cold failure. Update the PR body afterward; if no fresh review appears, ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P0] An ignored plaintext auth-profile field can change the raw owner-contract digest even though the effective SecretRef and provider configuration are unchanged, causing an outage reload to discard last-known-good credentials instead of retaining them as stale.
  • [P1] This is a compatibility-sensitive change to existing SecretRef reload, provider-auth, and configuration-write behavior; maintainer acceptance needs redacted proof of both stale-retention and cold-failure boundaries.

Maintainer options:

  1. Fix normalized owner contracts before merge (recommended)
    Build auth-profile owner contracts from the same normalized effective credential state that resolution uses, then add regression coverage for an ignored plaintext edit during a failed reload.
  2. Accept raw-profile cold failures
    Merge only if maintainers intentionally want ignored plaintext edits to invalidate stale credential retention during a provider outage.

Next step before merge

  • [P1] A protected maintainer label, an explicit credential-retention policy choice, a concrete P2 defect, and missing contributor-run live proof require human review rather than automated repair.

Maintainer decision needed

  • Question: Should transient SecretRef reload failures retain credentials only when the normalized effective owner configuration is unchanged, including ignored plaintext fields in auth profiles?
  • Rationale: The branch establishes a credential-retention boundary across reload failures. The reported edge case is mechanically fixable, but maintainers should explicitly confirm the normalized effective-profile contract as the intended safety rule.
  • Likely owner: steipete — Recent merged and current work shows direct ownership of the SecretRef degradation and reload implementation.
  • Options:
    • Normalize effective auth profiles (recommended): Exclude plaintext key or token fields when their corresponding SecretRef is present before hashing the owner contract, so only meaningful owner changes force cold failure.
    • Keep raw-profile strictness: Treat any raw auth-profile edit, including ignored plaintext, as a change that discards stale credentials during an unavailable SecretRef reload.

Security
Cleared: No new dependency, workflow, package-source, or secret-exposure change is evident in the supplied diff metadata; the credential-retention boundary is tracked as a functional compatibility finding.

Review findings

  • [P2] Normalize ignored auth plaintext before hashing owner contracts — src/secrets/runtime-auth-collectors.ts:30-45
Review details

Best possible solution:

Normalize each auth profile to its effective credential shape before computing the owner contract, preserve stale state only for that normalized unchanged contract, and attach redacted live Gateway reload proof for healthy, stale, and cold owners before merge.

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

No high-confidence live reproduction is included. The inline review provides a source-level path: an auth profile with keyRef or tokenRef, ignored plaintext credentials, and a transient SecretRef failure can distinguish stale retention from cold failure.

Is this the best way to solve the issue?

No: owner-scoped retention is the right direction, but hashing the raw profile before ignored plaintext is normalized is not the narrowest correct boundary; use the effective normalized profile instead.

Full review comments:

  • [P2] Normalize ignored auth plaintext before hashing owner contracts — src/secrets/runtime-auth-collectors.ts:30-45
    When keyRef or tokenRef is present, the collector later ignores plaintext credential fields, but resolveAuthProfileOwnerContract currently clones the unnormalized profile. A change only to that ignored plaintext therefore makes an otherwise unchanged unavailable owner cold and drops its last-known-good credential; derive the contract from the effective normalized profile instead.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.8

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 837db49ebb24.

Label changes

Label justifications:

  • P2: The PR addresses a bounded but cross-cutting reliability and credential-reload behavior change.
  • merge-risk: 🚨 compatibility: Existing SecretRef reload behavior and fallback boundaries change for configured owners.
  • merge-risk: 🚨 auth-provider: The affected owner contracts include provider-auth and auth-profile credentials.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Tests and CI listed in the PR body are supplemental only; add redacted after-fix Gateway terminal output, logs, or a linked artifact proving healthy refresh, unchanged-owner stale retention, and changed-owner cold failure. Update the PR body afterward; if no fresh review appears, ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +1037, Tests +1739, Docs -2, Generated 0. Total +2774 across 53 files.

View PR surface stats
Area Files Added Removed Net
Source 31 1590 553 +1037
Tests 19 1869 130 +1739
Docs 2 9 11 -2
Config 0 0 0 0
Generated 1 3 3 0
Other 0 0 0 0
Total 53 3471 697 +2774

What I checked:

  • Concrete current-head review concern: The supplied inline review identifies that the new auth-profile owner contract hashes the raw profile before the collector removes plaintext key or token values that are ignored when keyRef or tokenRef exists. Editing only that ignored field during an outage would make an effective no-op look changed and turn stale retention into cold failure. (src/secrets/runtime-auth-collectors.ts:30, e8ff4a881e71)
  • Missing real behavior artifact: The PR body reports focused tests and a changed gate, but it does not include an inspectable redacted after-fix live Gateway transcript, runtime log, or linked artifact showing one healthy refresh, one unchanged failed owner retained as stale, and one changed failed owner cold. (e8ff4a881e71)
  • Protected maintainer routing: The supplied GitHub context shows the PR has the protected maintainer label, so it should remain open for explicit maintainer handling. (e8ff4a881e71)
  • Feature-history provenance: The related merged SecretRef degradation follow-up was authored by the same contributor and merged as commit 347ee45895033b461649b1bcd2035b23fd221d5b; this PR explicitly follows that owner-isolation work into reload semantics. (src/secrets/runtime.ts:146, 347ee4589503)

Likely related people:

  • steipete: Authored the current branch and the immediately preceding merged SecretRef degradation follow-up that this PR extends to reload-time behavior. (role: recent area contributor; confidence: high; commits: 49d0bc99355d, e8ff4a881e71; files: src/secrets/runtime.ts, src/gateway/server-reload-handlers.ts, src/secrets/runtime-auth-collectors.ts)
  • snowzlmbot: Authored the merged cold-start SecretRef owner-isolation foundation that the supplied PR body identifies as the preceding implementation. (role: introduced related owner-isolation foundation; confidence: medium; commits: 17c2ce05d80a; files: src/secrets/runtime-config-collectors-core.ts, src/secrets/runtime-degraded-state.ts)
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.

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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-18T15:45:30.886Z sha 62c9c1470318f9e74ceb2dc0922f987b5e15d5a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T16:12:47.676Z sha e8ff4a881e7192d5edd041684bbfa6920a262169 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 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: e8ff4a881e

ℹ️ 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".

(normalizeOptionalLowercaseString(candidateId) ?? candidateId) === providerId,
);
return {
profile: structuredClone(profile),

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 Exclude ignored auth plaintext from stale-owner contracts

When an auth profile has keyRef/tokenRef plus a plaintext key/token, the collector warns that the plaintext is ignored and clears it before resolution, but the new owner contract hashes structuredClone(profile) before that normalization. If a user edits only that ignored plaintext while the SecretRef provider is unavailable, the contract digest changes even though the effective ref and provider config are unchanged, so classifySecretOwnerDegradationState marks the account cold instead of stale and drops the last-known-good auth credential. Build the contract from the normalized effective profile or omit plaintext fields when a ref is present.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the fix/secrets-degraded-postmerge branch from e8ff4a8 to 656ebf3 Compare July 18, 2026 17:23
@steipete
steipete merged commit 8a5c869 into main Jul 18, 2026
118 checks passed
@steipete
steipete deleted the fix/secrets-degraded-postmerge branch July 18, 2026 17:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 19, 2026
…nclaw#110779)

* fix(secrets): isolate reload failures per owner

* refactor(secrets): split runtime activation helpers

* fix(secrets): export web warning type

* fix(secrets): reject unsafe degraded config writes

* fix(secrets): derive reload defaults type

* fix(secrets): defer reload state publication

* fix(secrets): preserve partial refresh state

* fix(secrets): retry superseded reload preflight

* fix(secrets): bind stale credentials to owner contracts

* fix(secrets): scope degraded credential contracts

* fix(secrets): restore source ownership guards

* fix(secrets): recover provider-only degradation

* fix(secrets): enforce degraded reload contracts

* fix(secrets): preserve scoped reload state

* fix(secrets): reconcile deferred descendant state

* fix(secrets): commit reload state atomically

* fix(secrets): preserve source transaction lineage

* test(secrets): use non-secret lineage marker

* chore(plugin-sdk): refresh API baseline

* fix(secrets): canonicalize web owner contracts

* fix(plugin-sdk): preserve legacy secret owner contracts

* fix(secrets): satisfy startup activation types

* test(secrets): align reload fixtures with owner contracts

* refactor(secrets): move source recovery scope helper

* fix(secrets): preserve owner contracts on web failures

* fix(secrets): bind legacy web resolution contract

* fix(secrets): retry stale auth publication
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…nclaw#110779)

* fix(secrets): isolate reload failures per owner

* refactor(secrets): split runtime activation helpers

* fix(secrets): export web warning type

* fix(secrets): reject unsafe degraded config writes

* fix(secrets): derive reload defaults type

* fix(secrets): defer reload state publication

* fix(secrets): preserve partial refresh state

* fix(secrets): retry superseded reload preflight

* fix(secrets): bind stale credentials to owner contracts

* fix(secrets): scope degraded credential contracts

* fix(secrets): restore source ownership guards

* fix(secrets): recover provider-only degradation

* fix(secrets): enforce degraded reload contracts

* fix(secrets): preserve scoped reload state

* fix(secrets): reconcile deferred descendant state

* fix(secrets): commit reload state atomically

* fix(secrets): preserve source transaction lineage

* test(secrets): use non-secret lineage marker

* chore(plugin-sdk): refresh API baseline

* fix(secrets): canonicalize web owner contracts

* fix(plugin-sdk): preserve legacy secret owner contracts

* fix(secrets): satisfy startup activation types

* test(secrets): align reload fixtures with owner contracts

* refactor(secrets): move source recovery scope helper

* fix(secrets): preserve owner contracts on web failures

* fix(secrets): bind legacy web resolution contract

* fix(secrets): retry stale auth publication
steipete added a commit that referenced this pull request Sep 25, 2026
Carry the selected Gateway ambient policy into initial config auto-enable,
matching reload preparation. Require that policy at the startup config
boundary and classify explicit channel presence from authored source rather
than generated runtime enablement. Remove duplicate detector defaults.

Preserve explicit channel configuration and both ambient opt-in flags.
Document that the policy also applies to reloads and managed services.

Release-note context: env-only channel activation bypassed the documented
opt-in in stable releases through v2026.9.6. Affected operators must add
channels.<id> configuration or use --ambient-channels. Existing suppression
warnings explain the enablement path; no config migration should infer
operator consent from environment credentials. Completes the policy work
from #112011 and #123174 across the loader extracted in #110779.

Validation: 440 focused tests passed. Before the fix, the new suite had two
expected failures (suppression bypass and generated consent) and three
passes; after the fix all five pass. The authored-config/prior-release
corpus run had 24 passes and five 120-second timeouts, all in the first
Doctor checkpoint before Gateway config loading. No causal connection to
this fix was found; migration/worker timing remains a separate follow-up.
A standalone replay was stopped while waiting for the legitimate artifact
lock held by check-changed, before it reached Vitest.

The changed-check aggregate passed production typing, all 25 test-type
graphs, formatting, config docs, plugin boundaries and earlier guards, but
failed on the full-tree Knip export scan's 600-second timeout. The same
scan timed out when run alone with its unchanged limit; production/script
export scans passed. Changed-file lint passed with zero warnings/errors.
The native-state schema guard passed. The supplemental database-first
scan was stopped after over 16 minutes under host load around 179; later
media, sidecar, import-cycle, webhook and pairing guards were not run.
Full changed-check validation is not claimed green.
steipete added a commit that referenced this pull request Sep 25, 2026
…7387)

Carry the selected Gateway ambient policy into initial config auto-enable,
matching reload preparation. Require that policy at the startup config
boundary and classify explicit channel presence from authored source rather
than generated runtime enablement. Remove duplicate detector defaults.

Preserve explicit channel configuration and both ambient opt-in flags.
Document that the policy also applies to reloads and managed services.

Release-note context: env-only channel activation bypassed the documented
opt-in in stable releases through v2026.9.6. Affected operators must add
channels.<id> configuration or use --ambient-channels. Existing suppression
warnings explain the enablement path; no config migration should infer
operator consent from environment credentials. Completes the policy work
from #112011 and #123174 across the loader extracted in #110779.

Validation: 440 focused tests passed. Before the fix, the new suite had two
expected failures (suppression bypass and generated consent) and three
passes; after the fix all five pass. The authored-config/prior-release
corpus run had 24 passes and five 120-second timeouts, all in the first
Doctor checkpoint before Gateway config loading. No causal connection to
this fix was found; migration/worker timing remains a separate follow-up.
A standalone replay was stopped while waiting for the legitimate artifact
lock held by check-changed, before it reached Vitest.

The changed-check aggregate passed production typing, all 25 test-type
graphs, formatting, config docs, plugin boundaries and earlier guards, but
failed on the full-tree Knip export scan's 600-second timeout. The same
scan timed out when run alone with its unchanged limit; production/script
export scans passed. Changed-file lint passed with zero warnings/errors.
The native-state schema guard passed. The supplemental database-first
scan was stopped after over 16 minutes under host load around 179; later
media, sidecar, import-cycle, webhook and pairing guards were not run.
Full changed-check validation is not claimed green.

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…nclaw#157387)

Carry the selected Gateway ambient policy into initial config auto-enable,
matching reload preparation. Require that policy at the startup config
boundary and classify explicit channel presence from authored source rather
than generated runtime enablement. Remove duplicate detector defaults.

Preserve explicit channel configuration and both ambient opt-in flags.
Document that the policy also applies to reloads and managed services.

Release-note context: env-only channel activation bypassed the documented
opt-in in stable releases through v2026.9.6. Affected operators must add
channels.<id> configuration or use --ambient-channels. Existing suppression
warnings explain the enablement path; no config migration should infer
operator consent from environment credentials. Completes the policy work
from openclaw#112011 and openclaw#123174 across the loader extracted in openclaw#110779.

Validation: 440 focused tests passed. Before the fix, the new suite had two
expected failures (suppression bypass and generated consent) and three
passes; after the fix all five pass. The authored-config/prior-release
corpus run had 24 passes and five 120-second timeouts, all in the first
Doctor checkpoint before Gateway config loading. No causal connection to
this fix was found; migration/worker timing remains a separate follow-up.
A standalone replay was stopped while waiting for the legitimate artifact
lock held by check-changed, before it reached Vitest.

The changed-check aggregate passed production typing, all 25 test-type
graphs, formatting, config docs, plugin boundaries and earlier guards, but
failed on the full-tree Knip export scan's 600-second timeout. The same
scan timed out when run alone with its unchanged limit; production/script
export scans passed. Changed-file lint passed with zero warnings/errors.
The native-state schema guard passed. The supplemental database-first
scan was stopped after over 16 minutes under host load around 179; later
media, sidecar, import-cycle, webhook and pairing guards were not run.
Full changed-check validation is not claimed green.

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

channel: msteams Channel integration: msteams commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant