{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "openmontage/checkpoints/checkpoint",
  "title": "Pipeline Checkpoint",
  "description": "Full resumable snapshot after each pipeline stage.",
  "type": "object",
  "required": ["version", "project_id", "pipeline_type", "stage", "status", "timestamp", "artifacts"],
  "properties": {
    "version": { "type": "string", "const": "1.0" },
    "project_id": { "type": "string" },
    "stage": {
      "type": "string",
      "description": "Stage name — validated at runtime against the pipeline manifest's stage list"
    },
    "status": {
      "type": "string",
      "enum": ["completed", "failed", "awaiting_human", "in_progress"]
    },
    "timestamp": { "type": "string", "format": "date-time" },
    "pipeline_type": { "type": "string", "description": "Pipeline manifest name" },
    "style_playbook": { "type": "string" },
    "checkpoint_policy": { "type": "string", "enum": ["guided", "manual_all", "auto_noncreative"] },
    "human_approval_required": { "type": "boolean" },
    "human_approved": { "type": "boolean" },
    "artifacts": {
      "type": "object",
      "description": "Map of artifact name to artifact data or file path",
      "additionalProperties": true
    },
    "review": {
      "type": "object",
      "description": "Reviewer output for this stage, if any"
    },
    "cost_snapshot": {
      "type": "object",
      "properties": {
        "total_spent_usd": { "type": "number" },
        "total_reserved_usd": { "type": "number" },
        "budget_remaining_usd": { "type": "number" }
      }
    },
    "error": { "type": "string" },
    "metadata": { "type": "object" }
  },
  "additionalProperties": false
}
