FAILURE MAP
← Case archive

FA-13491 / Numerical aggregation / Open access

Retractable central summary: The state resets when one surviving observation still remains. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

The state resets when one surviving observation still remains.

VERIFIED REPAIR

Preserve the retractable central summary contract at the identified reduction decision.

Unsuccessful approach: Restoring the boundary but clearing only scatter leaves the deleted mean in the empty state.

Case contract

Process add/remove integer observations; each removal names one active equal-valued observation. Maintain [count, exact mean, unnormalised squared central scatter]. Empty state is [0,"0","0"].

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(events):
    n=0
    mean=m2=Fraction(0)
    for op,x in events:
        if op=="add":
            new_n=n+1
            delta=x-mean
            new_mean=mean+delta/new_n
            m2+=delta*(x-new_mean)
            mean=new_mean
            n=new_n
        else:
            new_n=n-1
            if new_n<=1:
                n=0
                mean=m2=Fraction(0)
                continue
            new_mean=(n*mean-x)/new_n
            m2-=(x-mean)*(x-new_mean)
            mean=new_mean
            n=new_n
    return [n,str(mean),str(m2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', -3), ('add', 8), ('remove', -3)],)), [1, '8', '0'])
check('regression 2', solve(*([('add', 6), ('remove', 6)],)), [0, '0', '0'])
check('regression 3', solve(*([('add', 1), ('add', 4), ('add', 8), ('remove', 4)],)), [2, '9/2', '49/2'])
check('regression 4', solve(*([('add', -5), ('remove', -5), ('add', 9)],)), [1, '9', '0'])
check('regression 5', solve(*([],)), [0, '0', '0'])
check('regression 6', solve(*([('add', 2), ('add', 2), ('remove', 2)],)), [1, '2', '0'])
check('regression 7', solve(*([('add', 0), ('add', 4), ('add', 9), ('add', -1), ('remove', 0), ('remove', 9)],)), [2, '3/2', '25/2'])
check('regression 8', solve(*([('add', 3), ('add', 8)],)), [2, '11/2', '25/2'])
check('regression 9', solve(*([('add', 1), ('add', 6), ('add', 9), ('remove', 1)],)), [2, '15/2', '9/2'])
check("variable removal",solve([("add",0),("add",N),("add",3*N),("remove",N)]),[2,str(Fraction(3*N,2)),str(Fraction(9*N*N,2))])
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[0, '0', '0'][1, '8', '0']Failed
regression 2[0, '0', '0'][0, '0', '0']Passed
regression 3[2, '9/2', '49/2'][2, '9/2', '49/2']Passed
regression 4[1, '9', '0'][1, '9', '0']Passed
regression 5[0, '0', '0'][0, '0', '0']Passed
regression 6[0, '0', '0'][1, '2', '0']Failed
regression 7[2, '3/2', '25/2'][2, '3/2', '25/2']Passed
regression 8[2, '11/2', '25/2'][2, '11/2', '25/2']Passed
regression 9[2, '15/2', '9/2'][2, '15/2', '9/2']Passed
variable removal[2, '3/2', '9/2'][2, '3/2', '9/2']Passed

SHA-256 / 7966395a2ff95d1d156da4fb0951843981c23241d33a14d86a3126e4dbf693f0

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(events):
    n=0
    mean=m2=Fraction(0)
    for op,x in events:
        if op=="add":
            new_n=n+1
            delta=x-mean
            new_mean=mean+delta/new_n
            m2+=delta*(x-new_mean)
            mean=new_mean
            n=new_n
        else:
            new_n=n-1
            if new_n==0:
                n=0
                m2=Fraction(0)
                continue
            new_mean=(n*mean-x)/new_n
            m2-=(x-mean)*(x-new_mean)
            mean=new_mean
            n=new_n
    return [n,str(mean),str(m2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', -3), ('add', 8), ('remove', -3)],)), [1, '8', '0'])
check('regression 2', solve(*([('add', 6), ('remove', 6)],)), [0, '0', '0'])
check('regression 3', solve(*([('add', 1), ('add', 4), ('add', 8), ('remove', 4)],)), [2, '9/2', '49/2'])
check('regression 4', solve(*([('add', -5), ('remove', -5), ('add', 9)],)), [1, '9', '0'])
check('regression 5', solve(*([],)), [0, '0', '0'])
check('regression 6', solve(*([('add', 2), ('add', 2), ('remove', 2)],)), [1, '2', '0'])
check('regression 7', solve(*([('add', 0), ('add', 4), ('add', 9), ('add', -1), ('remove', 0), ('remove', 9)],)), [2, '3/2', '25/2'])
check('regression 8', solve(*([('add', 3), ('add', 8)],)), [2, '11/2', '25/2'])
check('regression 9', solve(*([('add', 1), ('add', 6), ('add', 9), ('remove', 1)],)), [2, '15/2', '9/2'])
check("variable removal",solve([("add",0),("add",N),("add",3*N),("remove",N)]),[2,str(Fraction(3*N,2)),str(Fraction(9*N*N,2))])
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[1, '8', '0'][1, '8', '0']Passed
regression 2[0, '6', '0'][0, '0', '0']Failed
regression 3[2, '9/2', '49/2'][2, '9/2', '49/2']Passed
regression 4[1, '9', '0'][1, '9', '0']Passed
regression 5[0, '0', '0'][0, '0', '0']Passed
regression 6[1, '2', '0'][1, '2', '0']Passed
regression 7[2, '3/2', '25/2'][2, '3/2', '25/2']Passed
regression 8[2, '11/2', '25/2'][2, '11/2', '25/2']Passed
regression 9[2, '15/2', '9/2'][2, '15/2', '9/2']Passed
variable removal[2, '3/2', '9/2'][2, '3/2', '9/2']Passed

SHA-256 / 6287991ce5c390f569d3b6755b6bdd94a877903622868e19adc70197ecc86f48

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(events):
    n=0
    mean=m2=Fraction(0)
    for op,x in events:
        if op=="add":
            new_n=n+1
            delta=x-mean
            new_mean=mean+delta/new_n
            m2+=delta*(x-new_mean)
            mean=new_mean
            n=new_n
        else:
            new_n=n-1
            if new_n==0:
                n=0
                mean=m2=Fraction(0)
                continue
            new_mean=(n*mean-x)/new_n
            m2-=(x-mean)*(x-new_mean)
            mean=new_mean
            n=new_n
    return [n,str(mean),str(m2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', -3), ('add', 8), ('remove', -3)],)), [1, '8', '0'])
check('regression 2', solve(*([('add', 6), ('remove', 6)],)), [0, '0', '0'])
check('regression 3', solve(*([('add', 1), ('add', 4), ('add', 8), ('remove', 4)],)), [2, '9/2', '49/2'])
check('regression 4', solve(*([('add', -5), ('remove', -5), ('add', 9)],)), [1, '9', '0'])
check('regression 5', solve(*([],)), [0, '0', '0'])
check('regression 6', solve(*([('add', 2), ('add', 2), ('remove', 2)],)), [1, '2', '0'])
check('regression 7', solve(*([('add', 0), ('add', 4), ('add', 9), ('add', -1), ('remove', 0), ('remove', 9)],)), [2, '3/2', '25/2'])
check('regression 8', solve(*([('add', 3), ('add', 8)],)), [2, '11/2', '25/2'])
check('regression 9', solve(*([('add', 1), ('add', 6), ('add', 9), ('remove', 1)],)), [2, '15/2', '9/2'])
check("variable removal",solve([("add",0),("add",N),("add",3*N),("remove",N)]),[2,str(Fraction(3*N,2)),str(Fraction(9*N*N,2))])
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[1, '8', '0'][1, '8', '0']Passed
regression 2[0, '0', '0'][0, '0', '0']Passed
regression 3[2, '9/2', '49/2'][2, '9/2', '49/2']Passed
regression 4[1, '9', '0'][1, '9', '0']Passed
regression 5[0, '0', '0'][0, '0', '0']Passed
regression 6[1, '2', '0'][1, '2', '0']Passed
regression 7[2, '3/2', '25/2'][2, '3/2', '25/2']Passed
regression 8[2, '11/2', '25/2'][2, '11/2', '25/2']Passed
regression 9[2, '15/2', '9/2'][2, '15/2', '9/2']Passed
variable removal[2, '3/2', '9/2'][2, '3/2', '9/2']Passed

SHA-256 / 934603062c82331399a360a442923d58c38e14789ee6f7fbc7fe7e8ec85b9813

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

Case digest / c7d8213717e977c1f11b10e66a09ffca5c6b420895613b4d168c43604afa21af