{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developer.reits.tech/schemas/runner-live-audit.v1.schema.json",
  "title": "REITs Runner Live Admission Audit",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "status", "observedAt", "sources", "summary", "runners", "candidateQueues", "admissionPolicy", "decision"],
  "properties": {
    "schemaVersion": { "const": "developer.reits.tech/runner-live-audit/v1" },
    "status": { "enum": ["DENIED_NO_ELIGIBLE_CAPACITY", "READY", "ACCEPTED"] },
    "observedAt": { "type": "string", "format": "date-time" },
    "sources": {
      "type": "object",
      "additionalProperties": false,
      "required": ["gitea", "aws"],
      "properties": {
        "gitea": { "type": "object", "required": ["apiBase", "observedAt", "adminRunners", "organizationRunners", "repositoriesScanned", "credentialBoundary", "secretValuesRecorded"], "properties": { "apiBase": { "type": "string", "format": "uri" }, "observedAt": { "type": "string", "format": "date-time" }, "adminRunners": { "$ref": "#/$defs/count" }, "organizationRunners": { "$ref": "#/$defs/count" }, "repositoriesScanned": { "$ref": "#/$defs/count" }, "credentialBoundary": { "type": "string" }, "secretValuesRecorded": { "const": false } }, "additionalProperties": false },
        "aws": { "type": "object", "required": ["observedAt", "freshness", "account", "principal", "region", "runningInstances", "autoScalingGroups", "cloudFormationInventory", "productionInstance"], "properties": { "observedAt": { "type": "string", "format": "date-time" }, "freshness": { "const": "STALE_NOT_REOBSERVED_AWS_CLI_UNAVAILABLE" }, "account": { "type": "string" }, "principal": { "type": "string" }, "region": { "type": "string" }, "runningInstances": { "$ref": "#/$defs/count" }, "autoScalingGroups": { "$ref": "#/$defs/count" }, "cloudFormationInventory": { "enum": ["PASS", "BLOCKED_IAM"] }, "productionInstance": { "type": "object", "required": ["id", "name", "type", "publicIp", "runnerEligible", "reason"], "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "type": { "type": "string" }, "publicIp": { "type": "string" }, "runnerEligible": { "const": false }, "reason": { "type": "string" } }, "additionalProperties": false } }, "additionalProperties": false }
      }
    },
    "summary": { "type": "object", "required": ["registered", "online", "eligible", "organizationOnline", "activeCandidates", "pendingStatuses", "successfulStatuses", "failedStatuses", "reusableAwsInstances"], "additionalProperties": { "$ref": "#/$defs/count" } },
    "runners": { "type": "array", "minItems": 3, "items": { "$ref": "#/$defs/runner" } },
    "candidateQueues": { "type": "array", "minItems": 2, "items": { "$ref": "#/$defs/queue" } },
    "admissionPolicy": { "type": "array", "minItems": 5, "items": { "type": "string" } },
    "decision": { "type": "object", "additionalProperties": false, "required": ["requiresCostApproval", "nextAction", "forbiddenAction"], "properties": { "requiresCostApproval": { "const": true }, "nextAction": { "type": "string" }, "forbiddenAction": { "type": "string" } } },
    "discovery": { "type": "object", "additionalProperties": false, "required": ["workbench", "schema", "capacity", "capacityEvidence", "factory", "releaseUnits"], "properties": { "workbench": { "const": "/release-foundation" }, "schema": { "const": "/schemas/runner-live-audit.v1.schema.json" }, "capacity": { "const": "/api/runner-capacity" }, "capacityEvidence": { "const": "/api/runner-capacity/evidence" }, "factory": { "const": "/api/runner-factory" }, "releaseUnits": { "const": "/api/release-units" } } }
  },
  "$defs": {
    "count": { "type": "integer", "minimum": 0 },
    "criterion": { "type": "object", "additionalProperties": false, "required": ["id", "label", "status", "evidence"], "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "status": { "enum": ["PASS", "FAIL", "MISSING"] }, "evidence": { "type": "string" } } },
    "runner": { "type": "object", "additionalProperties": false, "required": ["id", "name", "platform", "architecture", "status", "busy", "ephemeral", "scope", "scopeEvidence", "repository", "labels", "admission", "criteria"], "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "platform": { "enum": ["linux", "macos"] }, "architecture": { "type": "string" }, "status": { "enum": ["online", "offline"] }, "busy": { "type": "boolean" }, "ephemeral": { "type": "boolean" }, "scope": { "enum": ["repository", "organization", "instance"] }, "scopeEvidence": { "type": "string" }, "repository": { "type": ["string", "null"] }, "labels": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "admission": { "enum": ["DENIED", "READY", "ACCEPTED"] }, "criteria": { "type": "array", "minItems": 5, "items": { "$ref": "#/$defs/criterion" } } } },
    "queue": { "type": "object", "additionalProperties": false, "required": ["repository", "pullRequest", "head", "decision", "contexts"], "properties": { "repository": { "type": "string" }, "pullRequest": { "type": "integer", "minimum": 1 }, "head": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, "decision": { "enum": ["WAITING_RUNNER", "CHECKS_FAILED"] }, "contexts": { "type": "array", "minItems": 1, "items": { "type": "object", "additionalProperties": false, "required": ["name", "role", "status", "description"], "properties": { "name": { "type": "string" }, "role": { "enum": ["REQUIRED", "DEPENDENT"] }, "status": { "enum": ["PENDING", "SUCCESS", "FAILURE", "ERROR", "WARNING"] }, "description": { "type": "string" } } } } } }
  }
}
