Repository navigation
quota: gatherer reads only the opencode quota subcommand + Supabase sink (#6127) - #6136
Conversation
Single-source rewire (Drew 2026-11-05, program #6125): the tick's only quota read is now two invocations of DESCRIPTION OpenCode command line interface USAGE opencode <subcommand> [flags] [<directory>] ARGUMENTS directory string Directory to start OpenCode in (optional) FLAGS --standalone Run with a private server instead of the background service --server string Connect to a server URL instead of the background service --auto Auto-approve permissions that are not explicitly denied --continue, -c Continue the last session --session, -s string Session ID to continue, or to create if it does not exist --prompt string Prompt to use GLOBAL FLAGS --help, -h Show help information --version, -v Show version information --wizard Start wizard mode for a command --completions <bash|zsh|fish|sh> Print shell completion script (choices: bash, zsh, fish, sh) --log-level <all|trace|debug|info|warn|warning|error|fatal|none> Sets the minimum log level (choices: all, trace, debug, info, warn, warning, error, fatal, none) --print-logs Print logs to stderr (server logs require --standalone) SUBCOMMANDS upgrade, update Upgrade OpenCode to the latest or a specific version uninstall Uninstall OpenCode, keeping session data, configuration, and state acp Start an Agent Client Protocol server api Make a request to the running server debug Debugging and troubleshooting tools auth manage integrations and credentials mcp Manage MCP (Model Context Protocol) servers plugin Manage plugins models List all available models stats Show shareable usage statistics mini Start the minimal interactive interface run Run OpenCode with a message session Manage sessions msg Send, read and search inter-session messages service Manage the background server reload Reload configuration pair Print one-time links to connect a browser or app serve Start the v2 API and web server (configured listing + explicit ask for the route-disabled live pools meta/command-code), mapped through the unchanged quota-gather-map contract. Retired from the gatherer: the in-process OpenChamber module import, the gatherer-side Turso read, the native ClinePass adapter fill, the file-export family, and the Claude expiry side-read (the subcommand results carry the metadata now). Kept: the OpenDesign session keeper (credential maintenance, runs before the read), #1268 last-known retention, #1331 pool splits, Command Code plan-window mapping, fail-soft heartbeat contract. quota-current.json source becomes "opencode-quota". Added: Supabase sink — one agent.quota_records row per pool entry per tick (source "opencode-quota"), replacing the "pm-pool" writer that died 2026-10-29. Fail-soft after the file write. QUOTA_SUBCOMMAND env overrides the whole command (interim fork builds); the systemd drop-in points at the fork-built binary until the nix switch ships the new system opencode.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 21 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97f8871b8b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| windows: e.windows.map((w) => ({ name: w.name, percent: w.pctOfLimit, resetsAt: w.resetsAt })), | ||
| provider: e.providerName, | ||
| }; | ||
| const id = `${e.serviceId}:${tickAt}`; |
There was a problem hiding this comment.
Preserve credential identity in Supabase row IDs
When a provider has multiple credentials, entryFromResult assigns each credential the same serviceId, so this ID collides within a tick. The existing two-workspace Go case in test/quota-gather-map.test.ts explicitly produces two opencode-go entries. With ON CONFLICT (id) DO NOTHING, the sink silently discards all but the first credential's reading, and the payload omits credential identity as well. Include the credential ID in the row identity and payload, or explicitly aggregate entries into a single pool reading before inserting.
Useful? React with 👍 / 👎.
| plan: e.planLabel ?? null, | ||
| state: e.state, | ||
| source: GATHERER_SOURCE, | ||
| windows: e.windows.map((w) => ({ name: w.name, percent: w.pctOfLimit, resetsAt: w.resetsAt })), |
There was a problem hiding this comment.
Preserve label-only measurements in the Supabase payload
For DeepSeek, the measured balance is carried solely in valueLabel (for example, ¥44.63), with pctOfLimit null, as demonstrated in test/quota-gather-map.test.ts. The mapper explicitly accepts these CNY balances as measured windows, but this projection drops valueLabel without storing the raw usage elsewhere in the payload. Consequently, every DeepSeek row written to Supabase loses its actual balance and contains only a null percentage. Preserve the label or serialize the numeric balance with its unit so this sink retains the reading.
Useful? React with 👍 / 👎.
…s it (opencode#1729)
… read (opencode#1729)
… double-published pools)
Single-source quota rewire — program #6125, closes the gatherer half of #6127 once the fork subcommand (developing-today-forks/opencode#1718) is deployed to the tick.
What changes
opencode quota --json(configured listing) +opencode quota --json meta command-code(explicit ask for route-disabled live pools; a named ask always fetches). Results map through the unchanged quota-gather-map contract.quota-current.jsonsource becomesopencode-quota(GATHERER_SOURCE) — the file names its real producer.agent.quota_recordsrow per pool entry per tick, sourceopencode-quota, pm-pool payload shape. The previous pool writer (sourcepm-pool) died 2026-10-29 — verified in muse-dev2: 12 rows ever, none since. Fail-soft after the file write.Verification so far:
bunx tsc --noEmitclean; quota test files (quota-gather-map, quota-current, credential-lifecycle) 106 pass / 0 fail. Live tick against the fork-built subcommand binary + the production drop-in flip land with opencode#1718's proof on #6125 — this PR merges in the same motion as that deployment so the timer never runs the new gatherer against a binary without the subcommand.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.