Skip to content

fix(auth): honor shared-store ownership in temp-state exec and agent deletion - #130437

Merged
steipete merged 1 commit into
mainfrom
steipete/fu-auth
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fu-auth

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two ownership gaps recorded on #130264 after the shared-auth-store read-through fix landed:

  1. agent exec with temporary state dropped the original shared-store root, so temp-state runs could not read-through shared credentials — a temp exec silently lost model auth the normal runtime resolves.
  2. Agent deletion safety still treated the implicit legacy owner (agents/main) as an undeletable credential owner even after openclaw doctor --fix relocated credentials to the shared store — contradicting the documented contract that the agent is undeletable only until relocation.

Why This Change Was Made

  • Temp-state exec preserves the original shared root for credential read-through: portable static profiles only (per the copy-portability policy in docs/auth-credential-semantics.md), local precedence and cooldowns preserved, no inherited-secret copies into temp state.
  • Deletion safety now consults the same resolveSharedAuthStoreOwnership fact the runtime inheritance uses: legacy ownership keeps the protection; post-relocation the implicit main is deletable like any agent, and shared credentials provably survive its deletion. Explicitly bound inheritance owners (agents.defaults.authInheritance.agentId) remain protected regardless.

Both fixes reuse the landed ownership fact — no new probes, no fallback readers. Net-negative overall diff.

User Impact

Temporary-state execs resolve shared API keys like normal runs; after doctor's relocation, operators can delete the retired implicit main agent without a misleading "owns the shared auth store" refusal — and deletion can never orphan live credentials.

Evidence

Both regressions verified failing pre-fix (temp-state exec resolving a shared api_key profile; post-relocation main deletable / pre-relocation protected / credentials survive). 303 tests across 11 focused files green; pnpm check:changed green; Codex autoreview clean (0.97). Full validation report retained in the branch workspace.

Context: #130264

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 21:50
@steipete
steipete requested a review from a team as a code owner August 26, 2026 21:50
…deletion

Two follow-ups from #130264: agent exec temporary state now preserves the
original shared auth root, so temp-state runs read-through portable static
profiles (local precedence and cooldowns preserved, no inherited-secret
copies); and agent deletion safety consults resolveSharedAuthStoreOwnership,
so the implicit legacy main owner is protected only while the legacy store
owns credentials — post-relocation main is deletable and shared credentials
provably survive. Explicitly bound inheritance owners stay protected.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 6:11 PM ET / 22:11 UTC.

ClawSweeper review

What this changes

The PR lets temporary agent exec runs read portable static credentials from the operator’s shared store and permits deletion of the implicit legacy owner after credential relocation.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This maintainer-owned PR remains necessary: current main repoints temporary exec state before preserving the original shared-store root, while the branch adds the bounded read-through and aligns both deletion entry points with the ownership fact. No blocking correctness defect was found in the reviewed patch.

Priority: P1
Reviewed head: 8a8ea8dd6ab7bb9505664f7604d8d90dafcb7faf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a well-scoped owner-boundary repair with focused coverage; exact-head validation is the remaining practical confidence step.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the available evidence is focused source and regression coverage, not a retained live transcript.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the available evidence is focused source and regression coverage, not a retained live transcript.
Evidence reviewed 6 items Current-main temporary-state gap: Current main resolves the configured agent directory, then repoints temporary state before any original shared-state root is retained; its auth scope carries only the agent directory.
Branch auth owner-boundary repair: The branch captures the original state directory, loads only a state-DB shared store, filters it to portable static credentials, and merges it only inside the async-local execution scope.
Deletion behavior uses the canonical ownership fact: The shared helper permits deletion after relocation only when no explicit inheritance owner remains; both CLI and Gateway deletion paths call it.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw agent exec --help

Result: PASS (completed)

$ node scripts/run-node.mjs agent exec --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 100.78 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 13.7s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4221ms (slowest: built plugin control-plane loads 3446ms)
│
◇

OpenClaw 2026.8.1 (8a8ea8d) — All your chats, one OpenClaw.

Usage: openclaw agent exec [options] [message]

Run one isolated headless embedded agent turn

Options:
  --auth-env-only              Use provider credentials from environment variables only (default: false)
  --code-mode ‹mode›           Tool mode: direct | auto | code
  --config ‹path›              Run against this config file instead of the ambient config (pins a reproducible run)
  --cwd ‹dir›                  Set both the agent workspace and tool working directory
  --fallback ‹provider/model›  Add an ordered fallback model (repeatab
… output truncated …

Assertions:

  • PASS expect_output: --auth-env-only
  • PASS expect_output: --force

How this fits together

Temporary agent exec creates disposable run state but should retain the operator’s configured credential access. Agent deletion uses the same shared-store ownership state to decide whether removing an agent can affect credentials.

flowchart LR
  A[Operator configuration and shared state] --> B[Agent exec request]
  B --> C[Capture original credential-store root]
  C --> D[Bounded portable credential read-through]
  D --> E[Temporary agent run]
  A --> F[Agent deletion request]
  F --> G[Shared-store ownership decision]
  G --> H[Delete agent or return protection error]
Loading

Before merge

  • Resolve merge risk (P1) - This bug fix adds a judged production net delta of +60 lines to an auth-sensitive default path; the extra scoped-store logic is justified by the no-persistence and OAuth-owner boundaries, but exact-head regression checks should remain required.
  • Resolve merge risk (P1) - Merging changes which stored credentials a default temporary exec can select after relocation; the branch tests local precedence and --auth-env-only, but that upgrade-sensitive routing change warrants focused validation.
  • Complete next step (P2) - No mechanical repair is indicated; this protected maintainer-owned PR should follow normal exact-head validation and owner review.
Agent review details

Security

None.

PR surface

Source +60, Tests +213, Docs +2. Total +275 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 130 70 +60
Tests 4 419 206 +213
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 551 276 +275

Review metrics

Metric Value Why it matters
Production vs test LOC production +60, tests +213, docs +2 The production growth implements a bounded in-memory shared-store view and unified deletion predicate; the added regression coverage is proportionate to the auth and deletion states.

Stored data model

Persistent data-model change detected: serialized state: src/commands/agent-exec.auth.test.ts, serialized state: src/commands/agent-exec.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the exact-head auth boundary (recommended)
    Run the focused exec and deletion regressions on the exact head, including legacy and relocated shared-store ownership, before merging the credential-routing change.
  2. Pause if the ownership contract changes
    Pause this PR if maintainers intend temporary exec to inherit OAuth or to preserve implicit ownership after relocation, because either choice needs a different documented contract.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run the focused agent-exec auth and agent-deletion regression suites on the exact head; retain legacy, relocated, explicit-owner, local-precedence, and OAuth-exclusion coverage.

Technical review

Best possible solution:

Keep one scoped shared-store view for temporary execution and one ownership predicate for CLI and Gateway deletion, with regression coverage for legacy ownership, relocated ownership, explicit bindings, local precedence, and OAuth exclusion.

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

Yes—source-reproducible: current main changes the temporary state root before retaining it for auth, while its scoped auth mode contains no shared-store view. The branch’s focused tests encode the state-DB reproduction, though this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The patch reuses the established ownership fact, scopes static-profile read-through to the temporary operation, and keeps explicit inheritance protection intact rather than adding a persisted copy or fallback reader.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3fe6e5821ba7.

Labels

Label changes:

  • add P1: Current default temporary agent execution can lose otherwise available shared model authentication, interrupting a core agent workflow.
  • add merge-risk: 🚨 auth-provider: The PR changes stored-credential selection for temporary execution after shared-store relocation, an auth-routing surface existing operators can exercise.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the available evidence is focused source and regression coverage, not a retained live transcript.

Label justifications:

  • P1: Current default temporary agent execution can lose otherwise available shared model authentication, interrupting a core agent workflow.
  • merge-risk: 🚨 auth-provider: The PR changes stored-credential selection for temporary execution after shared-store relocation, an auth-routing surface existing operators can exercise.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the available evidence is focused source and regression coverage, not a retained live transcript.

Evidence

What I checked:

  • Current-main temporary-state gap: Current main resolves the configured agent directory, then repoints temporary state before any original shared-state root is retained; its auth scope carries only the agent directory. (src/commands/agent-exec.ts:654, 3fe6e5821ba7)
  • Branch auth owner-boundary repair: The branch captures the original state directory, loads only a state-DB shared store, filters it to portable static credentials, and merges it only inside the async-local execution scope. (src/agents/auth-profiles/store.ts:122, 8a8ea8dd6ab7)
  • Deletion behavior uses the canonical ownership fact: The shared helper permits deletion after relocation only when no explicit inheritance owner remains; both CLI and Gateway deletion paths call it. (src/agents/agent-delete-safety.ts:30, 8a8ea8dd6ab7)
  • Focused regression coverage: The new execution test covers shared API-key and token read-through, local precedence, excluded OAuth, preserved cooldown/order state, no persistence into temporary state, and unreadable-store failure; CLI and Gateway deletion tests cover legacy, relocated, and explicit-owner cases. (src/commands/agent-exec.auth.test.ts:115, 8a8ea8dd6ab7)
  • Feature-history provenance: Shared-auth relocation and the explicit ownership seam both date to Peter Steinberger’s merged feature work, making the current owner routing clear. (src/agents/auth-profiles/path-resolve.ts:48, d2dad76ecde4)
  • Release and current-main check: The PR head is open and absent from current main; the checked release tag does not contain the branch head, so this is not implemented or shipped work. (8a8ea8dd6ab7)

Likely related people:

  • steipete: Peter Steinberger authored the shared-store relocation and explicit ownership seam, and current-main blame on the ownership resolver traces to that work. (role: shared-auth feature owner and recent area contributor; confidence: high; commits: d2dad76ecde4, 63b18e6e5f49, 057d1943728f; files: src/agents/auth-profiles/path-resolve.ts, src/agents/auth-profiles/store.ts, src/agents/agent-delete-safety.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run the focused temporary-exec auth and agent-deletion regressions on the exact head before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

@steipete
steipete merged commit 7d008a8 into main Aug 26, 2026
209 checks passed
@steipete
steipete deleted the steipete/fu-auth branch August 26, 2026 23:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (26 commits)
  fix(plugins): preserve registry epoch on activation rollback (#129232)
  refactor(plugins): make discovery invocation-owned (#130486)
  feat(ui): save appearance preferences per user profile (#130340)
  fix: Buzz bots recover relay stalls and reject revoked senders (#130467)
  fix(code-mode): serialize catalog handles nested in final values (#130276)
  fix(webchat): CLI skill and harness-injected turns render as operator-sent messages (#130427)
  fix(agents): read the published model catalog owner from session_status (#130277)
  fix(channels): preserve long presentation text (#130368)
  fix(agents): route CLI bootstrap truncation notice into the system prompt (#130325)
  refactor(plugins): unify setup registration and artifact selection (#130474)
  fix(memory): prevent forgotten session content from returning (#130451)
  refactor(outbound): consolidate transport completion (#130460)
  fix(workers): protect in-flight workspace manifests from concurrent retention (#130449)
  fix(portals): keep worker previews reachable and owned by the active environment (#130434)
  fix(config): keep core channels keys in the generated config schema (#120736)
  chore(deps): refresh dependencies after seven-day cooldown (#130296)
  fix(agents): remind exec models to quote shell metacharacters (#125485)
  fix(auth): honor shared-store ownership in temp-state exec and agent deletion (#130437)
  fix(openshell): preserve file writes during concurrent mirror commands (#130447)
  fix(workers): report full nodes as at capacity, not offline (#130445)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…deletion (openclaw#130437)

Two follow-ups from openclaw#130264: agent exec temporary state now preserves the
original shared auth root, so temp-state runs read-through portable static
profiles (local precedence and cooldowns preserved, no inherited-secret
copies); and agent deletion safety consults resolveSharedAuthStoreOwnership,
so the implicit legacy main owner is protected only while the legacy store
owns credentials — post-relocation main is deletable and shared credentials
provably survive. Explicitly bound inheritance owners stay protected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

1 participant