{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://telos-labs.ai/docs/receipt-spec.schema.json",
  "title": "TELOS unsigned integrity-hash receipt (telos/0.1-unsigned)",
  "description": "The canonical envelope minted per observed agent action by the telos-receipt package. The integrity hash is a key-free SHA-256 over the canonical JSON (sort_keys, compact separators, ensure_ascii escapes) of `payload`. It confirms the payload matches the recorded hash; it is not a digital signature and does not establish who issued the receipt or when. `signature` is null in this contract version and `signing_status` declares the unsigned state; a later signed contract fills `signature` without changing this shape.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "receipt_version", "kind", "agent_id", "payload", "issued_at",
    "integrity_hash", "covered_fields", "signing_status", "signature", "engine"
  ],
  "properties": {
    "receipt_version": {
      "type": "string",
      "const": "telos/0.1-unsigned",
      "description": "Which receipt contract produced this record. The name states the unsigned status."
    },
    "kind": {
      "type": "string",
      "description": "What kind of record this is. `action_governed` is one reviewed action; other kinds share the same envelope."
    },
    "agent_id": {
      "type": "string",
      "description": "Which agent did the work. A label the operating team assigns."
    },
    "payload": {
      "type": "object",
      "description": "The part the integrity hash covers: everything the record commits to. Must be JSON-native and finite; values with no canonical JSON form are refused at mint time."
    },
    "issued_at": {
      "type": "string",
      "description": "ISO 8601 timestamp of issue. Metadata, deliberately outside the hash, so the same logical payload always yields the same hash."
    },
    "integrity_hash": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$",
      "description": "Key-free SHA-256 over the canonical JSON serialization of `payload`. Recompute offline and compare; a match confirms the payload has not changed relative to the recorded hash."
    },
    "covered_fields": {
      "type": "string",
      "const": "payload (canonical JSON, sort_keys, compact separators)",
      "description": "States exactly what the hash covers."
    },
    "signing_status": {
      "type": "string",
      "const": "unsigned_integrity_hash",
      "description": "The receipt's own declaration that it is unsigned in this contract version."
    },
    "signature": {
      "type": "null",
      "description": "Null in telos/0.1-unsigned: not signed yet, and the receipt says so on itself. A later signed contract version fills this field and changes signing_status, with no change to the envelope shape."
    },
    "engine": {
      "type": "string",
      "description": "Which engine produced the payload. Honest labeling: the v0.1 default states that no governance engine is wired."
    }
  },
  "if": {
    "properties": { "kind": { "const": "action_governed" } }
  },
  "then": {
    "properties": {
      "payload": {
        "type": "object",
        "additionalProperties": false,
        "required": ["action_name", "action_params_hash", "verdict", "composite_score", "scores", "pa_id"],
        "properties": {
          "action_name": {
            "type": "string",
            "description": "The action the agent took."
          },
          "action_params_hash": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$",
            "description": "SHA-256 commitment to the exact action parameters. Raw arguments are never echoed, so the receipt is shareable without leaking content."
          },
          "verdict": {
            "type": "string",
            "enum": ["EXECUTE", "CLARIFY", "SUGGEST", "ESCALATE", "INERT"],
            "description": "The review outcome, from the public verdict vocabulary."
          },
          "composite_score": {
            "type": "number",
            "description": "Overall score of the action against its purpose anchor."
          },
          "scores": {
            "type": "object",
            "additionalProperties": { "type": "number" },
            "description": "Per-dimension scores behind the composite."
          },
          "pa_id": {
            "type": "string",
            "description": "The purpose anchor: the declared, human-specified purpose the action was measured against."
          }
        }
      }
    }
  }
}
