{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oshun.example/schemas/eve-engineering-benchmark.v1.json",
  "title": "Eve engineering benchmark documents",
  "oneOf": [
    { "$ref": "#/$defs/candidateCatalog" },
    { "$ref": "#/$defs/evaluatorAcceptance" },
    { "$ref": "#/$defs/releaseManifest" }
  ],
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "gitCommit": {
      "type": "string",
      "pattern": "^[0-9a-f]{40}$"
    },
    "caseId": {
      "type": "string",
      "pattern": "^eng-v1-[0-9]{3}$"
    },
    "taskClass": {
      "enum": [
        "diagnosis-only",
        "bug-fix",
        "feature",
        "refactor",
        "migration-contract",
        "security-repair",
        "docs-product-graph",
        "ui-playwright",
        "service-integration",
        "dcc-native"
      ]
    },
    "dataGovernance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sourceRights",
        "containsPersonalData",
        "containsCredentialValues",
        "containsRawConversations",
        "redaction",
        "retention"
      ],
      "properties": {
        "sourceRights": { "const": "repository-owned-development-work" },
        "containsPersonalData": { "const": false },
        "containsCredentialValues": { "const": false },
        "containsRawConversations": { "const": false },
        "redaction": {
          "type": "string",
          "minLength": 20
        },
        "retention": { "const": "versioned-internal-benchmark" }
      }
    },
    "publicCase": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "taskClass",
        "variant",
        "split",
        "sourceSnapshot",
        "taskBrief",
        "constraints",
        "expectedDeliverable",
        "riskTier",
        "taskSize",
        "runtimeRequirements",
        "dataGovernance"
      ],
      "properties": {
        "id": { "$ref": "#/$defs/caseId" },
        "taskClass": { "$ref": "#/$defs/taskClass" },
        "variant": {
          "enum": ["repository", "browser", "service", "dcc", "native-desktop"]
        },
        "split": { "const": "held-out" },
        "sourceSnapshot": { "$ref": "#/$defs/gitCommit" },
        "taskBrief": { "type": "string", "minLength": 80 },
        "constraints": {
          "type": "array",
          "minItems": 2,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 10 }
        },
        "expectedDeliverable": { "type": "string", "minLength": 20 },
        "riskTier": { "enum": ["low", "medium", "high"] },
        "taskSize": { "enum": ["small", "medium", "large"] },
        "runtimeRequirements": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "repository",
              "node",
              "python",
              "postgresql",
              "browser",
              "service",
              "blender",
              "native-desktop",
              "accessibility-api"
            ]
          }
        },
        "dataGovernance": { "$ref": "#/$defs/dataGovernance" }
      }
    },
    "candidateCatalog": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "documentType",
        "benchmarkVersion",
        "frozenAt",
        "visibility",
        "split",
        "contextPolicy",
        "cases"
      ],
      "properties": {
        "schemaVersion": { "const": "eve-engineering-benchmark.v1" },
        "documentType": { "const": "candidate-catalog" },
        "benchmarkVersion": { "const": "1.0.0" },
        "frozenAt": { "type": "string", "format": "date-time" },
        "visibility": { "const": "candidate-readable" },
        "split": { "const": "held-out" },
        "contextPolicy": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "materialization",
            "repositoryHistory",
            "network",
            "caseExposure",
            "candidateIncludes",
            "candidateExcludes",
            "onViolation"
          ],
          "properties": {
            "materialization": { "const": "git-archive" },
            "repositoryHistory": { "const": "base-snapshot-without-git-directory" },
            "network": { "const": "deny" },
            "caseExposure": { "const": "one-selected-case" },
            "candidateIncludes": {
              "type": "array",
              "const": ["case-metadata", "task-brief", "constraints", "base-workspace-tree"]
            },
            "candidateExcludes": {
              "type": "array",
              "const": [
                "oracle-commit",
                "acceptance-criteria",
                "verification-commands",
                "source-provenance",
                "evaluator-canaries",
                "current-or-future-git-history",
                "other-case-prompts"
              ]
            },
            "onViolation": { "const": "refuse-and-discard-run" }
          }
        },
        "cases": {
          "type": "array",
          "minItems": 11,
          "items": { "$ref": "#/$defs/publicCase" }
        }
      }
    },
    "sourceEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "sha256AtOracle"],
      "properties": {
        "path": { "type": "string", "minLength": 3 },
        "sha256AtOracle": { "$ref": "#/$defs/sha256" }
      }
    },
    "acceptanceCriterion": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "statement", "evidencePaths", "proofKinds"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "statement": { "type": "string", "minLength": 30 },
        "evidencePaths": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 3 }
        },
        "proofKinds": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "source",
              "unit",
              "integration",
              "contract",
              "e2e",
              "live-runtime",
              "governance"
            ]
          }
        }
      }
    },
    "verificationCommand": {
      "type": "object",
      "additionalProperties": false,
      "required": ["executable", "arguments", "boundary"],
      "properties": {
        "executable": { "type": "string", "minLength": 1 },
        "arguments": {
          "type": "array",
          "items": { "type": "string" }
        },
        "boundary": {
          "enum": ["static", "unit", "integration", "browser", "dcc", "native-desktop"]
        }
      }
    },
    "acceptanceCase": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "oracleCommit",
        "sourceSummary",
        "closedAt",
        "baseTree",
        "oracleTree",
        "changedPathCount",
        "changeSetSha256",
        "closureEvidence",
        "sourceEvidence",
        "acceptanceCriteria",
        "verificationCommands",
        "leakCanary"
      ],
      "properties": {
        "id": { "$ref": "#/$defs/caseId" },
        "oracleCommit": { "$ref": "#/$defs/gitCommit" },
        "sourceSummary": { "type": "string", "minLength": 10 },
        "closedAt": { "type": "string", "format": "date-time" },
        "baseTree": { "$ref": "#/$defs/gitCommit" },
        "oracleTree": { "$ref": "#/$defs/gitCommit" },
        "changedPathCount": { "type": "integer", "minimum": 1 },
        "changeSetSha256": { "$ref": "#/$defs/sha256" },
        "closureEvidence": {
          "type": "object",
          "additionalProperties": false,
          "required": ["basis", "ref"],
          "properties": {
            "basis": { "const": "first-parent-commit-reachable-from-origin-main" },
            "ref": { "const": "refs/remotes/origin/main" }
          }
        },
        "sourceEvidence": {
          "type": "array",
          "minItems": 2,
          "items": { "$ref": "#/$defs/sourceEvidence" }
        },
        "acceptanceCriteria": {
          "type": "array",
          "minItems": 2,
          "items": { "$ref": "#/$defs/acceptanceCriterion" }
        },
        "verificationCommands": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/verificationCommand" }
        },
        "leakCanary": {
          "type": "string",
          "pattern": "^EVE-HIDDEN-V1-[A-Z0-9-]{12,}$"
        }
      }
    },
    "evaluatorAcceptance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "documentType",
        "benchmarkVersion",
        "visibility",
        "candidateReadable",
        "handling",
        "cases"
      ],
      "properties": {
        "schemaVersion": { "const": "eve-engineering-benchmark.v1" },
        "documentType": { "const": "evaluator-acceptance" },
        "benchmarkVersion": { "const": "1.0.0" },
        "visibility": { "const": "evaluator-only" },
        "candidateReadable": { "const": false },
        "handling": {
          "type": "object",
          "additionalProperties": false,
          "required": ["owner", "candidateMount", "logPolicy", "rotationTrigger"],
          "properties": {
            "owner": { "const": "QA benchmark steward" },
            "candidateMount": { "const": "never" },
            "logPolicy": { "const": "criterion-ids-and-verdicts-only" },
            "rotationTrigger": {
              "const": "retire-and-replace-before-reuse-after-any-answer-aware-tuning"
            }
          }
        },
        "cases": {
          "type": "array",
          "minItems": 11,
          "items": { "$ref": "#/$defs/acceptanceCase" }
        }
      }
    },
    "releaseManifest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "documentType",
        "benchmarkVersion",
        "status",
        "frozenAt",
        "caseCount",
        "taskClasses",
        "variantCounts",
        "documents",
        "benchmarkSha256",
        "securityBoundary",
        "governance",
        "limitations"
      ],
      "properties": {
        "schemaVersion": { "const": "eve-engineering-benchmark.v1" },
        "documentType": { "const": "release-manifest" },
        "benchmarkVersion": { "const": "1.0.0" },
        "status": { "const": "frozen" },
        "frozenAt": { "type": "string", "format": "date-time" },
        "caseCount": { "type": "integer", "minimum": 11 },
        "taskClasses": {
          "type": "array",
          "minItems": 10,
          "maxItems": 10,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/taskClass" }
        },
        "variantCounts": {
          "type": "object",
          "additionalProperties": false,
          "required": ["repository", "browser", "service", "dcc", "native-desktop"],
          "properties": {
            "repository": { "type": "integer", "minimum": 1 },
            "browser": { "type": "integer", "minimum": 1 },
            "service": { "type": "integer", "minimum": 1 },
            "dcc": { "type": "integer", "minimum": 1 },
            "native-desktop": { "type": "integer", "minimum": 1 }
          }
        },
        "documents": {
          "type": "object",
          "additionalProperties": false,
          "required": ["candidateCatalog", "evaluatorAcceptance"],
          "properties": {
            "candidateCatalog": { "$ref": "#/$defs/documentDigest" },
            "evaluatorAcceptance": { "$ref": "#/$defs/documentDigest" }
          }
        },
        "benchmarkSha256": { "$ref": "#/$defs/sha256" },
        "securityBoundary": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "candidateExporter",
            "candidateSource",
            "workspace",
            "network",
            "acceptanceMount",
            "onLeak"
          ],
          "properties": {
            "candidateExporter": {
              "const": "tools/eve-everywhere/export-engineering-benchmark-context.mjs"
            },
            "candidateSource": { "const": "candidate-catalog-only" },
            "workspace": { "const": "archive-of-case-base-without-git-metadata" },
            "network": { "const": "denied-by-execution-lane" },
            "acceptanceMount": { "const": "evaluator-only" },
            "onLeak": { "const": "invalidate-run-retire-case-investigate" }
          }
        },
        "governance": {
          "type": "object",
          "additionalProperties": false,
          "required": ["amendmentRule", "answerAwareTuning", "sourceReview", "privacyReview"],
          "properties": {
            "amendmentRule": { "const": "new-version-before-results" },
            "answerAwareTuning": { "const": "retire-case-and-author-fresh-replacement" },
            "sourceReview": { "const": "repository-commit-and-blob-correspondence" },
            "privacyReview": { "const": "no-personal-data-credentials-or-raw-conversations" }
          }
        },
        "limitations": {
          "type": "array",
          "minItems": 3,
          "items": { "type": "string", "minLength": 20 }
        }
      }
    },
    "documentDigest": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "sha256", "bytes"],
      "properties": {
        "path": { "type": "string", "minLength": 3 },
        "sha256": { "$ref": "#/$defs/sha256" },
        "bytes": { "type": "integer", "minimum": 1 }
      }
    }
  }
}
