Repository navigation
fix(server): register a provider-usage.v1 source so the panel sees ZCode - #9
Conversation
The Provider usage panel never calls provider/usage: it federates over the provider-usage.v1 RPC contract that only builtin provider plugins implement, so the quota windows shipped earlier were unreachable from it (the panel listed no ZCode entry at all). The production worker was verified first - spawned exactly as the daemon spawns it, it returned GLM Coding Max with all three live windows - isolating the gap to the missing federation. src/usageSource.ts registers a discoverable source: host-scoped resources for the zcode provider on connected non-ephemeral hosts, window-grammar mapping by label (five-hour/weekly/custom, stable ids), a 60 s observedAt cache with refresh bypass, and error usage states for disconnected hosts and failed collections. Measurements flow through the daemon's provider/usage path via system.usageLimits, reusing the bridge quota fetch and its cache. src/usageContract.ts pins the wire; server.ts wires it with real sdk deps; tests cover listing, mapping, caching, and degradation. Wire semantics recorded in knowledge/contracts/quota-usage-protocol.md.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
Problem
After PR #8 the bridge reports real quota windows through
provider/usage,but the Provider usage panel still showed nothing for ZCode.
Root cause: the panel never calls
provider/usage. It is federated — bb'sbuiltin provider-usage plugin discovers usage sources server-side via
experimental_discoverRpcofprovider-usage.v1.listResourcesand readseach with
provider-usage.v1.getResource. Only plugins registering thatcontract (
experimental_discoverable: true) appear; the builtin providerplugins (codex, claude-code, acp, account-pool) implement it, bb-zcode did
not.
maintenance.usage/providers.list({capability:"usage"})is displaymetadata, not a data source.
Verification that isolated this: the production worker artifact was spawned
exactly as the daemon spawns it (
bb-provider-bridge-worker.mjs <artifact> zcode <dataDir>) and answeredprovider/usagewith the real account —status ok, GLM Coding Max, 5-hour/weekly/MCP windows with live reset times.
Change
src/usageContract.ts— pins the panel wire (method names, resource andwindow grammar) extracted from the builtin provider-codex implementation.
src/usageSource.ts— discoverableprovider-usage.v1source: host-scopedresources for the zcode provider on connected non-ephemeral hosts,
window-grammar mapping by label (
five-hour/weekly/custom, stable${i}:${label}ids,model: null,costpassthrough), a 60 sobservedAtcache withrefreshbypass, non-ok pass-through withoutinvented windows, and error usage states for disconnected hosts / failed
collections (no credential or body text leaks into messages).
system.usageLimits({hostId, providerId, refresh})→ daemonprovider/usage→ the bridge quota fetch with its owncache;
server.tswires the source with real sdk deps; deps are injectablefor tests.
Verification
tests/usage-source.test.ts: listing filters to thezcode provider on persistent hosts; window mapping parses against the
contract and the 60 s cache prevents re-collection (refresh bypasses);
disconnected-host and failed-collection error states (with a canary check
that internals do not leak); unauthenticated pass-through.
npm run typecheck, full suite 268 tests green,format:checkclean.provider/usageanswer(see above); the panel entry itself needs this PR merged + plugin update to
observe.
Docs/knowledge: CHANGELOG,
knowledge/contracts/quota-usage-protocol.md(new "panel federation" section),
knowledge/log.md.Summary by CodeRabbit