Skip to content

quota: no labelled opencode-go.popesdrew row — the account's Console measurement publishes as the unlabelled opencode-go aggregate #8260

Closed

Description

@dezren39

Symptom

The quota gatherer's record (~/.local/state/pm-aggregator/quota-current.json, 15-minute ticks) carries labelled per-account rows for two of the three OpenCode Go accounts — opencode-go.drewrypope and opencode-go.developing-today-0 — plus ONE unlabelled opencode-go row. There is no labelled opencode-go.popesdrew row, so that account's windows cannot be read or steered per-account. The three Go accounts are seated 1:1:1 in the deepseek-flash-plan tier of workhorse-ordered, so per-account steering matters.

Census 2026-11-10 (quota-current.json generatedAt 2026-11-10T20:30:08Z, all rows fresh-measured in that tick):

  • opencode-go.drewrypope — 5h 0% / weekly 100% / monthly 100% (monthly resets 2026-12-03T03:02:35Z)
  • opencode-go.developing-today-0 — 5h 0% / weekly 100% / monthly 54% (monthly resets 2026-12-08T22:09:41Z)
  • opencode-go (unlabelled, no credentialId) — weekly 100% / monthly 100%, credits_balance $0.00, resets 2026-11-16T00:00Z / 2026-12-03T17:35:51Z

Root cause (wire-verified on the laptop, 2026-11-10)

The unlabelled row IS popesdrew's measurement, unattributed:

  • popesdrew is enrolled as a Console OAuth device sign-in (credential cred_bh5LJo8s26zwYccj8tDnC3LP1x, org org_01M6H7986JGCDR5H81QXPFJW2J, popesdrew@gmail.com, token expiry 2026-12-03T17:42:29Z) stored under its own instance integration opencode-go.popesdrew. The other two accounts hold API-key credentials under their instance integrations. The same Console sign-in also exists as the shared opencode integration's active row.
  • The gatherer's single source is the opencode fork's quota subcommand (opencode quota --json, fork packages/ai/src/quota). Its base per-credential walk for opencode-go reads only the credential aliases opencode + opencode-go — so it measures popesdrew's account through the shared opencode row and emits it as the bare, unlabelled opencode-go result. Proof the numbers are popesdrew's: a direct Console status call with that credential returns week used 3,006,253,692 / 3,000,000,000 micro-cents (100%, resets 2026-11-16T00:00Z), month 6,006,253,692 / 6,000,000,000 (100%, resets 2026-12-03T17:35:51Z — exactly the unlabelled row's reset), billing balance 0 ($0.00 — exactly the unlabelled row's balance), fiveHour meter present but idle (used 0, resetsAt null — the Console parser drops a meter with no reset, which is why the unlabelled row has no 5h window while the API-key rows do).
  • The instance path never rescues it: opencode-go did not set foldInstanceCredentials (only Codex did), so configured instances were never folded into the base answer; and the row-usability verdict re-keys an instance row under the base id (opencode-go), where a Console sign-in reads as neither Console credential (that lookup keys on the shared opencode integration) nor API key — so the instance is judged unusable, excluded from the configured listing, and an explicit ask for opencode-go.popesdrew answers Not configured (verified live).

Fix

In the opencode fork's quota module (the gatherer's single source), with the OpenChamber quota lib (the same module's original home, still used by OpenChamber surfaces) mirrored:

  1. opencode-go provider sets foldInstanceCredentials: true — configured Go instances fold into the base answer, one labelled row per account, the pattern Codex already uses for openai.main / openai.alternate.
  2. The provider gains an isCredentialUsable hook that judges a row on its own shape (Console sign-in under the Console key, or an API key present) instead of the dispatcher's base-id re-keying, which cannot see an instance-stored Console row.
  3. The listing's instance-usability verdict consults the same hook the fetch path uses, so listing and fetch agree (previously the listing re-implemented the verdict without the hook).

Tests: fork packages/ai/test/quota.test.ts gains a describe block covering the fold, the instance ask, and the listing (212 pass, typecheck clean); OpenChamber lib index.test.js gains the mirror coverage (46 pass) and opencode-go.test.js stays green (45 pass).

Related: #5324 (the route-level sibling symptom — the popesdrew pool drawing zero), #2490 (quota read-path unification), #1161 (the Go console per-workspace adapter this builds on), #8102 (popesdrew self-renewal stays UNPROVEN — its Console token expires 2026-12-03).

Proof

Posted as a comment on this issue after deploy: a fresh gatherer tick's quota-current.json with three labelled opencode-go rows and popesdrew's numbers quoted.

Activity

  1. developing-today commented on Nov 10, 2026

    @developing-today
    Contributor
  2. added a commit that references this issue on Nov 10, 2026
  3. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Proof + deploy status — 2026-11-10 ~16:40 CST

    Fix: merged everywhere.

    • Fork (the gatherer's live quota source): opencode PR #2257 — the labelled Go quota rows pull request — merged, merge commit cb3968e4f4713ae9e2918250614d83f2df2a3bb8. providers/opencode-go.ts gains foldInstanceCredentials: true plus an isCredentialUsable hook that judges a row on its own shape; the configured-listing verdict in quota/index.ts now consults that hook like the fetch path already did. Tests: 212 pass / 0 fail in packages/ai, type check clean.
    • OpenChamber quota lib (the mirror copy): openchamber PR #2075 — the quota lib instance fold pull request — merged, merge commit 1fabc820a50f90c514592ceb3d05141606e54acd. Already live on the laptop: the OpenChamber sync service pulled it 2026-11-10 15:43 CST, exit 0.
    • Code pin: code PR #8265 — the opencode pin bump for the Go rows fix — merged, merge commit 6531b2b28034a265b904896682f60b0ac4ed488f. flake.lock opencode rev 3497ea22c → cb3968e4f.

    Proof on the wire, with the pinned binary.

    Built only the system path from the pin branch (reason below): /nix/store/6kfwdzx23s8lg1w3zsw60xh0b1smgycf-system-path/bin/opencode reports opencode v2.0.30+cb3968e.

    Direct instance ask, previously answered "Not configured":

    $ opencode quota --json opencode-go.popesdrew
    providerId:     opencode-go.popesdrew
    ok: true   configured: true
    credentialId:   cred_bh5LJo8s26zwYccj8tDnC3LP1x
    credentialLabel: OpenCode Go (popesdrew)
    weekly:  100% used, resets 2026-11-16T00:00:00Z
    monthly: 100% used, resets 2026-12-03T17:35:51Z
    credits_balance: $0.00
    

    One-off gatherer tick through the gatherer's own script (gather-quota.ts, working directory ~/git/code/pm-stack/aggregator, the unit's normal env and state paths) with only QUOTA_SUBCOMMAND pointed at the new binary: tick 2026-11-10T22:29:00.048Z, providers=17 ok=15 records=+4, journal line quota-gatherer: opencode-go.popesdrew ok ... rows=1, Turso sink wrote 23 quota_records rows. The snapshot history (snapshots/usage-2026-11.jsonl) carries the durable record from that tick:

    {"ts":"2026-11-10T22:29:12.919Z","serviceId":"opencode-go.popesdrew","metricId":"monthly","value":100,"resetsAt":"2026-12-03T17:35:51.000Z","source":"api","observedBy":"quota-gatherer"}
    

    Two honest caveats.

    1. No 5h window for popesdrew yet. The Console five-hour meter for this account reports resetsAt: null (used 0), and the quota parser drops a meter that has no reset time. So the labelled row carries weekly + monthly + balance, matching the account's real Console answer; the other two accounts' rows show a 5h window because their API-key path reports one. Separate small gap, noted here rather than hidden.
    2. Permanence waits on a generation switch that is currently blocked by unrelated breakage. The gatherer's timer still runs /run/current-system/sw/bin/opencode (system generation 554, 2.0.30+c43145b), so regular 15-minute ticks again write the record without the labelled row (current quota-current.json generatedAt 2026-11-10T22:30:18Z). A full generation build from the pin branch fails on pre-existing fleet-0.1.0 compile errors that have nothing to do with this change — rustc E0063: missing field parameters in SearchOptions, missing global_top_k/shard_top_k in BranchQuery (fleet-search library), cascading into atlas-search.service, opencode-env-key-materialize, and home-manager. The system-path component containing the new binary builds clean on its own (proof above). Once fleet builds again and a generation switch lands the merged pin, the labelled row becomes permanent with no further change needed here.

    Leaving this issue open for the deploy-permanence step only; the code fix itself is merged in both quota-module copies and pinned in code.

    One side effect worth recording: the first one-off tick attempt failed because invoking the new binary made the background OpenCode server restart on a version mismatch; opencode.service came back healthy at 16:22:59 CST ("opencode: ready", serving on 127.0.0.1:13420) and the retried tick then ran clean.

  4. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Update 2026-11-10 ~17:15 CST — popesdrew converted to an API key; this issue's OAuth premise is now moot in production

    Per Drew's ruling (2026-11-10 16:45 CST: "need popesdrew Ai key Instead?"), the opencode-go.popesdrew credential is no longer the OAuth device sign-in (cred_bh5LJo8s26zwYccj8tDnC3LP1x) this issue was written around. It is now an API key, shaped exactly like the other two Go accounts.

    What was done

    • Proved a key is a first-class Go credential before minting anything: the provider sends credential.key as the bearer for key rows (packages/core/src/plugin/provider/opencode.ts, credentialHeaders), route history shows the key-backed instances serving heavily (drewrypope key row 7,579 attempts / 4,805 ok in 14d; developing-today-0 key row 6,883 / 5,823), and the key quota path (GET /zen/go/v1/usage) returns the account's Go windows for both key accounts.
    • No popesdrew key existed anywhere (fleet secrets list + Bitwarden project inventory checked by name). Minted one through the Console API using the account's existing Console session — no browser sign-in needed: service account fleet (svcacct_3ffe4c75…) + key fleet (sk_6a3d4dd3…, permissions all) on popesdrew's own org (org_01M6H7986JGCDR5H81QXPFJW2J). Before swapping, the key was verified to read popesdrew's own windows (weekly 100% → 2026-11-16, monthly 100% → 2026-12-03T17:35:51Z — identical to the Console read).
    • Key vaulted in Bitwarden Secrets as opencode.api-key-popesdrew (project "developing today", secret id 85ac68c7-5705-4ee5-9eec-b4fe017c49a5), matching the opencode.api-key-developing-today-0 naming; read-back hash-verified (sha256 fp 1d3d2ab3).
    • Credential swap via the server credential API in one motion: new key row cred_pKcBNN4l8hgClpiztdF1dX created + activated (label "OpenCode Go (popesdrew)"), OAuth row cred_bh5LJo8s26zwYccj8tDnC3LP1x deleted in the same motion. The instance now holds exactly one credential row, a key — same end state as drewrypope / developing-today-0. The shared Console row cred_ewyKoFzIohrg5B3rVzFtC1vz (integration opencode) is untouched — it is the Console account session, not an instance credential.

    Verification on the wire

    • Direct instance ask on the standing build: opencode quota --json opencode-go.popesdrew → ok, 5h 0% with a real reset clock, weekly 100% → Sun Nov 16 00:00Z, monthly 100% → Dec 3 17:35:51Z.
    • Natural gatherer tick 2026-11-10T23:15:28Z (not a one-off): opencode-go.popesdrew files labelled, state walled, source opencode-quota, windows 5h 0% (resets 2026-11-11T04:15:28Z) / weekly 100% / monthly 100%. Durable snapshot record for opencode-go.popesdrew|5h written 23:07:15Z. The missing-5h gap is fixed by the key path — the key-based usage API reports the rolling window with a reset time, where the Console meter reported resetsAt: null.
    • No new spend: the key is a service-account key on the same already-paid $10/mo Go account.

    What this changes for this issue

  5. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Serving check (follow-up, ~17:25 CST): the new key row cred_pKcBNN4l8hgClpiztdF1dX is already bound in live routing — 11 route attempts since the swap, all failing 429 "OpenCode Go usage limit reached", the same quota-wall response the other two key rows return right now (account weekly/monthly at 100%). That is the key serving exactly like its siblings: authentication succeeds, the plan wall answers. Zero auth failures on the new row.

  6. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Permanence blocker removed. The generation switch this issue waits on was blocked by the fleet flake build failing; that failure is fixed and merged:

  7. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Interim: seat-side half of the permanence fix is live (2026-11-11)

    The labelled opencode-go.popesdrew row was being erased by regular gatherer ticks because the gatherer resolves an opencode binary at the stale c43145b vintage (no instance-fold fix). Status of the two halves:

  8. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    state: done (already_done)
    lane: any-b, worker: repo-worker-code, task 18619

    Triage verdict for #8260 (checked fresh this shift, 2026-11-17): resolved — the closing check named on this issue now passes, so I am closing it with the evidence.

    The issue's closing step was: at least 2 regular gatherer ticks (~15 min apart) keep the labelled opencode-go.popesdrew row in quota-current.json. Observed live this shift in /home/user/.local/state/pm-aggregator/quota-current.json:

    • Tick measured 2026-11-17T03:45:48Z — provider row opencode-go.popesdrew present, state ok; heartbeat perProvider opencode-go.popesdrew = {state: ok, rows: 1}.
    • Tick measured 2026-11-17T03:54:03Z — row present, state ok, rows: 1.
    • Tick measured 2026-11-17T04:00:55Z — row present, state ok, rows: 1.

    Three consecutive regular ticks spanning 15m07s (first and third 15m07s apart) all hold the labelled row — the gatherer-side permanence fix (generation advance carrying the instance-fold fix, whose seat-side half landed 2026-11-11 per comment 6784094285) is doing its job; the row is no longer erased between ticks and the account no longer publishes only as the unlabelled aggregate.

    No follow-on packet needed.

  9. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    task: 20137
    lane: any-n
    worker: repo-worker-code

    Freshly revalidated #8260 as CLOSED with status:done. The existing triage evidence confirms three regular gatherer ticks spanning 15m07s retained the labelled opencode-go.popesdrew row, satisfying the stated closing check. Queue task 20137 completed as already_done.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions