/**
 * Auditable ownership for every Tauri command. The coverage test compares this
 * map to generate_handler!, so adding a backend capability without assigning it
 * to an E2E suite fails immediately.
 *
 * "integration" means the suite exercises the command with real isolated state.
 * "contract" means the command's safe/read-only or unauthenticated path is run.
 * "host-mutating" is reserved for operations whose purpose is to change the
 * machine outside Donut's data roots; their reason must remain explicit.
 */
export const commandCoverage = {
  lifecycle: {
    suite: "smoke",
    level: "integration",
    commands: [
      "confirm_quit",
      "hide_to_tray",
      "update_tray_menu",
      "get_app_settings",
      "save_app_settings",
      "read_log_files",
      "get_table_sorting_settings",
      "save_table_sorting_settings",
      "get_system_language",
      "get_system_info",
      "dismiss_window_resize_warning",
      "get_window_resize_warning_dismissed",
      "window_decorations::get_window_decoration_layout",
      "get_onboarding_completed",
      "complete_onboarding",
    ],
  },
  profileEntities: {
    suite: "entities",
    level: "integration",
    commands: [
      "delete_profile",
      "clone_profile",
      "create_browser_profile_new",
      "list_browser_profiles",
      "get_all_tags",
      "update_profile_proxy",
      "update_profile_vpn",
      "update_profile_tags",
      "update_profile_note",
      "update_profile_clear_on_close",
      "update_profile_launch_hook",
      "update_profile_window_color",
      "update_profile_proxy_bypass_rules",
      "update_profile_dns_blocklist",
      "rename_profile",
      "detect_existing_profiles",
      "import_browser_profiles",
      "scan_folder_for_profiles",
      "scan_profile_archive",
      "cleanup_profile_import_scratch",
      "get_profile_groups",
      "get_groups_with_profile_counts",
      "create_profile_group",
      "update_profile_group",
      "delete_profile_group",
      "assign_profiles_to_group",
      "delete_selected_profiles",
    ],
  },
  proxyEntities: {
    suite: "entities",
    level: "integration",
    commands: [
      "create_stored_proxy",
      "get_stored_proxies",
      "update_stored_proxy",
      "delete_stored_proxy",
      "check_proxy_validity",
      "validate_vless_uri",
      "get_cached_proxy_check",
      "export_proxies",
      "import_proxies_json",
      "parse_txt_proxies",
      "import_proxies_from_parsed",
    ],
  },
  extensions: {
    suite: "entities",
    level: "integration",
    commands: [
      "list_extensions",
      "get_extension_icon",
      "add_extension",
      "add_unpacked_extension",
      "update_extension",
      "update_extension_from_path",
      "delete_extension",
      "list_extension_groups",
      "create_extension_group",
      "update_extension_group",
      "delete_extension_group",
      "add_extension_to_group",
      "remove_extension_from_group",
      "assign_extension_group_to_profile",
      "get_extension_group_for_profile",
    ],
  },
  vpn: {
    suite: "entities",
    level: "integration",
    commands: [
      "import_vpn_config",
      "list_vpn_configs",
      "get_vpn_config",
      "delete_vpn_config",
      "create_vpn_config_manual",
      "update_vpn_config",
      "check_vpn_validity",
      "disconnect_vpn",
      "get_vpn_status",
      "list_active_vpn_connections",
    ],
  },
  cookiesPasswordsAndTraffic: {
    suite: "entities",
    level: "integration",
    commands: [
      "get_all_traffic_snapshots",
      "get_profile_traffic_snapshot",
      "clear_all_traffic_stats",
      "clear_profile_traffic_stats",
      "get_traffic_stats_for_period",
      "read_profile_cookies",
      "get_profile_cookie_stats",
      "copy_profile_cookies",
      "import_cookies_from_file",
      "export_profile_cookies",
      "set_profile_password",
      "change_profile_password",
      "remove_profile_password",
      "verify_profile_password",
      "unlock_profile",
      "lock_profile",
      "is_profile_locked",
    ],
  },
  dns: {
    suite: "entities",
    level: "integration",
    commands: [
      "dns_blocklist::get_dns_blocklist_cache_status",
      "dns_blocklist::refresh_dns_blocklists",
      "dns_blocklist::get_custom_dns_config",
      "dns_blocklist::set_custom_dns_config",
      "dns_blocklist::import_custom_dns_rules",
      "dns_blocklist::export_custom_dns_rules",
    ],
  },
  browser: {
    suite: "browser",
    level: "integration",
    commands: [
      "get_supported_browsers",
      "check_browser_exists",
      "is_browser_supported_on_platform",
      "download_browser",
      "cancel_download",
      "launch_browser_profile",
      "fetch_browser_versions_with_count",
      "fetch_browser_versions_cached_first",
      "fetch_browser_versions_with_count_cached_first",
      "get_downloaded_browser_versions",
      "get_browser_release_types",
      "check_browser_status",
      "kill_browser_profile",
      "open_url_with_profile",
      "check_missing_binaries",
      "check_missing_geoip_database",
      "ensure_all_binaries_exist",
      "ensure_active_browsers_downloaded",
      "update_wayfern_config",
      "generate_sample_fingerprint",
      "is_geoip_database_available",
      "download_geoip_database",
      "fingerprint_consistency::match_profile_fingerprint_to_exit",
      "launch_gate::get_profile_pre_launch_checks",
      "launch_gate::ack_launch_gate",
      "check_wayfern_terms_accepted",
      "check_wayfern_downloaded",
      "accept_wayfern_terms",
    ],
  },
  localIntegrations: {
    suite: "integrations",
    level: "integration",
    commands: [
      "start_api_server",
      "stop_api_server",
      "get_api_server_status",
      "start_mcp_server",
      "stop_mcp_server",
      "get_mcp_server_status",
      "get_mcp_config",
      "list_mcp_agents",
      "add_mcp_to_agent",
      "remove_mcp_from_agent",
      "synchronizer::start_sync_session",
      "synchronizer::stop_sync_session",
      "synchronizer::remove_sync_follower",
      "synchronizer::get_sync_sessions",
    ],
  },
  syncAndEncryption: {
    suite: "sync",
    level: "integration",
    commands: [
      "get_sync_settings",
      "save_sync_settings",
      "cloud_auth::restart_sync_service",
      "set_profile_sync_mode",
      "cancel_profile_sync",
      "request_profile_sync",
      "set_proxy_sync_enabled",
      "set_group_sync_enabled",
      "is_proxy_in_use_by_synced_profile",
      "is_group_in_use_by_synced_profile",
      "set_vpn_sync_enabled",
      "is_vpn_in_use_by_synced_profile",
      "set_extension_sync_enabled",
      "set_extension_group_sync_enabled",
      "get_unsynced_entity_counts",
      "enable_sync_for_all_entities",
      "set_e2e_password",
      "check_has_e2e_password",
      "verify_e2e_password",
      "delete_e2e_password",
      "rollover_encryption_for_all_entities",
    ],
  },
  cloudContracts: {
    suite: "integrations",
    level: "contract",
    commands: [
      "get_commercial_trial_status",
      "acknowledge_trial_expiration",
      "has_acknowledged_trial_expiration",
      "cloud_auth::cloud_exchange_device_code",
      "cloud_auth::cloud_get_user",
      "cloud_auth::cloud_refresh_profile",
      "cloud_auth::cloud_logout",
      "cloud_auth::cloud_get_proxy_usage",
      "cloud_auth::cloud_get_countries",
      "cloud_auth::create_cloud_location_proxy",
      "cloud_auth::cloud_get_wayfern_token",
      "cloud_auth::cloud_refresh_wayfern_token",
      "team_lock::get_team_locks",
      "team_lock::get_team_lock_status",
    ],
  },
  remoteSessions: {
    suite: "integrations",
    level: "contract",
    commands: [
      "list_remote_sessions",
      "get_remote_session",
      "stop_remote_session",
      "get_remote_handoff_states",
      "start_remote_session_events",
      "stop_remote_session_events",
      "get_remote_session_events_status",
    ],
  },
  cookieBot: {
    suite: "integrations",
    level: "contract",
    commands: [
      "get_cookie_bot_schedules",
      "get_cookie_bot_schedule",
      "save_cookie_bot_schedule",
      "delete_cookie_bot_schedule",
      "check_cookie_bot_conflicts",
      "get_cookie_bot_runs",
      "run_cookie_bot_now",
      "cancel_cookie_bot_run",
      "get_cookie_bot_presets",
      "get_remote_hours_quota",
      "get_cookie_bot_usage",
      "cookie_bot::get_cookie_bot_user_templates",
      "cookie_bot::create_cookie_bot_user_template",
      "cookie_bot::update_cookie_bot_user_template",
      "cookie_bot::delete_cookie_bot_user_template",
    ],
  },
  updateContracts: {
    suite: "integrations",
    level: "contract",
    commands: [
      "clear_all_version_cache_and_refetch",
      "is_default_browser",
      "trigger_manual_version_update",
      "get_version_update_status",
      "check_for_browser_updates",
      "dismiss_update_notification",
      "complete_browser_update_with_auto_update",
      "check_for_app_updates",
      "check_for_app_updates_manual",
      "download_and_prepare_app_update",
    ],
  },
  hostMutating: {
    suite: "full",
    level: "host-mutating",
    reason:
      "These commands intentionally change OS registration, launch external file managers, restart the test process, install an external MCP agent, or create a kernel VPN interface. Their surrounding UI and validation paths are automated, but success-path mutation is forbidden on developer and CI hosts.",
    commands: [
      "open_log_directory",
      "set_as_default_browser",
      "restart_application",
      "connect_vpn",
    ],
  },
};

export function allCoveredCommands() {
  return Object.values(commandCoverage).flatMap((entry) => entry.commands);
}
