Skip to main content

ggen_core/domain/config/
loader.rs

1//! Configuration loader for ggen.toml
2
3use super::validation::{ConfigValidator, ValidationResult};
4use crate::utils::error::Error as DomainError;
5use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7use std::path::{Path, PathBuf};
8
9/// Complete ggen.toml configuration structure
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct GgenConfig {
12    pub project: ProjectMetadata,
13    #[serde(default)]
14    pub ontology: OntologyConfig,
15    #[serde(default)]
16    pub ai: AiConfig,
17    #[serde(default)]
18    pub templates: TemplatesConfig,
19    #[serde(default)]
20    pub rdf: RdfConfig,
21    #[serde(default)]
22    pub sparql: SparqlConfig,
23    #[serde(default)]
24    pub lifecycle: LifecycleConfig,
25    #[serde(default)]
26    pub security: SecurityConfig,
27    #[serde(default)]
28    pub performance: PerformanceConfig,
29    #[serde(default)]
30    pub logging: LoggingConfig,
31    #[serde(default)]
32    pub dependencies: DependenciesConfig,
33    #[serde(default)]
34    pub generation: GenerationConfig,
35    #[serde(default)]
36    pub zai: ZaiConfig,
37    #[serde(default)]
38    pub mcp: McpConfig,
39    #[serde(default)]
40    pub a2a: A2aConfig,
41    #[serde(default)]
42    pub marketplace: MarketplaceConfig,
43    #[serde(default)]
44    pub codeowners: CodeownersConfig,
45    #[serde(default)]
46    pub env: HashMap<String, HashMap<String, toml::Value>>,
47}
48
49/// Project metadata
50#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct ProjectMetadata {
52    pub name: String,
53    pub version: String,
54    pub description: String,
55    pub authors: Vec<String>,
56    pub license: String,
57    pub repository: String,
58}
59
60/// Ontology configuration
61#[derive(Debug, Clone, Serialize, Deserialize)]
62pub struct OntologyConfig {
63    pub source: String,
64    #[serde(default = "default_ontology_base_uri")]
65    pub base_uri: String,
66    #[serde(default = "default_ontology_format")]
67    pub format: String,
68}
69
70fn default_ontology_base_uri() -> String {
71    "https://ggen.dev/".to_string()
72}
73
74fn default_ontology_format() -> String {
75    "turtle".to_string()
76}
77
78impl Default for OntologyConfig {
79    fn default() -> Self {
80        Self {
81            source: "ontology.ttl".to_string(),
82            base_uri: default_ontology_base_uri(),
83            format: default_ontology_format(),
84        }
85    }
86}
87
88/// AI configuration
89#[derive(Debug, Clone, Serialize, Deserialize)]
90pub struct AiConfig {
91    #[serde(default = "default_ai_provider")]
92    pub provider: String,
93    pub model: String,
94    #[serde(default = "default_ai_temperature")]
95    pub temperature: f64,
96    #[serde(default = "default_ai_max_tokens")]
97    pub max_tokens: u32,
98    #[serde(default = "default_ai_timeout")]
99    pub timeout: u64,
100    #[serde(default)]
101    pub base_url: Option<String>,
102}
103
104fn default_ai_provider() -> String {
105    "anthropic".to_string()
106}
107
108fn default_ai_temperature() -> f64 {
109    0.5
110}
111
112fn default_ai_max_tokens() -> u32 {
113    8000
114}
115
116fn default_ai_timeout() -> u64 {
117    120
118}
119
120impl Default for AiConfig {
121    fn default() -> Self {
122        Self {
123            provider: default_ai_provider(),
124            model: "claude-3-opus-20240229".to_string(),
125            temperature: default_ai_temperature(),
126            max_tokens: default_ai_max_tokens(),
127            timeout: default_ai_timeout(),
128            base_url: None,
129        }
130    }
131}
132
133/// Templates configuration
134#[derive(Debug, Clone, Serialize, Deserialize)]
135pub struct TemplatesConfig {
136    #[serde(default = "default_templates_directory")]
137    pub directory: String,
138    #[serde(default = "default_true")]
139    pub backup_enabled: bool,
140    #[serde(default = "default_true")]
141    pub idempotent: bool,
142}
143
144fn default_templates_directory() -> String {
145    "templates".to_string()
146}
147
148impl Default for TemplatesConfig {
149    fn default() -> Self {
150        Self {
151            directory: default_templates_directory(),
152            backup_enabled: true,
153            idempotent: true,
154        }
155    }
156}
157
158/// RDF configuration
159#[derive(Debug, Clone, Serialize, Deserialize)]
160pub struct RdfConfig {
161    #[serde(default = "default_rdf_base_uri")]
162    pub base_uri: String,
163    #[serde(default = "default_rdf_format")]
164    pub default_format: String,
165    #[serde(default = "default_true")]
166    pub cache_queries: bool,
167    #[serde(default = "default_rdf_store_path")]
168    pub store_path: String,
169    #[serde(default)]
170    pub prefixes: HashMap<String, String>,
171}
172
173fn default_rdf_base_uri() -> String {
174    "https://ggen.dev/".to_string()
175}
176
177fn default_rdf_format() -> String {
178    "turtle".to_string()
179}
180
181fn default_rdf_store_path() -> String {
182    ".ggen/rdf-store".to_string()
183}
184
185impl Default for RdfConfig {
186    fn default() -> Self {
187        Self {
188            base_uri: default_rdf_base_uri(),
189            default_format: default_rdf_format(),
190            cache_queries: true,
191            store_path: default_rdf_store_path(),
192            prefixes: HashMap::new(),
193        }
194    }
195}
196
197/// SPARQL configuration
198#[derive(Debug, Clone, Serialize, Deserialize)]
199pub struct SparqlConfig {
200    #[serde(default = "default_sparql_timeout")]
201    pub timeout: u64,
202    #[serde(default = "default_sparql_max_results")]
203    pub max_results: u32,
204    #[serde(default = "default_true")]
205    pub cache_enabled: bool,
206    #[serde(default = "default_sparql_cache_ttl")]
207    pub cache_ttl: u64,
208}
209
210fn default_sparql_timeout() -> u64 {
211    60
212}
213
214fn default_sparql_max_results() -> u32 {
215    5000
216}
217
218fn default_sparql_cache_ttl() -> u64 {
219    7200
220}
221
222impl Default for SparqlConfig {
223    fn default() -> Self {
224        Self {
225            timeout: default_sparql_timeout(),
226            max_results: default_sparql_max_results(),
227            cache_enabled: true,
228            cache_ttl: default_sparql_cache_ttl(),
229        }
230    }
231}
232
233/// Lifecycle configuration
234#[derive(Debug, Clone, Serialize, Deserialize)]
235pub struct LifecycleConfig {
236    #[serde(default = "default_true")]
237    pub enabled: bool,
238    #[serde(default = "default_lifecycle_config_file")]
239    pub config_file: String,
240    #[serde(default = "default_lifecycle_cache_dir")]
241    pub cache_directory: String,
242    #[serde(default = "default_lifecycle_state_file")]
243    pub state_file: String,
244    #[serde(default)]
245    pub phases: LifecyclePhases,
246}
247
248fn default_lifecycle_config_file() -> String {
249    ".ggen/lifecycle.toml".to_string()
250}
251
252fn default_lifecycle_cache_dir() -> String {
253    ".ggen/cache".to_string()
254}
255
256fn default_lifecycle_state_file() -> String {
257    ".ggen/state.json".to_string()
258}
259
260#[derive(Debug, Clone, Serialize, Deserialize, Default)]
261pub struct LifecyclePhases {
262    #[serde(default)]
263    pub pre_generate: PhaseConfig,
264    #[serde(default)]
265    pub post_generate: PhaseConfig,
266}
267
268#[derive(Debug, Clone, Serialize, Deserialize, Default)]
269pub struct PhaseConfig {
270    #[serde(default)]
271    pub scripts: Vec<String>,
272}
273
274impl Default for LifecycleConfig {
275    fn default() -> Self {
276        Self {
277            enabled: true,
278            config_file: default_lifecycle_config_file(),
279            cache_directory: default_lifecycle_cache_dir(),
280            state_file: default_lifecycle_state_file(),
281            phases: Default::default(),
282        }
283    }
284}
285
286/// Security configuration
287#[derive(Debug, Clone, Serialize, Deserialize)]
288pub struct SecurityConfig {
289    #[serde(default)]
290    pub allowed_domains: Vec<String>,
291    #[serde(default = "default_max_file_size")]
292    pub max_file_size: u64,
293    #[serde(default = "default_true")]
294    pub validate_ssl: bool,
295}
296
297fn default_max_file_size() -> u64 {
298    104_857_600 // 100MB
299}
300
301impl Default for SecurityConfig {
302    fn default() -> Self {
303        Self {
304            allowed_domains: vec![
305                "schema.org".to_string(),
306                "w3.org".to_string(),
307                "ggen.dev".to_string(),
308                "github.com".to_string(),
309            ],
310            max_file_size: default_max_file_size(),
311            validate_ssl: true,
312        }
313    }
314}
315
316/// Performance configuration
317#[derive(Debug, Clone, Serialize, Deserialize)]
318pub struct PerformanceConfig {
319    #[serde(default = "default_true")]
320    pub parallel_generation: bool,
321    #[serde(default = "default_max_workers")]
322    pub max_workers: usize,
323    #[serde(default = "default_true")]
324    pub cache_templates: bool,
325    #[serde(default = "default_true")]
326    pub incremental_build: bool,
327}
328
329fn default_max_workers() -> usize {
330    8
331}
332
333impl Default for PerformanceConfig {
334    fn default() -> Self {
335        Self {
336            parallel_generation: true,
337            max_workers: default_max_workers(),
338            cache_templates: true,
339            incremental_build: true,
340        }
341    }
342}
343
344/// Logging configuration
345#[derive(Debug, Clone, Serialize, Deserialize)]
346pub struct LoggingConfig {
347    #[serde(default = "default_log_level")]
348    pub level: String,
349    #[serde(default = "default_log_format")]
350    pub format: String,
351    #[serde(default = "default_log_output")]
352    pub output: String,
353}
354
355fn default_log_level() -> String {
356    "info".to_string()
357}
358
359fn default_log_format() -> String {
360    "pretty".to_string()
361}
362
363fn default_log_output() -> String {
364    "stderr".to_string()
365}
366
367impl Default for LoggingConfig {
368    fn default() -> Self {
369        Self {
370            level: default_log_level(),
371            format: default_log_format(),
372            output: default_log_output(),
373        }
374    }
375}
376
377/// Dependencies configuration
378#[derive(Debug, Clone, Serialize, Deserialize, Default)]
379pub struct DependenciesConfig {
380    #[serde(default)]
381    pub crates: Vec<CrateDependency>,
382}
383
384#[derive(Debug, Clone, Serialize, Deserialize)]
385pub struct CrateDependency {
386    pub name: String,
387    pub version: String,
388    #[serde(default)]
389    pub optional: bool,
390}
391
392/// Generation configuration
393#[derive(Debug, Clone, Serialize, Deserialize)]
394pub struct GenerationConfig {
395    #[serde(default = "default_true")]
396    pub enabled: bool,
397    #[serde(default)]
398    pub rules: Vec<GenerationRule>,
399    #[serde(default)]
400    pub protected_paths: Vec<String>,
401    #[serde(default)]
402    pub regenerate_paths: Vec<String>,
403    #[serde(default = "default_generated_header")]
404    pub generated_header: String,
405    #[serde(default = "default_true")]
406    pub require_confirmation: bool,
407    #[serde(default = "default_true")]
408    pub backup_before_write: bool,
409    #[serde(default)]
410    pub poka_yoke: PokaYokeConfig,
411}
412
413fn default_generated_header() -> String {
414    r"
415// ============================================================
416// DO NOT EDIT THIS FILE
417//
418// This file is auto-generated by ggen from RDF ontology.
419// Any manual changes will be OVERWRITTEN on regeneration.
420//
421// Regenerate with: ggen generate
422// ============================================================
423"
424    .to_string()
425}
426
427/// File generation safety flags (≤3 bools)
428#[derive(Debug, Clone, Serialize, Deserialize, Default)]
429pub struct GenerationSafety {
430    #[serde(default = "default_true")]
431    pub warning_headers: bool,
432    #[serde(default)]
433    pub gitignore_generated: bool,
434    #[serde(default = "default_true")]
435    pub gitattributes_generated: bool,
436}
437
438/// Validation policy flags (≤3 bools)
439#[derive(Debug, Clone, Serialize, Deserialize, Default)]
440pub struct ValidationPolicy {
441    #[serde(default)]
442    pub validate_imports: bool,
443}
444
445/// Boolean feature flags for poka-yoke (mistake-proofing) settings
446#[derive(Debug, Clone, Serialize, Deserialize, Default)]
447pub struct PokaYokeFlags {
448    #[serde(flatten)]
449    pub generation: GenerationSafety,
450    #[serde(flatten)]
451    pub validation: ValidationPolicy,
452}
453
454#[derive(Debug, Clone, Serialize, Deserialize, Default)]
455pub struct PokaYokeConfig {
456    #[serde(flatten)]
457    pub flags: PokaYokeFlags,
458}
459
460#[derive(Debug, Clone, Serialize, Deserialize)]
461pub struct GenerationRule {
462    pub name: String,
463    pub source: String,
464    pub output: String,
465    #[serde(default)]
466    pub templates: Option<String>,
467}
468
469impl Default for GenerationConfig {
470    fn default() -> Self {
471        Self {
472            enabled: true,
473            rules: Vec::new(),
474            protected_paths: Vec::new(),
475            regenerate_paths: Vec::new(),
476            generated_header: default_generated_header(),
477            require_confirmation: true,
478            backup_before_write: true,
479            poka_yoke: Default::default(),
480        }
481    }
482}
483
484/// ZAI configuration (local GenAI integration)
485#[derive(Debug, Clone, Serialize, Deserialize)]
486pub struct ZaiConfig {
487    #[serde(default = "default_zai_provider")]
488    pub provider: String,
489    #[serde(default = "default_zai_model")]
490    pub model: String,
491    #[serde(default = "default_zai_base_url")]
492    pub base_url: String,
493    #[serde(default)]
494    pub api_key: Option<String>,
495    #[serde(default = "default_temperature")]
496    pub temperature: f64,
497    #[serde(default = "default_max_tokens")]
498    pub max_tokens: u32,
499    #[serde(default = "default_timeout")]
500    pub timeout: u64,
501    #[serde(default = "default_true")]
502    pub cache_enabled: bool,
503    #[serde(default = "default_cache_ttl")]
504    pub cache_ttl: u64,
505}
506
507fn default_zai_provider() -> String {
508    "zai".to_string()
509}
510
511fn default_zai_model() -> String {
512    "zai-chat".to_string()
513}
514
515fn default_zai_base_url() -> String {
516    "http://localhost:8080".to_string()
517}
518
519fn default_temperature() -> f64 {
520    0.7
521}
522
523fn default_max_tokens() -> u32 {
524    8000
525}
526
527fn default_timeout() -> u64 {
528    120
529}
530
531fn default_cache_ttl() -> u64 {
532    3600
533}
534
535impl Default for ZaiConfig {
536    fn default() -> Self {
537        Self {
538            provider: default_zai_provider(),
539            model: default_zai_model(),
540            base_url: default_zai_base_url(),
541            api_key: None,
542            temperature: default_temperature(),
543            max_tokens: default_max_tokens(),
544            timeout: default_timeout(),
545            cache_enabled: true,
546            cache_ttl: default_cache_ttl(),
547        }
548    }
549}
550
551/// MCP configuration
552#[derive(Debug, Clone, Serialize, Deserialize, Default)]
553pub struct McpConfig {
554    #[serde(default = "default_true")]
555    pub enabled: bool,
556    #[serde(default)]
557    pub servers: Vec<McpServerDef>,
558}
559
560#[derive(Debug, Clone, Serialize, Deserialize)]
561pub struct McpServerDef {
562    pub name: String,
563    pub command: String,
564    #[serde(default)]
565    pub args: Vec<String>,
566}
567
568/// A2A configuration
569#[derive(Debug, Clone, Serialize, Deserialize, Default)]
570pub struct A2aConfig {
571    #[serde(default)]
572    pub server: A2aServerDef,
573    #[serde(default)]
574    pub agents: Vec<A2aAgentDef>,
575}
576
577#[derive(Debug, Clone, Serialize, Deserialize)]
578pub struct A2aServerDef {
579    #[serde(default = "default_a2a_host")]
580    pub host: String,
581    #[serde(default = "default_a2a_port")]
582    pub port: u16,
583}
584
585fn default_a2a_host() -> String {
586    "127.0.0.1".to_string()
587}
588
589fn default_a2a_port() -> u16 {
590    8080
591}
592
593impl Default for A2aServerDef {
594    fn default() -> Self {
595        Self {
596            host: default_a2a_host(),
597            port: default_a2a_port(),
598        }
599    }
600}
601
602#[derive(Debug, Clone, Serialize, Deserialize)]
603pub struct A2aAgentDef {
604    pub name: String,
605    pub agent_type: String,
606    #[serde(default)]
607    pub description: Option<String>,
608}
609
610/// Marketplace configuration
611#[derive(Debug, Clone, Serialize, Deserialize)]
612pub struct MarketplaceConfig {
613    #[serde(default = "default_marketplace_url")]
614    pub registry_url: String,
615    #[serde(default = "default_true")]
616    pub cache_packages: bool,
617    #[serde(default = "default_true")]
618    pub verify_signatures: bool,
619}
620
621fn default_marketplace_url() -> String {
622    "https://marketplace.ggen.dev".to_string()
623}
624
625impl Default for MarketplaceConfig {
626    fn default() -> Self {
627        Self {
628            registry_url: default_marketplace_url(),
629            cache_packages: true,
630            verify_signatures: true,
631        }
632    }
633}
634
635/// CODEOWNERS configuration
636#[derive(Debug, Clone, Serialize, Deserialize)]
637pub struct CodeownersConfig {
638    #[serde(default = "default_true")]
639    pub enabled: bool,
640    #[serde(default)]
641    pub source_dirs: Vec<String>,
642    #[serde(default)]
643    pub base_dirs: Vec<String>,
644    #[serde(default = "default_codeowners_output")]
645    pub output_path: String,
646    #[serde(default)]
647    pub auto_regenerate: bool,
648}
649
650fn default_codeowners_output() -> String {
651    ".github/CODEOWNERS".to_string()
652}
653
654impl Default for CodeownersConfig {
655    fn default() -> Self {
656        Self {
657            enabled: true,
658            source_dirs: vec!["ontology".to_string(), "ontologies".to_string()],
659            base_dirs: vec![
660                "ontology".to_string(),
661                "ontologies".to_string(),
662                "src/generated".to_string(),
663                "src/domain".to_string(),
664                "crates/*/src/generated".to_string(),
665                "crates/*/src/domain".to_string(),
666            ],
667            output_path: default_codeowners_output(),
668            auto_regenerate: false,
669        }
670    }
671}
672
673fn default_true() -> bool {
674    true
675}
676
677/// Configuration loader
678pub struct ConfigLoader {
679    validator: ConfigValidator,
680}
681
682impl ConfigLoader {
683    pub fn new() -> Self {
684        Self {
685            validator: ConfigValidator::new(),
686        }
687    }
688
689    /// Load ggen.toml with environment override
690    pub fn load_with_env(
691        &self, config_path: &Path, environment: &str,
692    ) -> Result<(GgenConfig, ValidationResult), ConfigError> {
693        let mut config = self.load_base_config(config_path)?;
694        self.apply_environment_overrides(&mut config, environment)?;
695        let validation = self.validator.validate_ggen_config(&config);
696        Ok((config, validation))
697    }
698
699    /// Load ggen.toml without environment override
700    pub fn load(&self, config_path: &Path) -> Result<(GgenConfig, ValidationResult), ConfigError> {
701        let config = self.load_base_config(config_path)?;
702        let validation = self.validator.validate_ggen_config(&config);
703        Ok((config, validation))
704    }
705
706    fn load_base_config(&self, path: &Path) -> Result<GgenConfig, ConfigError> {
707        let content = std::fs::read_to_string(path).map_err(|e| ConfigError::IoError {
708            path: path.to_path_buf(),
709            source: e,
710        })?;
711
712        toml::from_str(&content).map_err(|e| ConfigError::ParseError {
713            path: path.to_path_buf(),
714            source: e,
715        })
716    }
717
718    fn apply_environment_overrides(
719        &self, config: &mut GgenConfig, environment: &str,
720    ) -> Result<(), ConfigError> {
721        let overrides = config.env.get(environment).cloned().unwrap_or_default();
722
723        for (key_path, value) in overrides {
724            self.apply_override(config, &key_path, value)?;
725        }
726
727        Ok(())
728    }
729
730    fn apply_override(
731        &self, config: &mut GgenConfig, key_path: &str, value: toml::Value,
732    ) -> Result<(), ConfigError> {
733        let parts: Vec<&str> = key_path.split('.').collect();
734
735        match parts.as_slice() {
736            ["ai", "provider"] => {
737                if let Some(s) = value.as_str() {
738                    config.ai.provider = s.to_string();
739                }
740            }
741            ["ai", "model"] => {
742                if let Some(s) = value.as_str() {
743                    config.ai.model = s.to_string();
744                }
745            }
746            ["ai", "temperature"] => {
747                if let Some(f) = value.as_float() {
748                    config.ai.temperature = f;
749                }
750            }
751            ["ai", "base_url"] => {
752                if let Some(s) = value.as_str() {
753                    config.ai.base_url = Some(s.to_string());
754                }
755            }
756            ["zai", "provider"] => {
757                if let Some(s) = value.as_str() {
758                    config.zai.provider = s.to_string();
759                }
760            }
761            ["zai", "model"] => {
762                if let Some(s) = value.as_str() {
763                    config.zai.model = s.to_string();
764                }
765            }
766            ["zai", "base_url"] => {
767                if let Some(s) = value.as_str() {
768                    config.zai.base_url = s.to_string();
769                }
770            }
771            ["logging", "level"] => {
772                if let Some(s) = value.as_str() {
773                    config.logging.level = s.to_string();
774                }
775            }
776            ["logging", "format"] => {
777                if let Some(s) = value.as_str() {
778                    config.logging.format = s.to_string();
779                }
780            }
781            ["performance", "max_workers"] => {
782                if let Some(n) = value.as_integer() {
783                    config.performance.max_workers = n as usize;
784                }
785            }
786            ["sparql", "cache_ttl"] => {
787                if let Some(n) = value.as_integer() {
788                    config.sparql.cache_ttl = n as u64;
789                }
790            }
791            _ => {
792                // Unknown override - ignore
793            }
794        }
795
796        Ok(())
797    }
798}
799
800impl Default for ConfigLoader {
801    fn default() -> Self {
802        Self::new()
803    }
804}
805
806/// Configuration error type
807#[derive(Debug, thiserror::Error)]
808pub enum ConfigError {
809    #[error("IO error reading config at {path:?}: {source}")]
810    IoError {
811        path: PathBuf,
812        #[source]
813        source: std::io::Error,
814    },
815
816    #[error("Parse error in config at {path:?}: {source}")]
817    ParseError {
818        path: PathBuf,
819        #[source]
820        source: toml::de::Error,
821    },
822
823    #[error("Validation error: {0}")]
824    ValidationError(String),
825
826    #[error("Invalid environment override: {0}")]
827    InvalidOverride(String),
828}
829
830impl From<ConfigError> for DomainError {
831    fn from(err: ConfigError) -> Self {
832        DomainError::invalid_input(err.to_string())
833    }
834}
835
836#[cfg(test)]
837mod tests {
838    use super::*;
839
840    #[test]
841    fn test_config_loader_default() {
842        use crate::domain::config::validation::ConfigValidator;
843        let validator = ConfigValidator::new();
844        assert!(!validator.allowed_licenses().is_empty());
845    }
846
847    #[test]
848    fn test_ontology_config_default() {
849        let config = OntologyConfig::default();
850        assert_eq!(config.base_uri, "https://ggen.dev/");
851        assert_eq!(config.format, "turtle");
852    }
853
854    #[test]
855    fn test_ai_config_default() {
856        let config = AiConfig::default();
857        assert_eq!(config.provider, "anthropic");
858        assert_eq!(config.temperature, 0.5);
859        assert_eq!(config.max_tokens, 8000);
860    }
861
862    #[test]
863    fn test_zai_config_default() {
864        let config = ZaiConfig::default();
865        assert_eq!(config.provider, "zai");
866        assert_eq!(config.model, "zai-chat");
867        assert_eq!(config.base_url, "http://localhost:8080");
868        assert_eq!(config.temperature, 0.7);
869    }
870
871    #[test]
872    fn test_generation_config_default() {
873        let config = GenerationConfig::default();
874        assert!(config.enabled);
875        assert!(config.require_confirmation);
876        assert!(config.backup_before_write);
877    }
878
879    #[test]
880    fn test_a2a_server_def_default() {
881        let config = A2aServerDef::default();
882        assert_eq!(config.host, "127.0.0.1");
883        assert_eq!(config.port, 8080);
884    }
885
886    #[test]
887    fn test_marketplace_config_default() {
888        let config = MarketplaceConfig::default();
889        assert_eq!(config.registry_url, "https://marketplace.ggen.dev");
890        assert!(config.cache_packages);
891        assert!(config.verify_signatures);
892    }
893
894    #[test]
895    fn test_security_config_default() {
896        let config = SecurityConfig::default();
897        assert_eq!(config.max_file_size, 104_857_600);
898        assert!(config.validate_ssl);
899        assert!(!config.allowed_domains.is_empty());
900    }
901
902    #[test]
903    fn test_performance_config_default() {
904        let config = PerformanceConfig::default();
905        assert!(config.parallel_generation);
906        assert_eq!(config.max_workers, 8);
907        assert!(config.incremental_build);
908    }
909
910    #[test]
911    fn test_logging_config_default() {
912        let config = LoggingConfig::default();
913        assert_eq!(config.level, "info");
914        assert_eq!(config.format, "pretty");
915        assert_eq!(config.output, "stderr");
916    }
917}