{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://genesiscode.dev/schemas/gc-agent-benchmark-score-v0.1.json",
  "title": "GenesisCode model-agnostic agent benchmark score v0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["kind", "version", "scoringId", "caseId", "taskClass", "contextTier", "bindings", "candidate", "validity", "dimensions", "qualityScoreBasisPoints", "verification", "patch", "policy", "resources", "modelSpecificMetrics", "scoreIdentitySha256"],
  "properties": {
    "kind": {"const": "genesis/agent-benchmark-score-v0.1"},
    "version": {"const": "0.1.0"},
    "scoringId": {"const": "GC-AGENT-BENCHMARK-SCORING-v0.1"},
    "caseId": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
    "taskClass": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
    "contextTier": {"enum": ["small", "medium", "large"]},
    "bindings": {"$ref": "#/$defs/bindings"},
    "candidate": {"$ref": "#/$defs/candidate"},
    "validity": {"$ref": "#/$defs/validity"},
    "dimensions": {"type": "array", "minItems": 6, "maxItems": 6, "items": {"$ref": "#/$defs/dimension"}},
    "qualityScoreBasisPoints": {"type": "integer", "minimum": 0, "maximum": 10000},
    "verification": {"type": "array", "minItems": 1, "maxItems": 8, "items": {"$ref": "#/$defs/verification"}},
    "patch": {"$ref": "#/$defs/patch"},
    "policy": {"$ref": "#/$defs/policy"},
    "resources": {"$ref": "#/$defs/resources"},
    "modelSpecificMetrics": {"$ref": "#/$defs/modelSpecificMetrics"},
    "scoreIdentitySha256": {"$ref": "#/$defs/sha256"}
  },
  "$defs": {
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "path": {"type": "string", "pattern": "^[A-Za-z0-9._/-]+$", "not": {"pattern": "(^/|(^|/)\\.\\.?(/|$))"}},
    "bindings": {
      "type": "object", "additionalProperties": false,
      "required": ["scoringContentIdentitySha256", "benchmarkContentIdentitySha256", "profileSha256", "scorerRuntimeSha256", "scorerContractSha256"],
      "properties": {
        "scoringContentIdentitySha256": {"$ref": "#/$defs/sha256"},
        "benchmarkContentIdentitySha256": {"$ref": "#/$defs/sha256"},
        "profileSha256": {"$ref": "#/$defs/sha256"},
        "scorerRuntimeSha256": {"$ref": "#/$defs/sha256"},
        "scorerContractSha256": {"$ref": "#/$defs/sha256"}
      }
    },
    "candidate": {
      "type": "object", "additionalProperties": false,
      "required": ["identitySha256", "fileCount", "bytes"],
      "properties": {
        "identitySha256": {"$ref": "#/$defs/sha256"},
        "fileCount": {"type": "integer", "minimum": 1},
        "bytes": {"type": "integer", "minimum": 1}
      }
    },
    "validity": {
      "type": "object", "additionalProperties": false,
      "required": ["passed", "failedDimensions"],
      "properties": {
        "passed": {"type": "boolean"},
        "failedDimensions": {"type": "array", "items": {"type": "string", "pattern": "^[a-z0-9-]+$"}}
      }
    },
    "dimension": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "applicable", "weightBasisPoints", "scoreBasisPoints"],
      "properties": {
        "id": {"enum": ["semantics", "obligations", "effects", "patch-minimality", "resource-use", "policy-scope"]},
        "applicable": {"type": "boolean"},
        "weightBasisPoints": {"type": "integer", "minimum": 1, "maximum": 10000},
        "scoreBasisPoints": {"type": "integer", "minimum": 0, "maximum": 10000}
      }
    },
    "verification": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "passed", "exitCode", "ok", "kind", "assertionsPassed", "outputIdentitySha256", "generatedIdentitySha256", "resourceUnits"],
      "properties": {
        "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
        "passed": {"type": "boolean"},
        "exitCode": {"type": "integer", "minimum": -1, "maximum": 255},
        "ok": {"type": ["boolean", "null"]},
        "kind": {"type": ["string", "null"]},
        "assertionsPassed": {"type": "integer", "minimum": 0},
        "outputIdentitySha256": {"$ref": "#/$defs/sha256"},
        "generatedIdentitySha256": {"$ref": "#/$defs/sha256"},
        "resourceUnits": {"type": "integer", "minimum": 1}
      }
    },
    "patch": {
      "type": "object", "additionalProperties": false,
      "required": ["changedPaths", "expectedChangedPaths", "editableScopeOk", "candidateUnits", "referenceUnits"],
      "properties": {
        "changedPaths": {"type": "array", "items": {"$ref": "#/$defs/path"}},
        "expectedChangedPaths": {"type": "array", "items": {"$ref": "#/$defs/path"}},
        "editableScopeOk": {"type": "boolean"},
        "candidateUnits": {"type": "integer", "minimum": 0},
        "referenceUnits": {"type": "integer", "minimum": 1}
      }
    },
    "policy": {
      "type": "object", "additionalProperties": false,
      "required": ["scopeOk", "candidateAuthorityIdentitySha256", "referenceAuthorityIdentitySha256", "broadenedAuthorities"],
      "properties": {
        "scopeOk": {"type": "boolean"},
        "candidateAuthorityIdentitySha256": {"$ref": "#/$defs/sha256"},
        "referenceAuthorityIdentitySha256": {"$ref": "#/$defs/sha256"},
        "broadenedAuthorities": {"type": "array", "items": {"type": "string", "pattern": "^[A-Za-z0-9._/*:-]+$"}}
      }
    },
    "resources": {
      "type": "object", "additionalProperties": false,
      "required": ["candidateUnits", "referenceUnits", "candidateGeneratedBytes", "referenceGeneratedBytes", "limitsSatisfied"],
      "properties": {
        "candidateUnits": {"type": "integer", "minimum": 1},
        "referenceUnits": {"type": "integer", "minimum": 1},
        "candidateGeneratedBytes": {"type": "integer", "minimum": 0},
        "referenceGeneratedBytes": {"type": "integer", "minimum": 0},
        "limitsSatisfied": {"type": "boolean"}
      }
    },
    "modelSpecificMetrics": {
      "type": "object", "additionalProperties": false,
      "required": ["includedInQualityScore", "recordedBy", "present"],
      "properties": {
        "includedInQualityScore": {"const": false},
        "recordedBy": {"const": "genesis/agent-benchmark-run-v0.1"},
        "present": {"const": false}
      }
    }
  }
}
