Skip to content

feat(console): add idempotent Go quota repair - #45553

Open
opencode-agent[bot] wants to merge 1 commit into
v2from
go-quota-repair
Open

opencode-agent[bot] wants to merge 1 commit into
v2from
go-quota-repair

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an authenticated support endpoint for one exact reduction of a Go subscriber's current monthly consumed quota, without changing weekly/rolling usage, billing, or the subscription.

  • Freeze the requester, workspace, Go user/row, customer, subscription, monthly period, expected raw counter, and expected timestamp.
  • Revalidate active membership, the product binding, and active Stripe Go subscription.
  • Apply an exact compare-and-set inside a transaction and preserve the monthly timestamp.
  • Store the idempotency receipt atomically with the change. Identical retries return the original receipt, even after subsequent usage or a later period; conflicting key reuse is rejected.

This repairs existing state after a confirmed counter defect. It does not replace the separate inference-accounting reset-boundary fix.

Deployment

Agent-side approval tool: https://github.com/anomalyco/experiments/pull/502.

Requires the additive 20260827122435_go_quota_repair migration, then the Console endpoint deployment. No production migration or mutation has been performed. The corresponding OpenCode Agent tool will require an exact human-approved correction and validate this endpoint's structured receipt.

Verification

  • TMPDIR=/tmp/opencode GO_QUOTA_REPAIR_TEST_PORT=<isolated-local-mysql-port> bun test test/go-quota-repair.test.ts test/date.test.ts test/subscription.test.ts in Console core: 69 passed, including real local MySQL transaction, concurrency, replay, stale-state, identity, expiry, and rollback coverage.
  • Four route auth/input smoke checks: 4 passed, without database or Stripe calls.
  • bun typecheck in Console core and Console app: passed.
  • Prettier and git diff --check: passed.
  • Independent review confirmed migration/snapshot only adds the receipt table and preserves existing schema.

PlanetScale and live Stripe execution have not been tested; the production action remains approval-gated.

Requested by: @MrMushrooooom (Jack via Slack)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant