{
 "use_case": "legal-drafting-editor",
 "title": "Drafting editor: a synthetic services agreement against a fictional firm's playbook",
 "about": "A two-page synthetic services agreement (Northwind / Brightwell) as a .docx, reviewed against three rules of a fictional firm's playbook and precedent library, both sent as files. Texas law must be found outside the playbook and redlined to New York, the 30-day warranty flagged, and the mutual exclusion of indirect loss found; the redline must pass its checks (reject-all gives the input, accept-all the proposal) with no untraced words, and the signed record must verify.",
 "licence": "Synthetic: Northwind, Brightwell and Halvorsen & Pike LLP are fictional; the contract, playbook and precedent clauses were written for the Decosa demo. Part of decosa-api, AGPL-3.0-or-later.",
 "inputs": [
  {
   "file": "inputs/northwind-msa.docx",
   "what": "The contract as a Word file (text-based .docx, up to about 60 pages); plain text also works."
  },
  {
   "file": "inputs/playbook.json",
   "what": "The firm's playbook: per rule, the question, preferred / fallback / walk-away positions, what to do when outside, and precedent ids."
  },
  {
   "file": "inputs/precedents.json",
   "what": "The precedent clause library the edits are drawn from, tagged by topic and position ({Client} and {Counterparty} placeholders)."
  }
 ],
 "steps": [
  {
   "id": "review",
   "method": "POST",
   "path": "/drafting/review",
   "timeout": 300,
   "body": {
    "docx_b64": {
     "$b64": "inputs/northwind-msa.docx"
    },
    "playbook": {
     "$file": "inputs/playbook.json"
    },
    "precedents": {
     "$file": "inputs/precedents.json"
    },
    "rules": [
     "GL",
     "WARR",
     "CONSEQ"
    ],
    "parties": {
     "client": "Customer",
     "counterparty": "Provider"
    },
    "title": "Rehearsal: Northwind services agreement (synthetic)",
    "stream": false
   }
  },
  {
   "id": "export",
   "method": "GET",
   "path": "/drafting/runs/${review.run_id}/export?format=md",
   "as": "text"
  },
  {
   "id": "verify",
   "method": "POST",
   "path": "/record/verify",
   "auth": false,
   "body": {
    "record": {
     "$ref": "review.report.record"
    }
   }
  },
  {
   "id": "tampered",
   "method": "POST",
   "path": "/record/verify",
   "auth": false,
   "body": {
    "record": {
     "$ref": "review.report.record"
    }
   },
   "tamper": {
    "at": "record.statement.title",
    "set": "Edited"
   }
  }
 ],
 "checks": [
  {
   "says": "Texas governing law is placed outside the playbook",
   "path": "review.findings[rule=GL][0].position",
   "in": [
    "outside",
    "walk_away"
   ]
  },
  {
   "says": "the governing-law clause is redlined from Texas to New York as a tracked change",
   "path": "review.edits[rule=GL,status=tracked][0]",
   "contains": [
    "Texas",
    "New York"
   ]
  },
  {
   "says": "the 30-day warranty is flagged",
   "path": "review.findings[rule=WARR][0].position",
   "in": [
    "outside",
    "walk_away"
   ]
  },
  {
   "says": "the exclusion of indirect loss (clause 4.2) is found and quoted",
   "path": "review.findings[rule=CONSEQ][0].quote",
   "contains": "consequential"
  },
  {
   "says": "no inserted word is untraced",
   "path": "review.report.totals.untraced_insertions",
   "equals": 0
  },
  {
   "says": "the redline passes its package checks",
   "path": "review.validation.ok",
   "equals": true
  },
  {
   "says": "rejecting every change gives back the input",
   "path": "review.validation.reject_all_is_input",
   "equals": true
  },
  {
   "says": "accepting every change gives the proposal",
   "path": "review.validation.accept_all_is_proposal",
   "equals": true
  },
  {
   "says": "the review memo (Markdown) has the governing-law finding",
   "path": "export",
   "contains": [
    "Governing law",
    "Texas"
   ]
  },
  {
   "says": "the signed record verifies",
   "path": "verify.ok",
   "equals": true
  },
  {
   "says": "a record with its title edited no longer verifies",
   "path": "tampered.ok",
   "equals": false
  },
  {
   "says": "every model call has a signed receipt",
   "receipts": "signed"
  }
 ]
}
