{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://genesiscode.dev/schemas/gc-agent-task-benchmark-v0.1.json",
  "title": "GenesisCode agent task benchmark v0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["kind", "version", "benchmarkId", "profile", "taskClasses", "contextTiers", "lineages", "conditions", "cases", "contentIdentitySha256"],
  "properties": {
    "kind": {"const": "genesis/agent-task-benchmark-v0.1"},
    "version": {"const": "0.1.0"},
    "benchmarkId": {"const": "GC-AGENT-TASK-BENCHMARK-v0.1"},
    "profile": {"$ref": "#/$defs/profile"},
    "taskClasses": {"const": ["completion", "deployment", "generation", "package-migration", "performance-repair", "policy-minimization", "refactor", "repair", "replay-investigation"]},
    "contextTiers": {"type": "array", "minItems": 3, "maxItems": 3, "items": {"$ref": "#/$defs/tier"}},
    "lineages": {"type": "array", "minItems": 9, "maxItems": 9, "items": {"$ref": "#/$defs/lineage"}},
    "conditions": {"type": "array", "minItems": 27, "maxItems": 27, "items": {"$ref": "#/$defs/condition"}},
    "cases": {"type": "array", "minItems": 27, "maxItems": 27, "items": {"$ref": "#/$defs/case"}},
    "contentIdentitySha256": {"$ref": "#/$defs/sha256"}
  },
  "$defs": {
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "path": {"type": "string", "pattern": "^[A-Za-z0-9._/-]+$", "not": {"pattern": "(^/|(^|/)\\.\\.?(/|$))"}},
    "profile": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "path", "sha256"],
      "properties": {
        "id": {"const": "GC-AGENT-v0.3"},
        "path": {"const": "docs/spec/GC_AGENT_PROFILE_v0.3.json"},
        "sha256": {"$ref": "#/$defs/sha256"}
      }
    },
    "artifact": {
      "type": "object", "additionalProperties": false,
      "required": ["path", "bytes", "sha256"],
      "properties": {
        "path": {"$ref": "#/$defs/path"},
        "bytes": {"type": "integer", "minimum": 1},
        "sha256": {"$ref": "#/$defs/sha256"}
      }
    },
    "tier": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "ordinal", "artifacts", "contextBytes"],
      "properties": {
        "id": {"enum": ["small", "medium", "large"]},
        "ordinal": {"type": "integer", "minimum": 1, "maximum": 3},
        "artifacts": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/artifact"}},
        "contextBytes": {"type": "integer", "minimum": 1}
      }
    },
    "assertion": {
      "type": "object", "additionalProperties": false,
      "required": ["pointer", "operator", "value"],
      "properties": {
        "pointer": {"type": "string", "pattern": "^/"},
        "operator": {"enum": ["equals", "contains"]},
        "value": {}
      }
    },
    "artifactAssertion": {
      "type": "object", "additionalProperties": false,
      "required": ["path", "format", "pointer", "operator", "value"],
      "properties": {
        "path": {"$ref": "#/$defs/path"},
        "format": {"enum": ["json", "toml"]},
        "pointer": {"type": "string", "pattern": "^(/|$)"},
        "operator": {"enum": ["equals", "contains"]},
        "value": {}
      }
    },
    "sourceAppend": {
      "type": "object", "additionalProperties": false,
      "required": ["path", "source"],
      "properties": {
        "path": {"$ref": "#/$defs/path"},
        "source": {"type": "string", "minLength": 1, "maxLength": 4096}
      }
    },
    "step": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "argv", "exitCode", "ok", "kind", "assertions", "sourceAppend"],
      "properties": {
        "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
        "argv": {"type": "array", "minItems": 3, "items": {"type": "string"}},
        "exitCode": {"type": "integer", "minimum": 0, "maximum": 255},
        "ok": {"type": "boolean"},
        "kind": {"type": "string", "pattern": "^genesis/"},
        "assertions": {"type": "array", "items": {"$ref": "#/$defs/assertion"}},
        "sourceAppend": {"oneOf": [{"type": "null"}, {"$ref": "#/$defs/sourceAppend"}]}
      }
    },
    "lineage": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "taskClass", "prompt", "inputRoot", "referenceRoot", "inputFiles", "referenceFiles", "editablePaths", "changedPaths", "oracleExposure", "artifactAssertions", "verification", "contentIdentitySha256"],
      "properties": {
        "id": {"type": "string", "pattern": "^lineage-[a-z0-9-]+-[0-9]{3}$"},
        "taskClass": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
        "prompt": {"type": "string", "minLength": 16},
        "inputRoot": {"$ref": "#/$defs/path"},
        "referenceRoot": {"$ref": "#/$defs/path"},
        "inputFiles": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/artifact"}},
        "referenceFiles": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/artifact"}},
        "editablePaths": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/path"}},
        "changedPaths": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/path"}},
        "oracleExposure": {"const": "public-development-reference"},
        "artifactAssertions": {"type": "array", "items": {"$ref": "#/$defs/artifactAssertion"}},
        "verification": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/step"}},
        "contentIdentitySha256": {"$ref": "#/$defs/sha256"}
      }
    },
    "condition": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "lineageId", "lineageIdentitySha256", "dimensions", "contextArtifacts", "contextBytes", "contentIdentitySha256"],
      "properties": {
        "id": {"type": "string", "pattern": "^condition-[a-z0-9-]+-[0-9]{3}$"},
        "lineageId": {"type": "string", "pattern": "^lineage-[a-z0-9-]+-[0-9]{3}$"},
        "lineageIdentitySha256": {"$ref": "#/$defs/sha256"},
        "dimensions": {
          "type": "object", "additionalProperties": false,
          "required": ["contextTier", "toolMode", "repairPolicy", "scaffold", "mutation"],
          "properties": {
            "contextTier": {"enum": ["small", "medium", "large"]},
            "toolMode": {"const": "production-json-cli-v0.1"},
            "repairPolicy": {"const": "no-agent-repair-v0.1"},
            "scaffold": {"const": "public-reference-executor-v0.1"},
            "mutation": {"const": "none"}
          }
        },
        "contextArtifacts": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/artifact"}},
        "contextBytes": {"type": "integer", "minimum": 1},
        "contentIdentitySha256": {"$ref": "#/$defs/sha256"}
      }
    },
    "case": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "lineageId", "lineageIdentitySha256", "conditionId", "conditionIdentitySha256", "taskClass", "contextTier", "prompt", "inputRoot", "referenceRoot", "inputFiles", "referenceFiles", "editablePaths", "changedPaths", "contextBytes", "oracleExposure", "artifactAssertions", "verification"],
      "properties": {
        "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
        "lineageId": {"type": "string", "pattern": "^lineage-[a-z0-9-]+-[0-9]{3}$"},
        "lineageIdentitySha256": {"$ref": "#/$defs/sha256"},
        "conditionId": {"type": "string", "pattern": "^condition-[a-z0-9-]+-[0-9]{3}$"},
        "conditionIdentitySha256": {"$ref": "#/$defs/sha256"},
        "taskClass": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
        "contextTier": {"enum": ["small", "medium", "large"]},
        "prompt": {"type": "string", "minLength": 16},
        "inputRoot": {"$ref": "#/$defs/path"},
        "referenceRoot": {"$ref": "#/$defs/path"},
        "inputFiles": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/artifact"}},
        "referenceFiles": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/artifact"}},
        "editablePaths": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/path"}},
        "changedPaths": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/path"}},
        "contextBytes": {"type": "integer", "minimum": 1},
        "oracleExposure": {"const": "public-development-reference"},
        "artifactAssertions": {"type": "array", "items": {"$ref": "#/$defs/artifactAssertion"}},
        "verification": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/step"}}
      }
    }
  }
}
