{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ghrisx.com/schemas/decision-trace-record-v1.json",
  "title": "Ghrisx Decision Trace Record v1",
  "description": "Privacy-minimized, local-only working record. It contains bounded categories, never a case body or personal identity.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "locale",
    "visibility",
    "local_only",
    "generated_in_browser",
    "transmitted_by_page",
    "stored_by_page",
    "analyzed_by_page",
    "profile_created",
    "scored",
    "ranked",
    "diagnosed",
    "personalized",
    "scenario_not_forecast",
    "dossier_id",
    "human_baseline",
    "trace_stage",
    "decision_object",
    "evidence_status",
    "proposed_consequence",
    "accountable_human_role",
    "challenge_state",
    "correction_state",
    "review_or_expiry_date",
    "remedy_state",
    "explicit_non_claim"
  ],
  "properties": {
    "schema": {
      "const": "ghrisx.decision-trace-record.v1"
    },
    "locale": {
      "enum": [
        "en-US",
        "es-US",
        "en",
        "zh",
        "hi",
        "es",
        "fr",
        "ar",
        "bn",
        "pt",
        "ru",
        "ur",
        "zh-Hans"
      ]
    },
    "visibility": {
      "const": "private_working_copy"
    },
    "local_only": {
      "const": true
    },
    "generated_in_browser": {
      "const": true
    },
    "transmitted_by_page": {
      "const": false
    },
    "stored_by_page": {
      "const": false
    },
    "analyzed_by_page": {
      "const": false
    },
    "profile_created": {
      "const": false
    },
    "scored": {
      "const": false
    },
    "ranked": {
      "const": false
    },
    "diagnosed": {
      "const": false
    },
    "personalized": {
      "const": false
    },
    "scenario_not_forecast": {
      "const": true
    },
    "dossier_id": {
      "enum": [
        "JD-01",
        "JD-02",
        "JD-03",
        "JD-04",
        "JD-05",
        "JD-06",
        "JD-07",
        "JD-08"
      ]
    },
    "human_baseline": {
      "enum": [
        "HS-01",
        "HS-02",
        "HS-03",
        "HS-04",
        "HS-05",
        "HS-06",
        "HS-07",
        "HS-08"
      ]
    },
    "trace_stage": {
      "enum": [
        "JT-01",
        "JT-02",
        "JT-03",
        "JT-04",
        "JT-05",
        "JT-06"
      ]
    },
    "decision_object": {
      "enum": [
        "access_decision",
        "employment_decision",
        "moderation_decision",
        "benefit_decision",
        "identity_decision",
        "investigation_referral",
        "cross_context_reuse"
      ]
    },
    "evidence_status": {
      "enum": [
        "observed_primary_record",
        "source_disputed",
        "inference_only",
        "missing_material_context",
        "uncertainty_unresolved"
      ]
    },
    "proposed_consequence": {
      "enum": [
        "none_advisory_only",
        "delay_or_hold",
        "denial_or_removal",
        "sanction_or_recovery",
        "investigation_or_referral",
        "downstream_propagation"
      ]
    },
    "accountable_human_role": {
      "enum": [
        "RC-01",
        "RC-02",
        "RC-03",
        "RC-04",
        "RC-05",
        "RC-06",
        "RC-07",
        "RC-08"
      ]
    },
    "challenge_state": {
      "enum": [
        "not_started",
        "notice_requested",
        "challenge_initiated",
        "human_review_pending",
        "challenge_decided"
      ]
    },
    "correction_state": {
      "enum": [
        "none_recorded",
        "source_correction_requested",
        "authoritative_record_corrected",
        "downstream_correction_pending",
        "correction_propagated"
      ]
    },
    "review_or_expiry_date": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "format": "date",
          "pattern": "^(20[0-9]{2}|2100)-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$"
        }
      ]
    },
    "remedy_state": {
      "enum": [
        "not_requested",
        "requested",
        "interim_protection",
        "partial",
        "completed",
        "refused"
      ]
    },
    "explicit_non_claim": {
      "type": "string",
      "minLength": 30,
      "maxLength": 220
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-01"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-01"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-02"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-02"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-03"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-03"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-04"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-04"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-05"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-05"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-06"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-06"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-07"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-07"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "dossier_id": {
            "const": "JD-08"
          }
        }
      },
      "then": {
        "properties": {
          "human_baseline": {
            "const": "HS-08"
          }
        }
      }
    }
  ]
}
