{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developer.reits.tech/schemas/runner-factory-reconciliation-planner.v1.schema.json",
  "title": "REITs Runner Factory cross-port reconciliation planner dossier",
  "type": "object",
  "required": ["schemaVersion", "status", "observedAt", "scope", "truth", "implementation", "operations", "sourceReads", "stateMachine", "invariants", "metricSeries", "verification", "failureClasses", "productionPrerequisites", "fixtureRegistry", "discovery"],
  "properties": {
    "schemaVersion": { "const": "developer.reits.tech/runner-factory-reconciliation-planner/v1" },
    "status": { "const": "PLANNER_IMPLEMENTED_NOT_CONFIGURED" },
    "observedAt": { "type": "string", "format": "date-time" },
    "scope": {
      "type": "object",
      "required": ["mode", "sources", "sourceWindowSeconds", "mutationPolicy", "failureMode"],
      "properties": {
        "mode": { "const": "READ_ONLY_CROSS_PORT_RECONCILIATION" },
        "sources": { "const": 5 },
        "sourceWindowSeconds": { "const": 300 },
        "mutationPolicy": { "const": "PLAN_ONLY_NO_EXTERNAL_ACTION" },
        "failureMode": { "const": "FREEZE_AND_PAGE_PLAN" }
      },
      "additionalProperties": false
    },
    "truth": {
      "type": "object",
      "required": ["runtimeSourcesConfigured", "schedulerIntegrated", "metricsExporterConfigured", "pagingProviderConfigured", "readinessGateSatisfied", "liveReports", "runtimeContainments", "pagesSent", "mutationsExecuted", "externalReadsExecuted", "externalWritesExecuted", "secretValuesRecorded", "paidResourcesCreated", "deploymentPermitted"],
      "properties": {
        "runtimeSourcesConfigured": { "const": 0 }, "schedulerIntegrated": { "const": false }, "metricsExporterConfigured": { "const": false }, "pagingProviderConfigured": { "const": false }, "readinessGateSatisfied": { "const": false },
        "liveReports": { "const": 0 }, "runtimeContainments": { "const": 0 }, "pagesSent": { "const": 0 }, "mutationsExecuted": { "const": 0 }, "externalReadsExecuted": { "const": 0 }, "externalWritesExecuted": { "const": 0 }, "secretValuesRecorded": { "const": 0 }, "paidResourcesCreated": { "const": false }, "deploymentPermitted": { "const": false }
      },
      "additionalProperties": false
    },
    "implementation": {
      "type": "object",
      "required": ["planner", "fixtureRegistry", "verifier", "runtimeSourceReader", "metricExporter", "pagingProvider"],
      "properties": {
        "planner": { "const": "ops/runner-factory/reconciliation-planner.mjs" },
        "fixtureRegistry": { "const": "ops/runner-factory/reconciliation-planner-fixtures.json" },
        "verifier": { "const": "scripts/verify-runner-factory-reconciliation-planner.mjs" },
        "runtimeSourceReader": { "const": "NOT_CONFIGURED" },
        "metricExporter": { "const": "NOT_CONFIGURED" },
        "pagingProvider": { "const": "NOT_CONFIGURED" }
      },
      "additionalProperties": false
    },
    "operations": {
      "type": "array", "minItems": 4, "maxItems": 4,
      "items": {
        "type": "object", "required": ["id", "guard", "result"],
        "properties": {
          "id": { "enum": ["assess", "summarize", "buildMetrics", "buildPage"] },
          "guard": { "type": "string", "minLength": 12 },
          "result": { "type": "string", "minLength": 12 }
        },
        "additionalProperties": false
      }
    },
    "sourceReads": {
      "type": "array", "minItems": 5, "maxItems": 5,
      "items": {
        "type": "object", "required": ["id", "boundary"],
        "properties": {
          "id": { "enum": ["Reservation", "Capacity", "Worker", "Runner", "Journal"] },
          "boundary": { "type": "string", "minLength": 20 }
        },
        "additionalProperties": false
      }
    },
    "stateMachine": {
      "type": "array", "minItems": 12, "maxItems": 12,
      "items": {
        "type": "object", "required": ["from", "condition", "to"],
        "properties": {
          "from": { "const": "SNAPSHOT" },
          "condition": { "type": "string", "minLength": 12 },
          "to": { "enum": ["HEALTHY_PRELAUNCH", "HEALTHY_BOOTSTRAP", "HEALTHY_IN_FLIGHT", "HEALTHY_COMPLETE", "HEALTHY_FAILED", "CONTAINED_FROZEN", "SOURCE_UNAVAILABLE", "SCOPE_MISMATCH", "STALE_CONTROL_STATE", "ORPHAN_AUTHORITY", "TERMINAL_CONFLICT", "UNCLASSIFIED_DRIFT"] }
        },
        "additionalProperties": false
      }
    },
    "invariants": { "type": "array", "minItems": 18, "maxItems": 18, "items": { "type": "string", "minLength": 12 } },
    "metricSeries": { "type": "array", "minItems": 8, "maxItems": 8, "items": { "type": "string", "pattern": "^reits_rf_reconciliation_" } },
    "verification": {
      "type": "object",
      "required": ["status", "fixtures", "safeOutcomes", "containedOutcomes", "deniedInputs", "freezePlans", "pagePlans", "metricSeries", "highCardinalityLabels", "secretValuesRecorded", "mutationsExecuted", "externalCallsExecuted"],
      "properties": {
        "status": { "const": "PASS_FIXTURE_ONLY" }, "fixtures": { "const": 32 }, "safeOutcomes": { "const": 7 }, "containedOutcomes": { "const": 24 }, "deniedInputs": { "const": 1 }, "freezePlans": { "const": 23 }, "pagePlans": { "const": 24 }, "metricSeries": { "const": 8 }, "highCardinalityLabels": { "const": 0 }, "secretValuesRecorded": { "const": 0 }, "mutationsExecuted": { "const": 0 }, "externalCallsExecuted": { "const": 0 }
      },
      "additionalProperties": false
    },
    "failureClasses": {
      "type": "array", "minItems": 6, "maxItems": 6,
      "items": {
        "type": "object", "required": ["code", "owner", "containment"],
        "properties": {
          "code": { "type": "string", "pattern": "^[A-Z_*|]+$" },
          "owner": { "enum": ["platform-oncall", "security-oncall", "platform-and-security"] },
          "containment": { "type": "string", "minLength": 20 }
        },
        "additionalProperties": false
      }
    },
    "productionPrerequisites": { "type": "array", "minItems": 7, "maxItems": 7, "items": { "type": "string", "minLength": 12 } },
    "fixtureRegistry": {
      "type": "object",
      "required": ["schemaVersion", "fixedTime", "cases"],
      "properties": {
        "schemaVersion": { "const": "developer.reits.tech/runner-factory-reconciliation-planner-fixtures/v1" },
        "fixedTime": { "const": "2026-07-20T19:30:00.000Z" },
        "cases": {
          "type": "array", "minItems": 32, "maxItems": 32,
          "items": {
            "oneOf": [
              {
                "type": "object", "required": ["id", "profile", "expected", "verdict", "severity", "freezeRequired"],
                "properties": {
                  "id": { "type": "string", "pattern": "^RFR-[0-9]{2}$" },
                  "profile": { "type": "string", "pattern": "^[a-z][a-z0-9-]+$" },
                  "expected": { "enum": ["SAFE", "CONTAIN"] },
                  "verdict": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]+$" },
                  "severity": { "enum": ["P0", "P1", "P2", "P3"] },
                  "freezeRequired": { "type": "boolean" }
                },
                "additionalProperties": false
              },
              {
                "type": "object", "required": ["id", "profile", "expected", "errorCode"],
                "properties": {
                  "id": { "type": "string", "pattern": "^RFR-[0-9]{2}$" },
                  "profile": { "type": "string", "pattern": "^[a-z][a-z0-9-]+$" },
                  "expected": { "const": "DENY" },
                  "errorCode": { "const": "RF_RECON_INPUT_SECRET" }
                },
                "additionalProperties": false
              }
            ]
          }
        }
      },
      "additionalProperties": false
    },
    "discovery": {
      "type": "object",
      "required": ["lifecycle", "controller", "workbench", "schema", "snapshotCoordinator", "snapshotCoordinatorSchema"],
      "properties": {
        "lifecycle": { "const": "/api/runner-factory" },
        "controller": { "const": "/api/runner-factory/controller" },
        "workbench": { "const": "/release-foundation#runtime-reconciliation" },
        "schema": { "const": "/schemas/runner-factory-reconciliation-planner.v1.schema.json" },
        "snapshotCoordinator": { "const": "/api/runner-factory/reconciliation/snapshot-coordinator" },
        "snapshotCoordinatorSchema": { "const": "/schemas/runner-factory-reconciliation-snapshot-coordinator.v1.schema.json" }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
