Skip to main content

optirs_core/privacy/federated_privacy/
config.rs

1// Configuration structures for federated privacy algorithms
2//
3// # 0.3.2 changes
4//
5// * [`FederatedPrivacyConfig::validate`] was added (see the `validation`
6//   module) and is called from `FederatedPrivacyCoordinator::new`, so an
7//   invalid federation can no longer be constructed. Configurations that used
8//   to be accepted silently -- `target_epsilon: -1.0`, `noise_multiplier: 0.0`,
9//   `clients_per_round > total_clients` -- are now rejected.
10// * Two defaults were corrected because they advertised a guarantee that no
11//   code path delivered: `CommunicationPrivacyConfig::encryption_enabled` and
12//   `SecureAggregationConfig::aggregate_dp` now default to `false`, and
13//   `AmplificationConfig::multi_round_amplification` likewise. Setting any of
14//   them explicitly is refused by `validate()` with an error naming what is
15//   missing, rather than being ignored.
16// * **`FederatedPrivacyConfig::default()` raises `noise_multiplier` from the
17//   DP-SGD default of 1.1 to 4.0.** A federated round is one subsampled-Gaussian
18//   release over 10% of the federation, not one minibatch step: at sigma = 1.1
19//   the moments accountant charges 2.25 epsilon for the *first* round against a
20//   default budget of 1.0, so `FederatedPrivacyCoordinator::start_federated_round`
21//   failed closed before it had run once. This is a real behaviour change for
22//   anyone relying on the default -- rounds now succeed, and each costs about
23//   0.22 epsilon instead of being rejected. Callers who want the old multiplier
24//   must set `base_config.noise_multiplier` explicitly and accept that the
25//   default epsilon budget will not cover a single round.
26// * Duplicated configuration types were removed in favour of the ones the audited
27//   implementations in `privacy::federated` actually consume; see the `pub use`
28//   re-exports below.
29
30use super::super::DifferentialPrivacyConfig;
31use std::time::Duration;
32
33/// Federated privacy configuration
34#[derive(Debug, Clone)]
35pub struct FederatedPrivacyConfig {
36    /// Base differential privacy config
37    pub base_config: DifferentialPrivacyConfig,
38
39    /// Number of participating clients per round
40    pub clients_per_round: usize,
41
42    /// Total number of clients in federation
43    pub total_clients: usize,
44
45    /// Client sampling strategy
46    pub sampling_strategy: ClientSamplingStrategy,
47
48    /// Secure aggregation settings
49    pub secure_aggregation: SecureAggregationConfig,
50
51    /// Privacy amplification settings
52    pub amplification_config: AmplificationConfig,
53
54    /// Cross-device privacy settings
55    pub cross_device_config: CrossDeviceConfig,
56
57    /// Federated composition method
58    pub composition_method: FederatedCompositionMethod,
59
60    /// Trust model
61    pub trust_model: TrustModel,
62
63    /// Communication privacy
64    pub communication_privacy: CommunicationPrivacyConfig,
65}
66
67/// Client sampling strategies for federated learning
68#[derive(Debug, Clone, Copy)]
69pub enum ClientSamplingStrategy {
70    /// Uniform random sampling
71    UniformRandom,
72
73    /// Stratified sampling based on data distribution
74    Stratified,
75
76    /// Importance sampling based on client importance
77    ImportanceSampling,
78
79    /// Poisson sampling for theoretical guarantees
80    PoissonSampling,
81
82    /// Fair sampling ensuring client diversity
83    FairSampling,
84}
85
86/// Secure aggregation configuration.
87///
88/// This is a re-export of [`crate::privacy::federated::secure_aggregation::SecureAggregationConfig`],
89/// the configuration consumed by the audited Bonawitz implementation. Until
90/// 0.3.2 this module declared its own near-identical copy (same seven fields,
91/// minus `quantization_scale` and `max_update_magnitude`, plus a
92/// `SeedSharingMethod` that lacked the one variant that is actually
93/// implemented). Two configuration types for one protocol meant a federation
94/// could be configured through the copy and then be rejected -- or worse,
95/// silently reinterpreted -- by the real aggregator. There is now exactly one.
96pub use super::super::federated::secure_aggregation::{SecureAggregationConfig, SeedSharingMethod};
97
98/// Configuration types re-exported from the audited implementations in
99/// [`crate::privacy::federated`].
100///
101/// Until 0.3.2 this module declared its own copy of each of these. Every copy
102/// was either field-identical to the real one or a strict subset of it, so the
103/// only thing the duplication bought was two configuration surfaces that could
104/// drift -- and one of them (`StatisticalTestConfig`) had already drifted, using
105/// `significance_level` where the implementation reads `significancelevel`.
106pub use super::super::federated::byzantine_aggregation::{
107    ByzantineRobustConfig, ByzantineRobustMethod, ReputationSystemConfig, StatisticalTestConfig,
108    StatisticalTestType,
109};
110pub use super::super::federated::composition_analyzer::FederatedCompositionMethod;
111pub use super::super::federated::cross_device_manager::CrossDeviceConfig;
112
113/// Privacy amplification configuration
114///
115/// # Relationship to `privacy::differential_privacy::AmplificationConfig`
116///
117/// That type is the canonical one consumed by the audited
118/// [`crate::privacy::differential_privacy::PrivacyAmplificationAnalyzer`]; it
119/// carries only the two switches the bounds actually depend on. This type is the
120/// federated-configuration surface and additionally carries switches that are
121/// not implemented (see `validate`). Use the [`From`] impl below rather than
122/// constructing the canonical type by hand, so the two cannot drift.
123#[derive(Debug, Clone)]
124pub struct AmplificationConfig {
125    /// Enable privacy amplification analysis
126    pub enabled: bool,
127
128    /// Subsampling amplification factor
129    pub subsampling_factor: f64,
130
131    /// Shuffling amplification (if applicable)
132    pub shuffling_enabled: bool,
133
134    /// Compose the amplification benefit across rounds.
135    ///
136    /// **Not implemented**: amplification is recomputed per round and never
137    /// composed. `validate()` refuses a configuration that sets this. Defaults
138    /// to `false` since 0.3.2 (it previously defaulted to `true`).
139    pub multi_round_amplification: bool,
140
141    /// Heterogeneous client amplification
142    pub heterogeneous_amplification: bool,
143}
144
145/// Trust models for federated learning
146#[derive(Debug, Clone, Copy)]
147pub enum TrustModel {
148    /// Honest-but-curious clients
149    HonestButCurious,
150
151    /// Semi-honest with some malicious clients
152    SemiHonest,
153
154    /// Byzantine fault tolerance
155    Byzantine,
156
157    /// Fully malicious adversary
158    Malicious,
159}
160
161/// Communication privacy configuration
162///
163/// Every switch defaults to `false`/`None`: none of them is implemented, and
164/// `FederatedPrivacyConfig::validate` refuses a configuration that sets one.
165#[derive(Debug, Clone, Default)]
166pub struct CommunicationPrivacyConfig {
167    /// Encrypt communications.
168    ///
169    /// **Not implemented**: this crate performs no transport. `validate()`
170    /// refuses a configuration that sets this. Defaults to `false` since 0.3.2
171    /// (it previously defaulted to `true` and was never read).
172    pub encryption_enabled: bool,
173
174    /// Use anonymous communication channels
175    pub anonymous_channels: bool,
176
177    /// Add communication noise
178    pub communication_noise: bool,
179
180    /// Traffic analysis protection
181    pub traffic_analysis_protection: bool,
182
183    /// Advanced threat modeling configuration
184    pub threat_modeling: AdvancedThreatModelingConfig,
185
186    /// Cross-silo federated learning configuration
187    pub cross_silo_config: Option<CrossSiloFederatedConfig>,
188}
189
190/// Advanced threat modeling configuration for comprehensive security analysis
191#[derive(Debug, Clone, Default)]
192pub struct AdvancedThreatModelingConfig {
193    /// Enable advanced threat analysis
194    pub enabled: bool,
195
196    /// Adversarial capabilities modeling
197    pub adversarial_capabilities: AdversarialCapabilities,
198
199    /// Attack surface analysis
200    pub attack_surface_analysis: AttackSurfaceConfig,
201
202    /// Threat intelligence integration
203    pub threat_intelligence: ThreatIntelligenceConfig,
204
205    /// Risk assessment framework
206    pub risk_assessment: RiskAssessmentConfig,
207
208    /// Countermeasure effectiveness evaluation
209    pub countermeasure_evaluation: CountermeasureEvaluationConfig,
210}
211
212/// Adversarial capabilities in federated learning environments
213#[derive(Debug, Clone)]
214pub struct AdversarialCapabilities {
215    /// Computational resources available to adversary
216    pub computational_resources: ComputationalThreatLevel,
217
218    /// Network access and control capabilities
219    pub network_capabilities: NetworkThreatCapabilities,
220
221    /// Data access and manipulation capabilities
222    pub data_capabilities: DataThreatCapabilities,
223
224    /// Model and algorithm knowledge
225    pub algorithmic_knowledge: AlgorithmicKnowledgeLevel,
226
227    /// Collusion potential among malicious clients
228    pub collusion_potential: CollusionThreatLevel,
229
230    /// Persistence and adaptability of attacks
231    pub attack_persistence: AttackPersistenceLevel,
232}
233
234/// Attack surface configuration for comprehensive analysis
235#[derive(Debug, Clone, Default)]
236pub struct AttackSurfaceConfig {
237    /// Client-side attack vectors
238    pub client_attack_vectors: ClientAttackVectors,
239
240    /// Server-side attack vectors
241    pub server_attack_vectors: ServerAttackVectors,
242
243    /// Communication channel vulnerabilities
244    pub communication_vulnerabilities: CommunicationVulnerabilities,
245
246    /// Aggregation phase vulnerabilities
247    pub aggregation_vulnerabilities: AggregationVulnerabilities,
248
249    /// Privacy mechanism vulnerabilities
250    pub privacy_mechanism_vulnerabilities: PrivacyMechanismVulnerabilities,
251}
252
253/// Threat intelligence integration for real-time threat assessment
254#[derive(Debug, Clone, Default)]
255pub struct ThreatIntelligenceConfig {
256    /// Enable threat intelligence feeds
257    pub enabled: bool,
258
259    /// Real-time threat monitoring
260    pub real_time_monitoring: bool,
261
262    /// Threat signature database
263    pub signature_database: ThreatSignatureDatabase,
264
265    /// Anomaly detection for novel threats
266    pub anomaly_detection: AnomalyDetectionConfig,
267
268    /// Threat correlation and analysis
269    pub threat_correlation: ThreatCorrelationConfig,
270}
271
272/// Risk assessment framework for quantitative security analysis
273#[derive(Debug, Clone)]
274pub struct RiskAssessmentConfig {
275    /// Risk assessment methodology
276    pub methodology: RiskAssessmentMethodology,
277
278    /// Risk tolerance levels
279    pub risk_tolerance: RiskToleranceLevels,
280
281    /// Impact assessment criteria
282    pub impact_assessment: ImpactAssessmentCriteria,
283
284    /// Likelihood estimation methods
285    pub likelihood_estimation: LikelihoodEstimationMethods,
286
287    /// Risk mitigation strategies
288    pub mitigation_strategies: RiskMitigationStrategies,
289}
290
291/// Effectiveness metrics for countermeasure evaluation
292#[derive(Debug, Clone, Default)]
293pub struct EffectivenessMetrics {
294    /// Accuracy of threat detection
295    pub detection_accuracy: f64,
296    /// False positive rate
297    pub false_positive_rate: f64,
298    /// False negative rate
299    pub false_negative_rate: f64,
300    /// Response time metrics
301    pub response_times: Vec<f64>,
302}
303
304/// Cost-benefit analysis configuration
305#[derive(Debug, Clone, Default)]
306pub struct CostBenefitAnalysisConfig {
307    /// Implementation costs
308    pub implementation_costs: Vec<f64>,
309    /// Operational costs
310    pub operational_costs: Vec<f64>,
311    /// Benefit metrics
312    pub benefits: Vec<f64>,
313    /// ROI calculation methods
314    pub roi_methods: Vec<String>,
315}
316
317/// Dynamic adaptation configuration
318#[derive(Debug, Clone, Default)]
319pub struct DynamicAdaptationConfig {
320    /// Adaptation triggers
321    pub triggers: Vec<String>,
322    /// Adaptation strategies
323    pub strategies: Vec<String>,
324    /// Learning rate for adaptation
325    pub learning_rate: f64,
326    /// Minimum adaptation threshold
327    pub min_threshold: f64,
328}
329
330/// Countermeasure optimization configuration
331#[derive(Debug, Clone, Default)]
332pub struct CountermeasureOptimizationConfig {
333    /// Optimization algorithms
334    pub algorithms: Vec<String>,
335    /// Target metrics
336    pub target_metrics: Vec<String>,
337    /// Constraints
338    pub constraints: Vec<String>,
339    /// Optimization frequency
340    pub frequency: String,
341}
342
343/// Countermeasure effectiveness evaluation framework
344#[derive(Debug, Clone, Default)]
345pub struct CountermeasureEvaluationConfig {
346    /// Effectiveness metrics
347    pub effectiveness_metrics: EffectivenessMetrics,
348
349    /// Cost-benefit analysis
350    pub cost_benefit_analysis: CostBenefitAnalysisConfig,
351
352    /// Dynamic adaptation based on threat landscape
353    pub dynamic_adaptation: DynamicAdaptationConfig,
354
355    /// Countermeasure optimization
356    pub optimization: CountermeasureOptimizationConfig,
357}
358
359/// Data marketplace configuration
360#[derive(Debug, Clone)]
361pub struct DataMarketplaceConfig {
362    /// Enable data marketplace
363    pub enabled: bool,
364    /// Pricing models
365    pub pricing_models: Vec<String>,
366    /// Quality metrics
367    pub quality_metrics: Vec<String>,
368    /// Access controls
369    pub access_controls: Vec<String>,
370}
371
372/// Regulatory compliance configuration
373#[derive(Debug, Clone)]
374pub struct RegulatoryComplianceConfig {
375    /// Applicable regulations
376    pub regulations: Vec<String>,
377    /// Compliance checks
378    pub compliance_checks: Vec<String>,
379    /// Reporting requirements
380    pub reporting_requirements: Vec<String>,
381    /// Audit trails
382    pub audit_trails: bool,
383}
384
385/// Audit and accountability configuration
386#[derive(Debug, Clone)]
387pub struct AuditAccountabilityConfig {
388    /// Audit logging
389    pub audit_logging: bool,
390    /// Accountability mechanisms
391    pub accountability_mechanisms: Vec<String>,
392    /// Verification methods
393    pub verification_methods: Vec<String>,
394    /// Compliance tracking
395    pub compliance_tracking: bool,
396}
397
398/// Trust establishment methods
399#[derive(Debug, Clone)]
400pub struct TrustEstablishmentMethods {
401    /// Certification authorities
402    pub certification_authorities: Vec<String>,
403    /// Reputation systems
404    pub reputation_systems: Vec<String>,
405    /// Verification protocols
406    pub verification_protocols: Vec<String>,
407}
408
409/// Trust verification mechanisms
410#[derive(Debug, Clone)]
411pub struct TrustVerificationMechanisms {
412    /// Verification methods
413    pub methods: Vec<String>,
414    /// Validation frequency
415    pub frequency: String,
416    /// Trust thresholds
417    pub thresholds: Vec<f64>,
418}
419
420/// Organization reputation system
421#[derive(Debug, Clone)]
422pub struct OrganizationReputationSystem {
423    /// Reputation metrics
424    pub metrics: Vec<String>,
425    /// Scoring algorithms
426    pub scoring_algorithms: Vec<String>,
427    /// Update frequencies
428    pub update_frequencies: Vec<String>,
429}
430
431/// Trust lifecycle management
432#[derive(Debug, Clone)]
433pub struct TrustLifecycleManagement {
434    /// Trust establishment phases
435    pub establishment_phases: Vec<String>,
436    /// Trust maintenance procedures
437    pub maintenance_procedures: Vec<String>,
438    /// Trust recovery mechanisms
439    pub recovery_mechanisms: Vec<String>,
440    /// Trust degradation triggers
441    pub degradation_triggers: Vec<String>,
442}
443
444/// Data governance configuration
445#[derive(Debug, Clone)]
446pub struct DataGovernanceConfig {
447    /// Data classification
448    pub classification: Vec<String>,
449    /// Access policies
450    pub access_policies: Vec<String>,
451    /// Quality standards
452    pub quality_standards: Vec<String>,
453    /// Retention policies
454    pub retention_policies: Vec<String>,
455}
456
457/// Privacy agreement configuration
458#[derive(Debug, Clone)]
459pub struct PrivacyAgreementConfig {
460    /// Agreement templates
461    pub templates: Vec<String>,
462    /// Negotiation protocols
463    pub negotiation_protocols: Vec<String>,
464    /// Enforcement mechanisms
465    pub enforcement_mechanisms: Vec<String>,
466    /// Compliance monitoring
467    pub compliance_monitoring: bool,
468}
469
470/// Cross-silo federated learning configuration for enterprise scenarios
471#[derive(Debug, Clone)]
472pub struct CrossSiloFederatedConfig {
473    /// Enable cross-silo federated learning
474    pub enabled: bool,
475
476    /// Organization trust levels and relationships
477    pub organization_trust: OrganizationTrustConfig,
478
479    /// Data governance and compliance
480    pub data_governance: DataGovernanceConfig,
481
482    /// Inter-organizational privacy agreements
483    pub privacy_agreements: PrivacyAgreementConfig,
484
485    /// Federated data marketplaces
486    pub data_marketplace: DataMarketplaceConfig,
487
488    /// Regulatory compliance framework
489    pub regulatory_compliance: RegulatoryComplianceConfig,
490
491    /// Audit and accountability mechanisms
492    pub audit_accountability: AuditAccountabilityConfig,
493}
494
495/// Organization trust configuration for cross-silo scenarios
496#[derive(Debug, Clone)]
497pub struct OrganizationTrustConfig {
498    /// Trust establishment methods
499    pub trust_establishment: TrustEstablishmentMethods,
500
501    /// Trust verification mechanisms
502    pub trust_verification: TrustVerificationMechanisms,
503
504    /// Reputation systems for organizations
505    pub reputation_system: OrganizationReputationSystem,
506
507    /// Trust degradation and recovery
508    pub trust_lifecycle: TrustLifecycleManagement,
509}
510
511// Supporting enums and types for the advanced configurations
512
513#[derive(Debug, Clone, Copy)]
514pub enum ComputationalThreatLevel {
515    Limited,     // Individual attacker with limited resources
516    Moderate,    // Small organization or group
517    Substantial, // Large organization or nation-state
518    Unlimited,   // Theoretical unlimited computational resources
519}
520
521#[derive(Debug, Clone, Default)]
522pub struct NetworkThreatCapabilities {
523    /// Can intercept communications
524    pub can_intercept: bool,
525    /// Can modify communications
526    pub can_modify: bool,
527    /// Can inject malicious communications
528    pub can_inject: bool,
529    /// Can perform traffic analysis
530    pub can_analyze_traffic: bool,
531    /// Can conduct timing attacks
532    pub can_timing_attack: bool,
533    /// Can perform network-level denial of service
534    pub can_dos: bool,
535}
536
537#[derive(Debug, Clone, Default)]
538pub struct DataThreatCapabilities {
539    /// Can access training data
540    pub can_access_training_data: bool,
541    /// Can modify training data
542    pub can_modify_training_data: bool,
543    /// Can inject poisoned data
544    pub can_inject_poisoned_data: bool,
545    /// Can perform membership inference
546    pub can_membership_inference: bool,
547    /// Can extract model parameters
548    pub can_extract_parameters: bool,
549    /// Can perform gradient inversion
550    pub can_gradient_inversion: bool,
551}
552
553#[derive(Debug, Clone, Copy)]
554pub enum AlgorithmicKnowledgeLevel {
555    BlackBox, // No knowledge of algorithms
556    GrayBox,  // Partial knowledge
557    WhiteBox, // Full algorithm knowledge
558    Adaptive, // Can adapt based on observations
559}
560
561#[derive(Debug, Clone, Copy)]
562pub enum CollusionThreatLevel {
563    None,        // No collusion
564    Limited,     // Small number of colluding clients
565    Substantial, // Significant fraction colluding
566    Majority,    // Majority collusion attack
567}
568
569#[derive(Debug, Clone, Copy)]
570pub enum AttackPersistenceLevel {
571    OneTime,      // Single attack attempt
572    Intermittent, // Sporadic attacks
573    Persistent,   // Continuous attack pressure
574    Adaptive,     // Evolving attack strategies
575}
576
577#[derive(Debug, Clone, Default)]
578pub struct ClientAttackVectors {
579    /// Model poisoning attacks
580    pub model_poisoning: bool,
581    /// Data poisoning attacks
582    pub data_poisoning: bool,
583    /// Gradient manipulation
584    pub gradient_manipulation: bool,
585    /// Local model extraction
586    pub local_model_extraction: bool,
587    /// Client impersonation
588    pub client_impersonation: bool,
589}
590
591#[derive(Debug, Clone, Default)]
592pub struct ServerAttackVectors {
593    /// Server compromise scenarios
594    pub server_compromise: bool,
595    /// Malicious aggregation
596    pub malicious_aggregation: bool,
597    /// Model backdoor injection
598    pub backdoor_injection: bool,
599    /// Privacy budget manipulation
600    pub budget_manipulation: bool,
601    /// Client discrimination
602    pub client_discrimination: bool,
603}
604
605#[derive(Debug, Clone, Default)]
606pub struct CommunicationVulnerabilities {
607    /// Man-in-the-middle attacks
608    pub mitm_attacks: bool,
609    /// Eavesdropping vulnerabilities
610    pub eavesdropping: bool,
611    /// Replay attacks
612    pub replay_attacks: bool,
613    /// Message injection
614    pub message_injection: bool,
615    /// Communication timing analysis
616    pub timing_analysis: bool,
617}
618
619#[derive(Debug, Clone, Default)]
620pub struct AggregationVulnerabilities {
621    /// Secure aggregation bypass
622    pub secure_aggregation_bypass: bool,
623    /// Aggregation manipulation
624    pub aggregation_manipulation: bool,
625    /// Statistical attacks on aggregation
626    pub statistical_attacks: bool,
627    /// Reconstruction attacks
628    pub reconstruction_attacks: bool,
629}
630
631#[derive(Debug, Clone, Default)]
632pub struct PrivacyMechanismVulnerabilities {
633    /// Differential privacy parameter inference
634    pub dp_parameter_inference: bool,
635    /// Privacy budget exhaustion attacks
636    pub budget_exhaustion: bool,
637    /// Composition attack vulnerabilities
638    pub composition_attacks: bool,
639    /// Auxiliary information attacks
640    pub auxiliary_info_attacks: bool,
641}
642
643#[derive(Debug, Clone, Default)]
644pub struct ThreatSignatureDatabase {
645    /// Known attack patterns
646    pub attack_patterns: Vec<AttackPattern>,
647    /// Threat actor profiles
648    pub threat_actors: Vec<ThreatActorProfile>,
649    /// Vulnerability signatures
650    pub vulnerability_signatures: Vec<VulnerabilitySignature>,
651}
652
653#[derive(Debug, Clone)]
654pub struct AttackPattern {
655    /// Pattern identifier
656    pub id: String,
657    /// Attack description
658    pub description: String,
659    /// Attack indicators
660    pub indicators: Vec<AttackIndicator>,
661    /// Severity level
662    pub severity: ThreatSeverity,
663    /// Mitigation recommendations
664    pub mitigations: Vec<String>,
665}
666
667#[derive(Debug, Clone)]
668pub struct ThreatActorProfile {
669    /// Actor identifier
670    pub id: String,
671    /// Actor capabilities
672    pub capabilities: AdversarialCapabilities,
673    /// Known attack methods
674    pub attack_methods: Vec<String>,
675    /// Targeting preferences
676    pub targeting_preferences: Vec<String>,
677}
678
679#[derive(Debug, Clone)]
680pub struct VulnerabilitySignature {
681    /// Vulnerability identifier
682    pub id: String,
683    /// Affected components
684    pub affected_components: Vec<String>,
685    /// Exploitation indicators
686    pub exploitation_indicators: Vec<String>,
687    /// Severity score
688    pub severity_score: f64,
689}
690
691#[derive(Debug, Clone)]
692pub struct AttackIndicator {
693    /// Indicator type
694    pub indicator_type: IndicatorType,
695    /// Indicator value or pattern
696    pub value: String,
697    /// Confidence level
698    pub confidence: f64,
699}
700
701#[derive(Debug, Clone, Copy)]
702pub enum IndicatorType {
703    NetworkTraffic,
704    GradientPattern,
705    ModelBehavior,
706    PerformanceAnomaly,
707    CommunicationPattern,
708}
709
710#[derive(Debug, Clone, Copy)]
711pub enum ThreatSeverity {
712    Low,
713    Medium,
714    High,
715    Critical,
716}
717
718#[derive(Debug, Clone)]
719pub struct AnomalyDetectionConfig {
720    /// Detection algorithms
721    pub algorithms: Vec<AnomalyDetectionAlgorithm>,
722    /// Detection thresholds
723    pub thresholds: AnomalyThresholds,
724    /// Response actions
725    pub response_actions: AnomalyResponseActions,
726}
727
728#[derive(Debug, Clone, Copy)]
729pub enum AnomalyDetectionAlgorithm {
730    StatisticalBaseline,
731    MachineLearningBased,
732    DeepLearningBased,
733    EnsembleMethods,
734}
735
736#[derive(Debug, Clone)]
737pub struct AnomalyThresholds {
738    /// Statistical significance threshold
739    pub statistical_threshold: f64,
740    /// Confidence threshold for ML-based detection
741    pub confidence_threshold: f64,
742    /// False positive tolerance
743    pub false_positive_rate: f64,
744}
745
746#[derive(Debug, Clone)]
747pub struct AnomalyResponseActions {
748    /// Alert generation
749    pub alert_generation: bool,
750    /// Automatic quarantine
751    pub automatic_quarantine: bool,
752    /// Enhanced monitoring
753    pub enhanced_monitoring: bool,
754    /// Incident escalation
755    pub incident_escalation: bool,
756}
757
758#[derive(Debug, Clone)]
759pub struct ThreatCorrelationConfig {
760    /// Correlation algorithms
761    pub correlation_algorithms: Vec<CorrelationAlgorithm>,
762    /// Temporal correlation window
763    pub temporal_window: Duration,
764    /// Cross-client correlation analysis
765    pub cross_client_correlation: bool,
766}
767
768#[derive(Debug, Clone, Copy)]
769pub enum CorrelationAlgorithm {
770    TemporalPatternMatching,
771    BehavioralProfiling,
772    GraphBasedAnalysis,
773    StatisticalCorrelation,
774}
775
776#[derive(Debug, Clone, Copy)]
777pub enum RiskAssessmentMethodology {
778    QualitativeAssessment,
779    QuantitativeAssessment,
780    SemiQuantitativeAssessment,
781    ScenarioBasedAssessment,
782}
783
784#[derive(Debug, Clone)]
785pub struct RiskToleranceLevels {
786    /// Privacy risk tolerance
787    pub privacy_risk_tolerance: f64,
788    /// Security risk tolerance
789    pub security_risk_tolerance: f64,
790    /// Utility risk tolerance
791    pub utility_risk_tolerance: f64,
792    /// Operational risk tolerance
793    pub operational_risk_tolerance: f64,
794}
795
796#[derive(Debug, Clone)]
797pub struct ImpactAssessmentCriteria {
798    /// Data confidentiality impact
799    pub confidentiality_impact: ImpactLevel,
800    /// Model integrity impact
801    pub integrity_impact: ImpactLevel,
802    /// Service availability impact
803    pub availability_impact: ImpactLevel,
804    /// Regulatory compliance impact
805    pub compliance_impact: ImpactLevel,
806}
807
808#[derive(Debug, Clone, Copy)]
809pub enum ImpactLevel {
810    Low,
811    Medium,
812    High,
813    Critical,
814}
815
816#[derive(Debug, Clone)]
817pub struct LikelihoodEstimationMethods {
818    /// Historical data analysis
819    pub historical_analysis: bool,
820    /// Expert judgment
821    pub expert_judgment: bool,
822    /// Threat modeling
823    pub threat_modeling: bool,
824    /// Simulation-based estimation
825    pub simulation_based: bool,
826}
827
828#[derive(Debug, Clone, Default)]
829pub struct RiskMitigationStrategies {
830    /// Risk avoidance strategies
831    pub avoidance_strategies: Vec<String>,
832    /// Risk mitigation controls
833    pub mitigation_controls: Vec<String>,
834    /// Risk transfer mechanisms
835    pub transfer_mechanisms: Vec<String>,
836    /// Risk acceptance criteria
837    pub acceptance_criteria: Vec<String>,
838}
839
840/// Personalization strategies for federated learning
841#[derive(Debug, Clone)]
842pub enum PersonalizationStrategy {
843    /// No personalization (standard federated learning)
844    None,
845
846    /// Fine-tuning on local data
847    FineTuning { local_epochs: usize },
848
849    /// Meta-learning based personalization (MAML)
850    MetaLearning { inner_lr: f64, outer_lr: f64 },
851
852    /// Clustered federated learning
853    ClusteredFL { num_clusters: usize },
854
855    /// Federated multi-task learning
856    MultiTask { task_similarity_threshold: f64 },
857
858    /// Personalized layers (some layers personalized, others shared)
859    PersonalizedLayers { personal_layer_indices: Vec<usize> },
860
861    /// Model interpolation
862    ModelInterpolation { interpolation_weight: f64 },
863
864    /// Adaptive personalization
865    Adaptive { adaptation_rate: f64 },
866}
867
868/// Communication compression strategies
869#[derive(Debug, Clone, Copy)]
870pub enum CompressionStrategy {
871    /// No compression
872    None,
873
874    /// Quantization with specified bits
875    Quantization { bits: u8 },
876
877    /// Top-K sparsification
878    TopK { k: usize },
879
880    /// Random sparsification
881    RandomSparsification { sparsity_ratio: f64 },
882
883    /// Error feedback compression
884    ErrorFeedback,
885
886    /// Gradient compression with memory
887    GradientMemory { memory_factor: f64 },
888
889    /// Low-rank approximation
890    LowRank { rank: usize },
891
892    /// Structured compression
893    Structured { structure_type: StructureType },
894}
895
896/// Structure types for compression
897#[derive(Debug, Clone, Copy)]
898pub enum StructureType {
899    Circulant,
900    Toeplitz,
901    Hankel,
902    BlockDiagonal,
903}
904
905/// Continual learning strategies in federated settings
906#[derive(Debug, Clone, Copy)]
907pub enum ContinualLearningStrategy {
908    /// Elastic Weight Consolidation (EWC)
909    EWC { lambda: f64 },
910
911    /// Memory-Aware Synapses (MAS)
912    MAS { lambda: f64 },
913
914    /// Progressive Neural Networks
915    Progressive,
916
917    /// Learning without Forgetting (LwF)
918    LwF { distillation_temperature: f64 },
919
920    /// Gradient Episodic Memory (GEM)
921    GEM { memory_size: usize },
922
923    /// Federated Continual Learning with Memory
924    FedContinual { memory_budget: usize },
925
926    /// Task-agnostic continual learning
927    TaskAgnostic,
928}
929
930/// Personalization configuration
931#[derive(Debug, Clone)]
932pub struct PersonalizationConfig {
933    /// Personalization strategy
934    pub strategy: PersonalizationStrategy,
935
936    /// Local adaptation parameters
937    pub local_adaptation: LocalAdaptationConfig,
938
939    /// Clustering parameters for clustered FL
940    pub clustering: ClusteringConfig,
941
942    /// Meta-learning parameters
943    pub meta_learning: MetaLearningConfig,
944
945    /// Privacy-preserving personalization
946    pub privacy_preserving: bool,
947}
948
949/// Adaptive privacy budget configuration
950#[derive(Debug, Clone)]
951pub struct AdaptiveBudgetConfig {
952    /// Enable adaptive budgeting
953    pub enabled: bool,
954
955    /// Budget allocation strategy
956    pub allocation_strategy: BudgetAllocationStrategy,
957
958    /// Dynamic privacy parameters
959    pub dynamic_privacy: DynamicPrivacyConfig,
960
961    /// Client importance weighting
962    pub importance_weighting: bool,
963
964    /// Contextual privacy adjustment
965    pub contextual_adjustment: ContextualAdjustmentConfig,
966}
967
968/// Communication efficiency configuration
969#[derive(Debug, Clone)]
970pub struct CommunicationConfig {
971    /// Compression strategy
972    pub compression: CompressionStrategy,
973
974    /// Lazy aggregation settings
975    pub lazy_aggregation: LazyAggregationConfig,
976
977    /// Federated dropout settings
978    pub federated_dropout: FederatedDropoutConfig,
979
980    /// Asynchronous update settings
981    pub async_updates: AsyncUpdateConfig,
982
983    /// Bandwidth adaptation
984    pub bandwidth_adaptation: BandwidthAdaptationConfig,
985}
986
987/// Continual learning configuration
988#[derive(Debug, Clone)]
989pub struct ContinualLearningConfig {
990    /// Continual learning strategy
991    pub strategy: ContinualLearningStrategy,
992
993    /// Memory management settings
994    pub memory_management: MemoryManagementConfig,
995
996    /// Task detection settings
997    pub task_detection: TaskDetectionConfig,
998
999    /// Knowledge transfer settings
1000    pub knowledge_transfer: KnowledgeTransferConfig,
1001
1002    /// Catastrophic forgetting prevention
1003    pub forgetting_prevention: ForgettingPreventionConfig,
1004}
1005
1006// Supporting configuration structures
1007
1008/// Local adaptation configuration
1009#[derive(Debug, Clone)]
1010pub struct LocalAdaptationConfig {
1011    pub adaptation_rate: f64,
1012    pub local_epochs: usize,
1013    pub adaptation_frequency: usize,
1014    pub adaptation_method: AdaptationMethod,
1015    pub regularization_strength: f64,
1016}
1017
1018#[derive(Debug, Clone, Copy)]
1019pub enum AdaptationMethod {
1020    FineTuning,
1021    FeatureExtraction,
1022    LayerWiseAdaptation,
1023    AttentionBasedAdaptation,
1024}
1025
1026/// Clustering configuration
1027#[derive(Debug, Clone)]
1028pub struct ClusteringConfig {
1029    pub num_clusters: usize,
1030    pub clustering_method: ClusteringMethod,
1031    pub similarity_metric: SimilarityMetric,
1032    pub cluster_update_frequency: usize,
1033    pub privacy_preserving_clustering: bool,
1034}
1035
1036#[derive(Debug, Clone, Copy)]
1037pub enum ClusteringMethod {
1038    KMeans,
1039    DBSCAN,
1040    AgglomerativeClustering,
1041    SpectralClustering,
1042    PrivacyPreservingKMeans,
1043}
1044
1045#[derive(Debug, Clone, Copy)]
1046pub enum SimilarityMetric {
1047    CosineSimilarity,
1048    EuclideanDistance,
1049    ModelParameters,
1050    GradientSimilarity,
1051    LossLandscape,
1052}
1053
1054/// Meta-learning configuration
1055#[derive(Debug, Clone)]
1056pub struct MetaLearningConfig {
1057    pub inner_learning_rate: f64,
1058    pub outer_learning_rate: f64,
1059    pub inner_steps: usize,
1060    pub meta_batch_size: usize,
1061    pub adaptation_method: MetaAdaptationMethod,
1062}
1063
1064#[derive(Debug, Clone, Copy)]
1065pub enum MetaAdaptationMethod {
1066    MAML,
1067    Reptile,
1068    ProtoNets,
1069    RelationNets,
1070    FOMAML,
1071}
1072
1073/// Budget allocation strategy
1074#[derive(Debug, Clone, Copy)]
1075pub enum BudgetAllocationStrategy {
1076    Uniform,
1077    ProportionalToData,
1078    ProportionalToParticipation,
1079    UtilityBased,
1080    FairnessAware,
1081    AdaptiveAllocation,
1082}
1083
1084/// Dynamic privacy configuration
1085#[derive(Debug, Clone)]
1086pub struct DynamicPrivacyConfig {
1087    pub enabled: bool,
1088    pub adaptation_frequency: usize,
1089    pub privacy_sensitivity: f64,
1090    pub utility_weight: f64,
1091    pub fairness_weight: f64,
1092}
1093
1094/// Contextual adjustment configuration
1095#[derive(Debug, Clone)]
1096pub struct ContextualAdjustmentConfig {
1097    pub enabled: bool,
1098    pub context_factors: Vec<ContextFactor>,
1099    pub adjustment_sensitivity: f64,
1100    pub temporal_adaptation: bool,
1101}
1102
1103#[derive(Debug, Clone, Copy)]
1104pub enum ContextFactor {
1105    DataSensitivity,
1106    ClientTrustLevel,
1107    NetworkConditions,
1108    ModelAccuracy,
1109    ParticipationHistory,
1110}
1111
1112/// Lazy aggregation configuration
1113#[derive(Debug, Clone)]
1114pub struct LazyAggregationConfig {
1115    pub enabled: bool,
1116    pub aggregation_threshold: f64,
1117    pub staleness_tolerance: usize,
1118    pub gradient_similarity_threshold: f64,
1119}
1120
1121/// Federated dropout configuration
1122#[derive(Debug, Clone)]
1123pub struct FederatedDropoutConfig {
1124    pub enabled: bool,
1125    pub dropout_probability: f64,
1126    pub adaptive_dropout: bool,
1127    pub importance_sampling: bool,
1128}
1129
1130/// Asynchronous update configuration
1131#[derive(Debug, Clone)]
1132pub struct AsyncUpdateConfig {
1133    pub enabled: bool,
1134    pub staleness_threshold: usize,
1135    pub mixing_coefficient: f64,
1136    pub buffering_strategy: BufferingStrategy,
1137}
1138
1139#[derive(Debug, Clone, Copy)]
1140pub enum BufferingStrategy {
1141    FIFO,
1142    LIFO,
1143    PriorityBased,
1144    AdaptiveMixing,
1145}
1146
1147/// Bandwidth adaptation configuration
1148#[derive(Debug, Clone, Default)]
1149pub struct BandwidthAdaptationConfig {
1150    pub enabled: bool,
1151    pub compression_adaptation: bool,
1152    pub transmission_scheduling: bool,
1153    pub quality_of_service: QoSConfig,
1154}
1155
1156/// Quality of Service configuration
1157#[derive(Debug, Clone)]
1158pub struct QoSConfig {
1159    pub priority_levels: usize,
1160    pub latency_targets: Vec<f64>,
1161    pub throughput_targets: Vec<f64>,
1162    pub fairness_constraints: bool,
1163}
1164
1165/// Memory management configuration
1166#[derive(Debug, Clone)]
1167pub struct MemoryManagementConfig {
1168    pub memory_budget: usize,
1169    pub eviction_strategy: EvictionStrategy,
1170    pub compression_enabled: bool,
1171    pub memory_adaptation: bool,
1172}
1173
1174#[derive(Debug, Clone, Copy)]
1175pub enum EvictionStrategy {
1176    LRU,
1177    LFU,
1178    FIFO,
1179    ImportanceBased,
1180    TemporalDecay,
1181}
1182
1183/// Task detection configuration
1184#[derive(Debug, Clone)]
1185pub struct TaskDetectionConfig {
1186    pub enabled: bool,
1187    pub detection_method: TaskDetectionMethod,
1188    pub sensitivity_threshold: f64,
1189    pub adaptation_delay: usize,
1190}
1191
1192#[derive(Debug, Clone, Copy)]
1193pub enum TaskDetectionMethod {
1194    GradientBased,
1195    LossBased,
1196    StatisticalTest,
1197    ChangePointDetection,
1198    EnsembleMethods,
1199}
1200
1201/// Knowledge transfer configuration
1202#[derive(Debug, Clone)]
1203pub struct KnowledgeTransferConfig {
1204    pub transfer_method: KnowledgeTransferMethod,
1205    pub transfer_strength: f64,
1206    pub selective_transfer: bool,
1207    pub privacy_preserving: bool,
1208}
1209
1210#[derive(Debug, Clone, Copy)]
1211pub enum KnowledgeTransferMethod {
1212    ParameterTransfer,
1213    FeatureTransfer,
1214    AttentionTransfer,
1215    DistillationBased,
1216    GradientBased,
1217}
1218
1219/// Forgetting prevention configuration
1220#[derive(Debug, Clone)]
1221pub struct ForgettingPreventionConfig {
1222    pub method: ForgettingPreventionMethod,
1223    pub regularization_strength: f64,
1224    pub memory_replay_ratio: f64,
1225    pub importance_estimation: ImportanceEstimationMethod,
1226}
1227
1228#[derive(Debug, Clone, Copy)]
1229pub enum ForgettingPreventionMethod {
1230    EWC,
1231    MAS,
1232    PackNet,
1233    ProgressiveNets,
1234    MemoryReplay,
1235}
1236
1237#[derive(Debug, Clone, Copy)]
1238pub enum ImportanceEstimationMethod {
1239    FisherInformation,
1240    GradientNorm,
1241    PathIntegral,
1242    AttentionWeights,
1243}
1244
1245#[derive(Debug, Clone)]
1246pub struct PrivacyLevel {
1247    pub name: String,
1248    pub epsilon: f64,
1249    pub delta: f64,
1250    pub scope: PrivacyScope,
1251}
1252
1253#[derive(Debug, Clone, Copy)]
1254pub enum PrivacyScope {
1255    Individual,
1256    Group,
1257    Organization,
1258    Global,
1259}
1260
1261// Default implementations for configurations
1262
1263impl Default for FederatedPrivacyConfig {
1264    fn default() -> Self {
1265        Self {
1266            // A federated round is one subsampled-Gaussian release over a cohort
1267            // of `clients_per_round / total_clients` = 10% of the federation, not
1268            // one DP-SGD minibatch step. At the DP-SGD default noise multiplier
1269            // of 1.1 the moments accountant charges 2.25 epsilon for the *first*
1270            // round -- more than the whole default budget of 1.0 -- so
1271            // `FederatedPrivacyCoordinator::start_federated_round` failed closed
1272            // before it had run once. 4.0 leaves headroom for a realistic number
1273            // of rounds (roughly 0.22 epsilon for round one, 0.35 after five) at
1274            // the same 10% sampling rate.
1275            base_config: DifferentialPrivacyConfig {
1276                noise_multiplier: 4.0,
1277                ..DifferentialPrivacyConfig::default()
1278            },
1279            clients_per_round: 100,
1280            total_clients: 1000,
1281            sampling_strategy: ClientSamplingStrategy::UniformRandom,
1282            // The protocol defaults to `enabled: true`; a federation that has
1283            // not wired up per-client key registration must not silently claim
1284            // masked aggregation, so the federated default keeps it off.
1285            secure_aggregation: SecureAggregationConfig {
1286                enabled: false,
1287                ..SecureAggregationConfig::default()
1288            },
1289            amplification_config: AmplificationConfig::default(),
1290            cross_device_config: CrossDeviceConfig::default(),
1291            composition_method: FederatedCompositionMethod::FederatedMomentsAccountant,
1292            trust_model: TrustModel::HonestButCurious,
1293            communication_privacy: CommunicationPrivacyConfig::default(),
1294        }
1295    }
1296}
1297
1298impl Default for AmplificationConfig {
1299    fn default() -> Self {
1300        Self {
1301            enabled: true,
1302            subsampling_factor: 1.0,
1303            shuffling_enabled: false,
1304            multi_round_amplification: false,
1305            heterogeneous_amplification: false,
1306        }
1307    }
1308}
1309
1310impl Default for AdversarialCapabilities {
1311    fn default() -> Self {
1312        Self {
1313            computational_resources: ComputationalThreatLevel::Limited,
1314            network_capabilities: NetworkThreatCapabilities::default(),
1315            data_capabilities: DataThreatCapabilities::default(),
1316            algorithmic_knowledge: AlgorithmicKnowledgeLevel::BlackBox,
1317            collusion_potential: CollusionThreatLevel::None,
1318            attack_persistence: AttackPersistenceLevel::OneTime,
1319        }
1320    }
1321}
1322
1323impl Default for AnomalyDetectionConfig {
1324    fn default() -> Self {
1325        Self {
1326            algorithms: vec![AnomalyDetectionAlgorithm::StatisticalBaseline],
1327            thresholds: AnomalyThresholds::default(),
1328            response_actions: AnomalyResponseActions::default(),
1329        }
1330    }
1331}
1332
1333impl Default for AnomalyThresholds {
1334    fn default() -> Self {
1335        Self {
1336            statistical_threshold: 0.95,
1337            confidence_threshold: 0.8,
1338            false_positive_rate: 0.05,
1339        }
1340    }
1341}
1342
1343impl Default for AnomalyResponseActions {
1344    fn default() -> Self {
1345        Self {
1346            alert_generation: true,
1347            automatic_quarantine: false,
1348            enhanced_monitoring: true,
1349            incident_escalation: false,
1350        }
1351    }
1352}
1353
1354impl Default for ThreatCorrelationConfig {
1355    fn default() -> Self {
1356        Self {
1357            correlation_algorithms: vec![CorrelationAlgorithm::StatisticalCorrelation],
1358            temporal_window: Duration::from_secs(3600), // 1 hour
1359            cross_client_correlation: false,
1360        }
1361    }
1362}
1363
1364impl Default for RiskAssessmentConfig {
1365    fn default() -> Self {
1366        Self {
1367            methodology: RiskAssessmentMethodology::QualitativeAssessment,
1368            risk_tolerance: RiskToleranceLevels::default(),
1369            impact_assessment: ImpactAssessmentCriteria::default(),
1370            likelihood_estimation: LikelihoodEstimationMethods::default(),
1371            mitigation_strategies: RiskMitigationStrategies::default(),
1372        }
1373    }
1374}
1375
1376impl Default for RiskToleranceLevels {
1377    fn default() -> Self {
1378        Self {
1379            privacy_risk_tolerance: 0.1,
1380            security_risk_tolerance: 0.05,
1381            utility_risk_tolerance: 0.2,
1382            operational_risk_tolerance: 0.15,
1383        }
1384    }
1385}
1386
1387impl Default for ImpactAssessmentCriteria {
1388    fn default() -> Self {
1389        Self {
1390            confidentiality_impact: ImpactLevel::Medium,
1391            integrity_impact: ImpactLevel::High,
1392            availability_impact: ImpactLevel::Medium,
1393            compliance_impact: ImpactLevel::High,
1394        }
1395    }
1396}
1397
1398impl Default for LikelihoodEstimationMethods {
1399    fn default() -> Self {
1400        Self {
1401            historical_analysis: true,
1402            expert_judgment: true,
1403            threat_modeling: false,
1404            simulation_based: false,
1405        }
1406    }
1407}
1408
1409impl Default for LocalAdaptationConfig {
1410    fn default() -> Self {
1411        Self {
1412            adaptation_rate: 0.01,
1413            local_epochs: 1,
1414            adaptation_frequency: 1,
1415            adaptation_method: AdaptationMethod::FineTuning,
1416            regularization_strength: 0.01,
1417        }
1418    }
1419}
1420
1421impl Default for ClusteringConfig {
1422    fn default() -> Self {
1423        Self {
1424            num_clusters: 5,
1425            clustering_method: ClusteringMethod::KMeans,
1426            similarity_metric: SimilarityMetric::CosineSimilarity,
1427            cluster_update_frequency: 10,
1428            privacy_preserving_clustering: false,
1429        }
1430    }
1431}
1432
1433impl Default for MetaLearningConfig {
1434    fn default() -> Self {
1435        Self {
1436            inner_learning_rate: 0.01,
1437            outer_learning_rate: 0.001,
1438            inner_steps: 5,
1439            meta_batch_size: 32,
1440            adaptation_method: MetaAdaptationMethod::MAML,
1441        }
1442    }
1443}
1444
1445impl Default for DynamicPrivacyConfig {
1446    fn default() -> Self {
1447        Self {
1448            enabled: false,
1449            adaptation_frequency: 10,
1450            privacy_sensitivity: 1.0,
1451            utility_weight: 0.5,
1452            fairness_weight: 0.3,
1453        }
1454    }
1455}
1456
1457impl Default for ContextualAdjustmentConfig {
1458    fn default() -> Self {
1459        Self {
1460            enabled: false,
1461            context_factors: vec![ContextFactor::DataSensitivity],
1462            adjustment_sensitivity: 0.1,
1463            temporal_adaptation: false,
1464        }
1465    }
1466}
1467
1468impl Default for LazyAggregationConfig {
1469    fn default() -> Self {
1470        Self {
1471            enabled: false,
1472            aggregation_threshold: 0.9,
1473            staleness_tolerance: 5,
1474            gradient_similarity_threshold: 0.8,
1475        }
1476    }
1477}
1478
1479impl Default for FederatedDropoutConfig {
1480    fn default() -> Self {
1481        Self {
1482            enabled: false,
1483            dropout_probability: 0.1,
1484            adaptive_dropout: false,
1485            importance_sampling: false,
1486        }
1487    }
1488}
1489
1490impl Default for AsyncUpdateConfig {
1491    fn default() -> Self {
1492        Self {
1493            enabled: false,
1494            staleness_threshold: 10,
1495            mixing_coefficient: 0.9,
1496            buffering_strategy: BufferingStrategy::FIFO,
1497        }
1498    }
1499}
1500
1501impl Default for QoSConfig {
1502    fn default() -> Self {
1503        Self {
1504            priority_levels: 3,
1505            latency_targets: vec![100.0, 200.0, 500.0],
1506            throughput_targets: vec![10.0, 5.0, 1.0],
1507            fairness_constraints: true,
1508        }
1509    }
1510}
1511
1512impl Default for MemoryManagementConfig {
1513    fn default() -> Self {
1514        Self {
1515            memory_budget: 1000,
1516            eviction_strategy: EvictionStrategy::LRU,
1517            compression_enabled: false,
1518            memory_adaptation: false,
1519        }
1520    }
1521}
1522
1523impl Default for TaskDetectionConfig {
1524    fn default() -> Self {
1525        Self {
1526            enabled: false,
1527            detection_method: TaskDetectionMethod::GradientBased,
1528            sensitivity_threshold: 0.1,
1529            adaptation_delay: 5,
1530        }
1531    }
1532}
1533
1534impl Default for KnowledgeTransferConfig {
1535    fn default() -> Self {
1536        Self {
1537            transfer_method: KnowledgeTransferMethod::ParameterTransfer,
1538            transfer_strength: 0.5,
1539            selective_transfer: false,
1540            privacy_preserving: true,
1541        }
1542    }
1543}
1544
1545impl Default for ForgettingPreventionConfig {
1546    fn default() -> Self {
1547        Self {
1548            method: ForgettingPreventionMethod::EWC,
1549            regularization_strength: 0.1,
1550            memory_replay_ratio: 0.1,
1551            importance_estimation: ImportanceEstimationMethod::FisherInformation,
1552        }
1553    }
1554}
1555
1556impl Default for AdaptiveBudgetConfig {
1557    fn default() -> Self {
1558        Self {
1559            enabled: false,
1560            allocation_strategy: BudgetAllocationStrategy::Uniform,
1561            dynamic_privacy: DynamicPrivacyConfig::default(),
1562            importance_weighting: false,
1563            contextual_adjustment: ContextualAdjustmentConfig::default(),
1564        }
1565    }
1566}
1567
1568impl From<&AmplificationConfig> for crate::privacy::differential_privacy::AmplificationConfig {
1569    /// Project the federated amplification switches onto the canonical ones.
1570    ///
1571    /// Only `enabled` and `shuffling_enabled` affect the published bounds, so
1572    /// those are the only fields the canonical type carries. The remaining
1573    /// federated fields are rejected by `FederatedPrivacyConfig::validate` when
1574    /// set, so nothing is silently dropped here.
1575    fn from(config: &AmplificationConfig) -> Self {
1576        Self {
1577            enabled: config.enabled,
1578            shuffling_enabled: config.shuffling_enabled,
1579        }
1580    }
1581}