{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:dependency-supply-chain-drift-monitor-v1",
  "title": "AWOOOI dependency supply-chain drift monitor v1",
  "description": "P2-004 依賴 / 供應鏈漂移監控讀回。此 schema 僅授權 repo-only committed snapshot 讀回，不授權排程啟用、workflow 寫入、外部 CVE / license / registry / Agent market 查詢、套件安裝或升級、lockfile 寫入、Docker build / image pull / registry push、PR 建立、Telegram 實發、secret 讀取、host probe 或 production write。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "rollups",
    "source_snapshot_readbacks",
    "monitor_checks",
    "drift_candidates",
    "owner_actions",
    "telegram_policy",
    "agent_roles",
    "next_actions",
    "monitor_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "dependency_supply_chain_drift_monitor_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",
        "runtime_authority",
        "status_note"
      ],
      "properties": {
        "overall_completion_percent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "current_priority": {
          "type": "string",
          "enum": ["P0", "P1", "P2", "P3"]
        },
        "current_task_id": {
          "type": "string",
          "const": "P2-004"
        },
        "next_task_id": {
          "type": "string",
          "minLength": 1
        },
        "read_only_mode": {
          "type": "boolean",
          "const": true
        },
        "runtime_authority": {
          "type": "string",
          "minLength": 1
        },
        "status_note": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "source_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "rollups": {
      "type": "object",
      "required": [
        "source_snapshot_count",
        "stale_source_snapshot_count",
        "monitor_check_count",
        "drift_candidate_count",
        "action_required_candidate_count",
        "owner_action_count",
        "blocked_operation_count",
        "by_domain",
        "action_required_drift_candidate_ids"
      ],
      "properties": {
        "source_snapshot_count": { "type": "integer", "minimum": 0 },
        "stale_source_snapshot_count": { "type": "integer", "minimum": 0 },
        "monitor_check_count": { "type": "integer", "minimum": 0 },
        "drift_candidate_count": { "type": "integer", "minimum": 0 },
        "action_required_candidate_count": { "type": "integer", "minimum": 0 },
        "owner_action_count": { "type": "integer", "minimum": 0 },
        "blocked_operation_count": { "type": "integer", "minimum": 0 },
        "by_domain": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "action_required_drift_candidate_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "source_snapshot_readbacks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "snapshot_id",
          "source_ref",
          "source_schema_version",
          "generated_at",
          "freshness_status",
          "evidence_status",
          "next_action"
        ],
        "properties": {
          "snapshot_id": { "type": "string", "minLength": 1 },
          "source_ref": { "type": "string", "minLength": 1 },
          "source_schema_version": { "type": "string", "minLength": 1 },
          "generated_at": { "type": "string", "minLength": 1 },
          "freshness_status": { "type": "string", "minLength": 1 },
          "evidence_status": { "type": "string", "minLength": 1 },
          "next_action": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "monitor_checks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "check_id",
          "domain",
          "owner_agent",
          "status",
          "current_signal",
          "evidence_refs",
          "blocked_now",
          "next_action"
        ],
        "properties": {
          "check_id": { "type": "string", "minLength": 1 },
          "domain": { "type": "string", "minLength": 1 },
          "owner_agent": { "type": "string", "enum": ["openclaw", "hermes", "nemotron"] },
          "status": { "type": "string", "minLength": 1 },
          "current_signal": { "type": "string", "minLength": 1 },
          "evidence_refs": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 }
          },
          "blocked_now": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 }
          },
          "next_action": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "drift_candidates": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "candidate_id",
          "domain",
          "severity",
          "status",
          "owner_agent",
          "summary",
          "evidence_refs",
          "next_owner_action"
        ],
        "properties": {
          "candidate_id": { "type": "string", "minLength": 1 },
          "domain": { "type": "string", "minLength": 1 },
          "severity": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
          "status": { "type": "string", "minLength": 1 },
          "owner_agent": { "type": "string", "enum": ["openclaw", "hermes", "nemotron"] },
          "summary": { "type": "string", "minLength": 1 },
          "evidence_refs": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 }
          },
          "next_owner_action": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "owner_actions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "action_id",
          "priority",
          "owner_agent",
          "approval_gate",
          "summary",
          "blocked_until"
        ],
        "properties": {
          "action_id": { "type": "string", "minLength": 1 },
          "priority": { "type": "string", "enum": ["P0", "P1", "P2", "P3"] },
          "owner_agent": { "type": "string", "enum": ["openclaw", "hermes", "nemotron"] },
          "approval_gate": { "type": "string", "minLength": 1 },
          "summary": { "type": "string", "minLength": 1 },
          "blocked_until": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "telegram_policy": {
      "type": "object",
      "required": [
        "status",
        "direct_send_allowed",
        "gateway_queue_write_allowed",
        "success_quiet",
        "failure_digest_after_approval",
        "draft_only_outputs"
      ],
      "properties": {
        "status": { "type": "string", "minLength": 1 },
        "direct_send_allowed": { "type": "boolean", "const": false },
        "gateway_queue_write_allowed": { "type": "boolean", "const": false },
        "success_quiet": { "type": "boolean" },
        "failure_digest_after_approval": { "type": "boolean" },
        "draft_only_outputs": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 }
        }
      },
      "additionalProperties": false
    },
    "agent_roles": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["agent_id", "role", "autonomy_level", "approval_gate", "outputs"],
        "properties": {
          "agent_id": { "type": "string", "enum": ["openclaw", "hermes", "nemotron"] },
          "role": { "type": "string", "minLength": 1 },
          "autonomy_level": { "type": "string", "minLength": 1 },
          "approval_gate": { "type": "string", "minLength": 1 },
          "outputs": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 }
          }
        },
        "additionalProperties": false
      }
    },
    "next_actions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["task_id", "priority", "summary", "gate"],
        "properties": {
          "task_id": { "type": "string", "minLength": 1 },
          "priority": { "type": "string", "enum": ["P0", "P1", "P2", "P3"] },
          "summary": { "type": "string", "minLength": 1 },
          "gate": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "monitor_boundaries": {
      "type": "object",
      "required": [
        "read_only_repo_monitor_allowed",
        "schedule_activation_allowed",
        "workflow_write_allowed",
        "external_cve_lookup_allowed",
        "external_license_lookup_allowed",
        "registry_lookup_allowed",
        "agent_market_external_lookup_allowed",
        "package_installation_allowed",
        "package_upgrade_allowed",
        "lockfile_write_allowed",
        "docker_build_allowed",
        "image_pull_allowed",
        "image_rebuild_allowed",
        "registry_push_allowed",
        "pr_creation_allowed",
        "telegram_send_allowed",
        "production_write_allowed",
        "paid_external_service_allowed",
        "secret_read_allowed",
        "host_probe_allowed",
        "npm_audit_allowed"
      ],
      "properties": {
        "read_only_repo_monitor_allowed": { "type": "boolean", "const": true },
        "schedule_activation_allowed": { "type": "boolean", "const": false },
        "workflow_write_allowed": { "type": "boolean", "const": false },
        "external_cve_lookup_allowed": { "type": "boolean", "const": false },
        "external_license_lookup_allowed": { "type": "boolean", "const": false },
        "registry_lookup_allowed": { "type": "boolean", "const": false },
        "agent_market_external_lookup_allowed": { "type": "boolean", "const": false },
        "package_installation_allowed": { "type": "boolean", "const": false },
        "package_upgrade_allowed": { "type": "boolean", "const": false },
        "lockfile_write_allowed": { "type": "boolean", "const": false },
        "docker_build_allowed": { "type": "boolean", "const": false },
        "image_pull_allowed": { "type": "boolean", "const": false },
        "image_rebuild_allowed": { "type": "boolean", "const": false },
        "registry_push_allowed": { "type": "boolean", "const": false },
        "pr_creation_allowed": { "type": "boolean", "const": false },
        "telegram_send_allowed": { "type": "boolean", "const": false },
        "production_write_allowed": { "type": "boolean", "const": false },
        "paid_external_service_allowed": { "type": "boolean", "const": false },
        "secret_read_allowed": { "type": "boolean", "const": false },
        "host_probe_allowed": { "type": "boolean", "const": false },
        "npm_audit_allowed": { "type": "boolean", "const": false }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
