FAILURE MAP
← Case archive

FA-13101 / Numerical aggregation / Open access

Frequency left quantile: An exact cumulative rank boundary advances to the next support value. · case 01

The reduction disagrees with its explicit aggregation oracle.

Verified by executionVariant 1 · 12 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

An exact cumulative rank boundary advances to the next support value.

VERIFIED REPAIR

Preserve the frequency left quantile contract at the identified reduction decision.

Unsuccessful approach: Adding one count also shifts nonintegral rank thresholds.

Case contract

Rows are integer [value, nonnegative frequency]; 0<=p<=q, q>0. Return the smallest supported value whose cumulative positive frequency reaches p/q of total. At p=0 return minimum positive support. No positive mass returns None.

Why this case matters

Exact bounded examples isolate a reduction defect without floating-point or external-service effects.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, p, q):
    rows=sorted((x,w) for x,w in rows if w>0)
    if not rows: return None
    total=sum(w for x,w in rows)
    threshold=Fraction(p,q)*total
    running=0
    for x,w in rows:
        running+=w
        if running>threshold: return x
    return rows[-1][0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(-8, 1), (-2, 1), (3, 1)], 2, 5)), -2)
check('regression 2', solve(*([(1, 2), (8, 5)], 1, 2)), 8)
check('regression 3', solve(*([(1, 1), (8, 2)], 2, 5)), 8)
check('regression 4', solve(*([(9, 1), (1, 3), (5, 2)], 1, 2)), 1)
check('regression 5', solve(*([(8, 0), (2, 1)], 0, 1)), 2)
check('regression 6', solve(*([], 1, 2)), None)
check('regression 7', solve(*([(1, 0), (5, 0)], 1, 2)), None)
check('regression 8', solve(*([(1, 1), (4, 2), (8, 1)], 3, 4)), 4)
check('regression 9', solve(*([(9, 4), (2, 1)], 1, 1)), 9)
check('regression 10', solve(*([(3, 2), (3, 1), (1, 1)], 1, 2)), 3)
check('regression 11', solve(*([(2, 2), (7, 2)], 1, 2)), 2)
check("variable rank",solve([(N,2),(N+4,1)],1,2),N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression 1-2-2Passed
regression 288Passed
regression 388Passed
regression 451Failed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 884Failed
regression 999Passed
regression 1033Passed
regression 1172Failed
variable rank11Passed

SHA-256 / f4441b9a1f3250e6e21b8a8027c75308821dcf7fe79b8125b62e28ba39ae7dfc

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, p, q):
    rows=sorted((x,w) for x,w in rows if w>0)
    if not rows: return None
    total=sum(w for x,w in rows)
    threshold=Fraction(p,q)*total
    running=0
    for x,w in rows:
        running+=w
        if running>=threshold+1: return x
    return rows[-1][0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(-8, 1), (-2, 1), (3, 1)], 2, 5)), -2)
check('regression 2', solve(*([(1, 2), (8, 5)], 1, 2)), 8)
check('regression 3', solve(*([(1, 1), (8, 2)], 2, 5)), 8)
check('regression 4', solve(*([(9, 1), (1, 3), (5, 2)], 1, 2)), 1)
check('regression 5', solve(*([(8, 0), (2, 1)], 0, 1)), 2)
check('regression 6', solve(*([], 1, 2)), None)
check('regression 7', solve(*([(1, 0), (5, 0)], 1, 2)), None)
check('regression 8', solve(*([(1, 1), (4, 2), (8, 1)], 3, 4)), 4)
check('regression 9', solve(*([(9, 4), (2, 1)], 1, 1)), 9)
check('regression 10', solve(*([(3, 2), (3, 1), (1, 1)], 1, 2)), 3)
check('regression 11', solve(*([(2, 2), (7, 2)], 1, 2)), 2)
check("variable rank",solve([(N,2),(N+4,1)],1,2),N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression 13-2Failed
regression 288Passed
regression 388Passed
regression 451Failed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 884Failed
regression 999Passed
regression 1033Passed
regression 1172Failed
variable rank51Failed

SHA-256 / 8c97b0d8991794a8d23a7c28801ec3e74a1d99e66f2fd6137a42ffa9531eefde

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, p, q):
    rows=sorted((x,w) for x,w in rows if w>0)
    if not rows: return None
    total=sum(w for x,w in rows)
    threshold=Fraction(p,q)*total
    running=0
    for x,w in rows:
        running+=w
        if running>=threshold: return x
    return rows[-1][0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(-8, 1), (-2, 1), (3, 1)], 2, 5)), -2)
check('regression 2', solve(*([(1, 2), (8, 5)], 1, 2)), 8)
check('regression 3', solve(*([(1, 1), (8, 2)], 2, 5)), 8)
check('regression 4', solve(*([(9, 1), (1, 3), (5, 2)], 1, 2)), 1)
check('regression 5', solve(*([(8, 0), (2, 1)], 0, 1)), 2)
check('regression 6', solve(*([], 1, 2)), None)
check('regression 7', solve(*([(1, 0), (5, 0)], 1, 2)), None)
check('regression 8', solve(*([(1, 1), (4, 2), (8, 1)], 3, 4)), 4)
check('regression 9', solve(*([(9, 4), (2, 1)], 1, 1)), 9)
check('regression 10', solve(*([(3, 2), (3, 1), (1, 1)], 1, 2)), 3)
check('regression 11', solve(*([(2, 2), (7, 2)], 1, 2)), 2)
check("variable rank",solve([(N,2),(N+4,1)],1,2),N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression 1-2-2Passed
regression 288Passed
regression 388Passed
regression 411Passed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 844Passed
regression 999Passed
regression 1033Passed
regression 1122Passed
variable rank11Passed

SHA-256 / 551bcdb223f6329978a6042ae9bafef33f637bb02ab4034980f21b6095458761

Verification & scope

Small offline integer/rational inputs only; no performance, statistical inference, or production-library conformance claim. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:39:03.583429+00:00.

Case digest / 1a57bcb0ffe7b240f37d01de3ad99dbf24eb2c467e7510be233db2a3aaeed109