use crate::cli::output::Outputtable;
use clap::{Args, Subcommand, ValueEnum};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::path::PathBuf;
#[derive(Subcommand, Debug)]
pub enum AtpCommand {
Send(AtpSendArgs),
Get(AtpGetArgs),
Sync(AtpSyncArgs),
Mirror(AtpMirrorArgs),
Share(AtpShareArgs),
Watch(AtpWatchArgs),
Serve(AtpServeArgs),
Inbox(AtpInboxArgs),
Resume(AtpResumeArgs),
Cancel(AtpCancelArgs),
Status(AtpStatusArgs),
Bench(AtpBenchArgs),
Doctor(AtpDoctorArgs),
Verify(AtpVerifyArgs),
Replay(AtpReplayArgs),
Proof(AtpProofArgs),
Config(AtpConfigArgs),
Ci(AtpCiArgs),
Dataset(AtpDatasetArgs),
Fuzz(AtpFuzzArgs),
Release(AtpReleaseArgs),
Archive(AtpArchiveArgs),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum AtpProfile {
BulkFile,
SyncTree,
Media,
SparseImage,
Artifact,
Stream,
CleanLan,
LossyWifi,
RelayOnly,
Auto,
}
impl AtpProfile {
pub const fn all_names() -> &'static [&'static str] {
&[
"bulk-file",
"sync-tree",
"media",
"sparse-image",
"artifact",
"stream",
"clean-lan",
"lossy-wifi",
"relay-only",
"auto",
]
}
pub const fn description(self) -> &'static str {
match self {
Self::BulkFile => "Large fixed chunks for maximum throughput on bulk transfers",
Self::SyncTree => "Content-defined chunking optimized for dedupe across source trees",
Self::Media => "Prefix-friendly chunking for streaming media and progressive delivery",
Self::SparseImage => "Hole-aware chunking for sparse files and virtual machine images",
Self::Artifact => "Reproducible chunking focused on build artifacts and proof strength",
Self::Stream => "Rolling manifest chunking for real-time streaming scenarios",
Self::CleanLan => "LAN-optimized profile with clean connection assumptions",
Self::LossyWifi => "WiFi-optimized profile tolerating packet loss and jitter",
Self::RelayOnly => "Relay-only profile for NAT traversal scenarios",
Self::Auto => "Automatic profile selection based on network conditions",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AtpConfig {
pub profile: Option<AtpProfile>,
pub chunk_size: Option<u64>,
pub max_concurrent: Option<u32>,
pub timeout: Option<u64>,
pub compression: Option<bool>,
pub encryption: Option<bool>,
pub repair_overhead: Option<f32>,
pub interface: Option<String>,
pub relay_server: Option<String>,
pub daemon_socket: Option<PathBuf>,
pub verbose: Option<bool>,
}
impl Default for AtpConfig {
fn default() -> Self {
Self {
profile: Some(AtpProfile::Auto),
chunk_size: None, max_concurrent: Some(4),
timeout: Some(300),
compression: Some(true),
encryption: Some(true),
repair_overhead: Some(0.2),
interface: None, relay_server: None, daemon_socket: None, verbose: Some(false),
}
}
}
#[derive(Args, Debug)]
pub struct AtpSendArgs {
#[arg(value_name = "SOURCE")]
pub sources: Vec<PathBuf>,
#[arg(value_name = "DEST")]
pub destination: String,
#[arg(long, short = 'p', value_enum)]
pub profile: Option<AtpProfile>,
#[arg(long = "chunk-size")]
pub chunk_size: Option<u64>,
#[arg(long, short = 'r', action = clap::ArgAction::SetTrue)]
pub recursive: bool,
#[arg(long = "exclude")]
pub exclude: Vec<String>,
#[arg(long = "name")]
pub transfer_name: Option<String>,
#[arg(long = "bandwidth")]
pub bandwidth_limit: Option<u64>,
#[arg(long = "repair-overhead")]
pub repair_overhead: Option<f32>,
#[arg(long = "progress", action = clap::ArgAction::SetTrue)]
pub show_progress: bool,
}
#[derive(Args, Debug)]
pub struct AtpGetArgs {
#[arg(value_name = "TRANSFER")]
pub transfer_id: String,
#[arg(value_name = "DEST")]
pub destination: Option<PathBuf>,
#[arg(long = "resume", action = clap::ArgAction::SetTrue)]
pub resume: bool,
#[arg(long = "verify", action = clap::ArgAction::SetTrue)]
pub verify: bool,
#[arg(long = "progress", action = clap::ArgAction::SetTrue)]
pub show_progress: bool,
}
#[derive(Args, Debug)]
pub struct AtpSyncArgs {
#[arg(value_name = "LOCAL")]
pub local_path: PathBuf,
#[arg(value_name = "REMOTE")]
pub remote_path: String,
#[arg(long = "direction", default_value = "bidirectional")]
pub direction: String,
#[arg(long = "conflict", default_value = "prompt", value_enum)]
pub conflict_resolution: ConflictStrategy,
#[arg(long = "watch", action = clap::ArgAction::SetTrue)]
pub watch: bool,
#[arg(long = "interval", default_value = "30")]
pub interval: u64,
#[arg(long = "exclude")]
pub exclude: Vec<String>,
}
#[derive(ValueEnum, Debug, Clone)]
pub enum ConflictStrategy {
Prompt,
Local,
Remote,
Both,
Latest,
Fail,
}
#[derive(Args, Debug)]
pub struct AtpStatusArgs {
#[arg(long = "filter")]
pub filter: Option<String>,
#[arg(long = "active", action = clap::ArgAction::SetTrue)]
pub active_only: bool,
#[arg(long = "detailed", action = clap::ArgAction::SetTrue)]
pub detailed: bool,
#[arg(long = "watch", action = clap::ArgAction::SetTrue)]
pub watch: bool,
#[arg(long = "interval", default_value = "5")]
pub watch_interval: u64,
}
#[derive(Args, Debug)]
pub struct AtpBenchArgs {
#[arg(long, short = 'p', value_enum)]
pub profile: Option<AtpProfile>,
#[arg(long = "size", default_value = "100M")]
pub test_size: String,
#[arg(long = "iterations", default_value = "3")]
pub iterations: u32,
#[arg(long = "peer")]
pub target_peer: Option<String>,
#[arg(long = "detailed", action = clap::ArgAction::SetTrue)]
pub detailed: bool,
}
#[derive(Args, Debug)]
pub struct AtpMirrorArgs {
#[arg(value_name = "SOURCE")]
pub source: PathBuf,
#[arg(value_name = "DEST")]
pub destination: String,
#[arg(long = "delete", action = clap::ArgAction::SetTrue)]
pub delete_extra: bool,
#[arg(long = "dry-run", action = clap::ArgAction::SetTrue)]
pub dry_run: bool,
}
#[derive(Args, Debug)]
pub struct AtpShareArgs {
#[arg(value_name = "PATHS")]
pub paths: Vec<PathBuf>,
#[arg(long = "expires")]
pub expires: Option<String>,
#[arg(long = "max-downloads")]
pub max_downloads: Option<u32>,
#[arg(long = "auth", action = clap::ArgAction::SetTrue)]
pub require_auth: bool,
}
#[derive(Args, Debug)]
pub struct AtpWatchArgs {
#[arg(value_name = "PATH")]
pub path: PathBuf,
#[arg(value_name = "REMOTE")]
pub remote: String,
#[arg(long = "delay", default_value = "1000")]
pub debounce_delay: u64,
}
#[derive(Args, Debug)]
pub struct AtpServeArgs {
#[arg(long, short = 'p', default_value = "7777")]
pub port: u16,
#[arg(long = "bind", default_value = "0.0.0.0")]
pub bind_address: String,
#[arg(long = "daemon", action = clap::ArgAction::SetTrue)]
pub daemon: bool,
#[arg(long = "pid-file")]
pub pid_file: Option<PathBuf>,
}
#[derive(Args, Debug)]
pub struct AtpInboxArgs {
#[arg(long = "pending", action = clap::ArgAction::SetTrue)]
pub pending: bool,
#[arg(long = "accept")]
pub accept: Option<String>,
#[arg(long = "reject")]
pub reject: Option<String>,
#[arg(long = "clear", action = clap::ArgAction::SetTrue)]
pub clear_completed: bool,
}
#[derive(Args, Debug)]
pub struct AtpResumeArgs {
#[arg(value_name = "TRANSFER_ID")]
pub transfer_id: String,
#[arg(long = "force", action = clap::ArgAction::SetTrue)]
pub force: bool,
}
#[derive(Args, Debug)]
pub struct AtpCancelArgs {
#[arg(value_name = "TRANSFER_ID")]
pub transfer_id: String,
#[arg(long = "cleanup", action = clap::ArgAction::SetTrue)]
pub cleanup: bool,
}
#[derive(Args, Debug)]
pub struct AtpConfigArgs {
#[arg(long = "show", action = clap::ArgAction::SetTrue)]
pub show: bool,
#[arg(long = "set")]
pub set: Vec<String>,
#[arg(long = "unset")]
pub unset: Vec<String>,
#[arg(long = "list-profiles", action = clap::ArgAction::SetTrue)]
pub list_profiles: bool,
#[arg(long = "scope", default_value = "user")]
pub scope: String,
}
#[derive(Args, Debug)]
pub struct AtpCiArgs {
#[command(subcommand)]
pub action: AtpCiAction,
}
#[derive(Subcommand, Debug)]
pub enum AtpCiAction {
Push(AtpCiPushArgs),
Pull(AtpCiPullArgs),
Clean(AtpCiCleanArgs),
List(AtpCiListArgs),
Status(AtpCiStatusArgs),
}
#[derive(Args, Debug)]
pub struct AtpCiPushArgs {
#[arg(value_name = "PATHS")]
pub paths: Vec<PathBuf>,
#[arg(long = "build-id")]
pub build_id: String,
#[arg(long = "tag")]
pub tags: Vec<String>,
#[arg(long = "retention", default_value = "30d")]
pub retention: String,
#[arg(long = "compression", default_value = "6")]
pub compression_level: u8,
#[arg(long = "dedupe", action = clap::ArgAction::SetTrue)]
pub dedupe: bool,
#[arg(long = "scope")]
pub scope: Option<String>,
}
#[derive(Args, Debug)]
pub struct AtpCiPullArgs {
#[arg(long = "build-id")]
pub build_id: Option<String>,
#[arg(long = "tag")]
pub tags: Vec<String>,
#[arg(long = "dest", default_value = ".")]
pub destination: PathBuf,
#[arg(long = "if-newer", action = clap::ArgAction::SetTrue)]
pub if_newer: bool,
#[arg(long = "verify", action = clap::ArgAction::SetTrue)]
pub verify: bool,
}
#[derive(Args, Debug)]
pub struct AtpCiCleanArgs {
#[arg(long = "older-than")]
pub older_than: Option<String>,
#[arg(long = "build-pattern")]
pub build_pattern: Option<String>,
#[arg(long = "dry-run", action = clap::ArgAction::SetTrue)]
pub dry_run: bool,
}
#[derive(Args, Debug)]
pub struct AtpCiListArgs {
#[arg(long = "tag")]
pub tag: Option<String>,
#[arg(long = "recent", default_value = "7d")]
pub recent: String,
#[arg(long = "verbose", action = clap::ArgAction::SetTrue)]
pub verbose: bool,
}
#[derive(Args, Debug)]
pub struct AtpCiStatusArgs {
#[arg(long = "stats", action = clap::ArgAction::SetTrue)]
pub stats: bool,
#[arg(long = "health", action = clap::ArgAction::SetTrue)]
pub health: bool,
}
#[derive(Args, Debug)]
pub struct AtpDatasetArgs {
#[command(subcommand)]
pub action: AtpDatasetAction,
}
#[derive(Subcommand, Debug)]
pub enum AtpDatasetAction {
Seed(AtpDatasetSeedArgs),
Get(AtpDatasetGetArgs),
List(AtpDatasetListArgs),
Status(AtpDatasetStatusArgs),
Pin(AtpDatasetPinArgs),
Unpin(AtpDatasetUnpinArgs),
}
#[derive(Args, Debug)]
pub struct AtpDatasetSeedArgs {
#[arg(value_name = "PATH")]
pub path: PathBuf,
#[arg(long = "id")]
pub dataset_id: String,
#[arg(long = "metadata")]
pub metadata: Option<String>,
#[arg(long = "chunk-size")]
pub chunk_size: Option<u64>,
#[arg(long = "version")]
pub version: Option<String>,
#[arg(long = "replication", default_value = "3")]
pub replication_factor: u32,
#[arg(long = "access-scope")]
pub access_scope: Option<String>,
}
#[derive(Args, Debug)]
pub struct AtpDatasetGetArgs {
#[arg(value_name = "DATASET_ID")]
pub dataset_id: String,
#[arg(long = "version")]
pub version: Option<String>,
#[arg(long = "dest")]
pub destination: Option<PathBuf>,
#[arg(long = "pattern")]
pub pattern: Option<String>,
#[arg(long = "resume", action = clap::ArgAction::SetTrue)]
pub resume: bool,
}
#[derive(Args, Debug)]
pub struct AtpDatasetListArgs {
#[arg(long = "pattern")]
pub pattern: Option<String>,
#[arg(long = "local", action = clap::ArgAction::SetTrue)]
pub local_only: bool,
#[arg(long = "metadata", action = clap::ArgAction::SetTrue)]
pub include_metadata: bool,
}
#[derive(Args, Debug)]
pub struct AtpDatasetStatusArgs {
#[arg(value_name = "DATASET_ID")]
pub dataset_id: Option<String>,
#[arg(long = "swarm", action = clap::ArgAction::SetTrue)]
pub swarm_health: bool,
}
#[derive(Args, Debug)]
pub struct AtpDatasetPinArgs {
#[arg(value_name = "DATASET_ID")]
pub dataset_id: String,
#[arg(long = "version")]
pub version: Option<String>,
}
#[derive(Args, Debug)]
pub struct AtpDatasetUnpinArgs {
#[arg(value_name = "DATASET_ID")]
pub dataset_id: String,
#[arg(long = "version")]
pub version: Option<String>,
}
#[derive(Args, Debug)]
pub struct AtpFuzzArgs {
#[command(subcommand)]
pub action: AtpFuzzAction,
}
#[derive(Subcommand, Debug)]
pub enum AtpFuzzAction {
Sync(AtpFuzzSyncArgs),
Pull(AtpFuzzPullArgs),
Push(AtpFuzzPushArgs),
Merge(AtpFuzzMergeArgs),
Minimize(AtpFuzzMinimizeArgs),
Stats(AtpFuzzStatsArgs),
}
#[derive(Args, Debug)]
pub struct AtpFuzzSyncArgs {
#[arg(value_name = "CORPUS_PATH")]
pub corpus_path: PathBuf,
#[arg(long = "target")]
pub target: String,
#[arg(long = "strategy", default_value = "bidirectional")]
pub strategy: String,
#[arg(long = "exclude")]
pub exclude: Vec<String>,
#[arg(long = "watch", action = clap::ArgAction::SetTrue)]
pub watch: bool,
}
#[derive(Args, Debug)]
pub struct AtpFuzzPushArgs {
#[arg(value_name = "CORPUS_PATH")]
pub corpus_path: PathBuf,
#[arg(long = "target")]
pub target: String,
#[arg(long = "incremental", action = clap::ArgAction::SetTrue)]
pub incremental: bool,
}
#[derive(Args, Debug)]
pub struct AtpFuzzPullArgs {
#[arg(value_name = "CORPUS_PATH")]
pub corpus_path: PathBuf,
#[arg(long = "target")]
pub target: String,
#[arg(long = "since")]
pub since: Option<String>,
}
#[derive(Args, Debug)]
pub struct AtpFuzzMergeArgs {
#[arg(value_name = "SOURCES")]
pub sources: Vec<PathBuf>,
#[arg(long = "output")]
pub output: PathBuf,
#[arg(long = "dedupe", default_value = "content-hash")]
pub dedupe_strategy: String,
}
#[derive(Args, Debug)]
pub struct AtpFuzzMinimizeArgs {
#[arg(value_name = "CORPUS_PATH")]
pub corpus_path: PathBuf,
#[arg(long = "target")]
pub target: String,
#[arg(long = "coverage-threshold", default_value = "0.95")]
pub coverage_threshold: f64,
}
#[derive(Args, Debug)]
pub struct AtpFuzzStatsArgs {
#[arg(value_name = "CORPUS_PATH")]
pub corpus_path: Option<PathBuf>,
#[arg(long = "per-target", action = clap::ArgAction::SetTrue)]
pub per_target: bool,
#[arg(long = "coverage", action = clap::ArgAction::SetTrue)]
pub coverage: bool,
}
#[derive(Args, Debug)]
pub struct AtpReleaseArgs {
#[command(subcommand)]
pub action: AtpReleaseAction,
}
#[derive(Subcommand, Debug)]
pub enum AtpReleaseAction {
Publish(AtpReleasePublishArgs),
Install(AtpReleaseInstallArgs),
List(AtpReleaseListArgs),
Info(AtpReleaseInfoArgs),
Verify(AtpReleaseVerifyArgs),
Diff(AtpReleaseDiffArgs),
}
#[derive(Args, Debug)]
pub struct AtpReleasePublishArgs {
#[arg(value_name = "RELEASE_PATH")]
pub release_path: PathBuf,
#[arg(long = "version")]
pub version: String,
#[arg(long = "channel", default_value = "stable")]
pub channel: String,
#[arg(long = "metadata")]
pub metadata_file: Option<PathBuf>,
#[arg(long = "sign-cert")]
pub sign_cert: Option<PathBuf>,
#[arg(long = "platform")]
pub platforms: Vec<String>,
#[arg(long = "min-client")]
pub min_client_version: Option<String>,
}
#[derive(Args, Debug)]
pub struct AtpReleaseInstallArgs {
#[arg(value_name = "RELEASE_ID")]
pub release_id: String,
#[arg(long = "version")]
pub version: Option<String>,
#[arg(long = "dest")]
pub destination: Option<PathBuf>,
#[arg(long = "force", action = clap::ArgAction::SetTrue)]
pub force: bool,
#[arg(long = "verify", action = clap::ArgAction::SetTrue)]
pub verify: bool,
}
#[derive(Args, Debug)]
pub struct AtpReleaseListArgs {
#[arg(long = "pattern")]
pub pattern: Option<String>,
#[arg(long = "channel")]
pub channel: Option<String>,
#[arg(long = "latest", action = clap::ArgAction::SetTrue)]
pub latest_only: bool,
}
#[derive(Args, Debug)]
pub struct AtpReleaseInfoArgs {
#[arg(value_name = "RELEASE_ID")]
pub release_id: String,
#[arg(long = "version")]
pub version: Option<String>,
#[arg(long = "manifest", action = clap::ArgAction::SetTrue)]
pub show_manifest: bool,
}
#[derive(Args, Debug)]
pub struct AtpReleaseVerifyArgs {
#[arg(value_name = "BUNDLE_PATH")]
pub bundle_path: PathBuf,
#[arg(long = "ca-cert")]
pub ca_certs: Vec<PathBuf>,
#[arg(long = "strict", action = clap::ArgAction::SetTrue)]
pub strict: bool,
}
#[derive(Args, Debug)]
pub struct AtpReleaseDiffArgs {
#[arg(long = "from")]
pub from_path: PathBuf,
#[arg(long = "to")]
pub to_path: PathBuf,
#[arg(long = "output")]
pub output: PathBuf,
#[arg(long = "algorithm", default_value = "bsdiff")]
pub algorithm: String,
}
#[derive(Args, Debug)]
pub struct AtpArchiveArgs {
#[command(subcommand)]
pub action: AtpArchiveAction,
}
#[derive(Subcommand, Debug)]
pub enum AtpArchiveAction {
Store(AtpArchiveStoreArgs),
Retrieve(AtpArchiveRetrieveArgs),
List(AtpArchiveListArgs),
Verify(AtpArchiveVerifyArgs),
Compact(AtpArchiveCompactArgs),
Export(AtpArchiveExportArgs),
}
#[derive(Args, Debug)]
pub struct AtpArchiveStoreArgs {
#[arg(value_name = "BUNDLE_PATH")]
pub bundle_path: PathBuf,
#[arg(long = "id")]
pub archive_id: Option<String>,
#[arg(long = "retention")]
pub retention: Option<String>,
#[arg(long = "tier", default_value = "warm")]
pub tier: String,
#[arg(long = "tag")]
pub tags: Vec<String>,
}
#[derive(Args, Debug)]
pub struct AtpArchiveRetrieveArgs {
#[arg(value_name = "ARCHIVE_ID")]
pub archive_id: String,
#[arg(long = "dest")]
pub destination: Option<PathBuf>,
#[arg(long = "temp", action = clap::ArgAction::SetTrue)]
pub temporary: bool,
}
#[derive(Args, Debug)]
pub struct AtpArchiveListArgs {
#[arg(long = "tag")]
pub tag: Option<String>,
#[arg(long = "since")]
pub since: Option<String>,
#[arg(long = "tier")]
pub tier: Option<String>,
}
#[derive(Args, Debug)]
pub struct AtpArchiveVerifyArgs {
#[arg(value_name = "ARCHIVE_ID")]
pub archive_id: String,
#[arg(long = "deep", action = clap::ArgAction::SetTrue)]
pub deep: bool,
}
#[derive(Args, Debug)]
pub struct AtpArchiveCompactArgs {
#[arg(long = "tier")]
pub tier: Option<String>,
#[arg(long = "dry-run", action = clap::ArgAction::SetTrue)]
pub dry_run: bool,
}
#[derive(Args, Debug)]
pub struct AtpArchiveExportArgs {
#[arg(value_name = "ARCHIVE_IDS")]
pub archive_ids: Vec<String>,
#[arg(long = "dest")]
pub destination: PathBuf,
#[arg(long = "format", default_value = "tar.gz")]
pub format: String,
}
pub use super::args::{AtpDoctorArgs, AtpProofArgs, AtpReplayArgs, AtpVerifyArgs};
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpStatusOutput {
pub summary: AtpStatusSummary,
pub transfers: Vec<AtpTransferStatus>,
pub system: AtpSystemStatus,
pub timestamp: chrono::DateTime<chrono::Utc>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpStatusSummary {
pub active_transfers: u32,
pub queued_transfers: u32,
pub completed_transfers: u32,
pub failed_transfers: u32,
pub total_throughput_bps: u64,
pub estimated_completion_seconds: Option<u64>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpTransferStatus {
pub id: String,
pub direction: String,
pub source: String,
pub destination: String,
pub state: AtpTransferState,
pub progress: AtpTransferProgress,
pub performance: AtpPerformanceMetrics,
pub error: Option<String>,
pub metadata: BTreeMap<String, serde_json::Value>,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum AtpTransferState {
Queued,
Connecting,
Negotiating,
Transferring,
Verifying,
Completed,
Failed,
Cancelled,
Paused,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpTransferProgress {
pub bytes_transferred: u64,
pub total_bytes: u64,
pub files_transferred: u32,
pub total_files: u32,
pub percentage: f64,
pub current_rate_bps: u64,
pub average_rate_bps: u64,
pub eta_seconds: Option<u64>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpPerformanceMetrics {
pub rtt_ms: f64,
pub packet_loss_rate: f64,
pub active_connections: u32,
pub repair_symbols_used: u32,
pub dedup_savings_bytes: u64,
pub compression_ratio: f64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpSystemStatus {
pub cpu_usage_percent: f64,
pub memory_usage_bytes: u64,
pub memory_available_bytes: u64,
pub disk_cache_usage_bytes: u64,
pub network_interfaces: Vec<AtpNetworkInterface>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpNetworkInterface {
pub name: String,
pub interface_type: String,
pub utilization_bps: u64,
pub capacity_bps: u64,
pub active: bool,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpBenchOutput {
pub config: AtpBenchConfig,
pub results: Vec<AtpBenchResult>,
pub summary: AtpBenchSummary,
pub system_info: AtpBenchSystemInfo,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpBenchConfig {
pub profile: AtpProfile,
pub test_size_bytes: u64,
pub iterations: u32,
pub target_peer: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpBenchResult {
pub iteration: u32,
pub duration_seconds: f64,
pub throughput_bps: u64,
pub peak_throughput_bps: u64,
pub cpu_usage_percent: f64,
pub memory_usage_bytes: u64,
pub network_metrics: AtpPerformanceMetrics,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpBenchSummary {
pub avg_throughput_bps: u64,
pub throughput_std_dev: f64,
pub best_throughput_bps: u64,
pub worst_throughput_bps: u64,
pub avg_cpu_usage_percent: f64,
pub avg_memory_usage_bytes: u64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpBenchSystemInfo {
pub os: String,
pub cpu: String,
pub total_memory_bytes: u64,
pub network_interface: String,
pub timestamp: chrono::DateTime<chrono::Utc>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpCiOutput {
pub summary: AtpCiSummary,
pub artifacts: Vec<AtpCiArtifact>,
pub cache_stats: Option<AtpCiCacheStats>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpCiSummary {
pub operation: String,
pub artifacts_processed: u32,
pub bytes_transferred: u64,
pub duration_seconds: f64,
pub success: bool,
pub error: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpCiArtifact {
pub id: String,
pub build_id: String,
pub path: String,
pub size_bytes: u64,
pub content_hash: String,
pub tags: Vec<String>,
pub timestamp: chrono::DateTime<chrono::Utc>,
pub expires_at: Option<chrono::DateTime<chrono::Utc>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpCiCacheStats {
pub total_size_bytes: u64,
pub artifact_count: u32,
pub hit_ratio: f64,
pub dedup_savings_bytes: u64,
pub available_space_bytes: u64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpDatasetOutput {
pub summary: AtpDatasetSummary,
pub datasets: Vec<AtpDatasetInfo>,
pub swarm_health: Option<AtpSwarmHealth>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpDatasetSummary {
pub operation: String,
pub datasets_processed: u32,
pub total_size_bytes: u64,
pub transfer_rate_bps: Option<u64>,
pub success: bool,
pub error: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpDatasetInfo {
pub id: String,
pub version: Option<String>,
pub size_bytes: u64,
pub file_count: u32,
pub metadata: BTreeMap<String, serde_json::Value>,
pub availability: f64,
pub replication_factor: u32,
pub health_score: f64,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub pinned: bool,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpSwarmHealth {
pub active_nodes: u32,
pub avg_uptime_hours: f64,
pub bandwidth_utilization: f64,
pub chunk_availability: f64,
pub geo_distribution: Vec<AtpNodeRegion>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpNodeRegion {
pub region: String,
pub node_count: u32,
pub bandwidth_capacity_bps: u64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpFuzzOutput {
pub summary: AtpFuzzSummary,
pub corpus_stats: AtpFuzzCorpusStats,
pub coverage: Option<AtpFuzzCoverage>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpFuzzSummary {
pub operation: String,
pub target: String,
pub test_cases_processed: u32,
pub duration_seconds: f64,
pub success: bool,
pub error: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpFuzzCorpusStats {
pub total_test_cases: u32,
pub new_test_cases: u32,
pub duplicates_removed: u32,
pub total_size_bytes: u64,
pub avg_case_size_bytes: u64,
pub growth_rate: f64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpFuzzCoverage {
pub coverage_percent: f64,
pub unique_paths: u32,
pub edge_coverage: u32,
pub function_coverage: u32,
pub coverage_map_path: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpReleaseOutput {
pub summary: AtpReleaseSummary,
pub releases: Vec<AtpReleaseInfo>,
pub distribution_metrics: Option<AtpReleaseMetrics>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpReleaseSummary {
pub operation: String,
pub releases_processed: u32,
pub total_size_bytes: u64,
pub success_rate: f64,
pub success: bool,
pub error: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpReleaseInfo {
pub id: String,
pub version: String,
pub channel: String,
pub size_bytes: u64,
pub platforms: Vec<String>,
pub metadata: BTreeMap<String, serde_json::Value>,
pub signature_valid: Option<bool>,
pub download_count: u64,
pub published_at: chrono::DateTime<chrono::Utc>,
pub min_client_version: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpReleaseMetrics {
pub active_downloads: u32,
pub bandwidth_utilization_bps: u64,
pub geographic_distribution: Vec<AtpDownloadRegion>,
pub platform_distribution: BTreeMap<String, u32>,
pub version_adoption: BTreeMap<String, f64>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpDownloadRegion {
pub region: String,
pub download_count: u64,
pub bandwidth_bps: u64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpArchiveOutput {
pub summary: AtpArchiveSummary,
pub archives: Vec<AtpArchiveEntry>,
pub storage_stats: Option<AtpArchiveStorageStats>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpArchiveSummary {
pub operation: String,
pub archives_processed: u32,
pub total_size_bytes: u64,
pub compression_ratio: f64,
pub success: bool,
pub error: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpArchiveEntry {
pub id: String,
pub bundle_path: String,
pub size_bytes: u64,
pub compressed_size_bytes: u64,
pub tier: String,
pub tags: Vec<String>,
pub checksum: String,
pub archived_at: chrono::DateTime<chrono::Utc>,
pub expires_at: Option<chrono::DateTime<chrono::Utc>>,
pub last_verified_at: Option<chrono::DateTime<chrono::Utc>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpArchiveStorageStats {
pub tier_usage: BTreeMap<String, AtpTierStats>,
pub total_archives: u32,
pub total_storage_bytes: u64,
pub available_storage_bytes: u64,
pub integrity_check_status: AtpIntegrityStatus,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpTierStats {
pub archive_count: u32,
pub usage_bytes: u64,
pub avg_access_latency_ms: f64,
pub cost_per_gb_month: f64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AtpIntegrityStatus {
pub last_check_at: chrono::DateTime<chrono::Utc>,
pub verified_archives: u32,
pub failed_archives: u32,
pub pending_verification: u32,
}
macro_rules! impl_atp_output {
($ty:ty, $summary:expr, $tsv:expr) => {
impl Outputtable for $ty {
fn human_format(&self) -> String {
$summary(self)
}
fn human_summary(&self) -> String {
self.human_format()
}
fn tsv_format(&self) -> String {
$tsv(self)
}
}
};
}
impl_atp_output!(
AtpCiOutput,
|output: &AtpCiOutput| format!(
"ATP CI {}: {} artifact(s), {} byte(s), success={}",
output.summary.operation,
output.summary.artifacts_processed,
output.summary.bytes_transferred,
output.summary.success
),
|output: &AtpCiOutput| format!(
"{}\t{}\t{}\t{}",
output.summary.operation,
output.summary.artifacts_processed,
output.summary.bytes_transferred,
output.summary.success
)
);
impl_atp_output!(
AtpDatasetOutput,
|output: &AtpDatasetOutput| format!(
"ATP dataset {}: {} dataset(s), {} byte(s), success={}",
output.summary.operation,
output.summary.datasets_processed,
output.summary.total_size_bytes,
output.summary.success
),
|output: &AtpDatasetOutput| format!(
"{}\t{}\t{}\t{}",
output.summary.operation,
output.summary.datasets_processed,
output.summary.total_size_bytes,
output.summary.success
)
);
impl_atp_output!(
AtpFuzzOutput,
|output: &AtpFuzzOutput| format!(
"ATP fuzz {}: target={}, {} case(s), {} byte(s), success={}",
output.summary.operation,
output.summary.target,
output.summary.test_cases_processed,
output.corpus_stats.total_size_bytes,
output.summary.success
),
|output: &AtpFuzzOutput| format!(
"{}\t{}\t{}\t{}\t{}",
output.summary.operation,
output.summary.target,
output.summary.test_cases_processed,
output.corpus_stats.total_size_bytes,
output.summary.success
)
);
impl_atp_output!(
AtpReleaseOutput,
|output: &AtpReleaseOutput| format!(
"ATP release {}: {} release(s), {} byte(s), success={}",
output.summary.operation,
output.summary.releases_processed,
output.summary.total_size_bytes,
output.summary.success
),
|output: &AtpReleaseOutput| format!(
"{}\t{}\t{}\t{}",
output.summary.operation,
output.summary.releases_processed,
output.summary.total_size_bytes,
output.summary.success
)
);
impl_atp_output!(
AtpArchiveOutput,
|output: &AtpArchiveOutput| format!(
"ATP archive {}: {} archive(s), {} byte(s), success={}",
output.summary.operation,
output.summary.archives_processed,
output.summary.total_size_bytes,
output.summary.success
),
|output: &AtpArchiveOutput| format!(
"{}\t{}\t{}\t{}",
output.summary.operation,
output.summary.archives_processed,
output.summary.total_size_bytes,
output.summary.success
)
);