FAILURE MAP
← Case archive

FA-99561 / RAG context assembly / Open access

Context coverage interleaves document chunks without breaking prefixes · case 01

Context coverage interleaves document chunks without breaking prefixes.

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

ROOT CAUSE

Assembly emits whole document groups, so later documents receive no context until an earlier source is exhausted.

THE FAILURE

Assembly emits whole document groups, so later documents receive no context until an earlier source is exhausted.

Unsuccessful approach: Sorting each document’s chunks by cost can emit a continuation before its required prefix chunk.

Case contract

Rows are [document,ordinal,text,cost] with unique contiguous ordinals per document. In first-seen document order, emit one next chunk per pass; each document contributes only a contiguous ordinal prefix. Skip a document after its next chunk cannot fit the remaining budget. Return [document,ordinal,text] rows.

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(rows, budget):
    groups={}; order=[]
    for doc,ordinal,text,cost in rows:
        if doc not in groups: groups[doc]=[]; order.append(doc)
        groups[doc].append((ordinal,[doc,ordinal,text],cost))
    return [item for doc in order for ordinal,item,cost in sorted(groups[doc])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
a='doc'+str(N); b='other'+str(N)
check('round robin keeps local order', solve([[a,0,'a0',1],[a,1,'a1',1],[b,0,'b0',1],[b,1,'b1',1]],3), [[a,0,'a0'],[b,0,'b0'],[a,1,'a1']])
check('expensive prefix keeps dependency', solve([[a,0,'a0',3],[a,1,'a1',1],[b,0,'b0',1],[b,1,'b1',0]],4), [[a,0,'a0'],[b,0,'b0'],[b,1,'b1']])
check('input order inside source is ordinal', solve([[a,1,'a1',1],[b,0,'b0',1],[a,0,'a0',1]],3), [[a,0,'a0'],[b,0,'b0'],[a,1,'a1']])
check('empty', solve([],N), [])
check('one document prefix', solve([[a,0,'a0',1],[a,1,'a1',1]],2), [[a,0,'a0'],[a,1,'a1']])
check('zero budget blocks positive chunks', solve([[a,0,'a0',1],[b,0,'b0',1]],0), [])
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
round robin keeps local order[['doc1', 0, 'a0'], ['doc1', 1, 'a1'], ['other1', 0, 'b0'], ['other1', 1, 'b1']][['doc1', 0, 'a0'], ['other1', 0, 'b0'], ['doc1', 1, 'a1']]Failed
expensive prefix keeps dependency[['doc1', 0, 'a0'], ['doc1', 1, 'a1'], ['other1', 0, 'b0'], ['other1', 1, 'b1']][['doc1', 0, 'a0'], ['other1', 0, 'b0'], ['other1', 1, 'b1']]Failed
input order inside source is ordinal[['doc1', 0, 'a0'], ['doc1', 1, 'a1'], ['other1', 0, 'b0']][['doc1', 0, 'a0'], ['other1', 0, 'b0'], ['doc1', 1, 'a1']]Failed
empty[][]Passed
one document prefix[['doc1', 0, 'a0'], ['doc1', 1, 'a1']][['doc1', 0, 'a0'], ['doc1', 1, 'a1']]Passed
zero budget blocks positive chunks[['doc1', 0, 'a0'], ['other1', 0, 'b0']][]Failed

SHA-256 / 37f48bc313a13910788ca046689cdf4867ba530f9302cddd7451c34964b69669

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(rows, budget):
    groups={}; order=[]
    for doc,ordinal,text,cost in rows:
        if doc not in groups: groups[doc]=[]; order.append(doc)
        groups[doc].append((ordinal,[doc,ordinal,text],cost))
    for doc in order: groups[doc].sort(key=lambda row:row[2])
    out=[]; used=0; pos={doc:0 for doc in order}
    while True:
        advanced=False
        for doc in order:
            if pos[doc]<len(groups[doc]):
                advanced=True; ordinal,item,cost=groups[doc][pos[doc]]
                if used+cost<=budget: out.append(item); used+=cost; pos[doc]+=1
                else: pos[doc]=len(groups[doc])
        if not advanced: break
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
a='doc'+str(N); b='other'+str(N)
check('round robin keeps local order', solve([[a,0,'a0',1],[a,1,'a1',1],[b,0,'b0',1],[b,1,'b1',1]],3), [[a,0,'a0'],[b,0,'b0'],[a,1,'a1']])
check('expensive prefix keeps dependency', solve([[a,0,'a0',3],[a,1,'a1',1],[b,0,'b0',1],[b,1,'b1',0]],4), [[a,0,'a0'],[b,0,'b0'],[b,1,'b1']])
check('input order inside source is ordinal', solve([[a,1,'a1',1],[b,0,'b0',1],[a,0,'a0',1]],3), [[a,0,'a0'],[b,0,'b0'],[a,1,'a1']])
check('empty', solve([],N), [])
check('one document prefix', solve([[a,0,'a0',1],[a,1,'a1',1]],2), [[a,0,'a0'],[a,1,'a1']])
check('zero budget blocks positive chunks', solve([[a,0,'a0',1],[b,0,'b0',1]],0), [])
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
round robin keeps local order[['doc1', 0, 'a0'], ['other1', 0, 'b0'], ['doc1', 1, 'a1']][['doc1', 0, 'a0'], ['other1', 0, 'b0'], ['doc1', 1, 'a1']]Passed
expensive prefix keeps dependency[['doc1', 1, 'a1'], ['other1', 1, 'b1'], ['doc1', 0, 'a0']][['doc1', 0, 'a0'], ['other1', 0, 'b0'], ['other1', 1, 'b1']]Failed
input order inside source is ordinal[['doc1', 1, 'a1'], ['other1', 0, 'b0'], ['doc1', 0, 'a0']][['doc1', 0, 'a0'], ['other1', 0, 'b0'], ['doc1', 1, 'a1']]Failed
empty[][]Passed
one document prefix[['doc1', 0, 'a0'], ['doc1', 1, 'a1']][['doc1', 0, 'a0'], ['doc1', 1, 'a1']]Passed
zero budget blocks positive chunks[][]Passed

SHA-256 / 03a5dcea5a4160d476de6d7a557dc39e8ac21a2e5d5ac5ba5170435d3e8b11cc

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

Case digest / 0108ffaa7ece852ed633339cc40216f8f1a12e8120287d9d2db85b40e7c37403