xchecker 1.2.0

Spec pipeline with receipts and gateable JSON contracts
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
# Platform Support Guide


This document describes xchecker's cross-platform support, platform-specific features, and troubleshooting guidance.

## Supported Platforms


xchecker supports the following platforms:

| Platform | Support Level | Runner Modes | Notes |
|----------|--------------|--------------|-------|
| **Linux** | ✅ Full | Native | Best performance, native execution |
| **macOS** | ✅ Full | Native | Full support, native execution |
| **Windows** | ✅ Full | Native, WSL, Auto | Native or WSL execution |
| **WSL2** | ✅ Full | WSL | Recommended over WSL1 |
| **WSL1** | ⚠️ Limited | WSL | Slower, use WSL2 if possible |

## Platform-Specific Features


### Linux


**Advantages:**
- Best overall performance
- Native process control with `killpg`
- Excellent file system performance
- SIMD optimizations for BLAKE3
- No translation overhead

**Process Termination:**
- Uses `killpg` for process group termination
- TERM signal → 5s grace period → KILL signal
- Reliable child process cleanup

**File System:**
- Atomic rename on same filesystem
- Cross-filesystem fallback (copy+fsync+replace)
- POSIX mode bit preservation

**Example:**
```bash
# Native execution (default)

xchecker spec my-feature

# Verify runner mode

xchecker doctor --json | jq '.checks[] | select(.name == "runner_selection")'
```

### macOS


**Advantages:**
- Full native support
- Good file system performance
- SIMD optimizations for BLAKE3
- Native process control

**Process Termination:**
- Uses `killpg` for process group termination
- TERM signal → 5s grace period → KILL signal
- Reliable child process cleanup

**File System:**
- Atomic rename on same filesystem
- Cross-filesystem fallback (copy+fsync+replace)
- POSIX mode bit preservation

**Known Issues:**
- Case-insensitive file system by default (APFS)
- May affect file path matching in some cases

**Example:**
```bash
# Native execution (default)

xchecker spec my-feature

# Check file system case sensitivity

diskutil info / | grep "Case-sensitive"
```

### Windows (Native)


**Advantages:**
- Native execution without WSL
- Windows-specific optimizations
- Job Objects for process tree termination
- Retry logic for antivirus/indexer locks

**Process Termination:**
- Uses Job Objects for process tree termination
- Ensures all child processes are terminated
- Handles nested process hierarchies

**File System:**
- Atomic rename with retry logic (≤250ms)
- Handles antivirus/indexer transient locks
- File attribute preservation
- CRLF tolerance on read, LF enforcement on write

**Retry Logic:**
```
Attempt 1: Immediate rename
Attempt 2: Wait 10ms, retry
Attempt 3: Wait 20ms, retry
Attempt 4: Wait 40ms, retry
Attempt 5: Wait 80ms, retry
Total: ≤250ms
```

**Known Issues:**
- Antivirus scanning can slow file operations
- Windows Defender may scan new files
- Path length limit (260 characters by default)

**Solutions:**
- Exclude `.xchecker/` from antivirus scanning
- Enable long path support: `HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled`
- Use WSL if native performance is insufficient

**Example:**
```bash
# Native execution (default)

xchecker spec my-feature

# Verify Job Objects are working

xchecker doctor --json | jq '.checks[] | select(.name == "timeout_enforcement")'
```

### Windows (WSL)


**Advantages:**
- Linux environment on Windows
- Access to Linux tools and Claude CLI
- Better compatibility with Linux-based workflows
- Fallback when native Claude unavailable

**WSL Modes:**
- **WSL2**: Recommended, better performance, full Linux kernel
- **WSL1**: Legacy, slower, translation layer

**Path Translation:**
- Windows paths → WSL paths: `C:\path\to\file``/mnt/c/path/to/file`
- Uses `wslpath -a` for canonical translation
- Fallback heuristic if `wslpath` unavailable

**Process Execution:**
- Uses `wsl.exe --exec` with discrete argv
- No shell quoting issues
- Proper argument passing

**File System:**
- Artifacts persist in Windows spec root
- Cross-filesystem performance impact
- Path translation adds latency

**Runner Distro:**
- Captured from `wsl -l -q` or `$WSL_DISTRO_NAME`
- Included in receipts as `runner_distro`
- Configurable via `--runner-distro`

**Example:**
```bash
# WSL execution (explicit)

xchecker spec my-feature --runner-mode wsl

# WSL with specific distro

xchecker spec my-feature --runner-mode wsl --runner-distro Ubuntu-22.04

# Auto mode (native first, WSL fallback)

xchecker spec my-feature --runner-mode auto
```

## Runner Mode Selection


### Auto Mode (Recommended)


Auto mode automatically selects the best available runner:

1. **Try Native**: Check if Claude CLI is in Windows PATH
2. **Fallback to WSL**: If native unavailable, try WSL
3. **Error**: If neither available, exit with helpful error

**Example:**
```bash
# Auto mode (default)

xchecker spec my-feature

# Explicit auto mode

xchecker spec my-feature --runner-mode auto
```

### Native Mode


Force native execution, fail if Claude CLI not available:

**Example:**
```bash
# Native mode (explicit)

xchecker spec my-feature --runner-mode native

# Verify native Claude

where claude  # Windows
which claude  # Linux/macOS
```

### WSL Mode


Force WSL execution, fail if WSL not available:

**Example:**
```bash
# WSL mode (explicit)

xchecker spec my-feature --runner-mode wsl

# WSL with specific distro

xchecker spec my-feature --runner-mode wsl --runner-distro Ubuntu-22.04

# List available distros

wsl -l -v
```

## Platform-Specific Configuration


### Linux Configuration


```toml
# .xchecker/config.toml

[runner]
mode = "native"
claude_path = "/usr/local/bin/claude"

[selectors]
# Linux-specific patterns

include = [
    "src/**/*.rs",
    "Cargo.toml",
    "*.sh"
]
exclude = [
    "target/**",
    ".git/**"
]
```

### macOS Configuration


```toml
# .xchecker/config.toml

[runner]
mode = "native"
claude_path = "/usr/local/bin/claude"

[selectors]
# macOS-specific patterns

include = [
    "src/**/*.rs",
    "Cargo.toml",
    "*.sh"
]
exclude = [
    "target/**",
    ".git/**",
    ".DS_Store"
]
```

### Windows Native Configuration


```toml
# .xchecker/config.toml

[runner]
mode = "native"
claude_path = "C:\\Program Files\\Claude\\claude.exe"

[selectors]
# Windows-specific patterns

include = [
    "src/**/*.rs",
    "Cargo.toml",
    "*.ps1",
    "*.bat"
]
exclude = [
    "target/**",
    ".git/**",
    "*.tmp"
]
```

### Windows WSL Configuration


```toml
# .xchecker/config.toml

[runner]
mode = "wsl"
distro = "Ubuntu-22.04"
claude_path = "/usr/local/bin/claude"

[selectors]
# WSL-specific patterns

include = [
    "src/**/*.rs",
    "Cargo.toml",
    "*.sh"
]
exclude = [
    "target/**",
    ".git/**"
]
```

## Platform-Specific Troubleshooting


### Linux Issues


#### Permission Denied


**Symptom:** `Permission denied` when executing Claude CLI

**Solution:**
```bash
# Check Claude CLI permissions

ls -l $(which claude)

# Make executable if needed

chmod +x $(which claude)

# Verify execution

claude --version
```

#### File System Errors


**Symptom:** `EXDEV` error during atomic rename

**Solution:**
- Ensure `.xchecker/` is on same filesystem as project
- Check for cross-filesystem mounts
- Verify disk space available

### macOS Issues


#### Gatekeeper Blocking


**Symptom:** "Claude cannot be opened because the developer cannot be verified"

**Solution:**
```bash
# Allow Claude CLI

xattr -d com.apple.quarantine $(which claude)

# Or via System Preferences

# System Preferences → Security & Privacy → Allow

```

#### Case Sensitivity


**Symptom:** File path mismatches due to case-insensitive file system

**Solution:**
- Use consistent casing in file paths
- Consider case-sensitive APFS volume for development
- Check file system: `diskutil info / | grep "Case-sensitive"`

### Windows Native Issues


#### Antivirus Interference


**Symptom:** Slow file operations, timeout errors

**Solution:**
```powershell
# Exclude .xchecker from Windows Defender

Add-MpPreference -ExclusionPath "C:\path\to\project\.xchecker"

# Verify exclusions

Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
```

#### Path Length Limit


**Symptom:** `ERROR_PATH_TOO_LONG` or similar errors

**Solution:**
```powershell
# Enable long path support (requires admin)

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
  -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

# Restart required

Restart-Computer
```

#### Claude Not Found


**Symptom:** `'claude' is not recognized as an internal or external command`

**Solution:**
```powershell
# Check if Claude is in PATH

where claude

# Add Claude to PATH if needed

$env:PATH += ";C:\Program Files\Claude"

# Verify

claude --version
```

### Windows WSL Issues


#### WSL Not Installed


**Symptom:** `WSL is not available` error

**Solution:**
```powershell
# Install WSL

wsl --install

# Restart required

Restart-Computer

# Verify installation

wsl -l -v
```

#### Claude Not in WSL


**Symptom:** `Claude CLI not found in WSL` error

**Solution:**
```bash
# Install Claude in WSL

wsl -e bash -c "curl -fsSL https://claude.ai/install.sh | sh"

# Verify installation

wsl -e claude --version
```

#### WSL Path Translation


**Symptom:** `Invalid path` errors when using WSL

**Solution:**
```bash
# Verify wslpath is available

wsl -e wslpath -a "C:\path\to\file"

# Check WSL distro

wsl -l -v

# Set default distro if needed

wsl --set-default Ubuntu-22.04
```

#### WSL Performance


**Symptom:** Slow execution in WSL mode

**Solution:**
```powershell
# Upgrade to WSL2

wsl --set-version Ubuntu-22.04 2

# Verify WSL2

wsl -l -v

# Keep files in WSL filesystem for better performance

wsl -e bash -c "cd ~ && git clone <repo>"
```

## Performance Comparison


### Benchmark Results


Typical performance across platforms (100 files, 5 iterations):

| Platform | Dry Run | Packetization | JCS Emission |
|----------|---------|---------------|--------------|
| **Linux** | 1.8s | 95ms | 18ms |
| **macOS** | 2.3s | 125ms | 24ms |
| **Windows Native** | 2.9s | 145ms | 28ms |
| **Windows WSL2** | 3.7s | 175ms | 30ms |
| **Windows WSL1** | 5.2s | 245ms | 35ms |

### Performance Recommendations


1. **Linux**: Best performance, use for CI/CD
2. **macOS**: Good performance, native development
3. **Windows Native**: Good performance, use if Claude available
4. **Windows WSL2**: Moderate performance, use if native unavailable
5. **Windows WSL1**: Upgrade to WSL2 for better performance

## Platform-Specific Best Practices


### Linux


1. Use native execution (best performance)
2. Ensure Claude CLI in PATH
3. Use SSD storage for `.xchecker/`
4. Monitor disk space

### macOS


1. Use native execution
2. Handle Gatekeeper prompts
3. Be aware of case-insensitive file system
4. Use SSD storage for `.xchecker/`

### Windows Native


1. Exclude `.xchecker/` from antivirus
2. Enable long path support
3. Use SSD storage for `.xchecker/`
4. Monitor disk space
5. Consider WSL if performance insufficient

### Windows WSL


1. Use WSL2 (not WSL1)
2. Keep files in WSL filesystem when possible
3. Use `wslpath` for path translation
4. Set default distro explicitly
5. Monitor cross-filesystem performance

## CI/CD Platform Support


### GitHub Actions


```yaml
name: xchecker CI

on: [push, pull_request]

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    
    steps:
      - uses: actions/checkout@v3
      
      - name: Install xchecker
        run: cargo install xchecker
      
      - name: Run doctor
        run: xchecker doctor --strict-exit
      
      - name: Run benchmarks
        run: xchecker benchmark --json
```

### GitLab CI


```yaml
test:linux:
  image: rust:latest
  script:
    - cargo install xchecker
    - xchecker doctor --strict-exit
    - xchecker benchmark --json

test:macos:
  tags: [macos]
  script:
    - cargo install xchecker
    - xchecker doctor --strict-exit
    - xchecker benchmark --json

test:windows:
  tags: [windows]
  script:
    - cargo install xchecker
    - xchecker doctor --strict-exit
    - xchecker benchmark --json
```

## Platform Testing


### Testing Checklist


- [ ] Native execution works
- [ ] WSL execution works (Windows only)
- [ ] Auto mode selects correct runner
- [ ] File operations are atomic
- [ ] Process termination works correctly
- [ ] Path translation works (WSL only)
- [ ] Performance meets targets
- [ ] Doctor checks pass

### Platform-Specific Tests


```bash
# Linux/macOS

cargo test --all-features

# Windows Native (parallel execution may cause flaky tests)

cargo test --all-features

# Windows Native (recommended for CI - avoids env var race conditions)

cargo test --all-features -- --test-threads=1

# Windows WSL

cargo test --all-features -- --test-threads=1
```

### Known Test Isolation Issues


Some tests modify environment variables (e.g., `OPENROUTER_API_KEY`, `XCHECKER_OPENROUTER_BUDGET`) which are not thread-safe in Rust. When tests run in parallel, they can interfere with each other's environment variables, causing intermittent failures.

**Affected tests:**
- `llm::factory_tests::test_openrouter_backend_is_budgeted`
- `llm::factory_tests::test_openrouter_budget_exhaustion_in_production_path`
- `llm::budgeted_backend::tests::test_budget_precedence_env_over_config`

**Workaround:** Run tests with `--test-threads=1` to ensure serial execution:
```bash
cargo test --all-features -- --test-threads=1
```

**Note:** This is a known limitation of Rust's test framework when tests modify global state (environment variables). The tests pass reliably when run serially.

## Platform Support Roadmap


### Current Support (v1.0)

- ✅ Linux native execution
- ✅ macOS native execution
- ✅ Windows native execution
- ✅ Windows WSL2 execution
- ✅ Windows WSL1 execution (limited)
- ✅ Auto runner mode selection

### Future Support

- ⏳ FreeBSD native execution
- ⏳ ARM64 Linux support
- ⏳ ARM64 macOS support (Apple Silicon)
- ⏳ ARM64 Windows support
- ⏳ Docker container execution

## References


- [Runtime Requirements]../contributor/REQUIREMENTS_RUNTIME_V1.md - FR-WSL, NFR3, NFR4
- [Architecture]../explanation/ARCHITECTURE.md - Crate layout and execution model