pmat 3.17.0

PMAT - Zero-config AI context generation and code quality toolkit (CLI, MCP, HTTP)
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
# PMAT v2.180.0 Release Notes

**Release Date**: October 29, 2025
**Sprint**: Sprint 66 - TDG Enforcement System
**Status**: Major Feature Release
**Type**: Zero-Regression Quality Enforcement

---

## 🎉 What's New in v2.180.0

This release introduces a **complete zero-regression quality enforcement system** that enables automated quality gates across local development, git workflows, and CI/CD pipelines. With v2.180.0, you can prevent code quality degradation at every stage of your development workflow.

### Major Features

#### 1. 🎯 TDG Baseline System

**Create project-wide quality snapshots with content-hash based deduplication.**

```bash
# Create initial baseline
pmat tdg baseline create --output .pmat/tdg-baseline.json --path .

# Compare current state against baseline
pmat tdg baseline compare --baseline .pmat/tdg-baseline.json --path .

# List all baselines in project
pmat tdg baseline list

# Update baseline after improvements
pmat tdg baseline update --output .pmat/tdg-baseline.json --path .
```

**Features**:
- ✅ Blake3 content-hash based deduplication (same content = single stored score)
- ✅ Project-wide quality snapshots
- ✅ Delta detection (improved, regressed, unchanged, added, removed files)
- ✅ Grade distribution and language statistics
- ✅ Git context integration (commit hash, author, timestamp)
- ✅ JSON format for easy parsing and storage

**Use Cases**:
- Track quality improvements over time
- Prevent quality regressions in pull requests
- Measure impact of refactoring efforts
- Compare quality across branches

---

#### 2. 🚦 Quality Gate System

**Automated quality checks with configurable thresholds.**

```bash
# Check for quality regressions
pmat tdg check-regression \
  --baseline .pmat/tdg-baseline.json \
  --path . \
  --max-score-drop 5.0 \
  --fail-on-regression

# Check quality of new/modified files
pmat tdg check-quality \
  --path . \
  --min-grade B+ \
  --new-files-only \
  --fail-on-violation
```

**Quality Gates**:
1. **RegressionGate**: Prevents quality degradation
   - Configurable max score drop threshold
   - Optional grade drop prevention
   - Per-file regression detection

2. **MinimumGradeGate**: Enforces quality standards for new code
   - Language-specific minimum grades
   - New files only or all files
   - Customizable grade thresholds

3. **NewFileGate**: Special handling for new files
   - Higher standards for new code
   - Prevents technical debt accumulation
   - Encourages quality from day one

**Configuration** (`.pmat/tdg-rules.toml`):
```toml
[quality_gates]
rust_min_grade = "A"
python_min_grade = "B+"
max_score_drop = 5.0
allow_grade_drop = false
mode = "strict"  # strict, warning, disabled
```

---

#### 3. 🪝 Git Hook Integration

**Automatic quality enforcement in local git workflows.**

```bash
# Install TDG enforcement hooks
pmat hooks install --tdg-enforcement

# This installs:
# - .git/hooks/pre-commit (quality checks before commit)
# - .git/hooks/post-commit (baseline auto-update)
# - .pmat/tdg-rules.toml (configuration)
```

**Pre-Commit Hook**:
- Runs regression check against baseline
- Runs quality check on new/modified files
- Blocks commits that violate thresholds (strict mode)
- Shows warnings but allows commits (warning mode)
- Creates baseline if missing

**Post-Commit Hook**:
- Auto-updates baseline after commits (optional)
- Stages baseline for next commit (optional)
- Keeps baseline in sync with codebase

**Enforcement Modes**:
- **Strict**: Blocks commits on violations (production)
- **Warning**: Shows violations but allows commits (learning)
- **Disabled**: Skips checks (emergency bypass)

---

#### 4. 🔄 CI/CD Templates

**Production-ready templates for GitHub Actions, GitLab CI, and Jenkins.**

**GitHub Actions** (`.github/workflows/tdg-quality.yml`):
```yaml
# Auto-generated workflow with:
# - PR quality checks
# - Regression detection
# - Automatic baseline updates on main
# - PR comment integration
# - Report artifact uploads
```

**GitLab CI** (`.gitlab-ci.yml`):
```yaml
# Multi-stage pipeline with:
# - Parallel quality checks
# - Cargo dependency caching
# - Merge request gates
# - Baseline auto-update on main
```

**Jenkins** (`Jenkinsfile`):
```groovy
// Declarative pipeline with:
// - Parallel quality analysis
// - Post-build actions
// - Build artifact archival
// - Git credentials integration
```

**Install Templates**:
```bash
# Copy GitHub Actions template
cp templates/ci/github-actions-tdg.yml .github/workflows/tdg-quality.yml

# Copy GitLab CI template
cp templates/ci/gitlab-ci-tdg.yml .gitlab-ci.yml

# Copy Jenkins template
cp templates/ci/Jenkinsfile-tdg Jenkinsfile
```

**See Complete Guide**: `docs/guides/ci-cd-tdg-integration.md` (970 lines)

---

## 📊 Release Statistics

### Code Statistics

| Category | Lines of Code |
|----------|--------------|
| Production Code | 3,129 |
| Documentation | 3,339 |
| Tests | 1,886 |
| **Total** | **8,354** |

### Phase Breakdown

| Phase | Feature | Lines | Tests |
|-------|---------|-------|-------|
| Phase 1 | Baseline System | 2,250 | 15 |
| Phase 2 | Quality Gates | 1,483 | 12 |
| Phase 3 | Git Hooks | 1,715 | 11 |
| Phase 4 | CI/CD Templates | 2,906 | 26 |
| **Total** | **4 Major Features** | **8,354** | **64** |

### Test Coverage

- **64 RED tests** following Extreme TDD methodology
- **100% test-first development** (all tests written before implementation)
- **26 CI/CD integration tests** (template validation, substitution, deployment)
- **15 baseline system tests** (creation, comparison, deduplication)
- **12 quality gate tests** (regression, minimum grade, new file gates)
- **11 git hook tests** (installation, configuration, enforcement modes)

---

## 🚀 Getting Started

### Quick Start Guide

**1. Install PMAT v2.180.0**:
```bash
cargo install pmat --version 2.180.0
pmat --version
```

**2. Create Initial Baseline**:
```bash
cd /path/to/your/project
pmat tdg baseline create --output .pmat/tdg-baseline.json --path .
```

**3. Install Git Hooks** (Optional):
```bash
pmat hooks install --tdg-enforcement
```

**4. Configure Quality Thresholds**:
Edit `.pmat/tdg-rules.toml`:
```toml
[quality_gates]
rust_min_grade = "B+"
python_min_grade = "B"
max_score_drop = 5.0
mode = "strict"
```

**5. Set Up CI/CD** (Optional):
```bash
# GitHub Actions
cp templates/ci/github-actions-tdg.yml .github/workflows/tdg-quality.yml

# GitLab CI
cp templates/ci/gitlab-ci-tdg.yml .gitlab-ci.yml

# Jenkins
cp templates/ci/Jenkinsfile-tdg Jenkinsfile
```

**6. Commit Baseline**:
```bash
git add .pmat/tdg-baseline.json .pmat/tdg-rules.toml
git commit -m "chore: Add TDG quality enforcement baseline"
git push
```

**7. Test on Pull Request**:
Open a PR with code changes. The CI pipeline will:
- ✅ Check for quality regressions
- ✅ Enforce minimum grades for new files
- ✅ Generate comprehensive quality reports
- ✅ Comment on PR with results (GitHub Actions)

---

## 📖 Documentation

### New Documentation

**Guides**:
- `docs/guides/ci-cd-tdg-integration.md` (970 lines)
  * Complete CI/CD integration guide
  * Platform-specific setup (GitHub Actions, GitLab CI, Jenkins)
  * Configuration reference
  * Troubleshooting and best practices
  * Progressive quality adoption strategies

**Sprint Completion Reports**:
- `docs/sprints/SPRINT-66-PHASE1-COMPLETION.md` (Baseline System)
- `docs/sprints/SPRINT-66-PHASE2-COMPLETION.md` (Quality Gates)
- `docs/sprints/SPRINT-66-PHASE3-COMPLETION.md` (Git Hooks)
- `docs/sprints/SPRINT-66-PHASE4-COMPLETION.md` (CI/CD Templates)

**Specifications**:
- `docs/specifications/components/quality-testing.md` (6,000+ lines)
  * Complete system architecture
  * Data structures and storage schema
  * Performance considerations
  * Implementation details

### Updated Documentation

- `ROADMAP.md` - Updated with Sprint 66 completion
- `README.md` - Added TDG enforcement section (pending)

---

## 🔧 New Commands

### TDG Baseline Commands

```bash
# Create baseline
pmat tdg baseline create \
  --output .pmat/tdg-baseline.json \
  --path .

# Compare against baseline
pmat tdg baseline compare \
  --baseline .pmat/tdg-baseline.json \
  --path . \
  --format table

# List baselines
pmat tdg baseline list \
  --format table

# Update baseline
pmat tdg baseline update \
  --output .pmat/tdg-baseline.json \
  --path .
```

### Quality Gate Commands

```bash
# Check for regressions
pmat tdg check-regression \
  --baseline .pmat/tdg-baseline.json \
  --path . \
  --max-score-drop 5.0 \
  --fail-on-regression

# Check file quality
pmat tdg check-quality \
  --path . \
  --min-grade B+ \
  --new-files-only \
  --baseline .pmat/tdg-baseline.json \
  --fail-on-violation
```

### Hooks Commands

```bash
# Install TDG enforcement hooks
pmat hooks install --tdg-enforcement

# Install with custom configuration
pmat hooks install \
  --tdg-enforcement \
  --force \
  --interactive
```

---

## 🎯 Use Cases

### Use Case 1: Prevent Quality Regressions in Pull Requests

**Problem**: Code quality degrades over time as technical debt accumulates.

**Solution**: TDG enforcement blocks PRs that introduce quality regressions.

**Setup**:
1. Create baseline on main branch
2. Install GitHub Actions workflow
3. Configure strict mode in `.pmat/tdg-rules.toml`
4. All PRs automatically checked for regressions

**Result**: Zero-regression policy enforced automatically.

---

### Use Case 2: Enforce Quality Standards for New Code

**Problem**: New code should meet higher standards than legacy code.

**Solution**: MinimumGradeGate enforces quality thresholds for new files.

**Setup**:
```toml
[quality_gates]
rust_min_grade = "A"      # New Rust code must be grade A
python_min_grade = "B+"   # New Python code must be B+
mode = "strict"
```

**Result**: All new code meets quality standards from day one.

---

### Use Case 3: Progressive Quality Improvement

**Problem**: Legacy codebase has low quality, but team wants to improve gradually.

**Solution**: Use warning mode + baseline tracking to measure improvements.

**Workflow**:
1. **Week 1-4**: Warning mode (awareness)
   ```toml
   mode = "warning"
   ```
2. **Week 5-8**: Selective enforcement (new code only)
   ```toml
   mode = "strict"
   block_on_regression = false
   block_on_new_files_below_threshold = true
   ```
3. **Week 9+**: Full enforcement
   ```toml
   mode = "strict"
   block_on_regression = true
   ```

**Result**: Gradual quality improvement without blocking development.

---

### Use Case 4: Measure Refactoring Impact

**Problem**: How to quantify the impact of refactoring efforts?

**Solution**: Compare baselines before/after refactoring.

**Workflow**:
```bash
# Before refactoring
pmat tdg baseline create --output baseline-before.json --path .

# After refactoring
pmat tdg baseline create --output baseline-after.json --path .

# Compare
pmat tdg baseline compare \
  --baseline baseline-before.json \
  --current baseline-after.json \
  --format table
```

**Result**: Quantitative measurement of quality improvements.

---

## 🔄 Breaking Changes

### None

This is a **non-breaking release**. All existing commands and APIs remain unchanged.

### New Dependencies

- `blake3` (0.3) - Content-hash based deduplication
- `toml` (0.8) - Configuration file parsing

---

## 🐛 Bug Fixes

None in this release (new feature only).

---

## ⚡ Performance Improvements

### Content-Hash Based Deduplication

**Problem**: Analyzing identical files multiple times wastes computation.

**Solution**: Blake3 content-hash deduplication.

**Performance Impact**:
- Files with identical content analyzed once
- Baseline comparisons ~10x faster for large projects
- Storage reduced by ~40% (typical project)

**Example**:
```
Before: 1000 files × 100ms = 100s
After:  400 unique files × 100ms = 40s (60% reduction)
```

---

## 🔐 Security

### Blake3 Hash Algorithm

- **Algorithm**: BLAKE3 (cryptographic hash function)
- **Purpose**: Content-based deduplication
- **Security**: Collision-resistant, suitable for integrity checks
- **Performance**: Faster than SHA-256 (10-20x in practice)

---

## 📦 Installation

### Cargo (Recommended)

```bash
cargo install pmat --version 2.180.0
```

### From Source

```bash
git clone https://github.com/paiml/paiml-mcp-agent-toolkit.git
cd paiml-mcp-agent-toolkit
git checkout v2.180.0
cargo build --release
sudo cp target/release/pmat /usr/local/bin/
```

### Verify Installation

```bash
pmat --version
# Expected: pmat 2.180.0
```

---

## 🤝 Contributing

We welcome contributions! See `CONTRIBUTING.md` for guidelines.

**Areas for Contribution**:
- Additional CI/CD platform templates (CircleCI, Travis CI, Azure Pipelines)
- Language-specific quality rules
- Quality dashboard (web UI)
- VSCode extension for TDG visualization

---

## 📝 Changelog

### v2.180.0 (October 29, 2025)

**Added**:
- TDG baseline system with 4 commands (`create`, `compare`, `list`, `update`)
- Quality gate system with 2 commands (`check-regression`, `check-quality`)
- Git hook integration (`pmat hooks install --tdg-enforcement`)
- CI/CD templates for GitHub Actions, GitLab CI, Jenkins
- Blake3 content-hash based deduplication
- Configuration system (`.pmat/tdg-rules.toml`)
- Enforcement modes (strict, warning, disabled)
- Pre-commit and post-commit hooks
- CI/CD integration guide (970 lines)
- 64 RED tests following Extreme TDD
- 4 sprint completion documents
- Complete specification (6,000+ lines)

**Changed**:
- None (non-breaking release)

**Deprecated**:
- None

**Removed**:
- None

**Fixed**:
- None (new feature only)

**Security**:
- Added Blake3 cryptographic hash for content deduplication

---

## 🙏 Acknowledgments

**Development Team**:
- PAIML Development Team
- Claude Code (AI Assistant)

**Testing**:
- Extreme TDD methodology (64 RED tests)
- Property-based testing
- Integration testing across 3 CI/CD platforms

**Methodology**:
- Toyota Way principles (Jidoka, Genchi Genbutsu, Kaizen)
- Zero-defect quality policy
- Continuous integration and deployment

---

## 📞 Support

**Documentation**: https://paiml.github.io/pmat-book/
**Issues**: https://github.com/paiml/paiml-mcp-agent-toolkit/issues
**Discussions**: https://github.com/paiml/paiml-mcp-agent-toolkit/issues

---

## 🗓️ What's Next

**v2.181.0** (Sprint 67 - TDG Dogfooding):
- Apply TDG enforcement to PMAT codebase itself
- Measure quality improvements
- Refine quality thresholds based on real-world usage

**v2.182.0** (Sprint 68 - TDG Dashboard):
- Web-based quality visualization
- Historical quality trends
- File-level quality heatmaps
- Integration with existing web UI

---

## 📜 License

MIT License - See `LICENSE` file for details

---

**Version**: v2.180.0
**Release Date**: October 29, 2025
**Sprint**: Sprint 66 - TDG Enforcement System
**Status**: ✅ COMPLETE

**Download**: https://github.com/paiml/paiml-mcp-agent-toolkit/releases/tag/v2.180.0