Decide which access requests an agent may approve
Your task
Your security team drowns in access requests, and most of them are routine. An agent may approve one narrow, pre-approved class of request on its own. Everything else goes to a security engineer, even the requests it would deny.
Write triage_access_requests(scopes, environments, durations_days, peer_scopes, max_auto_days): the rule your agent follows for each request.
scopes(list of str): the permission each request asks for, such as"read-logs".environments(list of str): the environment it applies to.durations_days(list of int): how many days the access should last.peer_scopes(list of list of str): for each request, the scopes the requester's peers already hold.max_auto_days(int): the longest duration the agent may approve.- Index
iin each list is one request. Return one decision per request, in order:"auto_approve"or"human_review".
Rules, for each request. Names match exactly, so case matters, and the first rule that matches decides:
- The environment is not
dev,stagingorsandbox:"human_review". - The scope is not
read-logs,read-metricsorsandbox-deploy:"human_review". - The scope is not in that request's
peer_scopes:"human_review". - The duration is below 1 or above
max_auto_days:"human_review". - Otherwise:
"auto_approve".
Then, in a sentence or two: why does the agent send even clear denials to a person instead of denying them itself?
Examples
triage_access_requests(scopes: list[str], environments: list[str], durations_days: list[int], peer_scopes: list[list[str]], max_auto_days: int) -> list[str]Example 1
Input
triage_access_requests(["read-logs", "prod-admin", "read-metrics"], ["staging", "production", "dev"], [3, 3, 3], [["read-logs", "read-metrics"], ["read-logs"], ["read-logs"]], 7)Output
["auto_approve", "human_review", "human_review"]Example 2
Input
triage_access_requests(["read-logs"], ["staging"], [0], [["read-logs"]], 7)Output
["human_review"]Example 3
Input
triage_access_requests([], [], [], [], 7)Output
[]