bugger.
RL environments/Pythonhardrl-release-gate-v1
IMPLEMENTATION LAB

Decide whether a policy is ready for a canary

Implement release gates that combine task quality, timeouts, latency, and fallback evidence.

RL Environments

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

01 The slower candidate misses its latency budget
{"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"]}
02 Empty coverage holds the rollout
{"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"]}
03 Equality at the success and latency gates passes
{"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.

    Run the examples, then submit to check the full contract.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.