FAILURE MAP
← Case archive

FA-11831 / Document structure integrity / Open access

Comment replies create spurious independent document anchors · case 01

Comment replies create spurious independent document anchors in the controlled document model.

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

ROOT CAUSE

A thread exporter treats every comment record as an anchored root.

VERIFIED REPAIR

Select roots using the explicit None parent sentinel.

Unsuccessful approach: A truthiness check mistakes parent identity zero for no parent.

Case contract

Comments are [integer ID,parent ID or None]. Return only root IDs in storage order; replies inherit their thread anchor, and zero is a valid ID.

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(comments):
    return [item[0] for item in comments]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [(([(0,None),(N,0)],),[0]), (([],),[]), (([(N,None)],),[N]), (([(1,None),(2,1),(3,2)],),[1]), (([(1,None),(2,None)],),[1,2]), (([(3,0),(0,None)],),[0])]
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 0[0, 1][0]Failed
document fixture 1[][]Passed
document fixture 2[1][1]Passed
document fixture 3[1, 2, 3][1]Failed
document fixture 4[1, 2][1, 2]Passed
document fixture 5[3, 0][0]Failed

SHA-256 / 64740e943ee75dd778fc6d24279b7dcb2b9bb22ff094be92bb592cef4e308c55

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(comments):
    return [item[0] for item in comments if not item[1]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [(([(0,None),(N,0)],),[0]), (([],),[]), (([(N,None)],),[N]), (([(1,None),(2,1),(3,2)],),[1]), (([(1,None),(2,None)],),[1,2]), (([(3,0),(0,None)],),[0])]
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 0[0, 1][0]Failed
document fixture 1[][]Passed
document fixture 2[1][1]Passed
document fixture 3[1][1]Passed
document fixture 4[1, 2][1, 2]Passed
document fixture 5[3, 0][0]Failed

SHA-256 / 402a4ad52914e7573dfa3a10b0a464ea4445ed91aa93e581b35475167c15573e

3 / The verified repair

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

N = 1
observations = []
def solve(comments):
    return [identity for identity,parent in comments if parent is None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [(([(0,None),(N,0)],),[0]), (([],),[]), (([(N,None)],),[N]), (([(1,None),(2,1),(3,2)],),[1]), (([(1,None),(2,None)],),[1,2]), (([(3,0),(0,None)],),[0])]
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 0[0][0]Passed
document fixture 1[][]Passed
document fixture 2[1][1]Passed
document fixture 3[1][1]Passed
document fixture 4[1, 2][1, 2]Passed
document fixture 5[0][0]Passed

SHA-256 / b0c1c230a14cfb9db365864c52621c449d195d4f1bfea96b06d258279e67ebe0

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

Case digest / d30a7a92561a001f99a759c7dd37325a12f3cc0c099131f33e4b8ef27c2725ef