{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://genesiscode.dev/schemas/engineering-gate-timing-observation-v0.1.json",
  "title": "GenesisCode engineering gate timing E0 observation",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "kind",
    "version",
    "classId",
    "observedAtUnixSeconds",
    "durationMs",
    "outcome",
    "failureKind",
    "exitCode",
    "cleanupStatus",
    "gitCommit",
    "hostObservationCanonicalJson",
    "hostIdentitySha256",
    "toolchainIdentityCanonicalJson",
    "toolchainIdentitySha256",
    "controlObservationCanonicalJson",
    "workloadIdentitySha256",
    "cachePrecondition",
    "competingLaneState",
    "sourceIdentity",
    "chainScope",
    "previousObservationSha256",
    "identitySha256"
  ],
  "properties": {
    "kind": {"const": "genesis/engineering-gate-timing-observation-v0.1"},
    "version": {"const": "0.1"},
    "classId": {"enum": ["local-warm", "local-clean-fallback", "hosted-cold-shared-runner"]},
    "observedAtUnixSeconds": {"type": "integer", "minimum": 1},
    "durationMs": {"type": "integer", "minimum": 1},
    "outcome": {"enum": ["semantic-pass", "hard-failure"]},
    "failureKind": {"oneOf": [{"enum": ["command-failure", "competing-lane", "hard-timeout", "infrastructure-failure", "telemetry-budget", "interrupted"]}, {"type": "null"}]},
    "exitCode": {"oneOf": [{"type": "integer"}, {"type": "null"}]},
    "cleanupStatus": {"enum": ["reaped", "containment-failure"]},
    "gitCommit": {"type": "string", "pattern": "^[0-9a-f]{40}$"},
    "hostObservationCanonicalJson": {"type": "string", "minLength": 2},
    "hostIdentitySha256": {"$ref": "#/$defs/sha256"},
    "toolchainIdentityCanonicalJson": {"type": "string", "minLength": 2},
    "toolchainIdentitySha256": {"$ref": "#/$defs/sha256"},
    "controlObservationCanonicalJson": {"type": "string", "minLength": 2},
    "workloadIdentitySha256": {"$ref": "#/$defs/sha256"},
    "cachePrecondition": {"type": "string", "minLength": 1},
    "competingLaneState": {"type": "string", "minLength": 1},
    "sourceIdentity": {"type": "string", "pattern": "^(github-actions-run|local-observation):.+$"},
    "chainScope": {"enum": ["append-only-local", "standalone-hosted"]},
    "previousObservationSha256": {"$ref": "#/$defs/sha256"},
    "identitySha256": {"$ref": "#/$defs/sha256"}
  },
  "$defs": {
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
  }
}
