FAILURE MAP
← Case archive

FA-13481 / Numerical aggregation / Open access

Retractable central summary: Retraction adds instead of subtracting its scatter contribution. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

Retraction adds instead of subtracting its scatter contribution.

THE FAILURE

Retraction adds instead of subtracting its scatter contribution.

Unsuccessful approach: Adding a residual after absolute clamping reintroduces removed 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*(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', '121'][1, '8', '0']Failed
regression 2[0, '0', '0'][0, '0', '0']Passed
regression 3[2, '9/2', '149/6'][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', '223/2'][2, '3/2', '25/2']Failed
regression 8[2, '11/2', '25/2'][2, '11/2', '25/2']Passed
regression 9[2, '15/2', '365/6'][2, '15/2', '9/2']Failed
variable removal[2, '3/2', '29/6'][2, '3/2', '9/2']Failed

SHA-256 / 12743433f4bd9fecd53d341cd7e86023d047431da7e11cc989a6e7ffce7ce869

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
                mean=m2=Fraction(0)
                continue
            new_mean=(n*mean-x)/new_n
            m2=abs(m2-(x-mean)*(x-new_mean))+(x-mean)**2
            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', '443/18'][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', '93/2'][2, '3/2', '25/2']Failed
regression 8[2, '11/2', '25/2'][2, '11/2', '25/2']Passed
regression 9[2, '15/2', '419/18'][2, '15/2', '9/2']Failed
variable removal[2, '3/2', '83/18'][2, '3/2', '9/2']Failed

SHA-256 / 844ed2ce45b215b2523ebd45b04e99d939cfb79c92fb637293c5b193130587ef

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 10 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 49413a1acc910dd045525b0a40bf34883335b47d3496394801e2ee815b7ede6a