FAILURE MAP
← Case archive

FA-11816 / Document structure integrity / Open access

Updating an early field moves the offsets of later fields · case 01

Updating an early field moves the offsets of later fields in the controlled document model.

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

ROOT CAUSE

Original-document field offsets are applied to an already length-modified buffer.

VERIFIED REPAIR

Apply replacements from highest original offset to lowest.

Unsuccessful approach: Sorting edits left to right makes order deterministic but still invalidates later offsets.

Case contract

Replace disjoint nonempty half-open ranges whose offsets all refer to the original string. Input edits may be unordered.

Why this case matters

Structured editing must preserve document semantics independently of visual rendering.

1 / The failure

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

N = 1
observations = []
def solve(text, fields):
    for start,end,value in fields: text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [(( 'aXbYc',[(1,2,'q'*N+'q'),(3,4,'Z')]),'a'+'q'*N+'qbZc'), (('',[]),''), (('abc',[(0,3,'')]),''), (('XY',[(1,2,'BBB'),(0,1,'AA')]),'AABBB'), (('abc',[(1,2,'x')]),'axc'), (('XYZ',[(0,1,''),(2,3,'QQ')]),'YQQ')]
for i, (args, expected) in enumerate(fixtures):
    check("document fixture " + str(i), solve(*args), expected)
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
document fixture 0aqqZYcaqqbZcFailed
document fixture 1Passed
document fixture 2Passed
document fixture 3AABBBAABBBPassed
document fixture 4axcaxcPassed
document fixture 5YZQQYQQFailed

SHA-256 / 2bd2dfd3a009075dca3928c69948078b26f99d8d8097149f4d71693c3dd81aaf

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(text, fields):
    for start,end,value in sorted(fields): text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [(( 'aXbYc',[(1,2,'q'*N+'q'),(3,4,'Z')]),'a'+'q'*N+'qbZc'), (('',[]),''), (('abc',[(0,3,'')]),''), (('XY',[(1,2,'BBB'),(0,1,'AA')]),'AABBB'), (('abc',[(1,2,'x')]),'axc'), (('XYZ',[(0,1,''),(2,3,'QQ')]),'YQQ')]
for i, (args, expected) in enumerate(fixtures):
    check("document fixture " + str(i), solve(*args), expected)
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
document fixture 0aqqZYcaqqbZcFailed
document fixture 1Passed
document fixture 2Passed
document fixture 3ABBBYAABBBFailed
document fixture 4axcaxcPassed
document fixture 5YZQQYQQFailed

SHA-256 / d323fc3c235c1b1ceb39e8766d300fefb226d181b5abc97b6ecfa7e7081d9daf

3 / The verified repair

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

N = 1
observations = []
def solve(text, fields):
    for start,end,value in sorted(fields,reverse=True): text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [(( 'aXbYc',[(1,2,'q'*N+'q'),(3,4,'Z')]),'a'+'q'*N+'qbZc'), (('',[]),''), (('abc',[(0,3,'')]),''), (('XY',[(1,2,'BBB'),(0,1,'AA')]),'AABBB'), (('abc',[(1,2,'x')]),'axc'), (('XYZ',[(0,1,''),(2,3,'QQ')]),'YQQ')]
for i, (args, expected) in enumerate(fixtures):
    check("document fixture " + str(i), solve(*args), expected)
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
document fixture 0aqqbZcaqqbZcPassed
document fixture 1Passed
document fixture 2Passed
document fixture 3AABBBAABBBPassed
document fixture 4axcaxcPassed
document fixture 5YQQYQQPassed

SHA-256 / 1f42202a4fc14224e09c7d5d89aa69ae25c73e7bd19a63a718d7f803fa682bb3

Verification & scope

An offline simplified document model, not a claim of conformance to any office file format. 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:38:51.175840+00:00.

Case digest / 144d2c17387417bbaf12f187bdbb256d024c221f731b76bb4a083246b6e2ea30