{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ExperimentResult",
  "description": "A complete experiment result.",
  "type": "object",
  "properties": {
    "environment": {
      "description": "Where it ran.",
      "$ref": "#/$defs/Environment"
    },
    "evidence": {
      "description": "Raw evidence. Never empty.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/Evidence"
      },
      "minItems": 1
    },
    "expected": {
      "description": "What we expected to observe.",
      "type": "string"
    },
    "experiment": {
      "description": "Experiment id, for example `BL-001`.",
      "type": "string",
      "pattern": "^BL-[0-9]{3}$"
    },
    "limitations": {
      "description": "What this result does not show.",
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    },
    "methodology": {
      "description": "How the experiment was done, in enough detail to repeat it.",
      "type": "string"
    },
    "observed": {
      "description": "What we observed.",
      "type": "string"
    },
    "run_at": {
      "description": "RFC 3339 timestamp of the run.",
      "type": "string"
    },
    "run_id": {
      "description": "Unique run id, for example `BL-001-2026-12-06-a`.",
      "type": "string",
      "pattern": "^BL-[0-9]{3}-[0-9A-Za-z.-]+$"
    },
    "schema_version": {
      "description": "Schema version this document conforms to.",
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$"
    },
    "source_revisions": {
      "description": "Implementations under test, pinned by revision. Never empty.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/SourceRevision"
      },
      "minItems": 1
    },
    "status": {
      "description": "Outcome.",
      "$ref": "#/$defs/Status"
    },
    "supersedes": {
      "description": "Run ids of earlier results this one follows up or corrects.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "synthetic_data_only": {
      "description": "Must be true: laboratory data is always synthetic.",
      "type": "boolean"
    },
    "title": {
      "description": "Short title.",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "required": [
    "schema_version",
    "experiment",
    "run_id",
    "title",
    "run_at",
    "status",
    "source_revisions",
    "environment",
    "methodology",
    "expected",
    "observed",
    "evidence",
    "limitations",
    "synthetic_data_only"
  ],
  "$defs": {
    "Environment": {
      "description": "Where an experiment ran.",
      "type": "object",
      "properties": {
        "arch": {
          "description": "CPU architecture, for example `x86_64`.",
          "type": "string"
        },
        "browser": {
          "description": "Browser name and version, when a browser was part of the experiment.",
          "type": ["string", "null"]
        },
        "notes": {
          "description": "Free-form notes about the environment.",
          "type": ["string", "null"]
        },
        "os": {
          "description": "Operating system, for example `ubuntu-24.04`.",
          "type": "string"
        },
        "toolchain": {
          "description": "Toolchain, for example `rustc 1.100.0`.",
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": ["os", "arch", "toolchain"]
    },
    "Evidence": {
      "description": "A piece of raw evidence backing the observation.",
      "type": "object",
      "properties": {
        "description": {
          "description": "What this evidence shows.",
          "type": "string"
        },
        "kind": {
          "description": "Kind of evidence: `log`, `ci-run`, `artifact`, `screenshot`, `issue`.",
          "type": "string"
        },
        "location": {
          "description": "Link or repository-relative path.",
          "type": "string"
        },
        "sha256": {
          "description": "Lowercase hex SHA-256 of the artifact, when it is a file.",
          "type": ["string", "null"],
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "additionalProperties": false,
      "required": ["kind", "location", "description"]
    },
    "SourceRevision": {
      "description": "One implementation under test, pinned by git revision.",
      "type": "object",
      "properties": {
        "description": {
          "description": "Human description of what this revision is (branch, PR, tag).",
          "type": "string"
        },
        "repository": {
          "description": "Repository, as `owner/name`.",
          "type": "string",
          "pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"
        },
        "revision": {
          "description": "Full 40-hex git commit revision.",
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        }
      },
      "additionalProperties": false,
      "required": ["repository", "revision", "description"]
    },
    "Status": {
      "description": "Outcome of an experiment.",
      "oneOf": [
        {
          "description": "The observed outcome matched the expectation.",
          "type": "string",
          "const": "positive"
        },
        {
          "description": "The observed outcome contradicted the expectation, or the system failed.",
          "type": "string",
          "const": "negative"
        },
        {
          "description": "The experiment could not decide the question.",
          "type": "string",
          "const": "inconclusive"
        }
      ]
    }
  }
}
