{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/decide-fyi/json-schema/decide-fyi-decision-record-schema.json",
  "title": "DecisionRecord",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/decide-fyi-openapi.json#/components/schemas/DecisionRecord",
  "type": "object",
  "required": [
    "decision_protocol_version",
    "decision_record_version",
    "decision_id",
    "request_id",
    "verdict",
    "record_hash",
    "receipt_hash",
    "verify_url",
    "replay_url"
  ],
  "properties": {
    "decision_protocol_version": {
      "type": "string",
      "const": "decision_protocol_v1"
    },
    "decision_record_version": {
      "type": "string",
      "const": "decision_record_v1"
    },
    "response_view": {
      "type": "string",
      "enum": [
        "minimal",
        "standard",
        "full"
      ]
    },
    "decision_id": {
      "type": "string",
      "maxLength": 600
    },
    "request_id": {
      "type": "string"
    },
    "idempotency_key": {
      "type": "string"
    },
    "c": {
      "type": "string"
    },
    "v": {
      "type": "string"
    },
    "verdict": {
      "type": "string"
    },
    "application_verdict": {
      "type": "string",
      "description": "Purpose-specific bounded verdict produced by Rulebook v1, such as APPROVE, BLOCK, REVIEW, or NEEDS_INPUT."
    },
    "evaluator_version": {
      "type": "string",
      "description": "Versioned evaluator that produced the binding rulebook result."
    },
    "rulebook_contract": {
      "$ref": "#/$defs/RulebookContract"
    },
    "action": {
      "type": "string"
    },
    "reason_code": {
      "type": "string"
    },
    "matched_rule_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "rulebook": {
      "type": "object",
      "properties": {
        "schema_version": {
          "type": "string",
          "const": "rulebook_v1"
        },
        "id": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "rulebook_registry": {
      "$ref": "#/$defs/RulebookRegistryMetadata"
    },
    "runtime_binding": {
      "$ref": "#/$defs/RuntimeBinding"
    },
    "trusted_adapter": {
      "$ref": "#/$defs/TrustedAdapterAttestation"
    },
    "adapter_facts": {
      "type": "object",
      "description": "Schema-validated facts emitted by the pinned trusted adapter before Rulebook v1 evaluation.",
      "additionalProperties": true
    },
    "action_binding": {
      "$ref": "#/$defs/ActionBinding"
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "evidence_manifest": {
      "$ref": "#/$defs/EvidenceManifest"
    },
    "policy_id": {
      "type": "string"
    },
    "policy_version": {
      "type": "string"
    },
    "policy_hash": {
      "type": "string"
    },
    "source_hash": {
      "type": "string",
      "description": "Backend lineage hash returned in the full Decision Record response when the upstream decision engine supplies it."
    },
    "policy_bundle": {
      "$ref": "#/$defs/PolicyBundle"
    },
    "policy_bundle_hash": {
      "type": "string"
    },
    "confidence": {
      "$ref": "#/$defs/DecisionConfidence"
    },
    "decision_confidence": {
      "$ref": "#/$defs/DecisionConfidence"
    },
    "confidence_hash": {
      "type": "string"
    },
    "input_hash": {
      "type": "string"
    },
    "output_hash": {
      "type": "string"
    },
    "record_hash": {
      "type": "string",
      "description": "Tamper-evident hash of the normalized Decision Record v1 envelope, including binding application verdict, reason, matched rule, rulebook lineage, registry attestation, trusted adapter attestation, and adapter facts when present."
    },
    "receipt_hash": {
      "type": "string",
      "description": "Portable receipt hash over record_hash plus input/output, policy, action-binding, and evidence-manifest proof hashes."
    },
    "receipt_key_id": {
      "type": "string"
    },
    "receipt_signature": {
      "type": "string"
    },
    "receipt_signature_algorithm": {
      "type": "string",
      "enum": [
        "hmac-sha256",
        "ed25519"
      ]
    },
    "receipt_public_key": {
      "type": "string"
    },
    "receipt_public_key_fingerprint": {
      "type": "string"
    },
    "integrity": {
      "$ref": "#/$defs/Integrity"
    },
    "verify_url": {
      "type": "string"
    },
    "replay_url": {
      "type": "string"
    },
    "created_at": {
      "type": "string"
    },
    "audit_chain": {
      "$ref": "#/$defs/AuditChain"
    },
    "chain_url": {
      "type": "string"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "ActionBinding": {
      "type": "object",
      "properties": {
        "actor": {
          "type": "string"
        },
        "system": {
          "type": "string"
        },
        "resource": {
          "type": "string"
        },
        "proposed_action": {
          "type": "string"
        },
        "subject": {
          "type": "string"
        },
        "amount": {
          "type": "string"
        },
        "currency": {
          "type": "string"
        },
        "target_system": {
          "type": "string"
        },
        "target_object_id": {
          "type": "string"
        },
        "mutation": {
          "type": "string"
        },
        "expires_at": {
          "type": "string"
        },
        "execution_state": {
          "type": "string"
        },
        "execution_id": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "AuditChain": {
      "type": "object",
      "required": [
        "decision_chain_version",
        "chain_id",
        "chain_position",
        "leaf_hash",
        "merkle_root",
        "link_hash"
      ],
      "properties": {
        "decision_chain_version": {
          "type": "string",
          "const": "decision_chain_v1"
        },
        "chain_id": {
          "type": "string"
        },
        "chain_position": {
          "type": "integer"
        },
        "previous_link_hash": {
          "type": [
            "string",
            "null"
          ]
        },
        "leaf_hash": {
          "type": "string"
        },
        "merkle_root": {
          "type": "string"
        },
        "merkle_strategy": {
          "type": "string",
          "const": "rolling_sha256_pair_v1"
        },
        "link_hash": {
          "type": "string"
        },
        "chain_url": {
          "type": "string"
        },
        "created_at": {
          "type": "string"
        },
        "entry_type": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "DecisionConfidence": {
      "type": "object",
      "required": [
        "ok",
        "decision_confidence_version",
        "score",
        "level",
        "recommendation",
        "confidence_hash"
      ],
      "properties": {
        "ok": {
          "type": "boolean"
        },
        "decision_confidence_version": {
          "type": "string",
          "const": "decision_confidence_v1"
        },
        "generated_at": {
          "type": "string"
        },
        "source": {
          "type": "string",
          "const": "decision_outcomes"
        },
        "scope": {
          "type": "string",
          "const": "caller_api_key"
        },
        "decision_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "policy_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "policy_version": {
          "type": [
            "string",
            "null"
          ]
        },
        "verdict": {
          "type": "string"
        },
        "action": {
          "type": [
            "string",
            "null"
          ]
        },
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "level": {
          "type": "string",
          "enum": [
            "high",
            "medium",
            "low",
            "weak",
            "insufficient_data"
          ]
        },
        "based_on": {
          "type": "integer"
        },
        "similar_decisions": {
          "type": "integer"
        },
        "policy_stability": {
          "type": "string",
          "enum": [
            "high",
            "medium",
            "low",
            "insufficient_data"
          ]
        },
        "recommendation": {
          "type": "string",
          "enum": [
            "collect_more_outcomes",
            "high_confidence_proceed",
            "high_confidence_block",
            "high_confidence_review",
            "proceed_with_monitoring",
            "route_for_review",
            "monitor"
          ]
        },
        "metrics": {
          "type": "object",
          "additionalProperties": true
        },
        "baseline": {
          "type": "object",
          "additionalProperties": true
        },
        "data_quality": {
          "type": "object",
          "additionalProperties": true
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "confidence_hash": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "EvidenceManifest": {
      "type": "object",
      "properties": {
        "codes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EvidenceSource"
          }
        }
      },
      "additionalProperties": false
    },
    "EvidenceSource": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "vendor": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "policy_ref": {
          "type": "string"
        },
        "observed_at": {
          "type": "string"
        },
        "retrieval_id": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "snapshot_hash": {
          "type": "string"
        },
        "content_hash": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "Integrity": {
      "type": "object",
      "properties": {
        "canonicalization": {
          "type": "string"
        },
        "decision_protocol_version": {
          "type": "string"
        },
        "hash_algorithm": {
          "type": "string"
        },
        "input_hash": {
          "type": "string"
        },
        "output_hash": {
          "type": "string"
        },
        "policy_hash": {
          "type": "string"
        },
        "policy_bundle_hash": {
          "type": "string"
        },
        "record_hash": {
          "type": "string"
        },
        "receipt_hash": {
          "type": "string"
        },
        "replay_url": {
          "type": "string"
        },
        "verify_url": {
          "type": "string"
        },
        "signature": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    },
    "PolicyBundle": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "hash_algorithm": {
          "type": "string",
          "default": "sha256"
        },
        "canonicalization": {
          "type": "string",
          "default": "json.sort_deep.v1"
        },
        "source": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "effective_at": {
          "type": "string"
        },
        "deprecated_at": {
          "type": "string"
        },
        "changelog": {
          "type": "string"
        },
        "content_hash": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "RegistryAttestation": {
      "type": "object",
      "required": [
        "registry_attestation_version",
        "status",
        "attestation_hash"
      ],
      "properties": {
        "registry_attestation_version": {
          "type": "string",
          "const": "decision_registry_attestation_v1"
        },
        "status": {
          "type": "string",
          "enum": [
            "signed",
            "unsigned"
          ]
        },
        "attestation_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "key_id": {
          "type": "string"
        },
        "signature_algorithm": {
          "type": "string",
          "const": "ed25519"
        },
        "signature": {
          "type": "string",
          "pattern": "^ed25519:"
        },
        "public_key": {
          "type": "string"
        },
        "public_key_fingerprint": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "additionalProperties": false
    },
    "RulebookContract": {
      "type": "object",
      "required": [
        "schema_version",
        "schema_url",
        "schema_hash",
        "evaluator_version"
      ],
      "properties": {
        "schema_version": {
          "type": "string",
          "const": "rulebook_v1"
        },
        "schema_url": {
          "type": "string",
          "const": "https://api.decide.fyi/schemas/rulebook-v1.schema.json"
        },
        "schema_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "SHA-256 hash of the published Rulebook v1 JSON Schema enforced by the runtime."
        },
        "evaluator_version": {
          "type": "string",
          "const": "decide_rulebook_v1"
        }
      },
      "additionalProperties": false
    },
    "RulebookRegistryMetadata": {
      "type": "object",
      "required": [
        "rulebook_registry_version",
        "schema_version",
        "rulebook_id",
        "version",
        "hash",
        "evaluator_version",
        "hash_algorithm",
        "canonicalization",
        "scope_hash",
        "registry_attestation",
        "registered_at"
      ],
      "properties": {
        "rulebook_registry_version": {
          "type": "string",
          "const": "decision_rulebook_registry_v1"
        },
        "schema_version": {
          "type": "string",
          "const": "rulebook_v1"
        },
        "rulebook_id": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "hash": {
          "type": "string",
          "minLength": 64,
          "maxLength": 64
        },
        "evaluator_version": {
          "type": "string"
        },
        "trusted_adapter": {
          "$ref": "#/$defs/TrustedAdapterDependency"
        },
        "hash_algorithm": {
          "type": "string",
          "const": "sha256"
        },
        "canonicalization": {
          "type": "string",
          "const": "json.sort_deep.v1"
        },
        "scope_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "registry_attestation": {
          "$ref": "#/$defs/RegistryAttestation"
        },
        "registered_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    "RuntimeBinding": {
      "type": "object",
      "required": [
        "production_core",
        "binding_mode",
        "verdict_authority",
        "customer_supplied_code"
      ],
      "properties": {
        "production_core": {
          "type": "string",
          "const": "hybrid_declarative_rulebook_with_trusted_adapters"
        },
        "binding_mode": {
          "type": "string",
          "enum": [
            "direct_declarative_rulebook",
            "trusted_adapter_facts_then_declarative_rulebook"
          ]
        },
        "verdict_authority": {
          "type": "string",
          "const": "declarative_rulebook"
        },
        "adapter_authority": {
          "type": "string",
          "const": "facts_only"
        },
        "customer_supplied_code": {
          "type": "string",
          "const": "rejected"
        }
      },
      "additionalProperties": false
    },
    "TrustedAdapterAttestation": {
      "type": "object",
      "required": [
        "manifest_version",
        "adapter_id",
        "version",
        "implementation_revision",
        "implementation_hash",
        "manifest_hash",
        "input_hash",
        "output_hash",
        "execution_isolation",
        "capability_enforcement",
        "execution_timeout_ms"
      ],
      "properties": {
        "manifest_version": {
          "type": "string",
          "const": "trusted_adapter_manifest_v1"
        },
        "adapter_id": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "implementation_revision": {
          "type": "string"
        },
        "implementation_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "manifest_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "input_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "output_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "execution_isolation": {
          "type": "string",
          "const": "worker_thread_one_shot_v1"
        },
        "capability_enforcement": {
          "type": "string",
          "const": "ambient_capability_deny_v2"
        },
        "execution_timeout_ms": {
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false
    },
    "TrustedAdapterDependency": {
      "type": "object",
      "required": [
        "manifest_version",
        "adapter_id",
        "version",
        "implementation_revision",
        "implementation_hash",
        "manifest_hash"
      ],
      "properties": {
        "manifest_version": {
          "type": "string",
          "const": "trusted_adapter_manifest_v1"
        },
        "adapter_id": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "implementation_revision": {
          "type": "string"
        },
        "implementation_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "manifest_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "additionalProperties": false
    }
  }
}