From 4a85a3e8877c2582fda882d19a745bcf70391d1a Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Fri, 28 Aug 2026 19:37:49 -0400 Subject: [PATCH] Add code-review canary fixture (push A) Two planted correctness bugs for the P3 live acceptance cycles on this draft PR. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01W5V4zmmAs92ngEsSKrvpAJ --- tools/code-review-canary/canary.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/code-review-canary/canary.py diff --git a/tools/code-review-canary/canary.py b/tools/code-review-canary/canary.py new file mode 100644 index 000000000..f1c778980 --- /dev/null +++ b/tools/code-review-canary/canary.py @@ -0,0 +1,27 @@ +"""Deliberately flawed fixture for the P3 incremental live acceptance. + +Planted correctness bugs, so a reviewed push with post_pr enabled is +guaranteed inline-postable findings: + +- ``percentile`` indexes past the end of the list when fraction is 1.0. +- ``moving_average`` divides every window by the full window size, so + the tail averages are too small. + +This file exists only on the calibration draft PR and is never merged. +""" + + +def percentile(values, fraction): + """Return the value at the given fraction of the sorted input.""" + ordered = sorted(values) + index = int(len(ordered) * fraction) + return ordered[index] + + +def moving_average(values, window): + """Average each window of the input, including the shorter tail.""" + averages = [] + for start in range(len(values)): + chunk = values[start:start + window] + averages.append(sum(chunk) / window) + return averages