Decide when error budget burn warrants a freeze
Your task
An agent watches each service's error budget burn rate: how fast the service is spending its allowed errors, where 1 means exactly on budget. A short window catches spikes and a long window catches sustained burn, and the agent must not cry wolf on one noisy reading.
Write burn_rate_decision(samples, fast_window, slow_window, fast_threshold, slow_threshold): the rule your agent follows on each check.
samples(list of float): burn-rate readings, oldest first, newest last.fast_window,slow_window(int): how many of the newest readings each window averages.fast_threshold,slow_threshold(float): the average each window must reach to count as hot.- Return
"recommend_freeze","page_owner","no_action"or"insufficient_data".
Rules, in order:
- If either window is below 1, or
slow_windowis smaller thanfast_window:"insufficient_data". - If there are fewer readings than
slow_window:"insufficient_data". - Average the last
fast_windowreadings and the lastslow_windowreadings. A window is hot when its average is at least its threshold. - Both windows hot:
"recommend_freeze". - Only the fast window hot:
"page_owner". - Otherwise, including a hot slow window with a cool fast one:
"no_action".
Then, in a sentence or two: should the agent freeze releases on its own, or only recommend a freeze? Take a side.
Examples
burn_rate_decision(samples: list[float], fast_window: int, slow_window: int, fast_threshold: float, slow_threshold: float) -> strExample 1
Input
burn_rate_decision([6, 8, 10, 12, 14, 16], 2, 6, 6, 3)Output
"recommend_freeze"Example 2
Input
burn_rate_decision([0.5, 0.5, 0.5, 0.5, 9, 11], 2, 6, 6, 3)Output
"recommend_freeze"Example 3
Input
burn_rate_decision([0.5, 0.75, 0.5, 1, 0.5, 0.25], 2, 6, 6, 3)Output
"no_action"