Skip to content

fix(secrets): resolve active exec refs locally - #104192

Closed
arcabotai wants to merge 1 commit into
openclaw:mainfrom
arcabotai:fix/exec-secretref-gateway-noise
Closed

arcabotai wants to merge 1 commit into
openclaw:mainfrom
arcabotai:fix/exec-secretref-gateway-noise

Conversation

@arcabotai

@arcabotai arcabotai commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • resolve active command-scoped exec SecretRefs locally before calling gateway secrets.resolve
  • preserve gateway snapshot ownership for all remaining non-exec targets
  • fall back to gateway resolution when a local exec provider fails
  • preserve the path-specific local exec error only when gateway recovery also fails
  • preserve inactive-surface diagnostics and merge per-path resolution state

This prevents reply from producing noisy gateway secrets.resolve unavailable errors when agent-runtime model/provider credentials use locally executable SecretRefs.

Fixes #96653

What Problem This Solves

Queued reply turns currently send active model/provider exec SecretRefs to gateway secrets.resolve. The gateway cannot execute those local providers, so it returns UNAVAILABLE; the reply process then resolves the same ref locally and succeeds. That produces a misleading gateway error and needless round trip on every turn. Mixed-source commands additionally need a stable ownership boundary: resolving an exec path locally must not move unrelated env or other snapshot-backed credentials out of the gateway.

Resolution boundary

This PR intentionally uses split per-path resolution:

  1. Active and allowed exec paths resolve locally.
  2. Successfully resolved exec paths are removed from the unresolved target set.
  3. Remaining env/file/keychain/plugin-backed paths continue through the active gateway snapshot.
  4. If local exec fails, that path remains unresolved and is included in the gateway request.
  5. Successful gateway recovery removes the stale local error; dual failure retains the actionable local provider diagnostic.

This keeps configured exec execution narrowly scoped while preserving the gateway as the source of truth for non-exec credentials.

Evidence

Tested after rebasing onto current main.

Environment:

  • Linux x64
  • Node v22.22.2
  • production bundle built with pnpm build cliStartup
  • temporary real gateway process with a temporary config/state directory
  • real child process for the exec provider
  • no production credentials; all values were synthetic and redacted from output

Command:

node /root/cad/reports/pr-104192-live-proof.mjs

Redacted output:

LIVE BUILT-CODE PROOF — PR #104192
Node: v22.22.2
Dist: command-secret-gateway-B6pWjwzk.js

exec-only:
  markerRan: true
  talk.providers.local-exec.apiKey: resolved_local
  unresolved: false
  diagnostic: resolved exec SecretRefs locally without gateway secrets.resolve

mixed-exec-and-gateway:
  markerRan: true
  talk.providers.local-exec.apiKey: resolved_local
  talk.providers.gateway-env.apiKey: resolved_gateway
  unresolved: false

local-exec-failure-gateway-recovery:
  markerRan: false
  talk.providers.failing-exec.apiKey: resolved_gateway
  unresolved: false

local-exec-and-gateway-dual-failure:
  markerRan: false
  talk.providers.missing-exec.apiKey: unresolved
  unresolved: true
  diagnostic: failed to resolve talk.providers.missing-exec.apiKey locally (Exec provider "failing" exited with code 7.)
  misleading rerun-with-allow-exec diagnostic: absent

Gateway secrets.resolve failures in log: 0
ALL SCENARIOS PASS

What this demonstrates:

Scenario Local exec Gateway Result
Exec-only Runs Not needed Path is resolved_local; no gateway error
Mixed exec + env Runs for exec path Resolves env path Split ownership is preserved
Local exec failure Fails before producing a value Recovers failed path Path is resolved_gateway; no stale failure diagnostic
Local exec + gateway dual failure Fails before producing a value Leaves path unresolved Path-specific exit-code diagnostic is retained

Tests

Focused suites after the exact-head rebase:

$ pnpm test src/cli/command-secret-gateway.test.ts \
  src/auto-reply/reply/agent-runner-utils.test.ts \
  src/auto-reply/reply/agent-runner-utils.secret-resolution.test.ts

Test Files  3 passed (3)
Tests       60 passed (60)

Changed-file quality gate:

$ OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 CI=1 \
  pnpm check:changed -- \
  src/cli/command-secret-gateway.ts \
  src/cli/command-secret-gateway.test.ts

exit 0

The gate includes production and test typechecks, changed-file lint, dependency/package guards, database-first guards, and runtime import-cycle checks.

Relationship to #96661

PR #96661 is a useful candidate for the same canonical issue and supplied earlier live proof for active exec detection. The permanent boundary differs:

Useful coverage retained or expanded here:

  • active exec refs execute locally
  • inactive exec refs do not affect unrelated active targets
  • callers that disallow local exec keep gateway-first behavior
  • mixed exec/non-exec targets preserve separate resolution owners
  • failed local exec falls back to gateway resolution
  • successful gateway recovery removes stale local-failure diagnostics
  • dual failure preserves the path-specific local exec failure
  • recursive gateway fallback does not claim exec was skipped when it was already attempted

The split boundary is narrower: it moves only configured active exec execution into the local reply process and does not move env or other gateway-resolvable credentials out of the gateway snapshot.

Security impact

  • no credential values are added to gateway RPC metadata
  • only active, command-scoped, allowed exec paths execute locally
  • non-exec credentials remain gateway-owned
  • failed local exec does not force degraded operation when the gateway can recover
  • no config schema or protocol changes

Compatibility

Backward compatible. Resolution outcomes remain the same for successful setups; the change removes avoidable gateway failures and preserves gateway resolution for mixed-source targets.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 11, 2026, 3:19 PM ET / 19:19 UTC.

Summary
The PR resolves active allowed exec-backed command SecretRefs locally per path, sends remaining paths through the gateway snapshot, and merges recovery states and diagnostics.

PR surface: Source +102, Tests +140. Total +242 across 2 files.

Reproducibility: yes. Current source establishes gateway-first handling followed by local fallback for active exec targets, and the contributor's real-gateway transcript demonstrates the corrected final-head paths.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #96653
Summary: This PR is the stronger candidate fix for the canonical issue; the other open PR targets the same root cause but chooses a broader ownership boundary.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Risk before merge

  • [P1] Two proof-positive open PRs implement different permanent ownership semantics for the same bug; maintainers should select one and avoid landing both.
  • [P1] The PR is behind current main, although no relevant resolver-file drift or merge conflict was found.

Maintainer options:

  1. Land the narrower resolver (recommended)
    Merge after the secrets-area owner confirms this per-path process boundary and exact-head checks remain green.
  2. Choose the alternative semantics
    Pause or close this PR if maintainers intentionally prefer the competing whole-target local-fallback boundary.

Next step before merge

  • The implementation appears merge-ready, but the credential execution boundary and competing canonical PR require explicit owner selection.

Maintainer decision needed

  • Question: Should active allowed exec SecretRefs resolve locally per path while every remaining path retains gateway snapshot ownership?
  • Rationale: This determines the permanent process boundary for credential resolution and differs materially from the competing PR's whole-target gateway skip.
  • Likely owner: openclaw/openclaw-secops — CODEOWNERS assigns the relevant secret-resolution and gateway secret-handler boundary to this team.
  • Options:

Security
Cleared: The final diff retains the existing caller allow-exec policy, limits local execution to active or unknown command-target paths, and adds no permissions, protocol, config, dependency, or credential-value exposure.

Review details

Best possible solution:

Use this per-path resolver so successful active exec paths resolve locally while mixed non-exec and failed paths remain gateway-owned, with one canonical implementation for the linked issue.

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

Yes. Current source establishes gateway-first handling followed by local fallback for active exec targets, and the contributor's real-gateway transcript demonstrates the corrected final-head paths.

Is this the best way to solve the issue?

Yes. Per-path splitting is narrower than the competing whole-target skip and preserves gateway ownership and recovery for mixed secret sources.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 03558dc00821.

Label changes

Label changes:

  • add merge-risk: 🚨 auth-provider: The patch changes which process resolves model and provider credentials and the ordering of fallback recovery.
  • add merge-risk: 🚨 security-boundary: The patch executes configured exec secret providers locally before the gateway handles the remaining credential paths.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR includes redacted final-head built-code output from a real temporary gateway and real exec child process covering local success, mixed ownership, gateway recovery, and dual failure.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR includes redacted final-head built-code output from a real temporary gateway and real exec child process covering local success, mixed ownership, gateway recovery, and dual failure.

Label justifications:

  • P2: The PR fixes recurring misleading credential-resolution failures and wasted gateway calls without a reported outage or data loss.
  • merge-risk: 🚨 auth-provider: The patch changes which process resolves model and provider credentials and the ordering of fallback recovery.
  • merge-risk: 🚨 security-boundary: The patch executes configured exec secret providers locally before the gateway handles the remaining credential paths.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR includes redacted final-head built-code output from a real temporary gateway and real exec child process covering local success, mixed ownership, gateway recovery, and dual failure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes redacted final-head built-code output from a real temporary gateway and real exec child process covering local success, mixed ownership, gateway recovery, and dual failure.
Evidence reviewed

PR surface:

Source +102, Tests +140. Total +242 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 102 0 +102
Tests 1 143 3 +140
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 245 3 +242

What I checked:

  • Current-main behavior: The current resolver classifies command targets but still reaches gateway resolution before using local fallback, producing the reported unnecessary gateway failure for active exec-backed targets. (src/cli/command-secret-gateway.ts:895, 03558dc00821)
  • Narrow per-path boundary: The proposed head selects only active-or-unknown exec-backed command paths for local resolution, removes successful paths, and recursively sends unresolved and non-exec paths through the gateway with local exec disabled. (src/cli/command-secret-gateway.ts:964, 02a66be2410c)
  • Previous findings resolved: The final head retains a local provider failure only when the merged state remains unresolved and suppresses misleading rerun advice after exec was already allowed and attempted. (src/cli/command-secret-gateway.ts:1004, 02a66be2410c)
  • Focused regression coverage: Tests cover exec-only resolution, local failure followed by gateway recovery, local-and-gateway dual failure, mixed exec and non-exec ownership, inactive targets, and callers that disallow local exec. (src/cli/command-secret-gateway.test.ts:621, 02a66be2410c)
  • Real behavior proof: The PR body reports final-head built-code runs using a real temporary gateway and real exec child process, covering local success, mixed sources, gateway recovery, and actionable dual failure without gateway failure log noise. (02a66be2410c)
  • Best-fix comparison: The competing PR skips gateway resolution for the target set when an active exec ref exists; this PR instead preserves gateway snapshot ownership for non-exec and locally failed paths, making it the narrower solution. (src/cli/command-secret-gateway.ts:971, 02a66be2410c)

Likely related people:

  • openclaw/openclaw-secops: CODEOWNERS assigns the secrets implementation and gateway secret-handler surfaces governing this credential execution boundary to this team. (role: adjacent owner; confidence: high; files: src/secrets/, src/gateway/server-methods/secrets.ts)
  • Josh Avant: Available history ties the broader runtime SecretRef coverage underlying this resolver to commit 806803b. (role: introduced behavior; confidence: medium; commits: 806803b7efe2; files: src/cli/command-secret-gateway.ts, src/secrets/command-config.ts)
  • Vincent Koc: The related feature history identifies recent work on the active gateway exec-ref detection that this PR extends to command-target paths. (role: recent adjacent contributor; confidence: medium; commits: 1ee2733b2f; files: src/cli/command-secret-gateway.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 (5 earlier review cycles)
  • reviewed 2026-07-11T05:45:08.331Z sha 0070779b2627e5617adb89c80ba858c06de2ed66 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T09:01:41.583Z sha 9bf6c24f8575c320ecf3c58da0f4342db56648bd :: needs changes before merge. :: [P2] Preserve the local exec failure when gateway recovery also fails
  • reviewed 2026-07-11T09:10:23.146Z sha 9bf6c24f8575c320ecf3c58da0f4342db56648bd :: needs changes before merge. :: [P2] Preserve the local exec failure when gateway recovery also fails
  • reviewed 2026-07-11T09:18:15.879Z sha 9bf6c24f8575c320ecf3c58da0f4342db56648bd :: needs changes before merge. :: [P2] Preserve the local exec failure when gateway recovery also fails
  • reviewed 2026-07-11T19:01:38.592Z sha 6d2f4ee19e9b4531148d77f03afb75f382414b2c :: needs maintainer review before merge. :: none

@arcabotai
arcabotai force-pushed the fix/exec-secretref-gateway-noise branch from 0070779 to 9bf6c24 Compare July 11, 2026 08:52
@arcabotai

Copy link
Copy Markdown
Contributor Author

Addressed the requested contributor actions:

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 11, 2026
@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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 11, 2026
@arcabotai
arcabotai force-pushed the fix/exec-secretref-gateway-noise branch from 9bf6c24 to 6d2f4ee Compare July 11, 2026 18:53
@arcabotai

Copy link
Copy Markdown
Contributor Author

Addressed the remaining diagnostic-reconciliation finding at 6d2f4ee19e9b.

  • local exec failures are retained only for exec paths still unresolved after gateway recovery
  • successful gateway recovery explicitly asserts that the stale local failure is absent
  • added a dual-failure regression covering the path-specific provider exit code
  • extended the built-code proof with a real gateway + child-process dual-failure scenario
  • 60/60 focused tests pass; check:changed passes

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(secrets): resolve active exec refs locally This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@arcabotai

Copy link
Copy Markdown
Contributor Author

Addressed the independent follow-up diagnostic review at 02a66be2410c.

The dual-failure path now emits exactly the actionable local provider failure plus final degraded/unresolved diagnostics. It suppresses the recursive skipped local exec ... rerun with --allow-exec advice because exec was already allowed and attempted.

Coverage now asserts one local failure, no skipped/rerun advice, and the exact diagnostic count. The built-code real-gateway proof confirms the cleaned output. 60/60 focused tests and check:changed pass.

@clawsweeper re-review

@arcabotai
arcabotai force-pushed the fix/exec-secretref-gateway-noise branch from 6d2f4ee to 02a66be Compare July 11, 2026 19:09
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 11, 2026
@steipete

Copy link
Copy Markdown
Contributor

Superseded by the landed current-main fix #105160 / 00cab8d42b8bd6da2c868180d429b39368edf31c.

The landed boundary keeps the prepared active runtime snapshot authoritative—including exec-backed values already materialized during runtime preparation—and returns partial assignments so the existing caller fills only genuinely unresolved paths locally. That removes the noisy Gateway failure without adding per-turn exec-provider execution or a second split-resolution lifecycle in the reply process. Focused Testbox proof covered exec materialization, incomplete snapshots, and mixed Gateway/local targets; #96653 is closed as fixed.

Thank you for the careful mixed-source and failure-path analysis here.

@steipete steipete closed this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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]: reply-path secrets.resolve floods gateway log with UNAVAILABLE for model-provider exec SecretRefs (degrades correctly, ~1 line/turn)

2 participants