Decide whether a policy is ready for a canary
Implement release gates that combine task quality, timeouts, latency, and fallback evidence.
Your task
Input contains episodes (each with status success, failure, or timeout, and nonnegative step_ms), positive min_episodes, success and timeout thresholds as integer percentages from 0 to 100, max_step_p95_ms, and booleans regressions_pass and fallback_pass. Count every episode in both rate denominators. An empty run has no latency or rate evidence.
Return decision (advance when no rule fails, otherwise hold) and reasons in this exact order: regression when regressions_pass is false, fallback when fallback_pass is false, coverage when episode count is below min_episodes, success_rate when a nonempty run falls below min_success_pct, timeout_rate when it exceeds max_timeout_pct, and latency when p95 step_ms exceeds max_step_p95_ms. Use the nearest-rank p95: in ascending order select the ceil(0.95 × count)-th element, counting from one. Equal thresholds pass.
Expected behavior
A rollout advances only when it has enough data and every declared release gate passes. Keep all failed gate reasons.
Examples
{"episodes":[{"status":"success","step_ms":10},{"status":"success","step_ms":101}],"min_episodes":2,"min_success_pct":50,"max_timeout_pct":25,"max_step_p95_ms":100,"regressions_pass":true,"fallback_pass":true}{"decision":"hold","reasons":["latency"]}{"episodes":[],"min_episodes":2,"min_success_pct":50,"max_timeout_pct":25,"max_step_p95_ms":100,"regressions_pass":true,"fallback_pass":true}{"decision":"hold","reasons":["coverage"]}{"episodes":[{"status":"success","step_ms":100},{"status":"failure","step_ms":10}],"min_episodes":2,"min_success_pct":50,"max_timeout_pct":25,"max_step_p95_ms":100,"regressions_pass":true,"fallback_pass":true}{"decision":"advance","reasons":[]}Before you begin
- Python functions, lists, and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.