Skip to content

Commit 985de05

Browse files
authored
docs: update document to current state (#61)
- update document to current state - fix any error handling standard violation
1 parent ca38f01 commit 985de05

25 files changed

+713
-3024
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# CLI Implementation Standards
2+
3+
## Core Commands
4+
5+
### `zerv version [OPTIONS]`
6+
7+
Main version processing pipeline with composable operations.
8+
9+
### `zerv check <version> [OPTIONS]`
10+
11+
Validation-only command for version strings.
12+
13+
## Pipeline Architecture
14+
15+
```
16+
Input → Version Object → Zerv Object → Transform → Output Version Object → Display
17+
```
18+
19+
## Key Implementation Patterns
20+
21+
### Version Command Args Structure
22+
23+
```rust
24+
#[derive(Parser)]
25+
struct VersionArgs {
26+
version: Option<String>,
27+
#[arg(long, default_value = "git")]
28+
source: String,
29+
#[arg(long, default_value = "zerv-default")]
30+
schema: String,
31+
#[arg(long)]
32+
schema_ron: Option<String>,
33+
#[arg(long)]
34+
output_format: Option<String>,
35+
}
36+
```
37+
38+
### Check Command Args Structure
39+
40+
```rust
41+
#[derive(Parser)]
42+
struct CheckArgs {
43+
version: String,
44+
#[arg(long)]
45+
format: Option<String>, // pep440, semver, auto-detect (default)
46+
}
47+
```
48+
49+
### Core Pipeline Function
50+
51+
```rust
52+
pub fn run_version_pipeline(args: VersionArgs) -> Result<String> {
53+
// 1. Get VCS data
54+
let vcs_data = detect_vcs(current_dir())?.get_vcs_data()?;
55+
56+
// 2. Convert to ZervVars
57+
let vars = vcs_data_to_zerv_vars(vcs_data)?;
58+
59+
// 3. Apply schema and output format
60+
match args.output_format.as_deref() {
61+
Some("pep440") => Ok(PEP440::from_zerv(&vars)?.to_string()),
62+
Some("semver") => Ok(SemVer::from_zerv(&vars)?.to_string()),
63+
_ => Ok(vars.to_string()),
64+
}
65+
}
66+
```
67+
68+
## State-Based Versioning Tiers
69+
70+
**Tier 1** (Tagged, clean): `major.minor.patch`
71+
**Tier 2** (Distance, clean): `major.minor.patch.post<distance>+branch.<commit>`
72+
**Tier 3** (Dirty): `major.minor.patch.dev<timestamp>+branch.<commit>`
73+
74+
## Format Flag Validation Pattern
75+
76+
```rust
77+
// Error if conflicting format flags used
78+
if args.format.is_some() && (args.input_format.is_some() || args.output_format.is_some()) {
79+
return Err(ZervError::ConflictingFlags(
80+
"Cannot use --format with --input-format or --output-format".to_string()
81+
));
82+
}
83+
```
84+
85+
## Check Command Auto-Detection Pattern
86+
87+
```rust
88+
fn run_check_command(args: CheckArgs) -> Result<()> {
89+
match args.format.as_deref() {
90+
Some("pep440") => {
91+
PEP440::parse(&args.version)?;
92+
println!("✓ Valid PEP440 version");
93+
}
94+
Some("semver") => {
95+
SemVer::parse(&args.version)?;
96+
println!("✓ Valid SemVer version");
97+
}
98+
None => {
99+
// Auto-detect format
100+
let pep440_valid = PEP440::parse(&args.version).is_ok();
101+
let semver_valid = SemVer::parse(&args.version).is_ok();
102+
103+
match (pep440_valid, semver_valid) {
104+
(true, false) => println!("✓ Valid PEP440 version"),
105+
(false, true) => println!("✓ Valid SemVer version"),
106+
(true, true) => {
107+
println!("✓ Valid PEP440 version");
108+
println!("✓ Valid SemVer version");
109+
}
110+
(false, false) => return Err(ZervError::InvalidVersion(args.version)),
111+
}
112+
}
113+
Some(format) => return Err(ZervError::UnknownFormat(format.to_string())),
114+
}
115+
Ok(())
116+
}
117+
```
118+
119+
## Essential CLI Options
120+
121+
### Input Sources
122+
123+
- `--source git` (default) - Auto-detect Git
124+
- `--source string <version>` - Parse version string
125+
126+
### Schema Control
127+
128+
- `--schema zerv-default` (default) - Tier-aware schema
129+
- `--schema-ron <ron>` - Custom RON schema
130+
131+
### Output Control
132+
133+
- `--output-format <format>` - Target format: pep440, semver
134+
- `--output-template <template>` - Custom template string
135+
- `--output-prefix [prefix]` - Add prefix (defaults to "v")

.amazonq/rules/dev-workflow.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44

55
Before performing ANY coding task, **read `.dev/00-README.md`** for complete project context and workflow.
66

7+
## .dev Document Numbering
8+
9+
**Rule**: All .dev documents use sequential numbering to indicate creation order:
10+
11+
- `00-***.md`: Created at same point in time (current state)
12+
- `01-***.md`: Next development phase
13+
- `02-***.md`: Following phase
14+
- etc.
15+
16+
**Higher numbers = more recent/updated plans**
17+
18+
Always verify against actual codebase - higher numbered docs are more likely to be current.
19+
720
## Essential Commands
821

922
✅ Use `make` commands (defined in `.dev/00-README.md`)
@@ -22,6 +35,20 @@ Before performing ANY coding task, **read `.dev/00-README.md`** for complete pro
2235
- Include context in error messages for debugging
2336
- Use `io::Error::other()` instead of `io::Error::new(io::ErrorKind::Other, ...)`
2437

38+
## Performance Standards
39+
40+
- Parse 1000+ versions in <100ms
41+
- Minimal VCS command calls (batch when possible)
42+
- Use compiled regex patterns for speed
43+
- Zero-copy string operations where possible
44+
45+
## Architecture Patterns
46+
47+
- **Universal Format**: Component-based system with variable references
48+
- **Multi-Format Support**: PEP440, SemVer, template-based custom formats
49+
- **State-Based Tiers**: Tagged/Distance/Dirty states determine version components
50+
- **Pipeline Architecture**: Input → Parse → Transform → Output
51+
2552
**Error Standard Violations Check:**
2653

2754
When user mentions:

.amazonq/rules/docker-git-testing.md

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,63 @@ make test
207207
1. `src/test_utils/git/mod.rs` - GitOperations trait and exports
208208
2. `src/test_utils/git/docker.rs` - DockerGit implementation (local development)
209209
3. `src/test_utils/git/native.rs` - NativeGit implementation (CI testing)
210-
4. `src/config.rs` - Environment detection via `ZERV_CI` variable
211-
5. `src/test_utils/mod.rs` - `should_use_native_git()` helper function
210+
4. `src/config.rs` - Centralized environment variable loading via `ZERV_TEST_NATIVE_GIT` and `ZERV_TEST_DOCKER`
211+
5. `src/test_utils/mod.rs` - `should_use_native_git()` and `should_run_docker_tests()` helper functions
212+
213+
## Environment Variable Matrix
214+
215+
| Scenario | `ZERV_TEST_NATIVE_GIT` | `ZERV_TEST_DOCKER` | Git Implementation | Docker Tests | Result |
216+
| ---------------- | ---------------------- | ------------------ | ------------------ | ------------ | ------------------ |
217+
| Local Easy | `false` | `false` | Docker Git | Skipped | Coverage with gaps |
218+
| Local Full | `false` | `true` | Docker Git | Run | Full coverage |
219+
| CI Linux | `true` | `true` | Native Git | Run | Platform coverage |
220+
| CI macOS/Windows | `true` | `false` | Native Git | Skipped | Platform coverage |
221+
222+
## Centralized Configuration
223+
224+
**All environment variable loading centralized in `src/config.rs`:**
225+
226+
```rust
227+
#[derive(Debug, Clone, Default)]
228+
pub struct ZervConfig {
229+
pub test_native_git: bool, // ZERV_TEST_NATIVE_GIT
230+
pub test_docker: bool, // ZERV_TEST_DOCKER
231+
}
232+
233+
impl ZervConfig {
234+
pub fn load() -> Result<Self, Box<dyn std::error::Error>> {
235+
let test_native_git = Self::parse_bool_env("ZERV_TEST_NATIVE_GIT")?;
236+
let test_docker = Self::parse_bool_env("ZERV_TEST_DOCKER")?;
237+
Ok(ZervConfig { test_native_git, test_docker })
238+
}
239+
240+
fn parse_bool_env(var_name: &str) -> Result<bool, Box<dyn std::error::Error>> {
241+
match env::var(var_name) {
242+
Ok(val) => Ok(val == "true" || val == "1"),
243+
Err(_) => Ok(false),
244+
}
245+
}
246+
}
247+
```
248+
249+
**Key Behavior Changes:**
250+
251+
- Docker tests **fail** with clear error messages when `ZERV_TEST_DOCKER=true` but Docker unavailable
252+
- Policy enforcement: If Docker is available, tests must be enabled
253+
- Proper test separation between Docker-dependent and Docker-independent tests
212254

213255
## Current Testing Verification
214256

215257
```bash
216258
# Local test (uses DockerGit for isolation)
217-
make test
259+
make test_easy # Docker tests skipped
260+
make test # Docker tests enabled
218261

219262
# Test validation works
220263
cargo test test_docker_validation --lib
221264

222-
# Check specific git tests (Docker tests only run on Linux)
223-
cargo test git --include-ignored
265+
# Check specific git tests
266+
cargo test git
224267

225268
# Verify multi-platform CI passes
226269
git push # Check GitHub Actions on Linux, macOS, Windows
@@ -237,7 +280,7 @@ git push # Check GitHub Actions on Linux, macOS, Windows
237280
**Local Safety Maintained**:
238281

239282
-**Docker Isolation**: Protects personal git config during local development
240-
-**Environment Detection**: Automatic switching via `ZERV_CI=true`
283+
-**Environment Detection**: Automatic switching via `ZERV_TEST_NATIVE_GIT=true`
241284
-**Consistent API**: Same `GitOperations` trait for both implementations
242285

243286
## Architecture Evolution

.amazonq/rules/testing-standards.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
**CI Environment:**
1414

1515
- Use `NativeGit` for real platform testing (Windows/macOS/Linux)
16-
- Enabled automatically via `ZERV_CI=true` environment variable
16+
- Enabled automatically via `ZERV_TEST_NATIVE_GIT=true` environment variable
1717
- Tests actual platform-specific Git behavior, paths, line endings
1818

1919
**Implementation Pattern:**
@@ -31,6 +31,41 @@ fn get_git_impl() -> Box<dyn GitOperations> {
3131
}
3232
```
3333

34+
## Docker Test Control
35+
36+
**MANDATORY: Use `should_run_docker_tests()` for all Docker-dependent tests**
37+
38+
**Environment Variables:**
39+
40+
- `ZERV_TEST_DOCKER=true`: Enable Docker tests (requires Docker to be available)
41+
- `ZERV_TEST_DOCKER=false`: Skip Docker tests (default)
42+
43+
**Policy Enforcement:**
44+
45+
- If Docker is available on system, Docker tests MUST be enabled
46+
- Only skip Docker tests when Docker is genuinely unavailable
47+
- Tests will fail if `ZERV_TEST_DOCKER=true` but Docker is not available
48+
49+
**Implementation Pattern:**
50+
51+
```rust
52+
use crate::test_utils::should_run_docker_tests;
53+
54+
#[test]
55+
fn test_docker_functionality() {
56+
if !should_run_docker_tests() {
57+
return; // Skip when Docker tests are disabled
58+
}
59+
// Docker-dependent test code
60+
}
61+
```
62+
63+
**Make Commands:**
64+
65+
- `make test_easy`: Docker Git + Docker tests skipped (fast, coverage gaps)
66+
- `make test`: Docker Git + Docker tests enabled (full coverage)
67+
- CI: Native Git + Docker tests on Linux only
68+
3469
## Race Condition Prevention
3570

3671
**Atomic Operations Required:**

.dev/00-README.md

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,40 @@
1-
# .dev/
1+
# Zerv Development Guide
22

3-
Development documentation for zerv - Dynamic Versioning CLI
3+
## Quick Start
44

5-
## Project Status
5+
1. **Check current state**: Read `00-current-state.md`
6+
2. **Key files**: Reference `00-key-files.md`
7+
3. **Run tests**: `make test_easy` (quick) or `make test` (full)
8+
4. **Check rules**: `.amazonq/rules/` for coding standards
69

7-
**Current State**: Version parsing system implemented
8-
**Next Step**: Building Git VCS integration
9-
**Target**: Alpha release with Git support
10+
## Current Priority
1011

11-
## What's Implemented
12+
**CLI Implementation** - Core functionality exists, need CLI interface.
1213

13-
**Core Version System**
14+
## Architecture Overview
1415

15-
- Universal `Zerv` format with component-based structure
16-
- PEP440 version parsing, display, and conversion
17-
- SemVer version parsing, display, and conversion
18-
- Comprehensive test coverage (91.40%)
19-
20-
**Development Infrastructure**
21-
22-
- Docker-based testing for Git integration
23-
- Fast local tests without external dependencies
24-
- Makefile workflow with linting and formatting
25-
26-
## Development Workflow
16+
```
17+
CLI → VCS Detection → Tag Parsing → Format Output
18+
```
2719

28-
```bash
29-
# Fast development cycle (no Docker required)
30-
make lint # Format and check code
31-
make run # Test CLI binary
20+
**Key Components:**
3221

33-
# Full validation (includes Docker tests)
34-
make test # Run all tests including Docker integration
35-
make setup_dev # Install development dependencies
36-
```
22+
- **VCS Layer**: Extract git metadata (`src/vcs/`)
23+
- **Version System**: Parse/convert formats (`src/version/`)
24+
- **Pipeline**: Transform data (`src/pipeline/`)
25+
- **CLI**: User interface (`src/cli/` - needs work)
3726

38-
## Architecture
27+
## Testing Strategy
3928

40-
```
41-
src/version/
42-
├── zerv/ # Universal version format
43-
├── pep440/ # PEP440 implementation
44-
├── semver/ # SemVer implementation
45-
└── mod.rs # Public API
46-
```
29+
- **Local**: Docker Git for isolation
30+
- **CI**: Native Git for platform testing
31+
- **237 tests** with multi-platform coverage
4732

48-
## Files
33+
## Environment Variables
4934

50-
- `current-state.md` - Detailed implementation status
51-
- `new-cli-design.md` - Pipeline CLI architecture design
52-
- `roadmap.md` - Development roadmap to alpha release
53-
- `archived-insights.md` - Valuable concepts from old documentation
54-
- `.cache/` - Archived old documentation (preserved for reference)
35+
- `ZERV_TEST_NATIVE_GIT=true` - Use native Git (CI only)
36+
- `ZERV_TEST_DOCKER=true` - Enable Docker tests (Linux only)
5537

56-
## Next Phase
38+
## Next Steps
5739

58-
Git VCS integration + pipeline CLI (`zerv version` with `zerv-default` schema)
40+
Focus on `src/cli/app.rs` implementation to wire existing components together.

0 commit comments

Comments
 (0)