Repository navigation
fix(gateway): restore spend limits with incremental member accounting - #5133
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Verification status: IncompleteHead:
Both use |
|
Database changes have been split into #5135. It contains only SQL/Drizzle metadata, matching schema declarations, and the migration-validation support required for a consistent database package. Auto-merge here is paused. Please merge #5135 first and confirm Den DB Migrate succeeds; this implementation can then be rebased onto the updated dev branch. No implementation history was rewritten or force-pushed as part of the split. |
Database-first dependency
Merge #5135 and confirm its migration workflow succeeds before rebasing or merging this implementation. Auto-merge is paused until that sequence is complete.
Purpose
Replacement for #5056, which was merged and then reverted by #5124 after the usage path caused database lock contention. This restores the requested spend-policy UI and APIs, but replaces the accounting design rather than reinstating the organization-wide mutex.
Ready for human review; auto-merge requested by the author. Verification remains incomplete. Do not activate in production solely because the original tables already exist.
Request-path changes
The agreed semantics remain settled-estimate enforcement, not pre-dispatch reservations: already-admitted work may overshoot an allowance.
Preserved functionality
Policy day/week/month limits in integer micro-USD; per-person direct/team assignments; highest allowance per timeframe; 05:00 UTC calendar boundaries; hard/soft limits; one reviewed 25% increase per bucket; Den management and request review; Desktop usage controls, direct increase requests, pending/approved indications. Legacy OpenWork Models allowances remain separate.
Migration and rollout requirements
9b0adb849. Restoring files is not evidence that a particular database has matching receipts or complete physical schema.Operator CLI and procedure:
ee/packages/den-db/scripts/gateway-usage-operations.md. Preview is the default; apply requires explicit reviewed input. No production database was queried or migrated during development.Most of this PR's line count is generated migration snapshots and restoration of files deleted by #5124.
Verification on aa8223d
312 focused tests passed, zero skips: 195 backend tests and 117 UI tests. Scoped/app typechecks, generated SDK consistency, and API lint passed (0 errors, 39 warnings).
Real MySQL 8.4.10 tests cover:
Final-head latency measurements
10,000 historical raw rows; eight members; 24 concurrent operations; read/write pools limited to 10. Values are p50 / p95 / p99 milliseconds. These are local measurements, not PlanetScale certification.
Actual offboarding remained 49 SQL statements with either 0 or 200 unrelated members. Overload tests separately verified queue bounds, cancellation, deadline and unrelated-member progress.
End-to-end gap — do not treat as passed
Both commands were run on this exact committed head, with placement
local (--local):Each exited 1 with one failed test, zero passes/skips. Legacy stopped during local Chrome navigation; v2 completed policy creation/assignment but session creation did not return a session ID. Neither final-head run reached the required pre/post-increase composer flow. Earlier intermediate-tree successes are not substituted for current-head evidence.
Local diagnostic records:
evals/results/.testkit/cli-run-1789689161789.jsonevals/results/.testkit/cli-run-1789689364246.jsonComplete Desktop E2E, clean visual evidence, and controlled deployment validation remain required before production activation. Auto-merge is paused for the migration-first sequence. Production activation still requires the documented migration/cutover procedure and complete verification.