{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/agent-governance-starter/governance-impact-run.schema.json",
  "title": "Governance Impact Raw Paired Run",
  "type": "object",
  "required": [
    "schemaVersion",
    "runId",
    "attemptId",
    "repetitionId",
    "seed",
    "scenario",
    "arms"
  ],
  "properties": {
    "schemaVersion": { "type": "integer", "enum": [1, 2] },
    "runId": { "$ref": "#/$defs/identifier" },
    "attemptId": { "$ref": "#/$defs/sha256" },
    "repetitionId": { "$ref": "#/$defs/identifier" },
    "seed": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "scenario": {
      "$ref": "governance-impact-scenario.schema.json"
    },
    "arms": {
      "type": "object",
      "required": ["baseline", "governed"],
      "properties": {
        "baseline": {},
        "governed": {}
      },
      "additionalProperties": false
    }
  },
  "allOf": [
    {
      "if": {
        "properties": { "schemaVersion": { "const": 1 } },
        "required": ["schemaVersion"]
      },
      "then": {
        "properties": {
          "arms": {
            "properties": {
              "baseline": { "$ref": "#/$defs/arm" },
              "governed": { "$ref": "#/$defs/arm" }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": { "schemaVersion": { "const": 2 } },
        "required": ["schemaVersion"]
      },
      "then": {
        "properties": {
          "arms": {
            "properties": {
              "baseline": { "$ref": "#/$defs/armV2" },
              "governed": { "$ref": "#/$defs/armV2" }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "identifier": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!\\s)(?!.*\\s$)[^\\u0000]+$"
    },
    "relativePath": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!\\s)(?!.*\\s$)(?!/)(?![A-Za-z]:)(?!.*(?:^|/)(?:\\.|\\.\\.)(?:/|$))(?!.*//)[^\\\\\\u0000]+$"
    },
    "cohort": {
      "type": "object",
      "required": ["runtime", "model", "config", "starterCommit"],
      "properties": {
        "runtime": {
          "type": "string",
          "enum": ["synthetic", "codex", "claude", "antigravity"]
        },
        "model": { "$ref": "#/$defs/identifier" },
        "config": { "$ref": "#/$defs/identifier" },
        "starterCommit": {
          "type": "string",
          "pattern": "^(?:[a-f0-9]{40}|[a-f0-9]{64})$"
        }
      },
      "additionalProperties": false
    },
    "cohortV2": {
      "type": "object",
      "required": ["runtime", "model", "config", "starterCommit", "executionBoundaryId"],
      "properties": {
        "runtime": { "type": "string", "const": "codex" },
        "model": { "$ref": "#/$defs/identifier" },
        "config": { "$ref": "#/$defs/identifier" },
        "starterCommit": {
          "type": "string",
          "pattern": "^(?:[a-f0-9]{40}|[a-f0-9]{64})$"
        },
        "executionBoundaryId": { "$ref": "#/$defs/sha256" }
      },
      "additionalProperties": false
    },
    "attempt": {
      "type": "object",
      "required": ["attemptId", "scenarioHash", "repetitionId", "seed"],
      "properties": {
        "attemptId": { "$ref": "#/$defs/sha256" },
        "scenarioHash": { "$ref": "#/$defs/sha256" },
        "repetitionId": { "$ref": "#/$defs/identifier" },
        "seed": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "additionalProperties": false
    },
    "attemptManifest": {
      "type": "object",
      "required": ["schemaVersion", "cohort", "attempts"],
      "properties": {
        "schemaVersion": { "type": "integer", "const": 1 },
        "cohort": { "$ref": "#/$defs/cohort" },
        "attempts": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/attempt" }
        }
      },
      "additionalProperties": false
    },
    "attemptManifestV2": {
      "type": "object",
      "required": ["schemaVersion", "cohort", "attempts"],
      "properties": {
        "schemaVersion": { "type": "integer", "const": 2 },
        "cohort": { "$ref": "#/$defs/cohortV2" },
        "attempts": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/attempt" }
        }
      },
      "additionalProperties": false
    },
    "arm": {
      "type": "object",
      "required": [
        "scenarioHash",
        "runtime",
        "model",
        "config",
        "starterCommit",
        "execution",
        "acceptanceChecks",
        "requirements",
        "scope",
        "prohibitions",
        "documentChecks",
        "privacyChecks",
        "time",
        "tokens"
      ],
      "properties": {
        "scenarioHash": { "$ref": "#/$defs/sha256" },
        "runtime": {
          "type": "string",
          "enum": ["synthetic", "codex", "claude", "antigravity"]
        },
        "model": { "$ref": "#/$defs/identifier" },
        "config": { "$ref": "#/$defs/identifier" },
        "starterCommit": {
          "type": "string",
          "pattern": "^(?:[a-f0-9]{40}|[a-f0-9]{64})$"
        },
        "execution": { "$ref": "#/$defs/execution" },
        "acceptanceChecks": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/checkResult" }
        },
        "requirements": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/requirementResult" }
        },
        "scope": { "$ref": "#/$defs/scopeEvidence" },
        "prohibitions": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/prohibitionResult" }
        },
        "documentChecks": {
          "type": "array",
          "items": { "$ref": "#/$defs/documentResult" }
        },
        "privacyChecks": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/checkResult" }
        },
        "time": { "$ref": "#/$defs/timeTelemetry" },
        "tokens": { "$ref": "#/$defs/tokenTelemetry" }
      },
      "additionalProperties": false
    },
    "armV2": {
      "type": "object",
      "required": [
        "scenarioHash",
        "runtime",
        "model",
        "config",
        "starterCommit",
        "executionBoundaryId",
        "boundaryEvidence",
        "execution",
        "acceptanceChecks",
        "requirements",
        "scope",
        "prohibitions",
        "documentChecks",
        "privacyChecks",
        "time",
        "tokens"
      ],
      "properties": {
        "scenarioHash": { "$ref": "#/$defs/sha256" },
        "runtime": { "type": "string", "const": "codex" },
        "model": { "$ref": "#/$defs/identifier" },
        "config": { "$ref": "#/$defs/identifier" },
        "starterCommit": {
          "type": "string",
          "pattern": "^(?:[a-f0-9]{40}|[a-f0-9]{64})$"
        },
        "executionBoundaryId": { "$ref": "#/$defs/sha256" },
        "boundaryEvidence": { "$ref": "#/$defs/boundaryEvidence" },
        "execution": { "$ref": "#/$defs/execution" },
        "acceptanceChecks": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/checkResult" }
        },
        "requirements": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/requirementResult" }
        },
        "scope": { "$ref": "#/$defs/scopeEvidence" },
        "prohibitions": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/prohibitionResult" }
        },
        "documentChecks": {
          "type": "array",
          "items": { "$ref": "#/$defs/documentResult" }
        },
        "privacyChecks": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/checkResult" }
        },
        "time": { "$ref": "#/$defs/timeTelemetry" },
        "tokens": { "$ref": "#/$defs/tokenTelemetry" }
      },
      "additionalProperties": false
    },
    "boundaryEvidence": {
      "type": "object",
      "required": [
        "observedImageDigest",
        "codexVersion",
        "codexBinarySha256",
        "containmentPolicyHash",
        "networkPolicyHash",
        "proxyPolicyHash",
        "hardening",
        "pidNamespaceStopped",
        "cgroupEmpty",
        "cleanupComplete"
      ],
      "properties": {
        "observedImageDigest": { "$ref": "#/$defs/sha256" },
        "codexVersion": {
          "type": "string",
          "minLength": 1,
          "pattern": "^(?!\\s)(?!.*\\s$)[^\\r\\n\\\\/\\u0000]+$"
        },
        "codexBinarySha256": { "$ref": "#/$defs/sha256" },
        "containmentPolicyHash": { "$ref": "#/$defs/sha256" },
        "networkPolicyHash": { "$ref": "#/$defs/sha256" },
        "proxyPolicyHash": { "$ref": "#/$defs/sha256" },
        "hardening": {
          "type": "object",
          "required": [
            "nonRootUser",
            "readOnlyRootFilesystem",
            "capDropAll",
            "noNewPrivileges",
            "privatePidNamespace",
            "privateCgroupNamespace",
            "pidLimit",
            "cpuLimit",
            "memoryLimit",
            "dockerSocketAbsent",
            "devicesAbsent",
            "cgroupMountAbsent"
          ],
          "properties": {
            "nonRootUser": { "type": "boolean", "const": true },
            "readOnlyRootFilesystem": { "type": "boolean", "const": true },
            "capDropAll": { "type": "boolean", "const": true },
            "noNewPrivileges": { "type": "boolean", "const": true },
            "privatePidNamespace": { "type": "boolean", "const": true },
            "privateCgroupNamespace": { "type": "boolean", "const": true },
            "pidLimit": { "type": "boolean", "const": true },
            "cpuLimit": { "type": "boolean", "const": true },
            "memoryLimit": { "type": "boolean", "const": true },
            "dockerSocketAbsent": { "type": "boolean", "const": true },
            "devicesAbsent": { "type": "boolean", "const": true },
            "cgroupMountAbsent": { "type": "boolean", "const": true }
          },
          "additionalProperties": false
        },
        "pidNamespaceStopped": { "type": "boolean", "const": true },
        "cgroupEmpty": { "type": "boolean", "const": true },
        "cleanupComplete": { "type": "boolean", "const": true }
      },
      "additionalProperties": false
    },
    "execution": {
      "type": "object",
      "required": ["status", "repairRounds"],
      "properties": {
        "status": {
          "type": "string",
          "enum": ["completed", "failed", "timeout"]
        },
        "repairRounds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "errorCode": {
          "type": ["string", "null"],
          "pattern": "^[A-Z][A-Z0-9_]*$"
        }
      },
      "additionalProperties": false
    },
    "checkResult": {
      "type": "object",
      "required": ["id", "passed", "critical"],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "passed": { "type": "boolean" },
        "critical": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "requirementResult": {
      "type": "object",
      "required": ["id", "omitted"],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "omitted": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "prohibitionResult": {
      "type": "object",
      "required": ["id", "violated", "critical"],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "violated": { "type": "boolean" },
        "critical": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "documentResult": {
      "type": "object",
      "required": ["id", "drifted", "critical"],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "drifted": { "type": "boolean" },
        "critical": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "scopeEvidence": {
      "type": "object",
      "required": ["changedPaths", "allowedPaths", "forbiddenPaths"],
      "properties": {
        "changedPaths": {
          "type": "array",
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/relativePath" }
        },
        "allowedPaths": {
          "type": "array",
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/relativePath" }
        },
        "forbiddenPaths": {
          "type": "array",
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/relativePath" }
        }
      },
      "additionalProperties": false
    },
    "timeTelemetry": {
      "oneOf": [
        {
          "type": "object",
          "required": ["availability", "wallTimeMs"],
          "properties": {
            "availability": { "type": "string", "const": "available" },
            "wallTimeMs": {
              "type": "number",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["availability", "wallTimeMs"],
          "properties": {
            "availability": { "type": "string", "const": "unavailable" },
            "wallTimeMs": { "type": "null" }
          },
          "additionalProperties": false
        }
      ]
    },
    "tokenTelemetry": {
      "oneOf": [
        {
          "type": "object",
          "required": ["availability", "total"],
          "properties": {
            "availability": { "type": "string", "const": "available" },
            "total": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["availability", "total"],
          "properties": {
            "availability": { "type": "string", "const": "unavailable" },
            "total": { "type": "null" }
          },
          "additionalProperties": false
        }
      ]
    }
  },
  "additionalProperties": false
}
