pmat 2.213.14

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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
# PMAT Implementation Roadmap
# Extreme TDD with Zero Tolerance Quality Gates

meta:
  project: PMAT - Pragmatic AI Labs Multi-language Agent Toolkit
  approach: Extreme Test-Driven Development
  quality_gates:
    max_complexity: 10
    max_cognitive: 7
    min_coverage: 0.95
    min_mutation_score: 0.90
    satd_tolerance: 0
  execution:
    ticket_workflow: RED-GREEN-REFACTOR
    commit_strategy: atomic_per_ticket
    build_verification: mandatory_clean

# COMPLETED SPRINTS (v2.167.0 - v2.180.1)
completed_sprints:
  - id: sprint-66
    name: "TDG Enforcement System"
    status: "✅ COMPLETE"
    version: "v2.180.0"
    date: "October 29, 2025"
    deliverables:
      - "TDG baseline tracking with Blake3 content-hash"
      - "Quality gates (RegressionGate, MinimumGradeGate, NewFileGate)"
      - "Git hook integration (pre-commit, post-commit)"
      - "CI/CD templates (GitHub Actions, GitLab CI, Jenkins)"
      - "3,129 lines of production code"
      - "1,886 lines of tests (64 RED tests)"
      - "3,339 lines of documentation"

  - id: sprint-67
    name: "TDG Dogfooding"
    status: "✅ COMPLETE"
    version: "v2.180.1"
    date: "October 29, 2025"
    deliverables:
      - "Dogfooded TDG enforcement on PMAT codebase"
      - "851 files analyzed, 93.0 avg score (A grade)"
      - "Critical bugfix: hardcoded sled backend → libsql"
      - "< 4 hour turnaround from bug discovery to hotfix"
      - "Validated TDG system works at scale"

  - id: sprint-69
    name: "pmat-book TDG Chapter & Integration Reports"
    status: "✅ COMPLETE"
    date: "October 29, 2025"
    deliverables:
      - "Chapter 4.2: TDG Enforcement System (824 lines)"
      - "Published to https://paiml.github.io/pmat-book/"
      - "TDG integration reports: ruchy, bashrs, ruchyruchy (1,159 lines)"
      - "GitHub issues filed for all 3 PAIML projects"
      - "Mutation testing enhancement specification (952 lines)"

  - id: sprint-71
    name: "Known Defects v2.1: Zero Tolerance Production Defects"
    status: "✅ COMPLETE"
    version: "v2.199.0"
    date: "November 21, 2025"
    deliverables:
      - "TDG Auto-Fail: Files with critical defects get Score: 0.0, Grade: F"
      - "pmat analyze defects: Multi-format CLI (text/json/junit)"
      - "RustDefectDetector: RUST-UNWRAP-001 pattern with Cloudflare evidence"
      - "Test code exclusion: tests/, benches/, #[cfg(test)]"
      - "Exit code semantics: 1 for critical defects (CI/CD integration)"
      - "pmat-book updates: Chapter 4.1 (TDG), Chapter 5 (Analyze Suite)"
      - "Cross-references: TDG ↔ analyze defects ↔ rust-project-score"
    evidence:
      - "Cloudflare outage 2025-11-18 (3+ hours global disruption from .unwrap())"
      - "server/src/services/defect_detector.rs (207 lines)"
      - "server/src/cli/handlers/analyze_defects_handler.rs (261 lines)"
      - "TdgScore fields: critical_defects_count, has_critical_defects"
    testing:
      - "All library tests passing (4841 tests)"
      - "Test path exclusion verified (tests/integration_test.rs)"
      - "TdgScore struct fields added to all test initializations"

# ACTIVE SPRINTS
sprints:
  # SPRINT 70: cargo-mutants Wrapper (CURRENT)
  - id: sprint-70
    name: "cargo-mutants Wrapper"
    goal: "Replace defective generic mutation operators with cargo-mutants wrapper"
    status: "🚀 STARTING"
    priority: "HIGH (fix 0% effectiveness defect)"
    duration: "1-2 weeks"
    target_version: "v2.181.0 or v2.182.0"

    problem:
      description: "PMAT mutation testing has 0% kill rate due to generic operators"
      evidence:
        - "178 mutants generated across bashrs codebase"
        - "0 mutants killed by tests (100% survival rate)"
        - "Generic operators (AOR, ROR, COR, UOR) produce invalid/irrelevant mutations"
        - "cargo-mutants has proven ≥90% kill rate"

    solution:
      approach: "Wrap cargo-mutants (subprocess wrapper) instead of re-implementing"
      benefits:
        - "Achieve ≥90% kill rate (match cargo-mutants effectiveness)"
        - "Zero maintenance burden (community maintains cargo-mutants)"
        - "Maintain PMAT interface (seamless user experience)"
        - "1-2 weeks vs 3-4 weeks for re-implementation"

    implementation_phases:
      week_1:
        name: "Core Wrapper"
        days: "Days 1-5"
        tasks:
          day_1_2:
            goal: "Infrastructure"
            deliverables:
              - "Create server/src/mutation/cargo_mutants_wrapper.rs"
              - "Add which dependency to Cargo.toml"
              - "Implement CargoMutantsWrapper::new()"
              - "Handle cargo-mutants not installed gracefully"
            success_criteria:
              - "Can detect cargo-mutants in PATH"
              - "Can execute cargo-mutants --version"
              - "Graceful error if not installed"
              - "Unit tests passing"

          day_3_4:
            goal: "JSON Parsing"
            deliverables:
              - "Define CargoMutantsReport struct"
              - "Implement JSON parsing with serde"
              - "Implement to_pmat_report() conversion"
              - "Handle edge cases (no mutants, timeouts, unviable)"
            success_criteria:
              - "Can parse all cargo-mutants JSON formats"
              - "Handles all mutant outcomes (killed, survived, timeout, unviable)"
              - "Converts to PMAT MutationReport correctly"
              - "Edge case handling tested"

          day_5:
            goal: "CLI Integration"
            deliverables:
              - "Update handle_mutate_command() to use wrapper"
              - "Pass through cargo-mutants arguments"
              - "Add --cargo-mutants-args for advanced users"
              - "Display PMAT-formatted output"
            success_criteria:
              - "pmat mutate calls cargo-mutants successfully"
              - "Arguments passed through correctly"
              - "PMAT-formatted output displayed"
              - "Help text updated"

      week_2:
        name: "Testing & Release"
        days: "Days 6-10"
        tasks:
          day_6_7:
            goal: "Comprehensive Testing"
            deliverables:
              - "Unit tests for JSON parsing (all edge cases)"
              - "Integration tests with cargo-mutants"
              - "Error handling tests"
              - "Dogfood on PMAT codebase (target: ≥90% kill rate)"
            success_criteria:
              - "All unit tests passing"
              - "Integration tests working"
              - "≥90% kill rate on PMAT modules"
              - "Results match raw cargo-mutants"

          day_8:
            goal: "Documentation"
            deliverables:
              - "Update docs/guides/mutation-testing.md"
              - "Document cargo-mutants requirement"
              - "Add installation instructions"
              - "Create migration guide"
            success_criteria:
              - "Complete installation guide"
              - "Usage examples with expected output"
              - "Troubleshooting section"
              - "Migration guide from v2.180.1"

          day_9:
            goal: "Validation"
            deliverables:
              - "Run on multiple PMAT modules"
              - "Verify ≥90% kill rate achieved"
              - "Performance benchmarks"
              - "Compare vs generic operators (0% → ≥90%)"
            success_criteria:
              - "≥90% kill rate on PMAT codebase"
              - "Performance acceptable (~30s/mutant)"
              - "All quality gates passing"
              - "pmat-book validation passing"

          day_10:
            goal: "Release Preparation"
            deliverables:
              - "Update CHANGELOG"
              - "Version bump: v2.181.0 or v2.182.0"
              - "Create GitHub release"
              - "Update crates.io"
            success_criteria:
              - "Version bumped correctly"
              - "CHANGELOG complete"
              - "GitHub release published"
              - "crates.io updated"

    success_criteria:
      functional:
        - "cargo-mutants wrapper working"
        - "≥90% kill rate on PMAT codebase (vs 0% with generic operators)"
        - "JSON parsing handles all cargo-mutants output"
        - "PMAT CLI interface maintained"

      quality:
        - "All modules: Cyclomatic complexity <10"
        - "All modules: TDG score ≥90 (A grade)"
        - "All tests passing (unit, integration, dogfooding)"
        - "Zero security issues"

      performance:
        - "30-60s per mutant (match cargo-mutants)"
        - "No significant overhead from wrapper"
        - "Memory usage reasonable"

      documentation:
        - "Installation guide complete"
        - "Migration guide from generic operators"
        - "Troubleshooting section"
        - "pmat-book validation passing"

    files_to_create:
      - path: "server/src/mutation/cargo_mutants_wrapper.rs"
        lines: "~300"
      - path: "server/tests/mutation/cargo_mutants_integration.rs"
        lines: "~200"
      - path: "docs/guides/mutation-testing-cargo-mutants.md"
        lines: "~400"

    files_to_modify:
      - path: "server/src/mutation/mod.rs"
        change: "export wrapper"
      - path: "server/src/cli/handlers/mutate.rs"
        change: "use wrapper"
      - path: "Cargo.toml"
        change: "add which dependency"
      - path: "docs/guides/mutation-testing.md"
        change: "update for wrapper"
      - path: "README.md"
        change: "mention cargo-mutants requirement"
      - path: "CHANGELOG.md"
        change: "document changes"

    dependencies:
      cargo:
        - name: "which"
          version: "6.0"
          purpose: "Find cargo-mutants in PATH"

      external_tools:
        - name: "cargo-mutants"
          version: "v24.7.0+"
          installation: "cargo install cargo-mutants"
          purpose: "Language-specific Rust mutation testing"

  # FUTURE SPRINTS (Agent System Architecture)
  # SPRINT 1: Modular Monolith Foundation (Week 1-2)
  # SPRINT 1: Modular Monolith Foundation (Week 1-2)
  - id: sprint-1
    name: "Modular Monolith Foundation"
    goal: "Extract modules with compiler-enforced boundaries"
    duration: 2_weeks
    tickets:
      - id: PMAT-001
        title: "Setup quality gate infrastructure"
        priority: critical
        requirements:
          - "Quality gate runner with AST analysis"
          - "Complexity analyzer (McCabe/Cognitive)"
          - "SATD detector with zero tolerance"
          - "Pre-commit hook integration"
        tests:
          - "test_quality_gate_detects_complexity_violations"
          - "test_satd_zero_tolerance_enforcement"
          - "test_pre_commit_blocks_violations"
          - "proptest_complexity_calculation_correctness"
        acceptance:
          - "100% test coverage"
          - "All quality metrics < thresholds"
          - "Clean cargo build --release"

      - id: PMAT-002
        title: "Create module abstraction layer"
        priority: high
        requirements:
          - "Trait-based module interfaces"
          - "Dependency injection framework"
          - "Module registry with lifecycle management"
        tests:
          - "test_module_trait_implementation"
          - "test_dependency_injection_resolution"
          - "test_module_lifecycle_events"
          - "proptest_module_registry_consistency"
        acceptance:
          - "Zero circular dependencies"
          - "All modules behind traits"
          - "Benchmark: module lookup O(1)"

      - id: PMAT-003
        title: "Extract analyzer module"
        priority: high
        requirements:
          - "AnalyzerModule trait definition"
          - "Language-agnostic analysis interface"
          - "Metrics collection abstraction"
        tests:
          - "test_analyzer_trait_contract"
          - "test_rust_analyzer_implementation"
          - "test_metrics_aggregation"
          - "proptest_analysis_determinism"
        acceptance:
          - "Module compiles independently"
          - "All tests passing"
          - "Performance: <100ms per file"

      - id: PMAT-004
        title: "Extract transformer module"
        priority: high
        requirements:
          - "TransformerModule trait"
          - "AST manipulation abstraction"
          - "Transactional refactoring support"
        tests:
          - "test_transformer_trait_contract"
          - "test_refactoring_transactions"
          - "test_rollback_capability"
          - "proptest_transform_reversibility"
        acceptance:
          - "All transforms reversible"
          - "Zero AST corruption"
          - "Mutation testing score >90%"

      - id: PMAT-005
        title: "Architecture enforcement tests"
        priority: critical
        requirements:
          - "Dependency rule tests"
          - "Layer boundary tests"
          - "Acyclic dependency verification"
        tests:
          - "test_no_circular_dependencies"
          - "test_module_boundary_violations"
          - "test_layer_access_restrictions"
          - "proptest_dependency_graph_properties"
        acceptance:
          - "All architecture tests green"
          - "CI/CD integration complete"
          - "Documentation generated"

  # SPRINT 2: Quality Gates Engine (Week 3-4)
  - id: sprint-2
    name: "Quality Gates Engine"
    goal: "Implement zero-tolerance quality enforcement"
    duration: 2_weeks
    tickets:
      - id: PMAT-006
        title: "Implement complexity analyzer"
        priority: critical
        requirements:
          - "McCabe cyclomatic complexity"
          - "Cognitive complexity (Sonar)"
          - "Nesting depth analysis"
          - "Control flow graph generation"
        tests:
          - "test_mccabe_complexity_calculation"
          - "test_cognitive_complexity_rules"
          - "test_cfg_construction"
          - "proptest_complexity_monotonicity"
        acceptance:
          - "Matches SonarQube results ±5%"
          - "Performance: O(n) analysis"
          - "100% branch coverage"

      - id: PMAT-007
        title: "Build SATD detector"
        priority: critical
        requirements:
          - "Pattern-based SATD detection"
          - "Multi-language support"
          - "Configurable forbidden patterns"
        tests:
          - "test_satd_pattern_detection"
          - "test_multi_language_satd"
          - "test_custom_pattern_config"
          - "proptest_satd_detection_consistency"
        acceptance:
          - "Zero false negatives"
          - "Configurable patterns"
          - "Sub-second file scanning"

      - id: PMAT-008
        title: "Efficiency analyzer"
        priority: high
        requirements:
          - "Big-O complexity detection"
          - "Space complexity analysis"
          - "Symbolic execution engine"
        tests:
          - "test_loop_complexity_detection"
          - "test_recursive_complexity"
          - "test_space_complexity_bounds"
          - "proptest_complexity_bounds_correct"
        acceptance:
          - "Detects O(n²) and higher"
          - "Handles recursion correctly"
          - "Property tests passing"

      - id: PMAT-009
        title: "Shannon entropy calculator"
        priority: medium
        requirements:
          - "Code diversity metrics"
          - "Duplication detection"
          - "Entropy threshold enforcement"
        tests:
          - "test_shannon_entropy_calculation"
          - "test_duplication_detection"
          - "test_entropy_thresholds"
          - "proptest_entropy_properties"
        acceptance:
          - "Entropy calculation accurate"
          - "Duplication <2% enforced"
          - "Integration with quality gate"

      - id: PMAT-010
        title: "Git hook integration"
        priority: critical
        requirements:
          - "Pre-commit quality checks"
          - "Staged file analysis"
          - "Incremental checking"
        tests:
          - "test_pre_commit_hook_blocks_violations"
          - "test_staged_files_analysis"
          - "test_incremental_check_performance"
          - "integration_test_git_workflow"
        acceptance:
          - "Hooks installed automatically"
          - "Sub-second for small commits"
          - "Clear violation reporting"

  # SPRINT 3: In-Process Actor System (Week 5-6)
  - id: sprint-3
    name: "In-Process Actor System"
    goal: "Implement Actix-based agent architecture"
    duration: 2_weeks
    tickets:
      - id: PMAT-011
        title: "Setup Actix actor system"
        priority: critical
        requirements:
          - "Actix integration"
          - "Actor supervision tree"
          - "Message routing infrastructure"
        tests:
          - "test_actor_spawn_and_lifecycle"
          - "test_supervision_restart_strategy"
          - "test_message_routing"
          - "proptest_actor_message_ordering"
        acceptance:
          - "Actors spawn <50ms P99"
          - "Supervision tree stable"
          - "10K msg/s throughput"

      - id: PMAT-012
        title: "Implement AnalyzerActor"
        priority: high
        requirements:
          - "Async complexity analysis"
          - "Result caching"
          - "Bounded mailbox"
        tests:
          - "test_analyzer_actor_messages"
          - "test_cache_hit_performance"
          - "test_mailbox_backpressure"
          - "proptest_analysis_determinism"
        acceptance:
          - "Cache hit ratio >80%"
          - "No mailbox overflow"
          - "Concurrent analysis works"

      - id: PMAT-013
        title: "Implement TransformerActor"
        priority: high
        requirements:
          - "AST transformation actor"
          - "Transaction support"
          - "Rollback capability"
        tests:
          - "test_transformer_actor_operations"
          - "test_transaction_atomicity"
          - "test_rollback_correctness"
          - "proptest_transform_idempotence"
        acceptance:
          - "All transforms atomic"
          - "Rollback 100% reliable"
          - "No AST corruption"

      - id: PMAT-014
        title: "Implement ValidatorActor"
        priority: high
        requirements:
          - "Quality validation actor"
          - "Threshold checking"
          - "Parallel validation"
        tests:
          - "test_validator_actor_rules"
          - "test_threshold_enforcement"
          - "test_parallel_validation"
          - "proptest_validation_consistency"
        acceptance:
          - "All rules enforced"
          - "Parallel speedup >3x"
          - "Zero false negatives"

      - id: PMAT-015
        title: "Actor orchestration supervisor"
        priority: critical
        requirements:
          - "QualityGateSupervisor actor"
          - "Workflow coordination"
          - "Error aggregation"
        tests:
          - "test_supervisor_coordination"
          - "test_workflow_execution"
          - "test_error_handling"
          - "proptest_workflow_determinism"
        acceptance:
          - "Workflows complete reliably"
          - "Errors properly aggregated"
          - "Supervisor auto-restarts"

  # SPRINT 4: Agent Message Protocol (Week 7-8)
  - id: sprint-4
    name: "Agent Message Protocol"
    goal: "Implement inter-agent communication"
    duration: 2_weeks
    tickets:
      - id: PMAT-016
        title: "Define message format"
        priority: critical
        requirements:
          - "Zero-copy message structure"
          - "Header with metadata"
          - "Priority queue support"
        tests:
          - "test_message_serialization"
          - "test_zero_copy_performance"
          - "test_priority_ordering"
          - "proptest_message_round_trip"
        acceptance:
          - "Serialization <1ms"
          - "Zero allocations in hot path"
          - "Priority queue working"

      - id: PMAT-017
        title: "Request-response pattern"
        priority: high
        requirements:
          - "Correlation ID tracking"
          - "Timeout handling"
          - "Response routing"
        tests:
          - "test_request_response_flow"
          - "test_timeout_behavior"
          - "test_correlation_tracking"
          - "proptest_response_matching"
        acceptance:
          - "100% response matching"
          - "Timeouts enforced"
          - "No message loss"

      - id: PMAT-018
        title: "Publish-subscribe broker"
        priority: high
        requirements:
          - "Topic-based routing"
          - "Parallel broadcast"
          - "Subscription management"
        tests:
          - "test_pubsub_broadcast"
          - "test_topic_filtering"
          - "test_subscription_lifecycle"
          - "proptest_broadcast_delivery"
        acceptance:
          - "Broadcast <5ms for 100 subs"
          - "No message duplication"
          - "Dynamic subscriptions work"

      - id: PMAT-019
        title: "Circuit breaker pattern"
        priority: critical
        requirements:
          - "Failure detection"
          - "State transitions"
          - "Fallback handling"
        tests:
          - "test_circuit_breaker_states"
          - "test_failure_threshold"
          - "test_fallback_execution"
          - "proptest_breaker_consistency"
        acceptance:
          - "Breaker opens on threshold"
          - "Fallback always available"
          - "Recovery works correctly"

      - id: PMAT-020
        title: "Backpressure control"
        priority: high
        requirements:
          - "Token bucket rate limiting"
          - "Flow control mechanisms"
          - "Queue depth monitoring"
        tests:
          - "test_rate_limiting"
          - "test_backpressure_application"
          - "test_queue_monitoring"
          - "proptest_rate_limit_bounds"
        acceptance:
          - "Rate limits enforced ±5%"
          - "No queue overflow"
          - "Graceful degradation"

  # SPRINT 5: State Management (Week 9-10)
  - id: sprint-5
    name: "State Management"
    goal: "Hybrid event sourcing with snapshots"
    duration: 2_weeks
    tickets:
      - id: PMAT-021
        title: "Event store implementation"
        priority: critical
        requirements:
          - "Append-only event log"
          - "Event ordering guarantees"
          - "Persistence layer"
        tests:
          - "test_event_append_ordering"
          - "test_persistence_durability"
          - "test_concurrent_writes"
          - "proptest_event_log_consistency"
        acceptance:
          - "Events never lost"
          - "Ordering preserved"
          - "10K events/sec write"

      - id: PMAT-022
        title: "Snapshot store"
        priority: critical
        requirements:
          - "Zero-copy serialization"
          - "Compression (zstd)"
          - "Atomic writes"
        tests:
          - "test_snapshot_creation"
          - "test_compression_ratio"
          - "test_atomic_writes"
          - "proptest_snapshot_recovery"
        acceptance:
          - "Compression ratio >3:1"
          - "Snapshot <100ms for 10MB"
          - "100% recovery success"

      - id: PMAT-023
        title: "Adaptive snapshot scheduler"
        priority: high
        requirements:
          - "Multiple strategies"
          - "Recovery time targeting"
          - "Performance metrics"
        tests:
          - "test_snapshot_strategies"
          - "test_adaptive_scheduling"
          - "test_recovery_time_bounds"
          - "proptest_scheduler_decisions"
        acceptance:
          - "Recovery <1s target met"
          - "Adaptive strategy works"
          - "Metrics collected accurately"

      - id: PMAT-024
        title: "State recovery system"
        priority: critical
        requirements:
          - "Fast recovery from snapshots"
          - "Event replay engine"
          - "Parallel replay support"
        tests:
          - "test_recovery_from_snapshot"
          - "test_event_replay"
          - "test_parallel_replay"
          - "proptest_recovery_correctness"
        acceptance:
          - "Recovery <1s for 100K events"
          - "State matches exactly"
          - "Parallel speedup >3x"

      - id: PMAT-025
        title: "Raft consensus for critical state"
        priority: high
        requirements:
          - "Raft implementation"
          - "Leader election"
          - "Log replication"
        tests:
          - "test_raft_leader_election"
          - "test_log_replication"
          - "test_split_brain_prevention"
          - "proptest_consensus_properties"
        acceptance:
          - "Consensus in <100ms"
          - "No split brain possible"
          - "Linearizability guaranteed"

  # SPRINT 6: Resource Control (Week 11-12)
  - id: sprint-6
    name: "Resource Control"
    goal: "Cross-platform resource management"
    duration: 2_weeks
    tickets:
      - id: PMAT-026
        title: "Unified resource controller"
        priority: critical
        requirements:
          - "CPU limiting"
          - "Memory control"
          - "I/O throttling"
        tests:
          - "test_cpu_limiting"
          - "test_memory_enforcement"
          - "test_io_throttling"
          - "proptest_resource_bounds"
        acceptance:
          - "Limits enforced ±10%"
          - "Cross-platform support"
          - "No resource leaks"

      - id: PMAT-027
        title: "Platform-specific enforcers"
        priority: high
        requirements:
          - "Linux cgroups v2"
          - "macOS QoS classes"
          - "Windows Job Objects"
        tests:
          - "test_linux_cgroups"
          - "test_macos_qos"
          - "test_windows_jobs"
          - "integration_test_enforcement"
        acceptance:
          - "Each platform working"
          - "Graceful fallbacks"
          - "Resource isolation verified"

      - id: PMAT-028
        title: "Resource monitoring"
        priority: high
        requirements:
          - "Real-time metrics"
          - "Historical tracking"
          - "Alert thresholds"
        tests:
          - "test_metrics_collection"
          - "test_historical_storage"
          - "test_alert_triggering"
          - "proptest_metrics_accuracy"
        acceptance:
          - "Metrics accurate ±5%"
          - "Sub-second updates"
          - "Alerts fire correctly"

      - id: PMAT-029
        title: "Bulkhead isolation"
        priority: critical
        requirements:
          - "Thread pool isolation"
          - "Resource partitioning"
          - "Failure containment"
        tests:
          - "test_thread_pool_isolation"
          - "test_resource_partitions"
          - "test_failure_containment"
          - "chaos_test_cascading_failures"
        acceptance:
          - "No cascade failures"
          - "Pools isolated completely"
          - "Performance maintained"

      - id: PMAT-030
        title: "Adaptive throttling"
        priority: medium
        requirements:
          - "Dynamic throttle calculation"
          - "Sleep injection"
          - "Memory pressure response"
        tests:
          - "test_throttle_calculation"
          - "test_sleep_injection"
          - "test_memory_pressure"
          - "proptest_throttling_fairness"
        acceptance:
          - "Throttling effective"
          - "Fair resource sharing"
          - "System remains responsive"

  # SPRINT 7: MCP Integration (Week 13-14)
  - id: sprint-7
    name: "MCP Integration"
    goal: "Full MCP protocol support"
    duration: 2_weeks
    tickets:
      - id: PMAT-031
        title: "Agent-aware tool registration"
        priority: critical
        requirements:
          - "Extended tool descriptors"
          - "Agent metadata"
          - "Capability declaration"
        tests:
          - "test_tool_registration"
          - "test_agent_metadata"
          - "test_capability_matching"
          - "proptest_tool_discovery"
        acceptance:
          - "All tools registered"
          - "Claude Code compatible"
          - "Discovery working"

      - id: PMAT-032
        title: "MCP server implementation"
        priority: critical
        requirements:
          - "Tool call handling"
          - "Agent routing"
          - "Response formatting"
        tests:
          - "test_mcp_tool_calls"
          - "test_agent_routing"
          - "test_response_format"
          - "integration_test_claude_code"
        acceptance:
          - "MCP compliance 100%"
          - "Claude Code works"
          - "All tools accessible"

      - id: PMAT-033
        title: "Agent discovery protocol"
        priority: high
        requirements:
          - "Agent manifest format"
          - "Capability advertisement"
          - "Health endpoints"
        tests:
          - "test_manifest_format"
          - "test_capability_advertisement"
          - "test_health_checks"
          - "proptest_discovery_consistency"
        acceptance:
          - "Discovery reliable"
          - "Manifests valid"
          - "Health checks accurate"

      - id: PMAT-034
        title: "Service registry"
        priority: high
        requirements:
          - "Static configuration"
          - "Hot reload support"
          - "Optional etcd backend"
        tests:
          - "test_static_config"
          - "test_hot_reload"
          - "test_etcd_integration"
          - "proptest_registry_consistency"
        acceptance:
          - "Config reload works"
          - "No downtime on reload"
          - "etcd optional but working"

      - id: PMAT-035
        title: "Legacy CLI adapter"
        priority: critical
        requirements:
          - "Backward compatibility"
          - "Command routing"
          - "Output formatting"
        tests:
          - "test_legacy_commands"
          - "test_command_routing"
          - "test_output_compatibility"
          - "integration_test_existing_scripts"
        acceptance:
          - "All commands working"
          - "No breaking changes"
          - "Scripts still run"

  # SPRINT 8: Workflow Orchestration (Week 15-16)
  - id: sprint-8
    name: "Workflow Orchestration"
    goal: "DAG-based workflow execution"
    duration: 2_weeks
    tickets:
      - id: PMAT-036
        title: "DAG workflow engine"
        priority: critical
        requirements:
          - "DAG construction"
          - "Topological sorting"
          - "Execution planning"
        tests:
          - "test_dag_construction"
          - "test_topological_sort"
          - "test_execution_plan"
          - "proptest_dag_properties"
        acceptance:
          - "DAGs validated correctly"
          - "Optimal execution order"
          - "Parallelism exploited"

      - id: PMAT-037
        title: "Workflow executor"
        priority: critical
        requirements:
          - "Stage-based execution"
          - "Parallel node execution"
          - "Error aggregation"
        tests:
          - "test_stage_execution"
          - "test_parallel_nodes"
          - "test_error_handling"
          - "proptest_execution_determinism"
        acceptance:
          - "Workflows complete"
          - "Parallelism working"
          - "Errors handled gracefully"

      - id: PMAT-038
        title: "Saga coordinator"
        priority: high
        requirements:
          - "Saga pattern implementation"
          - "Compensation tracking"
          - "Distributed transactions"
        tests:
          - "test_saga_execution"
          - "test_compensation_rollback"
          - "test_transaction_semantics"
          - "proptest_saga_consistency"
        acceptance:
          - "Sagas atomic"
          - "Compensations work"
          - "No partial states"

      - id: PMAT-039
        title: "Event-driven choreography"
        priority: medium
        requirements:
          - "Event bus implementation"
          - "Subscription management"
          - "Event ordering"
        tests:
          - "test_event_bus"
          - "test_subscriptions"
          - "test_event_ordering"
          - "proptest_event_delivery"
        acceptance:
          - "Events delivered once"
          - "Ordering preserved"
          - "No event loss"

      - id: PMAT-040
        title: "Retry and compensation"
        priority: high
        requirements:
          - "Retry policies"
          - "Exponential backoff"
          - "Compensation logic"
        tests:
          - "test_retry_policies"
          - "test_backoff_calculation"
          - "test_compensation_execution"
          - "proptest_retry_bounds"
        acceptance:
          - "Retries bounded"
          - "Backoff working"
          - "Compensations reliable"

validation:
  continuous_integration:
    - cargo build --release
    - cargo test --all-features
    - cargo clippy -- -D warnings
    - cargo fmt -- --check
    - cargo llvm-cov --lcov --output-path coverage/lcov.info
    - cargo mutants --minimum-score 0.90

  quality_gates:
    - pmat analyze complexity --max 10
    - pmat analyze satd --zero-tolerance
    - pmat analyze efficiency --max "O(n log n)"
    - pmat quality-score --min 9.5

  performance_benchmarks:
    - agent_spawn_latency_p99: 50ms
    - message_throughput: 10000/s
    - state_recovery_time: 1s
    - workflow_parallelism: 16x

execution_protocol:
  ticket_workflow:
    - step: write_failing_tests
      description: "Write comprehensive test suite that fails"
      deliverable: "Red tests committed"

    - step: minimal_implementation
      description: "Implement just enough to pass tests"
      deliverable: "Green tests, no extras"

    - step: refactor_with_quality
      description: "Refactor while maintaining green"
      deliverable: "Clean code, all metrics pass"

    - step: atomic_commit
      description: "Single commit per ticket"
      deliverable: "Git log shows ticket complete"

    - step: clean_build
      description: "Verify build passes all checks"
      deliverable: "CI/CD green"

metrics_tracking:
  per_ticket:
    - test_coverage
    - mutation_score
    - complexity_metrics
    - performance_benchmarks
    - quality_score

  per_sprint:
    - velocity
    - defect_rate
    - technical_debt
    - test_suite_runtime
    - build_time

deployment_strategy:
  phases:
    - phase: development
      features:
        agent_system: true
        distributed_state: false
        resource_isolation: true

    - phase: staging
      features:
        agent_system: true
        distributed_state: true
        resource_isolation: true

    - phase: production
      features:
        agent_system: false  # Start conservative
        distributed_state: false
        resource_isolation: true
      rollout:
        strategy: canary
        percentage: 5
        duration: 1_week