FAILURE MAP
← Case archive

FA-13111 / Numerical aggregation / Open access

Frequency left quantile: Cumulative mass increments by one per row. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

Cumulative mass increments by one per row.

VERIFIED REPAIR

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

Unsuccessful approach: Tracking the largest frequency does not accumulate mass.

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+=1
        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 491Failed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 884Failed
regression 999Passed
regression 1033Passed
regression 1172Failed
variable rank51Failed

SHA-256 / 95eb44944fe063f568601e41a94cd458c9042aae61e8166b8250e2b635b361a6

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=max(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 13-2Failed
regression 288Passed
regression 388Passed
regression 411Passed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 884Failed
regression 999Passed
regression 1033Passed
regression 1122Passed
variable rank11Passed

SHA-256 / 117f353d5e8f01250d2bf2d73f67cdc8969f23bd070780cfaafc35ffb3e03909

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.631101+00:00.

Case digest / ec0424e8a74547768a011711fc3eb251a15807f50159d0b0c69f4ca3ca5cede3