Arsh Shah

Day 3: Grant check, a tiny permission checker for agents

Lab · · Demo

I keep saying being logged in isn't the same as being allowed. Today I wrote the check instead of the sentence.

Grant check takes two pieces of JSON. One's the grant: what a person said an agent may do. The other's the action the agent wants to take. It tells you allowed or denied, and why.

It checks six things:

The whole thing is one pure function, about 25 lines, and it runs in your browser. Nothing gets sent anywhere.

if (!acts.includes(action.action)) deny(`Action "${action.action}" isn't in the grant`);
if (spent + action.amount > grant.budget) deny(`Would bring total spend to ${spent + action.amount}`);

Click "logged in, no grant" and it says no. That's the default I want.

What I learned: every field I added was a question nobody'd asked the person yet. Who's the merchant? What's the cap? When does this stop?