fix: owner plan lookup + node-cap count bypass (post-#265 review)#267
Conversation
Two issues surfaced by adversarial review of the entitlement change: - Owner account was misclassified as free on the node-write path: getPlan received the DO-resolved id (owner collapses to 'default'), missing the owner's comp/subscription row keyed on the real user.id. Pass the billing id (session.user.id) to the plan lookup while the DO stub keeps routing on the resolved id — mirroring the MCP branch. - Node-cap growth count could be bypassed by a batch that deletes and re-inserts the same id (double-subtracted the survivor). Replaced the independent insert/delete sets with a pure, unit-tested countNetGrowth (last-op-per-distinct-id), so an id that ends the batch present is one insert and a delete+reinsert nets zero. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
Two correctness fixes for the free-tier entitlement work (#170) landed on the branch after #265 was already squash-merged, so they missed main. This lands them.
Changes
freeon the node-write path:getPlanreceived the DO-resolved id (the owner collapses to'default'), missing the owner's comp/subscription row keyed on the realuser.id. The plan lookup now takes the billing id (session.user.id) while the DO stub keeps routing on the resolved id — the same split the MCP branch already makes.countNetGrowth(last-op-per-distinct-id), so a delete+reinsert nets zero and can't creep past the cap.Both were found by adversarial review of #265 (two Opus reviewers, correctness + security).
Test plan
bun run typecheck/typecheck:worker/typecheck:test— greenbun test worker/— 172 pass, incl. newcountNetGrowthcases (delete+reinsert, upsert+delete, dup upsert, delete-of-absent)bun run lint,bun run fmt:check— cleanactivesubscription row on their real id now reads paid on node writes) — needs a live Worker + D1; e2e can't reach it.