FAILURE MAP
← Case archive

FA-13461 / Numerical aggregation / Open access

Retractable central summary: Insertion squares the old-center residual instead of multiplying old and new residuals. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

Insertion squares the old-center residual instead of multiplying old and new residuals.

VERIFIED REPAIR

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

Unsuccessful approach: Using only the new residual instead undercounts insertion scatter.

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*delta
            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', '139/2'][1, '8', '0']Failed
regression 2[0, '0', '0'][0, '0', '0']Passed
regression 3[2, '9/2', '481/12'][2, '9/2', '49/2']Failed
regression 4[1, '9', '81'][1, '9', '0']Failed
regression 5[0, '0', '0'][0, '0', '0']Passed
regression 6[1, '2', '4'][1, '2', '0']Failed
regression 7[2, '3/2', '791/18'][2, '3/2', '25/2']Failed
regression 8[2, '11/2', '34'][2, '11/2', '25/2']Failed
regression 9[2, '15/2', '337/12'][2, '15/2', '9/2']Failed
variable removal[2, '3/2', '85/12'][2, '3/2', '9/2']Failed

SHA-256 / 9912630ce38877ebeb866dc66d88d9de23c9ff3b06d5594cd7691b761a467039

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+=(x-new_mean)**2
            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', '-121/4'][1, '8', '0']Failed
regression 2[0, '0', '0'][0, '0', '0']Passed
regression 3[2, '9/2', '559/36'][2, '9/2', '49/2']Failed
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', '-139/18'][2, '3/2', '25/2']Failed
regression 8[2, '11/2', '25/4'][2, '11/2', '25/2']Failed
regression 9[2, '15/2', '-305/36'][2, '15/2', '9/2']Failed
variable removal[2, '3/2', '103/36'][2, '3/2', '9/2']Failed

SHA-256 / 0055991d2032421cbde1906d7164e56ea77376b9b069e3f8eb77528760679e98

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

Case digest / 08e4bab9c7b36bff1fc596943ff783c8d2b5e06de625635cae1a5e3208bbffdf