{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/test-gen-discovery.schema.json",
  "title": "Multi-Agent Pipeline  -  test-gen discovery",
  "description": "What the repository already has for testing the selected inventory items, $RUN/discovery.json of /multi-agent:test-gen (multi-agent-refs/test-gen/stages.md). Returned by the read-only test-gen-analyst persona and written by the orchestrator. testRoots[].command is what the write stage's run command is checked against (test-gen-gate.mjs written --discovery). Existing tests are joined to items by the identifier the test uses, never by a name. test-gen-gate.mjs check --stage discovery checks this shape without a dependency.",
  "type": "object",
  "additionalProperties": false,
  "required": ["stage", "testRoots", "existing", "handles"],
  "$defs": {
    "fileLine": { "type": "string", "pattern": "^[^\\s:]+:[1-9][0-9]*$" }
  },
  "properties": {
    "stage": { "const": "discovery" },
    "testRoots": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "runner", "command"],
        "properties": {
          "path": { "type": "string", "minLength": 1 },
          "runner": {
            "enum": [
              "xcuitest",
              "xctest",
              "swift-testing",
              "espresso",
              "compose",
              "junit",
              "playwright",
              "cypress",
              "jest",
              "vitest",
              "pytest",
              "other"
            ]
          },
          "command": { "type": "string", "minLength": 1 },
          "report": { "enum": ["junit", "xcresult", "none"] }
        }
      }
    },
    "existing": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["inventoryId", "tests"],
        "properties": {
          "inventoryId": { "type": "string", "minLength": 1 },
          "tests": { "type": "array", "items": { "$ref": "#/$defs/fileLine" } },
          "joinedBy": { "type": "string", "minLength": 1 }
        }
      }
    },
    "handles": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["inventoryId", "file", "line", "handle"],
        "properties": {
          "inventoryId": { "type": "string", "minLength": 1 },
          "file": { "type": "string", "minLength": 1 },
          "line": { "type": "integer", "minimum": 1 },
          "handle": { "type": "string", "minLength": 1 }
        }
      }
    },
    "conventions": { "type": "array", "items": { "type": "string", "minLength": 1 } },
    "notes": { "type": "array", "items": { "type": "string" } }
  }
}
