bench(valid): a training freeze may lower the ordinary floor to the ratio; the draw takes a size

The held-out benchmark keeps the 40-commit floor and the union of twelve-commit stratified draws.
A training freeze passes floor=20 (never below the ratio) and the record carries ordinary_floor.
When the union of twelve-commit draws cannot reach the count (small cells stay unallocated on
every draw), one stratified draw of the full count is used; with count equal to the eligible
commits that is every one of them.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Marius Ciepluch
2026-10-13 18:33:10 +02:00
co-authored by Claude Fable 5.1
parent f29b3a3df2
commit bbbb0f397e
4 changed files with 54 additions and 9 deletions
+19 -4
View File
@@ -494,7 +494,20 @@ def ordinary_history(git, head: str) -> list[dict]:
return rows
def draw_ordinary(rows: list[dict], fixes: set[str], known_functions: set[tuple[str, str]], *, seed: int) -> tuple[list[dict], dict]:
ORDINARY_FLOOR = 40 # eligible ordinary commits a repository must have before one stratified draw of 12
def draw_ordinary(
rows: list[dict],
fixes: set[str],
known_functions: set[tuple[str, str]],
*,
seed: int,
floor: int = ORDINARY_FLOOR,
draws: int = 12,
) -> tuple[list[dict], dict]:
"""One stratified draw of ``draws`` ordinary commits (time third x size bucket, proportional, at least one per
third). ``draws`` equal to the eligible count takes every eligible commit, cell by cell."""
import random
from collections import Counter, defaultdict
@@ -505,7 +518,9 @@ def draw_ordinary(rows: list[dict], fixes: set[str], known_functions: set[tuple[
counts[reason or "eligible"] += 1
if reason is None:
eligible.append(row)
if len(eligible) < 40:
if floor < 12 or draws < 12:
raise ValueError("the ordinary floor and draw size cannot be below one draw of 12")
if len(eligible) < max(floor, draws):
failure = Rejected("ordinary_floor")
failure.counts = dict(counts)
raise failure
@@ -523,11 +538,11 @@ def draw_ordinary(rows: list[dict], fixes: set[str], known_functions: set[tuple[
# Largest-deficit rounding with the mandatory minimum of one per time third.
# No cell can receive more draws than it has eligible commits.
allocation = Counter()
targets = {cell: 12 * len(items) / len(eligible) for cell, items in cells.items()}
targets = {cell: draws * len(items) / len(eligible) for cell, items in cells.items()}
for third in range(3):
cell = max(sorted(c for c in cells if c[0] == third), key=lambda c: targets[c])
allocation[cell] = 1
while sum(allocation.values()) < 12:
while sum(allocation.values()) < draws:
cell = max(sorted(c for c in cells if allocation[c] < len(cells[c])), key=lambda c: targets[c] - allocation[c])
allocation[cell] += 1
rng = random.Random(seed)