FAILURE MAP
← Case archive

FA-136 / Storage and queries / Open access

A prefix range scan misses negative secondary keys · case 01

A composite index lookup omits some rows for its leading key or leaks rows from the next leading key.

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

ROOT CAUSE

Tuple prefix bounds are incorrectly padded with a presumed minimum secondary key of zero.

THE FAILURE

Tuple prefix bounds are incorrectly padded with a presumed minimum secondary key of zero.

Unsuccessful approach: Adding zero as a secondary bound seems to fix empty prefix ranges but excludes negative secondary keys and admits negative keys of the next tenant.

Case contract

Input rows are sorted unique tuples [integer_tenant,integer_secondary,payload_string]. Return all rows for the requested tenant in index order. Secondary keys can be any integer. The model assumes integer, not string, leading keys.

Why this case matters

Exercises lexicographic B-tree range-bound construction without claiming to implement a physical index. It covers short-tuple ordering and invalid sentinel assumptions rather than cursor pagination.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from bisect import bisect_left, bisect_right
N = 1
observations = []
def solve(rows, tenant):
    index = [tuple(row) for row in rows]
    return [list(row) for row in index[bisect_left(index, (tenant,)):bisect_right(index, (tenant,))]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
rows = [[N, -N, 'negative'], [N, 0, 'zero'], [N, N, 'positive'], [N+1, -N, 'next']]
check('entire composite prefix', solve(rows, N), rows[:3])
check('next tenant negative key is not leaked backward', solve([[N+1, -N, 'next']], N), [])
check('negative secondary key is not omitted', solve([[N, -N, 'kept']], N), [[N, -N, 'kept']])
check('negative leading key', solve([[-N, -2, 'a'], [-N, 1, 'b'], [0, 0, 'c']], -N), [[-N, -2, 'a'], [-N, 1, 'b']])
check('missing leading prefix', solve(rows, N+3), [])
check('positive-only prefix still works', solve([[N, 1, 'a'], [N, N+2, 'b']], N), [[N, 1, 'a'], [N, N+2, 'b']])
check('empty index', solve([], N), [])
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
entire composite prefix[][[1, -1, 'negative'], [1, 0, 'zero'], [1, 1, 'positive']]Failed
next tenant negative key is not leaked backward[][]Passed
negative secondary key is not omitted[][[1, -1, 'kept']]Failed
negative leading key[][[-1, -2, 'a'], [-1, 1, 'b']]Failed
missing leading prefix[][]Passed
positive-only prefix still works[][[1, 1, 'a'], [1, 3, 'b']]Failed
empty index[][]Passed

SHA-256 / b1e16b7afa9eeac3a432e6a5039a6debcf14bb774f2c79bb69b15148da9241c1

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from bisect import bisect_left, bisect_right
N = 1
observations = []
def solve(rows, tenant):
    index = [tuple(row) for row in rows]
    return [list(row) for row in index[bisect_left(index, (tenant, 0)):bisect_left(index, (tenant+1, 0))]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
rows = [[N, -N, 'negative'], [N, 0, 'zero'], [N, N, 'positive'], [N+1, -N, 'next']]
check('entire composite prefix', solve(rows, N), rows[:3])
check('next tenant negative key is not leaked backward', solve([[N+1, -N, 'next']], N), [])
check('negative secondary key is not omitted', solve([[N, -N, 'kept']], N), [[N, -N, 'kept']])
check('negative leading key', solve([[-N, -2, 'a'], [-N, 1, 'b'], [0, 0, 'c']], -N), [[-N, -2, 'a'], [-N, 1, 'b']])
check('missing leading prefix', solve(rows, N+3), [])
check('positive-only prefix still works', solve([[N, 1, 'a'], [N, N+2, 'b']], N), [[N, 1, 'a'], [N, N+2, 'b']])
check('empty index', solve([], N), [])
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
entire composite prefix[[1, 0, 'zero'], [1, 1, 'positive'], [2, -1, 'next']][[1, -1, 'negative'], [1, 0, 'zero'], [1, 1, 'positive']]Failed
next tenant negative key is not leaked backward[[2, -1, 'next']][]Failed
negative secondary key is not omitted[][[1, -1, 'kept']]Failed
negative leading key[[-1, 1, 'b']][[-1, -2, 'a'], [-1, 1, 'b']]Failed
missing leading prefix[][]Passed
positive-only prefix still works[[1, 1, 'a'], [1, 3, 'b']][[1, 1, 'a'], [1, 3, 'b']]Passed
empty index[][]Passed

SHA-256 / 0f93058b4479d3dc6e931d99b34ce13f65678cd3b5c524b9c0d3509d0a931477

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 6931d3a36ec8252e029a46678c69cc889b9d61b8e7e337bc0f037ea66c4fa911