{"abstract":"The text of an attached message is shown as part of the body.","category":"Email MIME structure","checks":6,"contract":"Returns the text/plain strings to display in order. Types compare case-insensitively. multipart/alternative yields the result of its last child that yields any text; other multiparts concatenate their children. Entities with an attachment disposition yield nothing. A message/rfc822 without attachment disposition yields its body; text/plain yields its text; everything else yields nothing.","contract_signature":"tree","evaluation_group":"w2-email_mime_structure-display-text","failed_approach":"Exempting text/plain from the attachment rule shows attached log files instead. The attempted `if disp == 'attachment' and t != 'text/plain': return [] if t == 'message/rfc822': return walk(n['body'])` still disagrees with a fixture.","family":"w2-email_mime_structure-display-text-attachment-before-message","id":"FA-76646","implementations":{"attempt":{"sha256":"7f114b027a8e8215f5c25eb4f9df0d44c7b17c0aa2e4cb2f16b59853dfc17d21","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree):\n    def walk(n):\n        t = n['type'].lower()\n        disp = (n.get('disp') or 'inline').lower()\n        if t == 'multipart/alternative':\n            for child in reversed(n['parts']):\n                got = walk(child)\n                if got:\n                    return got\n            return []\n        if t.startswith('multipart/'):\n            out = []\n            for child in n['parts']:\n                out.extend(walk(child))\n            return out\n        if disp == 'attachment' and t != 'text/plain':\n            return []\n        if t == 'message/rfc822':\n            return walk(n['body'])\n        if t == 'text/plain':\n            return [n['text']]\n        return []\n    return walk(tree)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A1'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B1'}, {'type': 'image/png'}]}]},), ['B1']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 1'}, {'type': 'text/html'}]},), ['plain 1']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 1'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw1'}, {'type': 'text/html'}]}}]},), ['x', 'fw1']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't1'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t1', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 2: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A2'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B2'}, {'type': 'image/png'}]}]},), ['B2']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 2'}, {'type': 'text/html'}]},), ['plain 2']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 2'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw2'}, {'type': 'text/html'}]}}]},), ['x', 'fw2']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't2'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t2', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 3: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A3'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B3'}, {'type': 'image/png'}]}]},), ['B3']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 3'}, {'type': 'text/html'}]},), ['plain 3']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 3'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw3'}, {'type': 'text/html'}]}}]},), ['x', 'fw3']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't3'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t3', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 4: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A4'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B4'}, {'type': 'image/png'}]}]},), ['B4']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 4'}, {'type': 'text/html'}]},), ['plain 4']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 4'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw4'}, {'type': 'text/html'}]}}]},), ['x', 'fw4']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't4'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t4', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 5: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A5'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B5'}, {'type': 'image/png'}]}]},), ['B5']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 5'}, {'type': 'text/html'}]},), ['plain 5']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 5'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw5'}, {'type': 'text/html'}]}}]},), ['x', 'fw5']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't5'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t5', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])]}\nfor _label, _args, _expected in _CASES[N]:\n    check(_label, solve(*_args), _expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"991e16642bd89be52d1dc4b82881321f510d0e722b95300d189dc75697106f47","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree):\n    def walk(n):\n        t = n['type'].lower()\n        disp = (n.get('disp') or 'inline').lower()\n        if t == 'multipart/alternative':\n            for child in reversed(n['parts']):\n                got = walk(child)\n                if got:\n                    return got\n            return []\n        if t.startswith('multipart/'):\n            out = []\n            for child in n['parts']:\n                out.extend(walk(child))\n            return out\n        if t == 'message/rfc822':\n            return walk(n['body'])\n        if disp == 'attachment':\n            return []\n        if t == 'text/plain':\n            return [n['text']]\n        return []\n    return walk(tree)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A1'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B1'}, {'type': 'image/png'}]}]},), ['B1']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 1'}, {'type': 'text/html'}]},), ['plain 1']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 1'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw1'}, {'type': 'text/html'}]}}]},), ['x', 'fw1']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't1'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t1', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 2: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A2'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B2'}, {'type': 'image/png'}]}]},), ['B2']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 2'}, {'type': 'text/html'}]},), ['plain 2']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 2'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw2'}, {'type': 'text/html'}]}}]},), ['x', 'fw2']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't2'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t2', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 3: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A3'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B3'}, {'type': 'image/png'}]}]},), ['B3']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 3'}, {'type': 'text/html'}]},), ['plain 3']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 3'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw3'}, {'type': 'text/html'}]}}]},), ['x', 'fw3']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't3'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t3', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 4: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A4'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B4'}, {'type': 'image/png'}]}]},), ['B4']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 4'}, {'type': 'text/html'}]},), ['plain 4']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 4'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw4'}, {'type': 'text/html'}]}}]},), ['x', 'fw4']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't4'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t4', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])], 5: [('richer alternative holds text', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'A5'}, {'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'B5'}, {'type': 'image/png'}]}]},), ['B5']), ('html last alternative', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'plain 5'}, {'type': 'text/html'}]},), ['plain 5']), ('attached message and log', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'hi'}, {'type': 'message/rfc822', 'disp': 'attachment', 'body': {'type': 'text/plain', 'text': 'inner'}}, {'type': 'text/plain', 'disp': 'attachment', 'text': 'log 5'}]},), ['hi']), ('inline forwarded alternative', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'text': 'x'}, {'type': 'message/rfc822', 'body': {'type': 'multipart/alternative', 'parts': [{'type': 'text/plain', 'text': 'fw5'}, {'type': 'text/html'}]}}]},), ['x', 'fw5']), ('mixed-case types', ({'type': 'MULTIPART/Mixed', 'parts': [{'type': 'Text/Plain', 'text': 't5'}, {'type': 'TEXT/PLAIN', 'text': 'u'}]},), ['t5', 'u']), ('no text at all', ({'type': 'multipart/mixed', 'parts': [{'type': 'image/png'}, {'type': 'application/pdf'}]},), [])]}\nfor _label, _args, _expected in _CASES[N]:\n    check(_label, solve(*_args), _expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-email_mime_structure-display-text-attachment-before-message","generated_at":"2026-09-29T14:49:18.097366+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Text extraction powers previews, replies and search; wrong choices quote attachments or skip the real body.","root_cause":"The attachment before message decision evaluates `if t == 'message/rfc822': return walk(n['body']) if disp == 'attachment': return []` where the contract requires `if disp == 'attachment': return [] if t == 'message/rfc822': return walk(n['body'])`.","sha256":"731f4e8b583127731e0bcc43c6e2804d2a4f018a93af61530ea207da16f1e0f8","title":"Collect the plain-text body to display: attachment before message · case 01","variant":1,"variant_policy":"N selects a different enumerated fixture set (renamed identifiers, part counts and sizes); boundary fixtures recur across variants.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":38.791,"exit_code":1,"observations":[{"actual":["B1"],"check":"richer alternative holds text","expected":["B1"],"passed":true},{"actual":["plain 1"],"check":"html last alternative","expected":["plain 1"],"passed":true},{"actual":["hi","log 1"],"check":"attached message and log","expected":["hi"],"passed":false},{"actual":["x","fw1"],"check":"inline forwarded alternative","expected":["x","fw1"],"passed":true},{"actual":["t1","u"],"check":"mixed-case types","expected":["t1","u"],"passed":true},{"actual":[],"check":"no text at all","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"richer alternative holds text\", \"actual\": [\"B1\"], \"expected\": [\"B1\"], \"passed\": true}, {\"check\": \"html last alternative\", \"actual\": [\"plain 1\"], \"expected\": [\"plain 1\"], \"passed\": true}, {\"check\": \"attached message and log\", \"actual\": [\"hi\", \"log 1\"], \"expected\": [\"hi\"], \"passed\": false}, {\"check\": \"inline forwarded alternative\", \"actual\": [\"x\", \"fw1\"], \"expected\": [\"x\", \"fw1\"], \"passed\": true}, {\"check\": \"mixed-case types\", \"actual\": [\"t1\", \"u\"], \"expected\": [\"t1\", \"u\"], \"passed\": true}, {\"check\": \"no text at all\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.315,"exit_code":1,"observations":[{"actual":["B1"],"check":"richer alternative holds text","expected":["B1"],"passed":true},{"actual":["plain 1"],"check":"html last alternative","expected":["plain 1"],"passed":true},{"actual":["hi","inner"],"check":"attached message and log","expected":["hi"],"passed":false},{"actual":["x","fw1"],"check":"inline forwarded alternative","expected":["x","fw1"],"passed":true},{"actual":["t1","u"],"check":"mixed-case types","expected":["t1","u"],"passed":true},{"actual":[],"check":"no text at all","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"richer alternative holds text\", \"actual\": [\"B1\"], \"expected\": [\"B1\"], \"passed\": true}, {\"check\": \"html last alternative\", \"actual\": [\"plain 1\"], \"expected\": [\"plain 1\"], \"passed\": true}, {\"check\": \"attached message and log\", \"actual\": [\"hi\", \"inner\"], \"expected\": [\"hi\"], \"passed\": false}, {\"check\": \"inline forwarded alternative\", \"actual\": [\"x\", \"fw1\"], \"expected\": [\"x\", \"fw1\"], \"passed\": true}, {\"check\": \"mixed-case types\", \"actual\": [\"t1\", \"u\"], \"expected\": [\"t1\", \"u\"], \"passed\": true}, {\"check\": \"no text at all\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}