FAILURE MAP
← Case archive

FA-13096 / Numerical aggregation / Open access

Frequency left quantile: Weighted rank walks unsorted observations. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

Weighted rank walks unsorted observations.

VERIFIED REPAIR

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

Unsuccessful approach: Sorting by frequency does not order the value support.

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=[(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 929Failed
regression 1033Passed
regression 1122Passed
variable rank11Passed

SHA-256 / 7c0a1807b82dbe5ee9b083027ff8f0b94e2a78f0ffcf91e4362440d574a0a0b2

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),key=lambda r:r[1])
    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 844Passed
regression 999Passed
regression 1013Failed
regression 1122Passed
variable rank11Passed

SHA-256 / bef48ab1899735b8d1ba493d5236b4f1d2e0601431b93cb3e6844c75ef34da5f

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

Case digest / 64b9ce5f46bf5c17419846d0509e950b8a1a8fed03843ec7ea9f2212dc5f0dba