{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oshun.example/audits/eve-sota-provider-route-resilience.schema.json",
  "title": "Eve SOTA provider route resilience",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "taskId",
    "recordedAt",
    "source",
    "dependency",
    "routes",
    "faultMatrix",
    "circuit",
    "clientDegradation",
    "livePosture",
    "limitations"
  ],
  "properties": {
    "schemaVersion": { "const": "eve-sota-provider-route-resilience.v1" },
    "taskId": { "const": "15.2" },
    "recordedAt": { "type": "string", "format": "date-time" },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository", "commit", "bindings"],
      "properties": {
        "repository": { "const": "GreyChimp/oshun" },
        "commit": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "bindings": {
          "type": "array",
          "minItems": 8,
          "uniqueItems": true,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["path", "sha256"],
            "properties": {
              "path": { "type": "string", "minLength": 1 },
              "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
            }
          }
        }
      }
    },
    "dependency": {
      "type": "object",
      "additionalProperties": false,
      "required": ["taskId", "state", "manifest", "manifestSha256"],
      "properties": {
        "taskId": { "const": "15.1" },
        "state": { "const": "complete" },
        "manifest": { "const": "docs/audits/eve-sota-evidence/phase-15/task-15-1.json" },
        "manifestSha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
      }
    },
    "routes": {
      "type": "object",
      "additionalProperties": false,
      "required": ["endpointFailover", "modelFallback", "deterministicDegraded"],
      "properties": {
        "endpointFailover": { "$ref": "#/$defs/routeClass" },
        "modelFallback": { "$ref": "#/$defs/routeClass" },
        "deterministicDegraded": { "$ref": "#/$defs/routeClass" }
      }
    },
    "faultMatrix": {
      "type": "array",
      "minItems": 7,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "fault", "expected", "observed", "test"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "fault": { "type": "string", "minLength": 1 },
          "expected": { "enum": ["preserve", "refuse", "degrade-before-start"] },
          "observed": { "enum": ["preserved", "refused", "degraded-before-start"] },
          "test": { "type": "string", "minLength": 1 }
        }
      }
    },
    "circuit": {
      "type": "object",
      "additionalProperties": false,
      "required": ["consecutiveFailureThreshold", "cooldownMs", "scope", "successReset"],
      "properties": {
        "consecutiveFailureThreshold": { "const": 3 },
        "cooldownMs": { "const": 30000 },
        "scope": { "const": "process-local-assistant-route" },
        "successReset": { "const": true }
      }
    },
    "clientDegradation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["reason", "fallback", "preflightOnly", "ambiguousReplay"],
      "properties": {
        "reason": { "const": "assistant_agent_provider_circuit_open" },
        "fallback": { "const": "deterministic_message_route" },
        "preflightOnly": { "const": true },
        "ambiguousReplay": { "const": "refused" }
      }
    },
    "livePosture": {
      "type": "object",
      "additionalProperties": false,
      "required": ["receipt", "sha256", "result", "httpStatus", "claimBoundary"],
      "properties": {
        "receipt": {
          "const": "docs/audits/eve-sota-provider-route-resilience/2026-09-16.live.probe.json"
        },
        "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "result": { "enum": ["served-contract-preserved", "regional-route-unavailable"] },
        "httpStatus": { "type": "integer", "minimum": 100, "maximum": 599 },
        "claimBoundary": { "type": "string", "minLength": 1 }
      }
    },
    "limitations": {
      "type": "array",
      "minItems": 4,
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 20 }
    }
  },
  "$defs": {
    "routeClass": {
      "type": "object",
      "additionalProperties": false,
      "required": ["enabled", "scope", "controls"],
      "properties": {
        "enabled": { "type": "boolean" },
        "scope": { "type": "string", "minLength": 1 },
        "controls": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 1 }
        }
      }
    }
  }
}
