{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://civitas-cerebrum.github.io/element-interactions/schemas/subagent-returns/probe.schema.json",
  "title": "Probe (bug-discovery) return",
  "type": "object",
  "additionalProperties": true,
  "required": ["handover"],
  "properties": {
    "handover": {
      "allOf": [
        { "$ref": "handover.schema.json" },
        {
          "type": "object",
          "properties": {
            "status": {
              "enum": ["clean", "findings-emitted", "blocked"]
            }
          }
        }
      ]
    },
    "journey": { "type": "string", "pattern": "^j-[a-z0-9-]+$" },
    "findings-emitted": { "type": "integer", "minimum": 0 },
    "finding-ids": {
      "type": "array",
      "items": { "type": "string" },
      "minItems": 1,
      "$comment": "Ledger anchor IDs for the findings appended this dispatch (e.g. j-acme-4-01). Array length should equal the findings-emitted count.",
      "description": "Ledger anchor IDs of the emitted findings; length should equal findings-emitted."
    },
    "tests-added": { "type": "integer", "minimum": 0 },
    "summary": { "type": "string" },
    "spill": { "type": "string" },
    "blocked-reason": { "type": "string" }
  },
  "allOf": [
    {
      "if": {
        "type": "object",
        "properties": { "handover": { "type": "object", "required": ["status"], "properties": { "status": { "const": "findings-emitted" } } } }
      },
      "then": {
        "type": "object",
        "required": ["findings-emitted", "finding-ids"],
        "properties": {
          "findings-emitted": { "type": "integer", "minimum": 1 },
          "finding-ids": { "type": "array", "minItems": 1 }
        }
      }
    },
    {
      "if": {
        "type": "object",
        "properties": { "handover": { "type": "object", "required": ["status"], "properties": { "status": { "const": "blocked" } } } }
      },
      "then": {
        "type": "object",
        "required": ["blocked-reason"],
        "properties": { "blocked-reason": { "type": "string" } }
      }
    }
  ]
}
