{
 "use_case": "report-integrity",
 "title": "Report integrity: a workplace incident report checked against the interview transcript",
 "about": "A synthetic forklift-incident interview (timestamped transcript) and a supervisor's report written with planted problems: two statements the recording contradicts (thirty feet instead of ten; the backup alarm 'not working'), two statements the recording never makes (looking at a phone, prior incidents), and two events left out (the box hitting Kevin's shoulder, Kevin declining the clinic). Each planted sentence must be flagged, the faithful sentences supported, the left-out events listed as missing, and the signed statement must verify and catch an edit.",
 "licence": "Synthetic: a typed transcript and report written for Decosa (invented people, places and vehicles). Part of decosa-api, AGPL-3.0-or-later.",
 "inputs": [
  {
   "file": "inputs/forklift-interview-transcript.txt",
   "what": "The transcript of the recording, one utterance per line starting with a time and speaker, like [00:20] LUIS: ... Your own can also be diarizer segments (send \"segments\")."
  },
  {
   "file": "inputs/incident-report.txt",
   "what": "The report to check, as plain text (up to 12,000 characters)."
  },
  {
   "file": "inputs/what-was-planted.json",
   "what": "For reading only: the faithful version of the report and the list of planted discrepancies, with the transcript times they contradict."
  }
 ],
 "steps": [
  {
   "id": "check",
   "method": "POST",
   "path": "/report/check",
   "timeout": 240,
   "body": {
    "transcript": {
     "$file": "inputs/forklift-interview-transcript.txt"
    },
    "report": {
     "$file": "inputs/incident-report.txt"
    },
    "author": "Supervisor Moss",
    "kind": "workplace",
    "events": true
   }
  },
  {
   "id": "verify",
   "method": "POST",
   "path": "/report/verify",
   "auth": false,
   "body": {
    "statement": {
     "$ref": "check.signed"
    },
    "report": {
     "$file": "inputs/incident-report.txt"
    }
   }
  },
  {
   "id": "edited_report",
   "method": "POST",
   "path": "/report/verify",
   "auth": false,
   "body": {
    "statement": {
     "$ref": "check.signed"
    },
    "report": "Luis said he was backing the forklift out of aisle 12 when the rear wheel caught the corner of the pallet rack. He said Kevin was about ten feet behind him, picking, and jumped back when the boxes fell."
   }
  },
  {
   "id": "tampered",
   "method": "POST",
   "path": "/report/verify",
   "auth": false,
   "body": {
    "statement": {
     "$ref": "check.signed"
    }
   },
   "tamper": {
    "at": "statement.sentences[1].verdict",
    "set": "supported"
   }
  }
 ],
 "checks": [
  {
   "says": "every sentence got a verdict (none errored)",
   "path": "check.sentences[verdict=error]",
   "count": 0
  },
  {
   "says": "'thirty feet' (the recording says ten) is flagged",
   "path": "check.sentences[text~thirty feet][0].verdict",
   "in": [
    "contradicted",
    "partial",
    "unsupported"
   ]
  },
  {
   "says": "'the backup alarm was not working' (the recording says it was) is flagged",
   "path": "check.sentences[text~not working][0].verdict",
   "in": [
    "contradicted",
    "partial",
    "unsupported"
   ]
  },
  {
   "says": "'looking at his phone' (never said on the recording) is flagged",
   "path": "check.sentences[text~phone][0].verdict",
   "in": [
    "unsupported",
    "contradicted"
   ]
  },
  {
   "says": "'two prior forklift incidents' (never said on the recording) is flagged",
   "path": "check.sentences[text~prior forklift][0].verdict",
   "in": [
    "unsupported",
    "contradicted"
   ]
  },
  {
   "says": "the faithful 'walking speed' sentence is supported",
   "path": "check.sentences[text~walking speed][0].verdict",
   "equals": "supported"
  },
  {
   "says": "the left-out events (Kevin's shoulder, the declined clinic) are listed as missing",
   "path": "check.omissions[verdict=missing].what",
   "contains": [
    "shoulder",
    "clinic"
   ]
  },
  {
   "says": "the statement was signed by this server",
   "path": "verify.signed_by_this_server",
   "equals": true
  },
  {
   "says": "the signature is valid",
   "path": "verify.valid_signature",
   "equals": true
  },
  {
   "says": "the statement matches the report text",
   "path": "verify.text_matches",
   "equals": true
  },
  {
   "says": "an edited report no longer matches the signed statement",
   "path": "edited_report.text_matches",
   "equals": false
  },
  {
   "says": "a statement with one verdict changed no longer verifies",
   "path": "tampered.valid_signature",
   "equals": false
  },
  {
   "says": "every model call has a signed receipt",
   "receipts": "signed"
  }
 ]
}
