FAILURE MAP
← Case archive

FA-4826 / Heap invariants / Open access

Heap priority ties use arrival order · case 01

The operation returns a result or retained state that violates this contract: Order [priority,label] jobs by priority, using arrival sequence to break equal priorities independently of label lexical order.

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

ROOT CAUSE

The payload label becomes an accidental lexical tie breaker.

VERIFIED REPAIR

Order [priority,label] jobs by priority, using arrival sequence to break equal priorities independently of label lexical order.

Unsuccessful approach: Returning arrival order without prioritization ignores unequal priorities.

Case contract

Order [priority,label] jobs by priority, using arrival sequence to break equal priorities independently of label lexical order. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

Why this case matters

A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    a=[(p,v) for p,v in x]; heapq.heapify(a); return [heapq.heappop(a)[1] for _ in range(len(a))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal priority stable', solve([[1, 'z'], [1, 'a'], [0, 'm']]), ['m', 'z', 'a'])
check('priority dominates arrival', solve([[2, 'a'], [1, 'b']]), ['b', 'a'])
check('empty', solve([]), [])
check('singleton', solve([[1, 'a']]), ['a'])
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
equal priority stable['m', 'a', 'z']['m', 'z', 'a']Failed
priority dominates arrival['b', 'a']['b', 'a']Passed
empty[][]Passed
singleton['a']['a']Passed

SHA-256 / 6f0c0b9317c37d32fb85b32153497c55d7ceeb3ccc9f3063916a7c4fae40e59c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return [v for p,v in x]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal priority stable', solve([[1, 'z'], [1, 'a'], [0, 'm']]), ['m', 'z', 'a'])
check('priority dominates arrival', solve([[2, 'a'], [1, 'b']]), ['b', 'a'])
check('empty', solve([]), [])
check('singleton', solve([[1, 'a']]), ['a'])
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
equal priority stable['z', 'a', 'm']['m', 'z', 'a']Failed
priority dominates arrival['a', 'b']['b', 'a']Failed
empty[][]Passed
singleton['a']['a']Passed

SHA-256 / 400a016445f936f0dd9baed63c2b1eefbea4f95dc7f5855f6c3f6926b91f7baa

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    a=[(p,i,v) for i,(p,v) in enumerate(x)]; heapq.heapify(a); return [heapq.heappop(a)[2] for _ in range(len(a))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal priority stable', solve([[1, 'z'], [1, 'a'], [0, 'm']]), ['m', 'z', 'a'])
check('priority dominates arrival', solve([[2, 'a'], [1, 'b']]), ['b', 'a'])
check('empty', solve([]), [])
check('singleton', solve([[1, 'a']]), ['a'])
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
equal priority stable['m', 'z', 'a']['m', 'z', 'a']Passed
priority dominates arrival['b', 'a']['b', 'a']Passed
empty[][]Passed
singleton['a']['a']Passed

SHA-256 / 6a09ac16d0b73525e961031b4e242b0d90469568d2f599fb4396bc9dbcca1959

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

Case digest / 83ab4e1cbf71ddaa25dc5d9818d8cc3d830afcd000f26087650a7164e83d150c