FAILURE MAP
← Case archive

FA-99541 / RAG context assembly / Open access

RAG assembly stops at the first over-budget chunk · case 01

RAG assembly stops at the first over-budget chunk.

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

ROOT CAUSE

The loop treats the first candidate that exceeds remaining capacity as the end of the ranked list.

THE FAILURE

The loop treats the first candidate that exceeds remaining capacity as the end of the ranked list.

Unsuccessful approach: Filtering unaffordable chunks helps, but clipping accepted results to one chunk discards later fitting evidence.

Case contract

Given ranked [text,cost] chunks, return texts in input order whose summed costs fit budget; skip oversized chunks and continue.

Why this case matters

A small deterministic evidence assembly model makes context budgeting behavior inspectable.

1 / The failure

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

N = 1
observations = []
def solve(chunks, budget):
    out=[]; total=0
    for text,cost in chunks:
        if total+cost>budget: break
        out.append(text); total+=cost
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('skip costly lead', solve([['large',N+1],['small',1]],N), ['small'])
check('both fit', solve([['a',1],['b',N]],N+1), ['a','b'])
check('none fit', solve([['x',N+1]],N), [])
check('empty', solve([],N), [])
check('zero cost', solve([['z',0],['a',1]],1), ['z','a'])
check('later after skip', solve([['x',N+2],['y',N]],N), ['y'])
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
skip costly lead[]['small']Failed
both fit['a', 'b']['a', 'b']Passed
none fit[][]Passed
empty[][]Passed
zero cost['z', 'a']['z', 'a']Passed
later after skip[]['y']Failed

SHA-256 / 84a470dd7610e38548af446d6efd071805cf491005aa061169fa4d38e383d8d9

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(chunks, budget):
    out=[]; total=0
    for text,cost in chunks:
        if total+cost<=budget: out.append(text); total+=cost
    return out[:1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('skip costly lead', solve([['large',N+1],['small',1]],N), ['small'])
check('both fit', solve([['a',1],['b',N]],N+1), ['a','b'])
check('none fit', solve([['x',N+1]],N), [])
check('empty', solve([],N), [])
check('zero cost', solve([['z',0],['a',1]],1), ['z','a'])
check('later after skip', solve([['x',N+2],['y',N]],N), ['y'])
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
skip costly lead['small']['small']Passed
both fit['a']['a', 'b']Failed
none fit[][]Passed
empty[][]Passed
zero cost['z']['z', 'a']Failed
later after skip['y']['y']Passed

SHA-256 / d726599b100e2424f119d14882dee8b503403790dbb817ec9c2917077129b618

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 6 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

Toy inputs and token counts only; this does not claim compatibility with a tokenizer, prompt format, or production retrieval system. 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-30T16:48:25.347800+00:00.

Case digest / ba78abdf10a752a1c10e0d8d9a9add5188af5e21732107b3ffd5d77ce2945815