Standard library only · runs in your browser
The agent's new prompt goes to 10% of traffic. Twenty minutes in, the canary has 30 errors and production has 100. Someone says the canary looks fine, since it has fewer errors. Someone else wants to roll back. Settle it with a rule you'd use every time, not a feeling.
Each side is {"requests": int, "errors": int, "p95_ms": number}.
Write canary_decision(control, canary, min_requests=500, enough_requests=2000, z_threshold=2.33, latency_ratio_limit=1.2):
min_requests → {"decision": "keep_waiting", "z": None}.z_threshold → rollback.latency_ratio_limit × control p95 → rollback.enough_requests → promote. Otherwise → keep_waiting.Return {"decision": ..., "z": z}.
canary_decision(control: dict, canary: dict, ...) -> dict