|
| 1 | +# Reset Logic Schema Component Issue |
| 2 | + |
| 3 | +## Issue Summary |
| 4 | + |
| 5 | +During test refactoring in `src/version/zerv/bump/vars_primary.rs`, we discovered a design flaw in the reset logic for version bumping. |
| 6 | + |
| 7 | +## Problem Description |
| 8 | + |
| 9 | +When bumping major/minor/patch versions, the current reset logic only resets `ZervVars` fields but doesn't handle schema components that depend on those fields. |
| 10 | + |
| 11 | +### Current Behavior |
| 12 | + |
| 13 | +- `ZervVars.pre_release` gets reset to `None` ✅ |
| 14 | +- `Component::VarField("pre_release")` in schema remains untouched ❌ |
| 15 | +- Build metadata and other non-ZervVars components persist ❌ |
| 16 | + |
| 17 | +### Expected Behavior (Semantic Versioning) |
| 18 | + |
| 19 | +- Major bump: `1.5.2-rc.1+build.456` → `2.0.0` (all lower precedence removed) |
| 20 | +- Minor bump: `1.5.2-rc.1+build.456` → `1.6.0` (patch, pre-release, build removed) |
| 21 | + |
| 22 | +## Technical Details |
| 23 | + |
| 24 | +### Components Affected |
| 25 | + |
| 26 | +- `Component::String(String)` - static, should remain |
| 27 | +- `Component::Integer(u64)` - static, should remain |
| 28 | +- `Component::VarField(String)` - **ISSUE**: should be reset when referenced ZervVar is reset |
| 29 | +- `Component::VarTimestamp(String)` - static pattern, should remain |
| 30 | + |
| 31 | +### Current Reset Implementation |
| 32 | + |
| 33 | +Located in `/src/version/zerv/bump/reset.rs`: |
| 34 | + |
| 35 | +- Only resets `ZervVars` fields (major, minor, patch, pre_release, post, dev, epoch) |
| 36 | +- Doesn't touch schema components in `extra_core` or `build` |
| 37 | + |
| 38 | +## Test Cases That Revealed the Issue |
| 39 | + |
| 40 | +```rust |
| 41 | +// These tests currently fail due to the bug: |
| 42 | +#[case("1.0.0+build.123", 1, "2.0.0")] // Expected: no build metadata |
| 43 | +#[case("1.5.2-rc.1+build.456", 1, "2.0.0")] // Expected: no pre-release or build |
| 44 | + |
| 45 | +// Current (incorrect) behavior: |
| 46 | +#[case("1.0.0+build.123", 1, "2.0.0+build.123")] // Build metadata persists |
| 47 | +#[case("1.5.2-rc.1+build.456", 1, "2.0.0+build.456")] // Build metadata persists |
| 48 | +``` |
| 49 | + |
| 50 | +## Proposed Solutions |
| 51 | + |
| 52 | +### Option A: Extend Reset Logic |
| 53 | + |
| 54 | +Modify `reset_lower_precedence_components` to also clean schema components: |
| 55 | + |
| 56 | +- Remove `VarField` components that reference reset ZervVars |
| 57 | +- Keep static `String`/`Integer` components |
| 58 | + |
| 59 | +### Option B: Schema-Aware Reset |
| 60 | + |
| 61 | +Create separate method to reset schema components based on precedence rules. |
| 62 | + |
| 63 | +### Option C: Architectural Change |
| 64 | + |
| 65 | +Move all dynamic data into `ZervVars` so reset logic is centralized. |
| 66 | + |
| 67 | +## Impact |
| 68 | + |
| 69 | +This affects semantic versioning compliance and could lead to incorrect version strings being generated during automated bumping. |
| 70 | + |
| 71 | +## Status |
| 72 | + |
| 73 | +- **Discovered**: During test refactoring |
| 74 | +- **Severity**: Medium (affects SemVer compliance) |
| 75 | +- **Complexity**: High (requires careful design consideration) |
| 76 | +- **Decision**: Deferred for later architectural review |
| 77 | + |
| 78 | +## Files Involved |
| 79 | + |
| 80 | +- `src/version/zerv/bump/reset.rs` - Current reset implementation |
| 81 | +- `src/version/zerv/bump/vars_primary.rs` - Test cases that revealed issue |
| 82 | +- `src/version/zerv/components.rs` - Component definitions |
| 83 | +- `src/version/semver/from_zerv.rs` - Conversion logic that shows the problem |
| 84 | + |
| 85 | +## Next Steps |
| 86 | + |
| 87 | +1. Review overall reset architecture |
| 88 | +2. Decide on approach (A, B, or C above) |
| 89 | +3. Implement solution with comprehensive tests |
| 90 | +4. Ensure SemVer compliance across all scenarios |
0 commit comments