{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://shomra.ai/spec/agentprobe-report-1.schema.json",
  "title": "AgentProbe Report v1",
  "description": "An open report format for agent-security benchmark results. Structure only — the SEMANTIC rules (a score must re-derive from its own scenarios, NOT_FIRED is never HELD, an incomplete run carries no score) are in docs/AGENTPROBE-SPEC.md and are enforced by cli/agentprobe-verify.mjs, because JSON Schema cannot express them.",
  "type": "object",
  "required": ["format", "producer", "startedAt", "status", "corpus", "defender", "basis", "resilience", "totals", "scenarios"],
  "additionalProperties": true,
  "properties": {
    "format": {
      "const": "agentprobe/1",
      "description": "Version marker. A breaking change bumps this, so incompatibility is visible in the artifact rather than inferred from a date."
    },
    "producer": {
      "type": "object",
      "required": ["name"],
      "additionalProperties": true,
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "version": { "type": "string" }
      }
    },
    "startedAt": { "type": "string", "format": "date-time" },
    "finishedAt": { "type": ["string", "null"], "format": "date-time" },
    "status": {
      "enum": ["complete", "partial", "cancelled", "errored"],
      "description": "Only `complete` may carry a non-null resilience (spec R2)."
    },
    "corpus": {
      "type": "object",
      "required": ["name", "corpusHash", "public"],
      "additionalProperties": true,
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "version": { "type": "string" },
        "corpusHash": {
          "type": "string",
          "minLength": 1,
          "description": "Stable hash of the scenario set. Two runs are comparable only if this matches (spec §4)."
        },
        "public": {
          "type": "boolean",
          "description": "Are the payloads published? `false` results are checkable but NOT reproducible, and must not be described as reproducible (spec §9)."
        }
      }
    },
    "defender": {
      "type": "object",
      "required": ["description", "defenderHash"],
      "additionalProperties": true,
      "properties": {
        "description": { "type": "string", "minLength": 1 },
        "defenderHash": { "type": "string", "minLength": 1 }
      }
    },
    "basis": {
      "enum": ["complete", "floor"],
      "description": "`floor` when any scenario was NOT_FIRED — the true resilience could be lower (spec R3)."
    },
    "resilience": {
      "type": ["integer", "null"],
      "minimum": 0,
      "maximum": 100,
      "description": "held / (held + breached) × 100. MUST be null when nothing was fired or the run did not complete — never 0, never 100 (spec R1, R2)."
    },
    "totals": {
      "type": "object",
      "required": ["held", "breached", "notFired", "errored"],
      "additionalProperties": false,
      "properties": {
        "held": { "type": "integer", "minimum": 0 },
        "breached": { "type": "integer", "minimum": 0 },
        "notFired": { "type": "integer", "minimum": 0 },
        "errored": { "type": "integer", "minimum": 0 }
      }
    },
    "scenarios": {
      "type": "array",
      "minItems": 1,
      "description": "MUST include NOT_FIRED entries. A report that omits what it did not test reads as complete while covering only the part that ran (spec O1).",
      "items": {
        "type": "object",
        "required": ["key", "family", "outcome"],
        "additionalProperties": true,
        "properties": {
          "key": { "type": "string", "minLength": 1 },
          "family": { "type": "string", "minLength": 1 },
          "severity": { "enum": ["LOW", "MEDIUM", "HIGH", "CRITICAL"] },
          "outcome": { "enum": ["HELD", "BREACHED", "NOT_FIRED", "ERRORED"] },
          "probes": { "type": "integer", "minimum": 0 },
          "observed": {
            "type": "string",
            "description": "What was SEEN, not a verdict. Should be present on every BREACHED scenario."
          },
          "mappings": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "owaspLlm": { "type": "array", "items": { "type": "string" } },
              "owaspAgentic": { "type": "array", "items": { "type": "string" } },
              "atlas": { "type": "array", "items": { "type": "string" } }
            }
          }
        }
      }
    },
    "signature": {
      "type": "object",
      "description": "Conformance level L3. Detached Ed25519 signature over the canonical report with this field removed.",
      "required": ["alg", "publicKey", "value"],
      "additionalProperties": false,
      "properties": {
        "alg": { "const": "ed25519" },
        "publicKey": { "type": "string" },
        "value": { "type": "string" }
      }
    }
  }
}
