{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Nova Per-Run Manifest",
  "description": "Per-run manifest written to metrics/runs/<run_id>.json (REQ-187). Captures the full run lifecycle.",
  "type": "object",
  "required": ["run_id", "contract_id", "environment", "started_at", "completed_at", "exit_code", "stages"],
  "properties": {
    "run_id": {"type": "string", "minLength": 1},
    "contract_id": {"type": "string"},
    "environment": {"type": "string", "enum": ["dev", "qa", "prod", "dr"]},
    "started_at": {"type": "string", "format": "date-time"},
    "completed_at": {"type": "string", "format": "date-time"},
    "exit_code": {"type": "integer"},
    "stages": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "duration_ms", "exit_code"],
        "properties": {
          "name": {"type": "string"},
          "duration_ms": {"type": "number"},
          "exit_code": {"type": "integer"},
          "error": {"type": "string"}
        }
      }
    },
    "confidence": {
      "type": "object",
      "properties": {
        "score": {"type": "number"},
        "band": {"type": "string", "enum": ["pass", "warn", "block"]},
        "perInput": {"type": "object"}
      }
    },
    "hitl": {
      "type": "object",
      "properties": {
        "gate": {"type": "string"},
        "result": {"type": "string"},
        "block": {"type": "boolean"}
      }
    },
    "policy": {
      "type": "object",
      "properties": {
        "passed": {"type": "integer"},
        "failed": {"type": "integer"},
        "skipped": {"type": "integer"}
      }
    },
    "cost_estimate_usd": {"type": "number"},
    "decision_id": {"type": "string"},
    "outcome": {"type": "string", "enum": ["succeeded", "failed", "pending"]}
  },
  "additionalProperties": true
}