{"abstract":"An image the sender explicitly attached disappears into the body because the HTML happens to reference it.","category":"Email MIME structure","checks":8,"contract":"parts are the leaves of a multipart/mixed message in order: {type, disp, cid, filename}. Rules in order: an explicit \"attachment\" disposition (case-insensitive) is an attachment even when referenced; a part whose cid is exactly one of html_cids is inline; the first text/* part without a (non-empty) filename is the body; an explicit inline image/* is inline; everything else is an attachment.","evaluation_group":"w2-email_mime_structure-disposition-classify","failed_approach":"Exempting images from the explicit disposition has the same effect for referenced images. The attempted `if disp == 'attachment' and not p['type'].startswith('image/'):` still disagrees with a fixture.","family":"w2-email_mime_structure-disposition-classify-explicit-attachment-first","id":"FA-76406","implementations":{"attempt":{"sha256":"bea6f40c7235093b752aa40f27058eab58e0d4ce0cb16e67457c4a1f25f41a62","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(parts, html_cids):\n    out = []\n    have_body = False\n    for p in parts:\n        disp = (p.get('disp') or '').lower()\n        if disp == 'attachment' and not p['type'].startswith('image/'):\n            kind = 'attachment'\n        elif p.get('cid') and p['cid'] in html_cids:\n            kind = 'inline'\n        elif p['type'].startswith('text/') and not p.get('filename') and not have_body:\n            kind = 'body'\n            have_body = True\n        elif disp == 'inline' and p['type'].startswith('image/'):\n            kind = 'inline'\n        else:\n            kind = 'attachment'\n        out.append(kind)\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo1@x', 'disp': 'attachment'}], ['logo1@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes1.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a1@x'}, {'type': 'image/png', 'cid': 'ba1@x'}], ['a1@x']), ['body', 'inline', 'attachment'])], 2: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo2@x', 'disp': 'attachment'}], ['logo2@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes2.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a2@x'}, {'type': 'image/png', 'cid': 'ba2@x'}], ['a2@x']), ['body', 'inline', 'attachment'])], 3: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo3@x', 'disp': 'attachment'}], ['logo3@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes3.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a3@x'}, {'type': 'image/png', 'cid': 'ba3@x'}], ['a3@x']), ['body', 'inline', 'attachment'])], 4: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo4@x', 'disp': 'attachment'}], ['logo4@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes4.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a4@x'}, {'type': 'image/png', 'cid': 'ba4@x'}], ['a4@x']), ['body', 'inline', 'attachment'])], 5: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo5@x', 'disp': 'attachment'}], ['logo5@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes5.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a5@x'}, {'type': 'image/png', 'cid': 'ba5@x'}], ['a5@x']), ['body', 'inline', 'attachment'])]}\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":"510259ac72c940e443e00b4c90a2b9c55d5d802ead90e47ede0664efb687160a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(parts, html_cids):\n    out = []\n    have_body = False\n    for p in parts:\n        disp = (p.get('disp') or '').lower()\n        if disp == 'attachment' and p.get('cid') not in html_cids:\n            kind = 'attachment'\n        elif p.get('cid') and p['cid'] in html_cids:\n            kind = 'inline'\n        elif p['type'].startswith('text/') and not p.get('filename') and not have_body:\n            kind = 'body'\n            have_body = True\n        elif disp == 'inline' and p['type'].startswith('image/'):\n            kind = 'inline'\n        else:\n            kind = 'attachment'\n        out.append(kind)\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo1@x', 'disp': 'attachment'}], ['logo1@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes1.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a1@x'}, {'type': 'image/png', 'cid': 'ba1@x'}], ['a1@x']), ['body', 'inline', 'attachment'])], 2: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo2@x', 'disp': 'attachment'}], ['logo2@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes2.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a2@x'}, {'type': 'image/png', 'cid': 'ba2@x'}], ['a2@x']), ['body', 'inline', 'attachment'])], 3: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo3@x', 'disp': 'attachment'}], ['logo3@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes3.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a3@x'}, {'type': 'image/png', 'cid': 'ba3@x'}], ['a3@x']), ['body', 'inline', 'attachment'])], 4: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo4@x', 'disp': 'attachment'}], ['logo4@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes4.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a4@x'}, {'type': 'image/png', 'cid': 'ba4@x'}], ['a4@x']), ['body', 'inline', 'attachment'])], 5: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo5@x', 'disp': 'attachment'}], ['logo5@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes5.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a5@x'}, {'type': 'image/png', 'cid': 'ba5@x'}], ['a5@x']), ['body', 'inline', 'attachment'])]}\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"},"fixed":{"sha256":"2acfea1345e09119285fb28ee09392f1534e048123e83675b1bf5f1d465ca00c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(parts, html_cids):\n    out = []\n    have_body = False\n    for p in parts:\n        disp = (p.get('disp') or '').lower()\n        if disp == 'attachment':\n            kind = 'attachment'\n        elif p.get('cid') and p['cid'] in html_cids:\n            kind = 'inline'\n        elif p['type'].startswith('text/') and not p.get('filename') and not have_body:\n            kind = 'body'\n            have_body = True\n        elif disp == 'inline' and p['type'].startswith('image/'):\n            kind = 'inline'\n        else:\n            kind = 'attachment'\n        out.append(kind)\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo1@x', 'disp': 'attachment'}], ['logo1@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes1.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a1@x'}, {'type': 'image/png', 'cid': 'ba1@x'}], ['a1@x']), ['body', 'inline', 'attachment'])], 2: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo2@x', 'disp': 'attachment'}], ['logo2@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes2.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a2@x'}, {'type': 'image/png', 'cid': 'ba2@x'}], ['a2@x']), ['body', 'inline', 'attachment'])], 3: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo3@x', 'disp': 'attachment'}], ['logo3@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes3.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a3@x'}, {'type': 'image/png', 'cid': 'ba3@x'}], ['a3@x']), ['body', 'inline', 'attachment'])], 4: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo4@x', 'disp': 'attachment'}], ['logo4@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes4.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a4@x'}, {'type': 'image/png', 'cid': 'ba4@x'}], ['a4@x']), ['body', 'inline', 'attachment'])], 5: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo5@x', 'disp': 'attachment'}], ['logo5@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes5.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a5@x'}, {'type': 'image/png', 'cid': 'ba5@x'}], ['a5@x']), ['body', 'inline', 'attachment'])]}\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-disposition-classify-explicit-attachment-first","generated_at":"2026-09-29T14:49:16.005828+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Disposition decides what the reader sees in the message body and what is offered for download.","repair":"Use `if disp == 'attachment':` for the explicit attachment first decision and keep every other rule of the model unchanged.","root_cause":"The explicit attachment first decision evaluates `if disp == 'attachment' and p.get('cid') not in html_cids:` where the contract requires `if disp == 'attachment':`.","sha256":"f58f273a37540fe3e1d4689ee9ed791bc42d62a72184ab70f6492bd19c57e569","title":"Classify leaf parts as body, inline or attachment: explicit attachment first · case 01","variant":1,"variant_policy":"N selects a different enumerated fixture set (renamed identifiers, part counts and sizes); boundary fixtures recur across variants.","verification":{"attempt":{"elapsed_ms":40.015,"exit_code":1,"observations":[{"actual":["body","inline"],"check":"referenced image marked attachment","expected":["body","attachment"],"passed":false},{"actual":["attachment","body"],"check":"upper-case disposition","expected":["attachment","body"],"passed":true},{"actual":["body","attachment"],"check":"second text part","expected":["body","attachment"],"passed":true},{"actual":["attachment","body","attachment"],"check":"attachment precedes body","expected":["attachment","body","attachment"],"passed":true},{"actual":["attachment","body"],"check":"named text part","expected":["attachment","body"],"passed":true},{"actual":["body"],"check":"empty filename","expected":["body"],"passed":true},{"actual":["body","attachment","attachment","inline"],"check":"inline non-images","expected":["body","attachment","attachment","inline"],"passed":true},{"actual":["body","inline","attachment"],"check":"cid substring","expected":["body","inline","attachment"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"referenced image marked attachment\", \"actual\": [\"body\", \"inline\"], \"expected\": [\"body\", \"attachment\"], \"passed\": false}, {\"check\": \"upper-case disposition\", \"actual\": [\"attachment\", \"body\"], \"expected\": [\"attachment\", \"body\"], \"passed\": true}, {\"check\": \"second text part\", \"actual\": [\"body\", \"attachment\"], \"expected\": [\"body\", \"attachment\"], \"passed\": true}, {\"check\": \"attachment precedes body\", \"actual\": [\"attachment\", \"body\", \"attachment\"], \"expected\": [\"attachment\", \"body\", \"attachment\"], \"passed\": true}, {\"check\": \"named text part\", \"actual\": [\"attachment\", \"body\"], \"expected\": [\"attachment\", \"body\"], \"passed\": true}, {\"check\": \"empty filename\", \"actual\": [\"body\"], \"expected\": [\"body\"], \"passed\": true}, {\"check\": \"inline non-images\", \"actual\": [\"body\", \"attachment\", \"attachment\", \"inline\"], \"expected\": [\"body\", \"attachment\", \"attachment\", \"inline\"], \"passed\": true}, {\"check\": \"cid substring\", \"actual\": [\"body\", \"inline\", \"attachment\"], \"expected\": [\"body\", \"inline\", \"attachment\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.163,"exit_code":1,"observations":[{"actual":["body","inline"],"check":"referenced image marked attachment","expected":["body","attachment"],"passed":false},{"actual":["attachment","body"],"check":"upper-case disposition","expected":["attachment","body"],"passed":true},{"actual":["body","attachment"],"check":"second text part","expected":["body","attachment"],"passed":true},{"actual":["attachment","body","attachment"],"check":"attachment precedes body","expected":["attachment","body","attachment"],"passed":true},{"actual":["attachment","body"],"check":"named text part","expected":["attachment","body"],"passed":true},{"actual":["body"],"check":"empty filename","expected":["body"],"passed":true},{"actual":["body","attachment","attachment","inline"],"check":"inline non-images","expected":["body","attachment","attachment","inline"],"passed":true},{"actual":["body","inline","attachment"],"check":"cid substring","expected":["body","inline","attachment"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"referenced image marked attachment\", \"actual\": [\"body\", \"inline\"], \"expected\": [\"body\", \"attachment\"], \"passed\": false}, {\"check\": \"upper-case disposition\", \"actual\": [\"attachment\", \"body\"], \"expected\": [\"attachment\", \"body\"], \"passed\": true}, {\"check\": \"second text part\", \"actual\": [\"body\", \"attachment\"], \"expected\": [\"body\", \"attachment\"], \"passed\": true}, {\"check\": \"attachment precedes body\", \"actual\": [\"attachment\", \"body\", \"attachment\"], \"expected\": [\"attachment\", \"body\", \"attachment\"], \"passed\": true}, {\"check\": \"named text part\", \"actual\": [\"attachment\", \"body\"], \"expected\": [\"attachment\", \"body\"], \"passed\": true}, {\"check\": \"empty filename\", \"actual\": [\"body\"], \"expected\": [\"body\"], \"passed\": true}, {\"check\": \"inline non-images\", \"actual\": [\"body\", \"attachment\", \"attachment\", \"inline\"], \"expected\": [\"body\", \"attachment\", \"attachment\", \"inline\"], \"passed\": true}, {\"check\": \"cid substring\", \"actual\": [\"body\", \"inline\", \"attachment\"], \"expected\": [\"body\", \"inline\", \"attachment\"], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":39.599,"exit_code":0,"observations":[{"actual":["body","attachment"],"check":"referenced image marked attachment","expected":["body","attachment"],"passed":true},{"actual":["attachment","body"],"check":"upper-case disposition","expected":["attachment","body"],"passed":true},{"actual":["body","attachment"],"check":"second text part","expected":["body","attachment"],"passed":true},{"actual":["attachment","body","attachment"],"check":"attachment precedes body","expected":["attachment","body","attachment"],"passed":true},{"actual":["attachment","body"],"check":"named text part","expected":["attachment","body"],"passed":true},{"actual":["body"],"check":"empty filename","expected":["body"],"passed":true},{"actual":["body","attachment","attachment","inline"],"check":"inline non-images","expected":["body","attachment","attachment","inline"],"passed":true},{"actual":["body","inline","attachment"],"check":"cid substring","expected":["body","inline","attachment"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"referenced image marked attachment\", \"actual\": [\"body\", \"attachment\"], \"expected\": [\"body\", \"attachment\"], \"passed\": true}, {\"check\": \"upper-case disposition\", \"actual\": [\"attachment\", \"body\"], \"expected\": [\"attachment\", \"body\"], \"passed\": true}, {\"check\": \"second text part\", \"actual\": [\"body\", \"attachment\"], \"expected\": [\"body\", \"attachment\"], \"passed\": true}, {\"check\": \"attachment precedes body\", \"actual\": [\"attachment\", \"body\", \"attachment\"], \"expected\": [\"attachment\", \"body\", \"attachment\"], \"passed\": true}, {\"check\": \"named text part\", \"actual\": [\"attachment\", \"body\"], \"expected\": [\"attachment\", \"body\"], \"passed\": true}, {\"check\": \"empty filename\", \"actual\": [\"body\"], \"expected\": [\"body\"], \"passed\": true}, {\"check\": \"inline non-images\", \"actual\": [\"body\", \"attachment\", \"attachment\", \"inline\"], \"expected\": [\"body\", \"attachment\", \"attachment\", \"inline\"], \"passed\": true}, {\"check\": \"cid substring\", \"actual\": [\"body\", \"inline\", \"attachment\"], \"expected\": [\"body\", \"inline\", \"attachment\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}