{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/explore-run.schema.json",
  "version": "1.0.0",
  "title": "Multi-Agent Pipeline  -  exploratory test run",
  "description": "One exploratory session of /multi-agent:test or one /multi-agent:bug-bash charter, written as the run goes so explore-findings.mjs can decide when it must stop (check) and what its verdict is (report). Findings are claims with evidence; a bug bash proves them with a reproducing test before reporting them.",
  "type": "object",
  "required": ["goal", "budget", "steps", "findings"],
  "properties": {
    "goal": { "type": "string", "minLength": 1 },
    "platform": { "enum": ["ios", "android", "web"] },
    "persona": { "type": "string" },
    "budget": {
      "type": "object",
      "description": "Per-run budget; explore-findings.mjs fills defaults (8 steps, 10 minutes, 150000 tokens) and clamps to steps 1-12, minutes 3-15, tokens 20000-400000.",
      "properties": {
        "steps": { "type": "integer", "minimum": 1 },
        "minutes": { "type": "number", "minimum": 0 },
        "tokens": { "type": "integer", "minimum": 0 }
      }
    },
    "usage": {
      "type": "object",
      "properties": {
        "steps": { "type": "integer", "minimum": 0 },
        "minutes": { "type": "number", "minimum": 0 },
        "tokens": { "type": "integer", "minimum": 0 }
      }
    },
    "ended": { "enum": ["finished", "step-limit", "time", "tokens", "stuck", "aborted"] },
    "steps": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["index", "status"],
        "properties": {
          "index": { "type": "integer", "minimum": 1 },
          "title": { "type": "string" },
          "status": { "enum": ["passed", "failed", "blocked", "exhausted"] },
          "code": {
            "type": "string",
            "description": "The toolkit's verdict or locator code when the step did not pass: ASSERTION_FAILED and ASSERTION_INCONCLUSIVE are product failures; CREDENTIAL_MISSING, ENVIRONMENT_UNAVAILABLE and SEED_DATA_MISSING block by cause; LOCATOR_NOT_FOUND, LOCATOR_AMBIGUOUS and REPLAY_DIVERGED block as automation; BUDGET_EXCEEDED is exhausted."
          },
          "detail": { "type": "string" },
          "trace": {
            "type": "string",
            "description": "Path of the toolkit's failure trace.md, when it wrote one."
          }
        }
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["kind", "severity", "title", "expected", "observed", "repro", "evidence"],
        "properties": {
          "id": { "type": "string" },
          "step": { "type": "integer", "minimum": 1 },
          "kind": {
            "enum": ["issue", "warning"],
            "description": "issue: a functional defect, fails the run. warning: cosmetic, does not."
          },
          "severity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "description": "1 trivial, 2 low, 3 medium, 4 high, 5 critical."
          },
          "title": { "type": "string", "minLength": 1 },
          "screen": { "type": "string" },
          "expected": { "type": "string", "minLength": 1 },
          "observed": { "type": "string", "minLength": 1 },
          "repro": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 }
          },
          "evidence": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": ["kind", "path"],
              "properties": {
                "kind": { "enum": ["screenshot", "ui-tree", "video", "trace", "log", "text"] },
                "path": { "type": "string", "minLength": 1 }
              }
            }
          },
          "spec": {
            "type": "string",
            "description": "The acceptance criterion the expectation comes from, quoted, or 'no spec, model expectation'."
          },
          "judge": {
            "type": "object",
            "description": "Present when a visual or semantic assertion decided the finding: the fresh judge's checked verdict.",
            "properties": {
              "verdict": { "enum": ["passed", "failed"] },
              "code": { "type": ["string", "null"] },
              "reason": { "type": "string" }
            }
          }
        }
      }
    }
  }
}
