{"abstract":"A group made of individually small contributions disappears even though its total meets the reporting threshold.","category":"Storage and queries","checks":7,"contract":"Rows are [group_string,signed_integer_amount]. Return a map of existing groups to their full sum, keeping groups whose sum is >= threshold. Never invent groups for empty input; negative contributions must participate before filtering.","evaluation_group":"xs-group-total-filter","failed_approach":"Moving the filter after aggregation but making it strictly greater still omits groups exactly at the contract's threshold.","family":"store-aggregate-filter-placement","id":"FA-146","implementations":{"attempt":{"sha256":"be634c07c4f50e1d971e9d1276f8d6fd748a0bc49829aaf199223b75ced472af","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows, threshold):\n    totals = {}\n    for group, amount in rows:\n        totals[group] = totals.get(group, 0) + amount\n    return {group: total for group, total in totals.items() if total > threshold}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('small contributions jointly qualify', solve([['a', N], ['a', N]], 2*N), {'a': 2*N})\ncheck('exact single contribution qualifies', solve([['a', 3*N]], 3*N), {'a': 3*N})\ncheck('negative adjustment changes eligibility', solve([['a', 4*N], ['a', -3*N]], 2*N), {})\ncheck('group-specific totals do not mingle', solve([['a', N], ['b', 5*N], ['a', 2*N]], 3*N), {'a': 3*N, 'b': 5*N})\ncheck('below-threshold completed group', solve([['a', N], ['a', -1]], N), {})\ncheck('zero threshold retains a real cancelling group', solve([['a', N], ['a', -N]], 0), {'a': 0})\ncheck('empty relation does not invent a zero group', solve([], 0), {})\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"1d5027bce9f02fbb8d3259b81de335979a3c040eba9523c6cdb0353f6a9068b3","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows, threshold):\n    totals = {}\n    for group, amount in rows:\n        if amount >= threshold:\n            totals[group] = totals.get(group, 0) + amount\n    return totals\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('small contributions jointly qualify', solve([['a', N], ['a', N]], 2*N), {'a': 2*N})\ncheck('exact single contribution qualifies', solve([['a', 3*N]], 3*N), {'a': 3*N})\ncheck('negative adjustment changes eligibility', solve([['a', 4*N], ['a', -3*N]], 2*N), {})\ncheck('group-specific totals do not mingle', solve([['a', N], ['b', 5*N], ['a', 2*N]], 3*N), {'a': 3*N, 'b': 5*N})\ncheck('below-threshold completed group', solve([['a', N], ['a', -1]], N), {})\ncheck('zero threshold retains a real cancelling group', solve([['a', N], ['a', -N]], 0), {'a': 0})\ncheck('empty relation does not invent a zero group', solve([], 0), {})\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"eecd14c2c915f7f63d9d3a3f7558c1599fff84ec0bf51db078f59c6128333ab5","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows, threshold):\n    totals = {}\n    for group, amount in rows:\n        totals[group] = totals.get(group, 0) + amount\n    return {group: total for group, total in totals.items() if total >= threshold}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('small contributions jointly qualify', solve([['a', N], ['a', N]], 2*N), {'a': 2*N})\ncheck('exact single contribution qualifies', solve([['a', 3*N]], 3*N), {'a': 3*N})\ncheck('negative adjustment changes eligibility', solve([['a', 4*N], ['a', -3*N]], 2*N), {})\ncheck('group-specific totals do not mingle', solve([['a', N], ['b', 5*N], ['a', 2*N]], 3*N), {'a': 3*N, 'b': 5*N})\ncheck('below-threshold completed group', solve([['a', N], ['a', -1]], N), {})\ncheck('zero threshold retains a real cancelling group', solve([['a', N], ['a', -N]], 0), {'a': 0})\ncheck('empty relation does not invent a zero group', solve([], 0), {})\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":" 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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"store-aggregate-filter-placement","generated_at":"2026-09-29T14:36:50.983275+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A deterministic model of WHERE versus HAVING placement and inclusive reporting thresholds. It exercises query rewriting correctness when filters do not commute with aggregation, including signed adjustments.","repair":"Sum all signed contributions per group, then retain groups whose completed aggregate is at least the threshold.","root_cause":"An aggregate eligibility rule is pushed down to individual rows before grouping, changing the relation being summed.","sha256":"8c32280b5bd57598109939cacd9320b3d630abd2c50732dc14fa906979aecb98","title":"A row filter removes contributions before a group threshold is evaluated · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":34.356,"exit_code":1,"observations":[{"actual":{},"check":"small contributions jointly qualify","expected":{"a":2},"passed":false},{"actual":{},"check":"exact single contribution qualifies","expected":{"a":3},"passed":false},{"actual":{},"check":"negative adjustment changes eligibility","expected":{},"passed":true},{"actual":{"b":5},"check":"group-specific totals do not mingle","expected":{"a":3,"b":5},"passed":false},{"actual":{},"check":"below-threshold completed group","expected":{},"passed":true},{"actual":{},"check":"zero threshold retains a real cancelling group","expected":{"a":0},"passed":false},{"actual":{},"check":"empty relation does not invent a zero group","expected":{},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"small contributions jointly qualify\", \"actual\": {}, \"expected\": {\"a\": 2}, \"passed\": false}, {\"check\": \"exact single contribution qualifies\", \"actual\": {}, \"expected\": {\"a\": 3}, \"passed\": false}, {\"check\": \"negative adjustment changes eligibility\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"group-specific totals do not mingle\", \"actual\": {\"b\": 5}, \"expected\": {\"a\": 3, \"b\": 5}, \"passed\": false}, {\"check\": \"below-threshold completed group\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"zero threshold retains a real cancelling group\", \"actual\": {}, \"expected\": {\"a\": 0}, \"passed\": false}, {\"check\": \"empty relation does not invent a zero group\", \"actual\": {}, \"expected\": {}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":32.524,"exit_code":1,"observations":[{"actual":{},"check":"small contributions jointly qualify","expected":{"a":2},"passed":false},{"actual":{"a":3},"check":"exact single contribution qualifies","expected":{"a":3},"passed":true},{"actual":{"a":4},"check":"negative adjustment changes eligibility","expected":{},"passed":false},{"actual":{"b":5},"check":"group-specific totals do not mingle","expected":{"a":3,"b":5},"passed":false},{"actual":{"a":1},"check":"below-threshold completed group","expected":{},"passed":false},{"actual":{"a":1},"check":"zero threshold retains a real cancelling group","expected":{"a":0},"passed":false},{"actual":{},"check":"empty relation does not invent a zero group","expected":{},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"small contributions jointly qualify\", \"actual\": {}, \"expected\": {\"a\": 2}, \"passed\": false}, {\"check\": \"exact single contribution qualifies\", \"actual\": {\"a\": 3}, \"expected\": {\"a\": 3}, \"passed\": true}, {\"check\": \"negative adjustment changes eligibility\", \"actual\": {\"a\": 4}, \"expected\": {}, \"passed\": false}, {\"check\": \"group-specific totals do not mingle\", \"actual\": {\"b\": 5}, \"expected\": {\"a\": 3, \"b\": 5}, \"passed\": false}, {\"check\": \"below-threshold completed group\", \"actual\": {\"a\": 1}, \"expected\": {}, \"passed\": false}, {\"check\": \"zero threshold retains a real cancelling group\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 0}, \"passed\": false}, {\"check\": \"empty relation does not invent a zero group\", \"actual\": {}, \"expected\": {}, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":31.053,"exit_code":0,"observations":[{"actual":{"a":2},"check":"small contributions jointly qualify","expected":{"a":2},"passed":true},{"actual":{"a":3},"check":"exact single contribution qualifies","expected":{"a":3},"passed":true},{"actual":{},"check":"negative adjustment changes eligibility","expected":{},"passed":true},{"actual":{"a":3,"b":5},"check":"group-specific totals do not mingle","expected":{"a":3,"b":5},"passed":true},{"actual":{},"check":"below-threshold completed group","expected":{},"passed":true},{"actual":{"a":0},"check":"zero threshold retains a real cancelling group","expected":{"a":0},"passed":true},{"actual":{},"check":"empty relation does not invent a zero group","expected":{},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"small contributions jointly qualify\", \"actual\": {\"a\": 2}, \"expected\": {\"a\": 2}, \"passed\": true}, {\"check\": \"exact single contribution qualifies\", \"actual\": {\"a\": 3}, \"expected\": {\"a\": 3}, \"passed\": true}, {\"check\": \"negative adjustment changes eligibility\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"group-specific totals do not mingle\", \"actual\": {\"a\": 3, \"b\": 5}, \"expected\": {\"a\": 3, \"b\": 5}, \"passed\": true}, {\"check\": \"below-threshold completed group\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"zero threshold retains a real cancelling group\", \"actual\": {\"a\": 0}, \"expected\": {\"a\": 0}, \"passed\": true}, {\"check\": \"empty relation does not invent a zero group\", \"actual\": {}, \"expected\": {}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}