Repository navigation
fix(api): enforce approve-own constraints and the plan step cap on token approval of plan-step rows - #859
Conversation
…ken approval of plan-step rows A plan-step row has no creator, so an approve-own holder who is also the account contact_email fell through to the token path, where their capped approve-own was never applied, and a contact_email with no approve verb was bound by no cap at all. The token path now applies approve-own Constraints to plan-step rows regardless of creator and holds a verb-less or session-less approver to CheckStepCommitmentCap (auto-purchase plans, or manual plans that set a cap), ahead of the early return. The admin API key stays exempt. Refs #631. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 4 minutes for your next included review. View limit details
Comment |
Gate verdict: CHANGES REQUESTED at 3fb9d60Blocker (CI red, reproduced locally):
The guard rejects mock assertions whose receiver is not a plain identifier. Fix: bind the mock to a local ( Production change review (no defects found):
Re-gate needed after the test fix (new head restarts the gate). |
…oundary Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Gate verdict: APPROVED at c7a65ec
|
What it fixes
Refs #631 (item 48b, task D1). A plan-step row has no CreatedByUserID, so an approve-own-only user who is also the account contact_email hit the "cannot approve another user's pending purchase" 403, fell through to the token path, and
approveConstraintsForSessionreturned nil: their capped approve-own was never applied. A contact_email with no approve verb was bound by no cap at all.Now, for a row with PlanID set approved via the email token:
CheckStepCommitmentCap(auto-purchase plans, or manual plans that set a cap; a manual plan with no cap approves as before);User-created rows (no PlanID) behave as before.
Verification
Fixture/mock evidence (in-memory stores and purchase manager; the rec is the real
planstep.Resolveoutput and permission Constraints go through the real auth matcher). Docker was unresponsive here, so no integration run; no purchase package is touched.go test ./internal/apipasses;go build ./...,go vet, gofmt, pre-commit clean.🤖 Generated with Claude Code