embeddenator-workspace 0.20.0

Workspace management utilities for embeddenator development
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
# embeddenator-workspace

Workspace management utilities for developing the Embeddenator monorepo.

This crate provides CLI tools for managing version consistency, dependency updates, and documentation generation across the 11+ embeddenator repositories.

**Independent component** for managing the [Embeddenator workspace](https://github.com/tzervas/embeddenator).

**Repository:** [https://github.com/tzervas/embeddenator-workspace](https://github.com/tzervas/embeddenator-workspace)

## Features

- **Version Management**: Bump versions consistently across all packages
- **Dependency Tracking**: Check for version drift and inconsistencies
- **Workspace Health**: Comprehensive health checks for git, tests, docs, and specs
- **Patch Management**: Local development mode for git dependencies
- **Documentation Generation**: Build rustdoc and mdBook documentation

## Status

Alpha / internal use only.

## Installation

From the workspace root:

```bash
cargo build -p embeddenator-workspace --release
```

The binary will be available at `target/release/embeddenator-workspace`.

## Commands

### bump-version

Update package versions across all embeddenator crates and their inter-dependencies.

```bash
# Bump prerelease version (e.g., 0.20.0-alpha.1 → 0.20.0-alpha.2)
embeddenator-workspace bump-version --prerelease

# Bump patch version (e.g., 0.20.0-alpha.1 → 0.20.1)
embeddenator-workspace bump-version --patch

# Bump minor version (e.g., 0.20.0 → 0.21.0)
embeddenator-workspace bump-version --minor

# Bump major version (e.g., 0.20.0 → 1.0.0)
embeddenator-workspace bump-version --major

# Dry run - see what would change without making modifications
embeddenator-workspace bump-version --prerelease --dry-run
```

**What it does:**
1. Scans all `Cargo.toml` files in the workspace
2. Updates `package.version` in each embeddenator package
3. Updates dependency versions (e.g., `embeddenator-vsa = "0.20.0-alpha.1"`)
4. Writes changes to disk
5. Suggests a git commit command

**Example output:**
```
Performing Prerelease version bump...

Version Changes:
  embeddenator 0.20.0-alpha.1 → 0.20.0-alpha.2
  embeddenator-cli 0.20.0-alpha.1 → 0.20.0-alpha.2
  embeddenator-fs 0.21.0 → 0.21.1-alpha.1
  embeddenator-vsa 0.20.0-alpha.1 → 0.20.0-alpha.2
  ...

✓ 11 package(s) updated

Next: git commit -am "chore: bump version to 0.20.0-alpha.2"
```

### check-versions

Detect version inconsistencies and drift across the workspace.

```bash
# Check version consistency
embeddenator-workspace check-versions

# Show detailed information
embeddenator-workspace check-versions --verbose
```

**What it checks:**
- Version drift (packages on different major versions)
- Dependency mismatches (package A depends on package B v0.20.0 but B is at v0.21.0)
- Prerelease tag consistency

**Example output (with issues):**
```
Checking version consistency...

Scanned: 11 package(s)

Issues Found:
  • Version drift: 1 package(s) on major version 0: embeddenator-fs

Dependency Inconsistencies:
  • embeddenator-fs depends on embeddenator-vsa 0.20.0-alpha.1 (expected: 0.20.0-alpha.2)
  • embeddenator-retrieval depends on embeddenator-vsa 0.20.0-alpha.1 (expected: 0.20.0-alpha.2)

Suggestion: Run 'embeddenator-workspace bump-version --prerelease' to fix

# Exit code: 1
```

**Example output (no issues):**
```
Checking version consistency...

Scanned: 11 package(s)

✓ All versions are consistent!

# Exit code: 0
```

### health

Run comprehensive workspace health checks across all repositories.

```bash
# Run all health checks
embeddenator-workspace health

# Run specific checks only
embeddenator-workspace health --check git,version

# Show detailed output
embeddenator-workspace health --verbose

# Output as JSON for CI parsing
embeddenator-workspace health --json

# Save markdown report to file
embeddenator-workspace health --output health-report.md

# Specify workspace root
embeddenator-workspace health --workspace-root /path/to/workspace
```

**Health Check Categories:**

1. **Git Status** (`--check git`)
   - Dirty files (uncommitted changes)
   - Ahead/behind status vs upstream
   - Branch information
   - Orphaned upstream branches

2. **Version Alignment** (`--check version`)
   - Version consistency across packages
   - Dependency version drift
   - Prerelease tag alignment

3. **Test Coverage** (`--check tests`)
   - Run `cargo test` on all packages
   - Report pass/fail status
   - Identify failing test suites

4. **Documentation Coverage** (`--check docs`)
   - Run `cargo rustdoc` with `-D warnings`
   - Detect missing documentation
   - Count documentation warnings

5. **Spec Coverage** (`--check specs`)
   - Check for `specs/` directories
   - Calculate coverage percentage
   - Identify packages without specs

**Exit Codes:**
- `0`: All checks passed or warnings only
- `1`: Critical failures detected (dirty git, version drift, failing tests)

**Example output:**
```
════════════════════════════════════════════════════════════════════════════════
Workspace Health Report
════════════════════════════════════════════════════════════════════════════════
Generated: 2026-01-16T12:34:56-05:00
Workspace: /home/user/projects/embdntr
Overall Status: WARN

✓ git [Pass]
  All 11 repositories are clean and synced

✗ version [Fail]
  Version inconsistencies detected: 0 issue(s), 2 dependency mismatch(es)
    • embeddenator-fs depends on embeddenator-vsa 0.20.0 (expected: 0.20.1)
    • embeddenator-cli depends on embeddenator-vsa 0.20.0 (expected: 0.20.1)

✓ tests [Pass]
  Tests: 11 passed, 0 failed out of 11 packages

⚠ docs [Warn]
  Documentation: 9 clean, 2 with warnings out of 11 packages
    • embeddenator-io: 3 documentation warning(s)
    • embeddenator-obs: 1 documentation warning(s)

⚠ specs [Warn]
  Spec coverage: 81.8% (9/11 packages with specs/)
    • embeddenator-io: missing specs/ directory
    • embeddenator-obs: missing specs/ directory

════════════════════════════════════════════════════════════════════════════════
```

**JSON Output** (`--json`):
```json
{
  "timestamp": "2026-01-16T12:34:56-05:00",
  "workspace_root": "/home/user/projects/embdntr",
  "overall_status": "warn",
  "checks": [
    {
      "check_type": "git",
      "status": "pass",
      "message": "All 11 repositories are clean and synced",
      "details": []
    },
    {
      "check_type": "version",
      "status": "fail",
      "message": "Version inconsistencies detected",
      "details": [
        "embeddenator-fs depends on embeddenator-vsa 0.20.0 (expected: 0.20.1)"
      ]
    }
  ]
}
```

### patch-local / patch-reset

Manage local development patches for git dependencies (see [PATCH_MANAGEMENT_GUIDE.md](PATCH_MANAGEMENT_GUIDE.md)).

```bash
# Enable local development mode
embeddenator-workspace patch-local

# Disable and restore git dependencies
embeddenator-workspace patch-reset --clean
```

### docs / rustdoc / mdbook

Generate documentation:

```bash
# Generate both rustdoc and mdBook (if available)
embeddenator-workspace docs

# Generate only rustdoc
embeddenator-workspace rustdoc

# Generate only mdBook
embeddenator-workspace mdbook
```

## Typical Workflow

### Before a release:

1. **Run health checks**:
   ```bash
   embeddenator-workspace health
   ```

2. **Fix any critical issues** (version drift, failing tests)

3. **Check consistency**:
   ```bash
   embeddenator-workspace check-versions
   ```

4. **Bump versions** if needed:
   ```bash
   embeddenator-workspace bump-version --patch
   ```

5. **Verify changes**:
   ```bash
   git diff
   ```

6. **Commit**:
   ```bash
   git commit -am "chore: bump version to 0.20.1"
   git push
   ```

### During development:

Use `--dry-run` to preview changes:
```bash
embeddenator-workspace bump-version --prerelease --dry-run
```

Run specific health checks:
```bash
embeddenator-workspace health --check git,version
```

## Integration with CI

### Health Check Pipeline

```yaml
# .github/workflows/health-check.yml
name: Workspace Health Check

on: [pull_request]

jobs:
  health:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      
      - name: Build health checker
        run: cargo build -p embeddenator-workspace --release
      
      - name: Run health checks
        run: |
          ./target/release/embeddenator-workspace health --json > health-report.json
          ./target/release/embeddenator-workspace health --output health-report.md
      
      - name: Upload health report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: health-report
          path: |
            health-report.json
            health-report.md
      
      - name: Check for failures
        run: |
          if jq -e '.overall_status == "fail"' health-report.json; then
            echo "Health check failed!"
            exit 1
          fi
```

### Version Consistency Check

```yaml
# .github/workflows/version-check.yml
name: Version Consistency Check

on: [pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@stable
      - name: Check version consistency
        run: |
          cargo build -p embeddenator-workspace
          cargo run -p embeddenator-workspace -- check-versions
```

## Architecture

### Module Structure

- `cargo.rs` - Cargo.toml parsing and manipulation using `toml_edit`
- `version.rs` - Version bumping logic with `semver`
- `workspace.rs` - Repository discovery and scanning with `walkdir`
- `patch.rs` - Patch management for git dependencies
- `health.rs` - Comprehensive workspace health checking with parallel execution
- `bin/embeddenator_workspace.rs` - CLI interface using `clap`

### Design Principles

1. **Safety First**: All operations use `toml_edit` to preserve formatting and comments
2. **Parallel Execution**: Health checks run concurrently using `tokio` for performance
3. **Dry Run Support**: Preview changes before applying them
4. **Clear Output**: Color-coded, structured output for easy parsing
5. **Exit Codes**: Non-zero exit on errors for CI integration
6. **Multiple Output Formats**: Terminal (colorized), Markdown, and JSON

### Performance Characteristics

- **Health Check Parallelization**: All health checks run concurrently
  - Git status: ~50ms per repo × 11 repos = ~550ms sequential → ~100ms parallel
  - Version check: Single pass over all packages (~200ms)
  - Test execution: Longest running (~5-30s per package, run in parallel)
  - Doc check: ~2-5s per package (parallel)
  - Spec coverage: Fast filesystem scan (~50ms)
  
- **Expected Runtime**:
  - All checks with passing tests: 5-10 seconds
  - All checks with failing tests: 10-30 seconds (depends on test suites)
  - Specific checks only (`--check git,version`): <1 second

## Running

From anywhere in the workspace:

```bash
cargo run -p embeddenator-workspace -- --help
cargo run -p embeddenator-workspace -- health --help

## License

MIT