Incident freeze that pauses agent autonomy
Your task
When an incident is open, the on-call team wants the platform's agents to stop changing things on their own until the dust settles. The freeze is driven by the incident log and applied to each agent action as it is requested.
Write freeze_decisions(events). events is a list in time order (whole minutes, never decreasing) of three kinds of event:
["open", t, incident_id, severity, services]: an incident opens.severityis 1, 2 or 3, andservicesis a list of service names.["close", t, incident_id]: the incident closes.["act", t, service, kind]: an agent asks to act onservice.kindis"read","write"or"destructive".
Return one decision per "act" event, in order: "run", "approve" (hold the action until a human approves it) or "block".
When a service is frozen
- A severity 1 incident freezes every service, whatever its list says. A severity 2 incident freezes only the services it lists. A severity 3 incident freezes nothing.
- An incident freezes from its open event until 30 minutes after it closes: an incident closed at minute
cstill freezes an action at minutetwhent < c + 30. An incident that never closes freezes for good. - A close for an incident that is not open (never opened, or already closed) is ignored. Incident ids are never reused.
- Events that share a minute take effect in list order: an incident opened earlier in the list, in the same minute, already freezes the action.
What happens to the action
| kind | service not frozen | service frozen |
|---|---|---|
| read | "run" | "run" |
| write | "run" | "approve" |
| destructive | "approve" | "block" |
Service names are compared exactly, case included.
Examples:
freeze_decisions([["open", 0, "INC-1", 2, ["billing"]], ["act", 5, "billing", "write"], ["act", 5, "search", "write"], ["close", 10, "INC-1"], ["act", 39, "billing", "destructive"], ["act", 40, "billing", "destructive"]])returns["approve", "run", "block", "approve"]. Search was never part of INC-1, and by minute 40 the 30 minutes after the close are over.freeze_decisions([["open", 3, "INC-7", 1, []], ["act", 3, "auth", "read"], ["act", 4, "auth", "write"]])returns["run", "approve"].
Examples
freeze_decisions(events: list[list]) -> list[str]Example 1
Input
freeze_decisions([["open", 0, "INC-1", 2, ["billing"]], ["act", 5, "billing", "write"], ["act", 5, "search", "write"], ["close", 10, "INC-1"], ["act", 39, "billing", "destructive"], ["act", 40, "billing", "destructive"]])Output
["approve", "run", "block", "approve"]Example 2
Input
freeze_decisions([["open", 3, "INC-7", 1, []], ["act", 3, "auth", "read"], ["act", 4, "auth", "write"]])Output
["run", "approve"]