FAILURE MAP
← Case archive

FA-90481 / Garbage collector invariants / Open access

Heap pacing: reaching the goal exactly does not trigger · case 01

Collections start one allocation late whenever the heap lands exactly on its goal.

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

ROOT CAUSE

The trigger compares heap > goal.

VERIFIED REPAIR

Trigger when the heap is at or above the goal.

Unsuccessful approach: Adding the allocation size again double-counts it and triggers too early.

Case contract

GOGC-style pacing starting at 100 percent with goal = min_heap. alloc b adds b to the heap and to live bytes and triggers a collection when collection is enabled (percentage >= 0) and heap >= goal: the heap shrinks to the live bytes, which become the marked size, and goal = max(marked + marked * pct // 100, min_heap). drop b turns b live bytes into garbage. setgc p changes the percentage (-1 disables) and, unless disabled, recomputes the goal from the last marked size. Return the heap sizes at which collections triggered, the final goal and heap.

Why this case matters

Collector pacing decides when collections run; off-by-one or base errors change memory footprint.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events, min_heap):
    gogc = 100
    live = 0
    marked = 0
    heap = 0
    goal = min_heap
    gcs = []
    for ev in events:
        if ev[0] == 'alloc':
            heap += ev[1]
            live += ev[1]
            if gogc >= 0 and heap > goal:
                gcs.append(heap)
                heap = live
                marked = live
                goal = max(live + live * gogc // 100, min_heap)
        elif ev[0] == 'drop':
            live -= ev[1]
        else:
            gogc = ev[1]
            if gogc >= 0:
                goal = max(marked + marked * gogc // 100, min_heap)
    return {'gcs': gcs, 'goal': goal, 'heap': heap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: heap reaching the goal exactly',
   ([['alloc', 55], ['alloc', 55], ['drop', 30], ['alloc', 25]], 110),
   {'gcs': [110], 'goal': 220, 'heap': 135}),
  ('goal grows with live heap',
   ([['alloc', 330], ['drop', 110], ['alloc', 220], ['alloc', 10]], 110),
   {'gcs': [330], 'goal': 660, 'heap': 560}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 220], ['alloc', 111]], 110),
   {'gcs': [220, 331], 'goal': 496, 'heap': 331}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 330], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 110),
   {'gcs': [331, 332], 'goal': 332, 'heap': 332}),
  ('goal recomputed from last marked heap',
   ([['alloc', 220], ['drop', 110], ['alloc', 10], ['setgc', 200], ['alloc', 330], ['alloc', 110]], 110),
   {'gcs': [220, 670], 'goal': 1680, 'heap': 560}),
  ('small live heap uses the minimum goal',
   ([['alloc', 110],
     ['drop', 110],
     ['alloc', 109],
     ['drop', 109],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 104]],
    110),
   {'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}),
  ('control: no allocation', ([['setgc', 50]], 110), {'gcs': [], 'goal': 110, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 60], ['alloc', 60], ['drop', 30], ['alloc', 25]], 120),
   {'gcs': [120], 'goal': 240, 'heap': 145}),
  ('goal grows with live heap',
   ([['alloc', 360], ['drop', 120], ['alloc', 240], ['alloc', 10]], 120),
   {'gcs': [360], 'goal': 720, 'heap': 610}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 240], ['alloc', 121]], 120),
   {'gcs': [240, 361], 'goal': 541, 'heap': 361}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 360], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 120),
   {'gcs': [361, 362], 'goal': 362, 'heap': 362}),
  ('goal recomputed from last marked heap',
   ([['alloc', 240], ['drop', 120], ['alloc', 10], ['setgc', 200], ['alloc', 360], ['alloc', 120]], 120),
   {'gcs': [240, 730], 'goal': 1830, 'heap': 610}),
  ('small live heap uses the minimum goal',
   ([['alloc', 120],
     ['drop', 120],
     ['alloc', 119],
     ['drop', 119],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 114]],
    120),
   {'gcs': [120, 240, 120], 'goal': 240, 'heap': 120}),
  ('control: no allocation', ([['setgc', 50]], 120), {'gcs': [], 'goal': 120, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 65], ['alloc', 65], ['drop', 30], ['alloc', 25]], 130),
   {'gcs': [130], 'goal': 260, 'heap': 155}),
  ('goal grows with live heap',
   ([['alloc', 390], ['drop', 130], ['alloc', 260], ['alloc', 10]], 130),
   {'gcs': [390], 'goal': 780, 'heap': 660}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 260], ['alloc', 131]], 130),
   {'gcs': [260, 391], 'goal': 586, 'heap': 391}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 390], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 130),
   {'gcs': [391, 392], 'goal': 392, 'heap': 392}),
  ('goal recomputed from last marked heap',
   ([['alloc', 260], ['drop', 130], ['alloc', 10], ['setgc', 200], ['alloc', 390], ['alloc', 130]], 130),
   {'gcs': [260, 790], 'goal': 1980, 'heap': 660}),
  ('small live heap uses the minimum goal',
   ([['alloc', 130],
     ['drop', 130],
     ['alloc', 129],
     ['drop', 129],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 124]],
    130),
   {'gcs': [130, 260, 130], 'goal': 260, 'heap': 130}),
  ('control: no allocation', ([['setgc', 50]], 130), {'gcs': [], 'goal': 130, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 70], ['alloc', 70], ['drop', 30], ['alloc', 25]], 140),
   {'gcs': [140], 'goal': 280, 'heap': 165}),
  ('goal grows with live heap',
   ([['alloc', 420], ['drop', 140], ['alloc', 280], ['alloc', 10]], 140),
   {'gcs': [420], 'goal': 840, 'heap': 710}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 280], ['alloc', 141]], 140),
   {'gcs': [280, 421], 'goal': 631, 'heap': 421}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 420], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 140),
   {'gcs': [421, 422], 'goal': 422, 'heap': 422}),
  ('goal recomputed from last marked heap',
   ([['alloc', 280], ['drop', 140], ['alloc', 10], ['setgc', 200], ['alloc', 420], ['alloc', 140]], 140),
   {'gcs': [280, 850], 'goal': 2130, 'heap': 710}),
  ('small live heap uses the minimum goal',
   ([['alloc', 140],
     ['drop', 140],
     ['alloc', 139],
     ['drop', 139],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 134]],
    140),
   {'gcs': [140, 280, 140], 'goal': 280, 'heap': 140}),
  ('control: no allocation', ([['setgc', 50]], 140), {'gcs': [], 'goal': 140, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 75], ['alloc', 75], ['drop', 30], ['alloc', 25]], 150),
   {'gcs': [150], 'goal': 300, 'heap': 175}),
  ('goal grows with live heap',
   ([['alloc', 450], ['drop', 150], ['alloc', 300], ['alloc', 10]], 150),
   {'gcs': [450], 'goal': 900, 'heap': 760}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 300], ['alloc', 151]], 150),
   {'gcs': [300, 451], 'goal': 676, 'heap': 451}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 450], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 150),
   {'gcs': [451, 452], 'goal': 452, 'heap': 452}),
  ('goal recomputed from last marked heap',
   ([['alloc', 300], ['drop', 150], ['alloc', 10], ['setgc', 200], ['alloc', 450], ['alloc', 150]], 150),
   {'gcs': [300, 910], 'goal': 2280, 'heap': 760}),
  ('small live heap uses the minimum goal',
   ([['alloc', 150],
     ['drop', 150],
     ['alloc', 149],
     ['drop', 149],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 144]],
    150),
   {'gcs': [150, 300, 150], 'goal': 300, 'heap': 150}),
  ('control: no allocation', ([['setgc', 50]], 150), {'gcs': [], 'goal': 150, 'heap': 0})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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: heap reaching the goal exactly{'gcs': [135], 'goal': 210, 'heap': 105}{'gcs': [110], 'goal': 220, 'heap': 135}Failed
goal grows with live heap{'gcs': [330], 'goal': 660, 'heap': 560}{'gcs': [330], 'goal': 660, 'heap': 560}Passed
fractional growth percentage{'gcs': [220, 331], 'goal': 496, 'heap': 331}{'gcs': [220, 331], 'goal': 496, 'heap': 331}Passed
collector disabled then zero percent{'gcs': [331, 332], 'goal': 332, 'heap': 332}{'gcs': [331, 332], 'goal': 332, 'heap': 332}Passed
goal recomputed from last marked heap{'gcs': [220, 670], 'goal': 1680, 'heap': 560}{'gcs': [220, 670], 'goal': 1680, 'heap': 560}Passed
small live heap uses the minimum goal{'gcs': [219, 219], 'goal': 220, 'heap': 110}{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}Failed
control: no allocation{'gcs': [], 'goal': 110, 'heap': 0}{'gcs': [], 'goal': 110, 'heap': 0}Passed

SHA-256 / 0c227c3e57346d4f264cda62d3b0d7c4f448a81d40cb2e5fcc2a3afbebdc2361

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events, min_heap):
    gogc = 100
    live = 0
    marked = 0
    heap = 0
    goal = min_heap
    gcs = []
    for ev in events:
        if ev[0] == 'alloc':
            heap += ev[1]
            live += ev[1]
            if gogc >= 0 and heap + ev[1] >= goal:
                gcs.append(heap)
                heap = live
                marked = live
                goal = max(live + live * gogc // 100, min_heap)
        elif ev[0] == 'drop':
            live -= ev[1]
        else:
            gogc = ev[1]
            if gogc >= 0:
                goal = max(marked + marked * gogc // 100, min_heap)
    return {'gcs': gcs, 'goal': goal, 'heap': heap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: heap reaching the goal exactly',
   ([['alloc', 55], ['alloc', 55], ['drop', 30], ['alloc', 25]], 110),
   {'gcs': [110], 'goal': 220, 'heap': 135}),
  ('goal grows with live heap',
   ([['alloc', 330], ['drop', 110], ['alloc', 220], ['alloc', 10]], 110),
   {'gcs': [330], 'goal': 660, 'heap': 560}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 220], ['alloc', 111]], 110),
   {'gcs': [220, 331], 'goal': 496, 'heap': 331}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 330], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 110),
   {'gcs': [331, 332], 'goal': 332, 'heap': 332}),
  ('goal recomputed from last marked heap',
   ([['alloc', 220], ['drop', 110], ['alloc', 10], ['setgc', 200], ['alloc', 330], ['alloc', 110]], 110),
   {'gcs': [220, 670], 'goal': 1680, 'heap': 560}),
  ('small live heap uses the minimum goal',
   ([['alloc', 110],
     ['drop', 110],
     ['alloc', 109],
     ['drop', 109],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 104]],
    110),
   {'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}),
  ('control: no allocation', ([['setgc', 50]], 110), {'gcs': [], 'goal': 110, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 60], ['alloc', 60], ['drop', 30], ['alloc', 25]], 120),
   {'gcs': [120], 'goal': 240, 'heap': 145}),
  ('goal grows with live heap',
   ([['alloc', 360], ['drop', 120], ['alloc', 240], ['alloc', 10]], 120),
   {'gcs': [360], 'goal': 720, 'heap': 610}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 240], ['alloc', 121]], 120),
   {'gcs': [240, 361], 'goal': 541, 'heap': 361}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 360], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 120),
   {'gcs': [361, 362], 'goal': 362, 'heap': 362}),
  ('goal recomputed from last marked heap',
   ([['alloc', 240], ['drop', 120], ['alloc', 10], ['setgc', 200], ['alloc', 360], ['alloc', 120]], 120),
   {'gcs': [240, 730], 'goal': 1830, 'heap': 610}),
  ('small live heap uses the minimum goal',
   ([['alloc', 120],
     ['drop', 120],
     ['alloc', 119],
     ['drop', 119],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 114]],
    120),
   {'gcs': [120, 240, 120], 'goal': 240, 'heap': 120}),
  ('control: no allocation', ([['setgc', 50]], 120), {'gcs': [], 'goal': 120, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 65], ['alloc', 65], ['drop', 30], ['alloc', 25]], 130),
   {'gcs': [130], 'goal': 260, 'heap': 155}),
  ('goal grows with live heap',
   ([['alloc', 390], ['drop', 130], ['alloc', 260], ['alloc', 10]], 130),
   {'gcs': [390], 'goal': 780, 'heap': 660}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 260], ['alloc', 131]], 130),
   {'gcs': [260, 391], 'goal': 586, 'heap': 391}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 390], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 130),
   {'gcs': [391, 392], 'goal': 392, 'heap': 392}),
  ('goal recomputed from last marked heap',
   ([['alloc', 260], ['drop', 130], ['alloc', 10], ['setgc', 200], ['alloc', 390], ['alloc', 130]], 130),
   {'gcs': [260, 790], 'goal': 1980, 'heap': 660}),
  ('small live heap uses the minimum goal',
   ([['alloc', 130],
     ['drop', 130],
     ['alloc', 129],
     ['drop', 129],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 124]],
    130),
   {'gcs': [130, 260, 130], 'goal': 260, 'heap': 130}),
  ('control: no allocation', ([['setgc', 50]], 130), {'gcs': [], 'goal': 130, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 70], ['alloc', 70], ['drop', 30], ['alloc', 25]], 140),
   {'gcs': [140], 'goal': 280, 'heap': 165}),
  ('goal grows with live heap',
   ([['alloc', 420], ['drop', 140], ['alloc', 280], ['alloc', 10]], 140),
   {'gcs': [420], 'goal': 840, 'heap': 710}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 280], ['alloc', 141]], 140),
   {'gcs': [280, 421], 'goal': 631, 'heap': 421}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 420], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 140),
   {'gcs': [421, 422], 'goal': 422, 'heap': 422}),
  ('goal recomputed from last marked heap',
   ([['alloc', 280], ['drop', 140], ['alloc', 10], ['setgc', 200], ['alloc', 420], ['alloc', 140]], 140),
   {'gcs': [280, 850], 'goal': 2130, 'heap': 710}),
  ('small live heap uses the minimum goal',
   ([['alloc', 140],
     ['drop', 140],
     ['alloc', 139],
     ['drop', 139],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 134]],
    140),
   {'gcs': [140, 280, 140], 'goal': 280, 'heap': 140}),
  ('control: no allocation', ([['setgc', 50]], 140), {'gcs': [], 'goal': 140, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 75], ['alloc', 75], ['drop', 30], ['alloc', 25]], 150),
   {'gcs': [150], 'goal': 300, 'heap': 175}),
  ('goal grows with live heap',
   ([['alloc', 450], ['drop', 150], ['alloc', 300], ['alloc', 10]], 150),
   {'gcs': [450], 'goal': 900, 'heap': 760}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 300], ['alloc', 151]], 150),
   {'gcs': [300, 451], 'goal': 676, 'heap': 451}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 450], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 150),
   {'gcs': [451, 452], 'goal': 452, 'heap': 452}),
  ('goal recomputed from last marked heap',
   ([['alloc', 300], ['drop', 150], ['alloc', 10], ['setgc', 200], ['alloc', 450], ['alloc', 150]], 150),
   {'gcs': [300, 910], 'goal': 2280, 'heap': 760}),
  ('small live heap uses the minimum goal',
   ([['alloc', 150],
     ['drop', 150],
     ['alloc', 149],
     ['drop', 149],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 144]],
    150),
   {'gcs': [150, 300, 150], 'goal': 300, 'heap': 150}),
  ('control: no allocation', ([['setgc', 50]], 150), {'gcs': [], 'goal': 150, 'heap': 0})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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: heap reaching the goal exactly{'gcs': [55, 110], 'goal': 220, 'heap': 135}{'gcs': [110], 'goal': 220, 'heap': 135}Failed
goal grows with live heap{'gcs': [330, 550], 'goal': 880, 'heap': 450}{'gcs': [330], 'goal': 660, 'heap': 560}Failed
fractional growth percentage{'gcs': [220, 331], 'goal': 496, 'heap': 331}{'gcs': [220, 331], 'goal': 496, 'heap': 331}Passed
collector disabled then zero percent{'gcs': [331, 332], 'goal': 332, 'heap': 332}{'gcs': [331, 332], 'goal': 332, 'heap': 332}Passed
goal recomputed from last marked heap{'gcs': [220, 560], 'goal': 1350, 'heap': 560}{'gcs': [220, 670], 'goal': 1680, 'heap': 560}Failed
small live heap uses the minimum goal{'gcs': [110, 219, 219], 'goal': 220, 'heap': 110}{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}Failed
control: no allocation{'gcs': [], 'goal': 110, 'heap': 0}{'gcs': [], 'goal': 110, 'heap': 0}Passed

SHA-256 / 80119ba96e6c3065d2e9892d33512bc39713ebbc58b57add23e57b8ad7759249

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events, min_heap):
    gogc = 100
    live = 0
    marked = 0
    heap = 0
    goal = min_heap
    gcs = []
    for ev in events:
        if ev[0] == 'alloc':
            heap += ev[1]
            live += ev[1]
            if gogc >= 0 and heap >= goal:
                gcs.append(heap)
                heap = live
                marked = live
                goal = max(live + live * gogc // 100, min_heap)
        elif ev[0] == 'drop':
            live -= ev[1]
        else:
            gogc = ev[1]
            if gogc >= 0:
                goal = max(marked + marked * gogc // 100, min_heap)
    return {'gcs': gcs, 'goal': goal, 'heap': heap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: heap reaching the goal exactly',
   ([['alloc', 55], ['alloc', 55], ['drop', 30], ['alloc', 25]], 110),
   {'gcs': [110], 'goal': 220, 'heap': 135}),
  ('goal grows with live heap',
   ([['alloc', 330], ['drop', 110], ['alloc', 220], ['alloc', 10]], 110),
   {'gcs': [330], 'goal': 660, 'heap': 560}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 220], ['alloc', 111]], 110),
   {'gcs': [220, 331], 'goal': 496, 'heap': 331}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 330], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 110),
   {'gcs': [331, 332], 'goal': 332, 'heap': 332}),
  ('goal recomputed from last marked heap',
   ([['alloc', 220], ['drop', 110], ['alloc', 10], ['setgc', 200], ['alloc', 330], ['alloc', 110]], 110),
   {'gcs': [220, 670], 'goal': 1680, 'heap': 560}),
  ('small live heap uses the minimum goal',
   ([['alloc', 110],
     ['drop', 110],
     ['alloc', 109],
     ['drop', 109],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 104]],
    110),
   {'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}),
  ('control: no allocation', ([['setgc', 50]], 110), {'gcs': [], 'goal': 110, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 60], ['alloc', 60], ['drop', 30], ['alloc', 25]], 120),
   {'gcs': [120], 'goal': 240, 'heap': 145}),
  ('goal grows with live heap',
   ([['alloc', 360], ['drop', 120], ['alloc', 240], ['alloc', 10]], 120),
   {'gcs': [360], 'goal': 720, 'heap': 610}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 240], ['alloc', 121]], 120),
   {'gcs': [240, 361], 'goal': 541, 'heap': 361}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 360], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 120),
   {'gcs': [361, 362], 'goal': 362, 'heap': 362}),
  ('goal recomputed from last marked heap',
   ([['alloc', 240], ['drop', 120], ['alloc', 10], ['setgc', 200], ['alloc', 360], ['alloc', 120]], 120),
   {'gcs': [240, 730], 'goal': 1830, 'heap': 610}),
  ('small live heap uses the minimum goal',
   ([['alloc', 120],
     ['drop', 120],
     ['alloc', 119],
     ['drop', 119],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 114]],
    120),
   {'gcs': [120, 240, 120], 'goal': 240, 'heap': 120}),
  ('control: no allocation', ([['setgc', 50]], 120), {'gcs': [], 'goal': 120, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 65], ['alloc', 65], ['drop', 30], ['alloc', 25]], 130),
   {'gcs': [130], 'goal': 260, 'heap': 155}),
  ('goal grows with live heap',
   ([['alloc', 390], ['drop', 130], ['alloc', 260], ['alloc', 10]], 130),
   {'gcs': [390], 'goal': 780, 'heap': 660}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 260], ['alloc', 131]], 130),
   {'gcs': [260, 391], 'goal': 586, 'heap': 391}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 390], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 130),
   {'gcs': [391, 392], 'goal': 392, 'heap': 392}),
  ('goal recomputed from last marked heap',
   ([['alloc', 260], ['drop', 130], ['alloc', 10], ['setgc', 200], ['alloc', 390], ['alloc', 130]], 130),
   {'gcs': [260, 790], 'goal': 1980, 'heap': 660}),
  ('small live heap uses the minimum goal',
   ([['alloc', 130],
     ['drop', 130],
     ['alloc', 129],
     ['drop', 129],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 124]],
    130),
   {'gcs': [130, 260, 130], 'goal': 260, 'heap': 130}),
  ('control: no allocation', ([['setgc', 50]], 130), {'gcs': [], 'goal': 130, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 70], ['alloc', 70], ['drop', 30], ['alloc', 25]], 140),
   {'gcs': [140], 'goal': 280, 'heap': 165}),
  ('goal grows with live heap',
   ([['alloc', 420], ['drop', 140], ['alloc', 280], ['alloc', 10]], 140),
   {'gcs': [420], 'goal': 840, 'heap': 710}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 280], ['alloc', 141]], 140),
   {'gcs': [280, 421], 'goal': 631, 'heap': 421}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 420], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 140),
   {'gcs': [421, 422], 'goal': 422, 'heap': 422}),
  ('goal recomputed from last marked heap',
   ([['alloc', 280], ['drop', 140], ['alloc', 10], ['setgc', 200], ['alloc', 420], ['alloc', 140]], 140),
   {'gcs': [280, 850], 'goal': 2130, 'heap': 710}),
  ('small live heap uses the minimum goal',
   ([['alloc', 140],
     ['drop', 140],
     ['alloc', 139],
     ['drop', 139],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 134]],
    140),
   {'gcs': [140, 280, 140], 'goal': 280, 'heap': 140}),
  ('control: no allocation', ([['setgc', 50]], 140), {'gcs': [], 'goal': 140, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 75], ['alloc', 75], ['drop', 30], ['alloc', 25]], 150),
   {'gcs': [150], 'goal': 300, 'heap': 175}),
  ('goal grows with live heap',
   ([['alloc', 450], ['drop', 150], ['alloc', 300], ['alloc', 10]], 150),
   {'gcs': [450], 'goal': 900, 'heap': 760}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 300], ['alloc', 151]], 150),
   {'gcs': [300, 451], 'goal': 676, 'heap': 451}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 450], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 150),
   {'gcs': [451, 452], 'goal': 452, 'heap': 452}),
  ('goal recomputed from last marked heap',
   ([['alloc', 300], ['drop', 150], ['alloc', 10], ['setgc', 200], ['alloc', 450], ['alloc', 150]], 150),
   {'gcs': [300, 910], 'goal': 2280, 'heap': 760}),
  ('small live heap uses the minimum goal',
   ([['alloc', 150],
     ['drop', 150],
     ['alloc', 149],
     ['drop', 149],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 144]],
    150),
   {'gcs': [150, 300, 150], 'goal': 300, 'heap': 150}),
  ('control: no allocation', ([['setgc', 50]], 150), {'gcs': [], 'goal': 150, 'heap': 0})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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: heap reaching the goal exactly{'gcs': [110], 'goal': 220, 'heap': 135}{'gcs': [110], 'goal': 220, 'heap': 135}Passed
goal grows with live heap{'gcs': [330], 'goal': 660, 'heap': 560}{'gcs': [330], 'goal': 660, 'heap': 560}Passed
fractional growth percentage{'gcs': [220, 331], 'goal': 496, 'heap': 331}{'gcs': [220, 331], 'goal': 496, 'heap': 331}Passed
collector disabled then zero percent{'gcs': [331, 332], 'goal': 332, 'heap': 332}{'gcs': [331, 332], 'goal': 332, 'heap': 332}Passed
goal recomputed from last marked heap{'gcs': [220, 670], 'goal': 1680, 'heap': 560}{'gcs': [220, 670], 'goal': 1680, 'heap': 560}Passed
small live heap uses the minimum goal{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}Passed
control: no allocation{'gcs': [], 'goal': 110, 'heap': 0}{'gcs': [], 'goal': 110, 'heap': 0}Passed

SHA-256 / 5395f4c4d9801b7ec7294bd530511772d826ee600e9d6016b2993249d762f12d

Verification & scope

A deterministic, bounded teaching model of one garbage-collector mechanism with stipulated rules; it is not a production collector and claims no conformance to any particular runtime. 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:51:27.125250+00:00.

Case digest / 463200758363a57d90decce7341efba66d6f902ec08bf04a8e49de6973e722a7