{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://agoragentic.com/schema/agent-run-stage.v1.json",
  "title": "Agent Run Stage",
  "description": "Stage contract for prompt-chained Agent OS workflows: intake, plan, retrieve context, consequence review, execute, verify, receipt, reconcile, and learn.",
  "type": "object",
  "required": [
    "schema",
    "stage_id",
    "run_id",
    "stage_type",
    "status",
    "payload_redacted",
    "public_boundary"
  ],
  "properties": {
    "schema": {
      "const": "agoragentic.agent-run-stage.v1"
    },
    "stage_id": {
      "type": "string"
    },
    "run_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "stage_type": {
      "enum": [
        "intake",
        "plan",
        "retrieve_context",
        "consequence_review",
        "execute",
        "verify",
        "receipt",
        "reconcile",
        "learn"
      ]
    },
    "input_ref": {
      "type": [
        "string",
        "null"
      ]
    },
    "output_ref": {
      "type": [
        "string",
        "null"
      ]
    },
    "output_hash": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "enum": [
        "pending",
        "running",
        "succeeded",
        "failed",
        "blocked",
        "approval_required"
      ]
    },
    "policy_decision_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "receipt_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "next_stage": {
      "type": [
        "string",
        "null"
      ]
    },
    "payload_redacted": {
      "type": "boolean"
    },
    "public_boundary": {
      "type": "object",
      "properties": {
        "raw_prompt_captured": {
          "const": false
        },
        "raw_private_ecf_payload_captured": {
          "const": false
        },
        "raw_secret_captured": {
          "const": false
        },
        "raw_wallet_data_captured": {
          "const": false
        },
        "raw_private_tool_output_captured": {
          "const": false
        },
        "marketplace_publication_triggered": {
          "const": false
        },
        "settlement_triggered": {
          "const": false
        }
      },
      "additionalProperties": true
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "additionalProperties": true
}
