{
  "openapi": "3.1.0",
  "info": {
    "title": "Decide Decision API",
    "summary": "Decision protocol for state-changing software actions.",
    "description": "Call Decide before products, agents, queues, billing systems, CRMs, or internal tools change state. The API returns a signed Decision Record v1 object with policy bundle attestation, evidence, action binding, replay, verification handles, portable Decision Packet v1 exports, simulation-only counterfactual analysis, cryptographic audit chains, Action Execution Receipts, Outcome Records, CRM Sync Records, predictive confidence, first-party policy pattern templates, policy effectiveness metrics, opt-in anonymized benchmarks, and explainable anomaly reports derived from reported outcomes.",
    "version": "1.13.0",
    "x-decision-protocol-version": "decision_protocol_v1",
    "x-decision-record-version": "decision_record_v1",
    "x-decision-packet-version": "decision_packet_v1"
  },
  "servers": [
    {
      "url": "https://www.decide.fyi",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Decision Protocol",
      "description": "Core decide, replay, diff, verification, readiness, and registry endpoints."
    },
    {
      "name": "Counterfactuals",
      "description": "Simulation-only what-if analysis for stored Decision Records."
    },
    {
      "name": "Verification",
      "description": "Hosted and exported Decision Record verification."
    },
    {
      "name": "Registries",
      "description": "Receipt key and policy bundle registries."
    },
    {
      "name": "Policy Patterns",
      "description": "First-party Decision API pattern templates for common state-changing integrations."
    },
    {
      "name": "Action Execution",
      "description": "Record target-system neutral receipts proving whether the action authorized by a Decision Record was executed, skipped, failed, blocked, or reverted."
    },
    {
      "name": "Outcome Tracking",
      "description": "Report and read what happened after a Decision Record authorized or routed an action."
    },
    {
      "name": "CRM Sync",
      "description": "Record CRM write-back and inbound sync receipts linked to Decision Records."
    },
    {
      "name": "Effectiveness",
      "description": "Outcome-based policy effectiveness scoring scoped to the caller API key."
    },
    {
      "name": "Confidence",
      "description": "Predictive decision confidence from caller-scoped Outcome Records."
    },
    {
      "name": "Benchmarks",
      "description": "Opt-in anonymized cross-customer benchmarks with minimum privacy thresholds."
    },
    {
      "name": "Anomalies",
      "description": "Explainable outcome-based anomaly reports scoped to the caller API key."
    },
    {
      "name": "Audit Chain",
      "description": "Caller-scoped cryptographic audit trails with rolling Merkle roots and retained-link verification."
    },
    {
      "name": "Decision Packets",
      "description": "Portable Decision Packet v1 exports that bundle a Decision Record with execution, outcome, intelligence, and audit-chain proof material."
    }
  ],
  "paths": {
    "/api/decide": {
      "post": {
        "tags": [
          "Decision Protocol"
        ],
        "operationId": "createDecision",
        "summary": "Create a Decision Record",
        "description": "Returns a Decision Record v1 object. Use mode=rulebook for deterministic evaluation of a versioned declarative rulebook. Facts may come from context.inputs or one exact-version registered trusted adapter invocation, never both. The rulebook remains the binding verdict selector. Legacy single, multi, and runtime modes are AI-assisted.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/DecisionResponseView"
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/Prefer"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionRequest"
              },
              "examples": {
                "pricingExceptionAiAssisted": {
                  "summary": "AI-assisted pricing exception before billing mutation",
                  "value": {
                    "question": "Approve 15% annual-plan discount exception?",
                    "mode": "single",
                    "context": {
                      "workflow": "pricing_exception",
                      "source_record_id": "deal_1042",
                      "requested_action": "approve_discount",
                      "target_system": "billing",
                      "target_object_id": "sub_1042",
                      "mutation": "discount.create",
                      "margin_floor": "passed",
                      "owner_rule": "verified"
                    }
                  }
                },
                "pricingExceptionRulebook": {
                  "summary": "Deterministic pricing exception rulebook",
                  "value": {
                    "mode": "rulebook",
                    "rulebook": {
                      "schema_version": "rulebook_v1",
                      "rulebook_id": "pricing_exception",
                      "version": "2026-06-11",
                      "input_schema": {
                        "required": [
                          "discount_percent",
                          "margin_percent"
                        ],
                        "properties": {
                          "discount_percent": {
                            "type": "number"
                          },
                          "margin_percent": {
                            "type": "number"
                          }
                        }
                      },
                      "rules": [
                        {
                          "rule_id": "approve_standard_exception",
                          "priority": 50,
                          "condition": {
                            "all": [
                              {
                                "field": "discount_percent",
                                "operator": "lte",
                                "value": 15
                              },
                              {
                                "field": "margin_percent",
                                "operator": "gte",
                                "value": 15
                              }
                            ]
                          },
                          "outcome": {
                            "decision": "yes",
                            "verdict": "APPROVE",
                            "action": "approve_discount",
                            "reason_code": "STANDARD_EXCEPTION_ALLOWED"
                          }
                        }
                      ],
                      "default_outcome": {
                        "decision": "review",
                        "verdict": "REVIEW",
                        "action": "route_to_owner",
                        "reason_code": "NO_RULE_MATCHED"
                      }
                    },
                    "context": {
                      "inputs": {
                        "discount_percent": 10,
                        "margin_percent": 22
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision Record projection",
            "headers": {
              "x-decision-id": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-record-hash": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-receipt-hash": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-confidence-score": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-confidence-level": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-confidence-hash": {
                "schema": {
                  "type": "string"
                }
              },
              "x-idempotency-status": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "created",
                    "replayed"
                  ]
                }
              },
              "x-decision-verify-url": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionRecord"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "description": "Rulebook validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamFailure"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/decision/status": {
      "get": {
        "tags": [
          "Decision Protocol"
        ],
        "operationId": "getDecisionStatus",
        "summary": "Read Decision API readiness",
        "security": [],
        "responses": {
          "200": {
            "description": "Ready",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionStatus"
                }
              }
            }
          },
          "503": {
            "description": "Degraded readiness",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionStatus"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/policy-bundles": {
      "get": {
        "tags": [
          "Registries"
        ],
        "operationId": "listPolicyBundles",
        "summary": "Read the policy bundle registry",
        "security": [],
        "parameters": [
          {
            "name": "hash",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional policy bundle hash to resolve a single bundle."
          }
        ],
        "responses": {
          "200": {
            "description": "Policy bundle registry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PolicyBundleRegistry"
                }
              }
            }
          },
          "404": {
            "description": "Bundle hash not found"
          }
        }
      }
    },
    "/api/decision/rulebooks": {
      "get": {
        "tags": [
          "Registries"
        ],
        "operationId": "getRulebookMetadata",
        "summary": "Resolve tenant-scoped rulebook metadata",
        "description": "Returns metadata for one immutable rulebook snapshot in the authenticated caller scope. Provide hash, or both rulebook_id and version. Registry listing and snapshot-body disclosure are intentionally unsupported.",
        "parameters": [
          {
            "name": "hash",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rulebook_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant-scoped immutable rulebook metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "rulebook"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "rulebook": {
                      "$ref": "#/components/schemas/RulebookRegistryMetadata"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Exact lookup parameters are required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Rulebook metadata not found in caller scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/policy-patterns": {
      "get": {
        "tags": [
          "Policy Patterns"
        ],
        "operationId": "listPolicyPatterns",
        "summary": "Read the policy pattern registry",
        "description": "Returns first-party Decision API pattern templates. Pass pattern_id for a single pattern or tag to filter the registry.",
        "security": [],
        "parameters": [
          {
            "name": "pattern_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional pattern id or policy id to resolve a single policy pattern."
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional tag filter for the registry view."
          }
        ],
        "responses": {
          "200": {
            "description": "Policy pattern registry or single policy pattern",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/DecisionPatternRegistry"
                    },
                    {
                      "$ref": "#/components/schemas/DecisionPatternResponse"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Pattern not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/receipt-keys": {
      "get": {
        "tags": [
          "Registries"
        ],
        "operationId": "listReceiptKeys",
        "summary": "Read the public receipt key registry",
        "security": [],
        "responses": {
          "200": {
            "description": "Receipt key registry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptKeyRegistry"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/verify": {
      "get": {
        "tags": [
          "Verification"
        ],
        "operationId": "describeRecordVerification",
        "summary": "Describe exported-record verification",
        "security": [],
        "responses": {
          "200": {
            "description": "Verification endpoint metadata"
          }
        }
      },
      "post": {
        "tags": [
          "Verification"
        ],
        "operationId": "verifyExportedDecisionRecord",
        "summary": "Verify an exported Decision Record",
        "description": "Verifies Decision Record hashes and signatures without requiring a hosted ledger lookup. A verified=true authenticity result requires a server-configured Decide receipt key or HMAC secret; a public key supplied in the same request is used only for integrity diagnostics and is not a trust anchor.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyRecordRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/packet/verify": {
      "get": {
        "tags": [
          "Decision Packets",
          "Verification"
        ],
        "operationId": "describeDecisionPacketVerification",
        "summary": "Describe Decision Packet verification",
        "security": [],
        "responses": {
          "200": {
            "description": "Decision Packet verification endpoint metadata"
          }
        }
      },
      "post": {
        "tags": [
          "Decision Packets",
          "Verification"
        ],
        "operationId": "verifyDecisionPacket",
        "summary": "Verify an exported Decision Packet",
        "description": "Verifies a Decision Packet v1 object supplied in the request body, including packet hash, embedded Decision Record verification, execution and outcome hash links, intelligence report hashes, and retained audit-chain links when present. A verified=true authenticity result requires a server-configured Decide receipt key or HMAC secret.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyDecisionPacketRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision Packet verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/{decision_id}": {
      "get": {
        "tags": [
          "Decision Protocol"
        ],
        "operationId": "getDecision",
        "summary": "Fetch a stored decision",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          }
        ],
        "responses": {
          "200": {
            "description": "Stored decision ledger entry"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          }
        }
      }
    },
    "/api/decision/{decision_id}/verify": {
      "get": {
        "tags": [
          "Verification"
        ],
        "operationId": "verifyStoredDecision",
        "summary": "Verify a stored decision",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          }
        ],
        "responses": {
          "200": {
            "description": "Ledger verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          }
        }
      },
      "post": {
        "tags": [
          "Verification"
        ],
        "operationId": "verifyStoredOrSuppliedDecision",
        "summary": "Verify a stored or supplied decision",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyRecordRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Stored decision not found in the authenticated caller scope when no record is supplied"
          }
        }
      }
    },
    "/api/decision/{decision_id}/packet": {
      "get": {
        "tags": [
          "Decision Packets"
        ],
        "operationId": "getDecisionPacket",
        "summary": "Export a portable Decision Packet",
        "description": "Returns a complete Decision Packet v1 export for a stored Decision Record in the authenticated caller scope, optionally including original input, retained audit-chain links, execution receipts, outcome records, and policy intelligence summaries. If a required packet source cannot be read, the export fails with 503 rather than returning partial proof material.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "name": "include_input",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "include_chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "include_intelligence",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "execution_limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 20
            }
          },
          {
            "name": "outcome_limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 20
            }
          },
          {
            "name": "chain_limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Decision Packet export",
            "headers": {
              "x-decision-packet-version": {
                "schema": {
                  "type": "string",
                  "const": "decision_packet_v1"
                }
              },
              "x-decision-packet-hash": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionPacket"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/decision/{decision_id}/replay": {
      "post": {
        "tags": [
          "Decision Protocol"
        ],
        "operationId": "replayDecision",
        "summary": "Replay a stored decision",
        "description": "Rulebook decisions default to historical replay using the immutable stored rulebook snapshot, original canonical input, and pinned trusted adapter invocation when present. Adapter lineage drift and caller input overrides are rejected. Legacy decisions default to current-mode replay.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "$ref": "#/components/parameters/DecisionResponseView"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReplayRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay summary and current decision projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReplayResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "409": {
            "description": "Historical rulebook or trusted adapter lineage is unavailable or does not match the stored Decision Record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid replay mode, forbidden historical input override, or unavailable replay input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/{decision_id}/diff": {
      "post": {
        "tags": [
          "Decision Protocol"
        ],
        "operationId": "diffDecision",
        "summary": "Replay/diff alias for a stored decision",
        "description": "Forces current-mode replay so callers can compare the stored decision against the current runtime or a supplied current-mode input override.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "$ref": "#/components/parameters/DecisionResponseView"
          }
        ],
        "responses": {
          "200": {
            "description": "Replay/diff summary and current decision projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReplayResult"
                }
              }
            }
          }
        }
      }
    },
    "/api/decision/{decision_id}/counterfactuals": {
      "post": {
        "tags": [
          "Counterfactuals"
        ],
        "operationId": "createDecisionCounterfactuals",
        "summary": "Evaluate what-if scenarios for a stored decision",
        "description": "Runs labeled simulation-only scenarios against the current Decision API runtime. Counterfactuals do not authorize downstream mutation; use the returned diffs for planning, rollout review, and policy tuning.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "$ref": "#/components/parameters/DecisionResponseView"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CounterfactualRequest"
              },
              "examples": {
                "pricingDiscountScenarios": {
                  "summary": "Compare discount levels",
                  "value": {
                    "response_view": "standard",
                    "scenarios": [
                      {
                        "scenario_id": "discount_10_percent",
                        "label": "10% discount",
                        "context_patch": {
                          "discount_percent": 10
                        }
                      },
                      {
                        "scenario_id": "discount_25_percent",
                        "label": "25% discount",
                        "context_patch": {
                          "discount_percent": 25,
                          "margin_floor": "review_required"
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Counterfactual report",
            "headers": {
              "x-decision-counterfactuals-version": {
                "schema": {
                  "type": "string",
                  "const": "decision_counterfactuals_v1"
                }
              },
              "x-decision-counterfactual-hash": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-counterfactual-scenarios": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionCounterfactualsResult"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid scenarios"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "422": {
            "description": "Base input unavailable"
          }
        }
      }
    },
    "/api/decision/{decision_id}/execution": {
      "post": {
        "tags": [
          "Action Execution"
        ],
        "operationId": "recordDecisionExecution",
        "summary": "Record a Decision Action Execution receipt",
        "description": "Creates a hashed Action Execution Receipt linked to the original Decision Record and action binding. Keyed writes are atomically claimed: the same key plus the same canonical execution payload replays the original receipt, a concurrent request returns 409 in progress, and the same key plus a different payload returns 409 conflict. Authoritative storage and idempotency failures return 503 without acknowledging an untracked receipt.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionExecutionRequest"
              },
              "examples": {
                "billingExecution": {
                  "summary": "Billing mutation execution receipt",
                  "value": {
                    "execution_status": "executed",
                    "action_taken": "apply_discount",
                    "target_system": "billing",
                    "target_object_id": "sub_1042",
                    "mutation": "discount.create",
                    "execution_id": "billing_run_1042",
                    "external_ref": "bill_1042",
                    "decision_record_hash": "7f3a...",
                    "decision_receipt_hash": "c91e...",
                    "state_before_hash": "sha256:subscription_before_1042",
                    "state_after_hash": "sha256:subscription_after_1042",
                    "executor": {
                      "type": "service",
                      "id": "billing-worker"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay of an existing Action Execution Receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionExecutionResult"
                }
              }
            }
          },
          "201": {
            "description": "Action Execution Receipt recorded",
            "headers": {
              "x-decision-execution-id": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-execution-hash": {
                "schema": {
                  "type": "string"
                }
              },
              "x-idempotency-status": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "created",
                    "replayed"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionExecutionResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "get": {
        "tags": [
          "Action Execution"
        ],
        "operationId": "listDecisionExecutions",
        "summary": "List Action Execution Receipts for a decision",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Action Execution Receipt list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "decision_id",
                    "count",
                    "executions"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "decision_id": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "executions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DecisionExecution"
                      }
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/decision/{decision_id}/outcome": {
      "post": {
        "tags": [
          "Outcome Tracking"
        ],
        "operationId": "recordDecisionOutcome",
        "summary": "Record a Decision Outcome",
        "description": "Creates a hashed Outcome Record linked to the original Decision Record. Keyed writes are atomically claimed: the same key plus the same canonical outcome payload replays the original outcome, a concurrent request returns 409 in progress, and the same key plus a different payload returns 409 conflict. Authoritative storage and idempotency failures return 503 without acknowledging an untracked outcome.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionOutcomeRequest"
              },
              "examples": {
                "billingMutation": {
                  "summary": "Billing mutation outcome",
                  "value": {
                    "outcome_status": "succeeded",
                    "action_taken": "apply_discount",
                    "action_executed": true,
                    "target_system": "billing",
                    "target_object_id": "sub_1042",
                    "mutation": "discount.create",
                    "external_ref": "bill_1042",
                    "decision_record_hash": "7f3a...",
                    "decision_receipt_hash": "c91e...",
                    "observed_metrics": {
                      "margin_after_discount": 0.182
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay of an existing Decision Outcome",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionOutcomeResult"
                }
              }
            }
          },
          "201": {
            "description": "Decision Outcome recorded",
            "headers": {
              "x-decision-outcome-id": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-outcome-hash": {
                "schema": {
                  "type": "string"
                }
              },
              "x-idempotency-status": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "created",
                    "replayed"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionOutcomeResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "get": {
        "tags": [
          "Outcome Tracking"
        ],
        "operationId": "listDecisionOutcomes",
        "summary": "List Decision Outcomes for a decision",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Decision Outcome list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "decision_id",
                    "count",
                    "outcomes"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "decision_id": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "outcomes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DecisionOutcome"
                      }
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/decision/{decision_id}/crm-sync": {
      "post": {
        "tags": [
          "CRM Sync"
        ],
        "operationId": "recordDecisionCrmSync",
        "summary": "Record a Decision CRM Sync receipt",
        "description": "Creates a hashed CRM Sync Record linked to the original Decision Record. Keyed writes are atomically claimed: the same key plus the same canonical CRM sync payload replays the original receipt, a concurrent request returns 409 in progress, and the same key plus a different payload returns 409 conflict. Authoritative storage and idempotency failures return 503 without acknowledging an untracked sync receipt.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionCrmSyncRequest"
              },
              "examples": {
                "salesforceWriteback": {
                  "summary": "Salesforce opportunity write-back",
                  "value": {
                    "sync_status": "written",
                    "sync_direction": "writeback",
                    "crm_provider": "salesforce",
                    "crm_object_type": "Opportunity",
                    "crm_object_id": "006xx000004TmiQAAS",
                    "crm_record_url": "https://example.my.salesforce.com/006xx000004TmiQAAS",
                    "decision_record_hash": "7f3a...",
                    "decision_receipt_hash": "c91e...",
                    "decision_verdict": "yes",
                    "decision_action": "approve_discount",
                    "policy_id": "pricing_exception",
                    "policy_version": "v3"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay of an existing Decision CRM Sync receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionCrmSyncResult"
                }
              }
            }
          },
          "201": {
            "description": "Decision CRM Sync recorded",
            "headers": {
              "x-decision-crm-sync-id": {
                "schema": {
                  "type": "string"
                }
              },
              "x-decision-crm-sync-hash": {
                "schema": {
                  "type": "string"
                }
              },
              "x-idempotency-status": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "created",
                    "replayed"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionCrmSyncResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "get": {
        "tags": [
          "CRM Sync"
        ],
        "operationId": "listDecisionCrmSyncs",
        "summary": "List Decision CRM Sync receipts for a decision",
        "parameters": [
          {
            "$ref": "#/components/parameters/DecisionId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Decision CRM Sync receipt list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "decision_id",
                    "count",
                    "crm_syncs"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "decision_id": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "crm_syncs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DecisionCrmSync"
                      }
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Decision not found in the authenticated caller scope"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/decision/policies/{policy_id}/effectiveness": {
      "get": {
        "tags": [
          "Effectiveness"
        ],
        "operationId": "getPolicyEffectiveness",
        "summary": "Read outcome-based policy effectiveness",
        "description": "Returns policy_effectiveness_v1 metrics derived from the latest Decision Outcome per decision within the caller API-key scope. Proxy false-positive/false-negative rates are outcome proxies, not causal ML claims.",
        "parameters": [
          {
            "name": "policy_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "policy_version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 500
            }
          },
          {
            "name": "min_sample",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Policy effectiveness metrics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PolicyEffectiveness"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/decision/policies/{policy_id}/confidence": {
      "get": {
        "tags": [
          "Confidence"
        ],
        "operationId": "getPolicyConfidence",
        "summary": "Read predictive policy confidence",
        "description": "Returns decision_confidence_v1 for a candidate verdict/action using latest Decision Outcome records within the caller API-key scope. Scores are deterministic confidence signals, not causal ML claims.",
        "parameters": [
          {
            "name": "policy_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "policy_version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "verdict",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "yes"
            }
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 140
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1000
            }
          },
          {
            "name": "min_sample",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Decision confidence baseline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionConfidence"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/decision/policies/{policy_id}/benchmarks": {
      "get": {
        "tags": [
          "Benchmarks"
        ],
        "operationId": "getPolicyBenchmarks",
        "summary": "Read anonymized policy benchmarks",
        "description": "Returns decision_benchmark_v1 with caller metrics and opt-in anonymized cohort percentiles when minimum cohort privacy thresholds are met. Raw customer records are never exposed.",
        "parameters": [
          {
            "name": "policy_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "policy_version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 250000,
              "default": 5000
            }
          },
          {
            "name": "min_cohort_scopes",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 2,
              "maximum": 10000,
              "default": 3
            }
          },
          {
            "name": "min_cohort_decisions",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 5,
              "maximum": 1000000,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Anonymized policy benchmark report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionBenchmark"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/decision/policies/{policy_id}/anomalies": {
      "get": {
        "tags": [
          "Anomalies"
        ],
        "operationId": "getPolicyAnomalies",
        "summary": "Read outcome-based policy anomalies",
        "description": "Returns decision_anomaly_report_v1 derived from the latest Decision Outcome per decision within the caller API-key scope. Scores are deterministic outcome-signal heuristics with explainable reason codes, not model predictions.",
        "parameters": [
          {
            "name": "policy_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "policy_version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1000
            }
          },
          {
            "name": "min_sample",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 10
            }
          },
          {
            "name": "threshold",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 1,
              "default": 0.35
            }
          },
          {
            "name": "max_items",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Policy anomaly report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PolicyAnomalyReport"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/decision/chains/{chain_id}": {
      "get": {
        "tags": [
          "Audit Chain"
        ],
        "operationId": "getDecisionChain",
        "summary": "Read a Decision Record audit chain",
        "description": "Returns decision_chain_v1 head metadata, retained chain links, rolling Merkle root, and verification checks for the caller API-key scoped audit chain. Reads fail with 503 when the authoritative chain store is unavailable rather than reporting a missing chain.",
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 180
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Decision chain report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionChain"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Requested chain does not match caller scope"
          },
          "404": {
            "description": "Decision chain not found"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "parameters": {
      "DecisionId": {
        "name": "decision_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "maxLength": 600
        }
      },
      "DecisionResponseView": {
        "name": "x-decision-response-view",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "minimal",
            "standard",
            "full"
          ]
        }
      },
      "IdempotencyKey": {
        "name": "x-idempotency-key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 300
        }
      },
      "RequestId": {
        "name": "x-request-id",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 160
        }
      },
      "Prefer": {
        "name": "Prefer",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "examples": [
            "return=minimal",
            "return=standard",
            "return=full"
          ]
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "API key missing, invalid, inactive, or unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "IdempotencyConflict": {
        "description": "The idempotency key is already in progress, or it was reused with a different canonical payload",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit or monthly cap exceeded",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "UpstreamFailure": {
        "description": "Upstream decision engine unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "Decision storage or the upstream decision engine timed out or is temporarily unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "DecisionRequest": {
        "type": "object",
        "anyOf": [
          {
            "required": [
              "question"
            ]
          },
          {
            "required": [
              "prompt",
              "context"
            ]
          },
          {
            "required": [
              "mode",
              "rulebook",
              "context"
            ],
            "properties": {
              "mode": {
                "const": "rulebook"
              }
            }
          }
        ],
        "properties": {
          "question": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "single",
              "multi",
              "runtime",
              "rulebook"
            ]
          },
          "prompt": {
            "type": "string"
          },
          "stem": {
            "type": "string"
          },
          "options": {
            "type": "array",
            "minItems": 2,
            "maxItems": 8,
            "items": {
              "type": "string"
            }
          },
          "context": {
            "type": [
              "object",
              "string"
            ],
            "additionalProperties": true
          },
          "response_view": {
            "type": "string",
            "enum": [
              "minimal",
              "standard",
              "full"
            ]
          },
          "rulebook": {
            "$ref": "#/components/schemas/RulebookV1"
          },
          "adapter": {
            "$ref": "#/components/schemas/TrustedAdapterInvocation"
          }
        },
        "additionalProperties": false
      },
      "TrustedAdapterInvocation": {
        "type": "object",
        "required": [
          "adapter_id",
          "version",
          "manifest_hash",
          "input"
        ],
        "properties": {
          "adapter_id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.:-]{1,119}$"
          },
          "version": {
            "type": "string",
            "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
          },
          "manifest_hash": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "input": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "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
      },
      "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
      },
      "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
      },
      "RulebookV1": {
        "type": "object",
        "required": [
          "schema_version",
          "rulebook_id",
          "version",
          "rules",
          "default_outcome"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "const": "rulebook_v1"
          },
          "rulebook_id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.:-]{1,119}$"
          },
          "version": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "input_schema": {
            "$ref": "#/components/schemas/RulebookInputSchema"
          },
          "rules": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/RulebookRule"
            }
          },
          "default_outcome": {
            "$ref": "#/components/schemas/RulebookOutcome"
          }
        },
        "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
      },
      "RulebookInputSchema": {
        "type": "object",
        "properties": {
          "required": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z_][A-Za-z0-9_.-]{0,159}$"
            }
          },
          "properties": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "required": [
                "type"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "integer",
                    "boolean",
                    "array",
                    "object",
                    "null"
                  ]
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      },
      "RulebookRule": {
        "type": "object",
        "required": [
          "rule_id",
          "condition",
          "outcome"
        ],
        "properties": {
          "rule_id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.:-]{1,119}$"
          },
          "priority": {
            "type": "integer",
            "minimum": -1000,
            "maximum": 1000,
            "default": 0
          },
          "condition": {
            "$ref": "#/components/schemas/RulebookCondition"
          },
          "outcome": {
            "$ref": "#/components/schemas/RulebookOutcome"
          }
        },
        "additionalProperties": false
      },
      "RulebookCondition": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "all"
            ],
            "properties": {
              "all": {
                "type": "array",
                "minItems": 1,
                "maxItems": 32,
                "items": {
                  "$ref": "#/components/schemas/RulebookCondition"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "any"
            ],
            "properties": {
              "any": {
                "type": "array",
                "minItems": 1,
                "maxItems": 32,
                "items": {
                  "$ref": "#/components/schemas/RulebookCondition"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "not"
            ],
            "properties": {
              "not": {
                "$ref": "#/components/schemas/RulebookCondition"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "field",
              "operator"
            ],
            "properties": {
              "field": {
                "type": "string",
                "pattern": "^[A-Za-z_][A-Za-z0-9_.-]{0,159}$"
              },
              "operator": {
                "type": "string",
                "enum": [
                  "exists",
                  "not_exists",
                  "eq",
                  "neq",
                  "gt",
                  "gte",
                  "lt",
                  "lte",
                  "in",
                  "not_in",
                  "contains",
                  "not_contains"
                ]
              },
              "value": {}
            },
            "additionalProperties": false
          }
        ]
      },
      "RulebookOutcome": {
        "type": "object",
        "required": [
          "decision",
          "verdict",
          "action",
          "reason_code"
        ],
        "properties": {
          "decision": {
            "type": "string",
            "enum": [
              "yes",
              "no",
              "review"
            ]
          },
          "verdict": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]{1,79}$"
          },
          "action": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "reason_code": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]{1,79}$"
          }
        },
        "additionalProperties": false
      },
      "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
      },
      "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": "#/components/schemas/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": "#/components/schemas/RegistryAttestation"
          },
          "registered_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "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": "#/components/schemas/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": "#/components/schemas/RulebookRegistryMetadata"
          },
          "runtime_binding": {
            "$ref": "#/components/schemas/RuntimeBinding"
          },
          "trusted_adapter": {
            "$ref": "#/components/schemas/TrustedAdapterAttestation"
          },
          "adapter_facts": {
            "type": "object",
            "description": "Schema-validated facts emitted by the pinned trusted adapter before Rulebook v1 evaluation.",
            "additionalProperties": true
          },
          "action_binding": {
            "$ref": "#/components/schemas/ActionBinding"
          },
          "evidence": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence_manifest": {
            "$ref": "#/components/schemas/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": "#/components/schemas/PolicyBundle"
          },
          "policy_bundle_hash": {
            "type": "string"
          },
          "confidence": {
            "$ref": "#/components/schemas/DecisionConfidence"
          },
          "decision_confidence": {
            "$ref": "#/components/schemas/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": "#/components/schemas/Integrity"
          },
          "verify_url": {
            "type": "string"
          },
          "replay_url": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          },
          "audit_chain": {
            "$ref": "#/components/schemas/AuditChain"
          },
          "chain_url": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "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
      },
      "EvidenceManifest": {
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/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
      },
      "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
      },
      "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
      },
      "VerifyRecordRequest": {
        "type": "object",
        "required": [
          "record"
        ],
        "properties": {
          "record": {
            "$ref": "#/components/schemas/DecisionRecord"
          },
          "decision": {
            "$ref": "#/components/schemas/DecisionRecord"
          },
          "input": {
            "type": "object",
            "additionalProperties": true
          },
          "request": {
            "type": "object",
            "additionalProperties": true
          },
          "public_key": {
            "type": "string",
            "description": "Optional Ed25519 public key for integrity diagnostics. Because it arrives with the record, it is not a hosted-verifier trust anchor and cannot make authenticity_valid true."
          }
        },
        "additionalProperties": true
      },
      "VerifyDecisionPacketRequest": {
        "type": "object",
        "required": [
          "packet"
        ],
        "properties": {
          "packet": {
            "$ref": "#/components/schemas/DecisionPacket"
          },
          "decision_packet": {
            "$ref": "#/components/schemas/DecisionPacket"
          },
          "input": {
            "type": "object",
            "additionalProperties": true
          },
          "public_key": {
            "type": "string",
            "description": "Optional Ed25519 public key for integrity diagnostics. Because it arrives with the packet, it is not a hosted-verifier trust anchor and cannot make authenticity_valid true."
          }
        },
        "additionalProperties": true
      },
      "DecisionPacket": {
        "type": "object",
        "required": [
          "ok",
          "decision_protocol_version",
          "decision_packet_version",
          "decision_record",
          "packet_manifest",
          "packet_hash"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "decision_protocol_version": {
            "type": "string",
            "const": "decision_protocol_v1"
          },
          "decision_packet_version": {
            "type": "string",
            "const": "decision_packet_v1"
          },
          "generated_at": {
            "type": "string"
          },
          "decision_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "record_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "receipt_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "policy_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "policy_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "decision_record": {
            "$ref": "#/components/schemas/DecisionRecord"
          },
          "input": {
            "type": "object",
            "additionalProperties": true
          },
          "executions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DecisionExecution"
            }
          },
          "outcomes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DecisionOutcome"
            }
          },
          "policy_intelligence": {
            "type": "object",
            "properties": {
              "effectiveness": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/PolicyEffectiveness"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "anomalies": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/PolicyAnomalyReport"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "additionalProperties": true
          },
          "audit_chain": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DecisionChain"
              },
              {
                "type": "null"
              }
            ]
          },
          "verification_hints": {
            "type": "object",
            "additionalProperties": true
          },
          "packet_manifest": {
            "type": "object",
            "additionalProperties": true
          },
          "packet_hash": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "VerificationResult": {
        "type": "object",
        "required": [
          "ok",
          "verified",
          "checks"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "decision_id": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "verified": {
            "type": "boolean",
            "description": "True only when both integrity_valid and authenticity_valid are true."
          },
          "integrity_valid": {
            "type": "boolean",
            "description": "True when the supplied hashes, signature bytes, fingerprints, and optional input links are internally consistent."
          },
          "authenticity_valid": {
            "type": "boolean",
            "description": "True when the receipt signature validates against a trusted server, registry, pinned-key, or HMAC trust anchor."
          },
          "key_source": {
            "type": "string",
            "enum": [
              "public_key",
              "key_registry",
              "environment",
              "request_body",
              "record",
              "none"
            ],
            "description": "Where the verification key came from. request_body and record are diagnostic sources, not authenticity trust anchors."
          },
          "checks": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "boolean",
                "null"
              ]
            }
          },
          "expected": {
            "type": "object",
            "additionalProperties": true
          },
          "actual": {
            "type": "object",
            "additionalProperties": true
          },
          "policy_bundle": {
            "$ref": "#/components/schemas/PolicyBundle"
          },
          "record_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "receipt_hash": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": true
      },
      "DecisionStatus": {
        "type": "object",
        "required": [
          "ok",
          "status",
          "decision_protocol_version",
          "checks"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "ready",
              "degraded",
              "error"
            ]
          },
          "decision_protocol_version": {
            "type": "string"
          },
          "decision_record_version": {
            "type": "string"
          },
          "checks": {
            "type": "object",
            "properties": {
              "rulebook_runtime_contract": {
                "$ref": "#/components/schemas/RulebookRuntimeContractStatus"
              },
              "rulebook_registry": {
                "$ref": "#/components/schemas/RulebookRegistryStatus"
              }
            },
            "additionalProperties": true
          },
          "endpoints": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "additionalProperties": true
      },
      "RulebookRuntimeContractStatus": {
        "type": "object",
        "required": [
          "ok",
          "status",
          "manifest_version",
          "manifest_url",
          "schema_version",
          "schema_url",
          "schema_hash",
          "evaluator_version",
          "execution_model",
          "application_binding"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "status": {
            "type": "string",
            "const": "configured"
          },
          "manifest_version": {
            "type": "string",
            "const": "rulebook_runtime_manifest_v1"
          },
          "manifest_url": {
            "type": "string",
            "const": "https://api.decide.fyi/manifests/rulebook-runtime-v1.json"
          },
          "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",
            "const": "bbf6d40dc8318e4943c6a3955d1ee10c64b63e8a6fdfd53ce33a498d826dfa5c",
            "description": "SHA-256 hash of the published Rulebook v1 JSON Schema enforced by the runtime."
          },
          "evaluator_version": {
            "type": "string",
            "const": "decide_rulebook_v1"
          },
          "execution_model": {
            "type": "object",
            "required": [
              "production_core",
              "binding_verdict_selector",
              "customer_supplied_code",
              "trusted_adapters",
              "response_only_material_policy",
              "binding_modes",
              "unsupported_modes"
            ],
            "properties": {
              "production_core": {
                "type": "string",
                "const": "hybrid_declarative_rulebook_with_trusted_adapters"
              },
              "binding_verdict_selector": {
                "type": "string",
                "const": "declarative_rulebook"
              },
              "customer_supplied_code": {
                "type": "string",
                "const": "rejected"
              },
              "trusted_adapters": {
                "type": "string",
                "const": "registered_fact_producers"
              },
              "response_only_material_policy": {
                "type": "object",
                "required": [
                  "status",
                  "applies_to",
                  "fields",
                  "error"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "const": "rejected_on_request"
                  },
                  "applies_to": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "request_body",
                        "context.inputs",
                        "adapter_facts"
                      ]
                    },
                    "minItems": 3,
                    "maxItems": 3
                  },
                  "fields": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "runtime_binding",
                        "trusted_adapter",
                        "adapter_facts",
                        "rulebook_attestation",
                        "rulebook_contract",
                        "decision_contract",
                        "input_hash",
                        "decision_id",
                        "record_hash",
                        "receipt_hash",
                        "verify_url",
                        "replay_url",
                        "engine",
                        "evaluator_version",
                        "verdict",
                        "application_verdict",
                        "action",
                        "reason_code",
                        "matched_rule_id"
                      ]
                    },
                    "minItems": 18,
                    "maxItems": 18
                  },
                  "error": {
                    "type": "string",
                    "const": "RULEBOOK_OUTPUT_MATERIAL_FORBIDDEN"
                  }
                },
                "additionalProperties": false
              },
              "binding_modes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "mode": {
                      "type": "string",
                      "enum": [
                        "direct_declarative_rulebook",
                        "trusted_adapter_facts_then_declarative_rulebook"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "const": "supported"
                    },
                    "request_material": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "fact_source": {
                      "type": "string"
                    },
                    "adapter_authority": {
                      "type": "string",
                      "const": "facts_only"
                    },
                    "verdict_authority": {
                      "type": "string",
                      "const": "declarative_rulebook"
                    },
                    "customer_supplied_code": {
                      "type": "string",
                      "const": "rejected"
                    }
                  },
                  "additionalProperties": false
                }
              },
              "unsupported_modes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "mode": {
                      "type": "string",
                      "const": "customer_executable_rulebook"
                    },
                    "status": {
                      "type": "string",
                      "const": "rejected"
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "additionalProperties": false
          },
          "application_binding": {
            "type": "object",
            "required": [
              "contract_version",
              "applies_to",
              "must_bind_before_action",
              "accepted_fact_sources",
              "required_decision_material",
              "replay_reference",
              "conformance_reference",
              "prohibited_claims"
            ],
            "properties": {
              "contract_version": {
                "type": "string",
                "const": "decide_application_binding_v1"
              },
              "applies_to": {
                "type": "string",
                "const": "krafthaus_workflow_applications"
              },
              "must_bind_before_action": {
                "type": "boolean",
                "const": true
              },
              "accepted_fact_sources": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "context.inputs",
                    "adapter_facts"
                  ]
                },
                "minItems": 2,
                "maxItems": 2
              },
              "required_decision_material": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "rulebook_contract",
                    "runtime_binding",
                    "verdict",
                    "application_verdict",
                    "action",
                    "reason_code",
                    "matched_rule_id",
                    "rulebook.hash",
                    "input_hash",
                    "rulebook_attestation.bundle_hash"
                  ]
                },
                "minItems": 10,
                "maxItems": 10,
                "description": "Fields a workflow application must preserve before the downstream action handoff."
              },
              "replay_reference": {
                "type": "string",
                "const": "https://api.decide.fyi/replay/rulebook-v1/index.json"
              },
              "conformance_reference": {
                "type": "string",
                "const": "https://api.decide.fyi/conformance/rulebook-v1/index.json"
              },
              "prohibited_claims": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "llm_output_is_binding_production_verdict",
                    "customer_executable_code_runs_as_rulebook_v1",
                    "action_executes_before_decision_material_is_captured"
                  ]
                },
                "minItems": 3,
                "maxItems": 3
              }
            },
            "additionalProperties": false,
            "description": "Application-layer contract for Krafthaus workflow apps that bind Decide results before execution handoff."
          }
        },
        "additionalProperties": false
      },
      "RegistryAttestationStatus": {
        "type": "object",
        "required": [
          "ok",
          "status",
          "registry_attestation_version",
          "public_verification",
          "required"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "configured",
              "unconfigured"
            ]
          },
          "registry_attestation_version": {
            "type": "string",
            "const": "decision_registry_attestation_v1"
          },
          "algorithm": {
            "type": [
              "string",
              "null"
            ]
          },
          "current_key_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "public_key_fingerprint": {
            "type": [
              "string",
              "null"
            ]
          },
          "public_verification": {
            "type": "boolean"
          },
          "required": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "RulebookRegistryStatus": {
        "type": "object",
        "required": [
          "ok",
          "rulebook_registry_version",
          "backend",
          "durable",
          "storage",
          "snapshot_visibility",
          "metadata_lookup",
          "attestation"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "rulebook_registry_version": {
            "type": "string",
            "const": "decision_rulebook_registry_v1"
          },
          "backend": {
            "type": "string",
            "enum": [
              "kv",
              "fs"
            ]
          },
          "durable": {
            "type": "boolean"
          },
          "storage": {
            "type": "string"
          },
          "snapshot_visibility": {
            "type": "string",
            "const": "internal"
          },
          "metadata_lookup": {
            "type": "string",
            "const": "tenant_scoped"
          },
          "attestation": {
            "$ref": "#/components/schemas/RegistryAttestationStatus"
          }
        },
        "additionalProperties": false
      },
      "PolicyBundleRegistry": {
        "type": "object",
        "required": [
          "ok",
          "status",
          "bundles",
          "registry_hash"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string"
          },
          "current_policy_bundle_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "current": {
            "$ref": "#/components/schemas/PolicyBundle"
          },
          "bundles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PolicyBundle"
            }
          },
          "registry_hash": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionPattern": {
        "type": "object",
        "required": [
          "decision_pattern_version",
          "pattern_id",
          "policy_id",
          "pattern_hash"
        ],
        "properties": {
          "decision_pattern_version": {
            "type": "string",
            "const": "decision_pattern_v1"
          },
          "pattern_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "policy_id": {
            "type": "string"
          },
          "recommended_policy_version": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "required_context_fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "recommended_context_fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence_codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "decision_request_template": {
            "$ref": "#/components/schemas/DecisionRequest"
          },
          "outcome_template": {
            "type": "object",
            "additionalProperties": true
          },
          "crm_sync_template": {
            "type": "object",
            "additionalProperties": true
          },
          "sdk_examples": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "pattern_hash": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionPatternRegistry": {
        "type": "object",
        "required": [
          "ok",
          "decision_pattern_registry_version",
          "patterns",
          "registry_hash"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "decision_protocol_version": {
            "type": "string"
          },
          "decision_record_version": {
            "type": "string"
          },
          "decision_pattern_registry_version": {
            "type": "string",
            "const": "decision_pattern_registry_v1"
          },
          "source": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "patterns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DecisionPattern"
            }
          },
          "registry_hash": {
            "type": "string"
          },
          "endpoints": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "additionalProperties": true
      },
      "DecisionPatternResponse": {
        "type": "object",
        "required": [
          "ok",
          "policy_pattern"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "policy_pattern": {
            "$ref": "#/components/schemas/DecisionPattern"
          }
        },
        "additionalProperties": true
      },
      "ReceiptKeyRegistry": {
        "type": "object",
        "required": [
          "ok",
          "status",
          "keys"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string"
          },
          "current_key_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "keys": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key_id": {
                  "type": "string"
                },
                "algorithm": {
                  "type": "string"
                },
                "public_key": {
                  "type": "string"
                },
                "public_key_fingerprint": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "updated_at": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      },
      "ReplayRequest": {
        "type": "object",
        "properties": {
          "replay_mode": {
            "type": "string",
            "enum": [
              "historical",
              "current"
            ],
            "description": "Rulebook decisions default to historical. Legacy decisions default to current."
          },
          "input": {
            "$ref": "#/components/schemas/DecisionRequest",
            "description": "Optional current-mode input override. Forbidden for historical rulebook replay."
          },
          "response_view": {
            "type": "string",
            "enum": [
              "minimal",
              "standard",
              "full"
            ]
          }
        },
        "additionalProperties": false
      },
      "ReplaySummary": {
        "type": "object",
        "required": [
          "mode",
          "source_decision_id",
          "replay_decision_id",
          "changed",
          "semantic_match",
          "historical_reproduction",
          "previous",
          "current",
          "diff"
        ],
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "historical",
              "current"
            ]
          },
          "source_decision_id": {
            "type": "string"
          },
          "replay_decision_id": {
            "type": "string"
          },
          "changed": {
            "type": "boolean"
          },
          "semantic_match": {
            "type": "boolean"
          },
          "historical_reproduction": {
            "type": "boolean"
          },
          "rulebook_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "adapter_manifest_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "evaluator_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "previous": {
            "type": "object",
            "additionalProperties": true
          },
          "current": {
            "type": "object",
            "additionalProperties": true
          },
          "diff": {
            "type": "object",
            "properties": {
              "output_changed": {
                "type": "boolean"
              },
              "verdict_changed": {
                "type": "boolean"
              },
              "policy_version_changed": {
                "type": "boolean"
              },
              "semantic_changed": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ReplayResult": {
        "type": "object",
        "required": [
          "ok",
          "replay",
          "decision"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "replay": {
            "$ref": "#/components/schemas/ReplaySummary"
          },
          "decision": {
            "$ref": "#/components/schemas/DecisionRecord"
          }
        },
        "additionalProperties": true
      },
      "CounterfactualScenario": {
        "type": "object",
        "required": [
          "scenario_id"
        ],
        "properties": {
          "scenario_id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "input": {
            "$ref": "#/components/schemas/DecisionRequest"
          },
          "request": {
            "$ref": "#/components/schemas/DecisionRequest"
          },
          "patch": {
            "type": "object",
            "additionalProperties": true
          },
          "context_patch": {
            "type": "object",
            "additionalProperties": true
          },
          "question": {
            "type": "string"
          },
          "mode": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "CounterfactualRequest": {
        "type": "object",
        "required": [
          "scenarios"
        ],
        "properties": {
          "base_input": {
            "$ref": "#/components/schemas/DecisionRequest"
          },
          "input": {
            "$ref": "#/components/schemas/DecisionRequest"
          },
          "response_view": {
            "type": "string",
            "enum": [
              "minimal",
              "standard",
              "full"
            ]
          },
          "scenarios": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "items": {
              "$ref": "#/components/schemas/CounterfactualScenario"
            }
          }
        },
        "additionalProperties": true
      },
      "DecisionCounterfactualsResult": {
        "type": "object",
        "required": [
          "ok",
          "decision_counterfactuals_version",
          "source_decision_id",
          "simulation_only",
          "baseline",
          "scenarios",
          "counterfactual_hash"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "decision_counterfactuals_version": {
            "type": "string",
            "const": "decision_counterfactuals_v1"
          },
          "generated_at": {
            "type": "string"
          },
          "source_decision_id": {
            "type": "string"
          },
          "simulation_only": {
            "type": "boolean",
            "const": true
          },
          "baseline": {
            "type": "object",
            "additionalProperties": true
          },
          "scenario_count": {
            "type": "integer"
          },
          "evaluated_count": {
            "type": "integer"
          },
          "changed_count": {
            "type": "integer"
          },
          "scenarios": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "scenario_id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "evaluated",
                    "failed"
                  ]
                },
                "simulation_only": {
                  "type": "boolean"
                },
                "changed": {
                  "type": "boolean"
                },
                "verdict": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                },
                "input_hash": {
                  "type": "string"
                },
                "output_hash": {
                  "type": "string"
                },
                "record_hash": {
                  "type": "string"
                },
                "receipt_hash": {
                  "type": "string"
                },
                "diff": {
                  "type": "object",
                  "additionalProperties": true
                },
                "decision": {
                  "$ref": "#/components/schemas/DecisionRecord"
                },
                "scenario_hash": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          },
          "data_quality": {
            "type": "object",
            "additionalProperties": true
          },
          "counterfactual_hash": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "c": {
            "type": "string"
          },
          "v": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionOutcomeRequest": {
        "type": "object",
        "required": [
          "outcome_status"
        ],
        "properties": {
          "decision_id": {
            "type": "string",
            "maxLength": 600
          },
          "outcome_status": {
            "type": "string",
            "description": "Normalized to succeeded, failed, reverted, reviewed, skipped, unknown, or a compact custom status."
          },
          "action_taken": {
            "type": "string"
          },
          "action_executed": {
            "type": "boolean"
          },
          "target_system": {
            "type": "string"
          },
          "target_object_id": {
            "type": "string"
          },
          "mutation": {
            "type": "string"
          },
          "external_ref": {
            "type": "string"
          },
          "decision_record_hash": {
            "type": "string"
          },
          "decision_receipt_hash": {
            "type": "string"
          },
          "observed_metrics": {
            "type": "object",
            "additionalProperties": true
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": [
                "object",
                "string"
              ],
              "additionalProperties": true
            }
          },
          "executed_at": {
            "type": "string"
          },
          "reported_at": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionOutcome": {
        "type": "object",
        "required": [
          "decision_protocol_version",
          "decision_outcome_version",
          "outcome_id",
          "decision_id",
          "outcome_status",
          "outcome_hash",
          "reported_at"
        ],
        "properties": {
          "decision_protocol_version": {
            "type": "string",
            "const": "decision_protocol_v1"
          },
          "decision_outcome_version": {
            "type": "string",
            "const": "decision_outcome_v1"
          },
          "outcome_id": {
            "type": "string"
          },
          "decision_id": {
            "type": "string"
          },
          "idempotency_key": {
            "type": "string"
          },
          "outcome_status": {
            "type": "string"
          },
          "action_executed": {
            "type": "boolean"
          },
          "action_taken": {
            "type": "string"
          },
          "target_system": {
            "type": "string"
          },
          "target_object_id": {
            "type": "string"
          },
          "mutation": {
            "type": "string"
          },
          "external_ref": {
            "type": "string"
          },
          "decision_record_hash": {
            "type": "string"
          },
          "decision_receipt_hash": {
            "type": "string"
          },
          "decision_verdict": {
            "type": "string"
          },
          "decision_action": {
            "type": "string"
          },
          "policy_id": {
            "type": "string"
          },
          "policy_version": {
            "type": "string"
          },
          "policy_bundle_hash": {
            "type": "string"
          },
          "action_binding": {
            "$ref": "#/components/schemas/ActionBinding"
          },
          "observed_metrics": {
            "type": "object",
            "additionalProperties": true
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "outcome_input_hash": {
            "type": "string"
          },
          "outcome_hash": {
            "type": "string"
          },
          "integrity": {
            "type": "object",
            "additionalProperties": true
          },
          "executed_at": {
            "type": "string"
          },
          "reported_at": {
            "type": "string"
          },
          "decision_found": {
            "type": "boolean"
          },
          "decision_url": {
            "type": "string"
          },
          "verify_url": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionOutcomeResult": {
        "type": "object",
        "required": [
          "ok",
          "decision_id",
          "outcome"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "idempotency_status": {
            "type": "string"
          },
          "decision_id": {
            "type": "string"
          },
          "outcome": {
            "$ref": "#/components/schemas/DecisionOutcome"
          }
        },
        "additionalProperties": true
      },
      "DecisionCrmSyncRequest": {
        "type": "object",
        "required": [
          "sync_status",
          "crm_provider",
          "crm_object_type",
          "crm_object_id"
        ],
        "properties": {
          "decision_id": {
            "type": "string",
            "maxLength": 600
          },
          "sync_status": {
            "type": "string",
            "description": "Normalized to queued, written, failed, skipped, stale, unknown, or a compact custom status."
          },
          "sync_direction": {
            "type": "string",
            "enum": [
              "writeback",
              "inbound",
              "bidirectional"
            ]
          },
          "crm_provider": {
            "type": "string",
            "examples": [
              "salesforce",
              "hubspot",
              "generic"
            ]
          },
          "crm_object_type": {
            "type": "string"
          },
          "crm_object_id": {
            "type": "string"
          },
          "crm_record_url": {
            "type": "string"
          },
          "field_mapping": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "mapped_fields": {
            "type": "object",
            "additionalProperties": true
          },
          "decision_record_hash": {
            "type": "string"
          },
          "decision_receipt_hash": {
            "type": "string"
          },
          "decision_verdict": {
            "type": "string"
          },
          "decision_action": {
            "type": "string"
          },
          "policy_id": {
            "type": "string"
          },
          "policy_version": {
            "type": "string"
          },
          "crm_revision": {
            "type": "string"
          },
          "crm_modified_at": {
            "type": "string"
          },
          "reported_at": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionCrmSync": {
        "type": "object",
        "required": [
          "decision_protocol_version",
          "decision_crm_sync_version",
          "sync_id",
          "decision_id",
          "sync_status",
          "crm_target",
          "sync_hash",
          "reported_at"
        ],
        "properties": {
          "decision_protocol_version": {
            "type": "string",
            "const": "decision_protocol_v1"
          },
          "decision_crm_sync_version": {
            "type": "string",
            "const": "decision_crm_sync_v1"
          },
          "sync_id": {
            "type": "string"
          },
          "decision_id": {
            "type": "string"
          },
          "idempotency_key": {
            "type": "string"
          },
          "sync_direction": {
            "type": "string"
          },
          "sync_status": {
            "type": "string"
          },
          "crm_target": {
            "type": "object",
            "additionalProperties": true
          },
          "field_mapping": {
            "type": "object",
            "additionalProperties": true
          },
          "mapped_fields": {
            "type": "object",
            "additionalProperties": true
          },
          "decision_values": {
            "type": "object",
            "additionalProperties": true
          },
          "sync_input_hash": {
            "type": "string"
          },
          "sync_hash": {
            "type": "string"
          },
          "integrity": {
            "type": "object",
            "additionalProperties": true
          },
          "reported_at": {
            "type": "string"
          },
          "decision_found": {
            "type": "boolean"
          },
          "decision_url": {
            "type": "string"
          },
          "verify_url": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionCrmSyncResult": {
        "type": "object",
        "required": [
          "ok",
          "decision_id",
          "crm_sync"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "idempotency_status": {
            "type": "string"
          },
          "decision_id": {
            "type": "string"
          },
          "crm_sync": {
            "$ref": "#/components/schemas/DecisionCrmSync"
          }
        },
        "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
      },
      "DecisionBenchmark": {
        "type": "object",
        "required": [
          "ok",
          "decision_benchmark_version",
          "policy_id",
          "privacy",
          "your_metrics",
          "cross_customer",
          "recommendation",
          "benchmark_hash"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "decision_benchmark_version": {
            "type": "string",
            "const": "decision_benchmark_v1"
          },
          "generated_at": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "const": "decision_outcomes"
          },
          "scope": {
            "type": "string",
            "const": "caller_api_key_plus_anonymized_opt_in_cohort"
          },
          "policy_id": {
            "type": "string"
          },
          "policy_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "privacy": {
            "type": "object",
            "properties": {
              "anonymized": {
                "type": "boolean"
              },
              "raw_records_exposed": {
                "type": "boolean",
                "const": false
              },
              "caller_excluded_from_cohort": {
                "type": "boolean"
              },
              "opt_in_required": {
                "type": "boolean"
              },
              "enabled": {
                "type": "boolean"
              },
              "minimum_cohort_scopes": {
                "type": "integer"
              },
              "minimum_cohort_decisions": {
                "type": "integer"
              }
            },
            "additionalProperties": true
          },
          "your_metrics": {
            "type": "object",
            "additionalProperties": true
          },
          "cross_customer": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "available",
                  "insufficient_cohort",
                  "no_cohort_data",
                  "disabled"
                ]
              },
              "cohort_scopes": {
                "type": "integer"
              },
              "cohort_decisions": {
                "type": "integer"
              },
              "threshold_met": {
                "type": "boolean"
              },
              "metrics": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": true
              },
              "percentiles": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": true
              }
            },
            "additionalProperties": true
          },
          "comparison": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "recommendation": {
            "type": "string",
            "enum": [
              "benchmark_unavailable",
              "within_cohort_range",
              "review_policy_outcomes",
              "tighten_approval_policy",
              "reduce_manual_review_pressure"
            ]
          },
          "benchmark_hash": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "PolicyEffectiveness": {
        "type": "object",
        "required": [
          "ok",
          "policy_effectiveness_version",
          "policy_id",
          "decisions_analyzed",
          "metrics",
          "effectiveness_hash",
          "recommendation"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "policy_effectiveness_version": {
            "type": "string",
            "const": "policy_effectiveness_v1"
          },
          "generated_at": {
            "type": "string"
          },
          "policy_id": {
            "type": "string"
          },
          "policy_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": "string",
            "const": "decision_outcomes"
          },
          "minimum_sample_size": {
            "type": "integer"
          },
          "decisions_analyzed": {
            "type": "integer"
          },
          "outcomes_analyzed": {
            "type": "integer"
          },
          "distinct_decisions": {
            "type": "integer"
          },
          "by_status": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "by_verdict": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "metrics": {
            "type": "object",
            "properties": {
              "success_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "failure_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "revert_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "review_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "skipped_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "unknown_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "terminal_coverage": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "executed_rate": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "additionalProperties": true
          },
          "proxy_quality": {
            "type": "object",
            "properties": {
              "estimated_false_positive_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "estimated_false_negative_rate": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "note": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "effectiveness_score": {
            "type": [
              "number",
              "null"
            ]
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "scored",
              "insufficient_data"
            ]
          },
          "recommendation": {
            "type": "string",
            "enum": [
              "insufficient_data",
              "review_policy",
              "monitor",
              "healthy"
            ]
          },
          "window": {
            "type": "object",
            "additionalProperties": true
          },
          "data_quality": {
            "type": "object",
            "additionalProperties": true
          },
          "effectiveness_hash": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "PolicyAnomalyReason": {
        "type": "object",
        "required": [
          "code",
          "message",
          "weight"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "weight": {
            "type": "number"
          },
          "observed": {
            "type": "object",
            "additionalProperties": true
          },
          "baseline": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "PolicyAnomaly": {
        "type": "object",
        "required": [
          "decision_id",
          "outcome_id",
          "anomaly_score",
          "severity",
          "reasons"
        ],
        "properties": {
          "decision_id": {
            "type": "string"
          },
          "outcome_id": {
            "type": "string"
          },
          "anomaly_score": {
            "type": "number"
          },
          "severity": {
            "type": "string",
            "enum": [
              "normal",
              "low",
              "medium",
              "high"
            ]
          },
          "reasons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PolicyAnomalyReason"
            }
          },
          "decision_verdict": {
            "type": "string"
          },
          "outcome_status": {
            "type": "string"
          },
          "action_executed": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "policy_id": {
            "type": "string"
          },
          "policy_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "target_system": {
            "type": [
              "string",
              "null"
            ]
          },
          "target_object_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "mutation": {
            "type": [
              "string",
              "null"
            ]
          },
          "reported_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "outcome_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "decision_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "verify_url": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": true
      },
      "PolicyAnomalyReport": {
        "type": "object",
        "required": [
          "ok",
          "decision_anomaly_report_version",
          "policy_id",
          "decisions_analyzed",
          "summary",
          "baseline",
          "anomalies",
          "anomaly_hash",
          "recommendation"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "decision_anomaly_report_version": {
            "type": "string",
            "const": "decision_anomaly_report_v1"
          },
          "generated_at": {
            "type": "string"
          },
          "policy_id": {
            "type": "string"
          },
          "policy_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": "string",
            "const": "decision_outcomes"
          },
          "minimum_sample_size": {
            "type": "integer"
          },
          "anomaly_threshold": {
            "type": "number"
          },
          "max_anomalies_returned": {
            "type": "integer"
          },
          "decisions_analyzed": {
            "type": "integer"
          },
          "outcomes_analyzed": {
            "type": "integer"
          },
          "distinct_decisions": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "scored",
              "insufficient_data"
            ]
          },
          "recommendation": {
            "type": "string",
            "enum": [
              "collect_more_outcomes",
              "review_high_anomalies",
              "monitor_anomalies",
              "stable"
            ]
          },
          "summary": {
            "type": "object",
            "properties": {
              "anomaly_count": {
                "type": "integer"
              },
              "returned_count": {
                "type": "integer"
              },
              "high_count": {
                "type": "integer"
              },
              "medium_count": {
                "type": "integer"
              },
              "low_count": {
                "type": "integer"
              },
              "max_score": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "additionalProperties": true
          },
          "baseline": {
            "type": "object",
            "additionalProperties": true
          },
          "anomalies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PolicyAnomaly"
            }
          },
          "window": {
            "type": "object",
            "additionalProperties": true
          },
          "data_quality": {
            "type": "object",
            "additionalProperties": true
          },
          "anomaly_hash": {
            "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
      },
      "DecisionChainLink": {
        "type": "object",
        "required": [
          "decision_chain_version",
          "chain_id",
          "chain_position",
          "leaf_hash",
          "merkle_root",
          "link_hash",
          "decision_id",
          "record_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"
            ]
          },
          "previous_merkle_root": {
            "type": [
              "string",
              "null"
            ]
          },
          "leaf_hash": {
            "type": "string"
          },
          "merkle_root": {
            "type": "string"
          },
          "merkle_strategy": {
            "type": "string",
            "const": "rolling_sha256_pair_v1"
          },
          "link_hash": {
            "type": "string"
          },
          "entry_type": {
            "type": "string"
          },
          "decision_id": {
            "type": "string"
          },
          "record_hash": {
            "type": "string"
          },
          "receipt_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "policy_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "policy_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "verify_url": {
            "type": "string"
          },
          "chain_url": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionChain": {
        "type": "object",
        "required": [
          "ok",
          "decision_chain_version",
          "chain_id",
          "chain_size",
          "merkle_root",
          "head",
          "retained_links",
          "verification"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "decision_chain_version": {
            "type": "string",
            "const": "decision_chain_v1"
          },
          "chain_id": {
            "type": "string"
          },
          "chain_size": {
            "type": "integer"
          },
          "merkle_strategy": {
            "type": "string",
            "const": "rolling_sha256_pair_v1"
          },
          "merkle_root": {
            "type": [
              "string",
              "null"
            ]
          },
          "head_link_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": "string"
          },
          "head": {
            "$ref": "#/components/schemas/DecisionChainLink"
          },
          "retained_links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DecisionChainLink"
            }
          },
          "verification": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "DecisionExecutionRequest": {
        "type": "object",
        "required": [
          "execution_status"
        ],
        "properties": {
          "decision_id": {
            "type": "string",
            "maxLength": 600
          },
          "execution_status": {
            "type": "string",
            "description": "Normalized to queued, executed, failed, skipped, reverted, blocked, reviewed, unknown, or a compact custom status."
          },
          "execution_result": {
            "type": "string"
          },
          "action_taken": {
            "type": "string"
          },
          "target_system": {
            "type": "string"
          },
          "target_object_id": {
            "type": "string"
          },
          "mutation": {
            "type": "string"
          },
          "execution_id": {
            "type": "string"
          },
          "external_ref": {
            "type": "string"
          },
          "executor": {
            "type": "object",
            "additionalProperties": true
          },
          "decision_record_hash": {
            "type": "string"
          },
          "decision_receipt_hash": {
            "type": "string"
          },
          "action_binding": {
            "$ref": "#/components/schemas/ActionBinding"
          },
          "action_binding_hash": {
            "type": "string"
          },
          "state_before_hash": {
            "type": "string"
          },
          "state_after_hash": {
            "type": "string"
          },
          "state_before_ref": {
            "type": "string"
          },
          "state_after_ref": {
            "type": "string"
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": [
                "object",
                "string"
              ],
              "additionalProperties": true
            }
          },
          "executed_at": {
            "type": "string"
          },
          "reported_at": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionExecution": {
        "type": "object",
        "required": [
          "decision_protocol_version",
          "decision_execution_version",
          "execution_receipt_id",
          "decision_id",
          "execution_status",
          "execution_hash",
          "reported_at"
        ],
        "properties": {
          "decision_protocol_version": {
            "type": "string",
            "const": "decision_protocol_v1"
          },
          "decision_execution_version": {
            "type": "string",
            "const": "decision_execution_v1"
          },
          "execution_receipt_id": {
            "type": "string"
          },
          "decision_id": {
            "type": "string"
          },
          "idempotency_key": {
            "type": "string"
          },
          "execution_status": {
            "type": "string"
          },
          "execution_result": {
            "type": "string"
          },
          "action_taken": {
            "type": "string"
          },
          "target_system": {
            "type": "string"
          },
          "target_object_id": {
            "type": "string"
          },
          "mutation": {
            "type": "string"
          },
          "external_ref": {
            "type": "string"
          },
          "execution_id": {
            "type": "string"
          },
          "executor": {
            "type": "object",
            "additionalProperties": true
          },
          "decision_record_hash": {
            "type": "string"
          },
          "decision_receipt_hash": {
            "type": "string"
          },
          "decision_verdict": {
            "type": "string"
          },
          "decision_action": {
            "type": "string"
          },
          "policy_id": {
            "type": "string"
          },
          "policy_version": {
            "type": "string"
          },
          "policy_bundle_hash": {
            "type": "string"
          },
          "action_binding": {
            "$ref": "#/components/schemas/ActionBinding"
          },
          "action_binding_hash": {
            "type": "string"
          },
          "action_binding_match": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "state_before_hash": {
            "type": "string"
          },
          "state_after_hash": {
            "type": "string"
          },
          "state_before_ref": {
            "type": "string"
          },
          "state_after_ref": {
            "type": "string"
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "execution_input_hash": {
            "type": "string"
          },
          "execution_hash": {
            "type": "string"
          },
          "integrity": {
            "type": "object",
            "additionalProperties": true
          },
          "executed_at": {
            "type": "string"
          },
          "reported_at": {
            "type": "string"
          },
          "decision_found": {
            "type": "boolean"
          },
          "decision_url": {
            "type": "string"
          },
          "verify_url": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "DecisionExecutionResult": {
        "type": "object",
        "required": [
          "ok",
          "decision_id",
          "execution"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "idempotency_status": {
            "type": "string"
          },
          "decision_id": {
            "type": "string"
          },
          "execution": {
            "$ref": "#/components/schemas/DecisionExecution"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
