FAILURE MAP
← Case archive

FA-76536 / Email MIME structure / Open access

Build a bounded MIME tree summary from parser events: nested skip depth · case 01

After skipping an over-deep subtree with nested containers, parsing resumes inside it and misattributes its parts.

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

ROOT CAUSE

The nested skip depth decision evaluates `skip = 1` where the contract requires `skip += 1`.

THE FAILURE

The nested skip depth decision evaluates `skip = 1` where the contract requires `skip += 1`.

Unsuccessful approach: Capping the skip depth at two still resumes early for deeper skipped subtrees. The attempted `skip = min(skip + 1, 2)` still disagrees with a fixture.

Case contract

events are ["open", type] (multipart start), ["leaf", type, size] and ["close"]. The root multipart has depth 1. An open that would exceed max_depth records "too-deep" and its whole subtree (including nested opens) is skipped, but it still counts as a child of its parent. A multipart closing with no children records "empty-multipart", a close with nothing open records "stray-close", and containers left open record "unclosed". Result {leaves, depth (maximum reached), errors}.

Why this case matters

Bounding MIME nesting protects mail parsers from resource exhaustion while keeping the reachable structure intact.

1 / The failure

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

N = 1
observations = []
def solve(events, max_depth):
    stack = []
    skip = 0
    leaves = 0
    depth = 0
    errors = []
    for ev in events:
        kind = ev[0]
        if skip:
            if kind == 'open':
                skip = 1
            elif kind == 'close':
                skip -= 1
            continue
        if kind == 'open':
            if stack:
                stack[-1] += 1
            if len(stack) + 1 > max_depth:
                errors.append('too-deep')
                skip = 1
                continue
            stack.append(0)
            depth = max(depth, len(stack))
        elif kind == 'leaf':
            leaves += 1
            if stack:
                stack[-1] += 1
        elif not stack:
            errors.append('stray-close')
        elif stack.pop() == 0:
            errors.append('empty-multipart')
    if stack:
        errors.append('unclosed')
    return {'leaves': leaves, 'depth': depth, 'errors': errors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 1}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 4], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 1}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 1], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 1], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 2: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 2}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 5], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 2], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 2}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 2], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 2], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 3: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['leaf', 'image/png', 2], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 3}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 6], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 3], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1], ['leaf', 'text/plain', 2]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 3}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 3], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 3], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 4: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['leaf', 'image/png', 2], ['leaf', 'image/png', 3], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 4}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 7], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 4], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1], ['leaf', 'text/plain', 2], ['leaf', 'text/plain', 3]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 4}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 4], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 4], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 5: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['leaf', 'image/png', 2], ['leaf', 'image/png', 3], ['leaf', 'image/png', 4], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 5}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 8], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 5], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1], ['leaf', 'text/plain', 2], ['leaf', 'text/plain', 3], ['leaf', 'text/plain', 4]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 5}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 5], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, 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
three levels with limit two{'depth': 2, 'errors': ['too-deep'], 'leaves': 1}{'depth': 2, 'errors': ['too-deep'], 'leaves': 1}Passed
deep skipped subtree{'depth': 1, 'errors': ['too-deep', 'stray-close', 'stray-close'], 'leaves': 2}{'depth': 1, 'errors': ['too-deep'], 'leaves': 1}Failed
skipped child keeps parent non-empty{'depth': 1, 'errors': ['too-deep'], 'leaves': 0}{'depth': 1, 'errors': ['too-deep'], 'leaves': 0}Passed
unterminated root{'depth': 1, 'errors': ['unclosed'], 'leaves': 1}{'depth': 1, 'errors': ['unclosed'], 'leaves': 1}Passed
deepest branch first{'depth': 3, 'errors': [], 'leaves': 2}{'depth': 3, 'errors': [], 'leaves': 2}Passed
stray close{'depth': 0, 'errors': ['stray-close'], 'leaves': 1}{'depth': 0, 'errors': ['stray-close'], 'leaves': 1}Passed
empty multipart{'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0}{'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0}Passed

SHA-256 / f39f31044efff6e93ac90d21f83f6151e2573cc85ce7ca59cf6750fd6187a75d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(events, max_depth):
    stack = []
    skip = 0
    leaves = 0
    depth = 0
    errors = []
    for ev in events:
        kind = ev[0]
        if skip:
            if kind == 'open':
                skip = min(skip + 1, 2)
            elif kind == 'close':
                skip -= 1
            continue
        if kind == 'open':
            if stack:
                stack[-1] += 1
            if len(stack) + 1 > max_depth:
                errors.append('too-deep')
                skip = 1
                continue
            stack.append(0)
            depth = max(depth, len(stack))
        elif kind == 'leaf':
            leaves += 1
            if stack:
                stack[-1] += 1
        elif not stack:
            errors.append('stray-close')
        elif stack.pop() == 0:
            errors.append('empty-multipart')
    if stack:
        errors.append('unclosed')
    return {'leaves': leaves, 'depth': depth, 'errors': errors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 1}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 4], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 1}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 1], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 1], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 2: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 2}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 5], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 2], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 2}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 2], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 2], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 3: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['leaf', 'image/png', 2], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 3}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 6], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 3], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1], ['leaf', 'text/plain', 2]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 3}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 3], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 3], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 4: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['leaf', 'image/png', 2], ['leaf', 'image/png', 3], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 4}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 7], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 4], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1], ['leaf', 'text/plain', 2], ['leaf', 'text/plain', 3]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 4}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 4], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 4], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})], 5: [('three levels with limit two', ([['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close'], ['leaf', 'image/png', 0], ['leaf', 'image/png', 1], ['leaf', 'image/png', 2], ['leaf', 'image/png', 3], ['leaf', 'image/png', 4], ['close']], 2), {'depth': 2, 'errors': ['too-deep'], 'leaves': 5}), ('deep skipped subtree', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['leaf', 'text/plain', 2], ['close'], ['leaf', 'text/plain', 8], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 1}), ('skipped child keeps parent non-empty', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['leaf', 'text/plain', 5], ['close'], ['close']], 1), {'depth': 1, 'errors': ['too-deep'], 'leaves': 0}), ('unterminated root', ([['open', 'multipart/mixed'], ['leaf', 'text/plain', 0], ['leaf', 'text/plain', 1], ['leaf', 'text/plain', 2], ['leaf', 'text/plain', 3], ['leaf', 'text/plain', 4]], 3), {'depth': 1, 'errors': ['unclosed'], 'leaves': 5}), ('deepest branch first', ([['open', 'multipart/mixed'], ['open', 'multipart/mixed'], ['open', 'multipart/alternative'], ['leaf', 'text/plain', 1], ['close'], ['close'], ['open', 'multipart/related'], ['leaf', 'text/html', 5], ['close'], ['close']], 5), {'depth': 3, 'errors': [], 'leaves': 2}), ('stray close', ([['leaf', 'text/plain', 5], ['close']], 2), {'depth': 0, 'errors': ['stray-close'], 'leaves': 1}), ('empty multipart', ([['open', 'multipart/mixed'], ['close']], 2), {'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, 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
three levels with limit two{'depth': 2, 'errors': ['too-deep'], 'leaves': 1}{'depth': 2, 'errors': ['too-deep'], 'leaves': 1}Passed
deep skipped subtree{'depth': 1, 'errors': ['too-deep', 'stray-close'], 'leaves': 2}{'depth': 1, 'errors': ['too-deep'], 'leaves': 1}Failed
skipped child keeps parent non-empty{'depth': 1, 'errors': ['too-deep'], 'leaves': 0}{'depth': 1, 'errors': ['too-deep'], 'leaves': 0}Passed
unterminated root{'depth': 1, 'errors': ['unclosed'], 'leaves': 1}{'depth': 1, 'errors': ['unclosed'], 'leaves': 1}Passed
deepest branch first{'depth': 3, 'errors': [], 'leaves': 2}{'depth': 3, 'errors': [], 'leaves': 2}Passed
stray close{'depth': 0, 'errors': ['stray-close'], 'leaves': 1}{'depth': 0, 'errors': ['stray-close'], 'leaves': 1}Passed
empty multipart{'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0}{'depth': 1, 'errors': ['empty-multipart'], 'leaves': 0}Passed

SHA-256 / 71a6a96b9e6152ac9c3108e0431beda5603fd3f97670de3f0eff456a72f3407f

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

Stipulated offline model over pre-parsed MIME dictionaries; not a conforming MIME parser, generator or mail client. 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:49:17.373606+00:00.

Case digest / 5b2dbb80e1e12029d139dadd3ffd0a8429fba1c789ed033280d74a27d17e88f0