Fence a demo fleet agent into its sandbox
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
iis 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:
- The account is not
demo-sandbox:"deny". - The action is not
create,resetordestroy:"deny". - A
destroyof an environment older thanmax_age_days:"confirm". An age equal tomax_age_daysis allowed. - Otherwise:
"allow".
Examples
decide_fleet_actions(accounts: list[str], actions: list[str], ages_days: list[int], max_age_days: int) -> list[str]Example 1
Input
decide_fleet_actions(["demo-sandbox", "demo-sandbox", "prod-us-east"], ["create", "destroy", "reset"], [0, 9, 2], 7)Output
["allow", "confirm", "deny"]Example 2
Input
decide_fleet_actions(["demo-sandbox"], ["modify-template"], [1], 7)Output
["deny"]Example 3
Input
decide_fleet_actions([], [], [], 7)Output
[]