Skip to content

unify(quota-plane): one quota read path — server endpoint, CLI, and aggregator gatherer must share the direct credential-store read #2490

Open

Description

@dezren39

Leg of epic #1149 (quota-plane Stage 2). Filed at Drew's direction, 2026-10-29: "there was supposed to be a unification in the 3 quota read methods." There wasn't — three independent quota readers exist today, they resolve credentials three different ways, and they disagree. This issue is the unification leg of #1149; it cross-links the legs it absorbs or depends on rather than replacing them.

The three readers

  1. OpenChamber web server /api/quota/* — resolves credentials through the running OpenCode server's GET /api/credential projection (openchamber server/index.js:1647; projection server/lib/opencode/auth.js:91, 203-230, active rows only).
  2. openchamber quota CLI — server-first, with a direct credential-store fallback (openCodeLocalCredentialSource, reading opencode.db read-only). Built 2026-10-27 under fix(quota-plane): opencode-serve boot verification + quota CLI per-provider resilience (no wholesale transport failure) #1251, which deliberately switches to the store ONLY on transport failure and stamps each row credentialSource: server|local.
  3. PM-stack aggregator gatherer (pm-stack/aggregator/scripts/gather-quota.ts:10-19, 116-149) — reads opencode.db directly, by design, because the server-API path is known to diverge (fix(quota-plane): opencode-serve boot verification + quota CLI per-provider resilience (no wholesale transport failure) #1251), replicates the server's projection itself, and additionally ingests bespoke per-provider file exporters (Meta: pm-stack/meta-exporter/meta-quota-export.mjs). Writes quota-current.json on a ~15-minute systemd tick.

Divergence evidence (2026-10-29, same evening, same pools)

Meanwhile #2135 unified only the consumers — the steward went snapshot-first onto quota-current.json — but the dispatcher still live-probes reader 1, so consumers still disagree about the same pool at the same moment.

Why it matters

The fleet measurement gate forbids placement on a pool without a fresh read ≤60 min old. Every reader disagreement therefore closes a primary pool: Antigravity is the Gemini Flash pool's ONLY source and carries the Claude seats' clean read; Meta is a primary pool. The cost is burn-by-expiry — Antigravity's weekly (4% used on the Gemini tiers) resets Sat Oct 31 8:11 AM CDT largely unspent while OpenCode Go's monthly sits at ~96%. Three readers also means three places for the same bug family to recur (cf. the exporter's sibling defects #2460/#2461/#2470).

Proposed target state

One canonical read module: the direct credential-store read (the semantics reader 3 already implements and reader 2 falls back to) plus the shared provider fetchers, consumed by:

  • the OpenChamber server endpoint (no more server-projection-only resolution),
  • the CLI (no server-first/store-fallback split — one path, one provenance),
  • the gatherer, which keeps its 15-minute tick and file-export ingestion but imports the same read module instead of carrying its own projection logic.

Exception providers fold into the same path where their integration plans allow (#1167/#1301 for Meta, #1169 for Google/Antigravity — this issue absorbs #1169's read-path half; the login/token-capture half stays with #1169). Per-provider error states stay distinct end-to-end: not-configured vs store-read-failure vs provider-error are different facts and must never collapse into one another.

Acceptance criteria

  • All three surfaces (server endpoint, CLI, gatherer/hub) return identical windows for the same pool in the same tick, demonstrated on Antigravity, Meta, and one ordinary pool (e.g. ClinePass or OpenCode Go).
  • No surface can report not-configured for a credential the direct store read resolves.
  • Dispatcher, steward, babysitter, and the /quota UI consume one source with identical semantics (the Pool quota steward: consume the compiled hub numbers — probe only stale pools, follow-ups daily #2135 snapshot-first rule extends to the dispatcher's gate).
  • A credential-store read failure surfaces as its own error state on every surface, distinct from not-configured (the fix(id-world): manifest plan leaves omitted grants/ceiling/schedules/profile alone (#817) #858 resolver swallow is gone or subsumed).
  • The Meta exporter path either folds into the shared module or its parser contract is enforced by the same validation the shared path uses — a single bad field can no longer poison a whole pool's export.

Related

Activity

  1. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/highImportant and time-sensitive
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    on Oct 30, 2026
  2. developing-today commented on Oct 30, 2026

    @developing-today
    Contributor
  3. added
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    kind/designA design proposal (design-architect): multi-step, phased, decision-bearing
    on Oct 30, 2026
  4. dezren39 commented on Oct 30, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    Agent: quota-unification-filer
    State: filed
    Found via: Drew, 2026-10-29 — "there was supposed to be a unification in the 3 quota read methods"

    Filed at Drew's explicit direction (2026-10-29 ~20:19 CDT). This is the read-path unification leg of epic #1149: the OpenChamber /api/quota endpoint, the openchamber quota CLI, and the pm-stack aggregator gatherer each resolve credentials differently and disagree about live pools — Antigravity blind via the server projection (developing-today-forks/openchamber#858), Meta poisoned in its private exporter (#1301), OpenDesign absent until deployed (developing-today-forks/openchamber#536).

    Enqueued as a triage task on repo-health-code-pilot. Triage should confirm the shared-module shape (direct credential-store read as canonical, per pm-stack/aggregator/scripts/gather-quota.ts), rule on how #1169's read-path half folds in, and route the phased fix packets. Nothing self-assigned.

  5. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    Scope extension + fresh evidence — 2026-11-01 (Drew: "unify 1 quota path for all")

    Drew re-issued the unification order tonight after the Command Code meter dispute. #2490 already covers the three readers; tonight's failures show the unification must also cover the consumer side, or the readers can agree and the surfaces still disagree:

    1. Aggregator prose extraction is a fourth, shadow read path. pm-stack/aggregator/src/quota-extract.ts regex-parses dated prose out of the stewardship quota view and renders it as current pool state. On 2026-11-01 it presented a week-old Command Code read as current (defect filed separately as Quota reads: Command Code reports plan windows, not the top-up balance (extractor renders stale read) #3410). Under the unified design, the aggregator consumes the canonical record (quota-current.json / its successor) only; prose extraction is retired as a data path — the view stays a human log.
    2. Feed mapping diverges from the gatherer. The same gatherer tick (2026-11-01T06:45Z) reads OpenCode Go Personal/Lab monthly at 100%/100% in quota-current.json, while the fleet feed's pool mapping shows 84%/87%. One canonical record, one mapping — consumers never re-derive percentages.
    3. Plan-not-balance is a canonical-record invariant (Drew's ruling, 2026-11-01, Quota reads: Command Code reports plan windows, not the top-up balance (extractor renders stale read) #3410): the record for each pool carries the plan windows (used, limit, percent, resetsAt, measuredAt, source). A credit/top-up balance, where a provider exposes one, is a separate labeled field and is never a window. Concrete case: OpenChamber's packages/web/server/lib/quota/providers/command-code.js builds its monthly figure from /alpha/billing/credits as a balance window (usedPercent: null); only 5h/weekly come from windowLimits as real plan windows. The canonical module needs a plan monthly window for Command Code (console-format: monthly limit % of the $10 included credits).
    4. Steward/hub reporting follows the record. The Oct 30–31 "credits 0.1, walled-in-effect" Command Code reporting came from quoting the balance field outside the record. Consumers (stewardship, quota-check, orchestration, dispatcher) read the canonical record only — no side-channel figures.

    Acceptance addition: with the unified path live, one timestamped read per pool exists at any moment, and the dashboard, feed, steward view, and quota-check all show the same figures for the same pool at the same time (spot-check Command Code + both Go workspaces).

  6. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    Drew prioritized this in main chat 2026-11-01 (~02:01 CST) after tonight's Command Code / Go mapping disputes. Queue task 3721 moved from priority 90 (the last band — lower claims first) to priority 10, verified head of repo-health-code-pilot. The 2026-11-01 scope-extension comment above (consumer-side unification, plan-not-balance invariant, #3410) is part of the job.

  7. 85 remaining items

  8. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged

    Concurrence note (2026-11-14): this issue was triaged fresh earlier today by lane any-d (task 15235, note 2026-11-14T11:53Z); this lane re-verified the routing rather than re-triaging.

  9. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    Same-tick parity + error-state verification (2026-11-16T14:22:06–14:22:22Z, this machine)

    Surfaces compared in one tick:

    • CLI (new): this PR's openchamber quota --json antigravity meta codex — direct credential-store source.
    • Server endpoint (new): production route code from this PR (registerQuotaRoutes(app) with no injection — providers resolved from lib/quota/index.js), direct credential-store source wired.
    • CLI (deployed, old build): the installed openchamber quota, which reached the same store through its fallback leg (credentialSource: local on every result — no server answered).
    • Aggregator gatherer: its subcommand opencode quota --json antigravity meta codex, plus its last real tick's quota-current.json (generated 2026-11-16T14:15:02Z, source opencode-quota).

    Results:

    Provider CLI (new) Endpoint (new) CLI (deployed) Gatherer subcommand
    Meta ok, acct admin@drewrypope.com, 5h 52% / weekly 67% identical identical identical
    Codex (ordinary pool) ok ×2 credentials — "OpenAI Alternate (Student - popesdrew)" popesdrew@gmail.com 5h 0% / weekly 100%; "default" drewrypope@gmail.com weekly 100% identical identical identical (_openai ids)
    Antigravity (error state) ok=false, configured=false, "Not configured" identical identical ok=false, configured=true, "Failed to refresh Antigravity token"

    Antigravity is the error-state case: the credential store holds no google OAuth row (only google.* API keys) and no antigravity accounts file exists, so "Not configured" is the store's true answer, and the three openchamber surfaces agree on it exactly. The gatherer's deployed opencode binary still answers Antigravity from its own pre-unification reader (it finds a candidate the store does not hold and fails refreshing it). That divergence lives in the deployed binary, not in any reading path this PR controls: it converges when the opencode binary is next built from the unified quota source, and the gatherer's mapping consumes the subcommand JSON unchanged either way. Meta and Codex — the configured pools — are in exact parity across all four surfaces, including per-credential rows.

    Deliberate reporting change recorded per the acceptance criteria: with the direct store read as the only source, servedBy() collapses — every CLI result is stamped credentialSource: 'local', and the stderr "server unreachable → local store" note is removed (there is no server read left to mistake it for; the help text names the single source). An unreadable store now fails the CLI run with the store's error instead of being masked by a fallback (pinned by a new test).

    Implemented in PR #2318: CLI composition removed, routes.js resolves providers from the quota module directly (injection kept only as a test pass-through), openCodeLocalCredentialSource reports usesLocalStore() === true. Quota test tree: 951 tests passing.

  10. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged (queue task 18230, openchamber scheduled lane code-f)
    Fresh check 2026-11-17: issue open, kind/design, epic/pm-stack. Already triaged on 2026-11-14 (tasks 15235, 16785), and the 2026-11-16 same-tick parity comment records the unified direct credential-store read in an in-flight PR. Remaining work is that PR's merge plus the opencode-binary rebuild noted there. No new routing is needed; this pass creates no competing PR and enqueues no follow-up.
    Found via: queue triage task 18230

  11. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Agent note — task 19765 triaged (bulk-intake concurrence with state update, lane code-c, 2026-11-17)

    Triage of record stands (tasks 15235/16785, 2026-11-14; concurrence task 18230 today), with one material state change since those verdicts, verified fresh this shift:

    Verdict: no new routing, no competing PR, no follow-on packet. Issue #2490 stays open as the epic #1149 tracking record until the rebuilt opencode binary is deployed; task 19765 completes as triaged with the merged-PR evidence above.

  12. removed their assignment
    on Nov 20, 2026
  13. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up — shortlist rank 3, lane archer (Lane ED), 2026-11-22.

    Fresh same-tick verification this pass (laptop, 2026-11-23T04:15Z tick):

    • Gatherer/hub (quota-current.json, source opencode-quota): Antigravity state ok, real windows (weekly 1.64% on the claude-gpt and gemini groups).
    • Unified openchamber CLI (direct store read): Antigravity configured:false, "Not configured" in the same tick.
    • Deployed fork binary standalone (no EnvironmentFile): configured:true, "Failed to refresh Antigravity token".

    Root cause of the remaining divergence: the canonical module's Antigravity candidate set (accounts file + credential-store google OAuth) never adopted the agy keyring credential (Secret Service service gemini, username antigravity) — the login the fork's antigravity-auth bridge actually uses (Drew-sanctioned, code#8086) and the one the gatherer reads the pool through today. The unified surfaces therefore report a working primary pool as not configured — criterion 1 still fails on Antigravity, in the opposite direction from 2026-10-29.

    Slice being landed (one PR, developing-today-forks/openchamber): add the keyring candidate to the canonical Antigravity resolution — same in-place Secret Service read the fork performs (read-only, never written back), candidate order keyring → file → store mirroring the fork, wrong-client classification unchanged (keyring is Antigravity-issued by construction, like the accounts file) — with tests. Deploy leg (Nix packaging of the new module dependency) and the fork-side refresh-outcome classification gap are named remainders, recorded here when the PR lands.

  14. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Slice landed — lane archer (Lane ED), 2026-11-22. The canonical module now resolves the agy keyring login; Antigravity reads identical across surfaces at the code level.

    Landed: developing-today-forks/openchamber#2513, merged 49f96df6ee (head 63c750ba7):

    Verification:

    • Antigravity suite 55/55; full quota tree 58 files / 1038 tests passing. Type-check: no errors in any touched file (the run's other errors are the worktree's unbuilt-@openchamber/sdk baseline).
    • Live same-tick, this machine: the branch's module returns ok: true with the Gemini weekly at 1.6407999999999987% used — bit-identical to the gatherer's quota-current.json for the same pool (state ok, source opencode-quota) — where the deployed unified build reported configured: false, "Not configured" minutes earlier in the same tick.

    Criterion state: (1) Antigravity parity now demonstrated at the read level for all three surfaces once deployed; Meta + Codex parity stood from 2026-11-16. (2) No surface can report not-configured for the keyring login the fleet actually uses. (4) Error states stay distinct — keyring read failures add no candidate and manufacture no error; store-read failure keeps its own state. (3) and (5) unchanged from the 2026-11-16/17 records.

    Remainders (named next steps):

    1. Deploy leg: the Nix packaging of the openchamber build must pick up the new native dependency (@napi-rs/keyring) before the endpoint/CLI surfaces run this in production; unify(quota-plane): one quota read path — server endpoint, CLI, and aggregator gatherer must share the direct credential-store read #2490 stays open as the epic epic(quota-plane): Stage 2 — 15-minute quota gathering in the PM stack, token adapters, automated pool decisions #1149 tracking record until the deployed surfaces show the parity live.
    2. Fork slice: the fork's antigravity refresh outcome drops the token endpoint's status/OAuth error code, so its own wrong-client rule is dead code — filed as developing-today-forks/opencode#2693 with the fix shape.
  15. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up — shortlist rank 3, lane archer (Lane HO), 2026-11-23.

    Taking the named remainder #1 from Lane ED's landing record: the deploy leg — the Nix packaging of the openchamber build must pick up the new native dependency (@napi-rs/keyring, added by openchamber PR #2513) before the endpoint/CLI surfaces run the unified read in production. Premise re-verified fresh: #2490 open, no live claim (ED's slice landed and released), deploy remainder still named open.

    Plan: inspect the openchamber package in this repo, determine what the new native dep needs (vendoring / fetch / build input), land the packaging fix in one PR with a build or targeted check as the oracle, and record the result here.

  16. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Deploy leg — prepared, then held at a platform execution-risk flag (Lane HO, 2026-11-23).

    Progress before the hold:

    Hold: while verifying the fork package build from that worktree, the tooling returned a platform execution-risk flag on the worktree content. Per that notice I stopped — no further git/build/test commands inside the flagged content, and the prepared lock bump was not committed, pushed, or PR'd. A background nix build .#openchamber started before the flag was left as-is (build only; nothing deployed).

    To finish, Drew needs to say in plain words that working in these worktrees is approved despite the flag (or route the landing to an unflagged venue). Remaining steps once approved: commit + PR + merge the flake.lock bump in code, evaluate the amd config against the new pin, build the package, live-check the built CLI's Antigravity read against the gatherer, then record parity here. The final nixos switch stays a primary-seat deploy step.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/lLarge: multi-day or open-ended; expect staged check-insepic/pm-stackReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/highImportant and time-sensitivesource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions