Skip to content

fix(usage): keep healthy provider usage after auth failures - #124367

Merged
steipete merged 2 commits into
mainfrom
fix/autoqa-refill-usage-fanout-outcomes-v2
Aug 16, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/autoqa-refill-usage-fanout-outcomes-v2

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where one provider usage auth hook rejecting could make the entire provider-usage request fail, hiding otherwise healthy provider quota snapshots.

Why This Change Was Made

Provider auth is still resolved in the existing deterministic descriptor order, but resolveProviderAuths now lets the summary owner receive a provider-scoped error. loadProviderUsageSummary converts only those opted-in errors into the same snapshot shape already used for fetch failures and timeouts, then restores descriptor order across healthy and failed results. Direct resolveProviderAuths callers that do not supply the error owner still receive the exact original rejection object.

This leaves the #124131 cache boundary intact: the exact OpenClawConfig object remains the cache/dedupe identity and is passed unchanged into loadProviderUsageSummary. There is no provider auth, routing, config, default, billing, protocol, or schema contract change.

User Impact

Usage/status surfaces now keep healthy providers visible when a sibling provider's auth resolver fails. The failed provider appears with its existing error snapshot instead of blocking the whole response.

No changelog entry: this is a narrow internal reliability repair with no new user-facing surface.

Evidence

  • Rebased without patch drift onto the approved immutable base 2585edba2efda9ff50e6bed0a6de8cfaef8254fc; production +89/-78, net +11. Tests/test support +54/-0.
  • The requested provider-usage sweep now enumerates 208 tests in the rebased source (79 fast + 129 infra); all passed with the exact candidate files over hosted main on Blacksmith Testbox tbx_01m045cxt2tcf1cb9qmmw5at87, run 31921321514.
  • Full build passed on the same candidate-file Testbox overlay, including runtime postbuild, all 145 public Plugin SDK subpaths, Control UI build, and build stamps. Exact-head hosted CI remains the merge authority.
  • Built Gateway + built CLI loopback passed with ordered providers success → HTTP 503 → timeout → auth failure, exact endpoint requests 1/1/1/0, a live late timeout socket at result time, and verified Gateway listener plus isolated-state cleanup.
  • Core production types, all core test-type shards, changed-file oxfmt/oxlint, coercion-helper guard, and import-cycle check passed; git diff --check is clean.
  • The exact local changed gate honored sibling locks for ten minutes and exited without running. No lock was recovered. Exact-head hosted CI and native Testbox prepare remain authoritative.
  • Fresh autoreview against the immutable base: no findings; patch correct (0.99 confidence).

Codex contract inspection at openai/codex@57f42a81131ccf5933e7ec5dc659c381eeb5d72b:

Related sequencing:

@clawsweeper

clawsweeper Bot commented Aug 16, 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 size: M maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete steipete self-assigned this Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 02:43
@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 Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 10:48 PM ET / August 16, 2026, 02:48 UTC.

ClawSweeper review

What this changes

The PR isolates provider-specific authentication failures so usage summaries retain healthy provider snapshots and represent the failed provider as an error snapshot.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking source findings. This active maintainer-owned repair remains necessary: current main lets a rejected provider auth hook abort the whole usage summary, while the branch isolates that failure without changing direct resolver rejection behavior.

Priority: P2
Reviewed head: 2f4ac9956e0ae8d50d38b4e5221f5328a2150645

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch has source-proven regression coverage and no blocking correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body additionally reports a built Gateway/CLI fault-injection run.
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 proof gate; its body additionally reports a built Gateway/CLI fault-injection run.
Evidence reviewed 6 items Current-main failure boundary: Current main awaits each plugin auth hook in sequence without a provider-scoped catch, so a rejection exits before later providers are resolved.
Branch preserves direct-call behavior: The new catch rethrows unchanged unless the caller opts into onError, preserving existing direct resolver failure semantics.
Summary owner records the failure: The summary loader is the only production caller that opts into the callback; it converts the error to the established snapshot shape and restores descriptor order with successful fetches.
Findings None None.
Security None None.

How this fits together

Provider-usage loading resolves credentials for configured providers, then fetches each provider’s quota snapshot for status consumers. This change sits between plugin auth resolution and the summary returned to Gateway and status surfaces.

flowchart LR
  A[Configured providers] --> B[Provider auth resolution]
  B --> C{Auth succeeded?}
  C -->|Yes| D[Fetch usage snapshot]
  C -->|No| E[Create provider error snapshot]
  D --> F[Ordered usage summary]
  E --> F
  F --> G[Gateway and status consumers]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by 11 net lines; the summary-only callback must remain opt-in so direct resolver callers continue to receive their original rejection behavior.
  • Complete next step (P2) - No repair dispatch: this active maintainer-owned PR already contains the narrow fix and should proceed through normal exact-head CI and maintainer review.
Agent review details

Security

None.

PR surface

Source +23, Tests +42. Total +65 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 101 78 +23
Tests 2 42 0 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 143 78 +65

Review metrics

Metric Value Why it matters
Production vs test LOC production +89/-78 (net +11); tests/test support +54/-0 The production increase adds summary-only failure capture and ordering; the test growth covers both isolation and unchanged direct-call behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep provider-scoped error capture at the summary boundary, retain direct resolver rejection semantics, and avoid broadening the resolver into a new global result contract.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep provider-scoped error capture at the summary boundary, retain direct resolver rejection semantics, and avoid broadening the resolver into a new global result contract.

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

Yes—from source: reject one provider auth hook before a later healthy provider on current main, and the sequential await exits the summary before that later provider is collected.

Is this the best way to solve the issue?

Yes. The opt-in summary callback retains the resolver’s existing direct-call contract while recording the failure at the owner that can return an ordered usage result.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The PR repairs a bounded reliability failure in provider-usage status reporting.
  • 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 proof gate; its body additionally reports a built Gateway/CLI fault-injection run.

Label justifications:

  • P2: The PR repairs a bounded reliability failure in provider-usage status reporting.
  • 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 proof gate; its body additionally reports a built Gateway/CLI fault-injection run.

Evidence

What I checked:

  • Current-main failure boundary: Current main awaits each plugin auth hook in sequence without a provider-scoped catch, so a rejection exits before later providers are resolved. (src/infra/provider-usage.auth.ts:505, b170c2c02179)
  • Branch preserves direct-call behavior: The new catch rethrows unchanged unless the caller opts into onError, preserving existing direct resolver failure semantics. (src/infra/provider-usage.auth.ts:581, 2f4ac9956e0a)
  • Summary owner records the failure: The summary loader is the only production caller that opts into the callback; it converts the error to the established snapshot shape and restores descriptor order with successful fetches. (src/infra/provider-usage.load.ts:140, 2f4ac9956e0a)
  • Regression coverage: The added loader test injects one rejected auth hook and one healthy provider, while the adjacent auth test verifies direct callers still receive the exact rejection object. (src/infra/provider-usage.load.test.ts:219, 2f4ac9956e0a)
  • Codex boundary check: Configured Codex synthetic usage supplies explicit auth, and the resolver returns explicit auth before plugin resolution; the changed auth-error path therefore does not depend on the sibling Codex runtime contract. (src/commands/status-runtime-shared.ts:153, b170c2c02179)
  • Current-main comparison and history: Current main has no post-base edits to either production file, and blame attributes the present resolver block to the shallow-history boundary commit; this is routing evidence rather than causal regression provenance. (src/infra/provider-usage.auth.ts:477, 69c2c06c46a6)

Likely related people:

  • steipete: Authored the merged runtime-config usage-cache repair that owns the Gateway caller of this summary path, and authored this focused follow-up. (role: recent adjacent contributor; confidence: high; commits: 9fabdb40dcd0; files: src/gateway/server-methods/models-auth-status-usage-cache.ts, src/infra/provider-usage.load.ts)
  • Vyctor H. Brzezowski: Current-main blame maps the affected resolver and loader blocks to this commit, though older feature history is unavailable in the partial checkout. (role: current-line author in shallow history; confidence: medium; commits: 69c2c06c46a6; files: src/infra/provider-usage.auth.ts, src/infra/provider-usage.load.ts)

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

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up moves are satisfied on unchanged head 2f4ac9956e0ae8d50d38b4e5221f5328a2150645:

  • The merge-risk mitigation is the implementation contract: only loadProviderUsageSummary supplies onError; every direct resolveProviderAuths caller still rethrows the exact original error. The direct error-identity regression and 208-test provider-usage sweep are green.
  • The normal maintainer next step is complete: exact-head CI run 31922571605 passed (117 successful jobs, 16 intentional skips, no failures), fresh autoreview reported no findings, and native review artifacts validated as READY FOR /prepare-pr with zero findings.

No ClawSweeper finding was skipped and no additional source change was required.

@steipete
steipete merged commit 92b6c17 into main Aug 16, 2026
254 checks passed
@steipete
steipete deleted the fix/autoqa-refill-usage-fanout-outcomes-v2 branch August 16, 2026 02:59
@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

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: M 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