{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aevesa.com/schemas/liability-receipt/v1",
  "$comment": "Open Standard for Autonomous Session Accountability - liability-receipt/v1. Normative machine-readable definition published by Aevesa as the reference implementation for Verified Autonomous Sessions (VAS).",
  "title": "Liability Receipt v1 (Verified Autonomous Session)",
  "description": "A portable accountability document binding Identity, Policy, Human Release (HITL), and Side Effects to cryptographic proof. Intended for regulatory auditors, financial institution CISOs, and assurance firms.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "receipt_id",
    "issued_at",
    "issuer",
    "session",
    "identity",
    "policy",
    "hitl",
    "side_effects",
    "proof",
    "integrity",
    "diligence_summary"
  ],
  "$defs": {
    "accountability_pillars": {
      "$comment": "Conceptual model - not a document field. Every conforming receipt MUST populate the four sections below.",
      "pillar_identity": "Who acted: primary_actor, authority, optional human_release_actor.",
      "pillar_policy": "What policy allowed it: policy_pack_id, policy_version_hash, decision, thresholds.",
      "pillar_hitl": "Human release: required, status, approval_request_id, release_consumed, dual_signature_kind.",
      "pillar_side_effects": "What happened: action, effect_class, auditor-safe summary.",
      "pillar_proof": "What the proof says: aegis/1 anchors, verification status and methods."
    }
  },
  "properties": {
    "schema": {
      "type": "string",
      "const": "liability-receipt/v1",
      "$comment": "PILLAR: Document version. Implementations MUST reject unknown schema values."
    },
    "receipt_id": {
      "type": "string",
      "format": "uuid",
      "description": "Stable receipt identifier. Used in auditor portal URLs (/auditor-portal/:receiptId) and GRC evidence repositories."
    },
    "issued_at": {
      "type": "string",
      "format": "date-time",
      "description": "UTC timestamp (ISO 8601) when the accountability document was sealed."
    },
    "issuer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "product", "verification_profile"],
      "description": "Issuing authority metadata for the accountability document.",
      "properties": {
        "name": { "type": "string", "const": "Aevesa" },
        "product": { "type": "string", "const": "Verified Autonomous Sessions" },
        "verification_profile": {
          "type": "string",
          "description": "Cryptographic verification stack (e.g. aegis/1 ledger preimage + optional RS256 manifest)."
        },
        "organization_id": { "type": ["string", "null"] },
        "organization_display_name": { "type": ["string", "null"] }
      }
    },
    "session": {
      "type": "object",
      "$comment": "PILLAR: Session envelope - one governed autonomous outcome within a Verified Autonomous Session (VAS).",
      "additionalProperties": false,
      "required": ["session_id", "correlation_id", "vertical", "outcome"],
      "properties": {
        "session_id": { "type": "string" },
        "correlation_id": { "type": "string", "description": "End-to-end trace: intercept → decide → prove." },
        "vertical": {
          "type": "string",
          "enum": ["fintech_payments", "healthcare", "retail_pos", "enterprise_ops", "generic"]
        },
        "outcome": {
          "type": "string",
          "enum": ["permitted", "blocked", "pending_human_release", "released_after_hitl"]
        },
        "started_at": { "type": "string", "format": "date-time" },
        "completed_at": { "type": "string", "format": "date-time" }
      }
    },
    "identity": {
      "type": "object",
      "$comment": "PILLAR 1 - Identity: who acted under what delegated authority.",
      "additionalProperties": false,
      "required": ["primary_actor", "authority"],
      "properties": {
        "primary_actor": {
          "type": "object",
          "required": ["agent_id", "actor_class"],
          "properties": {
            "agent_id": { "type": "string" },
            "actor_class": {
              "type": "string",
              "enum": ["autonomous_agent", "delegated_kiosk", "human_operator", "system_control_plane"]
            },
            "display_name": { "type": ["string", "null"] }
          }
        },
        "authority": {
          "type": "object",
          "required": ["scoped_role", "permission_id"],
          "properties": {
            "scoped_role": { "type": "string", "description": "JIT passport role (SERVER, MANAGER, ADMIN)." },
            "permission_id": { "type": "string" },
            "location_id": { "type": ["string", "null"] },
            "constraints_digest": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" }
          }
        },
        "human_release_actor": {
          "type": ["object", "null"],
          "description": "Required when session.outcome is released_after_hitl.",
          "properties": {
            "agent_id": { "type": "string" },
            "scoped_role": { "type": "string" },
            "operator_id": { "type": ["string", "null"] }
          }
        }
      }
    },
    "policy": {
      "type": "object",
      "$comment": "PILLAR 2 - Policy: what governance rule allowed, escalated, or denied the action.",
      "additionalProperties": false,
      "required": ["policy_pack_id", "policy_version_hash", "decision"],
      "properties": {
        "policy_pack_id": { "type": "string" },
        "policy_version_hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "treaty_name": { "type": ["string", "null"] },
        "decision": {
          "type": "string",
          "enum": ["allow_within_ceiling", "require_hitl", "deny", "released"]
        },
        "thresholds": {
          "type": "object",
          "additionalProperties": {
            "oneOf": [{ "type": "number" }, { "type": "string" }, { "type": "boolean" }]
          }
        },
        "regulatory_framing": {
          "type": ["array", "null"],
          "items": { "type": "string" }
        }
      }
    },
    "hitl": {
      "type": "object",
      "$comment": "PILLAR 3 - Human Release (HITL): attestation that a qualified human authorized an exception.",
      "additionalProperties": false,
      "required": ["required", "status"],
      "properties": {
        "required": { "type": "boolean" },
        "status": {
          "type": "string",
          "enum": ["not_required", "pending", "signed", "expired", "rejected"]
        },
        "approval_request_id": { "type": ["string", "null"], "format": "uuid" },
        "required_role": { "type": ["string", "null"] },
        "manager_signed_at": { "type": ["string", "null"], "format": "date-time" },
        "dual_signature_kind": { "type": ["string", "null"] },
        "release_consumed": {
          "type": "boolean",
          "description": "MUST be true for permitted financial voids after HITL - one-shot replay protection."
        },
        "sla_due_at": { "type": ["string", "null"], "format": "date-time" }
      }
    },
    "side_effects": {
      "type": "object",
      "$comment": "PILLAR 4 - Side Effects: material business outcome (redacted; no PAN/PII/prompts).",
      "additionalProperties": false,
      "required": ["action", "effect_class", "summary"],
      "properties": {
        "action": {
          "type": "object",
          "required": ["tool_name", "verb"],
          "properties": {
            "tool_name": { "type": "string" },
            "verb": { "type": "string" },
            "metric_name": { "type": ["string", "null"] },
            "metric_value": { "type": ["number", "null"] },
            "currency": { "type": ["string", "null"], "pattern": "^[A-Z]{3}$" },
            "target_path": { "type": ["string", "null"] },
            "target_host": { "type": ["string", "null"] },
            "execution_scopes": { "type": "array", "items": { "type": "string" }, "maxItems": 16 }
          }
        },
        "effect_class": {
          "type": "string",
          "enum": ["financial_void", "data_access", "configuration_change", "communication", "none"]
        },
        "summary": { "type": "string" },
        "projected_liability_usd": { "type": ["number", "null"] },
        "blocked_reason": { "type": ["string", "null"] }
      }
    },
    "intent_context": {
      "type": "object",
      "description": "Optional Proof-of-Intent: agent rationale and model fingerprint bound into receipt_digest and aegis/1 governanceBinding.intentContext.",
      "additionalProperties": false,
      "required": ["reasoning_summary", "model_fingerprint"],
      "properties": {
        "reasoning_summary": {
          "type": "string",
          "maxLength": 4096,
          "description": "Redacted summary of agent reasoning before the governed tool invocation."
        },
        "model_fingerprint": {
          "type": "string",
          "maxLength": 256,
          "description": "Exact model identifier that produced the stated intent (e.g. gpt-4.1-2025-04-14)."
        }
      }
    },
    "intent_alignment": {
      "type": "object",
      "description": "KVR-102 - structural divergence evaluation digest-bound with intent_context. Required when intent_context is present.",
      "additionalProperties": false,
      "required": ["score", "level", "signals"],
      "properties": {
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "0.00 (aligned) to 1.00 (critical divergence)."
        },
        "level": {
          "type": "string",
          "enum": ["ALIGNED", "ELEVATED", "CRITICAL"]
        },
        "signals": {
          "type": "array",
          "items": { "type": "string" },
          "maxItems": 16,
          "description": "Deterministic rule tags; lexicographically sorted at digest time."
        }
      }
    },
    "causal_lineage": {
      "type": "object",
      "description": "KVR-301 - parent ledger anchor for delegated swarm child actions; digest-bound when present.",
      "additionalProperties": false,
      "required": ["parent_entry_hash"],
      "properties": {
        "parent_entry_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "entryHash of the parent agent's governing ledger row at delegation time."
        },
        "parent_session_id": {
          "type": "string",
          "maxLength": 256,
          "description": "Session id of the delegating parent agent."
        },
        "root_session_id": {
          "type": "string",
          "maxLength": 256,
          "description": "Swarm root session id for multi-hop delegation trees."
        }
      }
    },
    "receipt_profile": {
      "type": "string",
      "enum": ["PERMITTED", "DENIED", "HITL_PENDING", "HITL_RELEASED"],
      "description": "Wave 2.2 - explicit profile. DENIED = verifiable pre-execution refusal before side effects."
    },
    "denial": {
      "type": "object",
      "description": "Wave 2.2 - pre-execution denial semantics for DENIED profile receipts.",
      "additionalProperties": false,
      "required": ["pre_execution", "execution_occurred", "denial_stage"],
      "properties": {
        "pre_execution": { "type": "boolean", "const": true },
        "execution_occurred": { "type": "boolean", "const": false },
        "denial_stage": {
          "type": "string",
          "enum": ["gateway", "pep", "hitl", "runtime_firewall", "intent_alignment"]
        },
        "source": { "type": "string", "maxLength": 128 }
      }
    },
    "refusal_alignment": {
      "type": "object",
      "description": "Wave 2.2 - SCITT refusal-event draft alignment metadata for procurement interop.",
      "additionalProperties": false,
      "properties": {
        "profile": { "type": "string" },
        "mapping_version": { "type": "string" },
        "reference": { "type": "string" },
        "scitt_event_type": { "type": "string" },
        "mapped_fields": { "type": "array", "items": { "type": "string" } },
        "evidence_hash": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
        "kovera_receipt_profile": { "type": "string" }
      }
    },
    "gateway_attestation": {
      "type": "object",
      "description": "Proof Moat Phase 1 - external gateway permit/deny decision bound to Aevesa entryHash.",
      "additionalProperties": false,
      "required": ["gateway_decision_id", "gateway_source", "decision"],
      "properties": {
        "gateway_decision_id": {
          "type": "string",
          "maxLength": 512,
          "description": "Opaque id from Unity AI Gateway, Portkey, APIM, or generic OTLP sink."
        },
        "gateway_source": {
          "type": "string",
          "enum": ["databricks_unity_ai", "portkey", "microsoft_agent_365", "zscaler_ai_protect", "wiz_ai_spm", "azure_apim", "bedrock", "generic_otlp", "generic_webhook"]
        },
        "decision": {
          "type": "string",
          "enum": ["permit", "deny"]
        },
        "gateway_event_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "SHA-256 of canonical gateway event preimage (multi-party verify bundle)."
        },
        "data_classification_tag": {
          "type": ["string", "null"],
          "maxLength": 256,
          "description": "Optional Cyera / DLP classification tag from gateway context."
        },
        "policy_reference": {
          "type": ["string", "null"],
          "maxLength": 512
        },
        "evaluated_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "proof": {
      "type": "object",
      "$comment": "PILLAR 5 - Proof: independent verification anchors (aegis/1 + methods).",
      "additionalProperties": false,
      "required": ["ledger_spec", "primary_anchor", "verification"],
      "properties": {
        "ledger_spec": { "type": "string", "const": "aegis/1" },
        "primary_anchor": {
          "type": "object",
          "required": ["entry_hash", "event_type"],
          "properties": {
            "entry_hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
            "event_type": { "type": "string" },
            "timestamp": { "type": "string", "format": "date-time" }
          }
        },
        "secondary_anchors": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["entry_hash", "event_type"],
            "properties": {
              "entry_hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
              "event_type": { "type": "string" },
              "timestamp": { "type": "string", "format": "date-time" }
            }
          }
        },
        "proof_of_action_bundle_id": { "type": ["string", "null"] },
        "verification": {
          "type": "object",
          "required": ["status", "methods"],
          "properties": {
            "status": {
              "type": "string",
              "enum": ["verified", "partial", "unverified", "demo"]
            },
            "methods": { "type": "array", "items": { "type": "string" } },
            "verified_at": { "type": ["string", "null"], "format": "date-time" },
            "portal_urls": {
              "type": "object",
              "properties": {
                "auditor_portal": { "type": "string", "format": "uri" },
                "truth_portal": { "type": "string", "format": "uri" },
                "open_evidence": { "type": "string", "format": "uri" }
              }
            }
          }
        }
      }
    },
    "integrity": {
      "type": "object",
      "description": "Document integrity binding - receipt_digest over canonical JSON.",
      "additionalProperties": false,
      "required": ["receipt_digest", "signature_alg"],
      "properties": {
        "receipt_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "signature_alg": { "type": "string", "enum": ["RS256", "Ed25519", "none"] },
        "signature": { "type": ["string", "null"] },
        "manifest_signature_jws": { "type": ["string", "null"] }
      }
    },
    "diligence_summary": {
      "type": "object",
      "description": "15-minute diligence narrative for assurance professionals.",
      "additionalProperties": false,
      "required": ["who_acted", "what_policy_allowed", "what_proof_says"],
      "properties": {
        "who_acted": { "type": "string", "maxLength": 2000 },
        "what_policy_allowed": { "type": "string", "maxLength": 2000 },
        "what_proof_says": { "type": "string", "maxLength": 2000 },
        "executive_headline": { "type": ["string", "null"], "maxLength": 280 },
        "control_effectiveness": {
          "type": "string",
          "enum": ["effective", "effective_with_exceptions", "not_effective", "not_assessed"]
        },
        "recommended_auditor_actions": {
          "type": "array",
          "items": { "type": "string" },
          "maxItems": 8
        }
      }
    }
  }
}
