Skip to content

fix: avoid partial API-key saves during credential publication - #176166

Merged
steipete merged 2 commits into
mainfrom
fix/models-api-key-authority
Oct 18, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/models-api-key-authority

Conversation

@steipete

@steipete steipete commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a partial API-key save in Models and the CLI when an in-flight credential catalog publication overlaps application of the provider settings.

User Impact

A save waits for known credential publication before applying the provider binding. Unknown outcomes, retired owners, revoked callers, and competing agent overrides still refuse the operation. Genuine configuration failures retain the existing partial-save diagnostic.

Why This Change Was Made

The config transformer previously treated a pending publication as unavailable authority after the key had been persisted. The existing credential owner now supplies settlement waiting and wakes readers during publication, revocation, and state-owner closure. Synchronous reads keep their refusal checks; this does not retry a credential write or provide cross-store atomicity.

PR CI also caught a sibling fixture that stored the new async mutator's Promise as a config object. Production updateConfig already awaits async mutators. The follow-up makes the mock match that contract, preserves the requested-agent assertion, and strengthens the real-store test to verify its provider/mode binding. No additional production change was needed.

Evidence

  • A real credential batch held during config transformation reproduced the partial-save error before the production fix. Regressions cover settled publication, unknown outcome, closure, and a competing override.
  • All 114 test files in src/commands/models and src/agents/auth-profiles passed: 1,089 tests with --maxWorkers=1 (78 in the two changed files, then 1,011 in the remaining files). The requested-agent regression reproduced before the fixture fix and passes afterward, with the real-store binding assertion included.
  • Production and affected test typechecks, targeted lint, formatting, and P2 autoreview completed with no accepted actionable findings. The follow-up has only test changes.
  • Native real-Gateway Models/CLI E2E passed on production commit 38ede6108351 (1/1), including durable-state parity. Production/private-QA builds and CLI-bootstrap validation passed. That proof is unchanged by the test-only follow-up.

The exact trigger of hourly 39112003675 remains unproven: ten baseline native repetitions passed on macOS/Node 26.12.0; CI used Node 24. The first patched native attempt hit the intended dirty-checkout artifact-publication refusal before its CLI request; canonical clean-commit preparation allowed the full native test to pass. No guard was bypassed. The optional max-lines ratchet reports existing suppressions in three unchanged UI files; this patch adds none. No CI reruns.

Join pending credential catalog publications before applying the saved
key's provider binding. Keep synchronous authority checks and refuse
unknown outcomes, retired owners, and competing agent overrides.
Wake retained readers on publication settlement and owner closure,
including worker-only state owners without native-handle events.

A real batch held during config transformation reproduced the partial-save
error from main hourly 39112003675. Exact hourly attribution remains
unproven; ten native baseline repetitions passed locally.
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T09:36:37.749648Z 38ede61 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: S labels Oct 18, 2026
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 6f6311035c3ca9ea89cc7fbf4aa8d55ac0227509
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/candidate-stores.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

API-key saves wait for credential publication to settle before applying provider settings.

Example: Saving sample:manual while a credential catalog publication overlaps configuration preparation.

  • Before: The key persists, but applying its provider binding reports a partial-save error.
  • After: The save waits for settlement and applies the binding, while unknown outcomes and competing overrides still refuse it.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch resolves the previous finding and has meaningful owner-boundary coverage; directly inspectable overlap proof remains at the in-process harness level.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; inspected production-owner harnesses cover allowed settlement and refusal before persisted configuration changes for competing overrides, owner closure, unknown outcomes, and revoked callers.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Saving an API key can persist the secret but fail to apply its provider settings when credential publication overlaps the save.
Reason: The maintainer-authored repair restores shared Models/CLI behavior with a focused change and preserves existing refusal boundaries.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current credential-save failure, and the follow-up resolves the previous fixture finding; no actionable defects remain in the reviewed diff.

Priority: P2
Reviewed head: 6f6311035c3ca9ea89cc7fbf4aa8d55ac0227509

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The reported native Gateway save/remove run does not demonstrate injected publication overlap; that scenario is covered by the real-owner command harness.
Agent review details

How this fits together

Models and CLI saves share a credential writer and configuration transformer; the credential authority owner supplies current store facts before provider bindings change.

flowchart TD
  A[Models or CLI save] --> B[Shared API key owner]
  B --> C[Credential store write]
  B --> D[Credential authority owner]
  E[Catalog publication] --> D
  D --> F[Configuration transformer]
  F --> G[Provider binding]
Loading

Technical review

Best possible solution:

Keep settlement waiting in the existing credential authority owner and retain the corrected asynchronous CLI fixture.

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

Current-main source exposes the failing ordering, and the supplied command-boundary regression holds a real publication during configuration transformation; no target code was executed during this review.

Is this the best way to solve the issue?

The patch restores the existing save contract through its current owner without retrying credential writes, adding storage, or weakening synchronous authority checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 066c207b69e8.

Provenance checked

  • Credential publication authority keeps the original intent (5822af6: Deny credential use during publication and install committed facts before releasing denial.)
  • Candidate credential preparation keeps the original intent (0636e55: Use engine-aware retained authority for later credential validation without Gateway main-thread database reads.)
  • Shared Models and CLI persistence keeps the original intent (09e2b15: Share key persistence while preserving provider selections, external references, and agent-local overrides.)
  • Configuration application receipt keeps the original intent (4a54a57: Wait for provider settings to reach the Gateway and retain warnings when application is unconfirmed.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0636e55 adds src/commands/models/auth-api-key.ts:134 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0636e5523960; files: src/commands/models/auth-api-key.ts)
  • Ayaan Zaidi: Raw commit 09e2b15 adds src/commands/models/auth-api-key.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 09e2b15466e1; files: src/commands/models/auth-api-key.ts)

PR surface

Source +54, Tests +66. Total +120 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 69 15 +54
Tests 2 68 2 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 137 17 +120

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The repair addresses a bounded publication overlap that leaves an API key saved without its provider settings applied.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-18T09:48:07.917Z sha 38ede61 :: needs changes before merge. :: [P2] Await async config mutators in the sibling CLI fixture

Reviewed October 18, 2026, 5:58 AM ET / 09:58 UTC (Revision 2).

Match the production updateConfig contract in the auth command fixture:
await the mutator before recording and committing its configuration.
The settlement wait made the API-key mutator asynchronous, exposing the
mock's stored Promise as a missing requested-agent profile binding.

Keep the existing requested-agent assertions and additionally verify the
provider/mode binding through the real persisted-store test matrix.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@steipete
steipete merged commit c3af75f into main Oct 18, 2026
141 of 144 checks passed
@steipete
steipete deleted the fix/models-api-key-authority branch October 18, 2026 10:07
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…law#176166)

* fix(models): wait for credential publication before applying API keys

Join pending credential catalog publications before applying the saved
key's provider binding. Keep synchronous authority checks and refuse
unknown outcomes, retired owners, and competing agent overrides.
Wake retained readers on publication settlement and owner closure,
including worker-only state owners without native-handle events.

A real batch held during config transformation reproduced the partial-save
error from main hourly 39112003675. Exact hourly attribution remains
unproven; ten native baseline repetitions passed locally.

* test(models): await async auth configuration mutations

Match the production updateConfig contract in the auth command fixture:
await the mutator before recording and committing its configuration.
The settlement wait made the API-key mutator asynchronous, exposing the
mock's stored Promise as a missing requested-agent profile binding.

Keep the existing requested-agent assertions and additionally verify the
provider/mode binding through the real persisted-store test matrix.
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: S 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