Repository navigation
fix: OAuth catalog refresh fails with historical agent stores - #168957
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. What this changesThis PR routes historical OAuth peer fencing and settlement through the catalog worker’s existing native auth writer. Example: A Gateway refreshes xai:proof while a-historical contains a matching credential and b-empty has no auth row.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR fixes a current-main OAuth catalog failure and merits landing. The previous prerequisite finding is resolved, and no actionable correctness or security findings remain; required CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway model discovery runs provider catalogs in a worker; the auth-profile owner fences matching persisted credentials before token exchange and settles those credentials afterward. flowchart TD
A[Gateway models list] --> B[Catalog worker]
B --> C[OAuth refresh owner]
C --> D[Request native auth writer]
D --> E[Historical agent databases]
C --> F[Provider token exchange]
F --> C
C --> B
Technical reviewBest possible solution: Land the native-worker repair with the existing fencing, settlement, and persistence contracts intact once required gates pass. Do we have a high-confidence way to reproduce the issue? Current-main source routes catalog-worker peer updates into a host-only broker, matching the supplied baseline failures before token HTTP; no target code was executed during this read-only review. Is this the best way to solve the issue? The repair uses the worker’s already established native auth-write adapter and canonical transaction/save owners, addressing the execution-boundary defect without weakening peer fencing or changing authentication policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ec9db387c421. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +106, Tests +158, Docs +8, Other +1. Total +273 across 8 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 11, 2026, 3:18 AM ET / 07:18 UTC (Revision 2). |
Isolated bundled xAI Gateway traceObserved on macOS arm64 / Node 24.21.0 using this PR's runtime. All credentials were synthetic. An operator-configured CONNECT proxy terminated TLS with an ephemeral CA trusted only by the isolated process; it accepted only the two provider hosts and never forwarded external traffic. The starting credential expired at {"at":"2026-10-11T06:56:22.880Z","kind":"refresh","refreshCalls":1,"grant":"refresh_token","credential":"original-synthetic","held":true}
{"at":"2026-10-11T06:56:27.170Z","kind":"catalog","credential":"rotated-synthetic"}
{"at":"2026-10-11T06:56:28.840Z","kind":"catalog","credential":"rotated-synthetic"}The refresh endpoint was
The live driver's initial final assertion incorrectly expected rotated secret copies to remain in every local peer. Its exit status remains 1; inspection of the captured rows plus a separate read-only effective-auth check confirmed the intended removal/read-through contract. The OAuth request was not replayed merely to change that status. The permanent worker integration regression asserts the correct removal behavior. |
|
Fixed the missing runtime consumer registration in c37867c and added a runner-selection regression. The supported runner now passes the prerequisite checks and all three real Worker cases (8 tests). With the same built-runtime prerequisite on unmodified 390f0f0, all three fail before token HTTP with "Failed to fence every historical OAuth refresh peer. | Agent admission requires its host owner." The PR body now links the inspectable synthetic Gateway trace: #168957 (comment) . |
|
Landed as 43c68c3. Catalog-worker OAuth refresh now fences and settles historical peers through its request-owned native writer, retaining exact file identity and transactional generation checks. The runtime-prepared regressions reproduce the original failure and pass with the fix; isolated bundled xAI proof shows one refresh, fenced peers, rotated-bearer catalog publication, and correct settlement. Exact-head ClawSweeper was ready and all 84 CI jobs completed successfully. Thanks for reporting the catalog refresh failure. |
## What Problem This Solves Fixes OAuth model-catalog refresh failing before contacting the provider when other agent databases exist, including empty historical databases. ## User Impact Shared OAuth credentials can refresh during catalog discovery without requiring users to delete other agents or sign in again. Historical copies remain fenced during rotation and are settled afterward. No schema, stored format, or authentication-policy changes. ## Why This Change Was Made Historical-peer updates entered the host-only database executor from the catalog Worker. They now use that Worker's existing native auth-write scope, retaining the captured database path and file identity, existing-only opening, transactional credential comparisons, and committed publication. The same path handles fencing and settlement. Pre-request failures still roll claims back; failures after provider I/O remain terminal because a rotating token might already be consumed. No overlap with Pash/Sarah changes. ## Evidence - Three real catalog-Worker integration cases pass: shared OAuth with empty agent databases; an exact historical copy fenced during a held token exchange and removed after successful rotation; and rollback of earlier claims when a later peer already owns the generation. - All three fail against unmodified `origin/main` (`390f0f0acb98c577d5ccf71cd04201a6c4083c7b`) with the same built-runtime prerequisite: `Failed to fence every historical OAuth refresh peer. | Agent admission requires its host owner.` No refresh HTTP call is made. - The registered-runtime prerequisite and worker regression pass together (8 tests). The clean-shard prerequisite omission found by hosted CI is corrected and covered by the runner-selection test. - Existing candidate-store, peer-settlement, store-update, and catalog-retirement tests pass (31 tests across four files). - Isolated bundled xAI Gateway proof used only synthetic credentials and an operator-configured CONNECT/TLS stub with an ephemeral CA. Main, configured-peer, and historical-peer credentials were simultaneously pending-fenced during the held exchange. One refresh succeeded; both catalog requests used the rotated bearer; `models.list` published **Synthetic Grok catalog** with `xai:proof` marked `ready`. Historical rows were removed after settlement and an unrelated generation was unchanged. [Inspectable synthetic Gateway trace and settlement evidence](#168957 (comment)). - `pnpm build`, targeted Oxlint, the agents-root test typecheck, database-worker/dialect ratchets, line-cap/max-lines ratchets, assertion-safety, and `git diff --check` pass. The final Codex review reported no actionable defects. Merge danger: two-way door; reverting restores the old execution path without changing stored formats. Blast radius is refresh-managed OAuth used by catalog discovery, including shared credentials and historical agent copies. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 43c68c3)
Closes #169066 ## What Problem This Solves Fixes slow, misleading **Test connection** results that count model/credential preparation and internal agent-session work as provider latency. ## User Impact Connection checks make a fresh request without creating an agent session. Each credential shows a labeled **Request round-trip**; the ambiguous aggregate header timing is gone. Empty or thinking-only responses fail the format check, timeouts remain timeouts, and provider diagnostics remain useful and secret-redacted. ## Why This Change Was Made The original probe in [40181af](40181af) exercised a real provider request through an embedded agent. [#117494](#117494) added the structured internal session required by that runtime. Connectivity checks can now use the existing isolated-completion owner instead of paying for that agent-session lifecycle. The deliberately isolated, read-only direct-credential generation from [#125816](#125816) stays intact. Every credential still uses raw OpenClaw transport, preserving [#121500](#121500). OAuth refresh remains with its normal persistent owner, including the historical-peer fencing and settlement from [#168957](#168957); no new cooldown/quota writes are introduced. Known configured models no longer trigger unnecessary catalog preparation. Checked Sarah's [#159246](#159246): its Agents API restricted-session contract and runtime defaults are unchanged. No overlap with Pash's changes. ## Evidence - Command/target/resource regressions: **38 passed**. Includes direct and stored credentials, immutable API-key auth state, expired OAuth refreshing once into the real shared store with owner/peer fences and peer settlement, and valid OAuth causing no credential/state write. - Isolated-completion suite: **50 passed**; Gateway probe suite: **13 passed**. - Models view: **38 passed**; i18n verification passed; Models browser E2E: **7 passed**. - Discriminating negative control: removing the output/timeout/diagnostic fixes makes empty and thinking-only responses incorrectly report `ok`, aborted timeout output report `unknown`, and provider-detail assertions fail. - Mock-export gate passes after six justified isolation annotations and removal of six retired baseline entries. ### Paired timing comparison Real Gateway and Control UI button clicks against the same synthetic HTTP provider with a 250 ms response delay. Baseline `cbba7e2e2ef` versus candidate `994f04547a9`; five alternating measured samples per row, excluding one warmup per lane. These are local stub measurements, not live-provider speed claims. | Scenario | Median full probe RPC, before → after | Median displayed credential duration, before → request-only after | | --- | ---: | ---: | | Successful response | 2,103 → 738 ms | 1,532 → 256 ms | | HTTP 401 | 1,073 → 389 ms | 929 → 256 ms | The stub's median HTTP duration was 251–253 ms. Each success made one HTTP request; the old 401 path made two, while the new isolated check made one. Full probe time still includes setup; it is not shown as provider request time. ### Desktop Before — unlabeled aggregate and repeated credential timing:  After — labeled per-credential request timing, no aggregate header duration:  ### Mobile   ### CI context The initial CI run also hit the main-owned `eager-import-closure.test.ts` duplicate-inventory failure. The same three duplicate paths are demonstrated on clean main `44f538c1855d` in [the existing main reproduction](#169511 (comment)), and in [this PR's failing job](https://github.com/openclaw/openclaw/actions/runs/38198084932/job/114645376204). This PR does not modify that test, wrapper inventory, or those source files. Merge danger: two-way door. Reverting restores the old probe path without a schema or configuration migration. Blast radius is model connection diagnostics in the CLI and Control UI; ordinary chat and other runtime adapters are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
…aw#168957) ## What Problem This Solves Fixes OAuth model-catalog refresh failing before contacting the provider when other agent databases exist, including empty historical databases. ## User Impact Shared OAuth credentials can refresh during catalog discovery without requiring users to delete other agents or sign in again. Historical copies remain fenced during rotation and are settled afterward. No schema, stored format, or authentication-policy changes. ## Why This Change Was Made Historical-peer updates entered the host-only database executor from the catalog Worker. They now use that Worker's existing native auth-write scope, retaining the captured database path and file identity, existing-only opening, transactional credential comparisons, and committed publication. The same path handles fencing and settlement. Pre-request failures still roll claims back; failures after provider I/O remain terminal because a rotating token might already be consumed. No overlap with Pash/Sarah changes. ## Evidence - Three real catalog-Worker integration cases pass: shared OAuth with empty agent databases; an exact historical copy fenced during a held token exchange and removed after successful rotation; and rollback of earlier claims when a later peer already owns the generation. - All three fail against unmodified `origin/main` (`2903155d69a48f90d93cec74b83267cd145423b5`) with the same built-runtime prerequisite: `Failed to fence every historical OAuth refresh peer. | Agent admission requires its host owner.` No refresh HTTP call is made. - The registered-runtime prerequisite and worker regression pass together (8 tests). The clean-shard prerequisite omission found by hosted CI is corrected and covered by the runner-selection test. - Existing candidate-store, peer-settlement, store-update, and catalog-retirement tests pass (31 tests across four files). - Isolated bundled xAI Gateway proof used only synthetic credentials and an operator-configured CONNECT/TLS stub with an ephemeral CA. Main, configured-peer, and historical-peer credentials were simultaneously pending-fenced during the held exchange. One refresh succeeded; both catalog requests used the rotated bearer; `models.list` published **Synthetic Grok catalog** with `xai:proof` marked `ready`. Historical rows were removed after settlement and an unrelated generation was unchanged. [Inspectable synthetic Gateway trace and settlement evidence](openclaw#168957 (comment)). - `pnpm build`, targeted Oxlint, the agents-root test typecheck, database-worker/dialect ratchets, line-cap/max-lines ratchets, assertion-safety, and `git diff --check` pass. The final Codex review reported no actionable defects. Merge danger: two-way door; reverting restores the old execution path without changing stored formats. Blast radius is refresh-managed OAuth used by catalog discovery, including shared credentials and historical agent copies. Co-authored-by: Ayaan Zaidi <[email protected]>
…#169554) Closes openclaw#169066 ## What Problem This Solves Fixes slow, misleading **Test connection** results that count model/credential preparation and internal agent-session work as provider latency. ## User Impact Connection checks make a fresh request without creating an agent session. Each credential shows a labeled **Request round-trip**; the ambiguous aggregate header timing is gone. Empty or thinking-only responses fail the format check, timeouts remain timeouts, and provider diagnostics remain useful and secret-redacted. ## Why This Change Was Made The original probe in [5083dd5](openclaw@5083dd5) exercised a real provider request through an embedded agent. [openclaw#117494](openclaw#117494) added the structured internal session required by that runtime. Connectivity checks can now use the existing isolated-completion owner instead of paying for that agent-session lifecycle. The deliberately isolated, read-only direct-credential generation from [openclaw#125816](openclaw#125816) stays intact. Every credential still uses raw OpenClaw transport, preserving [openclaw#121500](openclaw#121500). OAuth refresh remains with its normal persistent owner, including the historical-peer fencing and settlement from [openclaw#168957](openclaw#168957); no new cooldown/quota writes are introduced. Known configured models no longer trigger unnecessary catalog preparation. Checked Sarah's [openclaw#159246](openclaw#159246): its Agents API restricted-session contract and runtime defaults are unchanged. No overlap with Pash's changes. ## Evidence - Command/target/resource regressions: **38 passed**. Includes direct and stored credentials, immutable API-key auth state, expired OAuth refreshing once into the real shared store with owner/peer fences and peer settlement, and valid OAuth causing no credential/state write. - Isolated-completion suite: **50 passed**; Gateway probe suite: **13 passed**. - Models view: **38 passed**; i18n verification passed; Models browser E2E: **7 passed**. - Discriminating negative control: removing the output/timeout/diagnostic fixes makes empty and thinking-only responses incorrectly report `ok`, aborted timeout output report `unknown`, and provider-detail assertions fail. - Mock-export gate passes after six justified isolation annotations and removal of six retired baseline entries. ### Paired timing comparison Real Gateway and Control UI button clicks against the same synthetic HTTP provider with a 250 ms response delay. Baseline `b372edb6424` versus candidate `994f04547a9`; five alternating measured samples per row, excluding one warmup per lane. These are local stub measurements, not live-provider speed claims. | Scenario | Median full probe RPC, before → after | Median displayed credential duration, before → request-only after | | --- | ---: | ---: | | Successful response | 2,103 → 738 ms | 1,532 → 256 ms | | HTTP 401 | 1,073 → 389 ms | 929 → 256 ms | The stub's median HTTP duration was 251–253 ms. Each success made one HTTP request; the old 401 path made two, while the new isolated check made one. Full probe time still includes setup; it is not shown as provider request time. ### Desktop Before — unlabeled aggregate and repeated credential timing:  After — labeled per-credential request timing, no aggregate header duration:  ### Mobile   ### CI context The initial CI run also hit the main-owned `eager-import-closure.test.ts` duplicate-inventory failure. The same three duplicate paths are demonstrated on clean main `1abe83478663` in [the existing main reproduction](openclaw#169511 (comment)), and in [this PR's failing job](https://github.com/openclaw/openclaw/actions/runs/38198084932/job/114645376204). This PR does not modify that test, wrapper inventory, or those source files. Merge danger: two-way door. Reverting restores the old probe path without a schema or configuration migration. Blast radius is model connection diagnostics in the CLI and Control UI; ordinary chat and other runtime adapters are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
…step 31 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
What Problem This Solves
Fixes OAuth model-catalog refresh failing before contacting the provider when other agent databases exist, including empty historical databases.
User Impact
Shared OAuth credentials can refresh during catalog discovery without requiring users to delete other agents or sign in again. Historical copies remain fenced during rotation and are settled afterward. No schema, stored format, or authentication-policy changes.
Why This Change Was Made
Historical-peer updates entered the host-only database executor from the catalog Worker. They now use that Worker's existing native auth-write scope, retaining the captured database path and file identity, existing-only opening, transactional credential comparisons, and committed publication. The same path handles fencing and settlement. Pre-request failures still roll claims back; failures after provider I/O remain terminal because a rotating token might already be consumed.
Evidence
origin/main(390f0f0acb98c577d5ccf71cd04201a6c4083c7b) with the same built-runtime prerequisite:Failed to fence every historical OAuth refresh peer. | Agent admission requires its host owner.No refresh HTTP call is made.models.listpublished Synthetic Grok catalog withxai:proofmarkedready. Historical rows were removed after settlement and an unrelated generation was unchanged.Inspectable synthetic Gateway trace and settlement evidence.
pnpm build, targeted Oxlint, the agents-root test typecheck, database-worker/dialect ratchets, line-cap/max-lines ratchets, assertion-safety, andgit diff --checkpass. The final Codex review reported no actionable defects.Merge danger: two-way door; reverting restores the old execution path without changing stored formats. Blast radius is refresh-managed OAuth used by catalog discovery, including shared credentials and historical agent copies.