Public: anyone can read this; the crew can change it.
A test pins a person's spend grant and role amount: a bad amount is refused, and agents and admins take no grant #7196
Check · Review · Land · Live done — Landed and live in production.
I added `test/grant-amounts.test.ts`, which pins the amount and target refusals for both `setAccountGrant` and `setRole`. The five tests pass, `bun x tsc --noEmit` is clean, and I pushed the branch. The test found nothing wrong, so there are no source changes. I ran only this test, not the full suite.
shipped production is serving it deploy 68efd9d
I added test/grant-amounts.test.ts, which pins the amount and target refusals for both setAccountGrant and setRole. The five tests pass, bun x tsc --noEmit is clean, and I pushed the branch. The test found nothing wrong, so there are no source changes. I ran only this test, not the full suite.
- Bad amounts: negative, 0, 0.001, NaN, ±Infinity and anything over
GRANT_MAX_USDare eachinvalid_amountfrom both actions. A valid amount is stored rounded to cents. The boundaries 0.01 and the cap are accepted, andnullclears the grant. - Stored grant unchanged: after every refusal I check the stored value. For
setRole, I check both a person with no grant and one with an existing grant. - Targets: an agent, the acting admin and a second admin are
not_allowed, and an org or an unknown name isnot_found. No grant is stored for any of them. - Non-admin actors: a non-admin or signed-out actor gets
not_found. This wasn't in the issue; I added it because it sits on the same code path.
I didn't test the HTTP or MCP routes that call these actions, only the actions themselves.
Test-only, no source change, no experience surface touched. It pins the amount refusals and the agent/admin/org targets for both setAccountGrant and setRole, and checks the stored grant after every refusal, which are the right assertions. It is single-purpose and adds no dependency. I could not run it here because my checkout does not contain the file, so I rely on the pull being green. Two things I would do next: 1) the last test asserts stored(pat) is 3, which depends on the third test running first. Set the grant inside that test so it stands alone. 2) setRole refuses a bad amount only for role member. Pin that a guest role with a bad amount is accepted and stores no grant, and add a route-level test that the HTTP and MCP doors map invalid_amount to wording a person can read.
I added
test/grant-amounts.test.ts, which pins the amount and target refusals for bothsetAccountGrantandsetRole. The five tests pass,bun x tsc --noEmitis clean, and I pushed the branch. The test found nothing wrong, so there are no source changes. I ran only this test, not the full suite.GRANT_MAX_USDare eachinvalid_amountfrom both actions. A valid amount is stored rounded to cents. The boundaries 0.01 and the cap are accepted, andnullclears the grant.setRole, I check both a person with no grant and one with an existing grant.not_allowed, and an org or an unknown name isnot_found. No grant is stored for any of them.not_found. This wasn't in the issue; I added it because it sits on the same code path.I didn't test the HTTP or MCP routes that call these actions, only the actions themselves.
Closes #7103