Decide which access requests an agent may approve

Agent buildEasy10 minMicrosoft style

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 i in 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:

  1. The environment is not dev, staging or sandbox: "human_review".
  2. The scope is not read-logs, read-metrics or sandbox-deploy: "human_review".
  3. The scope is not in that request's peer_scopes: "human_review".
  4. The duration is below 1 or above max_auto_days: "human_review".
  5. 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
Inputtriage_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
Inputtriage_access_requests(["read-logs"], ["staging"], [0], [["read-logs"]], 7)
Output["human_review"]
Example 3
Inputtriage_access_requests([], [], [], [], 7)
Output[]