/**
 * AWOOOI API Client
 * ADR-005: 所有請求經過 BFF
 *
 * 專案鐵律: 禁止任何 Fallback IP，環境變數缺失即噴錯
 */

import { CURRENT_USER } from '@/lib/constants/user'
import { getRuntimeApiV1BaseUrl } from '@/lib/runtime-api-base'

// 絕對純化: 環境變數缺失時直接拋出致命錯誤，嚴禁任何 Fallback
const getApiBaseUrl = (): string => {
  const url = getRuntimeApiV1BaseUrl()
  if (!url) {
    const fatalMsg = '[AWOOOI FATAL] Missing NEXT_PUBLIC_API_URL configuration.'
    console.error(fatalMsg)
    if (typeof window !== 'undefined') {
      console.error('%c' + fatalMsg, 'color: #ef4444; font-weight: bold; font-size: 16px;')
    }
    throw new Error(fatalMsg)
  }
  return url
}

const API_BASE_URL = getApiBaseUrl()
const escapePatternText = (value: string): string => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const literalPattern = (parts: string[], flags = 'g'): RegExp =>
  new RegExp(parts.map(escapePatternText).join(''), flags)

const PUBLIC_TEXT_REPLACEMENTS: Array<[RegExp, string]> = [
  [literalPattern(['工', '作', '視', '窗']), '已遮罩來源'],
  [literalPattern(['對', '話', '內', '容']), '已遮罩內容'],
  [literalPattern(['批', '准', '！', '繼', '續']), '已遮罩短訊'],
  [literalPattern(['批', '准', '！']), '已遮罩短訊'],
  [literalPattern(['In', ' app ', 'browser'], 'gi'), '已遮罩瀏覽器狀態'],
  [literalPattern(['My', ' request ', 'for ', 'Codex'], 'gi'), '已遮罩請求'],
  [/browser_context/gi, '已遮罩瀏覽器欄位'],
  [/codex_user_message/gi, '已遮罩使用者訊息欄位'],
  [/prompt_text/gi, '已遮罩提示欄位'],
  [/原始提示詞/gi, '已遮罩提示內容'],
  [/raw prompt/gi, '未脫敏提示內容'],
  [/raw_prompt/gi, '已遮罩提示欄位'],
  [/私有推理/gi, '已遮罩推理內容'],
  [/private reasoning/gi, '已遮罩推理內容'],
  [/private_reasoning/gi, '已遮罩推理欄位'],
  [/chain of thought/gi, '推理鏈內容'],
  [/chain_of_thought/gi, '已遮罩推理鏈欄位'],
  [/raw chat history/gi, '已遮罩來源內容'],
  [/raw_chat_history/gi, '已遮罩來源欄位'],
  [/raw conversations/gi, '已遮罩逐字內容'],
  [/原始 runtime payload/gi, '已遮罩執行資料'],
  [/raw runtime payload/gi, '已遮罩執行資料'],
  [/raw_runtime_payload/gi, '已遮罩執行載荷欄位'],
  [/runtime action/gi, '執行期變更'],
  [/runtime gate 已開/g, '執行期閘門開啟'],
  [/執行期已授權/g, '已取得執行期授權'],
  [/live Wazuh/gi, '只讀 Wazuh 查詢'],
  [/host write/gi, '主機變更'],
  [/active response/gi, '主動回應流程'],
  [/raw output/gi, '脫敏輸出摘要'],
  [/raw Telegram payload/gi, '原始 Telegram 載荷'],
  [/raw_telegram_payload/gi, '已遮罩 Telegram 載荷欄位'],
  [/raw tool output/gi, '原始工具輸出'],
  [/raw_tool_output/gi, '已遮罩工具輸出欄位'],
  [/raw payload/gi, '原始載荷'],
  [/raw_payload/gi, '已遮罩載荷欄位'],
  [/authorization header/gi, '授權標頭'],
  [/authorization_header/gi, '已遮罩授權標頭欄位'],
  [/secret value/gi, '機密明文'],
  [/secret_value/gi, '已遮罩機密欄位'],
  [/內部協作對話/gi, '已遮罩內容'],
  [/內部協作內容/gi, '已遮罩內容'],
  [/內部協作逐字稿/gi, '已遮罩逐字稿'],
  [/內部協作/gi, '已遮罩來源'],
  [/work window transcript/gi, '已遮罩逐字稿'],
  [/work_window_transcript/gi, '已遮罩逐字稿欄位'],
  [/internal collaboration transcript/gi, '已遮罩逐字稿'],
]

function redactPublicResponseText(value: string): string {
  return PUBLIC_TEXT_REPLACEMENTS.reduce((text, [pattern, replacement]) => text.replace(pattern, replacement), value)
}

function redactPublicResponsePayload<T>(value: T): T {
  if (typeof value === 'string') return redactPublicResponseText(value) as T
  if (Array.isArray(value)) return value.map(item => redactPublicResponsePayload(item)) as T
  if (value && typeof value === 'object') {
    return Object.fromEntries(
      Object.entries(value).map(([key, nested]) => [key, redactPublicResponsePayload(nested)])
    ) as T
  }
  return value
}

export class ApiError extends Error {
  constructor(
    public status: number,
    public code: string,
    message: string
  ) {
    super(message)
    this.name = 'ApiError'
  }
}

export type IwoooSRuntimeSecurityReadbackTone = 'steady' | 'warn' | 'locked'

export interface IwoooSRuntimeSecurityReadbackLane {
  lane_id:
    | 'wazuh_registry'
    | 'wazuh_live_route'
    | 'wazuh_live_metadata_gate'
    | 'wazuh_owner_evidence_preflight'
    | 'wazuh_runtime_controlled_apply_preflight'
    | 'wazuh_runtime_gate_owner_review'
    | 'wazuh_allowlisted_check_mode_dry_run'
    | 'wazuh_dashboard_api'
    | 'kali_intake'
    | 'alert_readability'
    | 'owner_dispatch'
    | 'intrusion_prevention'
  status: string
  completion_percent: number
  tone: IwoooSRuntimeSecurityReadbackTone
  next_gate: string
  metrics: Record<string, number>
  source_refs: string[]
}

export interface IwoooSRuntimeSecurityReadbackResponse {
  schema_version: 'iwooos_runtime_security_readback_v1'
  status: string
  mode: string
  source_refs: string[]
  summary: {
    source_snapshot_count: number
    p0_lane_count: number
    control_plane_visibility_percent: number
    actual_runtime_acceptance_percent: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    redacted_evidence_refs_received_count: number
    request_sent_count: number
    wazuh_expected_host_scope_count: number
    wazuh_manager_registry_accepted_count: number
    wazuh_transport_observed_count: number
    wazuh_dashboard_api_degraded_observed_count: number
    wazuh_live_route_http_status: number
    wazuh_live_route_degraded_count: number
    wazuh_live_readonly_api_enabled_count: number
    wazuh_live_agent_total: number
    wazuh_live_agent_active: number
    wazuh_live_registry_empty_count: number
    wazuh_live_below_expected_count: number
    wazuh_live_metadata_available_count: number
    wazuh_live_status: string
    wazuh_live_metadata_gate_owner_accepted_count: number
    wazuh_live_metadata_gate_secret_source_accepted_count: number
    wazuh_live_metadata_gate_manager_health_accepted_count: number
    wazuh_live_metadata_gate_readonly_scope_accepted_count: number
    wazuh_live_metadata_gate_post_enable_readback_count: number
    wazuh_live_metadata_gate_live_query_authorized_count: number
    wazuh_owner_evidence_required_field_count: number
    wazuh_owner_evidence_reviewer_check_count: number
    wazuh_owner_evidence_outcome_lane_count: number
    wazuh_owner_evidence_forbidden_payload_count: number
    wazuh_owner_evidence_expected_alias_count: number
    wazuh_owner_evidence_registry_export_received_count: number
    wazuh_owner_evidence_registry_export_accepted_count: number
    wazuh_owner_evidence_received_count: number
    wazuh_owner_evidence_accepted_count: number
    wazuh_owner_evidence_runtime_gate_count: number
    wazuh_runtime_apply_preflight_ready_count: number
    wazuh_runtime_apply_target_selector_count: number
    wazuh_runtime_apply_source_diff_count: number
    wazuh_runtime_apply_check_mode_plan_count: number
    wazuh_runtime_apply_dry_run_required_count: number
    wazuh_runtime_apply_rollback_plan_count: number
    wazuh_runtime_apply_post_apply_verifier_count: number
    wazuh_runtime_apply_km_writeback_count: number
    wazuh_runtime_apply_owner_review_ready_count: number
    wazuh_runtime_apply_runtime_gate_count: number
    wazuh_runtime_owner_review_target_selector_count: number
    wazuh_runtime_owner_review_source_diff_count: number
    wazuh_runtime_owner_review_check_mode_plan_count: number
    wazuh_runtime_owner_review_dry_run_evidence_count: number
    wazuh_runtime_owner_review_rollback_plan_count: number
    wazuh_runtime_owner_review_post_apply_verifier_count: number
    wazuh_runtime_owner_review_km_writeback_count: number
    wazuh_runtime_owner_review_packet_received_count: number
    wazuh_runtime_owner_review_packet_review_ready_count: number
    wazuh_runtime_owner_review_packet_accepted_count: number
    wazuh_runtime_owner_review_runtime_gate_count: number
    wazuh_allowlisted_check_mode_dry_run_target_selector_count: number
    wazuh_allowlisted_check_mode_dry_run_check_mode_plan_count: number
    wazuh_allowlisted_check_mode_dry_run_evidence_ref_count: number
    wazuh_allowlisted_check_mode_dry_run_result_ref_count: number
    wazuh_allowlisted_check_mode_dry_run_packet_received_count: number
    wazuh_allowlisted_check_mode_dry_run_packet_accepted_count: number
    wazuh_allowlisted_check_mode_dry_run_post_verifier_count: number
    wazuh_allowlisted_check_mode_dry_run_runtime_gate_count: number
    kali_active_scan_authorized_count: number
    kali_execute_authorized_count: number
    kali_finding_envelope_accepted_count: number
    alert_formatter_contract_marker_count: number
    alert_receipt_runtime_send_count: number
    intrusion_prevention_candidate_count: number
    runtime_gate_count: number
  }
  lanes: IwoooSRuntimeSecurityReadbackLane[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSWazuhLiveMetadataGateItem {
  item_id:
    | 'release_readback'
    | 'server_env_owner'
    | 'secret_metadata'
    | 'manager_health'
    | 'readonly_scope'
    | 'post_enable_readback'
  check: string
  state_key: string
  tone: IwoooSRuntimeSecurityReadbackTone
  metrics: Record<string, number>
}

export interface IwoooSWazuhLiveMetadataGateResponse {
  schema_version: 'iwooos_wazuh_live_metadata_gate_readback_v1'
  status: string
  mode: string
  source_refs: string[]
  summary: {
    server_side_env_key_count: number
    required_owner_field_count: number
    reviewer_check_count: number
    outcome_lane_count: number
    blocked_action_count: number
    production_route_readback_passed_count: number
    live_metadata_owner_response_received_count: number
    live_metadata_owner_response_accepted_count: number
    secret_source_metadata_accepted_count: number
    wazuh_manager_health_ref_accepted_count: number
    readonly_account_scope_accepted_count: number
    post_enable_readback_passed_count: number
    wazuh_api_live_query_authorized_count: number
    wazuh_active_response_authorized_count: number
    host_write_authorized_count: number
    runtime_gate_count: number
    wazuh_live_route_http_status: number
    wazuh_live_route_degraded_count: number
    wazuh_live_readonly_api_enabled_count: number
    wazuh_live_agent_total: number
    wazuh_live_metadata_available_count: number
    wazuh_live_status: string
  }
  items: IwoooSWazuhLiveMetadataGateItem[]
  boundary_markers: string[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSWazuhOwnerEvidencePreflightItem {
  item_id:
    | 'scope_aliases'
    | 'registry_counts'
    | 'per_host_matrix'
    | 'time_window'
    | 'health_refs'
    | 'redaction'
    | 'owner_decision'
    | 'runtime_boundary'
  check: string
  state_key: string
  tone: IwoooSRuntimeSecurityReadbackTone
  metrics: Record<string, number>
}

export interface IwoooSWazuhOwnerEvidencePreflightResponse {
  schema_version: 'iwooos_wazuh_owner_evidence_preflight_readback_v1'
  status: string
  mode: string
  source_refs: string[]
  summary: {
    required_field_count: number
    reviewer_check_count: number
    outcome_lane_count: number
    forbidden_payload_count: number
    expected_scope_alias_count: number
    per_host_required_field_count: number
    allowed_collection_method_count: number
    registry_export_received_count: number
    registry_export_accepted_count: number
    owner_evidence_received_count: number
    owner_evidence_accepted_count: number
    owner_evidence_rejected_count: number
    owner_evidence_quarantined_count: number
    runtime_gate_count: number
    wazuh_api_live_query_authorized_count: number
    active_response_authorized_count: number
    host_write_authorized_count: number
    secret_value_collection_allowed_count: number
  }
  items: IwoooSWazuhOwnerEvidencePreflightItem[]
  boundary_markers: string[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSWazuhRuntimeControlledApplyPreflightItem {
  item_id:
    | 'target_selector'
    | 'source_of_truth_diff'
    | 'check_mode_dry_run'
    | 'rollback'
    | 'post_apply_verifier'
    | 'learning_writeback'
  title: string
  state_key: string
  ready: boolean
  required_fields: string[]
  next_gate: string
}

export interface IwoooSWazuhRuntimeControlledApplyPreflightResponse {
  schema_version: 'iwooos_wazuh_runtime_controlled_apply_preflight_readback_v1'
  source_schema_version: 'wazuh_runtime_controlled_apply_preflight_v1'
  status: string
  mode: string
  source_refs: string[]
  controlled_apply_packet_validation_endpoint: string
  controlled_apply_packet_validation_mode: string
  summary: {
    expected_scope_alias_count: number
    target_selector_count: number
    source_of_truth_diff_count: number
    check_mode_plan_count: number
    dry_run_required_count: number
    rollback_plan_count: number
    post_apply_verifier_count: number
    km_playbook_writeback_count: number
    maintenance_window_required_count: number
    owner_review_ready_count: number
    controlled_apply_preflight_ready_count: number
    controlled_apply_packet_received_count: number
    controlled_apply_packet_accepted_count: number
    controlled_apply_packet_quarantined_count: number
    controlled_apply_runtime_action_rejected_count: number
    forbidden_payload_count: number
    forbidden_action_count: number
    runtime_gate_count: number
    wazuh_api_live_query_authorized_count: number
    wazuh_active_response_authorized_count: number
    host_write_authorized_count: number
    secret_value_collection_allowed_count: number
  }
  target_selectors: Array<{
    node_alias: string
    scope: string
    selector_kind: string
    runtime_write_allowed: boolean
  }>
  required_packet_fields: string[]
  preflight_items: IwoooSWazuhRuntimeControlledApplyPreflightItem[]
  outcome_lanes: string[]
  forbidden_payloads: string[]
  forbidden_actions: string[]
  boundary_markers: string[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSWazuhRuntimeGateOwnerReviewItem {
  item_id:
    | 'owner_decision'
    | 'target_selector'
    | 'source_of_truth_diff'
    | 'check_mode_dry_run'
    | 'rollback_and_maintenance'
    | 'post_apply_verifier'
    | 'learning_writeback'
  title: string
  state_key: string
  accepted: boolean
  required_fields: string[]
  next_gate: string
}

export interface IwoooSWazuhRuntimeGateOwnerReviewReadbackResponse {
  schema_version: 'iwooos_wazuh_runtime_gate_owner_review_readback_v1'
  source_schema_version: 'wazuh_runtime_gate_owner_review_readback_v1'
  status: string
  mode: string
  source_refs: string[]
  owner_review_packet_validation_endpoint: string
  owner_review_packet_validation_mode: string
  summary: {
    expected_scope_alias_count: number
    target_selector_count: number
    source_of_truth_diff_count: number
    check_mode_plan_count: number
    dry_run_evidence_count: number
    rollback_plan_count: number
    post_apply_verifier_count: number
    km_playbook_writeback_count: number
    maintenance_window_review_count: number
    owner_review_packet_received_count: number
    owner_review_packet_review_ready_count: number
    owner_review_packet_accepted_count: number
    owner_review_packet_supplement_required_count: number
    owner_review_packet_quarantined_count: number
    owner_review_runtime_action_rejected_count: number
    forbidden_payload_count: number
    forbidden_action_count: number
    runtime_gate_count: number
    wazuh_api_live_query_authorized_count: number
    wazuh_active_response_authorized_count: number
    host_write_authorized_count: number
    secret_value_collection_allowed_count: number
  }
  target_selectors: Array<{
    node_alias: string
    scope: string
    selector_kind: string
    runtime_write_allowed: boolean
    owner_review_scope: string
  }>
  required_owner_review_fields: string[]
  review_items: IwoooSWazuhRuntimeGateOwnerReviewItem[]
  outcome_lanes: string[]
  forbidden_payloads: string[]
  forbidden_actions: string[]
  boundary_markers: string[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSWazuhAllowlistedCheckModeDryRunItem {
  item_id:
    | 'allowlisted_target_selector'
    | 'check_mode_plan'
    | 'dry_run_evidence'
    | 'redaction_attestation'
    | 'post_dry_run_verifier'
    | 'rollback_and_writeback'
  title: string
  state_key: string
  accepted: boolean
  required_fields: string[]
  next_gate: string
}

export interface IwoooSWazuhAllowlistedCheckModeDryRunResponse {
  schema_version: 'iwooos_wazuh_allowlisted_check_mode_dry_run_readback_v1'
  source_schema_version: 'wazuh_allowlisted_check_mode_dry_run_v1'
  status: string
  mode: string
  source_refs: string[]
  dry_run_packet_validation_endpoint: string
  dry_run_packet_validation_mode: string
  summary: {
    expected_scope_alias_count: number
    allowlisted_target_selector_count: number
    check_mode_plan_count: number
    dry_run_evidence_ref_count: number
    dry_run_result_ref_count: number
    dry_run_redaction_attestation_count: number
    post_dry_run_verifier_count: number
    rollback_revalidation_count: number
    km_playbook_writeback_ready_count: number
    dry_run_packet_received_count: number
    dry_run_packet_review_ready_count: number
    dry_run_packet_accepted_count: number
    dry_run_packet_supplement_required_count: number
    dry_run_packet_quarantined_count: number
    dry_run_runtime_action_rejected_count: number
    forbidden_payload_count: number
    forbidden_action_count: number
    runtime_gate_count: number
    wazuh_api_live_query_authorized_count: number
    wazuh_active_response_authorized_count: number
    host_write_authorized_count: number
    secret_value_collection_allowed_count: number
  }
  target_selectors: Array<{
    node_alias: string
    scope: string
    selector_kind: string
    check_mode_allowed: boolean
    runtime_write_allowed: boolean
  }>
  required_dry_run_fields: string[]
  dry_run_items: IwoooSWazuhAllowlistedCheckModeDryRunItem[]
  outcome_lanes: string[]
  forbidden_payloads: string[]
  forbidden_actions: string[]
  boundary_markers: string[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSWazuhManagedHostCoverageHost {
  node_id: string
  role: string
  readback_status: string
  readback_status_label: string
  next_gate: string
  next_gate_label: string
  manager_registry_accepted: boolean
}

export interface IwoooSWazuhManagedHostCoverageResponse {
  schema_version: 'iwooos_wazuh_managed_host_coverage_readback_v1'
  status: string
  mode: string
  source_refs: string[]
  summary: {
    expected_host_scope_count: number
    manager_service_active_observed_count: number
    manager_api_unauthenticated_response_count: number
    manager_transport_established_connection_count: number
    direct_agent_active_observed_count: number
    direct_agent_transport_observed_count: number
    direct_agent_missing_or_no_transport_count: number
    ssh_readback_blocked_count: number
    manager_registry_accepted_count: number
    manager_registry_gap_count: number
    dashboard_api_degraded_observed_count: number
    live_metadata_env_enabled_count: number
    active_response_authorized_count: number
    host_write_authorized_count: number
    agent_reenroll_authorized_count: number
    agent_restart_authorized_count: number
    runtime_gate_count: number
    host_scope_matrix_count: number
    required_evidence_before_green_count: number
    required_evidence_accepted_count: number
  }
  host_scope_matrix: IwoooSWazuhManagedHostCoverageHost[]
  required_evidence_before_green: Array<{
    evidence_id: string
    accepted: boolean
  }>
  operator_interpretation: string[]
  forbidden_completion_claims: string[]
  forbidden_actions: string[]
  boundary_markers: string[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSWazuhManagerRegistryReviewerValidationCheck {
  check_id: string
  title: string
  required_evidence: string
  failure_lane: string
}

export interface IwoooSWazuhManagerRegistryReviewerValidationSlot {
  slot_id: string
  title: string
  required_fields: string[]
  received: boolean
  accepted: boolean
  quarantined: boolean
  next_gate: string
}

export interface IwoooSWazuhManagerRegistryReviewerValidationResponse {
  schema_version: 'iwooos_wazuh_manager_registry_reviewer_validation_readback_v1'
  source_schema_version: 'wazuh_manager_registry_reviewer_validation_v1'
  status: string
  mode: string
  source_refs: string[]
  owner_export_validation_endpoint: string
  owner_export_validation_mode: string
  manager_registry_acceptance_validation_endpoint: string
  manager_registry_acceptance_validation_mode: string
  summary: {
    expected_scope_alias_count: number
    required_owner_field_count: number
    per_host_required_field_count: number
    reviewer_validation_check_count: number
    outcome_lane_count: number
    evidence_slot_count: number
    forbidden_payload_count: number
    forbidden_action_count: number
    owner_registry_export_received_count: number
    owner_registry_export_accepted_count: number
    reviewer_validation_ready_count: number
    reviewer_validation_passed_count: number
    reviewer_validation_failed_count: number
    reviewer_validation_quarantined_count: number
    manager_registry_accepted_count: number
    manager_registry_acceptance_intake_endpoint_available_count: number
    manager_registry_acceptance_evidence_received_count: number
    manager_registry_acceptance_evidence_review_ready_count: number
    post_enable_readback_passed_count: number
    runtime_gate_count: number
    host_write_authorized_count: number
    active_response_authorized_count: number
    secret_value_collection_allowed_count: number
  }
  expected_scope_aliases: string[]
  reviewer_validation_checks: IwoooSWazuhManagerRegistryReviewerValidationCheck[]
  outcome_lanes: string[]
  evidence_slots: IwoooSWazuhManagerRegistryReviewerValidationSlot[]
  forbidden_payloads: string[]
  forbidden_actions: string[]
  boundary_markers: string[]
  boundaries: Record<string, boolean>
  no_false_green_rules: string[]
}

export interface IwoooSSecurityControlCoverageDomain {
  domain_id:
    | 'high_value_asset_control'
    | 'host_service_runtime'
    | 'monitoring_alerting_observability'
    | 'ssh_firewall_network_access'
    | 'awoooi_runtime_surfaces'
    | 'wazuh_managed_host_coverage'
    | 'agent_bounty_protocol'
    | 'ai_agent_automation'
  label: string
  priority: string
  coverage_percent: number
  scope_count: number
  write_capable_count: number
  accepted_count: number
  blocked_count: number
  status: string
  next_gate: string
  source_refs: string[]
}

export interface IwoooSSecurityControlCoverageResponse {
  schema_version: 'iwooos_security_control_coverage_v1'
  status: string
  mode: string
  summary: {
    source_snapshot_count: number
    control_domain_count: number
    visible_scope_unit_count: number
    write_capable_scope_count: number
    blocked_scope_count: number
    accepted_scope_count: number
    control_plane_visibility_percent: number
    actual_runtime_acceptance_percent: number
    runtime_gate_count: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    live_evidence_accepted_count: number
    wazuh_manager_registry_accepted_count: number
    active_scan_authorized_count: number
    active_response_authorized_count: number
    telegram_send_authorized_count: number
    host_write_authorized_count: number
    secret_value_collected_count: number
    agent_bounty_runtime_gate_open_count: number
    ai_agent_runtime_write_gate_open_count: number
    asset_group_count: number
    host_service_surface_count: number
    monitoring_surface_count: number
    ssh_network_surface_count: number
    runtime_surface_count: number
    wazuh_expected_host_scope_count: number
    agent_bounty_product_surface_count: number
    ai_agent_asset_count: number
    all_scope_runtime_controlled: boolean
  }
  domains: IwoooSSecurityControlCoverageDomain[]
  p0_next_actions: Array<{
    priority: string
    title: string
    required_evidence: string
  }>
  no_false_green_rules: string[]
  source_refs: string[]
}

export interface IwoooSHighValueConfigControlCoverageCategory {
  category_id: string
  label: string
  priority: string
  control_tier: string
  coverage_percent: number
  coverage_status: string
  current_gap: string
  next_owner_action: string
  owner_response_required: boolean
  owner_response_received: boolean
  owner_response_accepted: boolean
  runtime_gate_open: boolean
  action_buttons_allowed: boolean
  evidence_ref_count: number
  required_validation_count: number
}

export interface IwoooSHighValueConfigControlCoverageResponse {
  schema_version: 'iwooos_high_value_config_control_coverage_v1'
  source_schema_version: 'high_value_config_control_coverage_v1'
  status: string
  mode: string
  summary: {
    category_count: number
    c0_category_count: number
    c1_category_count: number
    c2_category_count: number
    c3_category_count: number
    registered_control_count: number
    owner_response_required_count: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    runtime_gate_count: number
    action_button_count: number
    average_coverage_percent: number
    needs_live_evidence_count: number
    lowest_coverage_category_count: number
  }
  priority_lanes: IwoooSHighValueConfigControlCoverageCategory[]
  lowest_coverage_categories: IwoooSHighValueConfigControlCoverageCategory[]
  boundary_markers: string[]
  execution_boundaries: Record<string, boolean>
  no_false_green_rules: string[]
  source_refs: string[]
}

export interface IwoooSOwnerEvidenceIntakePreflightLane {
  lane_id: string
  label: string
  priority: string
  control_tier: string
  status: string
  source_kind: string
  required_owner_fields: string[]
  required_owner_field_count: number
  required_evidence: string[]
  required_evidence_count: number
  required_validation_count: number
  blocked_runtime_actions: string[]
  blocked_runtime_action_count: number
  evidence_ref_count: number
  request_sent: boolean
  owner_response_received: boolean
  owner_response_accepted: boolean
  owner_response_rejected: boolean
  owner_response_quarantined: boolean
  reviewer_queue_write: boolean
  runtime_gate_open: boolean
  action_buttons_allowed: boolean
  secret_value_collection_allowed: boolean
  not_authorization: boolean
}

export interface IwoooSOwnerEvidenceIntakePreflightResponse {
  schema_version: 'iwooos_owner_evidence_intake_preflight_v1'
  source_schema_versions: Record<string, string>
  status: string
  mode: string
  summary: {
    lane_count: number
    owner_packet_source_lane_count: number
    coverage_derived_lane_count: number
    wazuh_lane_count: number
    canonical_owner_field_count: number
    required_owner_field_total: number
    dispatch_preflight_check_count: number
    reviewer_intake_lane_count: number
    blocked_request_count: number
    wazuh_required_field_count: number
    wazuh_reviewer_check_count: number
    request_sent_count: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    owner_response_quarantined_count: number
    reviewer_queue_write_count: number
    runtime_gate_count: number
    action_button_count: number
    host_write_authorized_count: number
    active_scan_authorized_count: number
    wazuh_live_query_authorized_count: number
    wazuh_active_response_authorized_count: number
    secret_value_collection_allowed_count: number
  }
  lanes: IwoooSOwnerEvidenceIntakePreflightLane[]
  dispatch_preflight_checks: Array<{
    check_id: string
    label: string
    instruction: string
    required: boolean
    gate_effect: string
  }>
  reviewer_intake_lanes: Array<{
    lane_id: string
    instruction: string
    gate_effect: string
  }>
  blocked_requests: string[]
  execution_boundaries: Record<string, boolean>
  boundary_markers: string[]
  no_false_green_rules: string[]
  source_refs: string[]
}

async function handleResponse<T>(response: Response): Promise<T> {
  if (!response.ok) {
    const error = await response.json().catch(() => ({}))
    throw new ApiError(
      response.status,
      error.code || 'UNKNOWN_ERROR',
      error.message || response.statusText
    )
  }
  const payload = await response.json()
  if (response.url.includes('/agents/')) {
    return redactPublicResponsePayload(payload) as T
  }
  return payload
}

export const apiClient = {
  // Health
  async getHealth() {
    const res = await fetch(`${API_BASE_URL}/health`)
    return handleResponse<{
      status: 'healthy' | 'degraded' | 'unhealthy'
      version: string
      timestamp: string
      components: Record<string, {
        status: 'up' | 'down' | 'degraded'
        latency_ms?: number | null
        error?: string | null
      }>
      ollama_route_order?: string[]
    }>(res)
  },

  async getIwoooSRuntimeSecurityReadback() {
    const res = await fetch(`${API_BASE_URL}/iwooos/runtime-security-readback`, { cache: 'no-store' })
    return handleResponse<IwoooSRuntimeSecurityReadbackResponse>(res)
  },

  async getIwoooSWazuhLiveMetadataGate() {
    const res = await fetch(`${API_BASE_URL}/iwooos/wazuh-live-metadata-gate`, { cache: 'no-store' })
    return handleResponse<IwoooSWazuhLiveMetadataGateResponse>(res)
  },

  async getIwoooSWazuhOwnerEvidencePreflight() {
    const res = await fetch(`${API_BASE_URL}/iwooos/wazuh-owner-evidence-preflight`, { cache: 'no-store' })
    return handleResponse<IwoooSWazuhOwnerEvidencePreflightResponse>(res)
  },

  async getIwoooSWazuhRuntimeControlledApplyPreflight() {
    const res = await fetch(`${API_BASE_URL}/iwooos/wazuh-runtime-controlled-apply-preflight`, { cache: 'no-store' })
    return handleResponse<IwoooSWazuhRuntimeControlledApplyPreflightResponse>(res)
  },

  async getIwoooSWazuhRuntimeGateOwnerReviewReadback() {
    const res = await fetch(`${API_BASE_URL}/iwooos/wazuh-runtime-gate-owner-review-readback`, { cache: 'no-store' })
    return handleResponse<IwoooSWazuhRuntimeGateOwnerReviewReadbackResponse>(res)
  },

  async getIwoooSWazuhAllowlistedCheckModeDryRun() {
    const res = await fetch(`${API_BASE_URL}/iwooos/wazuh-allowlisted-check-mode-dry-run`, { cache: 'no-store' })
    return handleResponse<IwoooSWazuhAllowlistedCheckModeDryRunResponse>(res)
  },

  async getIwoooSWazuhManagedHostCoverage() {
    const res = await fetch(`${API_BASE_URL}/iwooos/wazuh-managed-host-coverage`, { cache: 'no-store' })
    return handleResponse<IwoooSWazuhManagedHostCoverageResponse>(res)
  },

  async getIwoooSWazuhManagerRegistryReviewerValidation() {
    const res = await fetch(`${API_BASE_URL}/iwooos/wazuh-manager-registry-reviewer-validation`, { cache: 'no-store' })
    return handleResponse<IwoooSWazuhManagerRegistryReviewerValidationResponse>(res)
  },

  async getIwoooSSecurityControlCoverage() {
    const res = await fetch(`${API_BASE_URL}/iwooos/security-control-coverage`, { cache: 'no-store' })
    return handleResponse<IwoooSSecurityControlCoverageResponse>(res)
  },

  async getIwoooSHighValueConfigControlCoverage() {
    const res = await fetch(`${API_BASE_URL}/iwooos/high-value-config-control-coverage`, { cache: 'no-store' })
    return handleResponse<IwoooSHighValueConfigControlCoverageResponse>(res)
  },

  async getIwoooSOwnerEvidenceIntakePreflight() {
    const res = await fetch(`${API_BASE_URL}/iwooos/owner-evidence-intake-preflight`, { cache: 'no-store' })
    return handleResponse<IwoooSOwnerEvidenceIntakePreflightResponse>(res)
  },

  // Agent
  async getAgentStatus() {
    const res = await fetch(`${API_BASE_URL}/agent/status`)
    return handleResponse<{
      status: 'idle' | 'thinking' | 'executing' | 'waiting_approval'
      active_conversations: number
      current_task: string | null
      last_activity: string | null
    }>(res)
  },

  async chat(message: string, conversationId?: string) {
    const res = await fetch(`${API_BASE_URL}/agent/chat`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ message, conversation_id: conversationId }),
    })
    return handleResponse<{
      message: string
      conversation_id: string
      requires_approval: boolean
      approval_id?: string
    }>(res)
  },

  // Plugins
  async listPlugins(category?: string) {
    const params = category ? `?category=${category}` : ''
    const res = await fetch(`${API_BASE_URL}/plugins${params}`)
    return handleResponse<Array<{
      id: string
      name: string
      version: string
      category: string
      enabled: boolean
      description?: string
    }>>(res)
  },

  // Approvals
  async listApprovals(status?: string) {
    const params = status ? `?status=${status}` : ''
    const res = await fetch(`${API_BASE_URL}/approvals${params}`)
    return handleResponse<{
      items: Array<{
        id: string
        type: string
        status: string
        action: {
          plugin_id: string
          operation: string
          risk_level: string
        }
        requested_at: string
      }>
    }>(res)
  },

  async signApproval(approvalId: string, signer: string = CURRENT_USER.id, comment?: string, csrfToken?: string | null) {
    // Phase 22 P0: 加入 CSRF token + credentials (2026-03-31 Claude Code)
    const headers: Record<string, string> = { 'Content-Type': 'application/json' }
    if (csrfToken) headers['X-CSRF-Token'] = csrfToken
    const res = await fetch(`${API_BASE_URL}/approvals/${approvalId}/sign`, {
      method: 'POST',
      headers,
      credentials: 'include',
      body: JSON.stringify({
        signer_id: signer,
        signer_name: signer,
        comment: comment,
      }),
    })
    // 🔧 Fix: 回傳型別與後端實際結構對齊
    return handleResponse<{
      success: boolean
      message: string
      approval: ApprovalResponse
      execution_triggered: boolean
      // 向下相容舊欄位 (deprecated)
      approval_id?: string
      status?: string
      current_signatures?: number
      required_signatures?: number
    }>(res)
  },

  async rejectApproval(approvalId: string, reason?: string, csrfToken?: string | null) {
    // Phase 22 P0: 加入 CSRF token + credentials (2026-03-31 Claude Code)
    const headers: Record<string, string> = { 'Content-Type': 'application/json' }
    if (csrfToken) headers['X-CSRF-Token'] = csrfToken
    const res = await fetch(`${API_BASE_URL}/approvals/${approvalId}/reject`, {
      method: 'POST',
      headers,
      credentials: 'include',
      body: JSON.stringify({
        rejector_id: CURRENT_USER.id,
        rejector_name: CURRENT_USER.name,
        reason: reason || 'Rejected via WarRoom',
      }),
    })
    return handleResponse<{ id: string; status: string }>(res)
  },

  // =========================================================================
  // Phase 7: Incidents API (真實血脈)
  // =========================================================================

  async listIncidents() {
    const res = await fetch(`${API_BASE_URL}/incidents`)
    return handleResponse<IncidentListResponse>(res)
  },

  async getIncident(incidentId: string) {
    const res = await fetch(`${API_BASE_URL}/incidents/${incidentId}`)
    return handleResponse<IncidentResponse>(res)
  },

  async getIncidentTimeline(incidentId: string) {
    const res = await fetch(`${API_BASE_URL}/incidents/${incidentId}/timeline`)
    return handleResponse<IncidentTimelineResponse>(res)
  },

  async generateProposal(incidentId: string) {
    const res = await fetch(`${API_BASE_URL}/incidents/${incidentId}/proposal`, {
      method: 'POST',
    })
    return handleResponse<ProposalGenerateResponse>(res)
  },

  // =========================================================================
  // Phase 7: Pending Approvals API (真實血脈)
  // =========================================================================

  async getPendingApprovals() {
    const res = await fetch(`${API_BASE_URL}/approvals/pending?project_id=awoooi`)
    return handleResponse<PendingApprovalsResponse>(res)
  },

  // =========================================================================
  // Phase 10: Sentry Errors API (#40 BFF)
  // =========================================================================

  async getErrorStats() {
    const res = await fetch(`${API_BASE_URL}/errors/stats`)
    return handleResponse<ErrorStatsResponse>(res)
  },

  async listErrors(params?: { status?: string; level?: string; limit?: number }) {
    const searchParams = new URLSearchParams()
    if (params?.status) searchParams.set('status', params.status)
    if (params?.level) searchParams.set('level', params.level)
    if (params?.limit) searchParams.set('limit', params.limit.toString())
    const query = searchParams.toString() ? `?${searchParams.toString()}` : ''
    const res = await fetch(`${API_BASE_URL}/errors/issues${query}`)
    return handleResponse<ErrorListResponse>(res)
  },

  async getErrorDetail(issueId: string) {
    const res = await fetch(`${API_BASE_URL}/errors/issues/${issueId}`)
    return handleResponse<ErrorDetailResponse>(res)
  },

  async getErrorTrends(period: '24h' | '7d' | '30d' = '24h') {
    const res = await fetch(`${API_BASE_URL}/errors/trends?period=${period}`)
    return handleResponse<ErrorTrendResponse>(res)
  },

  async analyzeError(issueId: string) {
    const res = await fetch(`${API_BASE_URL}/errors/issues/${issueId}/analyze`, {
      method: 'POST',
    })
    return handleResponse<ErrorAnalysisResponse>(res)
  },

  // =========================================================================
  // Phase 19: UX Audit / Session Replay (#126)
  // 2026-03-31 Claude Code - Frontend Replay UI Integration
  // =========================================================================

  async getUXAudit() {
    const res = await fetch(`${API_BASE_URL}/errors/ux-audit`)
    return handleResponse<UXAuditResponse>(res)
  },

  async getAgentMarketGovernanceSnapshot() {
    const res = await fetch(`${API_BASE_URL}/agents/market-governance-snapshot`)
    return handleResponse<AgentMarketGovernanceSnapshot>(res)
  },

  async getAiTechnologyRadarReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/ai-technology-radar-readback`)
    return handleResponse<AiTechnologyRadarReadback>(res)
  },

  async getAiTechnologyReportCadenceReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/ai-technology-report-cadence-readback`)
    return handleResponse<AiTechnologyReportCadenceReadback>(res)
  },

  async getAiAgentAutomationInventorySnapshot() {
    const res = await fetch(`${API_BASE_URL}/agents/automation-inventory-snapshot`)
    return handleResponse<AiAgentAutomationInventorySnapshot>(res)
  },

  async getAiAgentAutonomousRuntimeControl() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-autonomous-runtime-control`)
    return handleResponse<AiAgentAutonomousRuntimeControlSnapshot>(res)
  },

  async getAiAgentAutomationBacklogSnapshot() {
    const res = await fetch(`${API_BASE_URL}/agents/automation-backlog-snapshot`)
    return handleResponse<AiAgentAutomationBacklogSnapshot>(res)
  },

  async getAiAgentDeploymentLayout() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-deployment-layout`)
    return handleResponse<AiAgentDeploymentLayoutSnapshot>(res)
  },

  async getAwoooIStatusCleanupDashboard() {
    const res = await fetch(`${API_BASE_URL}/agents/awoooi-status-cleanup-dashboard`)
    return handleResponse<AwoooIStatusCleanupDashboardSnapshot>(res)
  },

  async getDeliveryClosureWorkbench() {
    const res = await fetch(`${API_BASE_URL}/agents/delivery-closure-workbench`)
    return handleResponse<DeliveryClosureWorkbenchSnapshot>(res)
  },

  async getRebootAutoRecoveryDrillPreflight() {
    const res = await fetch(`${API_BASE_URL}/agents/reboot-auto-recovery-drill-preflight`, { cache: 'no-store' })
    return handleResponse<RebootAutoRecoveryDrillPreflightSnapshot>(res)
  },

  async getGiteaPrivateInventoryP0Scorecard() {
    const res = await fetch(`${API_BASE_URL}/agents/gitea-private-inventory-p0-scorecard`)
    return handleResponse<GiteaPrivateInventoryP0ScorecardSnapshot>(res)
  },

  async getGithubTargetPrivateBackupEvidenceGate() {
    const res = await fetch(`${API_BASE_URL}/agents/github-target-private-backup-evidence-gate`)
    return handleResponse<GithubTargetPrivateBackupEvidenceGateSnapshot>(res)
  },

  async getAiAgent12AgentWarRoom() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-12-agent-war-room`)
    return handleResponse<AiAgent12AgentWarRoomSnapshot>(res)
  },

  async getAiAgentProfessionalTaskExpansion() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-professional-task-expansion`)
    return handleResponse<AiAgentProfessionalTaskExpansionSnapshot>(res)
  },

  async getAiAgentReceiptReadbackOwnerReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-receipt-readback-owner-review`)
    return handleResponse<AiAgentReceiptReadbackOwnerReviewSnapshot>(res)
  },

  async getAiAgentReportNoWriteAnalysisRuntime() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-no-write-analysis-runtime`)
    return handleResponse<AiAgentReportNoWriteAnalysisRuntimeSnapshot>(res)
  },

  async getAiAgentLowMediumRiskWhitelist() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-low-medium-risk-whitelist`)
    return handleResponse<AiAgentLowMediumRiskWhitelistSnapshot>(res)
  },

  async getAiAgentHighRiskOwnerReviewQueue() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-high-risk-owner-review-queue`)
    return handleResponse<AiAgentHighRiskOwnerReviewQueueSnapshot>(res)
  },

  async getAiAgentControlledExecutorHandoff() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-controlled-executor-handoff`)
    return handleResponse<AiAgentControlledExecutorHandoffSnapshot>(res)
  },

  async getAiAgentActionAuditLedger() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-action-audit-ledger`)
    return handleResponse<AiAgentActionAuditLedgerSnapshot>(res)
  },

  async getAiAgentActionOwnerAcceptanceEventBus() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-action-owner-acceptance-event-bus`)
    return handleResponse<AiAgentActionOwnerAcceptanceEventBusSnapshot>(res)
  },

  async getHostRunawayAiopsLoopReadiness() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-host-runaway-aiops-loop-readiness`)
    return handleResponse<HostRunawayAiopsLoopReadinessSnapshot>(res)
  },

  async getAiAgentProactiveOperationsContract() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-proactive-operations-contract`)
    return handleResponse<AiAgentProactiveOperationsContractSnapshot>(res)
  },

  async getAiAgentVersionLifecycleUpdateProposal() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-version-lifecycle-update-proposal`)
    return handleResponse<AiAgentVersionLifecycleUpdateProposalSnapshot>(res)
  },

  async getAiAgentInteractionLearningProof() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-interaction-learning-proof`)
    return handleResponse<AiAgentInteractionLearningProofSnapshot>(res)
  },

  async getAiAgentLiveReadModelGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-live-read-model-gate`)
    return handleResponse<AiAgentLiveReadModelGateSnapshot>(res)
  },

  async getAiAgentRedisDryRunGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-redis-dry-run-gate`)
    return handleResponse<AiAgentRedisDryRunGateSnapshot>(res)
  },

  async getAiAgentLearningWritebackApprovalPackage() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-learning-writeback-approval-package`)
    return handleResponse<AiAgentLearningWritebackApprovalPackageSnapshot>(res)
  },

  async getAiAgentTelegramReceiptApprovalPackage() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-telegram-receipt-approval-package`)
    return handleResponse<AiAgentTelegramReceiptApprovalPackageSnapshot>(res)
  },

  async getAiAgentOwnerApprovedLearningDryRun() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-owner-approved-learning-dry-run`)
    return handleResponse<AiAgentOwnerApprovedLearningDryRunSnapshot>(res)
  },

  async getAiAgentRuntimeWriteGateReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-runtime-write-gate-review`)
    return handleResponse<AiAgentRuntimeWriteGateReviewSnapshot>(res)
  },

  async getAiAgentPostWriteVerifierPackage() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-post-write-verifier-package`)
    return handleResponse<AiAgentPostWriteVerifierPackageSnapshot>(res)
  },

  async getAiAgentRuntimeVerifierEvidenceReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-runtime-verifier-evidence-review`)
    return handleResponse<AiAgentRuntimeVerifierEvidenceReviewSnapshot>(res)
  },

  async getAiAgentReportTruthActionabilityReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-truth-actionability-review`)
    return handleResponse<AiAgentReportTruthActionabilityReviewSnapshot>(res)
  },

  async getAiAgentReportAutomationReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-automation-review`)
    return handleResponse<AiAgentReportAutomationReviewSnapshot>(res)
  },

  async getAiAgentReportStatusBoard() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-status-board`)
    return handleResponse<AiAgentReportStatusBoardSnapshot>(res)
  },

  async getAiAgentReportRuntimeReadiness() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-runtime-readiness`)
    return handleResponse<AiAgentReportRuntimeReadinessSnapshot>(res)
  },

  async getAiAgentReportRuntimeDryRun() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-runtime-dry-run`)
    return handleResponse<AiAgentReportRuntimeDryRunSnapshot>(res)
  },

  async getAiAgentReportRuntimeFixtureReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-runtime-fixture-readback`)
    return handleResponse<AiAgentReportRuntimeFixtureReadbackSnapshot>(res)
  },

  async getAiAgentRuntimeWorkerShadowGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-runtime-worker-shadow-gate`)
    return handleResponse<AiAgentRuntimeWorkerShadowGateSnapshot>(res)
  },

  async getAiAgentOperationPermissionModel() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-operation-permission-model`)
    return handleResponse<AiAgentOperationPermissionModelSnapshot>(res)
  },

  async getAiAgentCandidateOperationDryRunEvidence() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-candidate-operation-dry-run-evidence`)
    return handleResponse<AiAgentCandidateOperationDryRunEvidenceSnapshot>(res)
  },

  async getAiAgentTaskResultAuditTrail() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-task-result-audit-trail`)
    return handleResponse<AiAgentTaskResultAuditTrailSnapshot>(res)
  },

  async getAiAgentMatchedPlaybookLearningGap() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-matched-playbook-learning-gap`)
    return handleResponse<AiAgentMatchedPlaybookLearningGapSnapshot>(res)
  },

  async getAiAgentCriticReviewerResultCapture() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-critic-reviewer-result-capture`)
    return handleResponse<AiAgentCriticReviewerResultCaptureSnapshot>(res)
  },

  async getAiAgentOwnerApprovedResultCaptureDryRun() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-owner-approved-result-capture-dry-run`)
    return handleResponse<AiAgentOwnerApprovedResultCaptureDryRunSnapshot>(res)
  },

  async getAiAgentOwnerApprovedResultCaptureReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-owner-approved-result-capture-readback`)
    return handleResponse<AiAgentOwnerApprovedResultCaptureReadbackSnapshot>(res)
  },

  async getAiAgentRuntimeReadbackApprovalPackage() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-runtime-readback-approval-package`)
    return handleResponse<AiAgentRuntimeReadbackApprovalPackageSnapshot>(res)
  },

  async getAiAgentRuntimeReadbackImplementationReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-runtime-readback-implementation-review`)
    return handleResponse<AiAgentRuntimeReadbackImplementationReviewSnapshot>(res)
  },

  async getAiAgentReportLiveDeliveryApprovalPackage() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-report-live-delivery-approval-package`)
    return handleResponse<AiAgentReportLiveDeliveryApprovalPackageSnapshot>(res)
  },

  async getAiAgentRuntimeReadbackFixtureApproval() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-runtime-readback-fixture-approval`)
    return handleResponse<AiAgentRuntimeReadbackFixtureApprovalSnapshot>(res)
  },

  async getAiAgentRuntimeReadbackPromotionGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-runtime-readback-promotion-gate`)
    return handleResponse<AiAgentRuntimeReadbackPromotionGateSnapshot>(res)
  },

  async getAiAgentOwnerApprovedFixturePromotionGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-owner-approved-fixture-promotion-gate`)
    return handleResponse<AiAgentOwnerApprovedFixturePromotionGateSnapshot>(res)
  },

  async getAiAgentCanonicalRuntimeReadbackOwnerAcceptance() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-canonical-runtime-readback-owner-acceptance`)
    return handleResponse<AiAgentCanonicalRuntimeReadbackOwnerAcceptanceSnapshot>(res)
  },

  async getAiAgentFailureReceiptNoSendReplay() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-failure-receipt-no-send-replay`)
    return handleResponse<AiAgentFailureReceiptNoSendReplaySnapshot>(res)
  },

  async getAiAgentReviewerQueueNoWriteReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-reviewer-queue-no-write-readback`)
    return handleResponse<AiAgentReviewerQueueNoWriteReadbackSnapshot>(res)
  },

  async getAiAgentResultCaptureNoWriteReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-no-write-readback`)
    return handleResponse<AiAgentResultCaptureNoWriteReadbackSnapshot>(res)
  },

  async getAiAgentResultCapturePromotionApprovalGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-promotion-approval-gate`)
    return handleResponse<AiAgentResultCapturePromotionApprovalGateSnapshot>(res)
  },

  async getAiAgentOwnerApprovedResultCapturePromotionDryRun() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-owner-approved-result-capture-promotion-dry-run`)
    return handleResponse<AiAgentOwnerApprovedResultCapturePromotionDryRunSnapshot>(res)
  },

  async getAiAgentResultCaptureWriteGateReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-write-gate-review`)
    return handleResponse<AiAgentResultCaptureWriteGateReviewSnapshot>(res)
  },

  async getAiAgentResultCaptureWriterImplementationReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-writer-implementation-review`)
    return handleResponse<AiAgentResultCaptureWriterImplementationReviewSnapshot>(res)
  },

  async getAiAgentResultCaptureWriterDryRunFixture() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-writer-dry-run-fixture`)
    return handleResponse<AiAgentResultCaptureWriterDryRunFixtureSnapshot>(res)
  },

  async getAiAgentResultCaptureWriterDryRunReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-writer-dry-run-readback`)
    return handleResponse<AiAgentResultCaptureWriterDryRunReadbackSnapshot>(res)
  },

  async getAiAgentResultCaptureOwnerPromotionReview() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-owner-promotion-review`)
    return handleResponse<AiAgentResultCaptureOwnerPromotionReviewSnapshot>(res)
  },

  async getAiAgentResultCaptureOwnerApprovedExecutionRehearsal() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-owner-approved-execution-rehearsal`)
    return handleResponse<AiAgentResultCaptureOwnerApprovedExecutionRehearsalSnapshot>(res)
  },

  async getAiAgentResultCaptureOwnerAcceptanceMaintenanceGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-owner-acceptance-maintenance-gate`)
    return handleResponse<AiAgentResultCaptureOwnerAcceptanceMaintenanceGateSnapshot>(res)
  },

  async getAiAgentResultCaptureOwnerAcceptanceReadbackPreflightHold() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-owner-acceptance-readback-preflight-hold`)
    return handleResponse<AiAgentResultCaptureOwnerAcceptanceReadbackPreflightHoldSnapshot>(res)
  },

  async getAiAgentResultCaptureOwnerApprovedPreflightReleasePackage() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-owner-approved-preflight-release-package`)
    return handleResponse<AiAgentResultCaptureOwnerApprovedPreflightReleasePackageSnapshot>(res)
  },

  async getAiAgentResultCaptureOwnerApprovedReleaseReadinessReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-owner-approved-release-readiness-readback`)
    return handleResponse<AiAgentResultCaptureOwnerApprovedReleaseReadinessReadbackSnapshot>(res)
  },

  async getAiAgentResultCaptureOwnerReleaseApprovalGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-owner-release-approval-gate`)
    return handleResponse<AiAgentResultCaptureOwnerReleaseApprovalGateSnapshot>(res)
  },

  async getAiAgentResultCapturePostReleaseVerifierRollbackGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-post-release-verifier-rollback-gate`)
    return handleResponse<AiAgentResultCapturePostReleaseVerifierRollbackGateSnapshot>(res)
  },

  async getAiAgentResultCaptureFinalReleaseCandidateReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-final-release-candidate-readback`)
    return handleResponse<AiAgentResultCaptureFinalReleaseCandidateReadbackSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseAuthorizationHold() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-authorization-hold`)
    return handleResponse<AiAgentResultCaptureReleaseAuthorizationHoldSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseAuthorizationReadbackGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-authorization-readback-gate`)
    return handleResponse<AiAgentResultCaptureReleaseAuthorizationReadbackGateSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseVerifierPreflightGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-verifier-preflight-gate`)
    return handleResponse<AiAgentResultCaptureReleaseVerifierPreflightGateSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseVerifierOwnerReviewPacket() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-verifier-owner-review-packet`)
    return handleResponse<AiAgentResultCaptureReleaseVerifierOwnerReviewPacketSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseDecisionHold() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-decision-hold`)
    return handleResponse<AiAgentResultCaptureReleaseDecisionHoldSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseDecisionReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-decision-readback`)
    return handleResponse<AiAgentResultCaptureReleaseDecisionReadbackSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseDecisionNextHandoff() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-decision-next-handoff`)
    return handleResponse<AiAgentResultCaptureReleaseDecisionNextHandoffSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseDecisionInputPrep() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-decision-input-prep`)
    return handleResponse<AiAgentResultCaptureReleaseDecisionInputPrepSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseDecisionOwnerResponsePreflight() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-decision-owner-response-preflight`)
    return handleResponse<AiAgentResultCaptureReleaseDecisionOwnerResponsePreflightSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseDecisionOwnerResponseReadback() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-decision-owner-response-readback`)
    return handleResponse<AiAgentResultCaptureReleaseDecisionOwnerResponseReadbackSnapshot>(res)
  },

  async getAiAgentResultCaptureReleaseDecisionOwnerResponseAcceptanceGate() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-result-capture-release-decision-owner-response-acceptance-gate`)
    return handleResponse<AiAgentResultCaptureReleaseDecisionOwnerResponseAcceptanceGateSnapshot>(res)
  },

  async getAiAgentOwnerApprovedFixtureDryRun() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-owner-approved-fixture-dry-run`)
    return handleResponse<AiAgentOwnerApprovedFixtureDryRunSnapshot>(res)
  },

  async getAiAgentHostStatefulVersionInventory() {
    const res = await fetch(`${API_BASE_URL}/agents/agent-host-stateful-version-inventory`)
    return handleResponse<AiAgentHostStatefulVersionInventorySnapshot>(res)
  },

  async getDependencySupplyChainDriftMonitor() {
    const res = await fetch(`${API_BASE_URL}/agents/dependency-supply-chain-drift-monitor`)
    return handleResponse<DependencySupplyChainDriftMonitorSnapshot>(res)
  },

  async getRuntimeSurfaceInventory() {
    const res = await fetch(`${API_BASE_URL}/agents/runtime-surface-inventory`)
    return handleResponse<RuntimeSurfaceInventorySnapshot>(res)
  },

  async getGiteaWorkflowRunnerHealth() {
    const res = await fetch(`${API_BASE_URL}/agents/gitea-workflow-runner-health`)
    return handleResponse<GiteaWorkflowRunnerHealthSnapshot>(res)
  },

  async getObservabilityContractMatrix() {
    const res = await fetch(`${API_BASE_URL}/agents/observability-contract-matrix`)
    return handleResponse<ObservabilityContractMatrixSnapshot>(res)
  },

  async getAiProviderRouteMatrix() {
    const res = await fetch(`${API_BASE_URL}/agents/ai-provider-route-matrix`)
    return handleResponse<AiProviderRouteMatrixSnapshot>(res)
  },

  async getServiceHealthGapMatrix() {
    const res = await fetch(`${API_BASE_URL}/agents/service-health-gap-matrix`)
    return handleResponse<ServiceHealthGapMatrixSnapshot>(res)
  },

  async getServiceHealthFailureNotificationPolicy() {
    const res = await fetch(`${API_BASE_URL}/agents/service-health-failure-notification-policy`)
    return handleResponse<ServiceHealthFailureNotificationPolicySnapshot>(res)
  },

  async getBackupDrTargetInventory() {
    const res = await fetch(`${API_BASE_URL}/agents/backup-dr-target-inventory`)
    return handleResponse<BackupDrTargetInventorySnapshot>(res)
  },

  async getBackupDrReadinessMatrix() {
    const res = await fetch(`${API_BASE_URL}/agents/backup-dr-readiness-matrix`)
    return handleResponse<BackupDrReadinessMatrixSnapshot>(res)
  },

  async getBackupNotificationPolicy() {
    const res = await fetch(`${API_BASE_URL}/agents/backup-notification-policy`)
    return handleResponse<BackupNotificationPolicySnapshot>(res)
  },

  async getOffsiteEscrowReadinessStatus() {
    const res = await fetch(`${API_BASE_URL}/agents/offsite-escrow-readiness-status`)
    return handleResponse<OffsiteEscrowReadinessStatusSnapshot>(res)
  },
}

// =========================================================================
// Type Definitions (Phase 7)
// =========================================================================

/**
 * Phase 6.5: 決策令牌資訊
 * 確保 UI 永遠有決策可操作
 */
export interface DecisionInfo {
  token: string
  state: 'init' | 'analyzing' | 'ready' | 'executing' | 'completed' | 'error'
  proposal_data: {
    action: string
    description: string
    reasoning: string
    risk_level: 'low' | 'medium' | 'critical'
    kubectl_command: string
    source: string
    confidence: number
  } | null
  proposal_id: string | null
}

export interface IncidentResponse {
  incident_id: string
  status: 'investigating' | 'mitigating' | 'resolved' | 'closed'
  severity: 'P0' | 'P1' | 'P2' | 'P3'
  signal_count: number
  affected_services: string[]
  proposal_count: number
  created_at: string
  updated_at: string
  /** Phase 6.5: 決策令牌 (確保 UI 永不鎖死) */
  decision: DecisionInfo | null
}

export interface IncidentListResponse {
  count: number
  incidents: IncidentResponse[]
}

export interface IncidentTimelineEvent {
  stage: string
  status: string
  title: string
  description: string | null
  actor: string | null
  timestamp: string | null
  source_table: string | null
  data: Record<string, unknown>
}

export interface IncidentTimelineStage extends IncidentTimelineEvent {
  label: string
  events: IncidentTimelineEvent[]
}

export interface IncidentTimelineResponse {
  incident_id: string
  title: string
  status: string
  severity: string
  started_at: string | null
  updated_at: string | null
  resolved_at: string | null
  affected_services: string[]
  approval_ids: string[]
  timeline: IncidentTimelineStage[]
  events: IncidentTimelineEvent[]
  ascii_timeline: string
}

export interface BlastRadius {
  affected_pods: number
  estimated_downtime: string
  related_services: string[]
  data_impact: 'none' | 'read_only' | 'write' | 'destructive'
}

export interface DryRunCheck {
  name: string
  passed: boolean
  message: string
}

export interface ApprovalResponse {
  id: string
  action: string
  description: string
  status: 'pending' | 'approved' | 'rejected' | 'expired'
  risk_level: 'low' | 'medium' | 'high' | 'critical'
  blast_radius: BlastRadius
  dry_run_checks: DryRunCheck[]
  required_signatures: number
  current_signatures: number
  signatures: Array<{ signer: string; signed_at: string }>
  requested_by: string
  created_at: string
  expires_at: string | null
}

export interface PendingApprovalsResponse {
  count: number
  approvals: ApprovalResponse[]
}

export interface ProposalGenerateResponse {
  success: boolean
  message: string
  incident_id: string
  proposal: ApprovalResponse | null
  incident_status: string | null
}

// =========================================================================
// Phase 10: Sentry Error Types (#40 BFF)
// =========================================================================

export interface SentryIssue {
  id: string
  short_id: string
  title: string
  culprit: string | null
  level: 'error' | 'warning' | 'info' | 'fatal'
  status: 'unresolved' | 'resolved' | 'ignored'
  count: number
  user_count: number
  first_seen: string
  last_seen: string
  permalink: string | null
}

export interface ErrorStatsResponse {
  total_issues: number
  unresolved_issues: number
  error_count_24h: number
  critical_count: number
  projects: string[]
}

export interface ErrorListResponse {
  issues: SentryIssue[]
  total: number
  has_more: boolean
}

export interface ErrorDetailResponse {
  issue: Record<string, unknown>
  latest_event: Record<string, unknown> | null
  sentry_url: string
}

export interface ErrorTrendPoint {
  timestamp: string
  count: number
}

export interface ErrorTrendResponse {
  period: '24h' | '7d' | '30d'
  data: ErrorTrendPoint[]
  total_count: number
  change_percent: number
}

export interface FixRecommendation {
  summary: string
  steps: string[]
  code_suggestion: string | null
}

export interface PreventionMeasure {
  type: string
  description: string
}

export interface ErrorAnalysis {
  root_cause: string
  category: string
  severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'
  impact_assessment: string
  fix_recommendation: FixRecommendation
  prevention: PreventionMeasure[]
  related_files: string[]
  confidence: number
  reasoning: string
}

export interface ErrorAnalysisResponse {
  status: 'completed' | 'failed'
  issue_id: string
  provider: string
  analysis?: ErrorAnalysis
  analyzed_at?: string
  sentry_url: string
  message?: string
}

// =========================================================================
// Phase 19: UX Audit / Session Replay Types (#126)
// 2026-03-31 Claude Code - Frontend Replay UI Integration
// =========================================================================

export interface UXAuditDetail {
  type: 'replay_with_errors' | 'ui_error'
  replay_id?: string
  issue_id?: string
  url: string
  error_count?: number
  title?: string
  count?: number
  urls?: string[]
}

export interface UXAuditResponse {
  replays_with_errors: number
  rage_clicks: number
  dead_clicks: number
  ui_errors: number
  health_score: 'good' | 'moderate' | 'poor'
  details: UXAuditDetail[]
  replay_dashboard_url: string
}

// =========================================================================
// Agent Market Governance Snapshot
// =========================================================================

export interface AgentMarketGovernanceSnapshot {
  schema_version: 'agent_market_governance_snapshot_v1'
  generated_at: string
  current_decision: string
  policy: Record<string, boolean>
  evaluation_cadence: {
    workflow: string
    schedule: string
    timezone: 'Asia/Taipei'
    next_scheduled_run_at: string
	    trigger_modes: string[]
	    primary_source_policy: string
	    controlled_review_gate: string
	    operator_review_gate?: string
	  }
	  market_watch_health: {
	    status: 'healthy' | 'controlled_queue' | 'blocked'
	    freshness_sla_hours: 168
	    stale_grace_hours: 6
	    stale_after: string
	    source_failures_require_controlled_reverify: boolean
	    source_failures_block_priority_upgrade?: boolean
	    blocked_from_integration: number
	    controlled_queue_reasons: string[]
	    operator_blockers?: string[]
  }
  summary: {
    candidate_count: number
    source_count: number
    source_failures: number
    changed_candidates: number
    integration_queue_count: number
    blocked_from_integration: number
    watch_only_candidates_reviewed: number
    eligible_for_market_scorecard_prescreen: number
    recommended_watch_additions_remaining: number
    priority_upgrades_approved: number
    market_scorecard_updates_approved: number
    replay_candidates_approved: number
    sdk_installations_approved: number
    paid_api_calls_approved: number
    production_changes_approved: number
    shadow_or_canary_approved: number
    replacement_decisions_approved: number
  }
  candidate_groups: {
    production_baseline: string[]
    replay_or_integration_blocked: string[]
    watch_only_candidates: string[]
    watch_only_scorecard_prescreen_ready: string[]
  }
  candidate_statuses: Array<{
    candidate_id: string
    display_name: string
    role: string
    evaluation_priority: string
    gate_status:
      | 'production_baseline'
      | 'integration_blocked'
      | 'integration_reviewed'
      | 'watch_only_prescreen_ready'
      | 'watch_only_blocked'
      | 'watch_only_monitoring'
      | 'registered_no_review'
    current_gate: string
    required_next_gate: string
    integration_decision: string
    score: number | null
    evidence: {
      latest_replay_summary: string | null
      latest_smoke_gate: string | null
      latest_smoke_matrix: string | null
      latest_smoke_model: string | null
    }
    approvals: {
      replay: false
      sdk_install: false
      paid_api: false
      shadow_or_canary: false
      production_routing: false
    }
    operator_blockers: string[]
  }>
  operator_decision_queue: Array<{
    candidate_id: string
    display_name: string
    priority: number
    queue_status:
	      | 'baseline_protected'
	      | 'blocked_needs_evidence'
	      | 'controlled_review_required'
	      | 'controlled_priority_review'
	      | 'operator_review_required'
	      | 'operator_priority_review'
      | 'watch_only_blocked'
      | 'watch_only_monitoring'
      | 'registered_no_review'
    recommended_action: string
    approval_boundary: {
      replacement_adr_required: boolean
      priority_upgrade_required: boolean
      market_scorecard_update_required: boolean
      replay_approval_required: boolean
      sdk_install_approval_required: boolean
      paid_api_approval_required: boolean
      shadow_or_canary_approval_required: boolean
      production_routing_approval_required: boolean
    }
    risk_notes: string[]
    evidence_refs: string[]
  }>
  next_allowed_actions: string[]
  forbidden_actions_without_new_approval: string[]
}

// =========================================================================
// AI Technology Radar Readback
// =========================================================================

export interface AiTechnologyRadarReadback {
  schema_version: 'ai_technology_radar_readback_v1'
  generated_at: string
  source_scope: Record<string, string>
  summary: {
    overall_completion_percent: number
    ai_technology_radar_completion_percent: number
    technology_count: number
    technology_area_count: number
    source_count: number
    changed_technologies: number
    review_queue_count: number
    source_failures: number
    high_priority_count: number
    rolling_update_status: string
  }
  policy: {
    read_only: true
    raw_chat_history_synced: false
    sdk_installation_approved: false
    paid_api_calls_approved: false
    production_routing_approved: false
    telegram_send_approved: false
    model_provider_switch_approved: false
    host_write_approved: false
    openclaw_replacement_approved: false
  }
  technology_area_counts: Record<string, number>
  technology_domains: Array<{
    technology_area: string
    technology_count: number
    high_priority_count: number
    changed_count: number
    representative_technologies: string[]
  }>
  high_priority_review_queue: Array<{
    technology_id: string
    display_name: string
    technology_area: string
    evaluation_priority: string
    gate_status: string
    next_gate: string
    requires_cost_approval: boolean
    requires_dependency_approval: boolean
    requires_security_review: boolean
  }>
  professional_agent_roles: Array<{
    agent: string
    professional_role: string
    auto_scope: string
    review_boundary: string
  }>
  rolling_update_controls: Array<{
    cadence: string
    cadence_source: string
    agent_auto_action: string
    output: string
    gate: string
  }>
  primary_source_alignment: Array<{
    practice: string
    source: string
    awoooi_gate: string
    agent_assignment: string
  }>
  integration_candidates: Array<{
    technology_id: string
    display_name: string
    technology_area: string
    integration_surface: string
    awoooi_role: string
    decision: string
    changed: boolean
    recommended_actions: string[]
  }>
  priority_workplan: Array<{
    order: number
    priority: string
    work_item: string
    automation_mode: string
    done_definition: string
  }>
  blocked_gates: string[]
  report_contract: {
    api_endpoint: string
    frontend_target: string
    schedule_enabled: boolean
    schedule_workflow: string
    schedule_cron_utc: string
    near_real_time: string
    daily: string
    weekly: string
    monthly: string
    agent_auto_allowed_for: string[]
    human_review_required_for: string[]
  }
}

export interface AiTechnologyReportCadenceReadback {
  schema_version: 'ai_technology_report_cadence_readback_v1'
  generated_at: string
  source_scope: Record<string, string>
  summary: {
    overall_completion_percent: number
    report_cadence_completion_percent: number
    report_cadence_count: number
    report_ready_count: number
    chart_section_count: number
    agent_status_report_count: number
    post_report_analysis_packet_count: number
    low_medium_auto_action_proposal_count: number
    high_risk_owner_review_count: number
    technology_count: number
    source_count: number
    source_failures: number
    telegram_send_enabled: false
    live_delivery_count_24h: 0
    report_receipt_write_count_24h: 0
    auto_optimization_write_count: 0
    policy_hold_count: number
    status: string
  }
  policy: {
    read_only: true
    raw_chat_history_synced: false
    raw_report_payload_display_allowed: false
    report_delivery_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    report_receipt_write_enabled: false
    ai_post_report_analysis_live_run_enabled: false
    low_medium_runtime_auto_write_enabled: false
    high_risk_owner_review_required: false
    low_medium_high_controlled_auto_route_enabled: true
    sdk_installation_approved: false
    paid_api_calls_approved: false
    production_routing_approved: false
    model_provider_switch_approved: false
    host_write_approved: false
    openclaw_replacement_approved: false
  }
  report_cadences: Array<{
    cadence: 'daily' | 'weekly' | 'monthly'
    cadence_label: string
    owner_agent: string
    reviewer_agent: string
    report_purpose: string
    data_inputs: string[]
    metrics: Record<string, number>
    chart_types: string[]
    ai_analysis_after_reading: string
    low_medium_auto_actions: string[]
    high_risk_owner_review_actions: string[]
    telegram_delivery_status: string
  }>
  agent_workload_reports: Array<{
    agent: string
    professional_responsibility: string
    work_unit_count: number
    work_unit_label: string
    latest_output: string
    next_action: string
  }>
  chart_sections: Array<{
    chart_id: string
    title: string
    chart_type: string
    primary_metric: string
    value: number
    expected_report_signal: string
  }>
  post_report_analysis_packets: Array<{
    report_id: 'daily' | 'weekly' | 'monthly'
    risk_tier: 'low' | 'medium' | 'high'
    key_finding: string
    proposed_solution: string
    agent_decision: string
    execution_boundary: string
  }>
  risk_automation_policy: Array<{
    risk_tier: 'low' | 'medium' | 'high'
    agent_auto_scope: string
    blocked_without_approval: string
    reporting_mode: string
  }>
  telegram_report_bridge: {
    integration_status: string
    canonical_group_env: string
    telegram_send_enabled: false
    bot_api_call_enabled: false
    report_receipt_write_enabled: false
    draft_count: number
    drafts: Array<{
      draft_id: string
      cadence: 'daily' | 'weekly' | 'monthly'
      status: string
      required_gate: string
    }>
    delivery_note: string
  }
  blocked_gates: string[]
  next_allowed_actions: string[]
  forbidden_actions_without_new_approval: string[]
  report_contract: {
    api_endpoint: string
    frontend_target: string
    source_endpoint: string
    daily: string
    weekly: string
    monthly: string
    telegram: string
  }
}

// =========================================================================
// AI Agent Automation Inventory Snapshot
// =========================================================================

export interface AiAgentAutonomousRuntimeControlSnapshot {
  schema_version: 'ai_agent_autonomous_runtime_control_v1'
  generated_at: string
  program_status: {
    current_task_id: 'P2-416-D1N'
    status: string
    runtime_authority: 'current_owner_directive_controlled_ai_automation'
    deploy_readback_marker: string
    deploy_attempt_note: string
    legacy_no_send_no_live_rules_overridden: true
    implementation_completion_percent: number
    status_note: string
  }
  current_policy: {
    low_risk_controlled_apply_allowed: boolean
    medium_risk_controlled_apply_allowed: boolean
    high_risk_controlled_apply_allowed: boolean
    critical_break_glass_required: boolean
    owner_review_required_for_low_medium_high: boolean
    direct_bot_api_allowed: boolean
    telegram_gateway_required: boolean
    post_apply_verifier_required: boolean
    km_learning_writeback_required: boolean
  }
  runtime_switches: {
    ansible_check_mode_worker_enabled: boolean
    ansible_controlled_apply_enabled: boolean
    ansible_controlled_apply_allowed_risk_levels: string[]
    ansible_check_mode_interval_seconds: number
    ansible_check_mode_batch_limit: number
    ansible_check_mode_timeout_seconds: number
    ansible_controlled_apply_timeout_seconds: number
  }
  agent_roles: Array<{
    agent_id: string
    role: string
    current_job: string
  }>
  report_delivery: {
    status: string
    cadences: Array<{
      cadence: 'daily' | 'weekly' | 'monthly'
      display_name: string
      schedule: string
      worker: string
      telegram_gateway_delivery_enabled: boolean
      direct_bot_api_allowed: boolean
      receipt_source: string
    }>
  }
  controlled_executor: {
    status: string
    operation_receipts: Array<{
      operation_type: string
      owner_agent: string
      purpose: string
      writes_runtime_state: boolean
    }>
    required_flow: string[]
  }
  legacy_policy_overrides: Array<{
    legacy_area: string
    current_effect: string
    new_behavior: string
  }>
  hard_blockers: string[]
  visibility_contract: {
    frontend_displays_runtime_truth: boolean
    work_window_transcript_display_allowed: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_telegram_payload_display_allowed: boolean
    lan_topology_redaction_required: boolean
  }
  rollups: {
    automated_risk_tier_count: number
    hard_blocker_count: number
    report_cadence_enabled_count: number
    telegram_gateway_delivery_enabled_count: number
    direct_bot_api_allowed_count: number
    controlled_executor_operation_receipt_count: number
    runtime_write_receipt_type_count: number
    legacy_policy_overridden_count: number
    live_ansible_apply_executed_count?: number
    live_auto_repair_execution_receipt_count?: number
    live_executor_latest_flow_closed_count?: number
    live_autonomous_execution_loop_closed_count?: number
    live_km_writeback_count?: number
    live_post_apply_verifier_count?: number
    live_telegram_receipt_count?: number
    live_log_controlled_writeback_consumer_apply_receipt_count?: number
    live_log_controlled_writeback_consumer_dispatch_ledger_count?: number
    live_log_controlled_writeback_runtime_target_write_count?: number
    live_work_item_completed_count?: number
    live_work_item_blocked_count?: number
    mcp_sensor_count?: number
    rag_context_query_count?: number
    playbook_decision_class_count?: number
    deploy_control_classifier_example_count?: number
  }
  runtime_receipt_readback?: {
    schema_version: 'ai_agent_autonomous_runtime_receipt_readback_v1'
    db_read_status: string
    writes_on_read: boolean
    autonomous_execution_loop_ledger?: {
      schema_version: 'ai_agent_autonomous_execution_loop_ledger_v1'
      project_id: string
      operation_id: string | null
      root_candidate_op_id: string | null
      check_mode_op_id: string | null
      apply_op_id: string | null
      incident_id: string | null
      catalog_id: string | null
      playbook_path: string | null
      execution_state: string
      closed: boolean
      missing_stage_ids: string[]
      next_executor_action: string
      stages: Array<{
        stage_id: string
        receipt_source: string
        present: boolean
        status: string
        ref_id: string | null
        writes_runtime_state: boolean
        next_action_if_missing: string | null
      }>
      safety_contract: {
        writes_on_read: boolean
        backfill_may_write_auto_repair_verifier_km: boolean
        backfill_may_send_telegram: boolean
        live_apply_may_send_telegram_gateway_receipt: boolean
        reads_raw_sessions: boolean
        reads_secret_values: boolean
      }
    }
  }
}

export interface AiAgentAutomationInventorySnapshot {
  schema_version: 'ai_agent_automation_inventory_snapshot_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  status_taxonomy: {
    task_statuses: string[]
    gate_statuses: string[]
    priorities: Array<'P0' | 'P1' | 'P2' | 'P3'>
  }
  agent_roles: Array<{
    agent_id: string
    display_name: string
    primary_role: string
    allowed_actions: string[]
    blocked_actions: string[]
  }>
  asset_domains: Array<{
    domain_id: string
    display_name: string
    description: string
  }>
  assets: Array<{
    asset_id: string
    domain_id: string
    display_name: string
    asset_type: string
    status: string
    gate_status: string
    owner_agent: string
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    evidence_refs: string[]
    next_action: string
  }>
  workstreams: Array<{
    workstream_id: string
    display_name: string
    completion_percent: number
    status: string
    next_task_id: string
  }>
  tasks: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    status: string
    completion_percent: number
    owner_agent: string
    title: string
    output: string
    gate_status: string
    approval_boundary: {
      mode: string
      display_summary: string
      allowed_actions: string[]
      blocked_actions: string[]
      requires_operator_approval_for: string[]
    }
    next_action: string
  }>
  task_approval_boundary_rollup: {
    total_tasks: number
    by_mode: Record<string, number>
    tasks_requiring_explicit_approval: string[]
    tasks_with_blocked_operations: string[]
  }
  evidence: Array<{
    evidence_id: string
    kind: 'schema' | 'test' | 'browser' | 'api' | 'build' | 'doc' | 'runtime'
    ref: string
    result: string
  }>
  approval_boundaries: Record<
    | 'sdk_installation_allowed'
    | 'paid_api_call_allowed'
    | 'shadow_or_canary_allowed'
    | 'production_routing_allowed'
    | 'destructive_operation_allowed',
    false
  >
}

export interface AiAgentAutomationBacklogSnapshot {
  schema_version: 'ai_agent_automation_backlog_v1'
  generated_at: string
  source_inventory_snapshot_ref: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  rollups: {
    total_items: number
    by_priority: Record<string, number>
    by_status: Record<string, number>
    by_gate_status: Record<string, number>
    by_owner_agent: Record<string, number>
  }
  progress_summary: {
    overall_percent: number
    done_items: number
    planned_items: number
    total_items: number
    formula: string
    by_priority: Array<{
      priority: 'P0' | 'P1' | 'P2' | 'P3'
      completion_percent: number
      done_items: number
      total_items: number
    }>
    by_workstream: Array<{
      workstream_id: string
      display_name: string
      completion_percent: number
      done_items: number
      total_items: number
      next_task_id: string
    }>
  }
  backlog_items: Array<{
    item_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    status: string
    workstream_id: string
    source_asset_id: string
    source_signal_kind: string
    title: string
    owner_agent: string
    recommended_action: string
    action_class: string
    gate_status: string
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    evidence_refs: string[]
    acceptance_criteria: string[]
    approval_boundary: {
      mode: string
      display_summary: string
      allowed_actions: string[]
      blocked_actions: string[]
      requires_operator_approval_for: string[]
    }
    next_review: string
  }>
  item_approval_boundary_rollup: {
    total_items: number
    by_mode: Record<string, number>
    items_requiring_explicit_approval: string[]
    items_with_blocked_operations: string[]
  }
  approval_boundaries: Record<
    | 'sdk_installation_allowed'
    | 'paid_api_call_allowed'
    | 'shadow_or_canary_allowed'
    | 'production_routing_allowed'
    | 'destructive_operation_allowed',
    false
  >
}

export interface AiAgentDeploymentLayoutSnapshot {
  schema_version: 'ai_agent_deployment_layout_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    deployment_authority: 'layout_only_no_runtime_deploy'
  }
  agent_contracts: Array<{
    agent_id: string
    display_name: string
    primary_specialty: string
    deployment_lane: string
    allowed_autonomy: string[]
    must_delegate_to: string[]
    blocked_actions: string[]
    learning_scope: string[]
  }>
  domains: Array<{
    domain_id: string
    display_name: string
    description: string
  }>
  deployment_targets: Array<{
    target_id: string
    domain_id: string
    display_name: string
    target_type: string
    primary_agent: string
    supporting_agents: string[]
    deployment_state:
      | 'active_governed'
      | 'read_only_layout'
      | 'blocked_by_gate'
      | 'planned'
      | 'candidate_only'
    automation_level:
      | 'observe_only'
      | 'prepare_only'
      | 'dry_run_only'
      | 'hitl_execute_after_approval'
      | 'blocked'
    capabilities: string[]
    telegram_policy:
      | 'failure_only'
      | 'action_required'
      | 'approval_required'
      | 'daily_summary_only'
      | 'no_direct_notify'
    learning_inputs: string[]
    communication_channels: string[]
    approval_gate: string
    evidence_refs: string[]
    next_action: string
  }>
  collaboration_contract: {
    message_bus: string
    audit_trail: string
    handoff_rules: string[]
    frontend_redaction: {
      operator_conversation_display_allowed: false
      agent_private_reasoning_display_allowed: false
      display_policy: string
    }
  }
  learning_contract: {
    event_sources: string[]
    feedback_loops: string[]
    growth_metrics: string[]
    retention_policy: string
  }
  telegram_contract: {
    primary_gateway: string
    bot_roles: string[]
    notification_classes: string[]
    redaction_policy: string
    e2e_validation: string
  }
  rollups: {
    total_targets: number
    by_domain: Record<string, number>
    by_primary_agent: Record<string, number>
    by_deployment_state: Record<string, number>
    by_telegram_policy: Record<string, number>
    blocked_target_ids: string[]
    approval_required_target_ids: string[]
  }
  approval_boundaries: Record<
    | 'sdk_installation_allowed'
    | 'paid_api_call_allowed'
    | 'shadow_or_canary_allowed'
    | 'production_routing_allowed'
    | 'destructive_operation_allowed'
    | 'secret_plaintext_allowed'
    | 'autonomous_host_mutation_allowed'
    | 'telegram_direct_send_allowed',
    false
  >
}

export interface AwoooIStatusCleanupDashboardSnapshot {
  schema_version: 'awoooi_status_cleanup_dashboard_v1'
  generated_at: string
  target_route: '/workspace/status-cleanup'
  summary: {
    dashboard_status: string
    overall_completion_percent: number
    gate_count: number
    blocked_gate_count: number
    accepted_owner_flag_count: number
    required_owner_flag_count: number
    approved_update_section_count: number
    required_update_section_count: number
    approved_target_path_count: number
    target_path_count: number
    boundary_ack_count: number
    required_boundary_ack_count: number
    controlled_status_cleanup_package_ready: true
    controlled_owner_acknowledgements_ready: true
    controlled_dry_run_package_ready: true
    controlled_post_apply_verifier_required: true
    apply_allowed: false
    memory_write_authorized: false
    wazuh_api_live_query_authorized: false
    runtime_execution_authorized: false
    ui_implementation_allowed: false
    [key: string]: unknown
  }
  metric_cards: Array<Record<string, unknown>>
  gate_cards: Array<Record<string, unknown>>
  workflow_rows: Array<Record<string, unknown>>
  risk_controls: Array<Record<string, unknown>>
  blocking_reasons: string[]
  next_actions: string[]
  wazuh_handoff: Record<string, unknown>
  hard_gates: string[]
  operation_boundaries: Record<string, false>
  secret_values_collected: false
  remote_write_performed: false
  local_product_write_performed: false
  execution_authorized: false
  memory_write_authorized: false
  wazuh_api_live_query_authorized: false
  runtime_execution_authorized: false
  ui_implementation_authorized: false
}

export interface DeliveryOperatorUnblock {
  required: boolean
  status: string
  github_account_status: string
  github_account_suspended: boolean
  github_api_forbidden_count: number
  required_actions: string[]
  recheck_commands: string[]
  still_forbidden: string[]
  safe_handoff: string
}

export interface RebootAutoRecoveryDrillPreflightSnapshot {
  schema_version: 'reboot_auto_recovery_drill_preflight_readback_v1'
  generated_at: string
  priority: 'P0-006'
  scope: 'reboot_auto_recovery_drill_preflight'
  status: string
  preflight_ready: boolean
  preflight_blocker_count: number
  break_glass_authorization_required: boolean
  execution_authorized_by_this_endpoint: boolean
  safe_next_step: string
  readback: {
    workplan_id: 'P0-006'
    workplan_title: string
    source_scorecard_status: string
    preflight_ready: boolean
    break_glass_authorization_required: boolean
    execution_authorized_by_this_endpoint: boolean
    target_selector: RebootAutoRecoveryDrillPreflightSnapshot['target_selector']
    current_readback: RebootAutoRecoveryDrillPreflightSnapshot['current_readback']
    check_mode: RebootAutoRecoveryDrillPreflightSnapshot['check_mode']
    rollback_plan: RebootAutoRecoveryDrillPreflightSnapshot['rollback_plan']
    safe_next_step: string
  }
  rollups: {
    preflight_ready: boolean
    preflight_ready_count: number
    preflight_blocker_count: number
    target_required_host_count: number
    target_observed_host_count: number
    target_missing_host_count: number
    target_unreachable_host_count: number
    target_stale_host_count: number
    service_green: boolean
    product_data_green: boolean
    backup_core_green: boolean
    stockplatform_freshness_ok: boolean
    stockplatform_ingestion_ok: boolean
    blocked_only_by_fresh_reboot_window: boolean
    break_glass_authorization_required: boolean
    execution_authorized_by_this_endpoint: boolean
    host_reboot_authorized_by_this_endpoint: boolean
    workflow_trigger_performed: boolean
    secret_value_collection_allowed: boolean
    runtime_write_allowed: boolean
  }
  active_blockers: string[]
  target_selector: {
    scope: string
    required_host_aliases: string[]
    required_host_count: number
    observed_host_count: number
    missing_host_count: number
    unreachable_host_count: number
    stale_host_count: number
    selector_source: string
  }
  preconditions: Record<string, boolean>
  current_readback: {
    scorecard_status: string
    readiness_percent: number
    active_blocker_count: number
    active_blockers: string[]
    service_green: boolean
    product_data_green: boolean
    backup_core_green: boolean
    post_start_blocked: number
    latest_verify_only_metric_ready: number
    latest_verify_only_metric_blocker_count: number
    latest_verify_only_metric_max_host_uptime_seconds: number
    stockplatform_freshness_status: string
    stockplatform_ingestion_status: string
  }
  check_mode: {
    verify_only_available: boolean
    verify_only_source: string
    post_apply_verifier_endpoint: string
    expected_after_real_fresh_boot_or_approved_drill: {
      status: string
      active_blocker_count: number
      latest_verify_only_metric_ready: number
      latest_verify_only_metric_blocker_count: number
      max_host_uptime_seconds_lte: number
    }
  }
  rollback_plan: {
    preflight_is_read_only: boolean
    rollback_required_for_this_endpoint: boolean
    if_separately_approved_drill_fails: string[]
  }
  operation_boundaries: {
    host_reboot_authorized_by_this_endpoint: boolean
    host_reboot_performed: boolean
    service_restart_performed: boolean
    database_write_or_restore_performed: boolean
    workflow_trigger_performed: boolean
    secret_value_collection_allowed: boolean
    github_api_used: boolean
    runtime_write_allowed: boolean
  }
  forbidden_without_separate_break_glass: string[]
}

export interface DeliveryClosureWorkbenchSnapshot {
  schema_version: 'delivery_closure_workbench_v1'
  generated_at: string
  status: 'blocked_delivery_actions_required' | 'ready' | string
  safe_next_step: string
  active_blockers: string[]
  readback: {
    workbench_status: string
    current_p0_workplan_id: string
    current_p0_source_id: string
    current_p0_status: string
    current_p0_safe_next_step: string
    current_p0_active_blockers: string[]
    current_p0_readiness_percent: number
    current_p0_drill_preflight_status: string
    current_p0_drill_preflight_ready: boolean
    current_p0_drill_preflight_safe_next_step: string
    current_p0_drill_preflight_break_glass_required: boolean
    current_p0_drill_preflight_execution_authorized_by_this_endpoint: boolean
    closed_p0_workplan_ids: string[]
    github_lane_status: string
    secret_value_collection_allowed: boolean
    workflow_trigger_authorized: boolean
    runtime_write_authorized: boolean
  }
  rollups: {
    source_count: number
    loaded_source_count: number
    average_completion_percent: number
    high_risk_blocker_count: number
    current_p0_blocker_count: number
    current_p0_readiness_percent: number
    current_p0_blocked_by_fresh_reboot_window_only: boolean
    current_p0_service_green: boolean
    current_p0_product_data_green: boolean
    current_p0_backup_core_green: boolean
    current_p0_stockplatform_freshness_status: string
    current_p0_stockplatform_ingestion_status: string
    current_p0_drill_preflight_ready: boolean
    current_p0_drill_preflight_ready_count: number
    current_p0_drill_preflight_blocker_count: number
    current_p0_drill_preflight_break_glass_required: boolean
    current_p0_drill_preflight_execution_authorized_by_this_endpoint: boolean
    current_p0_drill_preflight_runtime_write_allowed: boolean
    gitea_private_inventory_blocker_count: number
    credential_escrow_blocker_count: number
    production_deploy_hard_blocker_count: number
    secret_values_collected: boolean
    workflow_trigger_authorized: boolean
    runtime_write_authorized: boolean
  }
  summary: {
    source_count: number
    loaded_source_count: number
    average_completion_percent: number
    high_risk_blocker_count: number
    runtime_execution_authorized: boolean
    remote_write_authorized: boolean
    repo_creation_authorized: boolean
    visibility_change_authorized: boolean
    refs_sync_authorized: boolean
    workflow_trigger_authorized: boolean
    gitea_private_inventory_status: string
    gitea_private_inventory_workplan_id: string
    gitea_private_inventory_source: string
    gitea_private_inventory_review_readiness_percent: number
    gitea_private_inventory_active_blocker_count: number
    gitea_private_inventory_repo_inventory_status: string
    gitea_private_inventory_visibility_scope: string
    gitea_private_inventory_public_repo_count: number
    gitea_private_inventory_expected_product_count: number
    gitea_private_inventory_present_product_row_count: number
    gitea_private_inventory_missing_product_row_count: number
    gitea_private_inventory_accepted_payload_count: number
    gitea_private_inventory_owner_coverage_attestation_received_count: number
    gitea_private_inventory_all_active_product_repos_have_owner_readiness_row: boolean
    gitea_private_inventory_safe_next_step: string
    github_global_freeze_enabled: boolean
    github_lane_status: string
    github_lane_excluded_from_p0_blocker_count: boolean
    production_deploy_status: string
    production_deploy_source_control_main_ready: boolean
    production_deploy_image_tag_matches_main: boolean
    production_deploy_runtime_build_commit_sha: string
    production_deploy_runtime_build_commit_short_sha: string
    production_deploy_runtime_build_readback_status: string
    production_deploy_runtime_build_matches_gitops_desired_image_tag: boolean
    production_deploy_runtime_build_deploy_readback_current: boolean
    production_deploy_runtime_build_committed_readback_drift_accepted: boolean
    production_deploy_runtime_build_matches_committed_source_control_readback: boolean
    production_deploy_runtime_build_matches_committed_production_image_tag: boolean
    production_deploy_desired_main_api_image_tag_short_sha: string
    production_deploy_desired_main_api_image_tag_readback_status: string
    production_deploy_governance_fields_present: boolean
    production_deploy_authorized_dispatch_channel_ready: boolean
    production_deploy_manual_run_button_visible: boolean
    production_deploy_gitea_sign_in_required: boolean
    production_deploy_dispatch_without_token_http_status: number
    production_deploy_dispatch_without_token_message: string
    production_deploy_hard_blocker_count: number
    production_deploy_latest_visible_cd_run_id: string
    production_deploy_latest_visible_cd_run_status: string
    production_deploy_latest_visible_cd_run_jobs_total_count: number
    production_deploy_gitea_actions_list_without_token_http_status: number
    production_deploy_gitea_actions_list_without_token_message: string
    production_deploy_latest_visible_waiting_runner_run_id: string
    production_deploy_latest_visible_waiting_runner_workflow: string
    production_deploy_latest_visible_waiting_runner_kind: string
    production_deploy_latest_visible_waiting_runner_status: string
    production_deploy_latest_visible_waiting_runner_label: string
    production_deploy_public_actions_queue_readback_schema_version: string
    production_deploy_public_actions_queue_readback_verifier: string
    production_deploy_non110_runner_cd_closure_verifier_schema_version: string
    production_deploy_non110_runner_cd_closure_verifier: string
    production_deploy_non110_runner_cd_closure_status: string
    production_deploy_non110_runner_cd_closure_required: boolean
    production_deploy_non110_runner_cd_closure_ordered_step_count: number
    production_deploy_non110_runner_cd_closure_ordered_completed_prefix_count: number
    production_deploy_non110_runner_cd_closure_evidence_completed_step_count: number
    production_deploy_non110_runner_cd_closure_ordered_completion_percent: number
    production_deploy_non110_runner_cd_closure_evidence_completion_percent: number
    production_deploy_non110_runner_cd_closure_next_blocked_step_index: number
    production_deploy_non110_runner_cd_closure_next_blocked_step_id: string
    production_deploy_non110_runner_cd_closure_next_blocked_step_action: string
    production_deploy_non110_runner_ready: boolean
    production_deploy_non110_runner_prepare_only_source_ready: boolean
    production_deploy_non110_runner_safe_registration_helper_ready: boolean
    production_deploy_non110_runner_workflow_labels_aligned: boolean
    production_deploy_non110_runner_host_label: string
    production_deploy_non110_runner_ubuntu_label: string
    production_deploy_non110_runner_online_label_match: boolean
    production_deploy_non110_runner_autostart_path_armed: boolean
    production_deploy_non110_runner_ready_autostart_path_count: number
    production_deploy_non110_runner_registration_condition_required: boolean
    production_deploy_non110_runner_ready_config_count: number
    production_deploy_non110_runner_ready_service_count: number
    production_deploy_non110_runner_ready_registration_count: number
    production_deploy_non110_runner_safe_next_step: string
    production_deploy_non110_runner_remaining_blocker_count: number
    backup_credential_escrow_intake_scorecard_schema_version: string
    backup_credential_escrow_intake_scorecard_verifier: string
    backup_credential_escrow_intake_status: string
    backup_credential_escrow_active_gate_present: boolean
    backup_credential_escrow_preflight_status: string
    backup_credential_escrow_required_item_count: number
    backup_credential_escrow_effective_missing_count: number
    backup_credential_escrow_owner_response_received_count: number
    backup_credential_escrow_owner_response_accepted_count: number
    backup_credential_escrow_runtime_gate_count: number
    backup_credential_escrow_secret_value_collection_allowed: boolean
    backup_credential_marker_write_authorized_count: number
    backup_credential_escrow_forbidden_true_field_count: number
    github_write_channel_ready: boolean
    github_account_status: string
    github_account_suspended: boolean
    github_api_forbidden_count: number
    github_controlled_apply_ready_count: number
    github_blocked_preflight_target_count: number
    github_operator_unblock_required: boolean
    github_operator_unblock_status: string
    secret_values_collected: boolean
  }
  source_statuses: Array<{
    id: string
    loaded: boolean
    schema_version: string
    generated_at: string
    missing_reason: string
  }>
  lanes: Array<{
    id:
      | 'release'
      | 'production_deploy'
      | 'gitea_private_inventory'
      | 'cicd_baseline'
      | 'reboot_auto_recovery'
      | 'credential_escrow'
      | 'gitea'
      | 'runtime'
      | 'backup'
    source_id: string
    completion_percent: number
    status: string
    blocker_count: number
    metric:
      | { kind: 'blocked_gate'; blocked: number; total: number }
      | {
          kind: 'deploy_readback'
          observed_source_control_main_short_sha: string
          production_image_tag_short_sha: string
          production_image_tag_matches_main: boolean
          runtime_build_commit_short_sha: string
          runtime_build_readback_status: string
          runtime_build_matches_gitops_desired_image_tag: boolean
          runtime_build_deploy_readback_current: boolean
          runtime_build_committed_readback_drift_accepted: boolean
          runtime_build_matches_committed_source_control_readback: boolean
          runtime_build_matches_committed_production_image_tag: boolean
          desired_main_api_image_tag_short_sha: string
          desired_main_api_image_tag_readback_status: string
          current_main_cd_run_visible: boolean
          authorized_dispatch_channel_ready: boolean
          manual_run_button_visible: boolean
          gitea_sign_in_required: boolean
          dispatch_without_token_http_status: number
          dispatch_without_token_message: string
          latest_visible_cd_run_id: string
          latest_visible_cd_run_status: string
          latest_visible_cd_run_jobs_total_count: number
          gitea_actions_list_without_token_http_status: number
          gitea_actions_list_without_token_message: string
          latest_visible_waiting_runner_run_id: string
          latest_visible_waiting_runner_workflow: string
          latest_visible_waiting_runner_kind: string
          latest_visible_waiting_runner_status: string
          latest_visible_waiting_runner_label: string
          public_actions_queue_readback_schema_version: string
          public_actions_queue_readback_verifier: string
          non110_runner_cd_closure_verifier_schema_version: string
          non110_runner_cd_closure_verifier: string
          non110_runner_cd_closure_status: string
          non110_runner_cd_closure_required: boolean
          non110_runner_cd_closure_ordered_step_count: number
          non110_runner_cd_closure_ordered_completed_prefix_count: number
          non110_runner_cd_closure_evidence_completed_step_count: number
          non110_runner_cd_closure_ordered_completion_percent: number
          non110_runner_cd_closure_evidence_completion_percent: number
          non110_runner_cd_closure_next_blocked_step_index: number
          non110_runner_cd_closure_next_blocked_step_id: string
          non110_runner_cd_closure_next_blocked_step_action: string
          non110_runner_ready: boolean
          non110_runner_prepare_only_source_ready: boolean
          non110_runner_safe_registration_helper_ready: boolean
          non110_runner_workflow_labels_aligned: boolean
          non110_runner_host_label: string
          non110_runner_ubuntu_label: string
          non110_runner_online_label_match: boolean
          non110_runner_autostart_path_armed: boolean
          non110_runner_ready_autostart_path_count: number
          non110_runner_registration_condition_required: boolean
          non110_runner_ready_config_count: number
          non110_runner_ready_service_count: number
          non110_runner_ready_registration_count: number
          non110_runner_safe_next_step: string
          non110_runner_remaining_blocker_count: number
        }
      | {
          kind: 'private_inventory'
          workplan_id: string
          private_inventory_source: string
          gitea_repo_inventory_status: string
          gitea_visibility_scope: string
          gitea_public_repo_count: number
          expected_product_count: number
          present_product_row_count: number
          missing_product_row_count: number
          accepted_inventory_payload_count: number
          owner_coverage_attestation_received_count: number
          github_lane_excluded_from_p0_blocker_count: boolean
          active_blockers: string[]
        }
      | {
          kind: 'source_readiness'
          workplan_id: string
          required_source_count: number
          present_required_source_count: number
          missing_required_source_count: number
          source_readiness_percent: number
          blocked_source_ids: string[]
          workflow_modification_allowed: boolean
          workflow_trigger_allowed: boolean
          safe_next_step: string
        }
      | {
          kind: 'reboot_auto_recovery_slo'
          workplan_id: string
          target_minutes: number
          can_claim_all_services_recovered_within_target: boolean
          active_blockers: string[]
          post_start_blocked: number
          service_green: boolean
          product_data_green: boolean
          backup_core_green: boolean
          observed_host_count: number
          missing_host_count: number
          unreachable_host_count: number
          stale_host_count: number
          stockplatform_freshness_status: string
          stockplatform_ingestion_status: string
          stockplatform_freshness_blocker_count: number
          stockplatform_ingestion_blocker_count: number
          stockplatform_freshness_blockers: string[]
          stockplatform_ingestion_blockers: string[]
          stockplatform_eod_classification: string
          stockplatform_eod_next_action: string
          stockplatform_final_retry_window_end_local: string
          stockplatform_final_retry_window_passed: boolean
          stockplatform_controlled_recovery_gate_required: boolean
          stockplatform_controlled_recovery_gate_status: string
          host_reboot_performed: boolean
          service_restart_performed: boolean
          database_write_or_restore_performed: boolean
          secret_value_collection_allowed: boolean
        }
      | {
          kind: 'credential_escrow_evidence'
          workplan_id: string
          required_item_count: number
          effective_missing_count: number
          active_gate_present: boolean
          preflight_status: string
          accepted_item_count: number
          owner_response_received_count: number
          owner_response_accepted_count: number
          runtime_gate_count: number
          secret_value_collection_allowed: boolean
          credential_marker_write_authorized_count: number
          forbidden_true_field_count: number
          controlled_closeout_status: string
          controlled_closeout_redacted_receipt_writeback_ready_count: number
          controlled_closeout_source_ref: string
          controlled_closeout_projected_effective_missing_count: number
          single_preflight_intake_ready: boolean
          single_preflight_intake_ready_count: number
          single_preflight_intake_schema_version: string
          single_preflight_required_item_count: number
          single_preflight_secret_value_collection_allowed: boolean
          single_preflight_credential_marker_write_performed: boolean
          single_preflight_runtime_action_performed: boolean
          owner_response_skeleton_required_item_count: number
          owner_response_skeleton_secret_value_collection_allowed: boolean
          scorecard_schema_version: string
          scorecard_verifier: string
        }
      | { kind: 'workflow_count'; count: number }
      | { kind: 'surface_count'; total: number }
      | {
          kind: 'readiness_row_count'
          rows: number
          credential_escrow_intake_scorecard_schema_version: string
          credential_escrow_intake_scorecard_verifier: string
          credential_escrow_intake_status: string
          credential_escrow_active_gate_present: boolean
          credential_escrow_preflight_status: string
          credential_escrow_required_item_count: number
          credential_escrow_effective_missing_count: number
          credential_escrow_owner_response_received_count: number
          credential_escrow_owner_response_accepted_count: number
          credential_escrow_runtime_gate_count: number
          credential_escrow_secret_value_collection_allowed: boolean
          credential_marker_write_authorized_count: number
          credential_escrow_forbidden_true_field_count: number
        }
    href: string
    operator_unblock?: DeliveryOperatorUnblock
    next_action: string
    tone: 'ok' | 'warn' | 'danger'
  }>
  next_focus: Array<{
    lane_id: string
    blocker_count: number
    completion_percent: number
    next_action: string
  }>
  operation_boundaries: {
    read_only_api_allowed: true
    runtime_write_allowed: boolean
    remote_write_allowed: boolean
    repo_creation_allowed: boolean
    visibility_change_allowed: boolean
    refs_sync_allowed: boolean
    workflow_trigger_allowed: boolean
    gitea_api_write_allowed: boolean
    gitea_authenticated_inventory_import_execution_allowed: boolean
    github_write_channel_ready: boolean
    github_controlled_apply_allowed: boolean
    secret_value_collection_allowed: boolean
    backup_restore_execution_allowed: boolean
    active_scan_allowed: boolean
  }
}

export interface AiAgent12AgentWarRoomSnapshot {
  schema_version: 'ai_agent_12_agent_war_room_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-143'
    next_task_id: 'P2-144'
    read_only_mode: true
    runtime_authority: '12_agent_war_room_read_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  coordination_model: {
    logical_agent_count: number
    subagent_batch_limit: number
    subagent_batch_count: number
    coordination_mode: string
    arbiter: string
    memory_owner: string
    replay_owner: string
    gateway_owner: string
    summary: string
  }
  agent_roles: Array<{
    agent_id: string
    display_name: string
    primary_agent: string
    war_room_role: string
    review_status: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    work_units: number
    evidence_items: number
    blocker_count: number
    approval_required_count: number
    live_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    next_action: string
  }>
  workload_summary: {
    total_work_units: number
    total_evidence_items: number
    status_report_visible: boolean
    chart_ready: boolean
    daily_report_required: boolean
    weekly_report_required: boolean
    monthly_report_required: boolean
    standard_agent_metrics: string[]
  }
  risk_policy: {
    low_risk_auto_handle: string
    medium_risk_auto_handle: string
    high_risk_requires_approval: string
    openclaw_gate_required: boolean
    qa_verifier_required: boolean
    security_gate_required: boolean
  }
  reporting_contract: Record<'daily' | 'weekly' | 'monthly', {
    required: boolean
    delivery_mode: string
    sections: string[]
  }>
  market_watch_contract: {
    cadence: string
    auto_collect_allowed: string[]
    approval_required: string[]
    p0_refresh_candidates: string[]
    candidate_package_required_fields: string[]
  }
  telegram_contract: {
    direct_send_allowed: boolean
    bot_api_call_allowed: boolean
    success_immediate_send_allowed: boolean
    action_required_digest_allowed_after_approval: boolean
    failure_only_escalation: boolean
    dedup_required: boolean
    receipt_required: boolean
    forbidden_actions: string[]
    summary: string
  }
  display_redaction_contract: {
    redaction_required: boolean
    conversation_transcript_display_allowed: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: {
    agent_role_count: number
    read_only_review_completed_count: number
    subagent_batch_limit: number
    subagent_batch_count: number
    approval_required_total: number
    blocker_total: number
    total_work_units: number
    total_evidence_items: number
    daily_report_required_count: number
    weekly_report_required_count: number
    monthly_report_required_count: number
    market_refresh_candidate_count: number
    live_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    production_write_count: number
    paid_api_call_count: number
    sdk_install_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentProfessionalTaskExpansionSnapshot {
  schema_version: 'ai_agent_professional_task_expansion_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-405F'
    next_task_id: 'P2-406B'
    read_only_mode: true
    runtime_authority: 'professional_task_expansion_and_telegram_bridge_read_only_no_send'
    status_note: string
  }
  source_refs: string[]
  telegram_runtime_bridge: {
    canonical_room: string
    canonical_room_env: string
    gateway_required: boolean
    gateway_owner: string
    arbiter: string
    receipt_owner: string
    replay_owner: string
    no_send_preview_ready: boolean
    queue_preview_readback_ready: boolean
    approved_canary_required: boolean
    direct_bot_api_allowed: boolean
    bot_api_call_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    delivery_receipt_write_enabled: boolean
    stages: Array<{
      stage_id: string
      title: string
      status: string
      allowed_output: string
      live_send_enabled: boolean
      exit_condition: string
    }>
    message_types: Array<{
      message_type: string
      cadence: string
      risk_tier: string
      owner_agent: string
      send_policy: string
    }>
    no_send_message_previews: Array<{
      preview_id: string
      message_type: string
      title: string
      target_room_alias: string
      target_room_env: string
      owner_agent: string
      risk_tier: 'low' | 'medium' | 'high' | 'critical'
      status: string
      dedup_key: string
      receipt_expectation_id: string
      approval_required_before_send: boolean
      canary_required_before_live: boolean
      send_enabled: boolean
      gateway_queue_write_enabled: boolean
      bot_api_call_enabled: boolean
      delivery_receipt_write_enabled: boolean
      sanitized_body_lines: string[]
      redaction_checks: string[]
    }>
    dedup_policy: {
      required: boolean
      key_count: number
      collision_policy: string
      preview_hash_algorithm: string
      live_cache_write_enabled: boolean
      keys: Array<{
        message_type: string
        key_template: string
        owner_agent: string
        risk_tier: string
        window: string
        live_cache_write_enabled: boolean
      }>
    }
    queue_preview_readback: {
      enabled: boolean
      preview_only: boolean
      write_enabled: boolean
      readback_enabled: boolean
      envelope_fields: string[]
      readback_checks: string[]
    }
    receipt_expectations: Array<{
      receipt_id: string
      message_type: string
      preview_id: string
      expected_signal: string
      required_evidence_refs: string[]
      receipt_write_enabled: boolean
      production_receipt_readback_enabled: boolean
      missing_receipt_policy: string
    }>
    canary_approval_package: {
      package_id: string
      status: string
      package_ready: boolean
      approval_required: boolean
      target_room_alias: string
      target_room_env: string
      arbiter: string
      owner_agent: string
      reviewers: string[]
      message_type_scope: string[]
      required_approval_inputs: string[]
      approval_checklist: string[]
      live_send_enabled: boolean
      gateway_queue_write_enabled: boolean
      bot_api_call_enabled: boolean
      delivery_receipt_write_enabled: boolean
      production_write_enabled: boolean
    }
    canary_send_approval_packet: {
      packet_id: string
      status: string
      packet_ready: boolean
      approval_required: boolean
      approval_granted: boolean
      recommended_first_message_type: string
      selected_message_type: string
      eligible_message_types: string[]
      target_room_alias: string
      target_room_env: string
      target_room_value_visible: boolean
      proposed_time_window: string
      owner_agent: string
      arbiter: string
      reviewers: string[]
      operator_approval_fields: Array<{
        field_id: string
        label: string
        required: boolean
        current_value_status: string
        value_display_allowed: boolean
      }>
      rate_limit_plan: {
        max_messages: number
        window: string
        cooldown_after_attempt_minutes: number
        duplicate_policy: string
        live_rate_limit_write_enabled: boolean
      }
      mute_rollback_plan: string[]
      receipt_readback_plan: {
        owner_agent: string
        required_checks: string[]
        production_receipt_write_enabled: boolean
        receipt_readback_enabled_before_send: boolean
      }
      stop_conditions: string[]
      execution_flags: {
        canary_send_execution_enabled: boolean
        gateway_queue_write_enabled: boolean
        bot_api_call_enabled: boolean
        delivery_receipt_write_enabled: boolean
        production_write_enabled: boolean
        secret_read_enabled: boolean
        paid_api_enabled: boolean
      }
      approval_decision_log: unknown[]
    }
    canary_delivery_gate: {
      gate_id: string
      status: string
      gate_ready: boolean
      delivery_approved: boolean
      delivery_attempt_allowed: boolean
      selected_message_type: string
      selected_message_type_source: string
      target_room_alias: string
      target_room_env: string
      target_room_value_visible: boolean
      target_room_verified: boolean
      proposed_time_window: string
      approved_time_window: string
      owner_agent: string
      arbiter: string
      reviewers: string[]
      required_delivery_fields: Array<{
        field_id: string
        label: string
        required: boolean
        current_value_status: string
        value_display_allowed: boolean
      }>
      preflight_checks: string[]
      hold_reasons: string[]
      delivery_attempt_plan: {
        max_messages: number
        dry_run_message_type: string
        dedup_key_template: string
        send_mode: string
        live_delivery_enabled: boolean
        gateway_queue_write_enabled: boolean
        bot_api_call_enabled: boolean
        delivery_receipt_write_enabled: boolean
        production_write_enabled: boolean
        secret_read_enabled: boolean
        paid_api_enabled: boolean
      }
      readback_after_approval_plan: {
        owner_agent: string
        enabled_before_delivery: boolean
        production_receipt_write_enabled: boolean
        required_checks: string[]
      }
      rollback_mute_controls: string[]
      execution_flags: {
        live_delivery_enabled: boolean
        gateway_queue_write_enabled: boolean
        bot_api_call_enabled: boolean
        delivery_receipt_write_enabled: boolean
        production_write_enabled: boolean
        secret_read_enabled: boolean
        paid_api_enabled: boolean
      }
      delivery_decision_log: unknown[]
    }
    canary_delivery_rehearsal: {
      rehearsal_id: string
      status: string
      rehearsal_ready: boolean
      selected_message_type: string
      selected_preview_id: string
      selected_receipt_expectation_id: string
      target_room_alias: string
      target_room_env: string
      target_room_value_visible: boolean
      dry_run_window: string
      preview_hash_algorithm: string
      sanitized_preview_hash: string
      dedup_key: string
      gateway_envelope_preview: {
        message_type: string
        target_room_env_ref: string
        dedup_key: string
        preview_hash: string
        risk_tier: string
        queue_write_enabled: boolean
        bot_api_call_enabled: boolean
        telegram_send_enabled: boolean
        delivery_receipt_write_enabled: boolean
      }
      dry_run_steps: string[]
      readback_drill: {
        owner_agent: string
        required_checks: string[]
        completed_check_count: number
        failed_check_count: number
        production_receipt_write_enabled: boolean
        live_receipt_readback_enabled: boolean
      }
      stop_conditions: string[]
      rollback_mute_controls: string[]
      execution_flags: {
        live_delivery_enabled: boolean
        gateway_queue_write_enabled: boolean
        bot_api_call_enabled: boolean
        telegram_send_enabled: boolean
        delivery_receipt_write_enabled: boolean
        production_write_enabled: boolean
        secret_read_enabled: boolean
        paid_api_enabled: boolean
      }
      next_gate: string
    }
    canary_live_delivery_owner_review_gate: {
      gate_id: string
      status: string
      gate_ready: boolean
      approval_required: boolean
      owner_review_received: boolean
      owner_review_accepted: boolean
      live_canary_delivery_approved: boolean
      delivery_attempt_allowed: boolean
      prior_rehearsal_id: string
      prior_rehearsal_status: string
      prior_readback_completed_check_count: number
      prior_readback_failed_check_count: number
      selected_message_type: string
      selected_preview_id: string
      selected_receipt_expectation_id: string
      target_room_alias: string
      target_room_env: string
      target_room_value_visible: boolean
      dedup_key: string
      sanitized_preview_hash: string
      owner_agent: string
      receipt_readback_owner: string
      arbiter: string
      reviewers: string[]
      required_owner_fields: Array<{
        field_id: string
        label: string
        required: boolean
        current_value_status: string
        value_display_allowed: boolean
      }>
      acceptance_checks: string[]
      rejection_reasons: string[]
      reviewer_actions: string[]
      receipt_readback_plan: {
        owner_agent: string
        required_checks: string[]
        completed_check_count: number
        failed_check_count: number
        production_receipt_write_enabled: boolean
        live_receipt_readback_enabled: boolean
      }
      execution_flags: {
        live_delivery_enabled: boolean
        gateway_queue_write_enabled: boolean
        bot_api_call_enabled: boolean
        telegram_send_enabled: boolean
        delivery_receipt_write_enabled: boolean
        production_write_enabled: boolean
        secret_read_enabled: boolean
        paid_api_enabled: boolean
      }
      owner_decision_log: unknown[]
      next_gate: string
    }
    no_send_preview_completion_percent: number
    canary_approval_package_completion_percent: number
    canary_send_approval_packet_ready: boolean
    canary_send_approval_granted: boolean
    canary_send_execution_enabled: boolean
    canary_send_approval_packet_completion_percent: number
    canary_delivery_gate_ready: boolean
    canary_delivery_approved: boolean
    canary_delivery_attempt_allowed: boolean
    canary_delivery_gate_completion_percent: number
    canary_delivery_rehearsal_ready: boolean
    canary_delivery_rehearsal_completion_percent: number
    canary_live_delivery_owner_review_ready: boolean
    canary_live_delivery_owner_review_received: boolean
    canary_live_delivery_owner_review_accepted: boolean
    canary_live_delivery_approved: boolean
    canary_live_delivery_owner_review_completion_percent: number
  }
  professional_task_domains: Array<{
    domain_id: string
    label: string
    owner_agent: string
  }>
  professional_tasks: Array<{
    task_id: string
    title: string
    domain_id: string
    owner_agent: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    automation_mode: string
    telegram_policy: string
    required_mcp: string[]
    required_rag: string[]
    approval_required: boolean
    current_live_count_24h: number
    blocked_actions: string[]
  }>
  reporting_contract: Record<'daily' | 'weekly' | 'monthly' | 'action_required', {
    required: boolean
    owner_agent: string
    telegram_stage: string
  }>
  redaction_contract: {
    redaction_required: boolean
    conversation_transcript_display_allowed: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    telegram_message_must_be_sanitized: boolean
    frontend_display_policy: string
    message_preview_redaction_checks: string[]
    canary_packet_redaction_checks: string[]
    canary_delivery_redaction_checks: string[]
  }
  rollups: {
    professional_task_count: number
    domain_count: number
    telegram_stage_count: number
    telegram_message_type_count: number
    approval_required_count: number
    low_risk_task_count: number
    medium_risk_task_count: number
    high_risk_task_count: number
    critical_risk_task_count: number
    current_live_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    delivery_receipt_write_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
    no_send_preview_count: number
    dedup_key_count: number
    receipt_expectation_count: number
    canary_approval_package_count: number
    queue_preview_envelope_field_count: number
    canary_required_preview_count: number
    approval_required_preview_count: number
    preview_send_enabled_count: number
    preview_queue_write_enabled_count: number
    preview_bot_api_call_enabled_count: number
    receipt_live_write_enabled_count: number
    canary_live_send_enabled_count: number
    canary_send_approval_packet_count: number
    canary_operator_approval_field_count: number
    canary_stop_condition_count: number
    canary_rollback_mute_step_count: number
    canary_receipt_readback_check_count: number
    canary_approval_granted_count: number
    canary_selected_message_type_count: number
    canary_approved_time_window_count: number
    canary_send_execution_enabled_count: number
    canary_gateway_queue_write_enabled_count: number
    canary_bot_api_call_enabled_count: number
    canary_delivery_receipt_write_enabled_count: number
    canary_secret_read_enabled_count: number
    canary_delivery_gate_count: number
    canary_delivery_required_field_count: number
    canary_delivery_preflight_check_count: number
    canary_delivery_hold_reason_count: number
    canary_delivery_readback_check_count: number
    canary_delivery_rollback_mute_control_count: number
    canary_delivery_approved_count: number
    canary_delivery_attempt_allowed_count: number
    canary_delivery_live_send_enabled_count: number
    canary_delivery_gateway_queue_write_enabled_count: number
    canary_delivery_bot_api_call_enabled_count: number
    canary_delivery_secret_read_enabled_count: number
    canary_delivery_paid_api_enabled_count: number
    canary_delivery_rehearsal_count: number
    canary_delivery_rehearsal_step_count: number
    canary_delivery_rehearsal_readback_check_count: number
    canary_delivery_rehearsal_stop_condition_count: number
    canary_delivery_rehearsal_rollback_mute_control_count: number
    canary_delivery_rehearsal_completed_check_count: number
    canary_delivery_rehearsal_failed_check_count: number
    canary_delivery_rehearsal_live_send_enabled_count: number
    canary_delivery_rehearsal_gateway_queue_write_enabled_count: number
    canary_delivery_rehearsal_bot_api_call_enabled_count: number
    canary_delivery_rehearsal_receipt_write_enabled_count: number
    canary_live_delivery_owner_review_gate_count: number
    canary_live_delivery_owner_review_required_field_count: number
    canary_live_delivery_owner_review_acceptance_check_count: number
    canary_live_delivery_owner_review_rejection_reason_count: number
    canary_live_delivery_owner_review_reviewer_action_count: number
    canary_live_delivery_owner_review_receipt_check_count: number
    canary_live_delivery_owner_review_received_count: number
    canary_live_delivery_owner_review_accepted_count: number
    canary_live_delivery_approved_count: number
    canary_live_delivery_attempt_allowed_count: number
    canary_live_delivery_gateway_queue_write_enabled_count: number
    canary_live_delivery_bot_api_call_enabled_count: number
    canary_live_delivery_telegram_send_enabled_count: number
    canary_live_delivery_receipt_write_enabled_count: number
  }
}

export interface AiAgentReceiptReadbackOwnerReviewSnapshot {
  schema_version: 'ai_agent_receipt_readback_owner_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-406B'
    next_task_id: 'P2-407'
    read_only_mode: true
    runtime_authority: 'receipt_readback_owner_review_only_no_send_or_write'
    status_note: string
  }
  source_refs: string[]
  source_readbacks: Array<{
    readback_id: string
    source_schema_version: string
    source_ref: string
    endpoint: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    evidence_status: string
    key_readback: string
    next_action: string
  }>
  rollups: {
    source_readback_count: number
    report_cadence_count: number
    owner_review_gate_count: number
    receipt_readback_check_count: number
    drift_candidate_count: number
    report_truth_blocker_count: number
    approval_required_count: number
    blocked_runtime_action_count: number
    live_write_count: number
    telegram_send_count: number
    gateway_queue_write_count: number
    bot_api_call_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
  }
  report_owner_review: {
    cadences: Array<{
      cadence_id: 'daily' | 'weekly' | 'monthly'
      display_name: string
      owner_agent: 'openclaw' | 'hermes' | 'nemotron'
      completion_percent: number
      delivery_state: string
      source_confidence: string
      live_delivery_count: number
      review_status: string
      next_gate: string
    }>
  }
  receipt_readback_plan: {
    canonical_room: string
    canonical_room_env: string
    gateway_owner: string
    arbiter: 'openclaw'
    receipt_owner: 'hermes'
    replay_owner: 'nemotron'
    dry_run_receipt_only: boolean
    owner_review_required_before_canary: boolean
    canary_send_approved: boolean
    receipt_production_write_enabled: boolean
    readback_checks: Array<{
      check_id: string
      owner_agent: 'openclaw' | 'hermes' | 'nemotron'
      status: string
      evidence_refs: string[]
      blocked_runtime_action: string
    }>
  }
  owner_review_gates: Array<{
    gate_id: string
    title: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    status: string
    approval_required: true
    required_owner_fields: string[]
    acceptance_checks: string[]
    rejection_reasons: string[]
    blocked_runtime_actions: string[]
    evidence_refs: string[]
    next_action: string
  }>
  drift_monitor_owner_review: {
    source_task_id: 'P2-004'
    drift_candidate_count: number
    action_required_candidate_count: number
    stale_source_snapshot_count: number
    external_lookup_allowed: false
    package_upgrade_allowed: false
    owner_actions: string[]
  }
  report_truth_owner_review: {
    source_task_id: 'P2-403J'
    all_zero_weekly_report_is_actionable_anomaly: true
    all_zero_weekly_report_confidence: 'low_trust_actionable_anomaly'
    zero_signal_finding_count: number
    critical_finding_count: number
    high_finding_count: number
    telegram_report_send_allowed: false
    cronjob_change_allowed: false
    freshness_gate_implemented: false
    source_confidence_gate_implemented: false
    actionability_score_implemented: false
    owner_actions: string[]
  }
  activation_boundaries: Record<string, boolean>
  telegram_policy: {
    status: string
    canonical_room: string
    canonical_room_env: string
    gateway_queue_write_allowed: false
    direct_bot_api_allowed: false
    telegram_send_allowed: false
    receipt_write_allowed: false
    owner_review_required?: boolean
    canary_message_limit?: number
    canary_approval_task?: string
  }
  agent_roles: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    role: string
    specialty: string
    autonomy_level: string
    approval_gate: string
    runtime_write_allowed: false
    outputs: string[]
  }>
  operator_decision: {
    status: 'owner_review_required_before_canary'
    approval_packet_required: true
    rollback_plan_required: true
    mute_plan_required: true
    required_fields: string[]
    stop_conditions: string[]
    next_decision_point: string
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface AiAgentProactiveOperationsContractSnapshot {
  schema_version: 'ai_agent_proactive_operations_contract_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: string
    status_note: string
  }
  delegation_model: {
    autonomy_levels: Array<{
      level: string
      meaning: string
    }>
    agent_responsibilities: Array<{
      agent_id: string
      responsibility: string
    }>
    telegram_policy: {
      allowed_now: string
      failure_only: string
      success_spam: string
    }
  }
  version_lifecycle_domains: Array<{
    domain_id: string
    display_name: string
    primary_owner: string
    cadence: string
    current_allowed_autonomy: string
    update_authority: string
    approval_gate: string
    tracked_examples: string[]
  }>
  delegable_capabilities: Array<{
    capability_id: string
    display_name: string
    primary_owner: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    automation_level: string
    outputs: string[]
    approval_gate: string
    telegram_policy: string
  }>
  cadence_matrix: Array<{
    cadence_id: string
    frequency: string
    scope: string
    allowed_now: boolean
    next_gate: string
  }>
  mcp_tool_requirements: Array<{
    tool_id: string
    display_name: string
    purpose: string
    owner_agent: string
    status: string
    approval_gate: string
  }>
  rag_memory_contract: Array<{
    memory_id: string
    display_name: string
    storage: string
    owner_agent: string
    purpose: string
    redaction_policy: string
  }>
  rollout_tasks: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    status: string
    completion_percent: number
    owner_agent: string
    summary: string
    next_gate: string
  }>
  approval_boundaries: Record<string, false>
  rollups: {
    version_domain_count: number
    delegable_capability_count: number
    cadence_count: number
    mcp_tool_count: number
    rag_memory_count: number
    rollout_task_count: number
    auto_execute_allowed_count: number
    approval_required_capability_count: number
    blocked_update_domain_ids: string[]
    telegram_action_required_capability_ids: string[]
  }
}

export interface AiAgentVersionLifecycleUpdateProposalSnapshot {
  schema_version: 'ai_agent_version_lifecycle_update_proposal_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: string
    status_note: string
  }
  source_refs: string[]
  agent_roles: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    role: string
    responsibility: string
  }>
  lifecycle_domains: Array<{
    domain_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    cadence: string
    decision_policy: string
    current_authority: string
  }>
  update_proposals: Array<{
    proposal_id: string
    domain_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    status: string
    summary: string
    evidence_refs: string[]
    approval_gate: string
    requires_owner_approval: true
    direct_update_allowed: false
    auto_execution_allowed: false
    validation_plan: string[]
    rollback_plan: string[]
    blocked_runtime_actions: string[]
    telegram_policy: string
  }>
  cadence_matrix: Array<{
    cadence_id: string
    frequency: string
    scope: string
    allowed_now: boolean
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    output: string
  }>
  approval_gate_matrix: Array<{
    gate_id: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    owner_approval_required: true
    auto_execute_allowed: false
    required_evidence: string[]
  }>
  telegram_digest_contract: {
    status: string
    direct_send_allowed: false
    gateway_queue_write_allowed: false
    bot_api_call_allowed: false
    success_noise_suppression: boolean
    draft_outputs: string[]
    redaction_required: boolean
  }
  runtime_boundaries: Record<string, boolean>
  rollups: {
    domain_count: number
    proposal_count: number
    cadence_count: number
    approval_gate_count: number
    read_only_proposal_count: number
    approval_required_count: number
    critical_candidate_count: number
    high_candidate_count: number
    false_runtime_boundary_count: number
    auto_execution_allowed_count: number
    telegram_direct_send_count: number
    telegram_gateway_queue_write_count: number
    production_write_count: number
    update_allowed_count: number
    domain_ids: string[]
    proposal_ids: string[]
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    summary: string
    gate: string
  }>
}

export interface HostRunawayAiopsLoopReadinessSnapshot {
  schema_version: 'host_runaway_aiops_loop_readiness_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P3'
    current_task_id: 'P3-009'
    next_task_id: 'P3-010'
    read_only_mode: true
    runtime_authority: 'host_runaway_aiops_loop_readiness_only_no_host_write'
    status_note: string
  }
  source_refs: string[]
  rollups: {
    loop_stage_count: number
    alert_lane_count: number
    asset_writeback_contract_count: number
    source_ref_count: number
    live_readback_metric_count: number
    blocked_runtime_action_count: number
    runtime_remediation_authorized_count: number
    telegram_send_count: number
    gateway_queue_write_count: number
    bot_api_call_count: number
    host_write_count: number
    process_termination_count: number
    docker_restart_count: number
    systemd_restart_count: number
    nginx_reload_count: number
    firewall_change_count: number
    kubectl_action_count: number
    production_write_count: number
  }
  loop_stages: Array<{
    stage_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    completion_percent: number
    evidence_refs: string[]
    next_action: string
    blocked_runtime_actions: string[]
  }>
  alert_lanes: Array<{
    alertname: 'HostOrphanBrowserSmokeHighCpu' | 'HostCiRunnerLoadSaturation'
    lane_id: 'orphan_browser_smoke_runaway_process' | 'ci_runner_load_saturation'
    classification: string
    action_policy: string
    dry_run_allowed: boolean
    apply_allowed_without_owner_gate: boolean
    runtime_write_gate: number
    next_action: string
  }>
  asset_writeback_contract: Array<{
    asset_id: string
    display_name: string
    required_on_real_incident: boolean
    live_write_enabled: boolean
    required_fields: string[]
  }>
  live_readback: {
    host_label: string
    monitor_up: number
    orphan_browser_group_count: number
    active_ci_container_count: number
    load5_per_core_upper_observed: number
    swap_used_ratio_upper_observed: number
    remediation_authorized_count: number
    alerts_firing_count: number
    deploy_marker: string
    runtime_revision: string
    argocd_sync: string
    argocd_health: string
    production_route_count: number
    forbidden_public_hit_count: number
  }
  remediation_gate: {
    dry_run_required: boolean
    owner_approval_required: boolean
    maintenance_window_required: boolean
    evidence_ref_required: boolean
    post_check_required: boolean
    allowed_signal_after_gate: 'SIGTERM'
    process_termination_authorized: boolean
    disallowed_actions: string[]
  }
  activation_boundaries: {
    read_only_readback_allowed: boolean
    ai_triage_packet_allowed: boolean
    dry_run_generation_allowed: boolean
    runtime_remediation_enabled: boolean
    process_termination_authorized: boolean
    telegram_send_enabled: boolean
    gateway_queue_write_enabled: boolean
    bot_api_call_enabled: boolean
    host_write_enabled: boolean
    docker_restart_enabled: boolean
    systemd_restart_enabled: boolean
    nginx_reload_enabled: boolean
    firewall_change_enabled: boolean
    kubectl_action_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
  }
  next_steps: Array<{
    step_id: string
    description: string
    runtime_write_allowed: boolean
  }>
}

export interface AiAgentInteractionLearningProofSnapshot {
  schema_version: 'ai_agent_interaction_learning_proof_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'proof_surface_only_no_live_worker'
    status_note: string
  }
  live_truth: {
    runtime_loop_enabled: false
    live_agent_session_readback_enabled: false
    redis_consumer_group_enabled: false
    telegram_send_enabled: false
    learning_writeback_enabled: false
    active_live_agent_sessions: number
    live_agent_messages_24h: number
    live_handoffs_24h: number
    live_learning_writes_24h: number
    telegram_digest_receipts_24h: number
    truth_note: string
  }
  proof_ladder: Array<{
    level_id: string
    display_name: string
    status: string
    completion_percent: number
    operator_meaning: string
    source_of_truth: string
    next_gate: string
  }>
  agent_lanes: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    primary_role: string
    current_visible_state: string
    visible_signals: string[]
    growth_metric: string
    what_operator_will_feel: string
  }>
  proof_signals: Array<{
    signal_id: string
    display_name: string
    category: string
    source_of_truth: string
    visible_surface: string
    current_state: string
    operator_interpretation: string
    next_gate: string
  }>
  operator_surfaces: Array<{
    surface_id: string
    display_name: string
    route_or_channel: string
    operator_feel: string
    redaction_policy: string
    current_state: string
  }>
  runtime_gates: Array<{
    gate_id: string
    display_name: string
    status: string
    required_before_green: string
    next_task_id: string
  }>
  learning_memory_stack: Array<{
    layer_id: string
    display_name: string
    storage_or_service: string
    visible_growth_signal: string
    current_state: string
  }>
  telegram_receipt_contract: {
    direct_send_allowed: false
    gateway_queue_write_allowed: false
    receipt_visible_to_operator: true
    allowed_future_notification_classes: string[]
    success_policy: string
    redaction_policy: string
  }
  frontend_redaction: {
    operator_conversation_display_allowed: false
    agent_private_reasoning_display_allowed: false
    raw_prompt_display_allowed: false
    display_policy: string
  }
  approval_boundaries: Record<string, false>
  rollups: {
    proof_level_count: number
    contract_ready_level_count: number
    live_pending_level_ids: string[]
    signal_count: number
    live_signal_count: number
    operator_surface_count: number
    runtime_gate_count: number
    blocked_gate_ids: string[]
    active_live_agent_sessions: number
    live_agent_messages_24h: number
    live_handoffs_24h: number
    live_learning_writes_24h: number
    telegram_digest_receipts_24h: number
  }
}

export interface AiAgentLiveReadModelGateSnapshot {
  schema_version: 'ai_agent_live_read_model_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'gate_plan_only_no_live_worker'
    status_note: string
  }
  source_refs: string[]
  live_truth: {
    live_agent_session_readback_enabled: false
    live_redis_stream_read_enabled: false
    runtime_worker_enabled: false
    telegram_receipt_send_enabled: false
    learning_writeback_enabled: false
    active_live_agent_sessions: number
    live_redis_events_24h: number
    live_handoffs_24h: number
    live_learning_writes_24h: number
    telegram_digest_receipts_24h: number
    truth_note: string
  }
  existing_storage_contract: {
    db_table: string
    schema_status: string
    migration_delta_required: false
    approved_for_live_query: false
    safe_read_query_defined: true
    safe_selected_fields: string[]
    forbidden_selected_fields: string[]
    required_indexes: string[]
    read_query_contract: string
    query_limits: {
      default_window_hours: number
      max_limit: number
      order_by: string
    }
  }
  redis_stream_contract: {
    stream_namespace: string
    candidate_streams: string[]
    consumer_group_allowed: false
    xadd_allowed: false
    xreadgroup_allowed: false
    dead_letter_required: boolean
    replay_required_before_worker: boolean
    event_envelope_required_fields: string[]
    forbidden_event_fields: string[]
  }
  read_model_cards: Array<{
    card_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_of_truth: string
    readiness_status: string
    operator_signal: string
    next_gate: string
  }>
  worker_gate_plan: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    required_evidence: string
    blocked_action: string
  }>
  rollback_plan: Array<{
    rollback_id: string
    step: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
  }>
  no_write_smoke_plan: Array<{
    smoke_id: string
    status: 'defined'
    writes_allowed: false
    assertion: string
  }>
  display_redaction_contract: {
    redaction_required: true
    work_window_conversation_display_allowed: false
    agent_raw_output_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  approval_boundaries: Record<string, false>
  rollups: {
    source_ref_count: number
    read_model_card_count: number
    gate_count: number
    approval_required_gate_ids: string[]
    query_contract_ready_card_ids: string[]
    rollback_step_count: number
    no_write_smoke_count: number
    forbidden_frontend_content_count: number
    live_truth_count_total: number
  }
}

export interface AiAgentRedisDryRunGateSnapshot {
  schema_version: 'ai_agent_redis_dry_run_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'dry_run_contract_only_no_redis_runtime'
    status_note: string
  }
  source_refs: string[]
  dry_run_truth: {
    redis_connection_allowed: false
    consumer_group_created: false
    xadd_allowed: false
    xreadgroup_allowed: false
    ack_allowed: false
    dead_letter_write_allowed: false
    replay_runtime_allowed: false
    telegram_send_allowed: false
    learning_writeback_allowed: false
    live_dry_run_event_count: number
    live_ack_count: number
    live_dead_letter_count: number
    live_replay_count: number
    truth_note: string
  }
  consumer_group_dry_run_contract: {
    candidate_group_name: string
    stream_namespace: string
    fixture_only: true
    redis_network_call_allowed: false
    required_fixture_fields: string[]
    forbidden_fixture_fields: string[]
    dry_run_assertion: string
  }
  handoff_envelope_contract: {
    required_fields: string[]
    forbidden_fields: string[]
    redacted_evidence_required: true
    idempotency_key_required: true
    operator_meaning: string
  }
  ack_dead_letter_replay_contract: {
    ack_requires_verifier: true
    dead_letter_requires_reason: true
    replay_requires_idempotency: true
    runtime_replay_allowed: false
    ack_allowed_statuses: string[]
    dead_letter_reasons: string[]
    replay_preconditions: string[]
  }
  dry_run_steps: Array<{
    step_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    operator_signal: string
    blocked_runtime_action: string
  }>
  handoff_lanes: Array<{
    lane_id: string
    display_name: string
    from_agent: 'openclaw' | 'hermes' | 'nemotron'
    to_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    required_evidence: string
  }>
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    source_ref_count: number
    dry_run_step_count: number
    handoff_lane_count: number
    contract_ready_step_ids: string[]
    approval_required_step_ids: string[]
    blocked_runtime_action_count: number
    required_handoff_field_count: number
    forbidden_field_count: number
    live_truth_count_total: number
  }
}

export interface AiAgentLearningWritebackApprovalPackageSnapshot {
  schema_version: 'ai_agent_learning_writeback_approval_package_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'approval_package_only_no_learning_writeback'
    status_note: string
  }
  source_refs: string[]
  learning_truth: {
    km_write_allowed: false
    playbook_trust_write_allowed: false
    timeline_learning_write_allowed: false
    agent_replay_score_write_allowed: false
    telegram_send_allowed: false
    runtime_worker_allowed: false
    live_learning_write_count: number
    live_playbook_trust_update_count: number
    live_km_update_count: number
    truth_note: string
  }
  writeback_package: {
    required_fields: string[]
    forbidden_fields: string[]
    owner_review_required: true
    rollback_required: true
    operator_meaning: string
  }
  review_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    required_evidence: string
    blocked_write_action: string
  }>
  learning_lanes: Array<{
    lane_id: string
    display_name: string
    target_surface: string
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    review_owner: string
    required_review: string
  }>
  rollback_contract: {
    rollback_required: true
    rollback_steps: string[]
  }
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    review_gate_count: number
    learning_lane_count: number
    approval_required_gate_ids: string[]
    blocked_write_action_count: number
    required_field_count: number
    forbidden_field_count: number
    live_write_count_total: number
  }
}

export interface AiAgentTelegramReceiptApprovalPackageSnapshot {
  schema_version: 'ai_agent_telegram_receipt_approval_package_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'approval_package_only_no_telegram_send'
    status_note: string
  }
  source_refs: string[]
  telegram_truth: {
    telegram_send_allowed: false
    gateway_queue_write_allowed: false
    direct_bot_api_allowed: false
    receiver_route_change_allowed: false
    runtime_worker_allowed: false
    live_queued_receipt_count: number
    live_delivered_receipt_count: number
    live_acknowledged_receipt_count: number
    live_failed_receipt_count: number
    live_retry_count: number
    truth_note: string
  }
  receipt_package: {
    required_fields: string[]
    forbidden_fields: string[]
    owner_review_required: true
    retry_policy_required: true
    delivery_receipt_required: true
    operator_meaning: string
  }
  receipt_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    required_evidence: string
    blocked_runtime_action: string
  }>
  receipt_lanes: Array<{
    lane_id: string
    display_name: string
    target_surface: string
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    review_owner: string
    required_review: string
  }>
  retry_contract: {
    retry_required: true
    retry_steps: string[]
  }
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    receipt_gate_count: number
    receipt_lane_count: number
    approval_required_gate_ids: string[]
    blocked_runtime_action_count: number
    required_field_count: number
    forbidden_field_count: number
    live_receipt_count_total: number
  }
}

export interface AiAgentOwnerApprovedLearningDryRunSnapshot {
  schema_version: 'ai_agent_owner_approved_learning_dry_run_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'owner_approved_dry_run_only_no_learning_write'
    status_note: string
  }
  source_refs: string[]
  dry_run_truth: {
    owner_approval_required: true
    owner_approval_received_count: number
    dry_run_preview_allowed: true
    dry_run_preview_generated_count: number
    km_write_allowed: false
    playbook_trust_write_allowed: false
    timeline_learning_write_allowed: false
    agent_replay_score_write_allowed: false
    telegram_send_allowed: false
    runtime_worker_allowed: false
    truth_note: string
  }
  dry_run_preview: {
    required_inputs: string[]
    forbidden_inputs: string[]
    preview_outputs: string[]
    operator_meaning: string
  }
  operator_actions: Array<{
    action_id: string
    display_name: string
    action_type: 'review' | 'collect_evidence' | 'approve_dry_run' | 'reject_or_rework'
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    blocked_runtime_action: string
  }>
  dry_run_gates: Array<{
    gate_id: string
    display_name: string
    status: string
    required_evidence: string
    blocked_write_action: string
  }>
  verification_contract: {
    verification_required: true
    verification_steps: string[]
    rollback_required: true
  }
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    operator_action_count: number
    dry_run_gate_count: number
    approval_required_gate_ids: string[]
    blocked_write_action_count: number
    required_input_count: number
    forbidden_input_count: number
    preview_output_count: number
    live_write_count_total: number
    dry_run_preview_generated_count: number
  }
}

export interface AiAgentRuntimeWriteGateReviewSnapshot {
  schema_version: 'ai_agent_runtime_write_gate_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'write_gate_review_only_no_runtime_write'
    status_note: string
  }
  source_refs: string[]
  runtime_write_truth: {
    runtime_write_allowed: false
    dual_approval_required: true
    dual_approval_received_count: number
    dry_run_hash_required: true
    dry_run_hash_verified_count: number
    post_write_verifier_required: true
    post_write_verifier_pass_count: number
    km_write_allowed: false
    playbook_trust_write_allowed: false
    timeline_learning_write_allowed: false
    agent_replay_score_write_allowed: false
    telegram_send_allowed: false
    truth_note: string
  }
  write_gate_review: {
    operator_meaning: string
    required_fields: string[]
    forbidden_fields: string[]
  }
  write_targets: Array<{
    target_id: string
    display_name: string
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    required_before_write: string
    blocked_write_action: string
  }>
  approval_gates: Array<{
    gate_id: string
    display_name: string
    status: string
    required_evidence: string
    blocked_runtime_action: string
  }>
  post_write_verification: {
    verification_required: true
    rollback_required: true
    verification_steps: string[]
  }
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    write_target_count: number
    approval_gate_count: number
    approval_required_gate_ids: string[]
    blocked_runtime_action_count: number
    required_field_count: number
    forbidden_field_count: number
    live_write_count_total: number
  }
}

export interface AiAgentPostWriteVerifierPackageSnapshot {
  schema_version: 'ai_agent_post_write_verifier_package_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'post_write_verifier_package_only_no_runtime_write'
    status_note: string
  }
  source_refs: string[]
  verifier_truth: {
    runtime_write_allowed: false
    post_write_verifier_implemented: false
    post_write_verifier_executed_count: number
    rollback_work_item_created_count: number
    telegram_failure_receipt_sent_count: number
    canonical_readback_allowed: false
    truth_note: string
  }
  verifier_package: {
    operator_meaning: string
    required_inputs: string[]
    forbidden_inputs: string[]
    success_policy: string
    failure_policy: string
  }
  verification_targets: Array<{
    target_id: string
    display_name: string
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    verifier_check: string
    failure_escalation: string
    blocked_runtime_action: string
  }>
  failure_lanes: Array<{
    lane_id: string
    display_name: string
    status: string
    trigger: string
    blocked_runtime_action: string
    operator_instruction: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    action_type: 'review' | 'collect_evidence' | 'approve_implementation' | 'reject_or_rework'
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    blocked_runtime_action: string
  }>
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    verification_target_count: number
    failure_lane_count: number
    operator_action_count: number
    approval_required_action_ids: string[]
    blocked_runtime_action_count: number
    required_input_count: number
    forbidden_input_count: number
    live_verifier_execution_count: number
  }
}

export interface AiAgentRuntimeVerifierEvidenceReviewSnapshot {
  schema_version: 'ai_agent_runtime_verifier_evidence_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'runtime_verifier_evidence_review_only_no_live_execution'
    status_note: string
  }
  source_refs: string[]
  review_truth: {
    review_packet_ready: true
    runtime_verifier_implementation_allowed: false
    post_write_verifier_execution_allowed: false
    runtime_verifier_executed_count: number
    canonical_readback_allowed: false
    canonical_readback_executed_count: number
    rollback_work_item_created_count: number
    telegram_failure_receipt_sent_count: number
    learning_writeback_after_verifier_count: number
    truth_note: string
  }
  review_package: {
    required_evidence: string[]
    forbidden_evidence: string[]
    operator_meaning: string
    approval_policy: string
    failure_policy: string
  }
  evidence_checks: Array<{
    check_id: string
    display_name: string
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    required_evidence: string
    review_question: string
    blocked_runtime_action: string
  }>
  implementation_review_lanes: Array<{
    lane_id: string
    display_name: string
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    trigger: string
    operator_instruction: string
    blocked_runtime_action: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    action_type: 'review' | 'collect_evidence' | 'approve_implementation' | 'reject_or_rework'
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    blocked_runtime_action: string
  }>
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    evidence_check_count: number
    implementation_review_lane_count: number
    operator_action_count: number
    approval_required_action_ids: string[]
    blocked_runtime_action_count: number
    required_evidence_count: number
    forbidden_evidence_count: number
    live_verifier_execution_count: number
  }
}

export interface AiAgentReportTruthActionabilityReviewSnapshot {
  schema_version: 'ai_agent_report_truth_actionability_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'report_truth_actionability_review_only_no_report_send_or_runtime_fix'
    status_note: string
  }
  source_refs: string[]
  report_truth: {
    report_truth_packet_ready: true
    all_zero_weekly_report_is_actionable_anomaly: true
    daily_report_contract_present: boolean
    weekly_report_contract_present: boolean
    monthly_report_contract_present: false
    freshness_gate_implemented: true
    source_confidence_gate_implemented: true
    actionability_score_implemented: true
    ai_agent_runtime_control_allowed: false
    telegram_report_send_allowed: false
    cronjob_change_allowed: false
    truth_note: string
  }
  source_freshness_gates: Array<{
    gate_id: string
    display_name: string
    freshness_state: string
    last_success_at: string
    required_ttl: string
    evidence_ref: string
    operator_impact: string
    ai_next_action: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    work_item_required: true
  }>
  source_confidence_gates: Array<{
    confidence_id: string
    display_name: string
    confidence: 'low'
    score: number
    reason: string
    display_policy: string
    blocked_green_badge: true
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
  }>
  report_actionability_scores: Array<{
    report_id: string
    display_name: string
    score: number
    lane: string
    send_policy: string
    next_action: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
  }>
  zero_signal_work_items: Array<{
    work_item_id: string
    asset_type: string
    status: 'draft_required'
    source_gate_id: string
    required_assets: string[]
  }>
  zero_signal_findings: Array<{
    finding_id: string
    display_name: string
    severity: string
    source: string
    evidence: string
    operator_meaning: string
    required_fix: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    blocked_runtime_action: string
  }>
  report_cadence_contracts: Array<{
    cadence_id: string
    display_name: string
    status: string
    source: string
    required_truth: string
    next_action: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
  }>
  alert_actionability_lanes: Array<{
    lane_id: string
    display_name: string
    routing_policy: string
    ai_agent_role: string
    notification_policy: string
  }>
  telegram_routing_consolidation: {
    canonical_room_name: 'AwoooI SRE 戰情室'
    canonical_room_env: 'SRE_GROUP_CHAT_ID'
    product_alerts_must_route_to_canonical_room: true
    other_bot_or_group_alerts_allowed: false
    direct_telegram_api_send_allowed: false
    secret_value_read_allowed: false
    route_change_allowed: false
    routing_note: string
  }
  telegram_egress_guard?: {
    schema_version: 'telegram_notification_egress_no_new_bypass_guard_v1'
    status: string
    mode: string
    source_snapshot: string
    guarded_roots: string[]
    guarded_bot_methods: string[]
    summary: {
      current_direct_bot_api_call_count: number
      current_direct_bot_api_file_count: number
      live_direct_bot_api_call_count: number
      live_direct_bot_api_file_count: number
      live_scan_matches_committed_guard_count: boolean
      gitea_workflow_direct_bot_api_call_count: number
      ops_script_direct_bot_api_call_count: number
      ci_script_direct_bot_api_call_count: number
      api_direct_bot_api_call_count: number
      direct_bot_api_awooop_db_receipt_count: number
      direct_bot_api_awooop_db_receipt_missing_count: number
      direct_bot_api_ai_controlled_route_count: number
      direct_bot_api_ai_controlled_route_missing_count: number
      new_bypass_count: number
      sendMessage_call_count: number
    }
    telegram_receipt_coverage: {
      coverage_status: string
      gateway_alert_notification_db_receipt_enabled: boolean
      gateway_alert_notification_receipt_source: string
      direct_bot_api_total_count: number
      direct_bot_api_awooop_db_receipt_count: number
      direct_bot_api_awooop_db_receipt_missing_count: number
      direct_bot_api_ai_controlled_route_count: number
      direct_bot_api_ai_controlled_route_missing_count: number
      all_direct_routes_have_awooop_db_receipt: boolean
      all_direct_routes_have_ai_controlled_route: boolean
      all_telegram_alerts_have_db_or_log_receipts: boolean
      all_telegram_alerts_ai_controlled: boolean
      evidence_persistence_states: string[]
      ai_agent_next_action: string
    }
    current_direct_bot_api_calls: Array<{
      path: string
      line: number
      method: string
      surface_kind: string
      sanitized_excerpt: string
      receipt_state: string
      evidence_persistence_state: string
      ai_controlled_route_state: string
    }>
    ai_agent_interpretation: {
      no_new_bypass: boolean
      existing_direct_routes_need_migration: boolean
      db_receipt_required: boolean
      ai_controlled_route_required: boolean
      all_direct_routes_have_awooop_db_receipt: boolean
      all_direct_routes_have_ai_controlled_route: boolean
      manual_default_outcome_allowed: false
      next_action: string
    }
  }
  telegram_route_findings: Array<{
    route_id: string
    display_name: string
    source: string
    current_state: string
    target_state: string
    risk: string
    required_fix: string
    blocked_runtime_action: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    action_type: string
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    blocked_runtime_action: string
  }>
  approval_boundaries: Record<string, false>
  rollups: {
    zero_signal_finding_count: number
    source_freshness_gate_count: number
    stale_or_untrusted_source_count: number
    source_confidence_gate_count: number
    low_confidence_gate_count: number
    report_actionability_score_count: number
    actionability_score_ready_count: number
    zero_signal_work_item_count: number
    work_item_required_count: number
    critical_finding_count: number
    high_finding_count: number
    cadence_contract_count: number
    missing_cadence_contract_count: number
    actionability_lane_count: number
    telegram_route_finding_count: number
    legacy_or_direct_route_count: number
    operator_action_count: number
    approval_required_action_ids: string[]
    blocked_runtime_action_count: number
    all_zero_weekly_report_confidence: 'low_trust_actionable_anomaly'
    all_zero_weekly_report_actionability_score: number
  }
}

export interface AiAgentReportNoWriteAnalysisRuntimeSnapshot {
  schema_version: 'ai_agent_report_no_write_analysis_runtime_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-407'
    next_task_id: 'P2-408'
    read_only_mode: true
    runtime_authority: 'report_analysis_no_write_runtime_only_committed_snapshot'
    status_note: string
  }
  source_refs: string[]
  source_readbacks: Array<{
    readback_id: string
    source_schema_version: string
    source_ref: string
    endpoint: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    key_readback: string
    next_action: string
  }>
  analysis_truth: {
    daily_weekly_monthly_reports_loaded: true
    agent_workload_loaded: true
    charts_loaded: true
    receipt_owner_review_loaded: true
    dependency_drift_loaded: true
    report_truth_loaded: true
    analysis_draft_snapshot_ready: true
    ai_analysis_runtime_enabled: false
    report_delivery_enabled: false
    telegram_send_enabled: false
    gateway_queue_write_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    live_ai_analysis_run_count_24h: number
    live_report_delivery_count_24h: number
    telegram_send_count_24h: number
    gateway_queue_write_count_24h: number
    bot_api_call_count_24h: number
    receipt_production_write_count_24h: number
    production_write_count_24h: number
    truth_note: string
  }
  report_inputs: Array<{
    report_id: 'daily' | 'weekly' | 'monthly'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    completion_percent: number
    source_confidence: string
    actionability_score: number
    analysis_focus: string[]
    blocked_runtime_action: string
  }>
  agent_analysis_passes: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    role: string
    reviewed_source_count: number
    draft_finding_count: number
    highest_risk_tier: 'low' | 'medium' | 'high' | 'critical'
    live_runtime_write_allowed: false
    summary: string
    handoff_to: string
  }>
  draft_recommendations: Array<{
    recommendation_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    approval_required: boolean
    actionability_score: number
    problem: string
    draft_solution: string
    expected_signal: string
    blocked_runtime_action: string
  }>
  draft_artifacts: Array<{
    artifact_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'committed_snapshot_ready' | 'draft_only' | 'owner_review_required' | 'blocked_by_runtime_gate'
    writes_production: false
    sends_telegram: false
    contains_secret: false
    evidence_ref: string
  }>
  owner_review_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    status: 'owner_review_required' | 'blocked_by_runtime_gate' | 'draft_ready'
    required_fields: string[]
    acceptance_checks: string[]
    blocked_runtime_actions: string[]
  }>
  activation_boundaries: {
    read_only_analysis_allowed: true
    draft_snapshot_write_allowed: true
    ai_analysis_runtime_enabled: false
    report_delivery_enabled: false
    telegram_send_enabled: false
    gateway_queue_write_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    openclaw_replacement_allowed: false
  }
  telegram_policy: {
    canonical_room: 'AwoooI SRE 戰情室'
    canonical_room_env: 'SRE_GROUP_CHAT_ID'
    gateway_queue_write_allowed: false
    direct_bot_api_allowed: false
    telegram_send_allowed: false
    receipt_write_allowed: false
    policy_note: string
  }
  display_redaction_contract: {
    redaction_required: true
    raw_report_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    source_readback_count: number
    report_input_count: number
    agent_analysis_pass_count: number
    draft_recommendation_count: number
    draft_artifact_count: number
    owner_review_gate_count: number
    approval_required_recommendation_count: number
    approval_required_recommendation_ids: string[]
    low_risk_recommendation_count: number
    medium_risk_recommendation_count: number
    high_risk_recommendation_count: number
    critical_risk_recommendation_count: number
    actionability_score_ready_count: number
    blocked_runtime_action_count: number
    live_report_delivery_count: number
    live_ai_analysis_count: number
    telegram_send_count: number
    gateway_queue_write_count: number
    bot_api_call_count: number
    receipt_production_write_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface AiAgentLowMediumRiskWhitelistSnapshot {
  schema_version: 'ai_agent_low_medium_risk_whitelist_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-408'
    next_task_id: 'P2-409'
    read_only_mode: true
    runtime_authority: 'low_medium_risk_whitelist_no_live_execution_committed_snapshot'
    status_note: string
  }
  source_refs: string[]
  source_readbacks: Array<{
    readback_id: string
    source_schema_version: string
    source_ref: string
    endpoint: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre'
    status: string
    key_readback: string
    next_action: string
  }>
  whitelist_truth: {
    p2_407_no_write_analysis_loaded: true
    operation_permission_model_loaded: true
    candidate_dry_run_evidence_loaded: true
    report_policy_review_loaded: true
    dependency_drift_loaded: true
    low_risk_candidates_ready: true
    medium_risk_candidates_ready: true
    dry_run_verifier_required: true
    rollback_proof_required: true
    audit_reason_required: true
    high_risk_redirect_ready: true
    auto_worker_enabled: false
    low_risk_live_execution_enabled: false
    medium_risk_live_execution_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    openclaw_replacement_allowed: false
    auto_worker_run_count_24h: number
    low_risk_execution_count_24h: number
    medium_risk_execution_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    bot_api_call_count_24h: number
    receipt_production_write_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    paid_api_call_count_24h: number
    host_write_count_24h: number
    kubectl_action_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  whitelist_candidates: Array<{
    candidate_id: string
    display_name: string
    risk_tier: 'low' | 'medium'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre'
    whitelist_status: 'candidate_only_no_live_execution' | 'dry_run_ready_no_live_execution' | 'owner_review_required_no_live_execution'
    allowed_no_write_outputs: string[]
    required_evidence: string[]
    dry_run_verifier_id: string
    rollback_proof_id: string
    audit_reason_template_id: string
    owner_approval_required_for_live_execution: true
    live_execution_allowed: false
    production_write_allowed: false
    side_effect_count: number
    blocked_runtime_actions: string[]
    next_gate: string
  }>
  dry_run_verifiers: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre'
    verifier_status: 'ready' | 'owner_review_required'
    required_inputs: string[]
    pass_condition: string
    live_readback_allowed: false
    production_write_allowed: false
  }>
  rollback_proofs: Array<{
    rollback_proof_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre'
    rollback_scope: string
    proof_status: 'noop_ready' | 'draft_ready' | 'owner_review_required'
    rollback_command_allowed: false
    required_before_live_execution: true
  }>
  audit_reason_templates: Array<{
    template_id: string
    display_name: string
    risk_tier: 'low' | 'medium'
    required_fields: string[]
    example_reason: string
    sensitive_payload_allowed: false
  }>
  high_risk_redirects: Array<{
    redirect_id: string
    display_name: string
    risk_tier: 'high' | 'critical'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre'
    redirect_to: 'P2-409 Owner Review Queue'
    blocked_runtime_actions: string[]
    reason: string
  }>
  owner_review_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre'
    status: 'owner_review_required' | 'blocked_by_runtime_gate' | 'draft_ready'
    required_fields: string[]
    acceptance_checks: string[]
    blocked_runtime_actions: string[]
  }>
  activation_boundaries: {
    read_only_whitelist_allowed: true
    dry_run_verifier_preview_allowed: true
    rollback_proof_preview_allowed: true
    audit_reason_template_allowed: true
    auto_worker_enabled: false
    low_risk_live_execution_enabled: false
    medium_risk_live_execution_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    openclaw_replacement_allowed: false
  }
  telegram_policy: {
    canonical_room: 'AwoooI SRE 戰情室'
    canonical_room_env: 'SRE_GROUP_CHAT_ID'
    gateway_queue_write_allowed: false
    direct_bot_api_allowed: false
    telegram_send_allowed: false
    receipt_write_allowed: false
    policy_note: string
  }
  display_redaction_contract: {
    redaction_required: true
    unsafe_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    source_readback_count: number
    whitelist_candidate_count: number
    low_risk_candidate_count: number
    medium_risk_candidate_count: number
    candidate_only_count: number
    dry_run_verifier_count: number
    rollback_proof_count: number
    audit_reason_template_count: number
    high_risk_redirect_count: number
    owner_review_gate_count: number
    live_execution_approval_required_count: number
    blocked_runtime_action_count: number
    auto_worker_run_count: number
    low_risk_execution_count: number
    medium_risk_execution_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    receipt_production_write_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
    destructive_operation_count: number
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface AiAgentHighRiskOwnerReviewQueueSnapshot {
  schema_version: 'ai_agent_high_risk_owner_review_queue_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0'
    current_task_id: 'P2-409'
    next_task_id: 'P2-410'
    read_only_mode: true
    runtime_authority: 'controlled_apply_break_glass_queue_readback_no_live_execution'
    status_note: string
  }
  source_refs: string[]
  source_readbacks: Array<{
    readback_id: string
    source_schema_version: string
    source_ref: string
    endpoint: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    status: string
    key_readback: string
    next_action: string
  }>
  queue_truth: {
    p2_408_redirects_loaded: true
    p2_406b_receipt_owner_review_loaded: true
    p2_110d_report_source_gap_loaded: true
    p2_110e_work_items_owner_review_loaded: true
    telegram_egress_inventory_loaded: true
    telegram_owner_request_draft_loaded: true
    all_high_risk_actions_paused: false
    approval_packets_ready: true
    rejection_guards_ready: true
    reviewer_checklists_ready: true
    high_risk_owner_review_required: false
    high_risk_controlled_apply_enabled: true
    critical_break_glass_required: true
    auto_worker_enabled: false
    live_execution_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    openclaw_replacement_allowed: false
    auto_worker_run_count_24h: number
    live_execution_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    bot_api_call_count_24h: number
    receipt_production_write_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    paid_api_call_count_24h: number
    host_write_count_24h: number
    kubectl_action_count_24h: number
    destructive_operation_count_24h: number
    owner_response_received_count_24h: number
    owner_response_accepted_count_24h: number
    redacted_payload_ingested_count_24h: number
    truth_note: string
  }
  owner_review_queue_items: Array<{
    queue_item_id: string
    display_name: string
    risk_tier: 'high' | 'critical'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    queue_status: 'controlled_apply_packet_ready' | 'critical_break_glass_required' | 'blocked_missing_owner_response' | 'approval_packet_preview_ready'
    source_readback_ids: string[]
    approval_packet_id: string
    rejection_guard_ids: string[]
    reviewer_checklist_ids: string[]
    required_owner_fields: string[]
    blocked_runtime_actions: string[]
    owner_response_required: boolean
    rollback_owner_required: true
    postcheck_required: true
    live_execution_allowed: false
    gateway_queue_write_allowed: false
    telegram_send_allowed: false
    production_write_allowed: false
    side_effect_count: number
    next_gate: string
  }>
  approval_packets: Array<{
    approval_packet_id: string
    queue_item_id: string
    display_name: string
    packet_status: 'controlled_apply_packet_ready' | 'break_glass_packet_ready' | 'blocked_missing_owner_response'
    required_owner_fields: string[]
    required_evidence_refs: string[]
    reviewer_checklist_id: string
    rejection_guard_ids: string[]
    rollback_owner_required: true
    postcheck_required: true
    sensitive_payload_allowed: false
    live_execution_allowed: false
    gateway_queue_write_allowed: false
    telegram_send_allowed: false
    production_write_allowed: false
  }>
  rejection_guards: Array<{
    guard_id: string
    display_name: string
    applies_to_risk_tiers: Array<'high' | 'critical'>
    rejection_condition: string
    blocked_runtime_actions: string[]
    reviewer_action: string
    sensitive_payload_quarantine_required: boolean
  }>
  reviewer_checklists: Array<{
    checklist_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    required_checks: string[]
    pass_condition: string
    approval_decision_allowed: false
    checklist_write_allowed: false
    side_effect_count: number
  }>
  routing_policy: {
    high_risk_default_route: 'controlled_apply_queue'
    critical_risk_default_route: 'critical_break_glass_queue'
    low_medium_runtime_route: 'controlled_apply_queue'
    owner_response_required: false
    verbal_approval_accepted: false
    redacted_payload_only: true
  }
  activation_boundaries: {
    read_only_owner_review_queue_allowed: false
    controlled_apply_queue_readback_allowed: true
    critical_break_glass_queue_readback_allowed: true
    approval_packet_preview_allowed: true
    rejection_guard_preview_allowed: true
    reviewer_checklist_allowed: true
    auto_worker_enabled: false
    live_execution_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    openclaw_replacement_allowed: false
  }
  telegram_policy: {
    canonical_room: 'AwoooI SRE 戰情室'
    canonical_room_env: 'SRE_GROUP_CHAT_ID'
    gateway_queue_write_allowed: false
    direct_bot_api_allowed: false
    telegram_send_allowed: false
    receipt_write_allowed: false
    policy_note: string
  }
  display_redaction_contract: {
    redaction_required: true
    unsafe_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    source_readback_count: number
    queue_item_count: number
    high_risk_queue_count: number
    critical_queue_count: number
    approval_packet_count: number
    rejection_guard_count: number
    reviewer_checklist_count: number
    approval_packet_required_count: number
    rejection_guard_required_queue_count: number
    rollback_owner_required_count: number
    postcheck_required_count: number
    blocked_runtime_action_count: number
    controlled_apply_queue_count: number
    critical_break_glass_queue_count: number
    owner_response_required_count: number
    high_risk_owner_review_required_count: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
    auto_worker_run_count: number
    live_execution_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    receipt_production_write_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
    destructive_operation_count: number
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface AiAgentControlledExecutorHandoffSnapshot {
  schema_version: 'ai_agent_controlled_executor_handoff_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0'
    current_task_id: 'P2-415'
    next_task_id: 'P2-416'
    read_only_mode: true
    runtime_authority: 'controlled_executor_handoff_readback_no_live_apply'
    status_note: string
  }
  source_refs: string[]
  source_readbacks: Array<{
    readback_id: string
    source_schema_version: string
    source_ref: string
    endpoint: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    status: string
    key_readback: string
    next_action: string
  }>
  handoff_truth: {
    p2_409_controlled_apply_queue_loaded: true
    p2_410_audit_ledger_loaded: true
    p2_411_handoff_event_bus_loaded: true
    runtime_readiness_loaded: true
    runtime_write_gate_loaded: true
    post_write_verifier_loaded: true
    learning_writeback_loaded: true
    telegram_receipt_loaded: true
    high_risk_controlled_executor_handoff_ready: true
    high_risk_owner_review_required: false
    critical_break_glass_required: true
    allowlist_route_required: true
    ansible_check_mode_required: true
    rollback_plan_required: true
    post_action_verifier_required: true
    telegram_evidence_required: true
    km_writeback_required: true
    playbook_trust_writeback_required: true
    controlled_executor_dispatch_enabled: false
    live_apply_enabled: false
    critical_auto_bypass_allowed: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    km_write_enabled: false
    playbook_trust_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    controlled_executor_dispatch_count_24h: number
    live_apply_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    bot_api_call_count_24h: number
    km_write_count_24h: number
    playbook_trust_write_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    paid_api_call_count_24h: number
    host_write_count_24h: number
    kubectl_action_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  executor_handoff_packets: Array<{
    packet_id: string
    source_queue_item_id: string
    display_name: string
    risk_tier: 'high' | 'critical'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    executor_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    executor_type:
      | 'ansible_playbook'
      | 'mcp_tool_route'
      | 'telegram_gateway_queue'
      | 'km_playbook_writer'
      | 'readback_verifier'
      | 'break_glass_only'
    handoff_status:
      | 'ready_for_controlled_executor'
      | 'critical_break_glass_only'
      | 'blocked_missing_check_mode'
      | 'blocked_missing_verifier'
      | 'blocked_missing_learning_writeback'
    controlled_route_id: string
    playbook_ref: string
    mcp_tool_ref: string
    check_mode_ref: string
    verifier_ref: string
    rollback_ref: string
    telegram_evidence_ref: string
    km_writeback_ref: string
    playbook_trust_ref: string
    allowlist_match: boolean
    check_mode_passed: boolean
    rollback_plan_ready: boolean
    post_action_verifier_ready: boolean
    telegram_evidence_ready: boolean
    km_writeback_ready: boolean
    playbook_trust_writeback_ready: boolean
    owner_response_required: boolean
    break_glass_required: boolean
    controlled_executor_handoff_allowed: boolean
    live_apply_performed: false
    side_effect_count: number
    blocked_runtime_actions: string[]
    next_gate: string
  }>
  executor_routes: Array<{
    route_id: string
    display_name: string
    executor_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    route_status: 'ready_for_handoff' | 'blocked_by_policy'
    required_inputs: string[]
    blocked_actions: string[]
    live_apply_allowed_by_this_readback: false
  }>
  verifier_bindings: Array<{
    binding_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    required_before_dispatch: true
    ready_count: number
    blocked_count: number
    failure_if_missing: string
  }>
  learning_writeback_contracts: Array<{
    contract_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    target_store: string
    writeback_status: 'ready_for_executor_receipt' | 'blocked_by_policy'
    required_fields: string[]
    runtime_write_performed: false
  }>
  activation_boundaries: {
    committed_snapshot_read_allowed: true
    controlled_executor_handoff_preview_allowed: true
    ansible_check_mode_receipt_preview_allowed: true
    mcp_tool_registry_route_preview_allowed: true
    post_action_verifier_binding_preview_allowed: true
    telegram_evidence_preview_allowed: true
    km_playbook_trust_writeback_preview_allowed: true
    controlled_executor_dispatch_enabled: false
    live_apply_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    km_write_enabled: false
    playbook_trust_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
  }
  display_redaction_contract: {
    redaction_required: true
    raw_tool_output_display_allowed: false
    raw_runtime_payload_display_allowed: false
    raw_telegram_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    source_readback_count: number
    handoff_packet_count: number
    ready_for_controlled_executor_count: number
    critical_break_glass_count: number
    high_risk_packet_count: number
    critical_packet_count: number
    ansible_check_mode_packet_count: number
    mcp_tool_route_count: number
    post_action_verifier_binding_count: number
    telegram_evidence_binding_count: number
    km_writeback_binding_count: number
    playbook_trust_writeback_binding_count: number
    owner_response_required_count: number
    blocked_by_critical_boundary_count: number
    missing_check_mode_count: number
    missing_rollback_count: number
    missing_verifier_count: number
    missing_telegram_evidence_count: number
    missing_learning_writeback_count: number
    executor_route_count: number
    verifier_binding_count: number
    learning_writeback_contract_count: number
    controlled_executor_dispatch_count: number
    live_apply_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    km_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
    destructive_operation_count: number
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface AiAgentActionAuditLedgerSnapshot {
  schema_version: 'ai_agent_action_audit_ledger_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0'
    current_task_id: 'P2-410'
    next_task_id: 'P2-411'
    read_only_mode: true
    runtime_authority: 'agent_action_audit_ledger_no_live_write_committed_snapshot'
    status_note: string
  }
  source_refs: string[]
  source_readbacks: Array<{
    readback_id: string
    source_schema_version: string
    source_ref: string
    endpoint: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    status: string
    key_readback: string
    next_action: string
  }>
  audit_truth: {
    p2_408_whitelist_loaded: true
    p2_409_owner_queue_loaded: true
    p2_103_result_audit_loaded: true
    p2_110c_sre_digest_loaded: true
    p2_110e_work_items_loaded: true
    telegram_no_new_bypass_loaded: true
    audit_event_templates_ready: true
    verifier_receipt_gates_ready: true
    immutable_event_required: true
    redacted_evidence_refs_required: true
    read_only_mode: true
    audit_db_write_enabled: false
    timeline_write_enabled: false
    km_write_enabled: false
    playbook_trust_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    audit_db_write_count_24h: number
    timeline_write_count_24h: number
    km_write_count_24h: number
    playbook_trust_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    bot_api_call_count_24h: number
    receipt_production_write_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    paid_api_call_count_24h: number
    host_write_count_24h: number
    kubectl_action_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  audit_event_templates: Array<{
    audit_event_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    event_stage: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    source_readback_ids: string[]
    required_audit_fields: string[]
    required_evidence_refs: string[]
    blocked_writes: string[]
    immutable_event_required: true
    audit_db_write_allowed: false
    timeline_write_allowed: false
    km_write_allowed: false
    playbook_trust_write_allowed: false
    gateway_queue_write_allowed: false
    telegram_send_allowed: false
    production_write_allowed: false
    side_effect_count: number
    next_gate: string
  }>
  verifier_receipt_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    required_checks: string[]
    failure_if_missing: string
    live_verifier_allowed: false
    receipt_write_allowed: false
    runtime_action_allowed: false
  }>
  activation_boundaries: {
    committed_snapshot_read_allowed: true
    audit_event_template_preview_allowed: true
    verifier_receipt_gate_preview_allowed: true
    governance_ui_projection_allowed: true
    audit_db_write_enabled: false
    timeline_write_enabled: false
    km_write_enabled: false
    playbook_trust_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
  }
  display_redaction_contract: {
    redaction_required: true
    unsafe_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_prompt_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    source_readback_count: number
    audit_event_template_count: number
    low_medium_event_count: number
    high_risk_event_count: number
    critical_event_count: number
    report_gap_event_count: number
    telegram_event_count: number
    verifier_receipt_gate_count: number
    required_audit_field_count: number
    blocked_runtime_action_count: number
    audit_db_write_count: number
    timeline_write_count: number
    km_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    receipt_production_write_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
    destructive_operation_count: number
    owner_response_received_count: number
    owner_response_accepted_count: number
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface AiAgentActionOwnerAcceptanceEventBusSnapshot {
  schema_version: 'ai_agent_action_owner_acceptance_event_bus_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0'
    current_task_id: 'P2-411'
    next_task_id: 'P2-412'
    read_only_mode: true
    runtime_authority: 'agent_action_owner_acceptance_event_bus_no_write_committed_snapshot'
    status_note: string
  }
  source_refs: string[]
  source_readbacks: Array<{
    readback_id: string
    source_schema_version: string
    source_ref: string
    endpoint: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    status: string
    key_readback: string
    next_action: string
  }>
  event_bus_truth: {
    p2_409_owner_queue_loaded: true
    p2_410_audit_ledger_loaded: true
    communication_contract_loaded: true
    war_room_loaded: true
    owner_acceptance_envelope_required: true
    handoff_protocol_ready: true
    rag_memory_proposal_ready: true
    event_bus_no_write_mode: true
    redacted_evidence_only: true
    high_critical_human_gate_required: true
    low_medium_owner_scope_required_before_worker: true
    owner_response_received: false
    owner_response_accepted: false
    owner_response_rejected: false
    external_response_ingested: false
    event_bus_publish_enabled: false
    audit_db_write_enabled: false
    timeline_write_enabled: false
    km_write_enabled: false
    playbook_trust_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    worker_dispatch_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
    owner_response_received_count_24h: number
    owner_response_accepted_count_24h: number
    owner_response_rejected_count_24h: number
    external_response_ingested_count_24h: number
    event_bus_publish_count_24h: number
    audit_db_write_count_24h: number
    timeline_write_count_24h: number
    km_write_count_24h: number
    playbook_trust_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    bot_api_call_count_24h: number
    worker_dispatch_count_24h: number
    receipt_production_write_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    paid_api_call_count_24h: number
    host_write_count_24h: number
    kubectl_action_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  owner_acceptance_lanes: Array<{
    lane_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    source_readback_ids: string[]
    required_owner_fields: string[]
    required_evidence_refs: string[]
    acceptance_status: 'blocked_no_external_response' | 'blocked_missing_fields' | 'candidate_only_no_write'
    acceptance_decision: 'not_evaluated'
    response_received: false
    acceptance_passed: false
    acceptance_rejected: false
    runtime_write_allowed: false
    event_bus_publish_allowed: false
    telegram_send_allowed: false
    rag_write_allowed: false
    side_effect_count: number
    next_gate: string
  }>
  handoff_event_templates: Array<{
    event_id: string
    display_name: string
    producer_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    consumer_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    event_stage: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    source_lane_ids: string[]
    required_event_fields: string[]
    blocked_writes: string[]
    event_bus_write_allowed: false
    audit_db_write_allowed: false
    timeline_write_allowed: false
    km_write_allowed: false
    playbook_trust_write_allowed: false
    gateway_queue_write_allowed: false
    telegram_send_allowed: false
    production_write_allowed: false
    side_effect_count: number
    next_gate: string
  }>
  rag_memory_proposals: Array<{
    proposal_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    target_store: string
    source_event_ids: string[]
    required_redaction_checks: string[]
    proposal_status: 'proposal_only_no_write'
    km_write_allowed: false
    playbook_trust_write_allowed: false
    embedding_write_allowed: false
    side_effect_count: number
  }>
  verifier_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron' | 'sre' | 'security' | 'devops'
    required_checks: string[]
    failure_if_missing: string
    live_verifier_allowed: false
    receipt_write_allowed: false
    runtime_action_allowed: false
  }>
  activation_boundaries: {
    committed_snapshot_read_allowed: true
    owner_acceptance_lane_preview_allowed: true
    handoff_event_template_preview_allowed: true
    rag_memory_proposal_preview_allowed: true
    governance_ui_projection_allowed: true
    event_bus_publish_enabled: false
    audit_db_write_enabled: false
    timeline_write_enabled: false
    km_write_enabled: false
    playbook_trust_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    worker_dispatch_enabled: false
    receipt_production_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    paid_api_call_enabled: false
    host_write_enabled: false
    kubectl_action_enabled: false
    destructive_operation_enabled: false
  }
  display_redaction_contract: {
    redaction_required: true
    unsafe_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_prompt_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    source_readback_count: number
    owner_acceptance_lane_count: number
    medium_lane_count: number
    high_lane_count: number
    critical_lane_count: number
    handoff_event_template_count: number
    rag_memory_proposal_count: number
    verifier_gate_count: number
    required_owner_field_count: number
    blocked_runtime_action_count: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    external_response_ingested_count: number
    event_bus_publish_count: number
    audit_db_write_count: number
    timeline_write_count: number
    km_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    worker_dispatch_count: number
    receipt_production_write_count: number
    production_write_count: number
    secret_read_count: number
    paid_api_call_count: number
    host_write_count: number
    kubectl_action_count: number
    destructive_operation_count: number
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface AiAgentReportAutomationReviewSnapshot {
  schema_version: 'ai_agent_report_automation_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'reporting_and_risk_policy_review_only_no_live_execution'
    status_note: string
  }
  source_refs: string[]
  report_truth: {
    daily_report_ready: true
    weekly_report_ready: true
    monthly_report_ready: true
    per_agent_workload_ready: true
    chart_package_ready: true
    report_delivery_enabled: false
    report_delivery_count_24h: number
    report_read_receipt_count_24h: number
    ai_analysis_after_report_enabled: false
    medium_low_auto_policy_defined: true
    medium_low_auto_execution_enabled: true
    low_medium_high_controlled_auto_policy_defined: true
    low_medium_high_controlled_auto_execution_enabled: true
    live_medium_low_auto_execution_count_24h: number
    high_risk_requires_approval: false
    critical_break_glass_required: true
    live_auto_optimization_count_24h: number
    truth_note: string
  }
  report_cadences: Array<{
    cadence_id: 'daily' | 'weekly' | 'monthly'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    schedule: string
    sections: string[]
    chart_ids: string[]
    delivery_channel: string
    status: string
    live_delivery_count: number
  }>
  agent_workload_metrics: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    primary_role: string
    deployment_targets: number
    delegable_capabilities: number
    report_owned_sections: number
    analysis_owned_recommendations: number
    work_units_total: number
    work_units_done: number
    work_units_waiting_approval: number
    work_units_in_controlled_queue: number
    live_runtime_work_units_24h: number
    workload_note: string
  }>
  report_charts: Array<{
    chart_id: string
    display_name: string
    chart_type: string
    unit: string
    series: Array<{
      label: string
      value: number
      tone: 'ok' | 'warn' | 'danger' | 'neutral'
    }>
    operator_question: string
  }>
  risk_tier_policy: {
    policy_summary: string
    risk_tiers: Array<{
      risk_id: 'low' | 'medium' | 'high' | 'critical'
      display_name: string
      approval_required: boolean
      auto_action_policy: string
      current_execution_enabled: boolean
      required_before_enable: string[]
    }>
  }
  analysis_recommendations: Array<{
    recommendation_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    approval_required: boolean
    current_auto_execution_enabled: boolean
    problem: string
    proposed_solution: string
    expected_report_signal: string
    blocked_runtime_action: string
  }>
  approval_boundaries: Record<string, boolean>
  display_redaction_contract: {
    redaction_required: true
    raw_report_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    report_cadence_count: number
    agent_count: number
    chart_count: number
    recommendation_count: number
    workload_unit_total: number
    workload_done_total: number
    workload_waiting_approval_total: number
    low_risk_recommendation_count: number
    medium_risk_recommendation_count: number
    high_risk_recommendation_count: number
    critical_risk_recommendation_count: number
    approval_required_recommendation_ids: string[]
    medium_low_auto_policy_count: number
    low_medium_high_controlled_policy_count: number
    workload_controlled_queue_total: number
    current_auto_execution_enabled_count: number
    live_report_delivery_count: number
    live_auto_optimization_count: number
  }
}

export interface AiAgentReportStatusBoardSnapshot {
  schema_version: 'ai_agent_report_status_board_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: 100
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-108'
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'report_status_board_only_no_live_send_or_write'
    status_note: string
  }
  source_refs: string[]
  report_completion_truth: {
    daily_report_visible: true
    weekly_report_visible: true
    monthly_report_visible: true
    per_agent_status_visible: true
    workload_metrics_visible: true
    chart_package_visible: true
    telegram_digest_draft_visible: true
    live_report_delivery_enabled: false
    live_telegram_send_count_24h: number
    ai_post_report_analysis_enabled: false
    medium_low_auto_optimization_enabled: true
    low_medium_high_controlled_apply_allowed: true
    high_risk_human_approval_required: false
    critical_break_glass_required: true
    live_auto_optimization_count_24h: number
    truth_note: string
  }
  report_status_cards: Array<{
    cadence_id: 'daily' | 'weekly' | 'monthly'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    completion_percent: 100
    contract_state: 'visible_contract_ready'
    delivery_state: 'draft_only'
    sections_count: number
    chart_count: number
    work_units_total: number
    live_delivery_count: number
    next_gate: string
  }>
  agent_status_reports: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    primary_role: string
    current_state: string
    work_units_total: number
    work_units_done: number
    work_units_waiting_approval: number
    work_units_in_controlled_queue: number
    report_sections_owned: number
    analysis_recommendations_owned: number
    live_runtime_work_units_24h: number
    communication_state: string
    learning_state: string
    telegram_policy: string
    status_note: string
  }>
  visible_charts: Array<{
    chart_id: string
    display_name: string
    chart_type: string
    unit: string
    series: Array<{
      label: string
      value: number
      tone: 'ok' | 'warn' | 'danger' | 'neutral'
    }>
  }>
  operator_answer_cards: Array<{
    answer_id: string
    question: string
    answer: string
    status: 'complete' | 'guarded' | 'next_gate'
  }>
  activation_boundaries: {
    scheduler_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    report_receipt_write_enabled: false
    ai_analysis_run_enabled: false
    medium_low_auto_execution_enabled: true
    high_risk_auto_execution_enabled: true
    low_medium_high_controlled_apply_allowed: true
    production_optimization_write_enabled: false
    high_risk_requires_human_approval: false
    critical_break_glass_required: true
  }
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    internal_transcript_display_allowed: false
  }
  rollups: {
    report_card_count: number
    agent_status_count: number
    visible_chart_count: number
    operator_answer_count: number
    completed_report_count: number
    workload_unit_total: number
    workload_done_total: number
    workload_waiting_approval_total: number
    live_delivery_count: number
    live_telegram_send_count: number
    live_runtime_work_units: number
    live_auto_optimization_count: number
    workload_controlled_queue_total: number
    high_risk_requires_human_approval: false
    low_medium_high_controlled_apply_allowed: true
    critical_break_glass_required: true
  }
}

export interface AiAgentReportRuntimeReadinessSnapshot {
  schema_version: 'ai_agent_report_runtime_readiness_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-403L'
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'report_runtime_readiness_only_no_live_delivery_or_optimization'
    status_note: string
  }
  source_refs: string[]
  activation_truth: {
    report_scheduler_contract_ready: true
    telegram_gateway_queue_contract_ready: true
    telegram_delivery_receipt_contract_ready: true
    ai_readback_analysis_contract_ready: true
    medium_low_auto_guard_contract_ready: true
    high_risk_controlled_apply_contract_ready: true
    critical_break_glass_gate_contract_ready: true
    live_report_delivery_enabled: false
    live_report_delivery_count_24h: number
    telegram_gateway_queue_write_enabled: false
    telegram_gateway_queue_write_count_24h: number
    report_read_receipt_write_enabled: false
    report_read_receipt_count_24h: number
    ai_analysis_runtime_enabled: false
    ai_analysis_runtime_count_24h: number
    medium_low_auto_worker_enabled: true
    medium_low_auto_execution_count_24h: number
    production_optimization_enabled: false
    production_optimization_count_24h: number
    high_risk_auto_execution_enabled: true
    high_risk_auto_execution_count_24h: number
    truth_note: string
  }
  runtime_lanes: Array<{
    lane_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    target_runtime: string
    contract_status: 'ready_for_owner_review' | 'blocked_by_runtime_gate'
    current_live_count_24h: number
    enablement_required: string[]
    blocked_actions: string[]
  }>
  automation_policies: Array<{
    risk_id: 'low' | 'medium' | 'high' | 'critical'
    display_name: string
    approval_required: boolean
    auto_allowed_after_guard: boolean
    current_execution_enabled: boolean
    required_guards: string[]
    reporting_rule: string
  }>
  report_delivery_cadence_gates: Array<{
    cadence_id: 'daily' | 'weekly' | 'monthly'
    display_name: string
    scheduler_source: string
    telegram_digest_policy: string
    recipient_room: string
    dry_run_required: true
    current_delivery_enabled: false
    live_delivery_count_24h: number
  }>
  telegram_route_readiness: {
    canonical_room: 'AwoooI SRE 戰情室'
    secret_ref: 'SRE_GROUP_CHAT_ID'
    gateway_required: true
    direct_bot_api_allowed: false
    bot_log_out_allowed: false
    legacy_routes_must_converge: true
    telegram_gateway_queue_write_enabled: false
    e2e_delivery_verified: false
    delivery_receipt_write_enabled: false
    blocked_route_count: number
  }
  agent_post_report_actions: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    after_report_responsibility: string
    allowed_without_approval: string[]
    blocked_until_approval: string[]
    live_action_count_24h: number
  }>
  operator_decisions: Array<{
    decision_id: string
    display_name: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    approval_required: boolean
    status: 'ready_for_review' | 'controlled_apply_ready' | 'blocked_by_runtime_gate' | 'approval_required'
    why_it_matters: string
    next_safe_step: string
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_report_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    runtime_lane_count: number
    report_cadence_gate_count: number
    operator_decision_count: number
    automation_policy_count: number
    ready_contract_count: number
    blocked_contract_count: number
    approval_required_decision_ids: string[]
    current_enabled_count: number
    live_report_delivery_count: number
    live_ai_analysis_count: number
    live_medium_low_auto_execution_count: number
    telegram_gateway_queue_write_count: number
    high_risk_auto_execution_count: number
  }
}

export interface AiAgentReportRuntimeDryRunSnapshot {
  schema_version: 'ai_agent_report_runtime_dry_run_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-403M'
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'report_runtime_no_write_dry_run_only_no_gateway_write_or_delivery'
    status_note: string
  }
  source_refs: string[]
  dry_run_truth: {
    no_write_dry_run_package_ready: true
    report_snapshot_dry_run_ready: true
    telegram_gateway_queue_draft_ready: true
    readback_verifier_plan_ready: true
    failure_only_telegram_draft_ready: true
    production_delivery_enabled: false
    telegram_gateway_queue_write_enabled: false
    telegram_bot_api_call_enabled: false
    delivery_receipt_write_enabled: false
    ai_runtime_worker_enabled: false
    medium_low_auto_worker_enabled: false
    post_action_verifier_live_readback_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    work_window_transcript_display_allowed: false
    live_report_delivery_count_24h: number
    telegram_gateway_queue_write_count_24h: number
    telegram_bot_api_call_count_24h: number
    delivery_receipt_write_count_24h: number
    ai_runtime_worker_run_count_24h: number
    medium_low_auto_execution_count_24h: number
    post_action_verifier_live_readback_count_24h: number
    production_write_count_24h: number
    truth_note: string
  }
  dry_run_artifacts: Array<{
    artifact_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    mode: 'repo_only_no_write'
    status: 'ready_for_local_smoke' | 'ready_for_owner_review' | 'approval_required' | 'blocked_by_runtime_gate'
    evidence_ref: string
    hash_strategy: string
    writes_production: false
    contains_secret: false
    blocked_until: string
  }>
  telegram_gateway_queue_drafts: Array<{
    draft_id: 'daily_report_digest' | 'weekly_report_digest' | 'monthly_report_digest'
    display_name: string
    recipient_room: 'AwoooI SRE 戰情室'
    secret_ref: 'SRE_GROUP_CHAT_ID'
    cadence: 'daily' | 'weekly' | 'monthly'
    noise_budget: string
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    direct_bot_api_allowed: false
    payload_contains_secret: false
    redaction_policy: string
  }>
  readback_verifier_cases: Array<{
    case_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    readback_surface: string
    expected_signal: string
    live_readback_enabled: false
    writes_result: false
    requires_secret_value: false
    blocked_until: string
  }>
  agent_dry_run_roles: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    dry_run_responsibility: string
    allowed_now: string[]
    blocked_now: string[]
    live_action_count_24h: number
  }>
  operator_checkpoints: Array<{
    checkpoint_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    approval_required: boolean
    status: 'ready_for_review' | 'approval_required' | 'blocked_by_runtime_gate'
    next_safe_step: string
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_report_payload_display_allowed: false
    raw_telegram_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    dry_run_artifact_count: number
    gateway_queue_draft_count: number
    readback_verifier_case_count: number
    agent_role_count: number
    operator_checkpoint_count: number
    approval_required_checkpoint_ids: string[]
    live_report_delivery_count: number
    telegram_gateway_queue_write_count: number
    telegram_bot_api_call_count: number
    delivery_receipt_write_count: number
    ai_runtime_worker_run_count: number
    medium_low_auto_execution_count: number
    post_action_verifier_live_readback_count: number
    production_write_count: number
  }
}

export interface AiAgentReportRuntimeFixtureReadbackSnapshot {
  schema_version: 'ai_agent_report_runtime_fixture_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-403N'
    next_task_id: 'P2-404'
    read_only_mode: true
    runtime_authority: 'fixture_smoke_queue_preview_readback_verifier_dry_run_only_no_live_send_or_write'
    status_note: string
  }
  source_refs: string[]
  fixture_readback_truth: {
    fixture_smoke_package_ready: true
    report_snapshot_hash_ready: true
    telegram_queue_preview_readback_ready: true
    readback_verifier_dry_run_ready: true
    redaction_assertions_ready: true
    operator_review_packet_ready: true
    production_delivery_enabled: false
    telegram_gateway_queue_write_enabled: false
    telegram_send_enabled: false
    telegram_bot_api_call_enabled: false
    delivery_receipt_write_enabled: false
    ai_runtime_worker_enabled: false
    medium_low_auto_worker_enabled: false
    post_action_verifier_live_readback_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    work_window_transcript_display_allowed: false
    live_report_delivery_count_24h: number
    telegram_gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    telegram_bot_api_call_count_24h: number
    delivery_receipt_write_count_24h: number
    ai_runtime_worker_run_count_24h: number
    medium_low_auto_execution_count_24h: number
    post_action_verifier_live_readback_count_24h: number
    production_write_count_24h: number
    truth_note: string
  }
  fixture_smoke_results: Array<{
    fixture_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_artifact_id: string
    smoke_status: 'passed_no_write' | 'passed_redaction' | 'ready_for_owner_review' | 'blocked_by_runtime_gate'
    evidence_ref: string
    input_hash_strategy: string
    output_hash: string
    writes_production: false
    sends_telegram: false
    reads_secret_value: false
    live_execution_count_24h: number
  }>
  queue_preview_readbacks: Array<{
    readback_id: 'daily_report_digest_readback' | 'weekly_report_digest_readback' | 'monthly_report_digest_readback'
    display_name: string
    cadence: 'daily' | 'weekly' | 'monthly'
    owner_agent: 'hermes'
    recipient_room: 'AwoooI SRE 戰情室'
    secret_ref: 'SRE_GROUP_CHAT_ID'
    preview_hash: string
    payload_redacted: true
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    direct_bot_api_allowed: false
    queue_write_count_24h: number
    readback_status: 'verified_redacted_preview'
  }>
  verifier_dry_run_cases: Array<{
    case_id: string
    display_name: string
    owner_agent: 'hermes' | 'nemotron'
    dry_run_status: 'passed_fixture' | 'ready_for_owner_review' | 'blocked_by_runtime_gate'
    expected_signal: string
    observed_signal: string
    evidence_hash: string
    live_readback_enabled: false
    writes_result: false
    requires_secret_value: false
  }>
  agent_fixture_roles: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    fixture_responsibility: string
    observed_work: string[]
    blocked_now: string[]
    live_action_count_24h: number
  }>
  operator_checkpoints: Array<{
    checkpoint_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    approval_required: boolean
    status: 'passed_no_write' | 'ready_for_owner_review' | 'blocked_by_runtime_gate'
    next_safe_step: string
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_report_payload_display_allowed: false
    raw_telegram_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    fixture_smoke_count: number
    passed_fixture_smoke_count: number
    queue_preview_readback_count: number
    verifier_dry_run_case_count: number
    agent_role_count: number
    operator_checkpoint_count: number
    approval_required_checkpoint_ids: string[]
    live_report_delivery_count: number
    telegram_gateway_queue_write_count: number
    telegram_send_count: number
    telegram_bot_api_call_count: number
    delivery_receipt_write_count: number
    ai_runtime_worker_run_count: number
    medium_low_auto_execution_count: number
    post_action_verifier_live_readback_count: number
    production_write_count: number
  }
}

export interface AiAgentRuntimeWorkerShadowGateSnapshot {
  schema_version: 'ai_agent_runtime_worker_shadow_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-404'
    next_task_id: 'P2-101'
    read_only_mode: true
    runtime_authority: 'runtime_worker_shadow_no_write_execution_evidence_gate_only_no_live_send_or_write'
    status_note: string
  }
  source_refs: string[]
  shadow_gate_truth: {
    shadow_worker_evidence_gate_ready: true
    promotion_from_fixture_readback_ready: true
    no_write_replay_plan_ready: true
    action_candidate_selection_ready: true
    mcp_evidence_reuse_ready: true
    verifier_dry_run_binding_ready: true
    failure_lane_ready: true
    operator_review_packet_ready: true
    production_delivery_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    telegram_bot_api_call_enabled: false
    delivery_receipt_write_enabled: false
    shadow_worker_live_enabled: false
    ai_runtime_worker_enabled: false
    medium_low_auto_worker_enabled: false
    post_action_verifier_live_readback_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    work_window_transcript_display_allowed: false
    shadow_worker_live_run_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    telegram_bot_api_call_count_24h: number
    delivery_receipt_write_count_24h: number
    ai_runtime_worker_run_count_24h: number
    medium_low_auto_execution_count_24h: number
    post_action_verifier_live_readback_count_24h: number
    production_write_count_24h: number
    truth_note: string
  }
  shadow_worker_candidates: Array<{
    candidate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_fixture_id: string
    target_surface: string
    shadow_status: 'passed_no_write_replay' | 'needs_owner_review' | 'blocked_by_runtime_gate'
    promotion_hash: string
    dry_run_ref: string
    writes_production: false
    sends_telegram: false
    reads_secret_value: false
    live_shadow_run_count_24h: number
    blocked_reason: string
    next_no_write_step: string
  }>
  no_write_execution_replays: Array<{
    replay_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    input_source: string
    expected_action: string
    simulated_outcome: string
    replay_status: 'passed_no_write' | 'blocked_by_runtime_gate'
    evidence_hash: string
    verifier_bound: true
    writes_result: false
    production_side_effect_count: number
  }>
  verifier_shadow_cases: Array<{
    case_id: string
    display_name: string
    owner_agent: 'hermes' | 'nemotron'
    expected_signal: string
    observed_signal: string
    evidence_hash: string
    live_readback_enabled: false
    writes_result: false
    requires_secret_value: false
  }>
  agent_shadow_roles: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    shadow_responsibility: string
    observed_work: string[]
    blocked_now: string[]
    live_action_count_24h: number
  }>
  operator_checkpoints: Array<{
    checkpoint_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    approval_required: boolean
    status: 'passed_no_write' | 'needs_owner_review' | 'blocked_by_runtime_gate'
    next_safe_step: string
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_report_payload_display_allowed: false
    raw_telegram_payload_display_allowed: false
    raw_shadow_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    shadow_candidate_count: number
    passed_no_write_candidate_count: number
    blocked_candidate_count: number
    needs_owner_review_candidate_count: number
    no_write_replay_count: number
    passed_no_write_replay_count: number
    verifier_shadow_case_count: number
    agent_role_count: number
    operator_checkpoint_count: number
    approval_required_checkpoint_ids: string[]
    shadow_worker_live_run_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    telegram_bot_api_call_count: number
    delivery_receipt_write_count: number
    ai_runtime_worker_run_count: number
    medium_low_auto_execution_count: number
    post_action_verifier_live_readback_count: number
    production_write_count: number
  }
}

export interface AiAgentOperationPermissionModelSnapshot {
  schema_version: 'ai_agent_operation_permission_model_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-101'
    next_task_id: 'P2-102'
    read_only_mode: true
    runtime_authority: 'operation_permission_model_only_no_live_execution_or_send'
    status_note: string
  }
  source_refs: string[]
  operation_permission_truth: {
    permission_model_ready: true
    operation_category_matrix_ready: true
    risk_tier_mapping_ready: true
    agent_responsibility_mapping_ready: true
    approval_gate_mapping_ready: true
    manual_sop_lane_ready: true
    p2_404_shadow_gate_handoff_ready: true
    runtime_execution_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    telegram_bot_api_call_enabled: false
    delivery_receipt_write_enabled: false
    ai_runtime_worker_enabled: false
    medium_low_auto_worker_enabled: false
    post_action_verifier_live_readback_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    paid_provider_call_enabled: false
    host_or_cluster_command_enabled: false
    destructive_operation_enabled: false
    work_window_transcript_display_allowed: false
    runtime_execution_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    telegram_bot_api_call_count_24h: number
    delivery_receipt_write_count_24h: number
    ai_runtime_worker_run_count_24h: number
    medium_low_auto_execution_count_24h: number
    post_action_verifier_live_readback_count_24h: number
    production_write_count_24h: number
    secret_value_read_count_24h: number
    paid_provider_call_count_24h: number
    host_or_cluster_command_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  permission_lanes: Array<{
    lane_id: 'observe_only' | 'no_write_replay_allowed' | 'proposal_only' | 'human_approval_required' | 'explicitly_blocked'
    display_name: string
    summary: string
    allowed_outputs: string[]
    required_gate_before_promotion: string
    live_execution_allowed: false
    production_write_allowed: false
  }>
  operation_categories: Array<{
    category_id: string
    display_name: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    permission_lane: 'observe_only' | 'no_write_replay_allowed' | 'proposal_only' | 'human_approval_required' | 'explicitly_blocked'
    primary_agent: 'openclaw' | 'hermes' | 'nemotron'
    allowed_outputs: string[]
    blocked_actions: string[]
    required_evidence: string[]
    next_gate: string
    queue_write_allowed: false
    telegram_send_allowed: false
    production_write_allowed: false
    secret_value_read_allowed: false
    destructive_action_allowed: false
    live_execution_allowed: false
    evidence_hash: string
  }>
  agent_permission_roles: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    display_name: string
    permission_responsibility: string
    allowed_lanes: string[]
    blocked_now: string[]
    self_approval_allowed: false
    live_action_count_24h: number
  }>
  gate_transitions: Array<{
    gate_id: string
    display_name: string
    current_status: 'ready_for_review' | 'blocked_until_evidence' | 'blocked_by_policy'
    required_before: string
    next_safe_step: string
    opens_live_execution: false
  }>
  operator_decision_templates: Array<{
    template_id: string
    display_name: string
    when_to_use: string
    human_instruction: string
    creates_runtime_action: false
    requires_human_review: true
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    permission_lane_count: number
    operation_category_count: number
    observe_only_category_count: number
    no_write_replay_allowed_category_count: number
    proposal_only_category_count: number
    human_approval_required_category_count: number
    explicitly_blocked_category_count: number
    human_approval_required_category_ids: string[]
    explicitly_blocked_category_ids: string[]
    agent_role_count: number
    gate_transition_count: number
    operator_decision_template_count: number
    runtime_execution_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    telegram_bot_api_call_count: number
    delivery_receipt_write_count: number
    ai_runtime_worker_run_count: number
    medium_low_auto_execution_count: number
    post_action_verifier_live_readback_count: number
    production_write_count: number
    secret_value_read_count: number
    paid_provider_call_count: number
    host_or_cluster_command_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentCandidateOperationDryRunEvidenceSnapshot {
  schema_version: 'ai_agent_candidate_operation_dry_run_evidence_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-102'
    next_task_id: 'P2-103'
    read_only_mode: true
    runtime_authority: 'candidate_operation_dry_run_evidence_only_no_live_execution_or_send'
    status_note: string
  }
  source_refs: string[]
  dry_run_truth: {
    p2_101_permission_model_loaded: true
    dry_run_evidence_gate_ready: true
    all_candidate_operations_have_dry_run_evidence: true
    side_effect_counter_ready: true
    verifier_plan_ready: true
    rollback_or_noop_plan_ready: true
    owner_review_packet_ready: true
    runtime_execution_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    telegram_bot_api_call_enabled: false
    delivery_receipt_write_enabled: false
    ai_runtime_worker_enabled: false
    medium_low_auto_worker_enabled: false
    post_action_verifier_live_readback_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    paid_provider_call_enabled: false
    host_or_cluster_command_enabled: false
    destructive_operation_enabled: false
    work_window_transcript_display_allowed: false
    runtime_execution_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    telegram_bot_api_call_count_24h: number
    delivery_receipt_write_count_24h: number
    ai_runtime_worker_run_count_24h: number
    medium_low_auto_execution_count_24h: number
    post_action_verifier_live_readback_count_24h: number
    production_write_count_24h: number
    secret_value_read_count_24h: number
    paid_provider_call_count_24h: number
    host_or_cluster_command_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  candidate_operations: Array<{
    candidate_id: string
    source_category_id: string
    display_name: string
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    permission_lane: 'observe_only' | 'no_write_replay_allowed' | 'proposal_only' | 'human_approval_required' | 'explicitly_blocked'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    dry_run_status: 'passed_no_write' | 'needs_owner_review' | 'blocked_until_allowlist' | 'blocked_by_policy'
    dry_run_scope: string
    input_evidence_hash: string
    output_evidence_hash: string
    side_effect_count: number
    production_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    secret_value_read_count: number
    destructive_action_count: number
    blocked_actions: string[]
    required_human_decision: string
    verifier_plan_id: string
    rollback_or_noop_plan: string
    next_gate: string
  }>
  verifier_plans: Array<{
    plan_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    verifier_scope: string
    expected_signal: string
    failure_lane: string
    live_readback_enabled: false
    writes_result: false
    requires_secret_value: false
    evidence_hash: string
  }>
  gate_evidence_requirements: Array<{
    gate_id: string
    display_name: string
    required_evidence: string[]
    missing_or_blocked: string[]
    opens_live_execution: false
  }>
  operator_handoffs: Array<{
    handoff_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    human_instruction: string
    creates_runtime_action: false
    requires_human_review: true
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    candidate_operation_count: number
    candidate_with_dry_run_evidence_count: number
    passed_no_write_count: number
    needs_owner_review_count: number
    blocked_until_allowlist_count: number
    blocked_by_policy_count: number
    verifier_plan_count: number
    gate_evidence_requirement_count: number
    operator_handoff_count: number
    side_effect_count: number
    runtime_execution_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    secret_value_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentTaskResultAuditTrailSnapshot {
  schema_version: 'ai_agent_task_result_audit_trail_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-103'
    next_task_id: 'P2-104'
    read_only_mode: true
    runtime_authority: 'task_result_audit_trail_contract_only_no_live_writeback'
    status_note: string
  }
  source_refs: string[]
  result_audit_truth: {
    p2_102_candidate_dry_run_loaded: true
    task_result_route_matrix_ready: true
    km_draft_contract_ready: true
    logbook_append_contract_ready: true
    audit_trail_contract_ready: true
    timeline_handoff_contract_ready: true
    operator_next_action_ready: true
    all_results_have_owner_and_next_step: true
    runtime_execution_enabled: false
    km_write_enabled: false
    logbook_runtime_write_enabled: false
    audit_db_write_enabled: false
    timeline_write_enabled: false
    playbook_trust_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    delivery_receipt_write_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    host_or_cluster_command_enabled: false
    destructive_operation_enabled: false
    work_window_transcript_display_allowed: false
    runtime_execution_count_24h: number
    km_write_count_24h: number
    logbook_runtime_write_count_24h: number
    audit_db_write_count_24h: number
    timeline_write_count_24h: number
    playbook_trust_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    delivery_receipt_write_count_24h: number
    production_write_count_24h: number
    secret_value_read_count_24h: number
    host_or_cluster_command_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  result_routes: Array<{
    route_id: string
    display_name: string
    source_signal: string
    result_state:
      | 'diagnostic_only'
      | 'owner_review_required'
      | 'execution_failed'
      | 'verified_no_change'
      | 'blocked_until_evidence'
      | 'blocked_by_policy'
      | 'correlation_gap'
      | 'report_quality_gap'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    primary_owner: string
    km_target: string
    logbook_target: string
    audit_target: string
    timeline_target: string
    operator_next_action: string
    blocked_reason: string
    writes_live_state: false
    requires_owner_review: boolean
    ready_for_km_draft: boolean
    evidence_hash: string
  }>
  writeback_contracts: Array<{
    contract_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    target_system: string
    purpose: string
    allowed_mode: 'committed_snapshot_only' | 'gated_owner_review' | 'manual_append_plan'
    write_enabled: false
    runtime_writer_enabled: false
    required_fields: string[]
    blocker_summary: string
    evidence_hash: string
  }>
  audit_checkpoints: Array<{
    checkpoint_id: string
    display_name: string
    required_for: string
    status: 'ready' | 'needs_owner_review' | 'blocked_by_policy'
    failure_if_missing: string
    creates_runtime_action: false
  }>
  operator_handoffs: Array<{
    handoff_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    human_instruction: string
    creates_runtime_action: false
    requires_human_review: true
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    result_route_count: number
    owner_next_action_ready_count: number
    requires_owner_review_count: number
    ready_for_km_draft_count: number
    blocked_result_count: number
    writeback_contract_count: number
    audit_checkpoint_count: number
    operator_handoff_count: number
    runtime_execution_count: number
    km_write_count: number
    logbook_runtime_write_count: number
    audit_db_write_count: number
    timeline_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    secret_value_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentMatchedPlaybookLearningGapSnapshot {
  schema_version: 'ai_agent_matched_playbook_learning_gap_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-104'
    next_task_id: 'P2-105'
    read_only_mode: true
    runtime_authority: 'matched_playbook_learning_gap_contract_only_no_live_trust_write'
    status_note: string
  }
  source_refs: string[]
  production_readback: {
    readback_at: string
    readback_mode: 'read_only_db_readback'
    project_id_scope: 'awoooi'
    rls_fail_closed_verified: true
    approval_total: number
    approval_matched_total: number
    approval_24h_total: number
    approval_24h_matched: number
    matched_rate_24h_percent: number
    playbook_total: number
    playbook_with_execution_stats: number
    playbook_updated_24h: number
    readback_note: string
  }
  recent_status_breakdown: Array<{
    status: 'APPROVED' | 'PENDING' | 'EXECUTION_FAILED'
    total: number
    matched: number
    execution_kind_present: number
    repair_attempted_true: number
    repair_executed_true: number
    learning_candidate_count: number
    readback_note: string
  }>
  learning_gap_truth: {
    p2_103_task_result_audit_loaded: true
    production_db_readback_completed: true
    rls_fail_closed_verified: true
    matched_playbook_id_present_24h: true
    matched_playbook_id_gap_resolved: true
    execution_learning_gap_detected: true
    approved_without_execution_meta_detected: true
    playbook_trust_update_gap_detected: true
    runtime_learning_write_enabled: false
    playbook_trust_write_enabled: false
    approval_auto_execute_enabled: false
    km_write_enabled: false
    logbook_runtime_write_enabled: false
    audit_db_write_enabled: false
    timeline_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    destructive_operation_enabled: false
    work_window_transcript_display_allowed: false
    approval_24h_total: number
    approval_24h_matched: number
    approved_without_execution_meta_24h: number
    pending_with_matched_24h: number
    execution_failed_with_matched_24h: number
    playbook_updated_24h: number
    live_learning_write_count_24h: number
    playbook_trust_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    production_write_count_24h: number
    secret_value_read_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  gap_lanes: Array<{
    lane_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'passed' | 'blocked' | 'owner_review_required' | 'ready'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    count_24h: number
    matched_count_24h: number
    live_write_enabled: false
    evidence: string
    next_gate: string
    evidence_hash: string
  }>
  learning_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'needs_owner_review' | 'blocked_by_policy'
    required_before: string
    failure_if_missing: string
    creates_runtime_write: false
  }>
  writeback_candidates: Array<{
    candidate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    target_system: string
    allowed_mode: 'committed_snapshot_only' | 'gated_owner_review' | 'manual_append_plan'
    write_enabled: false
    runtime_writer_enabled: false
    required_fields: string[]
    blocker_summary: string
    evidence_hash: string
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    gap_lane_count: number
    passed_lane_count: number
    blocked_lane_count: number
    owner_review_lane_count: number
    approval_24h_total: number
    approval_24h_matched: number
    matched_rate_24h_percent: number
    approved_without_execution_meta_24h: number
    pending_with_matched_24h: number
    execution_failed_with_matched_24h: number
    playbook_with_execution_stats_count: number
    playbook_updated_24h_count: number
    learning_gate_count: number
    writeback_candidate_count: number
    live_learning_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    secret_value_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentCriticReviewerResultCaptureSnapshot {
  schema_version: 'ai_agent_critic_reviewer_result_capture_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-105'
    next_task_id: 'P2-106'
    read_only_mode: true
    runtime_authority: 'critic_reviewer_result_capture_contract_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_readback: {
    source_schema_version: 'ai_agent_matched_playbook_learning_gap_v1'
    readback_at: string
    approval_24h_total: number
    approval_24h_matched: number
    approved_without_execution_meta_24h: number
    pending_with_matched_24h: number
    execution_failed_with_matched_24h: number
    playbook_updated_24h: number
    readback_note: string
  }
  score_truth: {
    p2_104_gap_loaded: true
    critic_reviewer_score_required: true
    result_capture_required: true
    playbook_trust_candidate_required: true
    owner_review_required_before_write: true
    post_write_verifier_required: true
    runtime_critic_score_enabled: false
    runtime_reviewer_score_enabled: false
    runtime_result_capture_enabled: false
    runtime_learning_write_enabled: false
    playbook_trust_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    production_write_enabled: false
    secret_value_read_enabled: false
    destructive_operation_enabled: false
    work_window_transcript_display_allowed: false
    approval_24h_total: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    critic_runtime_score_count_24h: number
    reviewer_runtime_score_count_24h: number
    result_capture_runtime_write_count_24h: number
    learning_write_count_24h: number
    playbook_trust_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    production_write_count_24h: number
    secret_value_read_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  agent_scorecards: Array<{
    scorecard_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    role: 'critic' | 'reviewer' | 'reporter' | 'verifier' | 'coordinator'
    status: 'ready_for_owner_review' | 'blocked_by_policy'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    minimum_score: number
    required_fields: string[]
    failure_if_missing: string
    runtime_score_enabled: false
    evidence_hash: string
  }>
  result_capture_contracts: Array<{
    contract_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    result_state: string
    status: 'ready' | 'needs_owner_review' | 'blocked_by_policy'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    count_24h: number
    required_fields: string[]
    write_enabled: false
    runtime_writer_enabled: false
    blocker_summary: string
    evidence_hash: string
  }>
  promotion_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'needs_owner_review' | 'blocked_by_policy'
    required_before: string
    failure_if_missing: string
    creates_runtime_write: false
  }>
  candidate_routes: Array<{
    route_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    candidate_count_24h: number
    status: 'ready_for_owner_review' | 'blocked_by_policy'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    next_gate: string
    write_enabled: false
    evidence_hash: string
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
    allowed_display_fields: string[]
    blocked_display_fields: string[]
  }
  rollups: {
    scorecard_count: number
    result_capture_contract_count: number
    promotion_gate_count: number
    candidate_route_count: number
    approval_24h_total: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    pending_with_matched_24h: number
    blocked_gate_count: number
    owner_review_gate_count: number
    runtime_critic_score_count: number
    runtime_reviewer_score_count: number
    result_capture_runtime_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    secret_value_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentOwnerApprovedResultCaptureDryRunSnapshot {
  schema_version: 'ai_agent_owner_approved_result_capture_dry_run_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-106'
    next_task_id: 'P2-107'
    read_only_mode: true
    runtime_authority: 'owner_approved_result_capture_dry_run_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_contract_readback: {
    source_schema_version: 'ai_agent_critic_reviewer_result_capture_v1'
    readback_at: string
    approval_24h_total: number
    scorecard_count: number
    result_capture_contract_count: number
    promotion_gate_count: number
    candidate_route_count: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    pending_with_matched_24h: number
    result_capture_runtime_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    telegram_send_count: number
    readback_note: string
  }
  dry_run_truth: {
    p2_105_contract_loaded: true
    owner_approval_required: true
    dry_run_preview_allowed: true
    result_capture_payload_template_ready: true
    critic_reviewer_score_fixture_ready: true
    post_write_verifier_fixture_required: true
    redacted_operator_digest_ready: true
    runtime_result_capture_write_enabled: false
    runtime_score_write_enabled: false
    runtime_learning_write_enabled: false
    playbook_trust_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    dry_run_preview_generated_count: number
    result_capture_write_count_24h: number
    score_write_count_24h: number
    learning_write_count_24h: number
    playbook_trust_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  approval_packet: {
    packet_id: string
    display_name: string
    required_owner_fields: string[]
    forbidden_inputs: string[]
    operator_meaning: string
    dry_run_plan_fingerprint: string
  }
  result_capture_dry_run_templates: Array<{
    template_id: string
    display_name: string
    source_contract_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    result_state: string
    status: 'ready_for_dry_run' | 'approval_required' | 'blocked_by_policy'
    candidate_count_24h: number
    required_inputs: string[]
    preview_outputs: string[]
    write_enabled: false
    runtime_writer_enabled: false
    blocked_write_action: string
    no_write_evidence_hash: string
  }>
  critic_reviewer_score_fixtures: Array<{
    fixture_id: string
    source_scorecard_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    minimum_score: number
    fixture_only: true
    runtime_score_write_enabled: false
    required_inputs: string[]
    failure_if_missing: string
    evidence_hash: string
  }>
  dry_run_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_evidence: string
    blocked_write_action: string
    creates_runtime_write: false
  }>
  operator_actions: Array<{
    action_id: string
    action_type: 'review' | 'collect_evidence' | 'approve_dry_run' | 'reject_or_rework' | 'promote_to_next_gate'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    frontend_display_policy: string
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
  }
  rollups: {
    result_capture_template_count: number
    score_fixture_count: number
    dry_run_gate_count: number
    operator_action_count: number
    approval_required_gate_count: number
    blocked_gate_count: number
    approval_24h_total: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    owner_approval_received_count: number
    dry_run_preview_generated_count: number
    result_capture_write_count: number
    score_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentOwnerApprovedResultCaptureReadbackSnapshot {
  schema_version: 'ai_agent_owner_approved_result_capture_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-107'
    next_task_id: 'P2-108'
    read_only_mode: true
    runtime_authority: 'owner_approved_result_capture_readback_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_dry_run_readback: {
    source_schema_version: 'ai_agent_owner_approved_result_capture_dry_run_v1'
    readback_at: string
    result_capture_template_count: number
    score_fixture_count: number
    dry_run_gate_count: number
    operator_action_count: number
    approval_required_gate_count: number
    blocked_gate_count: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    owner_approval_received_count: number
    dry_run_preview_generated_count: number
    result_capture_write_count: number
    score_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    readback_note: string
  }
  readback_truth: {
    p2_106_dry_run_loaded: true
    fixture_readback_allowed: true
    readback_digest_ready: true
    promotion_readiness_review_ready: true
    owner_review_required_before_promotion: true
    canonical_runtime_readback_enabled: false
    runtime_result_capture_write_enabled: false
    runtime_score_write_enabled: false
    runtime_learning_write_enabled: false
    playbook_trust_write_enabled: false
    reviewer_queue_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    readback_digest_generated_count: number
    promotion_approved_count: number
    reviewer_queue_write_count: number
    result_capture_write_count_24h: number
    score_write_count_24h: number
    learning_write_count_24h: number
    playbook_trust_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  result_capture_readback_digests: Array<{
    digest_id: string
    display_name: string
    source_template_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    candidate_count_24h: number
    readback_fields: string[]
    verifier_checks: string[]
    promotion_blocker: string
    fixture_only: true
    runtime_read_enabled: false
    write_enabled: false
    evidence_hash: string
  }>
  promotion_readiness_reviews: Array<{
    review_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_digest_id: string
    readiness_state: 'ready_for_owner_review' | 'needs_owner_review' | 'blocked_by_policy'
    risk_tier: 'low' | 'medium' | 'high' | 'critical'
    required_before_promotion: string[]
    failure_if_missing: string
    promotion_allowed: false
    creates_runtime_write: false
  }>
  failure_lanes: Array<{
    lane_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_review' | 'blocked_by_policy'
    trigger_condition: string
    required_response: string
    aborts_promotion: true
    creates_runtime_write: false
  }>
  reviewer_queue_preview: Array<{
    queue_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    reviewer_role: 'arbiter' | 'reporter' | 'verifier' | 'safety_reviewer'
    status: 'queued_for_owner_review' | 'blocked_by_policy'
    required_inputs: string[]
    queue_write_enabled: false
    telegram_send_enabled: false
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    action_type: 'review_readback' | 'compare_digest' | 'review_failure_lane' | 'reject_or_rework' | 'promote_to_next_gate'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    frontend_display_policy: string
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
  }
  rollups: {
    readback_digest_count: number
    promotion_review_count: number
    failure_lane_count: number
    reviewer_queue_preview_count: number
    operator_action_count: number
    approval_required_digest_count: number
    blocked_digest_count: number
    ready_review_count: number
    blocked_review_count: number
    blocked_failure_lane_count: number
    queued_reviewer_preview_count: number
    blocked_reviewer_preview_count: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    owner_approval_received_count: number
    readback_digest_generated_count: number
    promotion_approved_count: number
    reviewer_queue_write_count: number
    result_capture_write_count: number
    score_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentRuntimeReadbackApprovalPackageSnapshot {
  schema_version: 'ai_agent_runtime_readback_approval_package_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-109'
    next_task_id: 'P2-110'
    read_only_mode: true
    runtime_authority: 'runtime_readback_approval_package_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_readback_readiness: {
    source_schema_version: 'ai_agent_owner_approved_result_capture_readback_v1'
    readback_at: string
    readback_digest_count: number
    promotion_review_count: number
    failure_lane_count: number
    reviewer_queue_preview_count: number
    operator_action_count: number
    approval_required_digest_count: number
    blocked_total_count: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    owner_approval_received_count: number
    readback_digest_generated_count: number
    promotion_approved_count: number
    reviewer_queue_write_count: number
    result_capture_write_count: number
    score_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    production_write_count: number
    readiness_note: string
  }
  approval_package_truth: {
    p2_107_readback_loaded: true
    approval_package_ready: true
    canonical_readback_plan_ready: true
    rollback_drill_ready: true
    telegram_failure_receipt_gate_ready: true
    owner_review_required_before_runtime: true
    canonical_runtime_readback_enabled: false
    runtime_result_capture_write_enabled: false
    runtime_score_write_enabled: false
    runtime_learning_write_enabled: false
    playbook_trust_write_enabled: false
    reviewer_queue_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_failure_receipt_send_enabled: false
    bot_api_call_enabled: false
    rollback_work_item_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    runtime_readback_execution_count: number
    result_capture_write_count_24h: number
    score_write_count_24h: number
    learning_write_count_24h: number
    playbook_trust_write_count_24h: number
    reviewer_queue_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_failure_receipt_send_count_24h: number
    bot_api_call_count_24h: number
    rollback_work_item_write_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  approval_packet_templates: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    risk_tier: 'medium' | 'high' | 'critical'
    required_approval_fields: string[]
    blocked_runtime_actions: string[]
    operator_guidance: string
    approval_required: true
    runtime_write_allowed: false
    evidence_hash: string
  }>
  canonical_readback_plans: Array<{
    plan_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'planned_no_runtime_read' | 'blocked_by_policy'
    query_scope: string
    required_fields: string[]
    redaction_checks: string[]
    live_query_enabled: false
    runtime_write_allowed: false
    evidence_hash: string
  }>
  rollback_drill_lanes: Array<{
    lane_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'planned_no_write' | 'blocked_by_policy'
    rollback_owner: string
    required_steps: string[]
    failure_if_missing: string
    rollback_write_enabled: false
    creates_runtime_write: false
  }>
  telegram_failure_receipt_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'blocked_by_policy'
    required_evidence: string[]
    failure_if_missing: string
    queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    action_type: 'review_approval_package' | 'validate_canonical_plan' | 'review_rollback_drill' | 'review_failure_receipt_gate' | 'reject_or_promote'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    frontend_display_policy: string
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
  }
  rollups: {
    approval_packet_count: number
    canonical_readback_plan_count: number
    rollback_drill_lane_count: number
    telegram_failure_receipt_gate_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_packet_count: number
    blocked_readback_plan_count: number
    blocked_rollback_lane_count: number
    blocked_telegram_gate_count: number
    approved_without_execution_meta_24h: number
    execution_failed_with_matched_24h: number
    owner_approval_received_count: number
    runtime_readback_execution_count: number
    result_capture_write_count: number
    score_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_failure_receipt_send_count: number
    bot_api_call_count: number
    rollback_work_item_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentRuntimeReadbackImplementationReviewSnapshot {
  schema_version: 'ai_agent_runtime_readback_implementation_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-110'
    next_task_id: 'P2-111'
    read_only_mode: true
    runtime_authority: 'runtime_readback_implementation_review_only_no_live_read_or_write'
    status_note: string
  }
  source_refs: string[]
  prior_approval_package: {
    source_schema_version: 'ai_agent_runtime_readback_approval_package_v1'
    readback_at: string
    approval_packet_count: number
    canonical_readback_plan_count: number
    rollback_drill_lane_count: number
    telegram_failure_receipt_gate_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_total_count: number
    owner_approval_received_count: number
    runtime_readback_execution_count: number
    telegram_failure_receipt_send_count: number
    bot_api_call_count: number
    rollback_work_item_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    readiness_note: string
  }
  implementation_review_truth: {
    p2_109_approval_package_loaded: true
    implementation_review_ready: true
    adapter_contract_ready: true
    verifier_contract_ready: true
    redaction_contract_ready: true
    telemetry_receipt_contract_ready: true
    owner_review_required_before_runtime: true
    canonical_runtime_readback_enabled: false
    live_query_enabled: false
    runtime_result_capture_write_enabled: false
    runtime_score_write_enabled: false
    runtime_learning_write_enabled: false
    playbook_trust_write_enabled: false
    reviewer_queue_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_failure_receipt_send_enabled: false
    bot_api_call_enabled: false
    rollback_work_item_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    runtime_readback_execution_count: number
    live_query_count_24h: number
    result_capture_write_count_24h: number
    score_write_count_24h: number
    learning_write_count_24h: number
    playbook_trust_write_count_24h: number
    reviewer_queue_write_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_failure_receipt_send_count_24h: number
    bot_api_call_count_24h: number
    rollback_work_item_write_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  implementation_review_cards: Array<{
    card_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    risk_tier: 'high' | 'critical'
    implementation_surface: string
    required_interfaces: string[]
    blocked_runtime_actions: string[]
    review_guidance: string
    owner_review_required: true
    no_write_mode: true
    evidence_hash: string
  }>
  no_write_verifier_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'blocked_by_policy'
    check_scope: string
    required_evidence: string[]
    failure_if_missing: string
    live_query_enabled: false
    runtime_write_allowed: false
    evidence_hash: string
  }>
  implementation_blockers: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'blocking_runtime' | 'blocking_live_read' | 'blocking_queue_write' | 'blocking_notification' | 'blocking_production_write'
    blocked_until: string
    blocked_action: string
    required_resolution: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    action_type: 'review_implementation_contract' | 'validate_adapter_mapping' | 'validate_zero_write_counters' | 'review_failure_receipt_mapping' | 'reject_or_promote'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    frontend_display_policy: string
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    work_window_transcript_display_allowed: false
  }
  rollups: {
    implementation_review_card_count: number
    no_write_verifier_check_count: number
    implementation_blocker_count: number
    operator_action_count: number
    approval_required_card_count: number
    blocked_card_count: number
    blocked_verifier_check_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    runtime_readback_execution_count: number
    live_query_count: number
    result_capture_write_count: number
    score_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_failure_receipt_send_count: number
    bot_api_call_count: number
    rollback_work_item_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentReportLiveDeliveryApprovalPackageSnapshot {
  schema_version: 'ai_agent_report_live_delivery_approval_package_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-111'
    next_task_id: 'P2-112'
    read_only_mode: true
    runtime_authority: 'report_live_delivery_approval_package_only_no_live_send_or_write'
    status_note: string
  }
  source_refs: string[]
  prior_report_status_board: {
    source_schema_version: 'ai_agent_report_status_board_v1'
    readback_at: string
    report_card_count: number
    agent_status_report_count: number
    visible_chart_count: number
    operator_answer_count: number
    work_units_total: number
    work_units_done: number
    work_units_waiting_approval: number
    live_delivery_count: number
    live_telegram_send_count_24h: number
    live_auto_optimization_count_24h: number
    readiness_note: string
  }
  prior_runtime_review: {
    approval_package_schema_version: 'ai_agent_runtime_readback_approval_package_v1'
    implementation_review_schema_version: 'ai_agent_runtime_readback_implementation_review_v1'
    telegram_failure_receipt_gate_count: number
    implementation_blocker_count: number
    no_write_verifier_check_count: number
    owner_approval_received_count: number
    runtime_readback_execution_count: number
    live_query_count: number
    telegram_failure_receipt_send_count: number
    bot_api_call_count: number
    gateway_queue_write_count: number
    production_write_count: number
    readiness_note: string
  }
  delivery_approval_truth: {
    p2_108_report_status_loaded: true
    p2_109_failure_receipt_gate_loaded: true
    p2_110_implementation_review_loaded: true
    delivery_approval_package_ready: true
    daily_delivery_package_ready: true
    weekly_delivery_package_ready: true
    monthly_delivery_package_ready: true
    sre_war_room_route_locked: true
    payload_redaction_ready: true
    dry_run_receipt_ready: true
    owner_review_required_before_delivery: true
    scheduler_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    report_receipt_write_enabled: false
    ai_analysis_run_enabled: false
    medium_low_auto_optimization_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    scheduled_delivery_count_24h: number
    gateway_queue_write_count_24h: number
    telegram_send_count_24h: number
    bot_api_call_count_24h: number
    report_receipt_write_count_24h: number
    ai_analysis_run_count_24h: number
    auto_optimization_count_24h: number
    production_write_count_24h: number
    secret_read_count_24h: number
    destructive_operation_count_24h: number
    truth_note: string
  }
  delivery_approval_packets: Array<{
    packet_id: string
    display_name: string
    cadence: 'daily' | 'weekly' | 'monthly' | 'failure_only' | 'receipt'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'approval_required' | 'ready_for_owner_review' | 'blocked_by_policy'
    risk_tier: 'medium' | 'high' | 'critical'
    required_approval_fields: string[]
    blocked_runtime_actions: string[]
    operator_guidance: string
    approval_required: true
    no_send_mode: true
    evidence_hash: string
  }>
  route_lock_gates: Array<{
    gate_id: string
    display_name: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    required_evidence: string[]
    blocked_routes: string[]
    telegram_send_enabled: false
    bot_api_call_enabled: false
    gateway_queue_write_enabled: false
    evidence_hash: string
  }>
  payload_redaction_checks: Array<{
    check_id: string
    display_name: string
    status: 'ready' | 'blocked_by_policy'
    required_rule: string
    failure_if_missing: string
    display_allowed: false
    evidence_hash: string
  }>
  dry_run_delivery_receipts: Array<{
    receipt_id: string
    display_name: string
    cadence: 'daily' | 'weekly' | 'monthly' | 'failure_only' | 'receipt'
    status: 'ready_for_owner_review' | 'blocked_by_policy'
    required_fields: string[]
    live_send_count: number
    receipt_write_allowed: false
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    action_type: 'review_delivery_packet' | 'validate_sre_route' | 'validate_payload_redaction' | 'validate_zero_send_counters' | 'reject_or_promote'
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    live_send_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    frontend_display_policy: string
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_telegram_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
  }
  rollups: {
    delivery_approval_packet_count: number
    route_lock_gate_count: number
    payload_redaction_check_count: number
    dry_run_delivery_receipt_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_packet_count: number
    blocked_route_gate_count: number
    blocked_receipt_count: number
    owner_approval_received_count: number
    scheduled_delivery_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    ai_analysis_run_count: number
    auto_optimization_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentRuntimeReadbackFixtureApprovalSnapshot {
  schema_version: 'ai_agent_runtime_readback_fixture_approval_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-112'
    next_task_id: 'P2-113'
    read_only_mode: true
    runtime_authority: 'runtime_readback_fixture_approval_only_no_canonical_target_or_live_query'
    status_note: string
  }
  source_refs: string[]
  prior_runtime_review: {
    implementation_review_schema_version: 'ai_agent_runtime_readback_implementation_review_v1'
    implementation_review_card_count: number
    no_write_verifier_check_count: number
    implementation_blocker_count: number
    runtime_readback_execution_count: number
    live_query_count: number
    production_write_count: number
    readiness_note: string
  }
  prior_delivery_approval: {
    delivery_approval_schema_version: 'ai_agent_report_live_delivery_approval_package_v1'
    delivery_approval_packet_count: number
    route_lock_gate_count: number
    payload_redaction_check_count: number
    dry_run_delivery_receipt_count: number
    telegram_send_count: number
    gateway_queue_write_count: number
    bot_api_call_count: number
    readiness_note: string
  }
  fixture_approval_truth: {
    p2_110_implementation_review_loaded: true
    p2_111_delivery_approval_loaded: true
    fixture_approval_package_ready: true
    adapter_contract_ready: true
    verifier_fixture_ready: true
    blocker_mapping_ready: true
    owner_review_required_before_readback: true
    canonical_runtime_target_read_enabled: false
    live_query_enabled: false
    runtime_readback_execution_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    report_receipt_write_enabled: false
    result_capture_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    fixture_readback_execution_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    production_write_count: number
    truth_note: string
  }
  fixture_approval_cards: Array<{
    card_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_task_id: 'P2-110' | 'P2-111'
    status: 'approval_required' | 'ready_for_owner_review' | 'blocked_by_policy'
    risk_tier: 'medium' | 'high' | 'critical'
    required_fixture_fields: string[]
    blocked_runtime_actions: string[]
    operator_guidance: string
    owner_approval_required: true
    fixture_only: true
    evidence_hash: string
  }>
  adapter_contracts: Array<{
    contract_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    input_schema: string
    output_schema: string
    required_evidence: string[]
    canonical_target_read_enabled: false
    live_query_enabled: false
    evidence_hash: string
  }>
  verifier_fixture_checks: Array<{
    check_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_fixture: string
    failure_if_missing: string
    live_verifier_enabled: false
    evidence_hash: string
  }>
  blocker_mappings: Array<{
    blocker_id: string
    display_name: string
    source_blocker: string
    severity: 'medium' | 'high' | 'critical'
    blocked_action: string
    blocked_until: string
    status: 'mapped' | 'approval_required' | 'blocked_by_policy'
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    action_type: 'review_fixture_approval' | 'compare_adapter_contract' | 'confirm_no_live_query' | 'reject_canonical_target' | 'promote_to_p2_113'
    operator_instruction: string
    runtime_readback_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    frontend_display_policy: string
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
  }
  rollups: {
    fixture_approval_card_count: number
    adapter_contract_count: number
    verifier_fixture_check_count: number
    blocker_mapping_count: number
    operator_action_count: number
    approval_required_card_count: number
    blocked_card_count: number
    blocked_contract_count: number
    blocked_check_count: number
    owner_approval_received_count: number
    fixture_readback_execution_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentRuntimeReadbackPromotionGateSnapshot {
  schema_version: 'ai_agent_runtime_readback_promotion_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-113'
    next_task_id: 'P2-114'
    read_only_mode: true
    runtime_authority: 'runtime_readback_promotion_gate_only_no_live_queue_or_result_write'
    status_note: string
  }
  source_refs: string[]
  prior_fixture_approval: {
    fixture_approval_schema_version: 'ai_agent_runtime_readback_fixture_approval_v1'
    fixture_approval_card_count: number
    adapter_contract_count: number
    verifier_fixture_check_count: number
    blocker_mapping_count: number
    operator_action_count: number
    owner_approval_received_count: number
    fixture_readback_execution_count: number
    live_query_count: number
    production_write_count: number
    readiness_note: string
  }
  promotion_truth: {
    p2_112_fixture_approval_loaded: true
    promotion_gate_ready: true
    failure_receipt_fixture_ready: true
    reviewer_queue_preview_ready: true
    result_capture_preview_ready: true
    owner_acceptance_required_before_promotion: true
    canonical_runtime_target_read_enabled: false
    live_query_enabled: false
    failure_receipt_send_enabled: false
    reviewer_queue_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    report_receipt_write_enabled: false
    result_capture_write_enabled: false
    learning_write_enabled: false
    playbook_trust_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    promotion_execution_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    failure_receipt_send_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    truth_note: string
  }
  promotion_lanes: Array<{
    lane_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_task_id: 'P2-111' | 'P2-112' | 'P2-113'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    risk_tier: 'medium' | 'high' | 'critical'
    allowed_artifact: string
    blocked_runtime_actions: string[]
    operator_guidance: string
    owner_approval_required: true
    promotion_only: true
    evidence_hash: string
  }>
  receipt_contracts: Array<{
    contract_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    source_schema: string
    output_artifact: string
    required_evidence: string[]
    live_send_enabled: false
    receipt_write_enabled: false
    evidence_hash: string
  }>
  reviewer_queue_previews: Array<{
    preview_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_fields: string[]
    queue_write_enabled: false
    audit_write_enabled: false
    evidence_hash: string
  }>
  result_capture_previews: Array<{
    preview_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_fields: string[]
    result_capture_write_enabled: false
    learning_write_enabled: false
    evidence_hash: string
  }>
  no_write_verifier_checks: Array<{
    check_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_fixture: string
    failure_if_missing: string
    live_verifier_enabled: false
    evidence_hash: string
  }>
  blocker_mappings: Array<{
    blocker_id: string
    display_name: string
    severity: 'medium' | 'high' | 'critical'
    status: 'mapped' | 'approval_required' | 'blocked_by_policy'
    source_blocker: string
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    action_type: 'review_promotion_lane' | 'verify_failure_receipt_fixture' | 'confirm_reviewer_queue_no_write' | 'compare_result_capture_preview' | 'promote_to_p2_114'
    operator_instruction: string
    runtime_promotion_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    promotion_lane_count: number
    receipt_contract_count: number
    reviewer_queue_preview_count: number
    result_capture_preview_count: number
    no_write_verifier_check_count: number
    blocker_mapping_count: number
    operator_action_count: number
    approval_required_lane_count: number
    blocked_lane_count: number
    blocked_receipt_contract_count: number
    approval_required_reviewer_preview_count: number
    blocked_result_preview_count: number
    owner_approval_received_count: number
    promotion_execution_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    failure_receipt_send_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentOwnerApprovedFixturePromotionGateSnapshot {
  schema_version: 'ai_agent_owner_approved_fixture_promotion_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-114'
    next_task_id: 'P2-115'
    read_only_mode: true
    runtime_authority: 'owner_approved_fixture_promotion_gate_only_no_live_read_or_write'
    status_note: string
  }
  source_refs: string[]
  prior_promotion_gate: {
    schema_version: 'ai_agent_runtime_readback_promotion_gate_v1'
    promotion_lane_count: number
    receipt_contract_count: number
    reviewer_queue_preview_count: number
    result_capture_preview_count: number
    no_write_verifier_check_count: number
    blocker_mapping_count: number
    operator_action_count: number
    owner_approval_received_count: number
    promotion_execution_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    production_write_count: number
    readiness_note: string
  }
  owner_gate_truth: {
    p2_113_promotion_gate_loaded: true
    owner_promotion_package_ready: true
    acceptance_record_template_ready: true
    reviewer_queue_fixture_ready: true
    result_capture_fixture_ready: true
    rollback_owner_required: true
    verifier_plan_required: true
    owner_approval_received: false
    canonical_runtime_target_read_enabled: false
    live_query_enabled: false
    failure_receipt_send_enabled: false
    reviewer_queue_write_enabled: false
    gateway_queue_write_enabled: false
    telegram_send_enabled: false
    bot_api_call_enabled: false
    report_receipt_write_enabled: false
    result_capture_write_enabled: false
    learning_write_enabled: false
    playbook_trust_write_enabled: false
    production_write_enabled: false
    secret_read_enabled: false
    destructive_operation_enabled: false
    owner_approval_received_count: number
    owner_acceptance_record_write_count: number
    promotion_execution_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    failure_receipt_send_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    truth_note: string
  }
  owner_approval_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_lane_id: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    risk_tier: 'high' | 'critical'
    required_owner_fields: string[]
    allowed_fixture: string
    blocked_runtime_actions: string[]
    owner_acceptance_required: true
    evidence_hash: string
  }>
  acceptance_record_templates: Array<{
    template_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_fields: string[]
    accepted: false
    record_write_enabled: false
    evidence_hash: string
  }>
  fixture_promotion_reviews: Array<{
    review_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    source_packet_id: string
    review_outcome: string
    runtime_write_enabled: false
    evidence_hash: string
  }>
  no_write_verifier_plans: Array<{
    plan_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_fixture: string
    failure_if_missing: string
    live_verifier_enabled: false
    evidence_hash: string
  }>
  blocked_promotions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    action_type: 'review_owner_packet' | 'verify_acceptance_template' | 'confirm_verifier_plan' | 'lock_blocked_promotion' | 'promote_to_p2_115'
    operator_instruction: string
    runtime_promotion_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    owner_approval_packet_count: number
    acceptance_record_template_count: number
    fixture_promotion_review_count: number
    no_write_verifier_plan_count: number
    blocked_promotion_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_packet_count: number
    approval_required_template_count: number
    blocked_template_count: number
    approval_required_review_count: number
    blocked_review_count: number
    approval_required_verifier_count: number
    blocked_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    owner_acceptance_record_write_count: number
    promotion_execution_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    failure_receipt_send_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentCanonicalRuntimeReadbackOwnerAcceptanceSnapshot
  extends Omit<AiAgentOwnerApprovedFixturePromotionGateSnapshot, 'schema_version' | 'program_status'> {
  schema_version: 'ai_agent_canonical_runtime_readback_owner_acceptance_v1'
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-115'
    next_task_id: 'P2-116'
    read_only_mode: true
    runtime_authority: 'canonical_runtime_readback_owner_acceptance_only_no_live_read_or_write'
    status_note: string
  }
}

export interface AiAgentFailureReceiptNoSendReplaySnapshot {
  schema_version: 'ai_agent_failure_receipt_no_send_replay_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-116'
    next_task_id: 'P2-117'
    read_only_mode: true
    runtime_authority: 'failure_receipt_no_send_replay_only_no_queue_or_send'
    status_note: string
  }
  source_refs: string[]
  prior_owner_acceptance: {
    schema_version: string
    owner_approval_packet_count: number
    acceptance_record_template_count: number
    fixture_promotion_review_count: number
    no_write_verifier_plan_count: number
    blocked_promotion_count: number
    operator_action_count: number
    owner_approval_received_count: number
    owner_acceptance_record_write_count: number
    canonical_runtime_target_read_count: number
    failure_receipt_send_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    result_capture_write_count: number
    readiness_note: string
  }
  replay_truth: {
    p2_115_owner_acceptance_loaded: boolean
    no_send_replay_package_ready: boolean
    failure_receipt_fixture_ready: boolean
    route_lock_fixture_ready: boolean
    redaction_fixture_ready: boolean
    operator_handoff_ready: boolean
    no_send_verifier_required: boolean
    owner_approval_received: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    failure_receipt_send_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    failure_receipt_send_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    reviewer_queue_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    truth_note: string
  }
  no_send_replay_fixtures: Array<{
    fixture_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_packet_id: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    incident_stage: string
    target_channel: string
    payload_outline: string[]
    redaction_contract: string
    send_enabled: false
    evidence_hash: string
  }>
  route_lock_checks: Array<{
    check_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    target_route: string
    deprecated_route_count: number
    queue_write_enabled: false
    evidence_hash: string
  }>
  replay_verifier_checks: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifies: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  blocked_sends: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_send_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    no_send_replay_fixture_count: number
    route_lock_check_count: number
    replay_verifier_check_count: number
    blocked_send_count: number
    operator_action_count: number
    approval_required_fixture_count: number
    blocked_fixture_count: number
    approval_required_route_lock_count: number
    blocked_route_lock_count: number
    approval_required_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    failure_receipt_send_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    reviewer_queue_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentReviewerQueueNoWriteReadbackSnapshot {
  schema_version: 'ai_agent_reviewer_queue_no_write_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-117'
    next_task_id: 'P2-118'
    read_only_mode: true
    runtime_authority: 'reviewer_queue_no_write_readback_only_no_queue_write_or_send'
    status_note: string
  }
  source_refs: string[]
  prior_failure_receipt_replay: {
    schema_version: string
    no_send_replay_fixture_count: number
    route_lock_check_count: number
    replay_verifier_check_count: number
    blocked_send_count: number
    operator_action_count: number
    failure_receipt_send_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    reviewer_queue_write_count: number
    result_capture_write_count: number
    readiness_note: string
  }
  readback_truth: {
    p2_116_no_send_replay_loaded: boolean
    reviewer_queue_readback_package_ready: boolean
    reviewer_queue_fixture_ready: boolean
    queue_item_mapping_ready: boolean
    no_write_verifier_ready: boolean
    operator_handoff_ready: boolean
    result_capture_preview_ready: boolean
    owner_approval_received: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    truth_note: string
  }
  reviewer_queue_readback_fixtures: Array<{
    fixture_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_replay_fixture_id: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    queue_lane: string
    readback_mode: 'no_write_fixture'
    reviewer_queue_write_enabled: false
    next_manual_action: string
    evidence_hash: string
  }>
  queue_item_mappings: Array<{
    mapping_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    source_fixture_id: string
    target_queue: string
    queue_write_enabled: false
    required_reviewer: string
    evidence_hash: string
  }>
  readback_verifier_checks: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifies: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  blocked_queue_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_queue_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    reviewer_queue_readback_fixture_count: number
    queue_item_mapping_count: number
    readback_verifier_check_count: number
    blocked_queue_write_count: number
    operator_action_count: number
    approval_required_fixture_count: number
    blocked_fixture_count: number
    approval_required_mapping_count: number
    blocked_mapping_count: number
    approval_required_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureNoWriteReadbackSnapshot {
  schema_version: 'ai_agent_result_capture_no_write_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-118'
    next_task_id: 'P2-119'
    read_only_mode: true
    runtime_authority: 'result_capture_no_write_readback_only_no_capture_or_learning_write'
    status_note: string
  }
  source_refs: string[]
  prior_reviewer_queue_readback: {
    schema_version: string
    reviewer_queue_readback_fixture_count: number
    queue_item_mapping_count: number
    readback_verifier_check_count: number
    blocked_queue_write_count: number
    operator_action_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    readiness_note: string
  }
  readback_truth: {
    p2_117_reviewer_queue_readback_loaded: boolean
    result_capture_readback_package_ready: boolean
    result_capture_fixture_ready: boolean
    capture_field_mapping_ready: boolean
    no_write_verifier_ready: boolean
    operator_handoff_ready: boolean
    learning_preview_ready: boolean
    owner_approval_received: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    truth_note: string
  }
  result_capture_readback_fixtures: Array<{
    fixture_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_queue_mapping_id: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    capture_lane: string
    readback_mode: 'no_write_fixture'
    result_capture_write_enabled: false
    next_manual_action: string
    evidence_hash: string
  }>
  capture_field_mappings: Array<{
    mapping_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    source_fixture_id: string
    target_capture: string
    capture_write_enabled: false
    required_owner: string
    evidence_hash: string
  }>
  readback_verifier_checks: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifies: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  blocked_result_capture_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_capture_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    result_capture_readback_fixture_count: number
    capture_field_mapping_count: number
    readback_verifier_check_count: number
    blocked_result_capture_write_count: number
    operator_action_count: number
    approval_required_fixture_count: number
    blocked_fixture_count: number
    approval_required_mapping_count: number
    blocked_mapping_count: number
    approval_required_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCapturePromotionApprovalGateSnapshot {
  schema_version: 'ai_agent_result_capture_promotion_approval_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-119'
    next_task_id: 'P2-120'
    read_only_mode: true
    runtime_authority: 'result_capture_promotion_approval_gate_only_no_capture_or_learning_write'
    status_note: string
  }
  source_refs: string[]
  prior_result_capture_no_write_readback: {
    schema_version: string
    result_capture_readback_fixture_count: number
    capture_field_mapping_count: number
    readback_verifier_check_count: number
    blocked_result_capture_write_count: number
    operator_action_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  promotion_truth: {
    p2_118_result_capture_readback_loaded: boolean
    promotion_approval_package_ready: boolean
    acceptance_gate_template_ready: boolean
    promotion_verifier_ready: boolean
    operator_handoff_ready: boolean
    rollback_and_reverify_required: boolean
    owner_approval_received: boolean
    capture_promotion_approved: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    capture_promotion_approved_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    truth_note: string
  }
  promotion_approval_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_capture_fixture_id: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    approval_lane: string
    promotion_mode: 'approval_gate_only'
    result_capture_write_enabled: false
    required_decision: string
    evidence_hash: string
  }>
  acceptance_gate_templates: Array<{
    template_id: string
    display_name: string
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    source_packet_id: string
    target_promotion: string
    promotion_write_enabled: false
    required_owner: string
    required_fields: string[]
    evidence_hash: string
  }>
  promotion_verifier_checks: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifies: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  blocked_promotion_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_promotion_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    promotion_approval_packet_count: number
    acceptance_gate_template_count: number
    promotion_verifier_check_count: number
    blocked_promotion_write_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_packet_count: number
    approval_required_template_count: number
    blocked_template_count: number
    approval_required_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    capture_promotion_approved_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentOwnerApprovedResultCapturePromotionDryRunSnapshot {
  schema_version: 'ai_agent_owner_approved_result_capture_promotion_dry_run_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-120'
    next_task_id: 'P2-121'
    read_only_mode: true
    runtime_authority: 'owner_approved_result_capture_promotion_dry_run_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_result_capture_promotion_gate: {
    schema_version: string
    promotion_approval_packet_count: number
    acceptance_gate_template_count: number
    promotion_verifier_check_count: number
    blocked_promotion_write_count: number
    operator_action_count: number
    owner_approval_received_count: number
    capture_promotion_approved_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  dry_run_truth: {
    p2_119_promotion_gate_loaded: boolean
    owner_approval_required: boolean
    dry_run_preview_allowed: boolean
    promotion_packet_ready: boolean
    acceptance_template_ready: boolean
    verifier_dry_run_ready: boolean
    operator_handoff_ready: boolean
    owner_approval_received: boolean
    capture_promotion_approved: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    capture_promotion_approved_count: number
    dry_run_preview_generated_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    truth_note: string
  }
  promotion_dry_run_templates: Array<{
    template_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_packet_id: string
    status: 'ready_for_dry_run' | 'approval_required' | 'blocked_by_policy'
    target_dry_run: string
    dry_run_mode: 'preview_only'
    runtime_write_enabled: false
    preview_summary: string
    evidence_hash: string
  }>
  owner_acceptance_dry_run_fixtures: Array<{
    fixture_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_owner: string
    fixture_only: true
    runtime_write_enabled: false
    verifies: string
    evidence_hash: string
  }>
  dry_run_verifier_checks: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifies: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  blocked_runtime_promotions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    promotion_dry_run_template_count: number
    owner_acceptance_fixture_count: number
    dry_run_verifier_check_count: number
    blocked_runtime_promotion_count: number
    operator_action_count: number
    approval_required_template_count: number
    blocked_template_count: number
    approval_required_fixture_count: number
    blocked_fixture_count: number
    approval_required_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    capture_promotion_approved_count: number
    dry_run_preview_generated_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureWriteGateReviewSnapshot {
  schema_version: 'ai_agent_result_capture_write_gate_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-121'
    next_task_id: 'P2-122'
    read_only_mode: true
    runtime_authority: 'result_capture_write_gate_review_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_approved_promotion_dry_run: {
    schema_version: string
    promotion_dry_run_template_count: number
    owner_acceptance_fixture_count: number
    dry_run_verifier_check_count: number
    blocked_runtime_promotion_count: number
    operator_action_count: number
    owner_approval_received_count: number
    capture_promotion_approved_count: number
    dry_run_preview_generated_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  write_gate_truth: {
    p2_120_dry_run_loaded: boolean
    result_capture_writer_gate_review_ready: boolean
    learning_writer_gate_review_ready: boolean
    playbook_trust_writer_gate_review_ready: boolean
    reviewer_queue_gate_review_ready: boolean
    gateway_queue_gate_review_ready: boolean
    dual_approval_required: boolean
    dry_run_hash_required: boolean
    post_write_verifier_required: boolean
    rollback_required: boolean
    redaction_required: boolean
    result_capture_write_approved: boolean
    learning_write_approved: boolean
    playbook_trust_write_approved: boolean
    reviewer_queue_write_approved: boolean
    gateway_queue_write_approved: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    post_write_verifier_pass_count: number
    rollback_plan_verified_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  write_gate_reviews: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    target_writer: string
    target_write_gate: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    required_before_write: string
    blocked_write_action: string
    dual_approval_required: true
    dry_run_hash_required: true
    post_write_verifier_required: true
    runtime_write_enabled: false
    evidence_hash: string
  }>
  approval_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_evidence: string
    blocked_runtime_action: string
    runtime_write_allowed: false
  }>
  post_write_verifier_plan: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifies: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  blocked_live_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    write_gate_review_count: number
    approval_gate_count: number
    post_write_verifier_plan_count: number
    blocked_live_write_count: number
    operator_action_count: number
    approval_required_review_count: number
    blocked_review_count: number
    approval_required_gate_count: number
    blocked_gate_count: number
    approval_required_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    post_write_verifier_pass_count: number
    rollback_plan_verified_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureWriterImplementationReviewSnapshot {
  schema_version: 'ai_agent_result_capture_writer_implementation_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-122'
    next_task_id: 'P2-123'
    read_only_mode: true
    runtime_authority: 'result_capture_writer_implementation_review_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_result_capture_write_gate_review: {
    schema_version: string
    write_gate_review_count: number
    approval_gate_count: number
    post_write_verifier_plan_count: number
    blocked_live_write_count: number
    operator_action_count: number
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    post_write_verifier_pass_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  implementation_truth: {
    p2_121_write_gate_loaded: boolean
    result_capture_writer_implementation_review_ready: boolean
    learning_writer_implementation_review_ready: boolean
    playbook_trust_writer_implementation_review_ready: boolean
    reviewer_queue_writer_implementation_review_ready: boolean
    gateway_queue_writer_implementation_review_ready: boolean
    dual_approval_required: boolean
    dry_run_hash_required: boolean
    idempotency_key_required: boolean
    transaction_boundary_required: boolean
    post_implementation_verifier_required: boolean
    rollback_required: boolean
    redaction_required: boolean
    result_capture_write_approved: boolean
    learning_write_approved: boolean
    playbook_trust_write_approved: boolean
    reviewer_queue_write_approved: boolean
    gateway_queue_write_approved: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    writer_apply_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    post_write_verifier_pass_count: number
    writer_apply_count: number
    implementation_applied_count: number
    rollback_plan_verified_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  writer_implementation_reviews: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    target_writer: string
    target_implementation_gate: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    required_before_write: string
    blocked_write_action: string
    dual_approval_required: true
    idempotency_key_required: true
    post_implementation_verifier_required: true
    runtime_write_enabled: false
    evidence_hash: string
  }>
  implementation_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    required_evidence: string
    blocked_runtime_action: string
    runtime_write_allowed: false
  }>
  post_implementation_verifier_plan: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifies: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  blocked_runtime_changes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    implementation_review_count: number
    implementation_gate_count: number
    post_implementation_verifier_plan_count: number
    blocked_runtime_change_count: number
    operator_action_count: number
    approval_required_review_count: number
    blocked_review_count: number
    approval_required_gate_count: number
    blocked_gate_count: number
    approval_required_verifier_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    post_write_verifier_pass_count: number
    writer_apply_count: number
    implementation_applied_count: number
    rollback_plan_verified_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureWriterDryRunFixtureSnapshot {
  schema_version: 'ai_agent_result_capture_writer_dry_run_fixture_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-123'
    next_task_id: 'P2-124'
    read_only_mode: true
    runtime_authority: 'result_capture_writer_dry_run_fixture_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_result_capture_writer_implementation_review: {
    schema_version: string
    writer_implementation_review_count: number
    implementation_gate_count: number
    post_implementation_verifier_plan_count: number
    blocked_runtime_change_count: number
    operator_action_count: number
    writer_apply_count: number
    implementation_applied_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  dry_run_truth: {
    p2_122_implementation_review_loaded: boolean
    result_capture_writer_dry_run_fixture_ready: boolean
    receipt_preview_ready: boolean
    idempotency_replay_ready: boolean
    rollback_rehearsal_ready: boolean
    redaction_preview_ready: boolean
    fixture_only_mode: boolean
    owner_approval_required: boolean
    dual_approval_required: boolean
    dry_run_hash_required: boolean
    idempotency_key_required: boolean
    post_dry_run_verifier_required: boolean
    rollback_required: boolean
    writer_apply_enabled: boolean
    dry_run_execution_enabled: boolean
    receipt_write_enabled: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    writer_apply_count: number
    dry_run_execution_count: number
    receipt_write_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  writer_dry_run_fixtures: Array<{
    fixture_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    target_writer: string
    target_dry_run: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    input_fixture: string
    expected_receipt_preview: string
    idempotency_key: string
    blocked_live_action: string
    fixture_only: true
    runtime_write_enabled: false
    evidence_hash: string
  }>
  receipt_previews: Array<{
    receipt_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    preview_payload: string
    redaction_policy: string
    failure_if_missing: string
    live_receipt_enabled: false
  }>
  idempotency_replay_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    expected_outcome: string
    failure_if_missing: string
    live_execution_enabled: false
    evidence_hash: string
  }>
  rollback_rehearsals: Array<{
    rehearsal_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    rollback_preview: string
    blocked_live_action: string
    live_execution_enabled: false
  }>
  blocked_runtime_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    writer_dry_run_fixture_count: number
    receipt_preview_count: number
    idempotency_replay_check_count: number
    rollback_rehearsal_count: number
    blocked_runtime_write_count: number
    operator_action_count: number
    approval_required_fixture_count: number
    blocked_fixture_count: number
    approval_required_receipt_count: number
    blocked_receipt_count: number
    approval_required_replay_count: number
    blocked_replay_count: number
    approval_required_rollback_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    writer_apply_count: number
    dry_run_execution_count: number
    receipt_write_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureWriterDryRunReadbackSnapshot {
  schema_version: 'ai_agent_result_capture_writer_dry_run_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-124'
    next_task_id: 'P2-125'
    read_only_mode: true
    runtime_authority: 'result_capture_writer_dry_run_readback_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_result_capture_writer_dry_run_fixture: {
    schema_version: string
    writer_dry_run_fixture_count: number
    receipt_preview_count: number
    idempotency_replay_check_count: number
    rollback_rehearsal_count: number
    blocked_runtime_write_count: number
    operator_action_count: number
    writer_apply_count: number
    dry_run_execution_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  readback_truth: {
    p2_123_fixture_loaded: boolean
    dry_run_readback_ready: boolean
    receipt_verifier_ready: boolean
    promotion_readiness_ready: boolean
    fixture_only_mode: boolean
    owner_approval_required: boolean
    dual_approval_required: boolean
    dry_run_hash_required: boolean
    receipt_verifier_required: boolean
    promotion_owner_required: boolean
    rollback_owner_required: boolean
    writer_apply_enabled: boolean
    dry_run_execution_enabled: boolean
    receipt_write_enabled: boolean
    promotion_apply_enabled: boolean
    canonical_runtime_target_read_enabled: boolean
    live_query_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    receipt_verifier_pass_count: number
    writer_apply_count: number
    dry_run_execution_count: number
    receipt_write_count: number
    promotion_apply_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  dry_run_readback_cards: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_fixture: string
    receipt_preview: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    readback_only: true
    runtime_write_enabled: false
    dry_run_execution_enabled: false
    promotion_candidate: string
    operator_note: string
    evidence_hash: string
  }>
  receipt_verifier_checks: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready' | 'approval_required' | 'blocked_by_policy'
    verifier_mode: 'no_write_receipt_verifier'
    required_before_promotion: true
    live_receipt_enabled: false
    failure_if_missing: string
  }>
  promotion_readiness_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    required_evidence: string
    promotion_allowed: false
  }>
  blocked_promotion_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    dry_run_readback_card_count: number
    receipt_verifier_check_count: number
    promotion_readiness_gate_count: number
    blocked_promotion_write_count: number
    operator_action_count: number
    approval_required_readback_count: number
    blocked_readback_count: number
    approval_required_verifier_count: number
    blocked_verifier_count: number
    approval_required_gate_count: number
    blocked_gate_count: number
    critical_blocker_count: number
    owner_approval_received_count: number
    dual_approval_received_count: number
    dry_run_hash_verified_count: number
    receipt_verifier_pass_count: number
    writer_apply_count: number
    dry_run_execution_count: number
    receipt_write_count: number
    promotion_apply_count: number
    canonical_runtime_target_read_count: number
    live_query_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureOwnerPromotionReviewSnapshot {
  schema_version: 'ai_agent_result_capture_owner_promotion_review_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-125'
    next_task_id: 'P2-126'
    read_only_mode: true
    runtime_authority: 'result_capture_owner_promotion_review_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_result_capture_writer_dry_run_readback: {
    schema_version: string
    dry_run_readback_card_count: number
    receipt_verifier_check_count: number
    promotion_readiness_gate_count: number
    blocked_promotion_write_count: number
    operator_action_count: number
    writer_apply_count: number
    dry_run_execution_count: number
    receipt_write_count: number
    promotion_apply_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  owner_promotion_truth: {
    p2_124_readback_loaded: boolean
    owner_promotion_review_ready: boolean
    execution_gate_ready: boolean
    rollback_owner_review_ready: boolean
    dual_approval_required: boolean
    post_write_verifier_required: boolean
    idempotency_key_required: boolean
    redaction_review_required: boolean
    owner_promotion_approved: boolean
    execution_apply_enabled: boolean
    writer_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_promotion_approved_count: number
    execution_gate_pass_count: number
    rollback_owner_confirmed_count: number
    post_write_verifier_ready_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  owner_promotion_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_readback: string
    required_owner: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    promotion_review_only: true
    execution_apply_enabled: false
    required_decision_fields: string[]
    operator_note: string
    evidence_hash: string
  }>
  execution_gate_checks: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'no_write_execution_gate'
    required_before_execution: true
    execution_enabled: false
    failure_if_missing: string
  }>
  rollback_owner_reviews: Array<{
    rollback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    rollback_owner_required: true
    rollback_confirmed: false
    rollback_note: string
  }>
  blocked_execution_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    owner_promotion_packet_count: number
    execution_gate_check_count: number
    rollback_owner_review_count: number
    blocked_execution_write_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_packet_count: number
    approval_required_gate_count: number
    blocked_gate_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    critical_blocker_count: number
    owner_promotion_approved_count: number
    execution_gate_pass_count: number
    rollback_owner_confirmed_count: number
    post_write_verifier_ready_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureOwnerApprovedExecutionRehearsalSnapshot {
  schema_version: 'ai_agent_result_capture_owner_approved_execution_rehearsal_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-126'
    next_task_id: 'P2-127'
    read_only_mode: true
    runtime_authority: 'result_capture_owner_approved_execution_rehearsal_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_result_capture_owner_promotion_review: {
    schema_version: string
    owner_promotion_packet_count: number
    execution_gate_check_count: number
    rollback_owner_review_count: number
    blocked_execution_write_count: number
    operator_action_count: number
    owner_promotion_approved_count: number
    execution_gate_pass_count: number
    rollback_owner_confirmed_count: number
    post_write_verifier_ready_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  execution_rehearsal_truth: {
    p2_125_owner_promotion_loaded: boolean
    owner_approval_record_required: boolean
    no_write_apply_rehearsal_ready: boolean
    post_write_verifier_rehearsal_ready: boolean
    rollback_drill_ready: boolean
    idempotency_replay_required: boolean
    redaction_review_required: boolean
    execution_rehearsal_only: boolean
    owner_approval_record_received: boolean
    no_write_apply_executed: boolean
    post_write_verifier_passed: boolean
    rollback_drill_confirmed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_approval_record_received_count: number
    no_write_apply_execution_count: number
    post_write_verifier_pass_count: number
    rollback_drill_confirmed_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  execution_rehearsals: Array<{
    rehearsal_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_packet: string
    status: 'ready_for_rehearsal_review' | 'approval_required' | 'blocked_by_policy'
    rehearsal_mode: 'no_write_apply_rehearsal'
    no_write_only: true
    live_apply_enabled: false
    expected_output: string
    evidence_hash: string
  }>
  no_write_apply_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_rehearsal_review' | 'approval_required' | 'blocked_by_policy'
    check_mode: 'no_write_apply_gate'
    required_before_apply: true
    live_apply_enabled: false
    failure_if_missing: string
  }>
  post_write_verifier_rehearsals: Array<{
    verifier_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_rehearsal_review' | 'approval_required' | 'blocked_by_policy'
    verifier_mode: 'fixture_only_no_live_read'
    verifier_ready: false
    live_read_enabled: false
    expected_signal: string
  }>
  rollback_drills: Array<{
    drill_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_rehearsal_review' | 'approval_required' | 'blocked_by_policy'
    rollback_owner_required: true
    rollback_drill_confirmed: false
    drill_note: string
  }>
  blocked_live_applies: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    execution_rehearsal_count: number
    no_write_apply_check_count: number
    post_write_verifier_rehearsal_count: number
    rollback_drill_count: number
    blocked_live_apply_count: number
    operator_action_count: number
    approval_required_rehearsal_count: number
    blocked_rehearsal_count: number
    approval_required_check_count: number
    blocked_check_count: number
    approval_required_verifier_count: number
    blocked_verifier_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    critical_blocker_count: number
    owner_approval_record_received_count: number
    no_write_apply_execution_count: number
    post_write_verifier_pass_count: number
    rollback_drill_confirmed_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureOwnerAcceptanceMaintenanceGateSnapshot {
  schema_version: 'ai_agent_result_capture_owner_acceptance_maintenance_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-127'
    next_task_id: 'P2-128'
    read_only_mode: true
    runtime_authority: 'result_capture_owner_acceptance_maintenance_gate_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_approved_execution_rehearsal: {
    schema_version: string
    execution_rehearsal_count: number
    no_write_apply_check_count: number
    post_write_verifier_rehearsal_count: number
    rollback_drill_count: number
    blocked_live_apply_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_approval_record_received_count: number
    no_write_apply_execution_count: number
    post_write_verifier_pass_count: number
    rollback_drill_confirmed_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  owner_acceptance_truth: {
    p2_126_execution_rehearsal_loaded: boolean
    owner_acceptance_packet_ready: boolean
    maintenance_window_required: boolean
    rollback_owner_required: boolean
    post_apply_verifier_required: boolean
    redaction_review_required: boolean
    live_apply_gate_closed: boolean
    acceptance_gate_only: boolean
    owner_acceptance_received: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_apply_verifier_ready: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_acceptance_received_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_apply_verifier_ready_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  owner_acceptance_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_rehearsal: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    packet_mode: 'owner_acceptance_required'
    owner_acceptance_required: true
    owner_accepted: false
    required_evidence: string
    evidence_hash: string
  }>
  maintenance_windows: Array<{
    window_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    window_mode: 'maintenance_window_draft'
    maintenance_window_required: true
    window_approved: false
    blackout_policy: string
    validation_plan: string
  }>
  rollback_owner_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_scope: string
    failure_if_missing: string
  }>
  post_apply_verifier_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'post_apply_verifier_gate'
    verifier_ready: false
    live_read_enabled: false
    expected_signal: string
  }>
  blocked_live_writes: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    owner_acceptance_packet_count: number
    maintenance_window_count: number
    rollback_owner_check_count: number
    post_apply_verifier_gate_count: number
    blocked_live_write_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_packet_count: number
    approval_required_window_count: number
    blocked_window_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    approval_required_verifier_count: number
    blocked_verifier_count: number
    critical_blocker_count: number
    owner_acceptance_received_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_apply_verifier_ready_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureOwnerAcceptanceReadbackPreflightHoldSnapshot {
  schema_version: 'ai_agent_result_capture_owner_acceptance_readback_preflight_hold_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-128'
    next_task_id: 'P2-129'
    read_only_mode: true
    runtime_authority: 'result_capture_owner_acceptance_readback_preflight_hold_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_acceptance_maintenance_gate: {
    schema_version: string
    owner_acceptance_packet_count: number
    maintenance_window_count: number
    rollback_owner_check_count: number
    post_apply_verifier_gate_count: number
    blocked_live_write_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_acceptance_received_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_apply_verifier_ready_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  readback_truth: {
    p2_127_owner_acceptance_gate_loaded: boolean
    owner_acceptance_readback_ready: boolean
    preflight_hold_required: boolean
    live_apply_hold_active: boolean
    rollback_preflight_required: boolean
    post_apply_verifier_required: boolean
    redaction_review_required: boolean
    readback_only: boolean
    owner_acceptance_received: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_apply_verifier_ready: boolean
    live_apply_preflight_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_acceptance_received_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_apply_verifier_ready_count: number
    live_apply_preflight_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  owner_acceptance_readbacks: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_packet: string
    status: 'ready_for_preflight_review' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'owner_acceptance_status_readback'
    owner_acceptance_received: false
    readback_summary: string
    source_hash: string
  }>
  preflight_hold_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_preflight_review' | 'approval_required' | 'blocked_by_policy'
    preflight_mode: 'live_apply_preflight_hold'
    hold_required: true
    preflight_passed: false
    required_before_release: string
  }>
  live_apply_hold_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_preflight_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'live_apply_hold_gate'
    live_apply_enabled: false
    hold_reason: string
    release_condition: string
  }>
  rollback_preflight_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_preflight_review' | 'approval_required' | 'blocked_by_policy'
    rollback_owner_required: true
    rollback_preflight_passed: false
    rollback_scope: string
    hold_reason: string
  }>
  blocked_apply_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    owner_acceptance_readback_count: number
    preflight_hold_check_count: number
    live_apply_hold_gate_count: number
    rollback_preflight_check_count: number
    blocked_apply_transition_count: number
    operator_action_count: number
    approval_required_readback_count: number
    blocked_readback_count: number
    approval_required_preflight_count: number
    blocked_preflight_count: number
    approval_required_hold_gate_count: number
    blocked_hold_gate_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    critical_blocker_count: number
    owner_acceptance_received_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_apply_verifier_ready_count: number
    live_apply_preflight_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureOwnerApprovedPreflightReleasePackageSnapshot {
  schema_version: 'ai_agent_result_capture_owner_approved_preflight_release_package_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-129'
    next_task_id: 'P2-130'
    read_only_mode: true
    runtime_authority: 'result_capture_owner_approved_preflight_release_package_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_acceptance_readback_preflight_hold: {
    schema_version: string
    owner_acceptance_readback_count: number
    preflight_hold_check_count: number
    live_apply_hold_gate_count: number
    rollback_preflight_check_count: number
    blocked_apply_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_acceptance_received_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_apply_verifier_ready_count: number
    live_apply_preflight_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  release_truth: {
    p2_128_preflight_hold_loaded: boolean
    owner_approved_release_package_ready: boolean
    owner_release_review_required: boolean
    live_apply_release_hold_active: boolean
    rollback_release_required: boolean
    post_release_verifier_required: boolean
    redaction_review_required: boolean
    release_package_only: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  owner_approved_release_packages: Array<{
    package_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_readback: string
    status: 'ready_for_release_review' | 'approval_required' | 'blocked_by_policy'
    package_mode: 'owner_approved_preflight_release_package'
    owner_release_approved: false
    release_summary: string
    evidence_hash: string
  }>
  release_preflight_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_release_review' | 'approval_required' | 'blocked_by_policy'
    preflight_mode: 'release_preflight_check'
    release_hold_required: true
    release_preflight_passed: false
    required_before_live_apply: string
  }>
  live_apply_release_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_release_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'live_apply_release_gate'
    live_apply_release_enabled: false
    release_reason: string
    release_condition: string
  }>
  rollback_release_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_release_review' | 'approval_required' | 'blocked_by_policy'
    rollback_owner_required: true
    rollback_release_passed: false
    rollback_scope: string
    hold_reason: string
  }>
  blocked_release_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    owner_approved_release_package_count: number
    release_preflight_check_count: number
    live_apply_release_gate_count: number
    rollback_release_check_count: number
    blocked_release_transition_count: number
    operator_action_count: number
    approval_required_package_count: number
    blocked_package_count: number
    approval_required_preflight_count: number
    blocked_preflight_count: number
    approval_required_release_gate_count: number
    blocked_release_gate_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    critical_blocker_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureOwnerApprovedReleaseReadinessReadbackSnapshot {
  schema_version: 'ai_agent_result_capture_owner_approved_release_readiness_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-130'
    next_task_id: 'P2-131'
    read_only_mode: true
    runtime_authority: 'result_capture_owner_approved_release_readiness_readback_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_approved_preflight_release_package: {
    schema_version: string
    owner_approved_release_package_count: number
    release_preflight_check_count: number
    live_apply_release_gate_count: number
    rollback_release_check_count: number
    blocked_release_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  release_readiness_truth: {
    p2_129_release_package_loaded: boolean
    release_readiness_readback_ready: boolean
    owner_release_review_required: boolean
    maintenance_window_review_required: boolean
    live_apply_readiness_hold_active: boolean
    rollback_readiness_required: boolean
    post_release_verifier_required: boolean
    redaction_review_required: boolean
    release_readiness_readback_only: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    release_readiness_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_readiness_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  release_readiness_readbacks: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_release_package: string
    status: 'ready_for_owner_readback' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'owner_approved_release_readiness_readback'
    release_readiness_passed: false
    owner_release_approved: false
    readiness_summary: string
    evidence_hash: string
  }>
  owner_release_readiness_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_readback' | 'approval_required' | 'blocked_by_policy'
    check_mode: 'owner_release_readiness_check'
    owner_release_review_required: true
    owner_release_approved: false
    required_before_live_apply: string
  }>
  live_apply_readiness_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_readback' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'live_apply_readiness_gate'
    release_readiness_passed: false
    live_apply_release_enabled: false
    hold_reason: string
    release_condition: string
  }>
  rollback_readiness_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_readback' | 'approval_required' | 'blocked_by_policy'
    rollback_owner_required: true
    rollback_readiness_passed: false
    rollback_scope: string
    hold_reason: string
  }>
  blocked_readiness_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    release_readiness_readback_count: number
    owner_release_readiness_check_count: number
    live_apply_readiness_gate_count: number
    rollback_readiness_check_count: number
    blocked_readiness_transition_count: number
    operator_action_count: number
    approval_required_readback_count: number
    blocked_readback_count: number
    approval_required_owner_release_check_count: number
    blocked_owner_release_check_count: number
    approval_required_readiness_gate_count: number
    blocked_readiness_gate_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    critical_blocker_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_readiness_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureOwnerReleaseApprovalGateSnapshot {
  schema_version: 'ai_agent_result_capture_owner_release_approval_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-131'
    next_task_id: 'P2-132'
    read_only_mode: true
    runtime_authority: 'result_capture_owner_release_approval_gate_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_approved_release_readiness_readback: {
    schema_version: string
    release_readiness_readback_count: number
    owner_release_readiness_check_count: number
    live_apply_readiness_gate_count: number
    rollback_readiness_check_count: number
    blocked_readiness_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_readiness_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  owner_release_approval_truth: {
    p2_130_readiness_loaded: boolean
    owner_release_approval_gate_ready: boolean
    owner_release_review_required: boolean
    maintenance_window_review_required: boolean
    live_apply_approval_hold_active: boolean
    rollback_owner_review_required: boolean
    post_release_verifier_required: boolean
    redaction_review_required: boolean
    owner_release_approval_gate_only: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    release_approval_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_approval_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  owner_release_approval_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_readiness: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    approval_mode: 'owner_release_approval_gate'
    owner_release_approved: false
    release_approval_passed: false
    approval_summary: string
    evidence_hash: string
  }>
  maintenance_window_approval_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'maintenance_window_approval_gate'
    maintenance_window_review_required: true
    maintenance_window_approved: false
    required_before_live_apply: string
  }>
  live_apply_release_approval_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'live_apply_release_approval_gate'
    release_approval_passed: false
    live_apply_release_enabled: false
    hold_reason: string
    release_condition: string
  }>
  rollback_owner_approval_checks: Array<{
    check_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_scope: string
    hold_reason: string
  }>
  blocked_approval_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    owner_release_approval_packet_count: number
    maintenance_window_approval_gate_count: number
    live_apply_release_approval_gate_count: number
    rollback_owner_approval_check_count: number
    blocked_approval_transition_count: number
    operator_action_count: number
    approval_required_packet_count: number
    blocked_packet_count: number
    approval_required_maintenance_window_count: number
    blocked_maintenance_window_count: number
    approval_required_live_apply_count: number
    blocked_live_apply_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    critical_blocker_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_approval_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCapturePostReleaseVerifierRollbackGateSnapshot {
  schema_version: 'ai_agent_result_capture_post_release_verifier_rollback_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-132'
    next_task_id: 'P2-133'
    read_only_mode: true
    runtime_authority: 'result_capture_post_release_verifier_rollback_gate_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_release_approval_gate: {
    schema_version: string
    owner_release_approval_packet_count: number
    maintenance_window_approval_gate_count: number
    live_apply_release_approval_gate_count: number
    rollback_owner_approval_check_count: number
    blocked_approval_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_approval_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  post_release_verifier_truth: {
    p2_131_approval_gate_loaded: boolean
    post_release_verifier_gate_ready: boolean
    rollback_release_gate_ready: boolean
    release_verification_hold_active: boolean
    live_apply_post_release_hold_active: boolean
    owner_release_review_still_required: boolean
    maintenance_window_review_still_required: boolean
    rollback_owner_review_required: boolean
    redaction_review_required: boolean
    post_release_verifier_gate_only: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    release_verification_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_verification_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  post_release_verifier_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_approval_gate: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'post_release_verifier_gate'
    post_release_verifier_ready: false
    release_verification_passed: false
    verifier_summary: string
    evidence_hash: string
  }>
  rollback_release_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'rollback_release_gate'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_release_enabled: false
    rollback_scope: string
  }>
  release_verification_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'release_verification_hold'
    owner_release_approved: false
    maintenance_window_approved: false
    release_verification_passed: false
    hold_reason: string
  }>
  live_apply_post_release_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    gate_mode: 'live_apply_post_release_gate'
    post_release_verifier_ready: false
    live_apply_release_enabled: false
    release_condition: string
  }>
  blocked_post_release_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    post_release_verifier_gate_count: number
    rollback_release_gate_count: number
    release_verification_hold_count: number
    live_apply_post_release_gate_count: number
    blocked_post_release_transition_count: number
    operator_action_count: number
    approval_required_verifier_count: number
    blocked_verifier_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    approval_required_verification_hold_count: number
    blocked_verification_hold_count: number
    approval_required_live_apply_count: number
    blocked_live_apply_count: number
    critical_blocker_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_verification_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureFinalReleaseCandidateReadbackSnapshot {
  schema_version: 'ai_agent_result_capture_final_release_candidate_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-133'
    next_task_id: 'P2-134'
    read_only_mode: true
    runtime_authority: 'result_capture_final_release_candidate_readback_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_post_release_verifier_rollback_gate: {
    schema_version: string
    post_release_verifier_gate_count: number
    rollback_release_gate_count: number
    release_verification_hold_count: number
    live_apply_post_release_gate_count: number
    blocked_post_release_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    release_verification_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  final_release_candidate_truth: {
    p2_132_post_release_gate_loaded: boolean
    final_release_candidate_readback_ready: boolean
    rollback_candidate_readback_ready: boolean
    candidate_acceptance_hold_active: boolean
    live_apply_candidate_hold_active: boolean
    owner_release_review_still_required: boolean
    maintenance_window_review_still_required: boolean
    rollback_owner_review_required: boolean
    redaction_review_required: boolean
    final_release_candidate_readback_only: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    final_release_candidate_approved: boolean
    final_release_candidate_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  final_release_candidate_readbacks: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_post_release_gate: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'final_release_candidate_readback'
    final_release_candidate_approved: false
    final_release_candidate_passed: false
    candidate_summary: string
    evidence_hash: string
  }>
  rollback_candidate_readbacks: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'rollback_candidate_readback'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_release_enabled: false
    rollback_summary: string
  }>
  candidate_acceptance_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'candidate_acceptance_hold'
    owner_release_approved: false
    maintenance_window_approved: false
    final_release_candidate_passed: false
    hold_reason: string
  }>
  live_apply_candidate_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'live_apply_candidate_hold'
    final_release_candidate_approved: false
    live_apply_release_enabled: false
    release_condition: string
  }>
  blocked_final_candidate_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    final_release_candidate_readback_count: number
    rollback_candidate_readback_count: number
    candidate_acceptance_hold_count: number
    live_apply_candidate_hold_count: number
    blocked_final_candidate_transition_count: number
    operator_action_count: number
    approval_required_candidate_count: number
    blocked_candidate_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    approval_required_acceptance_hold_count: number
    blocked_acceptance_hold_count: number
    approval_required_live_apply_count: number
    blocked_live_apply_count: number
    critical_blocker_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureReleaseAuthorizationHoldSnapshot {
  schema_version: 'ai_agent_result_capture_release_authorization_hold_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-134'
    next_task_id: 'P2-135'
    read_only_mode: true
    runtime_authority: 'result_capture_release_authorization_hold_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_final_release_candidate_readback: {
    schema_version: string
    final_release_candidate_readback_count: number
    rollback_candidate_readback_count: number
    candidate_acceptance_hold_count: number
    live_apply_candidate_hold_count: number
    blocked_final_candidate_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  release_authorization_truth: {
    p2_133_final_candidate_loaded: boolean
    release_authorization_hold_ready: boolean
    rollback_authorization_hold_ready: boolean
    release_window_hold_active: boolean
    live_apply_authorization_hold_active: boolean
    owner_authorization_review_still_required: boolean
    maintenance_window_review_still_required: boolean
    rollback_owner_review_required: boolean
    redaction_review_required: boolean
    release_authorization_hold_only: boolean
    owner_release_authorized: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    final_release_candidate_approved: boolean
    final_release_candidate_passed: boolean
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  release_authorization_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_final_candidate: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'release_authorization_hold'
    owner_release_authorized: false
    release_authorization_granted: false
    release_authorization_passed: false
    authorization_summary: string
    evidence_hash: string
  }>
  rollback_authorization_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'rollback_authorization_hold'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_release_enabled: false
    rollback_summary: string
  }>
  release_window_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'release_window_hold'
    owner_release_authorized: false
    maintenance_window_approved: false
    final_release_candidate_passed: false
    hold_reason: string
  }>
  live_apply_authorization_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'live_apply_authorization_hold'
    release_authorization_granted: false
    live_apply_release_enabled: false
    release_condition: string
  }>
  blocked_authorization_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'high' | 'critical'
    status: 'approval_required' | 'blocked_by_policy'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    release_authorization_hold_count: number
    rollback_authorization_hold_count: number
    release_window_hold_count: number
    live_apply_authorization_hold_count: number
    blocked_authorization_transition_count: number
    operator_action_count: number
    approval_required_authorization_count: number
    blocked_authorization_count: number
    approval_required_rollback_count: number
    blocked_rollback_count: number
    approval_required_release_window_count: number
    blocked_release_window_count: number
    approval_required_live_apply_count: number
    blocked_live_apply_count: number
    critical_blocker_count: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureReleaseAuthorizationReadbackGateSnapshot {
  schema_version: 'ai_agent_result_capture_release_authorization_readback_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-135'
    next_task_id: 'P2-136'
    read_only_mode: true
    runtime_authority: 'result_capture_release_authorization_readback_gate_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_release_authorization_hold: {
    schema_version: string
    release_authorization_hold_count: number
    rollback_authorization_hold_count: number
    release_window_hold_count: number
    live_apply_authorization_hold_count: number
    blocked_authorization_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  release_authorization_readback_truth: {
    p2_134_release_authorization_hold_loaded: boolean
    release_authorization_readback_ready: boolean
    rollback_release_readback_ready: boolean
    maintenance_window_readback_hold_active: boolean
    live_apply_release_readback_hold_active: boolean
    owner_authorization_review_still_required: boolean
    release_verifier_review_still_required: boolean
    rollback_owner_review_required: boolean
    redaction_review_required: boolean
    release_authorization_readback_only: boolean
    owner_release_authorized: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    final_release_candidate_approved: boolean
    final_release_candidate_passed: boolean
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  release_authorization_readbacks: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_authorization_hold: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'release_authorization_readback_gate'
    owner_release_authorized: false
    release_authorization_granted: false
    release_authorization_passed: false
    readback_summary: string
    evidence_hash: string
  }>
  rollback_release_readbacks: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'rollback_release_readback_gate'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_release_passed: false
    rollback_release_enabled: false
    readback_summary: string
  }>
  maintenance_window_readback_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'maintenance_window_readback_hold'
    owner_release_authorized: false
    maintenance_window_approved: false
    final_release_candidate_passed: false
    hold_reason: string
  }>
  live_apply_release_readback_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'live_apply_release_readback_hold'
    release_authorization_granted: false
    release_authorization_passed: false
    live_apply_release_passed: false
    live_apply_release_enabled: false
    release_condition: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    release_authorization_readback_count: number
    rollback_release_readback_count: number
    maintenance_window_readback_hold_count: number
    live_apply_release_readback_hold_count: number
    blocked_release_readback_transition_count: number
    operator_action_count: number
    approval_required_authorization_readback_count: number
    blocked_authorization_readback_count: number
    approval_required_rollback_readback_count: number
    blocked_rollback_readback_count: number
    approval_required_maintenance_window_count: number
    blocked_maintenance_window_count: number
    approval_required_live_apply_readback_count: number
    blocked_live_apply_readback_count: number
    critical_blocker_count: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureReleaseVerifierPreflightGateSnapshot {
  schema_version: 'ai_agent_result_capture_release_verifier_preflight_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-136'
    next_task_id: 'P2-137'
    read_only_mode: true
    runtime_authority: 'result_capture_release_verifier_preflight_gate_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_release_authorization_readback_gate: {
    schema_version: string
    release_authorization_readback_count: number
    rollback_release_readback_count: number
    maintenance_window_readback_hold_count: number
    live_apply_release_readback_hold_count: number
    blocked_release_readback_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    readiness_note: string
  }
  release_verifier_preflight_truth: {
    p2_135_release_authorization_readback_gate_loaded: boolean
    release_verifier_preflight_ready: boolean
    rollback_verifier_preflight_ready: boolean
    maintenance_window_verifier_hold_active: boolean
    live_apply_verifier_hold_active: boolean
    owner_authorization_review_still_required: boolean
    release_verifier_review_still_required: boolean
    rollback_owner_review_required: boolean
    redaction_review_required: boolean
    release_verifier_preflight_only: boolean
    owner_release_authorized: boolean
    owner_release_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    final_release_candidate_approved: boolean
    final_release_candidate_passed: boolean
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  release_verifier_preflight_gates: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_authorization_hold: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'release_verifier_preflight_gate'
    owner_release_authorized: false
    release_authorization_granted: false
    release_authorization_passed: false
    readback_summary: string
    evidence_hash: string
  }>
  rollback_verifier_preflight_gates: Array<{
    readback_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    readback_mode: 'rollback_verifier_preflight_gate'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_release_passed: false
    rollback_release_enabled: false
    readback_summary: string
  }>
  maintenance_window_verifier_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'maintenance_window_verifier_hold'
    owner_release_authorized: false
    maintenance_window_approved: false
    final_release_candidate_passed: false
    hold_reason: string
  }>
  live_apply_verifier_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'live_apply_verifier_hold'
    release_authorization_granted: false
    release_authorization_passed: false
    live_apply_release_passed: false
    live_apply_release_enabled: false
    release_condition: string
  }>
  blocked_verifier_preflight_transitions: Array<{
    blocker_id: string
    display_name: string
    severity: 'critical' | 'high' | 'medium' | 'low'
    status: 'blocked_by_policy' | 'approval_required'
    blocked_action: string
    blocked_until: string
    evidence_hash: string
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    release_verifier_preflight_count: number
    rollback_verifier_preflight_count: number
    maintenance_window_verifier_hold_count: number
    live_apply_verifier_hold_count: number
    blocked_verifier_preflight_transition_count: number
    operator_action_count: number
    approval_required_authorization_readback_count: number
    blocked_authorization_readback_count: number
    approval_required_rollback_readback_count: number
    blocked_rollback_readback_count: number
    approval_required_maintenance_window_count: number
    blocked_maintenance_window_count: number
    approval_required_live_apply_readback_count: number
    blocked_live_apply_readback_count: number
    critical_blocker_count: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureReleaseVerifierOwnerReviewPacketSnapshot {
  schema_version: 'ai_agent_result_capture_release_verifier_owner_review_packet_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-137'
    next_task_id: 'P2-138'
    read_only_mode: true
    runtime_authority: 'result_capture_release_verifier_owner_review_packet_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_release_verifier_preflight_gate: {
    schema_version: string
    release_verifier_preflight_count: number
    rollback_verifier_preflight_count: number
    maintenance_window_verifier_hold_count: number
    live_apply_verifier_hold_count: number
    blocked_verifier_preflight_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    owner_review_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    readiness_note: string
  }
  release_verifier_owner_review_truth: {
    p2_136_release_verifier_preflight_gate_loaded: boolean
    owner_review_packet_ready: boolean
    release_verifier_review_required: boolean
    rollback_owner_review_required: boolean
    maintenance_window_review_required: boolean
    live_apply_review_required: boolean
    redaction_review_required: boolean
    owner_review_packet_only: boolean
    owner_release_authorized: boolean
    owner_release_approved: boolean
    owner_review_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    final_release_candidate_approved: boolean
    final_release_candidate_passed: boolean
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_authorized_count: number
    owner_release_approved_count: number
    owner_review_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
    truth_note: string
  }
  owner_review_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    source_readback_id: string
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    packet_mode: 'release_verifier_owner_review_packet'
    owner_release_authorized: false
    owner_review_approved: false
    release_authorization_granted: false
    release_authorization_passed: false
    review_summary: string
    evidence_hash: string
  }>
  verifier_review_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    packet_mode: 'release_verifier_review_packet'
    post_release_verifier_required: true
    post_release_verifier_ready: false
    release_authorization_passed: false
    verifier_summary: string
  }>
  rollback_owner_review_packets: Array<{
    packet_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    packet_mode: 'rollback_owner_review_packet'
    rollback_owner_required: true
    rollback_owner_confirmed: false
    rollback_release_passed: false
    rollback_summary: string
  }>
  maintenance_window_review_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'maintenance_window_owner_review_hold'
    owner_release_authorized: false
    maintenance_window_required: true
    maintenance_window_approved: false
    hold_reason: string
  }>
  live_apply_owner_review_holds: Array<{
    hold_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_owner_review' | 'approval_required' | 'blocked_by_policy'
    hold_mode: 'live_apply_owner_review_hold'
    release_authorization_granted: false
    release_authorization_passed: false
    live_apply_release_passed: false
    live_apply_release_enabled: false
    release_condition: string
  }>
  blocked_owner_review_transitions: Array<{
    transition_id: string
    status: 'blocked_by_policy' | 'approval_required'
    reason: string
    runtime_write_allowed: false
  }>
  operator_actions: Array<{
    action_id: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: 'ready_for_operator_review' | 'approval_required'
    operator_instruction: string
    runtime_write_allowed: false
  }>
  display_redaction_contract: {
    redaction_required: true
    raw_prompt_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    raw_runtime_payload_display_allowed: false
    internal_collaboration_content_display_allowed: false
    frontend_display_policy: string
  }
  rollups: {
    owner_review_packet_count: number
    verifier_review_packet_count: number
    rollback_owner_review_packet_count: number
    maintenance_window_review_hold_count: number
    live_apply_owner_review_hold_count: number
    blocked_owner_review_transition_count: number
    operator_action_count: number
    approval_required_owner_review_count: number
    blocked_owner_review_count: number
    approval_required_verifier_review_count: number
    blocked_verifier_review_count: number
    approval_required_rollback_owner_review_count: number
    blocked_rollback_owner_review_count: number
    approval_required_maintenance_window_count: number
    blocked_maintenance_window_count: number
    approval_required_live_apply_review_count: number
    blocked_live_apply_review_count: number
    critical_blocker_count: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    owner_review_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

export interface AiAgentResultCaptureReleaseDecisionHoldSnapshot {
  schema_version: 'ai_agent_result_capture_release_decision_hold_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-138'
    next_task_id: 'P2-139'
    read_only_mode: true
    runtime_authority: 'result_capture_release_decision_hold_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_release_verifier_owner_review_packet: {
    schema_version: string
    owner_review_packet_count: number
    verifier_review_packet_count: number
    rollback_owner_review_packet_count: number
    maintenance_window_review_hold_count: number
    live_apply_owner_review_hold_count: number
    blocked_owner_review_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    owner_release_authorized_count: number
    owner_review_approved_count: number
    owner_decision_approved_count: number
    release_decision_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    readiness_note: string
  }
  release_decision_hold_truth: {
    p2_137_owner_review_packet_loaded: boolean
    release_decision_hold_ready: boolean
    owner_decision_required: boolean
    verifier_decision_required: boolean
    rollback_decision_required: boolean
    maintenance_window_decision_required: boolean
    live_apply_decision_required: boolean
    release_decision_hold_only: boolean
    owner_release_authorized: boolean
    owner_review_approved: boolean
    owner_decision_approved: boolean
    verifier_decision_approved: boolean
    release_decision_passed: boolean
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    production_write_enabled: boolean
    truth_note: string
  }
  release_decision_holds: {
    hold_id: string
    display_name: string
    owner_agent: string
    source_packet_id: string
    status: string
    hold_mode: string
    decision_required: boolean
    decision_approved: boolean
    release_authorization_granted: boolean
    release_decision_passed: boolean
    decision_summary: string
    evidence_hash: string
  }[]
  owner_decision_holds: {
    hold_id: string
    display_name: string
    owner_agent: string
    status: string
    hold_mode: string
    owner_release_authorized: boolean
    owner_decision_approved: boolean
    decision_summary: string
  }[]
  verifier_decision_holds: {
    hold_id: string
    display_name: string
    owner_agent: string
    status: string
    hold_mode: string
    post_release_verifier_required: boolean
    verifier_decision_approved: boolean
    release_authorization_passed: boolean
    verifier_summary: string
  }[]
  rollback_decision_holds: {
    hold_id: string
    display_name: string
    owner_agent: string
    status: string
    hold_mode: string
    rollback_owner_required: boolean
    rollback_owner_confirmed: boolean
    rollback_release_passed: boolean
    rollback_summary: string
  }[]
  maintenance_window_decision_holds: {
    hold_id: string
    display_name: string
    owner_agent: string
    status: string
    hold_mode: string
    maintenance_window_required: boolean
    maintenance_window_approved: boolean
    live_apply_release_passed: boolean
    maintenance_summary: string
  }[]
  live_apply_decision_holds: {
    hold_id: string
    display_name: string
    owner_agent: string
    status: string
    hold_mode: string
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    live_apply_release_passed: boolean
    live_apply_release_enabled: boolean
    release_condition: string
  }[]
  blocked_decision_transitions: {
    transition_id: string
    status: string
    reason: string
    runtime_write_allowed: boolean
  }[]
  operator_actions: {
    action_id: string
    owner_agent: string
    status: string
    operator_instruction: string
    runtime_write_allowed: boolean
  }[]
  display_redaction_contract: {
    redaction_required: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    internal_collaboration_content_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: {
    release_decision_hold_count: number
    owner_decision_hold_count: number
    verifier_decision_hold_count: number
    rollback_decision_hold_count: number
    maintenance_window_decision_hold_count: number
    live_apply_decision_hold_count: number
    blocked_decision_transition_count: number
    operator_action_count: number
    approval_required_release_decision_count: number
    blocked_release_decision_count: number
    approval_required_owner_decision_count: number
    blocked_owner_decision_count: number
    approval_required_verifier_decision_count: number
    blocked_verifier_decision_count: number
    approval_required_rollback_decision_count: number
    blocked_rollback_decision_count: number
    approval_required_maintenance_window_decision_count: number
    blocked_maintenance_window_decision_count: number
    approval_required_live_apply_decision_count: number
    blocked_live_apply_decision_count: number
    critical_blocker_count: number
    owner_release_authorized_count: number
    owner_review_approved_count: number
    owner_decision_approved_count: number
    verifier_decision_approved_count: number
    release_decision_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
  }
}

interface AiAgentReleaseDecisionReadbackItem {
  readback_id: string
  display_name: string
  owner_agent: string
  source_hold_id: string
  readback_status: string
  readback_mode: string
  readback_summary: string
  release_decision_passed: boolean
  release_authorization_granted: boolean
  runtime_write_allowed: boolean
  telegram_send_allowed: boolean
  evidence_hash?: string
}

export interface AiAgentResultCaptureReleaseDecisionReadbackSnapshot {
  schema_version: 'ai_agent_result_capture_release_decision_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-139'
    next_task_id: 'P2-140'
    read_only_mode: true
    runtime_authority: 'result_capture_release_decision_readback_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_release_decision_hold: {
    schema_version: string
    release_decision_hold_count: number
    owner_decision_hold_count: number
    verifier_decision_hold_count: number
    rollback_decision_hold_count: number
    maintenance_window_decision_hold_count: number
    live_apply_decision_hold_count: number
    blocked_decision_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    readiness_note: string
    owner_release_authorized_count: number
    owner_release_approved_count: number
    owner_review_approved_count: number
    owner_decision_approved_count: number
    verifier_decision_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_decision_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
  release_decision_readback_truth: {
    p2_138_release_decision_hold_loaded: boolean
    release_decision_readback_ready: boolean
    owner_decision_still_required: boolean
    verifier_decision_still_required: boolean
    rollback_decision_still_required: boolean
    maintenance_window_decision_still_required: boolean
    live_apply_decision_still_required: boolean
    redaction_review_still_required: boolean
    release_decision_readback_only: boolean
    truth_note: string
    owner_release_authorized: boolean
    owner_release_approved: boolean
    owner_review_approved: boolean
    owner_decision_approved: boolean
    verifier_decision_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    final_release_candidate_approved: boolean
    final_release_candidate_passed: boolean
    release_decision_passed: boolean
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_release_authorized_count: number
    owner_release_approved_count: number
    owner_review_approved_count: number
    owner_decision_approved_count: number
    verifier_decision_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_decision_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
  release_decision_readbacks: AiAgentReleaseDecisionReadbackItem[]
  owner_decision_readbacks: AiAgentReleaseDecisionReadbackItem[]
  verifier_decision_readbacks: AiAgentReleaseDecisionReadbackItem[]
  rollback_decision_readbacks: AiAgentReleaseDecisionReadbackItem[]
  maintenance_window_decision_readbacks: AiAgentReleaseDecisionReadbackItem[]
  live_apply_decision_readbacks: AiAgentReleaseDecisionReadbackItem[]
  blocked_readback_transitions: {
    transition_id: string
    status: string
    reason: string
    runtime_write_allowed: boolean
  }[]
  operator_actions: {
    action_id: string
    owner_agent: string
    status: string
    operator_instruction: string
    runtime_write_allowed: boolean
  }[]
  display_redaction_contract: {
    redaction_required: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    internal_collaboration_content_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: {
    release_decision_readback_count: number
    owner_decision_readback_count: number
    verifier_decision_readback_count: number
    rollback_decision_readback_count: number
    maintenance_window_decision_readback_count: number
    live_apply_decision_readback_count: number
    blocked_readback_transition_count: number
    operator_action_count: number
    approval_required_release_decision_count: number
    blocked_release_decision_count: number
    approval_required_owner_decision_count: number
    blocked_owner_decision_count: number
    approval_required_verifier_decision_count: number
    blocked_verifier_decision_count: number
    approval_required_rollback_decision_count: number
    blocked_rollback_decision_count: number
    approval_required_maintenance_window_decision_count: number
    blocked_maintenance_window_decision_count: number
    approval_required_live_apply_decision_count: number
    blocked_live_apply_decision_count: number
    critical_blocker_count: number
    owner_release_authorized_count: number
    owner_release_approved_count: number
    owner_review_approved_count: number
    owner_decision_approved_count: number
    verifier_decision_approved_count: number
    maintenance_window_approved_count: number
    rollback_owner_confirmed_count: number
    post_release_verifier_ready_count: number
    final_release_candidate_approved_count: number
    final_release_candidate_pass_count: number
    release_decision_pass_count: number
    release_authorization_granted_count: number
    release_authorization_pass_count: number
    rollback_release_pass_count: number
    live_apply_release_pass_count: number
    writer_apply_count: number
    execution_apply_count: number
    receipt_write_count: number
    reviewer_queue_write_count: number
    gateway_queue_write_count: number
    telegram_send_count: number
    bot_api_call_count: number
    report_receipt_write_count: number
    result_capture_write_count: number
    learning_write_count: number
    playbook_trust_write_count: number
    production_write_count: number
    secret_read_count: number
    destructive_operation_count: number
  }
}

interface AiAgentReleaseDecisionNextHandoffZeroCounts {
  owner_release_authorized_count: number
  owner_release_approved_count: number
  owner_review_approved_count: number
  owner_decision_approved_count: number
  verifier_decision_approved_count: number
  maintenance_window_approved_count: number
  rollback_owner_confirmed_count: number
  post_release_verifier_ready_count: number
  final_release_candidate_approved_count: number
  final_release_candidate_pass_count: number
  release_decision_pass_count: number
  release_authorization_granted_count: number
  release_authorization_pass_count: number
  rollback_release_pass_count: number
  live_apply_release_pass_count: number
  writer_apply_count: number
  execution_apply_count: number
  receipt_write_count: number
  reviewer_queue_write_count: number
  gateway_queue_write_count: number
  telegram_send_count: number
  bot_api_call_count: number
  report_receipt_write_count: number
  result_capture_write_count: number
  learning_write_count: number
  playbook_trust_write_count: number
  production_write_count: number
  secret_read_count: number
  destructive_operation_count: number
}

interface AiAgentReleaseDecisionNextHandoffItem {
  handoff_id: string
  display_name: string
  owner_agent: string
  source_readback_id: string
  source_task_id: string
  current_task_id: string
  target_next_task_id: string
  handoff_status: string
  handoff_mode: string
  handoff_summary: string
  stale_self_loop_contained: boolean
  runtime_write_allowed: boolean
  telegram_send_allowed: boolean
  evidence_hash?: string
}

export interface AiAgentResultCaptureReleaseDecisionNextHandoffSnapshot {
  schema_version: 'ai_agent_result_capture_release_decision_next_handoff_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-140'
    next_task_id: 'P2-141'
    read_only_mode: true
    runtime_authority: 'result_capture_release_decision_next_handoff_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_release_decision_readback: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    schema_version: string
    current_task_id: string
    next_task_id: string
    release_decision_readback_count: number
    owner_decision_readback_count: number
    verifier_decision_readback_count: number
    rollback_decision_readback_count: number
    maintenance_window_decision_readback_count: number
    live_apply_decision_readback_count: number
    blocked_readback_transition_count: number
    operator_action_count: number
    approval_required_total: number
    blocked_total: number
    stale_self_loop_action_count: number
    readiness_note: string
  }
  next_handoff_truth: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    p2_139_release_decision_readback_loaded: boolean
    next_task_id_alignment_checked: boolean
    stale_self_loop_detected: boolean
    stale_self_loop_contained: boolean
    p2_140_next_handoff_only: boolean
    operator_instruction_requires_p2_141: boolean
    owner_decision_still_required: boolean
    verifier_decision_still_required: boolean
    rollback_decision_still_required: boolean
    maintenance_window_decision_still_required: boolean
    live_apply_decision_still_required: boolean
    redaction_review_still_required: boolean
    truth_note: string
    owner_release_authorized: boolean
    release_decision_passed: boolean
    release_authorization_granted: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
  }
  next_gate_handoffs: AiAgentReleaseDecisionNextHandoffItem[]
  stale_operator_action_containments: {
    containment_id: string
    source_action_id: string
    source_task_id: string
    expected_current_task_id: string
    expected_next_task_id: string
    containment_status: string
    containment_summary: string
    runtime_write_allowed: boolean
    telegram_send_allowed: boolean
  }[]
  blocked_handoff_transitions: {
    transition_id: string
    status: string
    reason: string
    runtime_write_allowed: boolean
  }[]
  operator_actions: {
    action_id: string
    owner_agent: string
    status: string
    operator_instruction: string
    runtime_write_allowed: boolean
  }[]
  display_redaction_contract: {
    redaction_required: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    internal_collaboration_content_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    next_gate_handoff_count: number
    stale_operator_action_count: number
    blocked_handoff_transition_count: number
    operator_action_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
  }
}

interface AiAgentReleaseDecisionInputPacket {
  packet_id: string
  display_name: string
  owner_agent: string
  source_handoff_id: string
  current_task_id: string
  target_next_task_id: string
  input_status: string
  required_input_type: string
  input_summary: string
  missing_fields: string[]
  approval_required: boolean
  runtime_write_allowed: boolean
  telegram_send_allowed: boolean
  evidence_hash?: string
}

export interface AiAgentResultCaptureReleaseDecisionInputPrepSnapshot {
  schema_version: 'ai_agent_result_capture_release_decision_input_prep_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-141'
    next_task_id: 'P2-142'
    read_only_mode: true
    runtime_authority: 'result_capture_release_decision_input_prep_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_next_handoff: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    schema_version: string
    current_task_id: string
    next_task_id: string
    next_gate_handoff_count: number
    stale_operator_action_count: number
    blocked_handoff_transition_count: number
    operator_action_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    readiness_note: string
  }
  decision_input_truth: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    p2_140_next_handoff_loaded: boolean
    next_task_id_alignment_checked: boolean
    stale_self_loop_containment_inherited: boolean
    p2_141_input_prep_only: boolean
    owner_input_packet_required: boolean
    verifier_input_packet_required: boolean
    rollback_input_packet_required: boolean
    maintenance_window_input_required: boolean
    live_apply_input_required: boolean
    redaction_review_required: boolean
    truth_note: string
    owner_release_authorized: boolean
    release_decision_passed: boolean
    release_authorization_granted: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
  }
  decision_input_packets: AiAgentReleaseDecisionInputPacket[]
  blocked_input_transitions: {
    transition_id: string
    status: string
    reason: string
    runtime_write_allowed: boolean
  }[]
  operator_actions: {
    action_id: string
    owner_agent: string
    status: string
    operator_instruction: string
    runtime_write_allowed: boolean
  }[]
  display_redaction_contract: {
    redaction_required: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    internal_collaboration_content_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    decision_input_packet_count: number
    owner_input_packet_count: number
    verifier_input_packet_count: number
    rollback_input_packet_count: number
    maintenance_window_input_count: number
    live_apply_input_count: number
    missing_input_field_count: number
    blocked_input_transition_count: number
    operator_action_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    stale_operator_action_count: number
  }
}

interface AiAgentReleaseDecisionOwnerResponseIntakeLane {
  lane_id: string
  display_name: string
  source_packet_id: string
  owner_agent: string
  current_task_id: string
  target_next_task_id: string
  intake_status: string
  required_fields: string[]
  preflight_summary: string
  accepted: boolean
  redacted_payload_ingested: boolean
  runtime_write_allowed: boolean
  telegram_send_allowed: boolean
  evidence_hash?: string
}

export interface AiAgentResultCaptureReleaseDecisionOwnerResponsePreflightSnapshot {
  schema_version: 'ai_agent_result_capture_release_decision_owner_response_preflight_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-143'
    next_task_id: 'P2-144'
    read_only_mode: true
    runtime_authority: 'result_capture_release_decision_owner_response_preflight_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_decision_input_prep: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    schema_version: string
    current_task_id: string
    next_task_id: string
    decision_input_packet_count: number
    missing_input_field_count: number
    blocked_input_transition_count: number
    operator_action_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    readiness_note: string
  }
  owner_response_preflight_truth: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    p2_141_input_prep_loaded: boolean
    p2_142_war_room_baseline_preserved: boolean
    required_owner_fields_declared: boolean
    required_verifier_fields_declared: boolean
    required_rollback_fields_declared: boolean
    required_maintenance_window_fields_declared: boolean
    required_live_apply_fields_declared: boolean
    redaction_contract_loaded: boolean
    preflight_only_mode: boolean
    no_raw_payload_required: boolean
    rejection_policy_active: boolean
    truth_note: string
    owner_response_received: boolean
    owner_response_accepted: boolean
    owner_response_rejected: boolean
    redacted_payload_ingested: boolean
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
    release_authorization_granted: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
  }
  response_intake_lanes: AiAgentReleaseDecisionOwnerResponseIntakeLane[]
  intake_validation_checks: {
    check_id: string
    status: string
    requirement: string
    runtime_write_allowed: boolean
  }[]
  rejection_guards: {
    guard_id: string
    status: string
    reason: string
    runtime_write_allowed: boolean
  }[]
  operator_actions: {
    action_id: string
    owner_agent: string
    status: string
    operator_instruction: string
    runtime_write_allowed: boolean
  }[]
  display_redaction_contract: {
    redaction_required: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    internal_collaboration_content_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    response_intake_lane_count: number
    required_owner_field_count: number
    intake_validation_check_count: number
    rejection_guard_count: number
    operator_action_count: number
    waiting_external_response_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
  }
}

interface AiAgentReleaseDecisionOwnerResponseReadbackLane {
  readback_id: string
  display_name: string
  source_lane_id: string
  owner_agent: string
  current_task_id: string
  target_next_task_id: string
  readback_status: string
  required_fields: string[]
  readback_summary: string
  response_received: boolean
  response_accepted: boolean
  response_rejected: boolean
  redacted_payload_ingested: boolean
  runtime_write_allowed: boolean
  telegram_send_allowed: boolean
  evidence_hash?: string
}

export interface AiAgentResultCaptureReleaseDecisionOwnerResponseReadbackSnapshot {
  schema_version: 'ai_agent_result_capture_release_decision_owner_response_readback_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-144'
    next_task_id: 'P2-145'
    read_only_mode: true
    runtime_authority: 'result_capture_release_decision_owner_response_readback_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_response_preflight: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    schema_version: string
    current_task_id: string
    next_task_id: string
    response_intake_lane_count: number
    required_owner_field_count: number
    intake_validation_check_count: number
    rejection_guard_count: number
    operator_action_count: number
    waiting_external_response_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    readiness_note: string
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
  }
  owner_response_readback_truth: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    p2_143_preflight_loaded: boolean
    p2_142_war_room_baseline_preserved: boolean
    owner_response_readback_ready: boolean
    readback_only_mode: boolean
    no_external_response_received: boolean
    no_raw_payload_required: boolean
    redaction_contract_loaded: boolean
    rejection_policy_preserved: boolean
    truth_note: string
    owner_response_received: boolean
    owner_response_accepted: boolean
    owner_response_rejected: boolean
    redacted_payload_ingested: boolean
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
    release_authorization_granted: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
  }
  response_readback_lanes: AiAgentReleaseDecisionOwnerResponseReadbackLane[]
  readback_validation_checks: {
    check_id: string
    status: string
    requirement: string
    runtime_write_allowed: boolean
  }[]
  readback_rejection_guards: {
    guard_id: string
    status: string
    reason: string
    runtime_write_allowed: boolean
  }[]
  operator_actions: {
    action_id: string
    owner_agent: string
    status: string
    operator_instruction: string
    runtime_write_allowed: boolean
  }[]
  display_redaction_contract: {
    redaction_required: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    internal_collaboration_content_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    response_readback_lane_count: number
    required_owner_field_count: number
    readback_validation_check_count: number
    readback_rejection_guard_count: number
    operator_action_count: number
    waiting_external_response_count: number
    no_external_response_received_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
  }
}

interface AiAgentReleaseDecisionOwnerResponseAcceptanceGateLane {
  gate_id: string
  display_name: string
  source_readback_id: string
  owner_agent: string
  current_task_id: string
  target_next_task_id: string
  acceptance_status: string
  acceptance_decision: string
  required_fields: string[]
  acceptance_summary: string
  response_received: boolean
  acceptance_passed: boolean
  acceptance_rejected: boolean
  redacted_payload_ingested: boolean
  runtime_write_allowed: boolean
  telegram_send_allowed: boolean
  evidence_hash?: string
}

export interface AiAgentResultCaptureReleaseDecisionOwnerResponseAcceptanceGateSnapshot {
  schema_version: 'ai_agent_result_capture_release_decision_owner_response_acceptance_gate_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: 'P2-145'
    next_task_id: 'P2-146'
    read_only_mode: true
    runtime_authority: 'result_capture_release_decision_owner_response_acceptance_gate_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  prior_owner_response_readback: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    schema_version: string
    current_task_id: string
    next_task_id: string
    response_readback_lane_count: number
    required_owner_field_count: number
    readback_validation_check_count: number
    readback_rejection_guard_count: number
    operator_action_count: number
    waiting_external_response_count: number
    no_external_response_received_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    readiness_note: string
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
  }
  owner_response_acceptance_truth: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    p2_144_readback_loaded: boolean
    p2_143_preflight_baseline_preserved: boolean
    owner_response_acceptance_gate_ready: boolean
    acceptance_gate_only_mode: boolean
    no_acceptable_external_response: boolean
    requires_redacted_payload: boolean
    requires_complete_owner_fields: boolean
    rejection_policy_preserved: boolean
    truth_note: string
    owner_response_received: boolean
    owner_response_accepted: boolean
    owner_response_rejected: boolean
    redacted_payload_ingested: boolean
    owner_release_authorized: boolean
    owner_release_approved: boolean
    owner_review_approved: boolean
    owner_decision_approved: boolean
    verifier_decision_approved: boolean
    maintenance_window_approved: boolean
    rollback_owner_confirmed: boolean
    post_release_verifier_ready: boolean
    final_release_candidate_approved: boolean
    final_release_candidate_passed: boolean
    release_decision_passed: boolean
    release_authorization_granted: boolean
    release_authorization_passed: boolean
    rollback_release_passed: boolean
    live_apply_release_passed: boolean
    writer_apply_enabled: boolean
    execution_apply_enabled: boolean
    receipt_write_enabled: boolean
    reviewer_queue_write_enabled: boolean
    gateway_queue_write_enabled: boolean
    telegram_send_enabled: boolean
    bot_api_call_enabled: boolean
    report_receipt_write_enabled: boolean
    result_capture_write_enabled: boolean
    learning_write_enabled: boolean
    playbook_trust_write_enabled: boolean
    production_write_enabled: boolean
    secret_read_enabled: boolean
    destructive_operation_enabled: boolean
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
  }
  acceptance_gate_lanes: AiAgentReleaseDecisionOwnerResponseAcceptanceGateLane[]
  acceptance_validation_checks: {
    check_id: string
    status: string
    requirement: string
    runtime_write_allowed: boolean
  }[]
  acceptance_rejection_guards: {
    guard_id: string
    status: string
    reason: string
    runtime_write_allowed: boolean
  }[]
  operator_actions: {
    action_id: string
    owner_agent: string
    status: string
    operator_instruction: string
    runtime_write_allowed: boolean
  }[]
  display_redaction_contract: {
    redaction_required: boolean
    raw_prompt_display_allowed: boolean
    private_reasoning_display_allowed: boolean
    secret_value_display_allowed: boolean
    raw_runtime_payload_display_allowed: boolean
    internal_collaboration_content_display_allowed: boolean
    frontend_display_policy: string
  }
  rollups: AiAgentReleaseDecisionNextHandoffZeroCounts & {
    acceptance_gate_lane_count: number
    required_owner_field_count: number
    acceptance_validation_check_count: number
    acceptance_rejection_guard_count: number
    operator_action_count: number
    blocked_no_external_response_count: number
    acceptance_ready_count: number
    no_acceptable_external_response_count: number
    approval_required_subtotal: number
    blocked_and_critical_subtotal: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    owner_response_rejected_count: number
    redacted_payload_ingested_count: number
  }
}

export interface AiAgentOwnerApprovedFixtureDryRunSnapshot {
  schema_version: 'ai_agent_owner_approved_fixture_dry_run_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: 'owner_approved_fixture_dry_run_only_no_live_write'
    status_note: string
  }
  source_refs: string[]
  dry_run_truth: {
    owner_fixture_scope_approved: true
    production_write_approved: false
    fixture_dry_run_allowed: true
    km_write_allowed: false
    playbook_trust_write_allowed: false
    timeline_learning_write_allowed: false
    agent_replay_score_write_allowed: false
    gateway_queue_write_allowed: false
    telegram_send_allowed: false
    redis_consumer_group_allowed: false
    db_migration_allowed: false
    workflow_trigger_allowed: false
    runtime_worker_allowed: false
    host_or_cluster_command_allowed: false
    secret_or_paid_api_allowed: false
    live_learning_write_count: number
    live_playbook_trust_update_count: number
    live_km_update_count: number
    live_timeline_write_count: number
    live_replay_score_write_count: number
    live_gateway_queue_write_count: number
    live_telegram_send_count: number
    truth_note: string
  }
  fixture_package: {
    required_fields: string[]
    forbidden_fields: string[]
    owner_review_required: true
    rollback_required: true
    no_write_proof_required: true
    operator_meaning: string
  }
  fixture_sets: Array<{
    fixture_id: string
    display_name: string
    scenario_type: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    target_surface: string
    operator_visible_result: string
    blocked_runtime_action: string
  }>
  dry_run_gates: Array<{
    gate_id: string
    display_name: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    required_evidence: string
    blocked_runtime_action: string
  }>
  simulation_steps: Array<{
    step_id: string
    display_name: string
    status: string
    expected_artifact: string
  }>
  rollback_contract: {
    rollback_required: true
    rollback_steps: string[]
  }
  approval_boundaries: Record<string, false>
  display_redaction_contract: {
    redaction_required: true
    raw_payload_display_allowed: false
    private_reasoning_display_allowed: false
    secret_value_display_allowed: false
    action_button_allowed: false
    allowed_frontend_content: string[]
    forbidden_frontend_content: string[]
    frontend_display_policy: string
  }
  rollups: {
    fixture_set_count: number
    dry_run_gate_count: number
    simulation_step_count: number
    approved_fixture_only_count: number
    approval_required_gate_ids: string[]
    blocked_runtime_action_count: number
    required_field_count: number
    forbidden_field_count: number
    live_write_count_total: number
    live_send_count_total: number
    live_receipt_count_total: number
  }
}

export interface AiAgentHostStatefulVersionInventorySnapshot {
  schema_version: 'ai_agent_host_stateful_version_inventory_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: string
    status_note: string
  }
  source_refs: string[]
  operation_boundaries: Record<string, boolean>
  approval_boundaries: Record<string, false>
  agent_roles: Array<{
    agent: string
    role: string
    responsibility: string
  }>
  host_inventory: Array<{
    host_id: string
    display_name: string
    known_addresses: string[]
    primary_surfaces: string[]
    version_observation_status: string
    readonly_only: boolean
    host_update_authorized: boolean
    reboot_authorized: boolean
    maintenance_window_required: boolean
    next_evidence_needed: string[]
    blocked_actions: string[]
  }>
  k3s_inventory: {
    cluster_id: string
    api_endpoint: string
    version_observation_status: string
    skew_policy_required: boolean
    upgrade_authorized: boolean
    nodes: Array<{
      node_id: string
      host_id: string
      role: string
      readonly_only: boolean
      drain_authorized: boolean
      kubelet_restart_authorized: boolean
      version_observation_status: string
    }>
    required_pre_change_evidence: string[]
  }
  stateful_services: Array<{
    service_id: string
    display_name: string
    host_id: string
    endpoint_ref: string
    version_observation_status: string
    readonly_only: boolean
    restart_authorized: boolean
    upgrade_authorized: boolean
    backup_required_before_change: boolean
  }>
  readonly_probe_plan: Array<{
    step_id: string
    display_name: string
    planned_output: string
    run_now_allowed: boolean
    mutation_allowed: boolean
  }>
  maintenance_window_approval_package: {
    package_id: string
    approval_required_before_probe: boolean
    approval_required_before_change: boolean
    break_glass_record_required: boolean
    required_fields: string[]
    forbidden_fields: string[]
    minimum_smoke_plan: string[]
  }
  telegram_policy: {
    status: string
    direct_send_allowed: boolean
    gateway_queue_write_allowed: boolean
    allowed_digest_types_after_gate: string[]
    success_noise_suppression: boolean
  }
  display_redaction_contract: {
    conversation_transcript_display_allowed: false
    redaction_required: true
    allowed_frontend_fields: string[]
    forbidden_frontend_content: string[]
  }
  rollups: {
    host_count: number
    k3s_node_count: number
    stateful_service_count: number
    readonly_probe_step_count: number
    maintenance_required_field_count: number
    host_ids: string[]
    stateful_service_ids: string[]
    ssh_login_allowed_count: number
    kubectl_command_execution_allowed_count: number
    apt_upgrade_allowed_count: number
    k3s_upgrade_allowed_count: number
    node_drain_allowed_count: number
    reboot_allowed_count: number
    stateful_service_restart_allowed_count: number
    telegram_direct_send_allowed_count: number
    conversation_transcript_allowed_count: number
  }
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
}

export interface DependencySupplyChainDriftMonitorSnapshot {
  schema_version: 'dependency_supply_chain_drift_monitor_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
    runtime_authority: string
    status_note: string
  }
  source_refs: string[]
  rollups: {
    source_snapshot_count: number
    stale_source_snapshot_count: number
    monitor_check_count: number
    drift_candidate_count: number
    action_required_candidate_count: number
    owner_action_count: number
    blocked_operation_count: number
    by_domain: Record<string, number>
    action_required_drift_candidate_ids: string[]
  }
  source_snapshot_readbacks: Array<{
    snapshot_id: string
    source_ref: string
    source_schema_version: string
    generated_at: string
    freshness_status: string
    evidence_status: string
    next_action: string
  }>
  monitor_checks: Array<{
    check_id: string
    domain: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    status: string
    current_signal: string
    evidence_refs: string[]
    blocked_now: string[]
    next_action: string
  }>
  drift_candidates: Array<{
    candidate_id: string
    domain: string
    severity: 'low' | 'medium' | 'high' | 'critical'
    status: string
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    summary: string
    evidence_refs: string[]
    next_owner_action: string
  }>
  owner_actions: Array<{
    action_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    owner_agent: 'openclaw' | 'hermes' | 'nemotron'
    approval_gate: string
    summary: string
    blocked_until: string
  }>
  telegram_policy: {
    status: string
    direct_send_allowed: false
    gateway_queue_write_allowed: false
    success_quiet: boolean
    failure_digest_after_approval: boolean
    draft_only_outputs: string[]
  }
  agent_roles: Array<{
    agent_id: 'openclaw' | 'hermes' | 'nemotron'
    role: string
    autonomy_level: string
    approval_gate: string
    outputs: string[]
  }>
  next_actions: Array<{
    task_id: string
    priority: 'P0' | 'P1' | 'P2' | 'P3'
    summary: string
    gate: string
  }>
  monitor_boundaries: Record<string, boolean>
}

export interface RuntimeSurfaceInventorySnapshot {
  schema_version: 'runtime_surface_inventory_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  source_refs: string[]
  rollups: {
    total_surfaces: number
    by_kind: Record<string, number>
    by_status: Record<string, number>
    by_evidence_level: Record<string, number>
    action_required_surface_ids: string[]
    secret_surface_ids: string[]
    live_check_missing_surface_ids: string[]
    total_source_components: number
    source_components_with_runtime_binding: number
  }
  runtime_surfaces: Array<{
    surface_id: string
    display_name: string
    kind: 'deployment' | 'service' | 'ingress' | 'cronjob' | 'configmap' | 'secret' | 'rbac' | 'policy' | 'autoscaler' | 'availability'
    manifest_ref: string
    status: 'manifest_mapped' | 'action_required' | 'blocked' | 'missing'
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    evidence_level: 'committed_manifest' | 'source_file' | 'missing_manifest' | 'live_check_required'
    runtime_binding: string
    health_contract: string
    secret_exposure: 'none' | 'name_only' | 'template_only' | 'payload_redacted'
    live_check_status: 'not_run' | 'not_applicable' | 'required'
    evidence_refs: string[]
    next_action: string
  }>
  source_runtime_components: Array<{
    component_id: string
    display_name: string
    source_ref: string
    component_kind: string
    runtime_binding: string
    status: 'bound' | 'action_required' | 'source_only'
    next_action: string
  }>
  evidence_gaps: Array<{
    gap_id: string
    severity: 'low' | 'medium' | 'high' | 'critical'
    status: 'action_required' | 'blocked' | 'accepted'
    summary: string
    evidence_refs: string[]
    next_action: string
  }>
  operator_contract: {
    display_mode: 'read_only_runtime_surface'
    must_not_interpret_as: string[]
    secret_display_policy: string
  }
  operation_boundaries: Record<string, boolean>
  approval_boundaries: Record<string, false>
}

export interface GiteaWorkflowRunnerHealthSnapshot {
  schema_version: 'gitea_workflow_runner_health_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  source_refs: string[]
  rollups: {
    total_workflows: number
    by_workflow_status: Record<string, number>
    by_runner_evidence_status: Record<string, number>
    workflows_with_schedule: number
    workflows_with_workflow_dispatch: number
    workflows_with_notify_bridge: number
    workflows_with_actionable_or_failure_quiet_policy: number
    workflow_ids_requiring_runner_attestation: string[]
    total_runner_contracts: number
    runner_contracts_requiring_action: string[]
    notification_contracts_total: number
    notification_contracts_quiet_success_count: number
    notification_contracts_quiet_success_ids: string[]
  }
  workflow_records: Array<{
    workflow_id: string
    file_ref: string
    display_name: string
    scope: string
    status: 'manifest_mapped' | 'action_required' | 'blocked'
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    triggers: string[]
    schedule_cadence: string
    runner_labels: string[]
    runner_evidence_status: 'host_runner_mapped' | 'owner_attestation_required' | 'comment_ambiguous'
    job_count: number
    notification_policy: string
    notify_bridge_calls: number
    secrets_policy_status: string
    evidence_refs: string[]
    next_action: string
  }>
  runner_contracts: Array<{
    contract_id: string
    display_name: string
    status: 'manifest_mapped' | 'action_required' | 'dry_run_only' | 'prepared_not_applied_by_snapshot'
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    runner_labels: string[]
    used_by_workflows: string[]
    health_contract: string
    guardrail_refs: string[]
    evidence_refs: string[]
    next_action: string
  }>
  notification_contracts: Array<{
    contract_id: string
    display_name: string
    status: 'preserved' | 'exception_documented' | 'action_required'
    policy_kind: 'failure_only' | 'actionable_only' | 'deployment_status_exception' | 'manual_status_exception' | 'read_only_no_notify'
    success_noise_policy: string
    failure_policy: string
    workflow_refs: string[]
    evidence_refs: string[]
    next_action: string
  }>
  latest_observations: Array<{
    observation_id: string
    status: string
    summary: string
    evidence_refs: string[]
  }>
  operator_contract: {
    display_mode: 'read_only_gitea_workflow_runner_health'
    must_not_interpret_as: string[]
    secret_display_policy: string
    runner_mutation_policy: string
    notification_policy: string
  }
  operation_boundaries: Record<string, boolean>
  approval_boundaries: Record<string, false>
}

export interface GiteaPrivateInventoryP0ScorecardSnapshot {
  schema_version: 'gitea_private_inventory_p0_scorecard_readback_v1'
  generated_at: string
  priority: 'P0-003'
  scope: 'gitea_private_inventory_p0_scorecard'
  status: string
  readback: {
    workplan_id: 'P0-003' | string
    workplan_title: string
    source_scorecard_ref: string
    source_control_authority: 'gitea' | string
    private_inventory_source: 'gitea' | string
    safe_next_step: string
  }
  gitea_inventory: {
    schema_version: string
    status: string
    visibility_scope: string
    repo_count: number
    token_present?: boolean
    blocking_reason?: string
  }
  authenticated_import_acceptance: {
    schema_version: string
    status: string
    accepted_payload_count: number
    token_value_collection_allowed: false
    execution_authorized: false
  }
  coverage_attestation: {
    schema_version: string
    status: string
    received_attestation_count: number
    accepted_attestation_count: number
    execution_authorized: false
  }
  product_row_coverage: {
    expected_product_count: number
    present_product_row_count: number
    missing_product_row_count: number
    ready_product_count: number
    blocked_product_count: number
    internal_or_authenticated_inventory_required_count: number
    all_active_product_repos_have_gitea_owner_readiness_row: boolean
  }
  active_blockers: string[]
  exit_criteria: string[]
  met_exit_criteria: string[]
  rollups: {
    active_blocker_count: number
    review_readiness_percent: number
    gitea_repo_inventory_status: string
    gitea_visibility_scope: string
    gitea_public_repo_count: number
    accepted_inventory_payload_count: number
    owner_coverage_attestation_received_count: number
    owner_coverage_attestation_accepted_count: number
    expected_product_count: number
    present_product_row_count: number
    missing_product_row_count: number
    ready_product_count: number
    blocked_product_count: number
    internal_or_authenticated_inventory_required_count: number
    all_active_product_repos_have_gitea_owner_readiness_row: boolean
    github_lane_excluded_from_p0_blocker_count: boolean
    github_api_used: boolean
    github_cli_used: boolean
    github_primary_switch_authorized: boolean
  }
  operation_boundaries: Record<string, boolean>
  github_retired_context: {
    status: 'stopped_retired_do_not_use' | string
    excluded_from_active_p0_blocker_math: boolean
    api_used: boolean
    cli_used: boolean
    primary_switch_authorized: boolean
  }
}

export interface GithubTargetPrivateBackupEvidenceGateSnapshot {
  schema_version: 'github_target_private_backup_evidence_gate_v1'
  generated_at: string
  status:
    | 'blocked_public_visibility_and_safe_credential_evidence_required'
    | 'blocked_private_visibility_and_safe_credential_evidence_required'
  mode: 'read_only_private_backup_evidence_gate'
  source_reviews: Record<string, string>
  summary: {
    target_decision_count: number
    approval_required_target_count: number
    approval_package_item_count: number
    public_probe_visible_target_count: number
    not_found_or_private_target_count: number
    private_backup_verified_count: number
    private_visibility_evidence_missing_count: number
    safe_credential_required_count: number
    safe_credential_accepted_evidence_count: number
    owner_response_received_count: number
    owner_response_accepted_count: number
    execution_ready_count: number
    blocked_target_count: number
    external_scope_target_count: number
    forbidden_action_count: number
    repo_creation_authorized: false
    visibility_change_authorized: false
    refs_sync_authorized: false
    github_primary_switch_authorized: false
    workflow_modification_authorized: false
    workflow_trigger_authorized: false
    secret_value_collection_allowed: false
    private_clone_url_collection_allowed: false
    not_found_or_private_as_absent_allowed: false
    public_repo_allowed: false
  }
  targets: Array<{
    github_repo: string
    source_key: string
    approval_required: boolean
    probe_status: string
    target_state: string
    risk: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL' | string
    visibility_evidence_status:
      | 'external_scope_not_backup_target'
      | 'blocked_public_probe_visible_private_evidence_required'
      | 'blocked_private_or_absent_not_verified'
      | 'blocked_probe_status_unknown'
    private_backup_verified: false
    private_visibility_owner_evidence_ref: string | null
    safe_credential_evidence_status: string
    safe_credential_evidence_ref: string | null
    owner_response_accepted: false
    refs_sync_ready: false
    execution_ready: false
    blockers: string[]
    evidence_refs: string[]
    next_action: string
    forbidden_actions: string[]
    repo_creation_authorized: false
    visibility_change_authorized: false
    refs_sync_authorized: false
    github_primary_switch_authorized: false
    secret_values_collected: false
  }>
  acceptance_requirements: string[]
  rejection_rules: string[]
  operation_boundaries: {
    read_only_api_allowed: true
    github_api_write_allowed: false
    gitea_api_write_allowed: false
    repo_creation_allowed: false
    visibility_change_allowed: false
    refs_sync_allowed: false
    workflow_modification_allowed: false
    workflow_trigger_allowed: false
    github_primary_switch_allowed: false
    secret_value_collection_allowed: false
    private_clone_url_collection_allowed: false
  }
  authorization_flags: Record<string, false>
}

export interface ObservabilityContractMatrixSnapshot {
  schema_version: 'observability_contract_matrix_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  source_refs: string[]
  rollups: {
    total_surfaces: number
    by_kind: Record<string, number>
    by_status: Record<string, number>
    by_evidence_status: Record<string, number>
    by_noise_policy_status: Record<string, number>
    surface_ids_requiring_action: string[]
    surface_ids_with_proposal_only_noise_policy: string[]
    noise_reduction_opportunities_total: number
    approval_required_opportunity_ids: string[]
    classification_gap_ids: string[]
    read_only_denials_total: number
  }
  observability_surfaces: Array<{
    surface_id: string
    display_name: string
    kind: string
    status: 'verified' | 'action_required' | 'blocked'
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    evidence_status: string
    noise_policy_status: string
    coverage_contract: string
    current_contract?: string
    evidence_refs: string[]
    next_action: string
  }>
  noise_reduction_opportunities: Array<{
    opportunity_id: string
    display_name: string
    status: string
    proposal_only: true
    impact: string
    target_surface_ids?: string[]
    evidence_refs: string[]
    next_action: string
  }>
  classification_gaps: Array<{
    gap_id: string
    display_name: string
    status: string
    severity: 'low' | 'medium' | 'high' | 'critical'
    summary: string
    evidence_refs: string[]
    next_action: string
  }>
  latest_observations: Array<{
    observation_id: string
    status: string
    summary: string
    evidence_refs: string[]
  }>
  operator_contract: {
    display_mode: 'read_only_observability_contract_matrix'
    must_not_interpret_as: string[]
    secret_display_policy: string
    alertmanager_route_policy: string
    noise_reduction_policy: string
    notification_policy: string
  }
  operation_boundaries: Record<string, boolean>
  approval_boundaries: Record<string, false>
}

export interface AiProviderRouteMatrixSnapshot {
  schema_version: 'ai_provider_route_matrix_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  source_refs: string[]
  rollups: {
    total_routes: number
    by_kind: Record<string, number>
    by_status: Record<string, number>
    by_route_gate: Record<string, number>
    route_ids_requiring_action: string[]
    candidate_gate_ids_requiring_approval: string[]
    source_gap_ids: string[]
    read_only_denials_total: number
    provider_switch_allowed_count: number
    paid_api_call_allowed_count: number
    shadow_or_canary_allowed_count: number
    runtime_route_change_allowed_count: number
  }
  provider_routes: Array<{
    route_id: string
    display_name: string
    kind: string
    status: 'verified' | 'action_required' | 'blocked'
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    route_gate: string
    evidence_status: string
    current_policy: string
    provider_order: string[]
    fallback_policy: string
    evidence_refs: string[]
    next_action: string
  }>
  candidate_gates: Array<{
    gate_id: string
    display_name: string
    status: string
    approval_required: boolean
    summary: string
    evidence_refs: string[]
    next_action: string
  }>
  source_gaps: Array<{
    gap_id: string
    display_name: string
    status: string
    severity: 'low' | 'medium' | 'high' | 'critical'
    summary: string
    evidence_refs: string[]
    next_action: string
  }>
  latest_observations: Array<{
    observation_id: string
    status: string
    summary: string
    evidence_refs: string[]
  }>
  operator_contract: {
    display_mode: 'read_only_ai_provider_route_matrix'
    must_not_interpret_as: string[]
    secret_display_policy: string
    provider_switch_policy: string
    cost_policy: string
    runtime_policy: string
  }
  operation_boundaries: Record<string, boolean>
  approval_boundaries: Record<string, false>
}

export interface ServiceHealthGapMatrixSnapshot {
  schema_version: 'service_health_gap_matrix_v1'
  generated_at: string
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  source_refs: string[]
  rollups: {
    total_targets: number
    by_kind: Record<string, number>
    by_status: Record<string, number>
    by_freshness_status: Record<string, number>
    target_ids_requiring_action: string[]
    health_gap_ids: string[]
    stale_endpoint_ids: string[]
    critical_target_ids: string[]
    read_only_denials_total: number
    service_restart_allowed_count: number
    endpoint_change_allowed_count: number
    active_probe_allowed_count: number
    notification_send_allowed_count: number
    runtime_execution_allowed_count: number
  }
  service_health_targets: Array<{
    target_id: string
    display_name: string
    kind: string
    status: 'verified' | 'action_required' | 'blocked'
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    freshness_status: string
    health_contract: string
    endpoint_contract: string
    evidence_refs: string[]
    next_action: string
  }>
  health_gaps: Array<{
    gap_id: string
    display_name: string
    status: string
    severity: 'low' | 'medium' | 'high' | 'critical'
    summary: string
    target_ids: string[]
    evidence_refs: string[]
    next_action: string
  }>
  stale_endpoints: Array<{
    endpoint_id: string
    display_name: string
    status: string
    severity: 'low' | 'medium' | 'high' | 'critical'
    stale_ref: string
    current_truth: string
    evidence_refs: string[]
    next_action: string
  }>
  latest_observations: Array<{
    observation_id: string
    status: string
    summary: string
    evidence_refs: string[]
  }>
  operator_contract: {
    display_mode: 'read_only_service_health_gap_matrix'
    must_not_interpret_as: string[]
    secret_display_policy: string
    restart_policy: string
    endpoint_policy: string
    notification_policy: string
  }
  operation_boundaries: Record<string, boolean>
  approval_boundaries: Record<string, false>
}

export interface ServiceHealthFailureNotificationPolicySnapshot {
  schema_version: 'service_health_failure_notification_policy_v1'
  generated_at: string
  source_service_health_matrix_ref: string
  source_refs: string[]
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  rollups: {
    total_rules: number
    by_decision: Record<string, number>
    immediate_escalation_rule_ids: string[]
    suppressed_success_rule_ids: string[]
    action_required_rule_ids: string[]
    notification_send_allowed_count: number
  }
  notification_channels: Array<{
    channel_id: string
    purpose: string
    immediate_allowed: boolean
    success_immediate_allowed: boolean
    requires_operator_action: boolean
  }>
  policy_rules: Array<{
    rule_id: string
    event_kind: string
    service_state: string
    severity: string
    decision: string
    channels: string[]
    owner_agent: string
    requires_incident: boolean
    requires_approval_record: boolean
    message_contract: string
    evidence_refs: string[]
  }>
  message_template_contract: {
    required_fields: string[]
    forbidden_fields: string[]
    success_message_policy: string
    failure_message_policy: string
  }
  display_redaction_contract: {
    frontend_display_policy: string
    allowed_frontend_fields: string[]
    forbidden_frontend_content: string[]
    conversation_transcript_display_allowed: false
    redaction_required: true
  }
  operation_boundaries: Record<string, boolean>
  approval_boundaries: Record<string, false>
}

export interface BackupDrTargetInventorySnapshot {
  schema_version: 'backup_dr_target_inventory_v1'
  generated_at: string
  source_refs: string[]
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  rollups: {
    total_targets: number
    by_status: Record<string, number>
    by_target_type: Record<string, number>
    by_gate_status: Record<string, number>
    blocked_target_ids: string[]
  }
  backup_targets: Array<{
    target_id: string
    display_name: string
    target_type: string
    status: string
    risk_level: 'low' | 'medium' | 'high' | 'critical'
    owner_host: string
    primary_script: string
    schedule: string
    rpo: string
    storage_class: string
    storage_ref: string
    offsite_policy: string
    automation_gate_status: string
    restore_gate_status: string
    secret_policy: string
    evidence_refs: string[]
    next_action: string
  }>
  approval_boundaries: Record<string, false>
  operation_boundaries: Record<string, boolean>
}

export interface BackupDrReadinessMatrixSnapshot {
  schema_version: 'backup_dr_readiness_matrix_v1'
  generated_at: string
  source_target_inventory_ref: string
  source_refs: string[]
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  rollups: {
    total_rows: number
    by_overall_readiness: Record<string, number>
    by_restore_drill_status: Record<string, number>
    by_offsite_status: Record<string, number>
    blocked_row_ids: string[]
    action_required_row_ids: string[]
    credential_escrow_intake_scorecard_schema_version: string
    credential_escrow_intake_scorecard_verifier: string
    credential_escrow_intake_status: string
    credential_escrow_active_gate_present: boolean
    credential_escrow_preflight_status: string
    credential_escrow_required_item_count: number
    credential_escrow_effective_missing_count: number
    credential_escrow_owner_response_received_count: number
    credential_escrow_owner_response_accepted_count: number
    credential_escrow_runtime_gate_count: number
    credential_escrow_secret_value_collection_allowed: boolean
    credential_marker_write_authorized_count: number
    credential_escrow_forbidden_true_field_count: number
  }
  readiness_rows: Array<{
    target_id: string
    display_name: string
    overall_readiness: string
    freshness_status: string
    integrity_status: string
    restore_drill_status: string
    offsite_status: string
    notification_policy: string
    gate_status: string
    evidence_level: string
    evidence_refs: string[]
    blocker_summary: string
    next_action: string
  }>
  approval_boundaries: Record<string, false>
  operation_boundaries: Record<string, boolean>
}

export interface BackupNotificationPolicySnapshot {
  schema_version: 'backup_notification_policy_v1'
  generated_at: string
  source_readiness_matrix_ref: string
  source_refs: string[]
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  rollups: {
    total_rules: number
    by_decision: Record<string, number>
    immediate_escalation_rule_ids: string[]
    suppressed_success_rule_ids: string[]
  }
  notification_channels: Array<{
    channel_id: string
    purpose: string
    immediate_allowed: boolean
    success_immediate_allowed: boolean
    requires_operator_action: boolean
  }>
  policy_rules: Array<{
    rule_id: string
    event_kind: string
    backup_state: string
    severity: string
    decision: string
    channels: string[]
    owner_agent: string
    requires_incident: boolean
    requires_approval_record: boolean
    message_contract: string
    evidence_refs: string[]
  }>
  daily_summary_contract: Record<string, unknown>
  approval_boundaries: Record<string, false>
  operation_boundaries: Record<string, boolean>
}

export interface OffsiteEscrowReadinessStatusSnapshot {
  schema_version: 'offsite_escrow_readiness_status_v1'
  generated_at: string
  source_refs: string[]
  program_status: {
    overall_completion_percent: number
    current_priority: 'P0' | 'P1' | 'P2' | 'P3'
    current_task_id: string
    next_task_id: string
    read_only_mode: true
  }
  rollups: {
    total_cards: number
    by_readiness: Record<string, number>
    by_kind: Record<string, number>
    verified_offsite_card_ids: string[]
    blocked_escrow_card_ids: string[]
    action_required_card_ids: string[]
    execution_blocked_card_ids: string[]
  }
  readiness_cards: Array<{
    card_id: string
    target_id: string
    display_name: string
    kind: 'offsite_mirror' | 'credential_escrow' | 'k8s_resource_offsite'
    readiness: 'verified' | 'action_required' | 'blocked'
    offsite_status: string
    escrow_status: string
    restore_drill_status: string
    credential_exposure_status: string
    automation_gate_status: string
    operator_summary: string
    next_action: string
    evidence_refs: string[]
    blocked_operations: string[]
  }>
  operator_contract: {
    display_mode: 'read_only_status'
    success_notification_policy: string
    failure_notification_policy: string
    credential_display_policy: string
    must_not_interpret_as: string[]
  }
  approval_boundaries: Record<string, false>
  operation_boundaries: Record<string, boolean>
}
