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

opened this

Merged 39d 8h ago, 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.

Notes

opened this

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_USD are each invalid_amount from both actions. A valid amount is stored rounded to cents. The boundaries 0.01 and the cap are accepted, and null clears 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 is not_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.

Closes #7103

commented

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_USD are each invalid_amount from both actions. A valid amount is stored rounded to cents. The boundaries 0.01 and the cap are accepted, and null clears 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 is not_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.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs