FA-166 / Storage and queries / Open access
Updating a materialized summary adds the replacement without removing the old value · case 01
A materialized total accumulates superseded row values, while an attempted repair also counts updates as new rows.
ROOT CAUSE
A row replacement is treated as an insertion rather than a signed old/new contribution to an existing view.
VERIFIED REPAIR
Apply new-minus-old to the total and insertion-minus-deletion to row count, using presence tests that retain numeric zero.
Unsuccessful approach: Subtracting the old value repairs the sum but incrementing count for every new value still inflates row count on updates.
Case contract
Given a valid starting [sum,row_count] and an ordered list of [old_value,new_value] changes, return the updated pair. None means the row is absent, not a nullable stored value. Changes are valid and applied exactly once; no deduplication is requested.
Why this case matters
Models incremental maintenance of a materialized aggregate under insert, delete and replacement operations. It separates sum deltas from cardinality deltas and does not model concurrent lost updates or transaction replay.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(total, count, changes):
for old, new in changes:
if new is not None:
total += new
count += 1
return [total, count]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes sum but not row count', solve(N, 1, [[N, 3*N]]), [3*N, 1])
check('deleting the last row', solve(N, 1, [[N, None]]), [0, 0])
check('insertion creates a row', solve(0, 0, [[None, N]]), [N, 1])
check('zero is a present row value', solve(0, 1, [[0, N], [N, 0]]), [0, 1])
check('multiple replacements of the same row', solve(N, 1, [[N, N+1], [N+1, -N]]), [-N, 1])
check('insert and delete a zero row', solve(N, 1, [[None, 0], [0, None]]), [N, 1])
check('no changes preserve the original view', solve(2*N, 2, []), [2*N, 2])
check('different row operations compose', solve(3*N, 2, [[N, None], [2*N, 4*N], [None, -N]]), [3*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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| replacement changes sum but not row count | [4, 2] | [3, 1] | Failed |
| deleting the last row | [1, 1] | [0, 0] | Failed |
| insertion creates a row | [1, 1] | [1, 1] | Passed |
| zero is a present row value | [1, 3] | [0, 1] | Failed |
| multiple replacements of the same row | [2, 3] | [-1, 1] | Failed |
| insert and delete a zero row | [1, 2] | [1, 1] | Failed |
| no changes preserve the original view | [2, 2] | [2, 2] | Passed |
| different row operations compose | [6, 4] | [3, 2] | Failed |
SHA-256 / fe67354d892cb33252a0a50aeec5b3b5394152ecedea2295824af15fe97a36cc
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(total, count, changes):
for old, new in changes:
total += (new if new is not None else 0) - (old if old is not None else 0)
if new is not None:
count += 1
elif old is not None:
count -= 1
return [total, count]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes sum but not row count', solve(N, 1, [[N, 3*N]]), [3*N, 1])
check('deleting the last row', solve(N, 1, [[N, None]]), [0, 0])
check('insertion creates a row', solve(0, 0, [[None, N]]), [N, 1])
check('zero is a present row value', solve(0, 1, [[0, N], [N, 0]]), [0, 1])
check('multiple replacements of the same row', solve(N, 1, [[N, N+1], [N+1, -N]]), [-N, 1])
check('insert and delete a zero row', solve(N, 1, [[None, 0], [0, None]]), [N, 1])
check('no changes preserve the original view', solve(2*N, 2, []), [2*N, 2])
check('different row operations compose', solve(3*N, 2, [[N, None], [2*N, 4*N], [None, -N]]), [3*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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| replacement changes sum but not row count | [3, 2] | [3, 1] | Failed |
| deleting the last row | [0, 0] | [0, 0] | Passed |
| insertion creates a row | [1, 1] | [1, 1] | Passed |
| zero is a present row value | [0, 3] | [0, 1] | Failed |
| multiple replacements of the same row | [-1, 3] | [-1, 1] | Failed |
| insert and delete a zero row | [1, 1] | [1, 1] | Passed |
| no changes preserve the original view | [2, 2] | [2, 2] | Passed |
| different row operations compose | [3, 3] | [3, 2] | Failed |
SHA-256 / b8b9b2a2cad72534583871f577079766e46277ca6e94eaca2bbf9e7473da3dbc
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(total, count, changes):
for old, new in changes:
total += (new if new is not None else 0) - (old if old is not None else 0)
count += int(new is not None) - int(old is not None)
return [total, count]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes sum but not row count', solve(N, 1, [[N, 3*N]]), [3*N, 1])
check('deleting the last row', solve(N, 1, [[N, None]]), [0, 0])
check('insertion creates a row', solve(0, 0, [[None, N]]), [N, 1])
check('zero is a present row value', solve(0, 1, [[0, N], [N, 0]]), [0, 1])
check('multiple replacements of the same row', solve(N, 1, [[N, N+1], [N+1, -N]]), [-N, 1])
check('insert and delete a zero row', solve(N, 1, [[None, 0], [0, None]]), [N, 1])
check('no changes preserve the original view', solve(2*N, 2, []), [2*N, 2])
check('different row operations compose', solve(3*N, 2, [[N, None], [2*N, 4*N], [None, -N]]), [3*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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| replacement changes sum but not row count | [3, 1] | [3, 1] | Passed |
| deleting the last row | [0, 0] | [0, 0] | Passed |
| insertion creates a row | [1, 1] | [1, 1] | Passed |
| zero is a present row value | [0, 1] | [0, 1] | Passed |
| multiple replacements of the same row | [-1, 1] | [-1, 1] | Passed |
| insert and delete a zero row | [1, 1] | [1, 1] | Passed |
| no changes preserve the original view | [2, 2] | [2, 2] | Passed |
| different row operations compose | [3, 2] | [3, 2] | Passed |
SHA-256 / ab647e90d4035d9832f149ad7f853c57358fa930e3f2b35c7c6bdb64631ce7c0
Verification & scope
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:36:51.007172+00:00.
Case digest / a8afac4131aacffb09c5f9ff2c21be817dfdbc990b0bb2fd4dcf4199f8066b54