{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/axonflow/json-schema/axonflow-execution-schema.json",
  "title": "Execution",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/axonflow-decision-execution-replay-api-openapi.yml#/components/schemas/Execution",
  "type": "object",
  "properties": {
    "summary": {
      "$ref": "#/$defs/ExecutionSummary"
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ExecutionSnapshot"
      }
    }
  },
  "$defs": {
    "ExecutionSnapshot": {
      "type": "object",
      "properties": {
        "request_id": {
          "type": "string"
        },
        "step_index": {
          "type": "integer"
        },
        "step_name": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "running",
            "completed",
            "failed",
            "paused"
          ]
        },
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "completed_at": {
          "type": "string",
          "format": "date-time"
        },
        "duration_ms": {
          "type": "integer"
        },
        "input": {
          "type": "object"
        },
        "output": {
          "type": "object"
        },
        "provider": {
          "type": "string"
        },
        "model": {
          "type": "string"
        },
        "tokens_in": {
          "type": "integer"
        },
        "tokens_out": {
          "type": "integer"
        },
        "cost_usd": {
          "type": "number",
          "format": "double"
        },
        "policies_checked": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "policies_triggered": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PolicyEvent"
          }
        },
        "error_message": {
          "type": "string"
        },
        "retry_count": {
          "type": "integer"
        },
        "approval_required": {
          "type": "boolean",
          "description": "True when this step gated on human approval. The pair\n`approved_at` + `approved_by` records when and by whom\nthe approval was granted (or shows null on rejection).\n"
        },
        "approved_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the approval-required gate was resolved. Pair with\n`approved_by` to compute approval latency at the step level.\n"
        },
        "approved_by": {
          "type": "string",
          "description": "User email of the approver. Empty when\n`approval_required` is false or the gate was auto-resolved.\n"
        }
      }
    },
    "ExecutionSummary": {
      "type": "object",
      "properties": {
        "request_id": {
          "type": "string"
        },
        "workflow_name": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "running",
            "completed",
            "failed"
          ]
        },
        "total_steps": {
          "type": "integer"
        },
        "completed_steps": {
          "type": "integer"
        },
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "completed_at": {
          "type": "string",
          "format": "date-time"
        },
        "duration_ms": {
          "type": "integer"
        },
        "total_tokens": {
          "type": "integer"
        },
        "total_cost_usd": {
          "type": "number",
          "format": "double"
        },
        "org_id": {
          "type": "string"
        },
        "tenant_id": {
          "type": "string"
        },
        "user_id": {
          "type": "string"
        },
        "error_message": {
          "type": "string"
        },
        "input_summary": {
          "type": "string",
          "description": "Truncated, redacted summary of the workflow input — safe\nto display in audit listings without leaking PII or\nsecrets. Full input is in the per-step ExecutionSnapshot\nrecords.\n"
        },
        "output_summary": {
          "type": "string",
          "description": "Truncated, redacted summary of the workflow's final\noutput. Same redaction posture as `input_summary`.\n"
        }
      }
    },
    "PolicyEvent": {
      "type": "object",
      "properties": {
        "policy_id": {
          "type": "string"
        },
        "policy_name": {
          "type": "string"
        },
        "action": {
          "type": "string",
          "enum": [
            "block",
            "warn",
            "require_approval"
          ]
        },
        "matched": {
          "type": "string"
        },
        "resolution": {
          "type": "string"
        }
      }
    }
  }
}