PythiloLesson 12 of 12 · progress kept in this browser

Practice in Lab: Project: make a replay-safe, cohort-aware rollout monitor →

Project: make a replay-safe, cohort-aware rollout monitor

A rollout can improve an average while harming a small cohort or relying on labels not yet observed. This project joins delayed outcomes, requires per-cohort evidence and maintains a conservative decision state across windows. Two consecutive sufficiently observed regressions latch rollback; an incomplete window holds and breaks the bad-window streak. Payload identity makes a repeated monitoring window idempotent while rejecting changed evidence under the same identity. State is a local immutable-value contract: durable storage, concurrent writers and an actual traffic switch remain production responsibilities.

baseline, candidate, outcome = .1, .9, 0
brier_delta = (candidate-outcome)**2-(baseline-outcome)**2
print(round(brier_delta, 4))
print('regression' if brier_delta>.05 else 'within tolerance')
Your task

Predictions have unique id,cohort,baseline,candidate probabilities; outcomes have unique id,binary integer y,finite available. Pair only outcomes available<=finite asof. For every predicted cohort compute count and mean(candidate squared error - baseline squared error). A window has enough evidence only if every cohort reaches positive integer min_pairs. It is bad if sufficient and any cohort delta>nonnegative finite tolerance. Track consecutive bad windows, resetting on all other windows; rollback after two and latch rollback forever. Otherwise return continue for sufficient good evidence, hold otherwise. Window is a nonnegative increasing integer; identical canonical payload replay returns copied state, conflicting or older windows raise ValueError. Never mutate input state.

All lessons