Skip to content

fix(gateway): refresh model availability after OAuth renewal - #102289

Merged
fuller-stack-dev merged 1 commit into
mainfrom
codex/fix-model-list-stale-auth
Jul 8, 2026
Merged

fuller-stack-dev merged 1 commit into
mainfrom
codex/fix-model-list-stale-auth

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Summary

  • Read persisted auth profiles when computing gateway model availability so OAuth refreshes performed by another CLI process are visible without restarting the gateway.
  • Keep model browsing read-only and preserve process-local auth snapshots for prepared agent execution.
  • Add regression coverage for a fresh persisted OAuth credential paired with a stale runtime snapshot.

Verification

  • node scripts/run-vitest.mjs src/gateway/server-methods/models.test.ts --reporter=verbose
  • node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat-b.test.ts -t "chat.metadata coalesces configured models and text commands" --reporter=verbose
  • node_modules/.bin/oxfmt --write src/gateway/server-methods/models-list-result.ts src/gateway/server-methods/models.test.ts
  • git diff --check
  • AWS Crabbox pnpm check:changed --base b81666ca6af25c86cc099983a4358cdc5ea9ced8
    • lease: cbx_1f05b0e6e357
    • run: run_8d4a5fccd4f6
  • Codex autoreview: clean, no accepted/actionable findings

Real behavior proof

Behavior addressed: Control UI model rows remain unavailable after OAuth is refreshed by a separate CLI process because chat.metadata reads a stale gateway runtime snapshot.

Real environment tested: macOS source checkout for focused Gateway RPC tests and AWS Linux Crabbox for the exact-base changed gate.

Exact steps or command run after this patch: Ran the focused models.list regression suite, the real chat.metadata Gateway RPC test, and exact-base pnpm check:changed.

Evidence after fix: The regression stores fresh OAuth in SQLite, installs an expired process-local snapshot, and receives available: true; the chat.metadata RPC test also passes.

Observed result after fix: Model availability follows the refreshed persisted credential without mutating or refreshing the gateway execution snapshot.

What was not tested: A live xAI OAuth refresh against a packaged patched gateway; the provider-independent stale-snapshot contract and the Control UI metadata RPC path were exercised directly.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Jul 8, 2026
@clawsweeper

clawsweeper Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 8, 2026, 4:42 PM ET / 20:42 UTC.

Summary
The branch changes Gateway model availability browsing to load persisted auth profiles instead of a process-local runtime snapshot and adds stale OAuth snapshot regression coverage.

PR surface: Source 0, Tests +71. Total +71 across 2 files.

Reproducibility: yes. from source inspection and the added regression shape: current main can consult a stale runtime auth snapshot before persisted auth, while the PR test models fresh persisted OAuth plus an expired runtime snapshot. I did not run the tests in this read-only review.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/gateway/server-methods/models.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Next step before merge

  • [P2] No repair job is needed; this active maintainer-labeled PR has no blocking findings from the read-only review.

Security
Cleared: The diff only changes a read-only auth-store selection and regression tests; it adds no dependency, workflow, secret-writing, or new credential exposure path.

Review details

Best possible solution:

Land the narrow persisted-auth read for Gateway browse/metadata availability while keeping prepared execution on the existing runtime auth snapshot path.

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

Yes, from source inspection and the added regression shape: current main can consult a stale runtime auth snapshot before persisted auth, while the PR test models fresh persisted OAuth plus an expired runtime snapshot. I did not run the tests in this read-only review.

Is this the best way to solve the issue?

Yes. The fix is at the narrow browse/metadata availability boundary, uses the existing persisted read-only auth-store helper, and avoids changing the runtime execution auth snapshot path.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: The PR fixes a limited gateway model-availability bug after OAuth renewal without changing config, migrations, provider credentials, or public API surface.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: The PR fixes a limited gateway model-availability bug after OAuth renewal without changing config, migrations, provider credentials, or public API surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
Evidence reviewed

PR surface:

Source 0, Tests +71. Total +71 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 4 0
Tests 1 83 12 +71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 87 16 +71

What I checked:

  • PR diff changes the browse-only auth store source: The PR switches createModelsListProviderAuthChecker from ensureAuthProfileStoreWithoutExternalProfiles to loadAuthProfileStoreWithoutExternalProfiles, keeping allowKeychainPrompt: false and adding a comment that model browsing should read persisted SQLite after out-of-process OAuth refreshes. (src/gateway/server-methods/models-list-result.ts:173, a3af0ff64003)
  • Current main uses runtime snapshots before persisted fallback: On current main, ensureAuthProfileStoreWithoutExternalProfiles checks resolveRuntimeAuthProfileStore first and returns a store built from that snapshot when present, which explains why a stale process-local snapshot can shadow refreshed persisted auth. (src/agents/auth-profiles/store.ts:922, b81666ca6af2)
  • Persisted loader is read-only and bypasses runtime snapshots: loadAuthProfileStoreWithoutExternalProfiles constructs read-only load options, reads persisted per-agent and main stores, strips runtime external metadata, and does not consult resolveRuntimeAuthProfileStore. (src/agents/auth-profiles/store.ts:856, b81666ca6af2)
  • Gateway metadata path reaches the changed model-list builder: chat.metadata builds its model payload through buildModelsListResult({ view: "configured" }), so the changed availability check affects the Control UI metadata path named in the PR body. (src/gateway/server-methods/chat.ts:444, b81666ca6af2)
  • Regression coverage targets the stale snapshot case: The PR adds a models.list test that writes fresh persisted OAuth, installs an expired runtime auth snapshot, and expects the model row to return available: true. (src/gateway/server-methods/models.test.ts:541, a3af0ff64003)
  • History ties the current implementation to recent gateway/auth refactor work: Blame shows the current createModelsListProviderAuthChecker and auth-store helper lines came through commit 6765eb0166fc2607203caf8ca3b96824b1352e10, associated with refactor(memory-core): localize internal declarations #101969. (src/gateway/server-methods/models-list-result.ts:167, 6765eb0166fc)

Likely related people:

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.

@fuller-stack-dev fuller-stack-dev self-assigned this Jul 8, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 5b52e24 into main Jul 8, 2026
120 of 124 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the codex/fix-model-list-stale-auth branch July 8, 2026 20:45
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant