FAILURE MAP
← Case archive

FA-4201 / Sequence semantics / Open access

Stable value ranking · case 01

The operation returns a result or retained state that violates this contract: Sort values lexically and retain original positions, preserving original order among equal values.

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

ROOT CAUSE

Positions are assigned after sorting, losing original positions.

VERIFIED REPAIR

Sort values lexically and retain original positions, preserving original order among equal values.

Unsuccessful approach: Looking up each sorted value recovers only the first equal original position.

Case contract

Sort values lexically and retain original positions, preserving original order among equal values. 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

N = 1
observations = []
def solve(x, y=None):
    return [[i,v] for i,v in enumerate(sorted(x))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [[0, 'a']])
check('two distinct elements', solve(['a', 'b']), [[0, 'a'], [1, 'b']])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [[1, 'a'], [0, 'b'], [2, 'b'], [3, 'c']])
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
empty collection[][]Passed
singleton collection[[0, 'a']][[0, 'a']]Passed
two distinct elements[[0, 'a'], [1, 'b']][[0, 'a'], [1, 'b']]Passed
nonadjacent duplicate and unsorted order[[0, 'a'], [1, 'b'], [2, 'b'], [3, 'c']][[1, 'a'], [0, 'b'], [2, 'b'], [3, 'c']]Failed

SHA-256 / 5d344e10c69a1a90c775a50dff57dba84a8844e59dc436858d29fcdcac3fb670

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x, y=None):
    return [[x.index(v),v] for v in sorted(x)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [[0, 'a']])
check('two distinct elements', solve(['a', 'b']), [[0, 'a'], [1, 'b']])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [[1, 'a'], [0, 'b'], [2, 'b'], [3, 'c']])
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
empty collection[][]Passed
singleton collection[[0, 'a']][[0, 'a']]Passed
two distinct elements[[0, 'a'], [1, 'b']][[0, 'a'], [1, 'b']]Passed
nonadjacent duplicate and unsorted order[[1, 'a'], [0, 'b'], [0, 'b'], [3, 'c']][[1, 'a'], [0, 'b'], [2, 'b'], [3, 'c']]Failed

SHA-256 / 72d1db1fd0ef00f93e542f62065e857c31116fbd9aed44c2e6602a3ec990206c

3 / The verified repair

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

N = 1
observations = []
def solve(x, y=None):
    return [[i,x[i]] for i in sorted(range(len(x)), key=lambda i:x[i])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [[0, 'a']])
check('two distinct elements', solve(['a', 'b']), [[0, 'a'], [1, 'b']])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [[1, 'a'], [0, 'b'], [2, 'b'], [3, 'c']])
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
empty collection[][]Passed
singleton collection[[0, 'a']][[0, 'a']]Passed
two distinct elements[[0, 'a'], [1, 'b']][[0, 'a'], [1, 'b']]Passed
nonadjacent duplicate and unsorted order[[1, 'a'], [0, 'b'], [2, 'b'], [3, 'c']][[1, 'a'], [0, 'b'], [2, 'b'], [3, 'c']]Passed

SHA-256 / c095377a823a8db84d576ebdeb1f1ae5889e1e27ed81334d25a665d11ab94898

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

Case digest / 7e0dc57fcf7eb3699a8e6c3bc5d7e0fc8de874fe31182629f336edf9c71113df