{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:runtime-surface-inventory-v1",
  "title": "AWOOOI Runtime surface 只讀盤點 v1",
  "description": "以 repo 內 committed manifest 與 source file 建立 API / Web / Worker / K8s runtime surface 矩陣；不查 live cluster、不讀 Secret payload、不執行 rollout/restart/scale/delete。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "rollups",
    "runtime_surfaces",
    "source_runtime_components",
    "evidence_gaps",
    "operator_contract",
    "operation_boundaries",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": { "type": "string", "const": "runtime_surface_inventory_v1" },
    "generated_at": { "type": "string", "minLength": 1 },
    "program_status": {
      "type": "object",
      "required": ["overall_completion_percent", "current_priority", "current_task_id", "next_task_id", "read_only_mode"],
      "properties": {
        "overall_completion_percent": { "type": "integer", "minimum": 0, "maximum": 100 },
        "current_priority": { "type": "string", "enum": ["P0", "P1", "P2", "P3"] },
        "current_task_id": { "type": "string", "minLength": 1 },
        "next_task_id": { "type": "string", "minLength": 1 },
        "read_only_mode": { "type": "boolean", "const": true }
      },
      "additionalProperties": false
    },
    "source_refs": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "minLength": 1 }
    },
    "rollups": {
      "type": "object",
      "required": [
        "total_surfaces",
        "by_kind",
        "by_status",
        "by_evidence_level",
        "action_required_surface_ids",
        "secret_surface_ids",
        "live_check_missing_surface_ids",
        "total_source_components",
        "source_components_with_runtime_binding"
      ],
      "properties": {
        "total_surfaces": { "type": "integer", "minimum": 0 },
        "by_kind": { "type": "object", "additionalProperties": { "type": "integer", "minimum": 0 } },
        "by_status": { "type": "object", "additionalProperties": { "type": "integer", "minimum": 0 } },
        "by_evidence_level": { "type": "object", "additionalProperties": { "type": "integer", "minimum": 0 } },
        "action_required_surface_ids": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "secret_surface_ids": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "live_check_missing_surface_ids": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "total_source_components": { "type": "integer", "minimum": 0 },
        "source_components_with_runtime_binding": { "type": "integer", "minimum": 0 }
      },
      "additionalProperties": false
    },
    "runtime_surfaces": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "surface_id",
          "display_name",
          "kind",
          "manifest_ref",
          "status",
          "risk_level",
          "evidence_level",
          "runtime_binding",
          "health_contract",
          "secret_exposure",
          "live_check_status",
          "evidence_refs",
          "next_action"
        ],
        "properties": {
          "surface_id": { "type": "string", "minLength": 1 },
          "display_name": { "type": "string", "minLength": 1 },
          "kind": { "type": "string", "enum": ["deployment", "service", "ingress", "cronjob", "configmap", "secret", "rbac", "policy", "autoscaler", "availability"] },
          "manifest_ref": { "type": "string", "minLength": 1 },
          "status": { "type": "string", "enum": ["manifest_mapped", "action_required", "blocked", "missing"] },
          "risk_level": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
          "evidence_level": { "type": "string", "enum": ["committed_manifest", "source_file", "missing_manifest", "live_check_required"] },
          "runtime_binding": { "type": "string", "minLength": 1 },
          "health_contract": { "type": "string", "minLength": 1 },
          "secret_exposure": { "type": "string", "enum": ["none", "name_only", "template_only", "payload_redacted"] },
          "live_check_status": { "type": "string", "enum": ["not_run", "not_applicable", "required"] },
          "evidence_refs": { "type": "array", "items": { "type": "string", "minLength": 1 } },
          "next_action": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "source_runtime_components": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["component_id", "display_name", "source_ref", "component_kind", "runtime_binding", "status", "next_action"],
        "properties": {
          "component_id": { "type": "string", "minLength": 1 },
          "display_name": { "type": "string", "minLength": 1 },
          "source_ref": { "type": "string", "minLength": 1 },
          "component_kind": { "type": "string", "minLength": 1 },
          "runtime_binding": { "type": "string", "minLength": 1 },
          "status": { "type": "string", "enum": ["bound", "action_required", "source_only"] },
          "next_action": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "evidence_gaps": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["gap_id", "severity", "status", "summary", "evidence_refs", "next_action"],
        "properties": {
          "gap_id": { "type": "string", "minLength": 1 },
          "severity": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
          "status": { "type": "string", "enum": ["action_required", "blocked", "accepted"] },
          "summary": { "type": "string", "minLength": 1 },
          "evidence_refs": { "type": "array", "items": { "type": "string", "minLength": 1 } },
          "next_action": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "operator_contract": {
      "type": "object",
      "required": ["display_mode", "must_not_interpret_as", "secret_display_policy"],
      "properties": {
        "display_mode": { "type": "string", "const": "read_only_runtime_surface" },
        "must_not_interpret_as": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "secret_display_policy": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "operation_boundaries": { "type": "object", "additionalProperties": { "type": "boolean" } },
    "approval_boundaries": { "type": "object", "additionalProperties": { "type": "boolean", "const": false } }
  },
  "additionalProperties": false
}
