You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sec(plans): apply the USD-only rule to max_step_commitment once Azure recs carry a currency #1427
#1296 (for #361) makes the purchase spend cap fail closed: a grant with a USD MaxPurchaseAmount or API-key max_amount is refused any purchase whose commitment currency is not proven to be USD. The plan cap max_step_commitment was deliberately left out. It is still compared against the step's raw amounts, whatever their currency:
purchase.CheckStepCommitmentCap, used for auto-purchase plan steps;
requirePlanStepCap (internal/api/handler_purchases.go:1291-1311 on main at 6b586cc), which applies the plan cap to a plan-step row approved through the email link by someone with no approve verb.
So a plan step priced in a non-USD currency can still pass a cap that is meant to bound USD spend. That is the same class of bug #361 describes.
Why it was left out
Every auto-purchase plan must have max_step_commitment (handler_plans.go:642-643). Azure recommendations carry no currency yet (LeanerCloud/cloud-commitments-go#623). Failing closed here today would stop every Azure auto-purchase plan.
apply the same rule as enforcePurchaseConstraints in CheckStepCommitmentCap: if any recommendation in the step is not provably USD, refuse the step against the cap, with an error that names the currency and tells the user to refresh recommendations;
requirePlanStepCap then refuses with a 403, as it does for an over-cap step.
Acceptance criteria
A plan step whose recommendations are in another currency, or whose currency is empty, is refused by max_step_commitment in both the auto-purchase path and the email-token approve path.
An all-USD step behaves exactly as before.
Tests cover a non-USD step, an empty-currency step and a USD step, in both paths.
Done only after the go bump that sets Azure currency, so Azure auto-purchase plans keep working.
Claimed by claude-platform-2 (coordinator assignment 2026-11-14, not touching store_postgres.go, plans.ts, recommendations.ts): premise-check against main, then implement and close (Closes #1427), or comment the evidence/blocker.
Landed on main (d976708, Closes #1427; two review passes, mutants killed incl. fail-before for the API email-token path, lint v2.10.1 plain+integration clean, go test ./internal/... green): capCommitment refuses any currency not provably USD including empty, for plain and bound plans, covering requirePlanStepCap (email-token approval, 403), auto-purchase, scheduled fire and attach (all via CheckStepCommitmentCap); precondition met (Azure recs carry a currency since go#625, in the pinned module). Operational note: rows stored before the currency field was persisted (#1296) and rows with incomplete provider price legs have an empty currency; capped steps built from them are refused until the next daily collection refreshes them (intended fail-closed; such rows used to be summed with a partial price). Deploy-time check: count recommendation rows where payload->>'commitment_currency' is null or empty.
Activity
cristim commentedon Nov 14, 2026
Claimed by claude-platform-2 (coordinator assignment 2026-11-14, not touching store_postgres.go, plans.ts, recommendations.ts): premise-check against main, then implement and close (Closes #1427), or comment the evidence/blocker.
cristim commentedon Nov 14, 2026
Landed on main (d976708, Closes #1427; two review passes, mutants killed incl. fail-before for the API email-token path, lint v2.10.1 plain+integration clean, go test ./internal/... green): capCommitment refuses any currency not provably USD including empty, for plain and bound plans, covering requirePlanStepCap (email-token approval, 403), auto-purchase, scheduled fire and attach (all via CheckStepCommitmentCap); precondition met (Azure recs carry a currency since go#625, in the pinned module). Operational note: rows stored before the currency field was persisted (#1296) and rows with incomplete provider price legs have an empty currency; capped steps built from them are refused until the next daily collection refreshes them (intended fail-closed; such rows used to be summed with a partial price). Deploy-time check: count recommendation rows where payload->>'commitment_currency' is null or empty.