{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oshun.dev/schemas/audit/eve-sota-metis-seam-survey.v1.json",
  "title": "Eve SOTA Metis seam survey",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "taskId",
    "initiative",
    "surveyedAt",
    "scope",
    "sourceEvidence",
    "openApi",
    "transport",
    "migrations",
    "stores",
    "classifications",
    "pages",
    "churn",
    "decision",
    "limitations",
    "recordDigestSha256"
  ],
  "properties": {
    "schemaVersion": { "const": "1.0.0" },
    "taskId": { "const": "1.1" },
    "initiative": { "const": "eve-sota-gap-closure-2026-09-01" },
    "surveyedAt": { "$ref": "#/$defs/dateTime" },
    "scope": { "$ref": "#/$defs/scope" },
    "sourceEvidence": { "$ref": "#/$defs/sourceEvidence" },
    "openApi": { "$ref": "#/$defs/openApi" },
    "transport": { "$ref": "#/$defs/transport" },
    "migrations": { "$ref": "#/$defs/migrations" },
    "stores": {
      "type": "array",
      "minItems": 11,
      "maxItems": 11,
      "items": { "$ref": "#/$defs/store" }
    },
    "classifications": {
      "type": "array",
      "minItems": 10,
      "maxItems": 10,
      "items": { "$ref": "#/$defs/classification" }
    },
    "pages": {
      "type": "array",
      "minItems": 65,
      "maxItems": 65,
      "items": { "$ref": "#/$defs/page" }
    },
    "churn": { "$ref": "#/$defs/churn" },
    "decision": { "$ref": "#/$defs/decision" },
    "limitations": { "$ref": "#/$defs/nonEmptyStrings" },
    "recordDigestSha256": { "$ref": "#/$defs/sha256" }
  },
  "$defs": {
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "gitCommit": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
    "dateTime": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]+)?(?:Z|[+-][0-9]{2}:[0-9]{2})$"
    },
    "nonEmptyStrings": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "minLength": 1 }
    },
    "strings": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 }
    },
    "fileEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "sha256", "bytes"],
      "properties": {
        "path": { "type": "string", "minLength": 1 },
        "sha256": { "$ref": "#/$defs/sha256" },
        "bytes": { "type": "integer", "minimum": 1 }
      }
    },
    "treeEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["root", "fileCount", "manifestSha256"],
      "properties": {
        "root": { "type": "string", "minLength": 1 },
        "fileCount": { "type": "integer", "minimum": 1 },
        "manifestSha256": { "$ref": "#/$defs/sha256" }
      }
    },
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "statement",
        "webPageRoot",
        "pageCount",
        "routeHandlerCount",
        "excludedSurfaces"
      ],
      "properties": {
        "statement": { "type": "string", "minLength": 1 },
        "webPageRoot": { "const": "apps/metis/web/src/app" },
        "pageCount": { "const": 65 },
        "routeHandlerCount": { "const": 6 },
        "excludedSurfaces": { "$ref": "#/$defs/nonEmptyStrings" }
      }
    },
    "sourceEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["coreSources", "implementationSources", "sourceTrees", "pageRouteHandlers"],
      "properties": {
        "coreSources": {
          "type": "array",
          "minItems": 14,
          "maxItems": 14,
          "items": { "$ref": "#/$defs/fileEvidence" }
        },
        "implementationSources": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": { "$ref": "#/$defs/fileEvidence" }
        },
        "sourceTrees": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": { "$ref": "#/$defs/treeEvidence" }
        },
        "pageRouteHandlers": {
          "type": "array",
          "minItems": 6,
          "maxItems": 6,
          "items": { "$ref": "#/$defs/fileEvidence" }
        }
      }
    },
    "runtimeObservation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["observedAt", "command", "exitCode", "outcome"],
      "properties": {
        "observedAt": { "$ref": "#/$defs/dateTime" },
        "command": { "type": "string", "minLength": 1 },
        "exitCode": { "type": "integer", "minimum": 0 },
        "outcome": { "type": "string", "minLength": 1 }
      }
    },
    "openApi": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "artifact",
        "sha256",
        "openApiVersion",
        "title",
        "serviceVersion",
        "pathCount",
        "operationCount",
        "schemaCount",
        "pathPrefix",
        "runtimeParityObservation"
      ],
      "properties": {
        "artifact": { "const": "apps/metis/service/openapi/metis.openapi.json" },
        "sha256": { "$ref": "#/$defs/sha256" },
        "openApiVersion": { "const": "3.1.0" },
        "title": { "const": "Metis API" },
        "serviceVersion": { "const": "0.1.0" },
        "pathCount": { "type": "integer", "minimum": 1 },
        "operationCount": { "type": "integer", "minimum": 1 },
        "schemaCount": { "type": "integer", "minimum": 1 },
        "pathPrefix": { "const": "/api" },
        "runtimeParityObservation": { "$ref": "#/$defs/runtimeObservation" }
      }
    },
    "registeredPattern": {
      "type": "object",
      "additionalProperties": false,
      "required": ["method", "path", "source"],
      "properties": {
        "method": { "enum": ["GET", "POST", "PUT", "PATCH", "DELETE"] },
        "path": { "type": "string", "pattern": "^/api/v1/" },
        "source": { "type": "string", "pattern": "^apps/metis/api-gateway/src/routes/.+\\.ts$" }
      }
    },
    "transport": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "browserPrefix",
        "nextProxyMapping",
        "defaultMetisBaseUrl",
        "gatewayPrefix",
        "fastApiPrefix",
        "gatewayHasCatchAllProxy",
        "gatewayUnknownRouteOutcome",
        "configuredFamilies",
        "handlerFamilies",
        "registeredPatterns",
        "distinctBrowserMetisPathCount",
        "gatewayMatchedBrowserPathCount",
        "gatewayUnmatchedBrowserPathCount",
        "serviceContractMatchedBrowserPathCount",
        "limitation"
      ],
      "properties": {
        "browserPrefix": { "const": "/api/metis/v1" },
        "nextProxyMapping": { "type": "string", "minLength": 1 },
        "defaultMetisBaseUrl": { "const": "http://localhost:4020" },
        "gatewayPrefix": { "const": "/api/v1" },
        "fastApiPrefix": { "const": "/api" },
        "gatewayHasCatchAllProxy": { "const": false },
        "gatewayUnknownRouteOutcome": { "const": "404 NOT_FOUND before auth or FastAPI" },
        "configuredFamilies": { "$ref": "#/$defs/nonEmptyStrings" },
        "handlerFamilies": { "$ref": "#/$defs/nonEmptyStrings" },
        "registeredPatterns": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/registeredPattern" }
        },
        "distinctBrowserMetisPathCount": { "type": "integer", "minimum": 1 },
        "gatewayMatchedBrowserPathCount": { "type": "integer", "minimum": 0 },
        "gatewayUnmatchedBrowserPathCount": { "type": "integer", "minimum": 1 },
        "serviceContractMatchedBrowserPathCount": { "type": "integer", "minimum": 1 },
        "limitation": { "type": "string", "minLength": 1 }
      }
    },
    "databaseObservation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "observedAt",
        "boundary",
        "revisionQueryCommand",
        "revisionQueryExitCode",
        "observedRevision",
        "graphResolutionCommand",
        "graphResolutionExitCode",
        "outcome",
        "diagnostic",
        "limitation"
      ],
      "properties": {
        "observedAt": { "$ref": "#/$defs/dateTime" },
        "boundary": { "type": "string", "minLength": 1 },
        "revisionQueryCommand": { "type": "string", "minLength": 1 },
        "revisionQueryExitCode": { "const": 0 },
        "observedRevision": { "type": "string", "minLength": 1 },
        "graphResolutionCommand": { "type": "string", "minLength": 1 },
        "graphResolutionExitCode": { "const": 0 },
        "outcome": { "const": "code-database-head-aligned" },
        "diagnostic": { "type": "string", "minLength": 1 },
        "limitation": { "type": "string", "minLength": 1 }
      }
    },
    "revision": {
      "type": "object",
      "additionalProperties": false,
      "required": ["revision", "downRevision", "path", "sha256"],
      "properties": {
        "revision": { "type": "string", "pattern": "^[0-9]{3}$" },
        "downRevision": { "type": ["string", "null"] },
        "path": { "type": "string", "pattern": "^apps/metis/service/alembic/versions/.+\\.py$" },
        "sha256": { "$ref": "#/$defs/sha256" }
      }
    },
    "migrations": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "root",
        "revisionCount",
        "heads",
        "roots",
        "linear",
        "missingParents",
        "revisions",
        "databaseObservation"
      ],
      "properties": {
        "root": { "const": "apps/metis/service/alembic/versions" },
        "revisionCount": { "const": 43 },
        "heads": { "type": "array", "minItems": 1, "maxItems": 1, "items": { "const": "043" } },
        "roots": { "type": "array", "minItems": 1, "maxItems": 1, "items": { "const": "001" } },
        "linear": { "const": true },
        "missingParents": { "type": "array", "maxItems": 0, "items": { "type": "string" } },
        "revisions": {
          "type": "array",
          "minItems": 43,
          "maxItems": 43,
          "items": { "$ref": "#/$defs/revision" }
        },
        "databaseObservation": { "$ref": "#/$defs/databaseObservation" }
      }
    },
    "store": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "kind", "authority", "source"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "kind": { "type": "string", "minLength": 1 },
        "authority": { "type": "string", "minLength": 1 },
        "source": { "type": "string", "minLength": 1 }
      }
    },
    "classification": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "status", "meaning"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "status": { "enum": ["survey-derived", "proposed-adr", "explicit-gap"] },
        "meaning": { "type": "string", "minLength": 1 }
      }
    },
    "page": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "page",
        "source",
        "sourceSha256",
        "reachableSourceCount",
        "audience",
        "pageAccess",
        "apiFamilies",
        "apiPaths",
        "gatewayMatchedPaths",
        "gatewayUnmatchedPaths",
        "serviceContractMatchedPaths",
        "serviceContractUnmatchedPaths",
        "transportStatus",
        "stores",
        "authz",
        "classifications",
        "seamAdmission"
      ],
      "properties": {
        "page": { "type": "string", "pattern": "^/" },
        "source": {
          "type": "string",
          "pattern": "^apps/metis/web/src/app/.+/page\\.tsx$|^apps/metis/web/src/app/page\\.tsx$"
        },
        "sourceSha256": { "$ref": "#/$defs/sha256" },
        "reachableSourceCount": { "type": "integer", "minimum": 1 },
        "audience": { "type": "string", "minLength": 1 },
        "pageAccess": { "enum": ["public", "public-optional-session", "session-cookie-presence"] },
        "apiFamilies": { "$ref": "#/$defs/nonEmptyStrings" },
        "apiPaths": { "$ref": "#/$defs/nonEmptyStrings" },
        "gatewayMatchedPaths": { "$ref": "#/$defs/strings" },
        "gatewayUnmatchedPaths": { "$ref": "#/$defs/strings" },
        "serviceContractMatchedPaths": { "$ref": "#/$defs/strings" },
        "serviceContractUnmatchedPaths": { "$ref": "#/$defs/strings" },
        "transportStatus": {
          "enum": [
            "oshun-bff-direct",
            "no-metis-api",
            "mixed-bff-and-registered-metis",
            "gateway-and-service-contract-present",
            "service-contract-present-gateway-unregistered",
            "mixed-gateway-coverage",
            "unresolved-no-route-contract"
          ]
        },
        "stores": { "$ref": "#/$defs/nonEmptyStrings" },
        "authz": { "type": "string", "minLength": 1 },
        "classifications": { "$ref": "#/$defs/nonEmptyStrings" },
        "seamAdmission": { "const": "parked" }
      }
    },
    "dayCount": {
      "type": "object",
      "additionalProperties": false,
      "required": ["day", "count"],
      "properties": {
        "day": { "type": "string", "pattern": "^2026-(?:08-(?:27|28|29|30|31)|09-01)$" },
        "count": { "type": "integer", "minimum": 1 }
      }
    },
    "commit": {
      "type": "object",
      "additionalProperties": false,
      "required": ["commit", "authoredAt", "subject"],
      "properties": {
        "commit": { "$ref": "#/$defs/gitCommit" },
        "authoredAt": { "$ref": "#/$defs/dateTime" },
        "subject": { "type": "string", "minLength": 1 }
      }
    },
    "churn": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "startInclusive",
        "endExclusive",
        "expectedActiveUtcDays",
        "commitCount",
        "countsByUtcDay",
        "changedEveryUtcDay",
        "latestMetisCommit",
        "latestMetisCommitAt",
        "commits"
      ],
      "properties": {
        "startInclusive": { "const": "2026-08-27T00:00:00Z" },
        "endExclusive": { "const": "2026-09-02T00:00:00Z" },
        "expectedActiveUtcDays": {
          "type": "array",
          "minItems": 6,
          "maxItems": 6,
          "items": { "type": "string", "pattern": "^2026-(?:08-(?:27|28|29|30|31)|09-01)$" }
        },
        "commitCount": { "type": "integer", "minimum": 6 },
        "countsByUtcDay": {
          "type": "array",
          "minItems": 6,
          "maxItems": 6,
          "items": { "$ref": "#/$defs/dayCount" }
        },
        "changedEveryUtcDay": { "const": true },
        "latestMetisCommit": { "$ref": "#/$defs/gitCommit" },
        "latestMetisCommitAt": { "$ref": "#/$defs/dateTime" },
        "commits": { "type": "array", "minItems": 6, "items": { "$ref": "#/$defs/commit" } }
      }
    },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "posture",
        "seamClosed",
        "registeredViews",
        "ownerTaskIds",
        "resumeConditions",
        "reasons"
      ],
      "properties": {
        "posture": { "const": "parked-contract-moving-daily" },
        "seamClosed": { "const": false },
        "registeredViews": { "type": "array", "maxItems": 0, "items": { "type": "string" } },
        "ownerTaskIds": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": { "enum": ["1.2", "1.3"] }
        },
        "resumeConditions": { "$ref": "#/$defs/nonEmptyStrings" },
        "reasons": { "$ref": "#/$defs/nonEmptyStrings" }
      }
    }
  }
}
