pmat 3.11.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
# Release Notes

This document details the latest changes, features, and bug fixes for the `pmat` crate.

## v0.28.9 - CI/CD Integration & Exit Codes

### ๐ŸŽฏ Summary

This release adds comprehensive CI/CD support to all analyze commands, enabling seamless integration with GitHub Actions, GitLab CI, Jenkins, and other CI/CD platforms.

### โœจ New Features

- **Exit Code Support** - All `analyze` commands now support `--fail-on-violation` flag
  - Exit code 0: Success - no violations found or within thresholds
  - Exit code 1: Failure - violations exceed configured thresholds
- **Configurable Thresholds**
  - Complexity: `--max-cyclomatic` (default: 20), `--max-cognitive` (default: 15)
  - Dead Code: `--max-percentage` (default: 15.0%)
  - SATD: Zero tolerance when using `--fail-on-violation`
- **New Examples** - Added 5 comprehensive CI/CD integration examples
- **Documentation** - Complete CI/CD integration guide for all major platforms

### ๐Ÿ“š Documentation Updates

- Updated README.md with CI/CD integration section
- Updated CLI reference with all new flags
- Created comprehensive CI/CD integration guide
- Added examples README with running instructions

### ๐Ÿ’ก Usage Examples

```bash
# GitHub Actions
pmat analyze complexity --max-cyclomatic 15 --fail-on-violation

# GitLab CI  
pmat analyze satd --strict --fail-on-violation

# Pre-commit hook
pmat analyze dead-code --max-percentage 10.0 --fail-on-violation
```

## v0.28.8 - Comprehensive Quality Improvements and Documentation Updates

### ๐ŸŽฏ Summary

This release represents a major quality uplift with comprehensive clippy lint improvements, property test enhancements, and complete documentation updates. All Rust code quality checks now pass with zero warnings.

### โœจ Improvements

- **Clippy Lint Resolution** - Fixed all 180+ clippy warnings across the codebase
- **Property Test Enhancement** - Improved all property tests with better strategies and coverage
- **SATD Detector Improvements** - Enhanced pattern matching and Unicode support
- **Dead Code Analysis** - More accurate detection with better ranking algorithms
- **Documentation Updates** - Comprehensive updates to all documentation

### ๐Ÿ› Bug Fixes

- Fixed Unicode handling in SATD detector
- Fixed dead code percentage calculations
- Fixed property test edge cases
- Fixed memory allocations in hot paths
- Fixed error handling in analysis commands

## v0.28.7 - Lint Hotspot Analysis Improvements

### ๐ŸŽฏ Summary

This release improves the `analyze lint-hotspot` command with bug fixes, enhanced UX, and comprehensive property-based testing.

### โœจ Improvements

- **Fixed clippy flag handling** - Changed from `-D warnings` to `-W warnings` to prevent early termination
- **Single file mode fix** - Added `--all-targets` flag to properly analyze individual files including examples
- **Enhanced error handling** - Improved handling of non-zero exit codes from clippy
- **Property test coverage** - Added 9 comprehensive property tests for lint-hotspot functionality
- **Documentation updates** - Updated CLI reference with accurate command options and examples

### ๐Ÿ› Bug Fixes

- **Fixed zero violations bug** - Single file analysis now correctly detects all violations
- **Fixed Makefile errors** - Replaced `cd server &&` with `--manifest-path` for proper workspace handling
- **Fixed property test timeouts** - Optimized WASM and Mermaid property tests from 1000 to 100 cases

### ๐Ÿงช Testing

- **Property Tests Added**:
  - Defect density calculation correctness
  - File summary consistency
  - Severity distribution validation
  - Top violations sorting
  - Hotspot detection accuracy
  - Machine-applicable suggestion validation
  - Line range validation
  - Zero SLOC handling

## v0.28.4 (2025-07-05) - Documentation Testing Infrastructure

### ๐ŸŽฏ Summary

This release focuses on improving the developer experience by fixing all doctest failures and adding comprehensive test infrastructure for documentation validation.

### โœจ New Features

- **`make test-doc` target** - New Makefile target to run all doctests
- **Comprehensive doctest coverage** - All public APIs now have validated example code
- **CI/CD integration ready** - Doctests can now be included in continuous integration

### ๐Ÿ› Bug Fixes

- **Fixed 50+ failing doctests** - Corrected import paths, added missing parameters, fixed trait imports
- **Resolved hanging tests** - Added `no_run` attribute to tests requiring runtime dependencies
- **Disk space management** - Fixed test failures due to `/tmp` filesystem exhaustion

### ๐Ÿ“Š Results

- 86 doctests passing, 7 ignored (API changes), 0 failing

## v0.28.0 (2025-07-04) - Comprehensive API Documentation & Quality Improvements

### ๐Ÿš€ Highlights

This major release delivers on **API drift prevention** through comprehensive executable documentation and significant quality improvements. Over **500+ executable doctests** have been added across all core interfaces to ensure API stability.

### โœจ New Features

#### ๐Ÿ“– Comprehensive API Documentation
- **500+ Executable Doctests** - Complete coverage of all public APIs with working examples
- **CLI Interface Documentation** - All analyze and reporting handlers fully documented with usage examples
- **HTTP API Documentation** - REST endpoints with curl examples and JavaScript integration patterns
- **MCP Protocol Documentation** - JSON-RPC 2.0 examples with complete message schemas
- **Core Services Documentation** - All priority services with integration examples

#### ๐Ÿ”ง Enhanced Services
- **Defect Report Service** - New comprehensive defect analysis and reporting system
- **Coupling Analyzer** - Advanced architectural dependency analysis
- **Project Analyzer** - Unified project-wide analysis capabilities
- **Ranking Utils** - File prioritization and hotspot identification

#### ๐Ÿงน Infrastructure Improvements
- **Aggressive /tmp Cleanup** - New `make clean-tmp` target for build environment management
- **Artifact Cleanup** - Removed obsolete documentation and temporary files
- **Enhanced Testing** - Fixed git repository handling in test environments

### ๐Ÿ› Bug Fixes

#### Test Stability
- **Fixed Defect Report Tests** - Proper git repository setup for integration tests
- **Fixed CLI Command Tests** - Resolved stack overflow in command structure parsing
- **Fixed Import Warnings** - Conditional compilation for optional features

#### Build Quality
- **All Quality Gates Pass** - Zero violations in complexity, lint, and technical debt checks
- **Test Suite Stability** - Comprehensive test fixes for reliable CI/CD

### ๐Ÿ“š Documentation Coverage

All critical interfaces now have comprehensive executable documentation:

1. **Core Services** (`code_intelligence.rs`, `refactor_engine.rs`, `cache/strategies.rs`)
2. **CLI Handlers** (`analysis_handlers.rs`, `enhanced_reporting_handlers.rs`, `stubs.rs`)
3. **HTTP Components** (`http.rs` adapter, `router.rs`)
4. **MCP Protocol** (`server.rs`, `state_manager.rs`, `handlers.rs`)
5. **Data Models** (`unified_ast.rs` with complete AST documentation)

### ๐Ÿ” Quality Metrics

- **Complexity**: Max cyclomatic complexity 10 (target: โ‰ค20) โœ…
- **Technical Debt**: 92 SATD items (mostly documentation) โœ…
- **Test Coverage**: Enhanced with git repository handling โœ…
- **API Stability**: 500+ doctests prevent interface drift โœ…

### ๐Ÿ”ง Developer Experience

- **API Drift Prevention** - Comprehensive examples ensure interface stability
- **Integration Examples** - Real-world usage patterns for all major components
- **Performance Patterns** - Async/await examples with tokio_test integration
- **Error Handling** - Complete error scenarios and recovery patterns

### Breaking Changes
None - all changes are backward compatible. This release focuses on documentation and quality improvements.

## v0.27.5 (2025-07-03) - Documentation & Build Fixes

### ๐Ÿš€ Highlights

This release focuses on documentation improvements, build fixes, and enhanced developer experience.

### โœจ New Features

#### Documentation
- **Demo Interface Documentation** - Comprehensive guide for web demo, TUI, and protocol demonstrations
- **TUI Interface Documentation** - Complete terminal UI guide with keyboard shortcuts and navigation
- **Interfaces Overview Guide** - Helps users choose the right interface (CLI, HTTP, MCP, Rust API, Web, TUI)
- **Enhanced CLI Reference** - Updated and moved to proper location in docs

#### Developer Experience
- **New Makefile Targets**:
  - `make crate-release` - Interactive publishing to crates.io with pre-publish checklist
  - `make crate-docs` - Build and verify documentation with docs.rs configuration

### ๐Ÿ› Bug Fixes

#### Build & CI
- **Fixed docs.rs build failures** - Wrapped demo asset includes with `#[cfg(not(docsrs))]` to handle missing files in docs.rs environment
- **Fixed CI workflow timeout** - Removed nested timeout command that was causing premature test termination
- **Fixed build.rs asset handling** - Create empty gzipped placeholders for docs.rs builds

### ๐Ÿ“š Documentation

All six PMAT interfaces are now fully documented:
1. **CLI** - Command-line interface (`/docs/cli-reference.md`)
2. **HTTP API** - REST endpoints (`/rust-docs/http-api.md`)
3. **MCP** - Model Context Protocol (`/docs/features/mcp-protocol.md`)
4. **Rust API** - Library integration (`/docs/api-guide.md`)
5. **Web Demo** - Interactive browser UI (`/docs/features/demo-interface.md`)
6. **TUI** - Terminal user interface (`/docs/features/tui-interface.md`)

### ๐Ÿ”ง Technical Details

- Version bump to 0.27.5 for crates.io publication
- Successfully building on docs.rs
- CI pipeline improvements for better reliability

### Breaking Changes
None - all changes are backward compatible

## v0.27.0 (2025-07-03) - Stateful MCP Server & Enhanced Testing

### ๐Ÿš€ Major Features

#### 1. **Stateful MCP Server for Refactor Auto**
- New persistent refactoring sessions via Model Context Protocol (MCP)
- State snapshots enable resumable refactoring workflows
- JSON-RPC API with four core methods: `start`, `nextIteration`, `getState`, `stop`
- Cap'n Proto schema prepared for future binary serialization
- Environment-based activation: `PMAT_REFACTOR_MCP=1`

#### 2. **GitHub Issue Integration**
- New `--github-issue <url>` flag for `refactor auto` command
- Automatically fetches issue context to guide refactoring decisions
- Intelligent keyword extraction and severity scoring
- Enhanced AI prompts with issue-specific context

#### 3. **Comprehensive Property-Based Testing**
- Added 500+ property tests across 6 critical components
- Covers AST parsers (Rust, TypeScript), state machines, caching, DAG operations
- Discovered and fixed multiple edge cases
- Significantly improved robustness and reliability

### New Files
- `server/src/mcp_server/` - Complete MCP server implementation
- `server/src/services/github_integration.rs` - GitHub API integration
- `server/src/services/ast_typescript_property_tests.rs` - TypeScript parser tests
- `server/src/schema/refactor_state.capnp` - Cap'n Proto schema
- `docs/mcp-stateful-server.md` - MCP server documentation
- `examples/mcp-refactor-demo.sh` - Demo script

### Improvements
- Enhanced error handling in snapshot operations
- Better test isolation with temp directories
- Atomic file operations for state persistence
- Thread-safe concurrent access patterns

### Bug Fixes
- Fixed SATD parser severity ordering
- Resolved DAG property test ownership issues
- Fixed proptest macro syntax errors
- Corrected string lifetime issues in tests

### Breaking Changes
- None - all changes are backward compatible

### Migration Guide
No migration needed. New features are opt-in:
- MCP server requires `PMAT_REFACTOR_MCP=1` environment variable
- GitHub integration requires explicit `--github-issue` flag

## v0.26.4 (2025-07-02) - Simplified Package Name

### ๐ŸŽ‰ Major Change: Crate Renamed to `pmat`

The crate has been renamed from `paiml-mcp-agent-toolkit` to simply `pmat` for easier installation:

```bash
# Before
cargo install paiml-mcp-agent-toolkit

# Now
cargo install pmat
```

### Breaking Changes
- **Package name changed** from `paiml-mcp-agent-toolkit` to `pmat`
- **Import paths changed** from `use paiml_mcp_agent_toolkit::` to `use pmat::`
- Binary name remains `pmat` (no change)

### Documentation Updates
- All documentation updated to reflect new installation command
- Updated crates.io badges and links
- Updated API usage examples with new import paths

### Migration Guide
For existing users:
1. Update your `Cargo.toml`:
   ```toml
   # Old
   paiml-mcp-agent-toolkit = "0.26"
   
   # New
   pmat = "0.26"
   ```

2. Update your imports:
   ```rust
   // Old
   use paiml_mcp_agent_toolkit::services::CodeAnalysisService;
   
   // New
   use pmat::services::CodeAnalysisService;
   ```

3. Reinstall the CLI tool:
   ```bash
   cargo uninstall paiml-mcp-agent-toolkit
   cargo install pmat
   ```

## v0.26.3 (2025-07-02) - Quality Uplift

### ๐Ÿ† Major Achievement: Zero Tolerance Quality Standards

This release represents a significant milestone in achieving the "Zero Tolerance Quality Standards" as defined by Toyota Way principles. The entire codebase has been systematically refactored to meet extreme quality standards.

### Quality Improvements

#### Complexity Reduction
- **Eliminated Extreme Complexity**: Reduced cyclomatic complexity across critical files:
  - `format_quality_gate_output`: 136 โ†’ delegated to 6 specialized functions (79% reduction)
  - `handle_refactor_auto`: 93 โ†’ 20 (78% reduction)
  - `format_output`: 73 โ†’ 20 (73% reduction)
  - `format_comprehensive_report`: 68 โ†’ 20 (71% reduction)
  - `handle_analyze_makefile`: 57 โ†’ 20 (65% reduction)
- **Target Achieved**: All functions now meet the strict threshold of 20 (target: 5 for new code)

#### Technical Debt Elimination
- **SATD Removal**: 100% elimination of Self-Admitted Technical Debt
  - Removed all TODO/FIXME/HACK comments from implementation files
  - Total SATD reduced from 84 to 0 in implementation code
  - Test data preserved for SATD detection functionality
- **Lint Violations**: Drastically reduced clippy violations
  - `refactor_auto_handlers.rs`: 194 โ†’ 9 (95% reduction)
  - `stubs.rs`: All critical errors fixed to pass quality gates
  - `graph_metrics.rs`: All blocking violations resolved

#### Quality Gates
- **Make Lint**: Now passes with extreme standards (`-D warnings -D clippy::pedantic -D clippy::nursery`)
- **Quality Gate**: Project-wide quality gate reports 0 violations
- **Test Coverage**: Path to 90% coverage established (currently 65%)

### Features Enhanced

#### Single File Mode (Restored)
All three critical tools now support targeted single-file operations:
```bash
pmat refactor auto --single-file-mode --file path/to/file.rs
pmat analyze lint-hotspot --file path/to/file.rs
pmat enforce extreme --file path/to/file.rs
```

This enables the Kaizen (continuous improvement) workflow for incremental quality improvements.

### Bug Fixes
- Fixed compilation errors with experimental `#[allow]` attributes on expressions
- Resolved `map_or` โ†’ `is_ok_and` conversions for idiomatic Rust
- Fixed redundant `min(65535)` on `u16::MAX` 
- Corrected raw string literal formatting (removed unnecessary hashes)
- Fixed format string interpolation (`{var}` instead of `{}`, var)
- Resolved similar names warnings while preserving semantic meaning

### Documentation Updates
- Created comprehensive quality verification document (`docs/7-2-2025-bugs.md`)
- Added single file mode feature documentation (`docs/features/single-file-mode.md`)
- Updated README with v0.26.3 quality achievements
- Migrated analysis artifacts from root to `docs/analysis/`
- Cleaned up root directory (removed `.profraw` files)

### Infrastructure
- All quality standards now enforced in CI/CD pipeline
- `make lint` integrated as quality gate
- Single file mode tests added to prevent regression

### Breaking Changes
None - Full backward compatibility maintained

### Migration Guide
No migration needed. All existing commands work as before with enhanced quality.

### Next Steps
- Increase test coverage from 65% to 90%
- Further reduce complexity in remaining files
- Implement property-based testing for critical paths

## v0.26.2 (2025-07-02)

### New Features

#### ๐Ÿš€ WebAssembly and AssemblyScript Support
- Added comprehensive WebAssembly analysis capabilities
- Two new analysis commands:
  - `pmat analyze assemblyscript` - Analyze AssemblyScript source code
  - `pmat analyze webassembly` - Analyze WebAssembly binary and text formats
- Features include:
  - **Complexity Analysis**: WASM-specific metrics including gas estimation
  - **Security Validation**: Basic security checks for WebAssembly modules
  - **Memory Analysis**: Memory pool management and optimization hints
  - **Parallel Processing**: Efficient analysis of multiple WASM files
  - **Multiple Output Formats**: JSON, SARIF, Markdown, and summary formats
- Supports file extensions: `.wasm` (binary), `.wat` (text), `.ts` (AssemblyScript)

#### ๐Ÿ”ง Language Support Expansion
- Added Language enum variants: `AssemblyScript = 14`, `WebAssembly = 15`
- Integrated with unified AST system for consistent analysis
- Memory-safe parsing with timeout protection and file size limits

### Improvements
- Enhanced language detection to support WebAssembly file types
- Added WASM-specific complexity metrics (cyclomatic, cognitive, memory pressure)
- Implemented iterative parsing to prevent stack overflow on large files

### Bug Fixes
- Fixed compilation issues with unused imports and variables
- Resolved pattern matching exhaustiveness in test files
- Fixed field assignment clippy warnings

## v0.26.1 (2025-07-02)

### New Features

#### ๐ŸŽฏ Property-Based Testing Integration
- Added property-based testing support to `pmat refactor auto`
- Automatically generates property tests that verify behavior preservation during refactoring
- Integrates with QuickCheck and proptest frameworks
- Ensures refactored code maintains semantic equivalence

#### ๐Ÿš€ Refactor Auto UX Improvements
- Enhanced `pmat refactor auto` output with clear instructions
- Now displays actionable next steps after generating refactoring requests
- Explicitly states 80% test coverage requirement
- Improved user guidance for successful refactoring workflow

#### ๐Ÿงน AI-Assisted Documentation Cleanup (`pmat refactor docs`)
- New command for maintaining Zero Tolerance Quality Standards in documentation
- Identifies and removes temporary files, outdated status reports, and build artifacts
- Features:
  - Pattern-based detection with customizable patterns
  - Interactive mode for reviewing each file before removal
  - Dry run mode to preview changes
  - Automatic backup before removing files
  - Age-based filtering (only remove files older than X days)
  - Preservation patterns to protect important files
- Default patterns include:
  - Temporary scripts: `fix-*`, `test-*`, `temp-*`, `tmp-*`
  - Status files: `*_STATUS.md`, `*_PROGRESS.md`, `*_COMPLETE.md`
  - Build artifacts: `*.mmd`, `optimization_state.json`, `complexity_report.json`

#### ๐Ÿ”ฅ EXTREME Quality Lint Hotspot Analysis
- `pmat analyze lint-hotspot` now uses EXTREME quality standards by default
- Automatically includes:
  - `-D warnings` - Zero tolerance for all warnings
  - `-D clippy::pedantic` - Strictest built-in lint group
  - `-D clippy::nursery` - Experimental lints
  - `-D clippy::cargo` - Cargo.toml manifest lints
  - `--all-targets` - Lints library, binaries, tests, and examples

### Improvements

#### ๐Ÿ—๏ธ Major Complexity Reduction Refactoring
- Refactored high-complexity functions achieving 95%+ complexity reduction
- `handle_analyze_dead_code`: Cognitive complexity 244 โ†’ 10 (96% reduction)
- `format_quality_gate_output`: Complexity 136 โ†’ 5 (96.3% reduction)
- `handle_analyze_churn`: Complexity 97 โ†’ 5 (94.8% reduction)
- Established refactoring pattern: main function delegates to focused helper functions
- All refactored code includes comprehensive test suites with >80% coverage

#### ๐Ÿ“š Documentation Organization
- Reorganized entire documentation structure following Zero Tolerance Quality Standards
- Implemented strict directory structure rules:
  - No loose markdown files in `docs/` root
  - Bug tracking in `docs/bugs/active/` and `docs/bugs/archived/`
  - Specifications in `docs/todo/active/` and `docs/todo/archive/`
  - Removed duplicate directories (kaizen, system-status)
- Added comprehensive documentation-organization-spec.md

### Bug Fixes
- Fixed compilation errors in refactor handlers
- Fixed test failures related to AST parsing
- Updated binary size limits to accommodate new features

### Technical Debt
- Achieved Zero SATD (Self-Admitted Technical Debt)
- All functions now below complexity threshold of 20
- Removed all temporary and work-in-progress files

## v0.26.0 (2025-01-20)

### New Features
- Complete Kotlin language support with memory-safe parsing
- 11 additional analysis features including graph metrics, name similarity, and symbol table
- ML-based defect prediction
- Lightweight formal verification (provability analysis)
- Incremental coverage tracking with git diff integration

### Known Limitations
- `pmat context` command may timeout on very large codebases (>1000 files) with AST analysis enabled
  - Workaround: Use specific paths or exclude patterns

## Previous Releases
See git history for details on earlier releases.