Skip to content

fix: refresh model availability after stored-account quota recovery - #146691

Merged
steipete merged 2 commits into
mainfrom
codex/fix-catalog-usage-refresh
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-catalog-usage-refresh

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #146662

Related: #146587

What Problem This Solves

Fixes models remaining unavailable after a successful turn clears a stored-profile quota block, leaving the Control UI showing Signed in instead of Ready.

User Impact

Catalog and chat metadata reflect added, cleared, and reapplied stored-profile blocks without restarting or repeating provider discovery. Credential ownership and selection rules are preserved; no configuration or storage migration is required.

The next required chat metadata read after a usage update rebuilds its prepared generation. Synthetic measurements put that read at approximately 2 ms for one model, 18 ms for 32, 162 ms for 293, and 115 ms for eight agents with 32 models each. Stable reads remain close to baseline.

Config-only inline API-key health retains its existing freshness behavior. It has no stored-profile identity and is outside this repair's scope.

Why This Change Was Made

Retained catalogs paired current discovery with an older usage snapshot. Their existing auth owner now reads current usage from captured, still-owned stores with matching credentials. Copies retain that binding; retired owners and delayed workers cannot acquire replacement authority.

Chat metadata checks requested and inherited usage revisions before reuse and after asynchronous projection. Optional startup reads remain nonblocking while required reads perform the existing refresh.

Storage compatibility is unchanged: AuthProfileStore, persisted serialization, usage writers, SQLite schemas, and migrations are untouched. The reader only projects existing usageStats from published process snapshots; its binding remains in a private WeakMap and is never serialized. The native state-schema check and worker credential/SecretRef preservation cases pass.

Evidence

  • 102 distinct focused tests passed on the original nine-file repair. The worker regression fails on baseline stale availability and passes with the repair through the actual Gateway model-list result. Coverage includes block → clear → reblock, delayed workers, stable discovery, credential identity, SecretRefs, inherited/local precedence, owner retirement, and projection success/error races.
  • Both unchanged Linux real-Gateway browser cases passed on that nine-file candidate: automatic quota recovery and explicit saved-usage clearing. The browser returns to Ready, the CLI reports usable credentials, and the cleared block stays absent.
  • Actual prepared-owner/materialization and chat-projection measurements passed 72 cells across three alternating process pairs with complete-output parity and zero thinking-policy fallback. Stable reads rebuild nothing. Usage updates rebuild one projection per prepared agent.
  • Subsequent line-limit repairs extract an unchanged test fixture and share an equivalent generation predicate. Their incremental P2 review is scoped-clean with no findings, confidence 0.98. The original production review reported the inline-key limitation above; source inspection established it predates this repair, and the lead rejected expanding credential ownership without a separate identity contract. That original review remains recorded as findings.
  • Final ten-file candidate: all 79 affected chat/worker tests passed again, along with core production types, all 18 test-type graphs, targeted lint, formatting, and the remaining repository guards. Production unused-export scanning passed. The complete selected check still reports two unchanged tooling exports (canonicalProviderName and listPackagedStaticExtensionAssetOutputs); neither is changed by this PR. Initial hosted CI also hit an unrelated main import error, now fixed by fix: avoid channel discovery when plugins are disabled #146689. Fresh exact-head CI passes for the eleven-file head f59bd34c77e099cbd2e84fa76f8ae8d1f91695ef, including the required gate.
  • Hosted CI exposed an incomplete startup-static test mock. A three-line fixture update preserves its no-published-owner behavior; all 12 startup cases then pass on Linux, with targeted lint, test types, formatting, and independent P2 review also passing. Windows reaches a separate fixture path mismatch in six cases, so Linux supplies that suite's execution proof.
Measurement scope and proof attribution

Last-used publication followed by a required metadata read, baseline → candidate median milliseconds:

Prepared models Baseline Candidate
1 agent × 1 0.092 1.970
1 agent × 32 1.703 18.288
1 agent × 293 17.800 162.333
8 agents × 32 1.721 115.108

These are correctness costs, not a performance-improvement claim. Measurements use synthetic providers and built-in commands, excluding installed skill/plugin commands, network, and durable storage I/O. Earlier three-second diagnostics omitted production-prepared thinking policy and are not valid production latency evidence.

Linux proof uses Node 24.19.0 on Ubuntu 26.04; hosted CI uses Ubuntu 24.04. Windows Chromium launch was unavailable. The clean-only prebuilt configuration refused the dirty checkout; the ordinary local configuration ran the original cases unchanged. Browser and cost evidence precede the equivalent predicate extraction and named helper relocation; neither was remeasured after those mechanical changes or the subsequent startup-mock correction.

@clawsweeper

clawsweeper Bot commented Sep 13, 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.

@steipete
steipete marked this pull request as ready for review September 13, 2026 03:20
@steipete
steipete requested a review from a team as a code owner September 13, 2026 03:20
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 12:00 AM ET / 04:00 UTC (Revision 3).

ClawSweeper review

What this changes

Refreshes stored-account model availability in retained catalogs and chat metadata after quota blocks change, while preserving prepared credentials and provider discovery.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open as a useful fix for the linked quota-recovery issue. The previous mock-export finding is resolved, no remaining actionable defect was found, and current main still lacks this repair.

Priority: P2
Reviewed head: f59bd34c77e099cbd2e84fa76f8ae8d1f91695ef

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with useful regression coverage, disclosed runtime observations, and the previous blocker resolved.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the contributor proof gate. Its body reports real-Gateway Linux recovery through the changed catalog projection, returning Ready with the block cleared; the final commit only repairs the test mock.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the contributor proof gate. Its body reports real-Gateway Linux recovery through the changed catalog projection, returning Ready with the block cleared; the final commit only repairs the test mock.
Evidence reviewed 9 items Previous finding resolved: The only change since the previously reviewed head adds the typed identity usage-reader factory to the startup-static module mock. This directly addresses the retained P2 finding and rank-up move; the discussion reports all 12 startup cases passing on Linux.
Usage refresh preserves credential ownership: The reader captures published store owners, rejects missing or rebound owners, compares credential descriptors, and copies only changed usage statistics. Catalog access additionally fences the reader with the existing generation-liveness predicate.
Metadata freshness and asynchronous settlement: Required reads compare requested and inherited store revisions before reuse and after asynchronous projection; optional startup reads omit stale projections without starting preparation. Regression cases cover both obsolete successful and failed projections.
Findings None None.
Security None None.

How this fits together

OpenClaw’s prepared model catalog combines discovered models with account readiness. The Gateway projects those facts into model lists and chat metadata consumed by the Control UI.

flowchart TD
  A[Stored-account usage updates] --> B[Published auth snapshots]
  B --> C[Matching credential and owner check]
  D[Retained model catalog] --> C
  C --> E[Current availability projection]
  E --> F[Gateway model lists]
  E --> G[Chat metadata and Control UI]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +108, Tests +354. Total +462 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 129 21 +108
Tests 6 442 88 +354
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 571 109 +462

Review metrics

Metric Value Why it matters
Production versus regression coverage production +108 lines; tests and test support +354 lines Production growth adds the bounded usage binding and freshness checks; coverage exercises retained catalogs, ownership, and projection races.
Reported required-read cost 293 models: 17.8 → 162.3 ms after a usage publication The disclosed synthetic measurement quantifies the cost of rebuilding previously stale metadata; stable reads rebuild nothing.

Stored data model

Persistent data-model change detected: serialized state: src/agents/auth-profiles/runtime-snapshots.ts, unknown-data-model-change: src/agents/auth-profiles/runtime-snapshots.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146662
Summary: This PR is the explicit candidate repair for the open stored-account quota-recovery issue.

Members:

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

Technical review

Best possible solution:

Keep availability current through the existing snapshot and metadata owners without rotating credentials, repeating discovery, or changing stored state.

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

Yes: retained full-catalog auth and unchecked usage revisions explain stale availability on current main, and the existing quota-reset browser case supplies a concrete reproduction path. This review did not execute it.

Is this the best way to solve the issue?

Yes: refreshing usage at the existing owner boundary repairs the reported behavior while retaining credential identity, selection policy, and discovery results.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs stale stored-account readiness after quota recovery without evidence of a broader runtime outage.
  • 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: The maintainer-authored PR is exempt from the contributor proof gate. Its body reports real-Gateway Linux recovery through the changed catalog projection, returning Ready with the block cleared; the final commit only repairs the test mock.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-13T03:27:51.764Z sha 8ebaca3 :: blocked before merge. :: none
  • reviewed 2026-09-13T03:43:49.598Z sha 8ebaca3 :: blocked before merge. :: [P2] Include the usage-reader export in the startup-static test mock

@steipete

steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor Author

The data-model compatibility check is satisfied without a migration: this patch changes transient catalog projections, not persisted state.

  • AuthProfileStore, persisted auth serialization, usage writers, SQLite schemas, and state migrations are unchanged from the base. The native state-schema check passes.
  • The usage reader reads already-published process snapshots and returns the same store or a copy with existing usageStats fields refreshed. It performs no storage writes.
  • The reader binding lives in the existing private WeakMap and is not serialized into catalog, worker, or on-disk data. Worker integration tests preserve credential descriptors, resolved SecretRefs, labels, and ownership while clearing and reapplying usage blocks.

There is no new persisted format for an older or upgraded process to interpret. I have added this compatibility evidence to the PR description. The separate startup mock completeness fix passes all 12 cases on Linux. The shared main typecheck repair landed through #146689, and fresh exact-head CI is running. The current ClawSweeper review reports no remaining actionable code defect; its repeated compatibility checklist is covered by these unchanged-format checks, so no migration is applicable.

@clawsweeper clawsweeper Bot added 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. and removed 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 Sep 13, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The shared TS6133 compile blocker is repaired on main by #146689 at 4c47e8a06e57, with exact-head CI green. #146698 was the identical one-line import cleanup and is now closed as already fixed; its public re-export is preserved.

This PR can now refresh against repaired main. Our CI optimization PR #146550 observes the same automatic-recovery Signed in / Ready failure and is retaining your runtime repair as the canonical fix rather than creating another implementation.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The current head adds only the missing startup-static mock export. All 12 startup cases pass on Linux, and targeted lint, test types, formatting, and fresh independent P2 review pass. The production repair is unchanged.

The prior data-model compatibility request is addressed in the PR body and the existing compatibility comment: persisted types, serialization, usage writers, schemas, and migrations are unchanged; the reader and its WeakMap binding operate only on published process snapshots. The unrelated main import failure is fixed by #146689. Fresh exact-head CI is running.

@clawsweeper

clawsweeper Bot commented Sep 13, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed 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. labels Sep 13, 2026
@steipete
steipete merged commit a13a010 into main Sep 13, 2026
198 of 199 checks passed
@steipete
steipete deleted the codex/fix-catalog-usage-refresh branch September 13, 2026 04:07
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

Stored-account model availability stays stale after quota recovery in a running Gateway

1 participant