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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W5V4zmmAs92ngEsSKrvpAJ
This commit is contained in:
Bryan Helmkamp 2026-08-28 19:37:49 -04:00
parent a1e85a1dc5
commit 4a85a3e887
No known key found for this signature in database

View file

@ -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