{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/algenta-ai/json-schema/algenta-ai-execution-plan-response-schema.json",
  "title": "ExecutionPlanResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/algenta-ai-decision-workflow-api-openapi.yml#/components/schemas/ExecutionPlanResponse",
  "properties": {
    "plan_id": {
      "type": "string",
      "format": "uuid",
      "title": "Plan Id"
    },
    "case_id": {
      "type": "string",
      "format": "uuid",
      "title": "Case Id"
    },
    "run_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Run Id"
    },
    "lifecycle_state": {
      "type": "string",
      "title": "Lifecycle State"
    },
    "plan_hash": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Plan Hash"
    },
    "nonce": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Nonce",
      "description": "Single-use approval challenge (present only at propose time)"
    },
    "actions": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Actions"
    },
    "receipt": {
      "anyOf": [
        {
          "$ref": "#/$defs/ExecutionReceipt"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "type": "object",
  "required": [
    "plan_id",
    "case_id",
    "run_id",
    "lifecycle_state",
    "plan_hash",
    "actions"
  ],
  "$defs": {
    "ExecutionReceipt": {
      "properties": {
        "receipt_version": {
          "type": "string",
          "title": "Receipt Version",
          "description": "Receipt schema version. Bumped only on a breaking change.",
          "default": "1"
        },
        "status": {
          "type": "string",
          "enum": [
            "executed",
            "denied",
            "approval_required",
            "failed"
          ],
          "title": "Status",
          "description": "Terminal state of the governed operation this receipt describes."
        },
        "code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Code",
          "description": "Machine-readable reason when status is not 'executed' -- the same DecisionServiceError code the HTTP layer maps (e.g. plan_hash_mismatch, invalid_nonce, approval_expired)."
        },
        "retryable": {
          "type": "boolean",
          "title": "Retryable",
          "description": "Whether re-issuing the identical request could succeed. A policy denial is NOT retryable; an upstream timeout is. Stated explicitly so a caller does not have to infer intent from an HTTP status.",
          "default": false
        },
        "request_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Request Id",
          "description": "Identifies the single HTTP call that produced this receipt."
        },
        "trace_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Trace Id",
          "description": "W3C trace-id of the wider operation. One agent turn may produce several receipts; this is what lets them be reassembled afterwards."
        },
        "idempotency_key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Idempotency Key",
          "description": "The Idempotency-Key the caller supplied, echoed so a retry can be matched to its original outcome. None when the caller sent none."
        },
        "execution_id": {
          "type": "string",
          "format": "uuid",
          "title": "Execution Id",
          "description": "Unique id for this execution attempt, minted at execute time and persisted with the receipt. Distinct from plan_id: the plan is what was authorised, this is the act."
        },
        "plan_hash": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Plan Hash",
          "description": "Hash of the approved plan. An approval is bound to this exact value."
        },
        "approval_state": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "approved",
                "not_required",
                "pending",
                "rejected",
                "expired"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Approval State",
          "description": "Approval status at the moment of execution."
        },
        "policy_snapshot_hash": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Policy Snapshot Hash",
          "description": "Content hash of the policy snapshot in force. None on the decision-plan path, which carries no policy snapshot -- deliberately null rather than filled with a value that is not a policy hash."
        },
        "executed_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Executed At",
          "description": "When execution completed."
        },
        "result": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Result",
          "description": "Operation-specific result. Everything above is stable across operations."
        }
      },
      "type": "object",
      "required": [
        "status",
        "execution_id"
      ],
      "title": "ExecutionReceipt",
      "description": "Evidence that one approved plan executed exactly once, and under what authority."
    }
  }
}