Fence a demo fleet agent into its sandbox

Agent buildEasy10 min

Your task

Sales engineers lose hours babysitting demo environments. An agent manages the demo fleet, and it must be impossible for it to touch anything that is not a demo.

Write decide_fleet_actions(accounts, actions, ages_days, max_age_days): the rule your agent follows for each operation it wants to run.

  • accounts (list of str): the cloud account each operation targets.
  • actions (list of str): the operation, such as "reset".
  • ages_days (list of int): the age in days of the environment it targets.
  • max_age_days (int): the age beyond which a destroy needs a person.
  • The 3 lists have the same length, and index i is one operation. Return one decision per operation, in order: "allow", "confirm" (the owning engineer approves) or "deny".

Rules, for each operation. Names match exactly, and the first rule that matches decides:

  1. The account is not demo-sandbox: "deny".
  2. The action is not create, reset or destroy: "deny".
  3. A destroy of an environment older than max_age_days: "confirm". An age equal to max_age_days is allowed.
  4. Otherwise: "allow".

Examples

decide_fleet_actions(accounts: list[str], actions: list[str], ages_days: list[int], max_age_days: int) -> list[str]
Example 1
Inputdecide_fleet_actions(["demo-sandbox", "demo-sandbox", "prod-us-east"], ["create", "destroy", "reset"], [0, 9, 2], 7)
Output["allow", "confirm", "deny"]
Example 2
Inputdecide_fleet_actions(["demo-sandbox"], ["modify-template"], [1], 7)
Output["deny"]
Example 3
Inputdecide_fleet_actions([], [], [], 7)
Output[]