Repository navigation
|
We granted our agents broad permissions to get moving, and nobody knows which ones are used. Is there a way to check a smaller policy against what the agent really did? |
Replies: 1 comment
|
Use policy shrink. import { analyzeUsage, previewPolicyChange, suggestShrink } from "@glinr/theauth";
const since = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
const analysis = await analyzeUsage(theauth.db, agentId, { since });
const plan = suggestShrink(analysis, { minObservations: 5 });
const report = await previewPolicyChange(theauth.db, agentId, plan.keep, { since });
console.log(plan.remove, report.newlyDenied);In the repo example, 10 granted permissions had 5 unused, and replaying 496 recorded allows showed 3 newly denied. That is the line to read before applying anything. Limits:
Docs: docs/policy-shrink.mdx. |
Use policy shrink.
analyzeUsagecompares an agent's effective permissions (its own plus active delegations) with the allowed calls recorded in the audit log.suggestShrinkproposes a smaller set.previewPolicyChangereplays the recorded calls against that set and reports which would now be denied. Nothing is changed for you; you read the report and decide.