voirs-sdk 0.1.0-rc.1

Unified SDK and public API for VoiRS speech synthesis
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
//! Semantic versioning compliance and API stability guarantees for VoiRS
//!
//! This module provides version management, compatibility checking, and API stability
//! features to ensure reliable long-term support and migration paths.

use semver::{Version, VersionReq};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use thiserror::Error;

/// VoiRS version manager for API stability and compatibility
pub struct VersionManager {
    /// Current library version
    current_version: Version,
    /// API compatibility matrix
    compatibility_matrix: CompatibilityMatrix,
    /// Deprecation tracker
    deprecation_tracker: DeprecationTracker,
    /// API stability policies
    stability_policies: StabilityPolicies,
}

impl VersionManager {
    /// Create new version manager
    pub fn new() -> Result<Self, VersioningError> {
        let current_version = Version::parse(env!("CARGO_PKG_VERSION"))?;

        Ok(Self {
            current_version,
            compatibility_matrix: CompatibilityMatrix::new(),
            deprecation_tracker: DeprecationTracker::new(),
            stability_policies: StabilityPolicies::default(),
        })
    }

    /// Get current library version
    pub fn current_version(&self) -> &Version {
        &self.current_version
    }

    /// Check if a version requirement is compatible
    pub fn is_compatible(&self, requirement: &VersionReq) -> bool {
        requirement.matches(&self.current_version)
    }

    /// Check compatibility with specific version
    pub fn check_compatibility(&self, other_version: &Version) -> CompatibilityResult {
        self.compatibility_matrix
            .check_compatibility(&self.current_version, other_version)
    }

    /// Get migration path from one version to another
    pub fn get_migration_path(&self, from: &Version, to: &Version) -> MigrationPath {
        if from == to {
            return MigrationPath {
                from: from.clone(),
                to: to.clone(),
                steps: vec![],
                breaking_changes: vec![],
                recommended_actions: vec![],
                estimated_effort: MigrationEffort::None,
            };
        }

        let mut path = MigrationPath {
            from: from.clone(),
            to: to.clone(),
            steps: vec![],
            breaking_changes: vec![],
            recommended_actions: vec![],
            estimated_effort: MigrationEffort::Low,
        };

        // Analyze version differences
        if to.major > from.major {
            path.breaking_changes.push(BreakingChange {
                change_type: ChangeType::MajorVersionBump,
                description: format!("Major version change from {} to {}", from.major, to.major),
                affected_apis: vec!["All public APIs".to_string()],
                migration_notes: "Review all API usage for breaking changes".to_string(),
                introduced_in: to.clone(),
            });
            path.estimated_effort = MigrationEffort::High;
        }

        if to.minor > from.minor {
            path.steps.push(MigrationStep {
                step_type: StepType::FeatureUpdate,
                description: format!(
                    "Minor version update from {}.{} to {}.{}",
                    from.major, from.minor, to.major, to.minor
                ),
                required: false,
                validation: "Check for new features and deprecations".to_string(),
            });

            if path.estimated_effort == MigrationEffort::None {
                path.estimated_effort = MigrationEffort::Low;
            }
        }

        if to.patch > from.patch {
            path.steps.push(MigrationStep {
                step_type: StepType::BugFix,
                description: "Patch version update - bug fixes and improvements".to_string(),
                required: true,
                validation: "Test existing functionality".to_string(),
            });
        }

        // Add deprecation warnings
        for deprecation in self.deprecation_tracker.get_deprecations_between(from, to) {
            path.recommended_actions.push(format!(
                "Update deprecated API: {} (deprecated in {}, will be removed in {})",
                deprecation.api_name,
                deprecation.deprecated_since,
                deprecation
                    .removal_version
                    .as_ref()
                    .unwrap_or(&"future version".to_string())
            ));
        }

        path
    }

    /// Register API deprecation
    pub fn deprecate_api(
        &mut self,
        api_name: &str,
        reason: &str,
        removal_version: Option<Version>,
    ) {
        let deprecation = DeprecatedApi {
            api_name: api_name.to_string(),
            reason: reason.to_string(),
            deprecated_since: self.current_version.clone(),
            removal_version: removal_version.map(|v| v.to_string()),
            replacement: None,
            migration_guide: None,
        };

        self.deprecation_tracker.add_deprecation(deprecation);
    }

    /// Get all current deprecations
    pub fn get_current_deprecations(&self) -> Vec<&DeprecatedApi> {
        self.deprecation_tracker.get_current_deprecations()
    }

    /// Check if API is deprecated
    pub fn is_api_deprecated(&self, api_name: &str) -> bool {
        self.deprecation_tracker.is_deprecated(api_name)
    }

    /// Validate version bump compatibility
    pub fn validate_version_bump(&self, new_version: &Version) -> VersionBumpValidation {
        let mut validation = VersionBumpValidation {
            is_valid: true,
            issues: vec![],
            warnings: vec![],
            recommendations: vec![],
        };

        // Check semver compliance
        if new_version <= &self.current_version {
            validation.is_valid = false;
            validation.issues.push(format!(
                "New version {} must be greater than current version {}",
                new_version, self.current_version
            ));
        }

        // Validate version increment rules
        let major_diff = new_version.major.saturating_sub(self.current_version.major);
        let minor_diff = new_version.minor.saturating_sub(self.current_version.minor);
        let patch_diff = new_version.patch.saturating_sub(self.current_version.patch);

        if major_diff > 1 {
            validation.warnings.push(
                "Skipping major versions is unusual - consider incremental releases".to_string(),
            );
        }

        if major_diff > 0 && (new_version.minor > 0 || new_version.patch > 0) {
            validation
                .recommendations
                .push("Consider starting major versions with .0.0".to_string());
        }

        if minor_diff > 0 && major_diff == 0 && new_version.patch > 0 {
            validation
                .recommendations
                .push("Consider starting minor versions with .0 patch level".to_string());
        }

        // Check for breaking changes in non-major version bumps
        if major_diff == 0 {
            let pending_breaking_changes = self.get_pending_breaking_changes();
            if !pending_breaking_changes.is_empty() {
                validation.is_valid = false;
                validation.issues.push(
                    "Breaking changes detected but major version not incremented".to_string(),
                );
            }
        }

        validation
    }

    /// Get stability guarantees for current version
    pub fn get_stability_guarantees(&self) -> StabilityGuarantees {
        let api_level = if self.current_version.major == 0 {
            ApiStabilityLevel::Experimental
        } else {
            ApiStabilityLevel::Stable
        };

        StabilityGuarantees {
            api_level,
            public_api_breaking_changes: self.stability_policies.public_api_policy.clone(),
            internal_api_changes: self.stability_policies.internal_api_policy.clone(),
            deprecation_timeline: self.stability_policies.deprecation_timeline.clone(),
            lts_support: self.stability_policies.lts_support.clone(),
        }
    }

    fn get_pending_breaking_changes(&self) -> Vec<String> {
        // In a real implementation, this would check for actual breaking changes
        // For now, return empty as this is a placeholder
        vec![]
    }
}

impl Default for VersionManager {
    fn default() -> Self {
        Self::new().unwrap_or_else(|_| VersionManager {
            current_version: Version::new(0, 1, 0),
            compatibility_matrix: CompatibilityMatrix::default(),
            deprecation_tracker: DeprecationTracker::new(),
            stability_policies: StabilityPolicies::default(),
        })
    }
}

/// Compatibility matrix for version checking
#[derive(Debug, Clone)]
pub struct CompatibilityMatrix {
    /// Known incompatible version pairs
    incompatible_pairs: HashMap<String, Vec<String>>,
    /// Compatibility rules
    rules: Vec<CompatibilityRule>,
}

impl Default for CompatibilityMatrix {
    fn default() -> Self {
        Self::new()
    }
}

impl CompatibilityMatrix {
    pub fn new() -> Self {
        let mut matrix = Self {
            incompatible_pairs: HashMap::new(),
            rules: vec![
                // Standard semver rules
                CompatibilityRule {
                    name: "major_version_breaking".to_string(),
                    description: "Major version changes indicate breaking changes".to_string(),
                    rule_type: RuleType::Breaking,
                    condition: "major_version_different".to_string(),
                },
                CompatibilityRule {
                    name: "minor_version_additive".to_string(),
                    description: "Minor version changes are backward compatible".to_string(),
                    rule_type: RuleType::Compatible,
                    condition: "minor_version_higher".to_string(),
                },
                CompatibilityRule {
                    name: "patch_version_fixes".to_string(),
                    description: "Patch version changes are fully compatible".to_string(),
                    rule_type: RuleType::Compatible,
                    condition: "patch_version_different".to_string(),
                },
            ],
        };

        // Add known incompatible version pairs (if any)
        matrix
            .incompatible_pairs
            .insert("0.1.0".to_string(), vec!["0.2.0".to_string()]);

        matrix
    }

    pub fn check_compatibility(&self, current: &Version, other: &Version) -> CompatibilityResult {
        if current == other {
            return CompatibilityResult {
                compatible: true,
                level: CompatibilityLevel::Identical,
                issues: vec![],
                recommendations: vec![],
            };
        }

        let mut result = CompatibilityResult {
            compatible: true,
            level: CompatibilityLevel::FullyCompatible,
            issues: vec![],
            recommendations: vec![],
        };

        // Check for known incompatibilities
        if let Some(incompatible_versions) = self.incompatible_pairs.get(&current.to_string()) {
            if incompatible_versions.contains(&other.to_string()) {
                result.compatible = false;
                result.level = CompatibilityLevel::Incompatible;
                result
                    .issues
                    .push("Known incompatible version pair".to_string());
                return result;
            }
        }

        // Apply compatibility rules
        if other.major != current.major {
            result.level = if other.major > current.major {
                CompatibilityLevel::MajorUpgrade
            } else {
                CompatibilityLevel::Incompatible
            };

            if other.major < current.major {
                result.compatible = false;
                result
                    .issues
                    .push("Downgrading major version may cause compatibility issues".to_string());
            } else {
                result
                    .recommendations
                    .push("Review breaking changes before upgrading".to_string());
            }
        } else if other.minor != current.minor {
            result.level = if other.minor > current.minor {
                CompatibilityLevel::MinorUpgrade
            } else {
                CompatibilityLevel::BackwardCompatible
            };

            if other.minor < current.minor {
                result
                    .recommendations
                    .push("Downgrading minor version may remove features".to_string());
            }
        } else if other.patch != current.patch {
            result.level = if other.patch > current.patch {
                CompatibilityLevel::PatchUpgrade
            } else {
                CompatibilityLevel::BackwardCompatible
            };
        }

        result
    }
}

/// Deprecation tracker for API lifecycle management
#[derive(Debug, Clone)]
pub struct DeprecationTracker {
    deprecations: Vec<DeprecatedApi>,
}

impl Default for DeprecationTracker {
    fn default() -> Self {
        Self::new()
    }
}

impl DeprecationTracker {
    pub fn new() -> Self {
        Self {
            deprecations: vec![
                // Example deprecations - in real usage these would be loaded from configuration
                DeprecatedApi {
                    api_name: "old_synthesis_method".to_string(),
                    reason: "Replaced with more efficient implementation".to_string(),
                    deprecated_since: Version::new(0, 1, 0),
                    removal_version: Some("1.0.0".to_string()),
                    replacement: Some("new_synthesis_method".to_string()),
                    migration_guide: Some(
                        "Replace calls to old_synthesis_method() with new_synthesis_method()"
                            .to_string(),
                    ),
                },
            ],
        }
    }

    pub fn add_deprecation(&mut self, deprecation: DeprecatedApi) {
        self.deprecations.push(deprecation);
    }

    pub fn get_current_deprecations(&self) -> Vec<&DeprecatedApi> {
        self.deprecations.iter().collect()
    }

    pub fn is_deprecated(&self, api_name: &str) -> bool {
        self.deprecations.iter().any(|d| d.api_name == api_name)
    }

    pub fn get_deprecations_between(&self, from: &Version, to: &Version) -> Vec<&DeprecatedApi> {
        self.deprecations
            .iter()
            .filter(|d| d.deprecated_since > *from && d.deprecated_since <= *to)
            .collect()
    }
}

/// API stability policies
#[derive(Debug, Clone)]
pub struct StabilityPolicies {
    pub public_api_policy: String,
    pub internal_api_policy: String,
    pub deprecation_timeline: String,
    pub lts_support: String,
}

impl Default for StabilityPolicies {
    fn default() -> Self {
        Self {
            public_api_policy: "Public APIs are stable within major versions".to_string(),
            internal_api_policy: "Internal APIs may change in minor versions".to_string(),
            deprecation_timeline: "APIs deprecated for at least one major version before removal"
                .to_string(),
            lts_support: "LTS versions supported for 2 years".to_string(),
        }
    }
}

// Data structures for version management

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompatibilityResult {
    pub compatible: bool,
    pub level: CompatibilityLevel,
    pub issues: Vec<String>,
    pub recommendations: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum CompatibilityLevel {
    Identical,
    FullyCompatible,
    BackwardCompatible,
    PatchUpgrade,
    MinorUpgrade,
    MajorUpgrade,
    Incompatible,
}

#[derive(Debug, Clone)]
pub struct CompatibilityRule {
    pub name: String,
    pub description: String,
    pub rule_type: RuleType,
    pub condition: String,
}

#[derive(Debug, Clone)]
pub enum RuleType {
    Compatible,
    Breaking,
    Warning,
}

#[derive(Debug, Clone)]
pub struct MigrationPath {
    pub from: Version,
    pub to: Version,
    pub steps: Vec<MigrationStep>,
    pub breaking_changes: Vec<BreakingChange>,
    pub recommended_actions: Vec<String>,
    pub estimated_effort: MigrationEffort,
}

#[derive(Debug, Clone)]
pub struct MigrationStep {
    pub step_type: StepType,
    pub description: String,
    pub required: bool,
    pub validation: String,
}

#[derive(Debug, Clone)]
pub enum StepType {
    BugFix,
    FeatureUpdate,
    BreakingChange,
    Configuration,
    DataMigration,
}

#[derive(Debug, Clone)]
pub struct BreakingChange {
    pub change_type: ChangeType,
    pub description: String,
    pub affected_apis: Vec<String>,
    pub migration_notes: String,
    pub introduced_in: Version,
}

#[derive(Debug, Clone)]
pub enum ChangeType {
    MajorVersionBump,
    ApiRemoval,
    ApiSignatureChange,
    BehaviorChange,
    ConfigurationChange,
}

#[derive(Debug, Clone, PartialEq)]
pub enum MigrationEffort {
    None,
    Low,
    Medium,
    High,
    Critical,
}

impl fmt::Display for MigrationEffort {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            MigrationEffort::None => write!(f, "No migration needed"),
            MigrationEffort::Low => write!(f, "Low effort (< 1 day)"),
            MigrationEffort::Medium => write!(f, "Medium effort (1-3 days)"),
            MigrationEffort::High => write!(f, "High effort (> 3 days)"),
            MigrationEffort::Critical => write!(f, "Critical effort (weeks)"),
        }
    }
}

#[derive(Debug, Clone)]
pub struct DeprecatedApi {
    pub api_name: String,
    pub reason: String,
    pub deprecated_since: Version,
    pub removal_version: Option<String>,
    pub replacement: Option<String>,
    pub migration_guide: Option<String>,
}

#[derive(Debug, Clone)]
pub struct VersionBumpValidation {
    pub is_valid: bool,
    pub issues: Vec<String>,
    pub warnings: Vec<String>,
    pub recommendations: Vec<String>,
}

#[derive(Debug, Clone)]
pub struct StabilityGuarantees {
    pub api_level: ApiStabilityLevel,
    pub public_api_breaking_changes: String,
    pub internal_api_changes: String,
    pub deprecation_timeline: String,
    pub lts_support: String,
}

#[derive(Debug, Clone)]
pub enum ApiStabilityLevel {
    Experimental,
    Beta,
    Stable,
    LTS,
}

impl fmt::Display for ApiStabilityLevel {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            ApiStabilityLevel::Experimental => write!(f, "Experimental (no stability guarantees)"),
            ApiStabilityLevel::Beta => write!(f, "Beta (limited stability)"),
            ApiStabilityLevel::Stable => write!(f, "Stable (semver compliant)"),
            ApiStabilityLevel::LTS => write!(f, "Long Term Support"),
        }
    }
}

/// Versioning-related errors
#[derive(Error, Debug)]
pub enum VersioningError {
    #[error("Version parse error: {0}")]
    ParseError(#[from] semver::Error),
    #[error("Compatibility check failed: {0}")]
    CompatibilityError(String),
    #[error("Invalid version bump: {0}")]
    InvalidVersionBump(String),
    #[error("Migration error: {0}")]
    MigrationError(String),
}

/// Utility functions for version management
pub mod utils {
    use super::*;

    /// Check if version is pre-release
    pub fn is_prerelease(version: &Version) -> bool {
        !version.pre.is_empty()
    }

    /// Check if version is stable (>= 1.0.0)
    pub fn is_stable(version: &Version) -> bool {
        version.major >= 1
    }

    /// Get next major version
    pub fn next_major(version: &Version) -> Version {
        Version::new(version.major + 1, 0, 0)
    }

    /// Get next minor version
    pub fn next_minor(version: &Version) -> Version {
        Version::new(version.major, version.minor + 1, 0)
    }

    /// Get next patch version
    pub fn next_patch(version: &Version) -> Version {
        Version::new(version.major, version.minor, version.patch + 1)
    }

    /// Format version with stability indicator
    pub fn format_version_with_stability(version: &Version) -> String {
        if is_prerelease(version) {
            format!("{} (pre-release)", version)
        } else if is_stable(version) {
            format!("{} (stable)", version)
        } else {
            format!("{} (experimental)", version)
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_version_manager_creation() {
        let manager = VersionManager::new();
        assert!(manager.is_ok());

        let manager = manager.unwrap();
        assert!(!manager.current_version().to_string().is_empty());
    }

    #[test]
    fn test_compatibility_checking() {
        let manager = VersionManager::new().unwrap();

        // Same version should be compatible
        let same_req = VersionReq::parse("=0.1.0").unwrap();
        // Note: This might fail if the actual version is different
        // In a real test, we'd use the actual current version

        // Test with current version
        let current_str = manager.current_version().to_string();
        let current_req = VersionReq::parse(&format!("={}", current_str)).unwrap();
        assert!(manager.is_compatible(&current_req));

        // Compatible range should work - including pre-release versions
        let compatible_req = VersionReq::parse(">=0.1.0-alpha.0, <2.0.0").unwrap();
        assert!(manager.is_compatible(&compatible_req));
    }

    #[test]
    fn test_migration_path() {
        let manager = VersionManager::new().unwrap();

        let from = Version::parse("0.1.0").unwrap();
        let to = Version::parse("0.2.0").unwrap();

        let path = manager.get_migration_path(&from, &to);
        assert_eq!(path.from, from);
        assert_eq!(path.to, to);
        assert!(!path.steps.is_empty() || !path.breaking_changes.is_empty());
    }

    #[test]
    fn test_api_deprecation() {
        let mut manager = VersionManager::new().unwrap();

        manager.deprecate_api("old_function", "Use new_function instead", None);
        assert!(manager.is_api_deprecated("old_function"));
        assert!(!manager.is_api_deprecated("new_function"));

        let deprecations = manager.get_current_deprecations();
        assert!(deprecations.iter().any(|d| d.api_name == "old_function"));
    }

    #[test]
    fn test_version_bump_validation() {
        let manager = VersionManager::new().unwrap();
        let current = manager.current_version();

        // Valid patch bump
        let next_patch = Version::new(current.major, current.minor, current.patch + 1);
        let validation = manager.validate_version_bump(&next_patch);
        assert!(validation.is_valid);

        // Invalid downgrade
        if current.patch > 0 {
            let downgrade = Version::new(current.major, current.minor, current.patch - 1);
            let validation = manager.validate_version_bump(&downgrade);
            assert!(!validation.is_valid);
        }
    }

    #[test]
    fn test_compatibility_matrix() {
        let matrix = CompatibilityMatrix::new();

        let v1 = Version::parse("1.0.0").unwrap();
        let v2 = Version::parse("1.1.0").unwrap();
        let v3 = Version::parse("2.0.0").unwrap();

        // Minor version upgrade should be compatible
        let result = matrix.check_compatibility(&v1, &v2);
        assert!(result.compatible);
        assert_eq!(result.level, CompatibilityLevel::MinorUpgrade);

        // Major version upgrade should be flagged
        let result = matrix.check_compatibility(&v1, &v3);
        // Should still be marked as compatible but with major upgrade level
        assert_eq!(result.level, CompatibilityLevel::MajorUpgrade);
    }

    #[test]
    fn test_stability_guarantees() {
        let manager = VersionManager::new().unwrap();
        let guarantees = manager.get_stability_guarantees();

        // Verify stability level based on version
        if manager.current_version().major == 0 {
            assert!(matches!(
                guarantees.api_level,
                ApiStabilityLevel::Experimental
            ));
        } else {
            assert!(matches!(guarantees.api_level, ApiStabilityLevel::Stable));
        }
    }

    #[test]
    fn test_utility_functions() {
        use super::utils::*;

        let stable_version = Version::parse("1.2.3").unwrap();
        let experimental_version = Version::parse("0.1.0").unwrap();
        let prerelease_version = Version::parse("1.0.0-alpha.1").unwrap();

        assert!(is_stable(&stable_version));
        assert!(!is_stable(&experimental_version));
        assert!(is_prerelease(&prerelease_version));

        assert_eq!(
            next_major(&stable_version),
            Version::parse("2.0.0").unwrap()
        );
        assert_eq!(
            next_minor(&stable_version),
            Version::parse("1.3.0").unwrap()
        );
        assert_eq!(
            next_patch(&stable_version),
            Version::parse("1.2.4").unwrap()
        );
    }
}