{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://connorgallic.com/agent-dod/receipt.schema.json",
  "title": "Agent DoD receipt v1.0",
  "description": "One settled agent task under Agent DoD v1.0 (https://connorgallic.com/definition-of-done).",
  "type": "object",
  "required": ["dod", "task_id", "owner", "outcome", "target", "claimed_status", "proof", "verdict", "verdict_by"],
  "properties": {
    "dod": { "const": "1.0" },
    "task_id": { "type": "string" },
    "owner": { "type": "string", "description": "The one agent or harness responsible for the task (GOV-1)." },
    "outcome": { "type": "string", "description": "The observable after-state, named before the work started (DOD-1)." },
    "target": { "type": "string", "description": "Where the result lives: a URL, or system:object." },
    "claimed_status": { "enum": ["planned", "built", "deployed", "scheduled", "executed", "done", "blocked", "held", "failed", "superseded"] },
    "report": { "type": "string", "description": "The agent's own words. Checked for contradictions (DOD-7)." },
    "blocker": { "type": "string", "description": "The exact external condition, when blocked (DOD-9)." },
    "exit_code": { "type": "integer", "description": "Recorded, never counted as proof (DOD-3)." },
    "proof": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["kind", "ref", "checked_by", "result"],
        "properties": {
          "kind": { "enum": ["http_contains", "provider_object", "sent_log", "call_log", "payment", "deployment", "record", "commit", "pull_request", "file", "test_run", "screenshot", "log", "assertion"] },
          "ref": { "type": "string" },
          "expect": { "type": "string", "description": "Text or value the read-back must find." },
          "checked_by": { "enum": ["actor", "runner", "independent", "human", "verifier", "agent_dod"] },
          "checked_at": { "type": "string", "format": "date-time" },
          "result": { "enum": ["pass", "fail", "not_run"] }
        }
      }
    },
    "approval": {
      "type": "object",
      "properties": {
        "required": { "type": "boolean" },
        "status": { "enum": ["pending", "approved", "denied", "expired"] },
        "by": { "type": "string" }
      }
    },
    "business_outcome": {
      "type": "object",
      "properties": {
        "class": { "enum": ["inbound_customer", "revenue", "client_delivery", "visible_content"] },
        "ref": { "type": "string" },
        "verified": { "type": "boolean" }
      }
    },
    "cost": {
      "type": "object",
      "properties": {
        "input_tokens": { "type": "integer" },
        "output_tokens": { "type": "integer" },
        "usd": { "type": "number" }
      }
    },
    "verdict": { "enum": ["done", "blocked", "held", "failed", "superseded"] },
    "verdict_by": { "type": "string", "description": "Who issued the verdict. Never the owner (DOD-2)." },
    "settled_at": { "type": "string", "format": "date-time" }
  }
}
