{"abstract":"Attachments precede the body in multipart/mixed, so clients show an attachment as the message.","category":"Email MIME structure","checks":7,"contract":"The body is multipart/alternative(text, html) when both versions exist, the html alone when only html exists, else text. Inline images go into multipart/related with the html root first; without html they become attachments. When there are attachments the result is multipart/mixed(body, attachments...). Output is a compact string such as \"mixed(alternative(text,related(html,img)),att)\".","contract_signature":"has_text, has_html, inline_images, attachments","evaluation_group":"w2-email_mime_structure-compose-skeleton","failed_approach":"Placing one attachment before the body still puts an attachment first. The attempted `['att'] + [body] + ['att'] * (atts - 1)` still disagrees with a fixture.","family":"w2-email_mime_structure-compose-skeleton-body-before-attachments","id":"FA-76576","implementations":{"attempt":{"sha256":"fb9882353936f01aad6816a126d649048f45ac150756b02660515d625970c486","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(has_text, has_html, inline_images, attachments):\n    atts = attachments\n    html = None\n    if has_html:\n        html = 'html' if inline_images == 0 else 'related(' + ','.join(['html'] + ['img'] * inline_images) + ')'\n    else:\n        atts += inline_images\n    if has_text and html:\n        body = 'alternative(text,' + html + ')'\n    elif html:\n        body = html\n    else:\n        body = 'text'\n    if atts:\n        return 'mixed(' + ','.join(['att'] + [body] + ['att'] * (atts - 1)) + ')'\n    return body\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('images without html', (False, False, 2, 0), 'mixed(text,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 2, 0), 'alternative(text,related(html,img,img))'), ('html images and attachment', (False, True, 1, 1), 'mixed(related(html,img),att)'), ('text and attachments', (True, False, 0, 1), 'mixed(text,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 1), 'mixed(alternative(text,related(html,img,img)),att)')], 2: [('images without html', (False, False, 3, 0), 'mixed(text,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 3, 0), 'alternative(text,related(html,img,img,img))'), ('html images and attachment', (False, True, 2, 1), 'mixed(related(html,img,img),att)'), ('text and attachments', (True, False, 0, 2), 'mixed(text,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 2), 'mixed(alternative(text,related(html,img,img)),att,att)')], 3: [('images without html', (False, False, 4, 0), 'mixed(text,att,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 4, 0), 'alternative(text,related(html,img,img,img,img))'), ('html images and attachment', (False, True, 3, 1), 'mixed(related(html,img,img,img),att)'), ('text and attachments', (True, False, 0, 3), 'mixed(text,att,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 3), 'mixed(alternative(text,related(html,img,img)),att,att,att)')], 4: [('images without html', (False, False, 5, 0), 'mixed(text,att,att,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 5, 0), 'alternative(text,related(html,img,img,img,img,img))'), ('html images and attachment', (False, True, 4, 1), 'mixed(related(html,img,img,img,img),att)'), ('text and attachments', (True, False, 0, 4), 'mixed(text,att,att,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 4), 'mixed(alternative(text,related(html,img,img)),att,att,att,att)')], 5: [('images without html', (False, False, 6, 0), 'mixed(text,att,att,att,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 6, 0), 'alternative(text,related(html,img,img,img,img,img,img))'), ('html images and attachment', (False, True, 5, 1), 'mixed(related(html,img,img,img,img,img),att)'), ('text and attachments', (True, False, 0, 5), 'mixed(text,att,att,att,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 5), 'mixed(alternative(text,related(html,img,img)),att,att,att,att,att)')]}\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":"105d450c047f8ff50c1d4cca9537324d7561e24acb8ad99aad54fd237155c378","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(has_text, has_html, inline_images, attachments):\n    atts = attachments\n    html = None\n    if has_html:\n        html = 'html' if inline_images == 0 else 'related(' + ','.join(['html'] + ['img'] * inline_images) + ')'\n    else:\n        atts += inline_images\n    if has_text and html:\n        body = 'alternative(text,' + html + ')'\n    elif html:\n        body = html\n    else:\n        body = 'text'\n    if atts:\n        return 'mixed(' + ','.join(['att'] * atts + [body]) + ')'\n    return body\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('images without html', (False, False, 2, 0), 'mixed(text,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 2, 0), 'alternative(text,related(html,img,img))'), ('html images and attachment', (False, True, 1, 1), 'mixed(related(html,img),att)'), ('text and attachments', (True, False, 0, 1), 'mixed(text,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 1), 'mixed(alternative(text,related(html,img,img)),att)')], 2: [('images without html', (False, False, 3, 0), 'mixed(text,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 3, 0), 'alternative(text,related(html,img,img,img))'), ('html images and attachment', (False, True, 2, 1), 'mixed(related(html,img,img),att)'), ('text and attachments', (True, False, 0, 2), 'mixed(text,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 2), 'mixed(alternative(text,related(html,img,img)),att,att)')], 3: [('images without html', (False, False, 4, 0), 'mixed(text,att,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 4, 0), 'alternative(text,related(html,img,img,img,img))'), ('html images and attachment', (False, True, 3, 1), 'mixed(related(html,img,img,img),att)'), ('text and attachments', (True, False, 0, 3), 'mixed(text,att,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 3), 'mixed(alternative(text,related(html,img,img)),att,att,att)')], 4: [('images without html', (False, False, 5, 0), 'mixed(text,att,att,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 5, 0), 'alternative(text,related(html,img,img,img,img,img))'), ('html images and attachment', (False, True, 4, 1), 'mixed(related(html,img,img,img,img),att)'), ('text and attachments', (True, False, 0, 4), 'mixed(text,att,att,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 4), 'mixed(alternative(text,related(html,img,img)),att,att,att,att)')], 5: [('images without html', (False, False, 6, 0), 'mixed(text,att,att,att,att,att,att)'), ('text and html', (True, True, 0, 0), 'alternative(text,html)'), ('text html and images', (True, True, 6, 0), 'alternative(text,related(html,img,img,img,img,img,img))'), ('html images and attachment', (False, True, 5, 1), 'mixed(related(html,img,img,img,img,img),att)'), ('text and attachments', (True, False, 0, 5), 'mixed(text,att,att,att,att,att)'), ('plain text only', (True, False, 0, 0), 'text'), ('everything', (True, True, 2, 5), 'mixed(alternative(text,related(html,img,img)),att,att,att,att,att)')]}\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-compose-skeleton-body-before-attachments","generated_at":"2026-09-29T14:49:17.457935+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Composing the wrong skeleton makes clients show images as attachments, hide the plain-text version or drop parts.","root_cause":"The body before attachments decision evaluates `['att'] * atts + [body]` where the contract requires `[body] + ['att'] * atts`.","sha256":"a66f7d3803e04e021f929ed4a96fd2560052a797a0e367b6f13e276fe72f50d0","title":"Choose the MIME skeleton for an outgoing message: body before attachments · 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.568,"exit_code":1,"observations":[{"actual":"mixed(att,text,att)","check":"images without html","expected":"mixed(text,att,att)","passed":false},{"actual":"alternative(text,html)","check":"text and html","expected":"alternative(text,html)","passed":true},{"actual":"alternative(text,related(html,img,img))","check":"text html and images","expected":"alternative(text,related(html,img,img))","passed":true},{"actual":"mixed(att,related(html,img))","check":"html images and attachment","expected":"mixed(related(html,img),att)","passed":false},{"actual":"mixed(att,text)","check":"text and attachments","expected":"mixed(text,att)","passed":false},{"actual":"text","check":"plain text only","expected":"text","passed":true},{"actual":"mixed(att,alternative(text,related(html,img,img)))","check":"everything","expected":"mixed(alternative(text,related(html,img,img)),att)","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"images without html\", \"actual\": \"mixed(att,text,att)\", \"expected\": \"mixed(text,att,att)\", \"passed\": false}, {\"check\": \"text and html\", \"actual\": \"alternative(text,html)\", \"expected\": \"alternative(text,html)\", \"passed\": true}, {\"check\": \"text html and images\", \"actual\": \"alternative(text,related(html,img,img))\", \"expected\": \"alternative(text,related(html,img,img))\", \"passed\": true}, {\"check\": \"html images and attachment\", \"actual\": \"mixed(att,related(html,img))\", \"expected\": \"mixed(related(html,img),att)\", \"passed\": false}, {\"check\": \"text and attachments\", \"actual\": \"mixed(att,text)\", \"expected\": \"mixed(text,att)\", \"passed\": false}, {\"check\": \"plain text only\", \"actual\": \"text\", \"expected\": \"text\", \"passed\": true}, {\"check\": \"everything\", \"actual\": \"mixed(att,alternative(text,related(html,img,img)))\", \"expected\": \"mixed(alternative(text,related(html,img,img)),att)\", \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.554,"exit_code":1,"observations":[{"actual":"mixed(att,att,text)","check":"images without html","expected":"mixed(text,att,att)","passed":false},{"actual":"alternative(text,html)","check":"text and html","expected":"alternative(text,html)","passed":true},{"actual":"alternative(text,related(html,img,img))","check":"text html and images","expected":"alternative(text,related(html,img,img))","passed":true},{"actual":"mixed(att,related(html,img))","check":"html images and attachment","expected":"mixed(related(html,img),att)","passed":false},{"actual":"mixed(att,text)","check":"text and attachments","expected":"mixed(text,att)","passed":false},{"actual":"text","check":"plain text only","expected":"text","passed":true},{"actual":"mixed(att,alternative(text,related(html,img,img)))","check":"everything","expected":"mixed(alternative(text,related(html,img,img)),att)","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"images without html\", \"actual\": \"mixed(att,att,text)\", \"expected\": \"mixed(text,att,att)\", \"passed\": false}, {\"check\": \"text and html\", \"actual\": \"alternative(text,html)\", \"expected\": \"alternative(text,html)\", \"passed\": true}, {\"check\": \"text html and images\", \"actual\": \"alternative(text,related(html,img,img))\", \"expected\": \"alternative(text,related(html,img,img))\", \"passed\": true}, {\"check\": \"html images and attachment\", \"actual\": \"mixed(att,related(html,img))\", \"expected\": \"mixed(related(html,img),att)\", \"passed\": false}, {\"check\": \"text and attachments\", \"actual\": \"mixed(att,text)\", \"expected\": \"mixed(text,att)\", \"passed\": false}, {\"check\": \"plain text only\", \"actual\": \"text\", \"expected\": \"text\", \"passed\": true}, {\"check\": \"everything\", \"actual\": \"mixed(att,alternative(text,related(html,img,img)))\", \"expected\": \"mixed(alternative(text,related(html,img,img)),att)\", \"passed\": false}], \"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."}}