agentic-qe 1.8.2 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/.claude/agents/qe-test-generator.md +580 -0
  2. package/.claude/agents/subagents/qe-code-reviewer.md +86 -0
  3. package/.claude/agents/subagents/qe-coverage-gap-analyzer.md +485 -0
  4. package/.claude/agents/subagents/qe-data-generator.md +86 -0
  5. package/.claude/agents/subagents/qe-flaky-investigator.md +416 -0
  6. package/.claude/agents/subagents/qe-integration-tester.md +87 -0
  7. package/.claude/agents/subagents/qe-performance-validator.md +98 -0
  8. package/.claude/agents/subagents/qe-security-auditor.md +86 -0
  9. package/.claude/agents/subagents/qe-test-data-architect-sub.md +553 -0
  10. package/.claude/agents/subagents/qe-test-implementer.md +229 -15
  11. package/.claude/agents/subagents/qe-test-refactorer.md +265 -15
  12. package/.claude/agents/subagents/qe-test-writer.md +180 -20
  13. package/.claude/skills/cicd-pipeline-qe-orchestrator/README.md +2 -2
  14. package/.claude/skills/cicd-pipeline-qe-orchestrator/SKILL.md +6 -6
  15. package/CHANGELOG.md +294 -0
  16. package/README.md +83 -52
  17. package/config/constitution.schema.json +423 -0
  18. package/config/otel-collector.yaml +234 -0
  19. package/dist/cli/commands/init-claude-md-template.js +3 -3
  20. package/dist/constitution/index.d.ts +105 -0
  21. package/dist/constitution/index.d.ts.map +1 -0
  22. package/dist/constitution/index.js +207 -0
  23. package/dist/constitution/index.js.map +1 -0
  24. package/dist/constitution/loader.d.ts +141 -0
  25. package/dist/constitution/loader.d.ts.map +1 -0
  26. package/dist/constitution/loader.js +515 -0
  27. package/dist/constitution/loader.js.map +1 -0
  28. package/dist/constitution/schema.d.ts +409 -0
  29. package/dist/constitution/schema.d.ts.map +1 -0
  30. package/dist/constitution/schema.js +71 -0
  31. package/dist/constitution/schema.js.map +1 -0
  32. package/dist/core/hooks/validators/TDDPhaseValidator.d.ts +110 -0
  33. package/dist/core/hooks/validators/TDDPhaseValidator.d.ts.map +1 -0
  34. package/dist/core/hooks/validators/TDDPhaseValidator.js +287 -0
  35. package/dist/core/hooks/validators/TDDPhaseValidator.js.map +1 -0
  36. package/dist/core/hooks/validators/index.d.ts +3 -1
  37. package/dist/core/hooks/validators/index.d.ts.map +1 -1
  38. package/dist/core/hooks/validators/index.js +4 -2
  39. package/dist/core/hooks/validators/index.js.map +1 -1
  40. package/dist/core/memory/MemoryManagerFactory.d.ts +77 -0
  41. package/dist/core/memory/MemoryManagerFactory.d.ts.map +1 -0
  42. package/dist/core/memory/MemoryManagerFactory.js +270 -0
  43. package/dist/core/memory/MemoryManagerFactory.js.map +1 -0
  44. package/dist/core/memory/SwarmMemoryManager.d.ts +18 -0
  45. package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
  46. package/dist/core/memory/SwarmMemoryManager.js +96 -11
  47. package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
  48. package/dist/core/memory/index.d.ts +1 -0
  49. package/dist/core/memory/index.d.ts.map +1 -1
  50. package/dist/core/memory/index.js +12 -1
  51. package/dist/core/memory/index.js.map +1 -1
  52. package/dist/mcp/handlers/memory/memory-backup.js +6 -6
  53. package/dist/mcp/handlers/memory/memory-backup.js.map +1 -1
  54. package/dist/mcp/handlers/phase2/Phase2Tools.d.ts.map +1 -1
  55. package/dist/mcp/handlers/phase2/Phase2Tools.js +4 -2
  56. package/dist/mcp/handlers/phase2/Phase2Tools.js.map +1 -1
  57. package/dist/mcp/server.d.ts.map +1 -1
  58. package/dist/mcp/server.js +4 -38
  59. package/dist/mcp/server.js.map +1 -1
  60. package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
  61. package/dist/mcp/services/AgentRegistry.js +4 -4
  62. package/dist/mcp/services/AgentRegistry.js.map +1 -1
  63. package/dist/persistence/event-store.d.ts +162 -0
  64. package/dist/persistence/event-store.d.ts.map +1 -0
  65. package/dist/persistence/event-store.js +315 -0
  66. package/dist/persistence/event-store.js.map +1 -0
  67. package/dist/persistence/index.d.ts +145 -0
  68. package/dist/persistence/index.d.ts.map +1 -0
  69. package/dist/persistence/index.js +227 -0
  70. package/dist/persistence/index.js.map +1 -0
  71. package/dist/persistence/metrics-aggregator.d.ts +187 -0
  72. package/dist/persistence/metrics-aggregator.d.ts.map +1 -0
  73. package/dist/persistence/metrics-aggregator.js +495 -0
  74. package/dist/persistence/metrics-aggregator.js.map +1 -0
  75. package/dist/persistence/reasoning-store.d.ts +178 -0
  76. package/dist/persistence/reasoning-store.d.ts.map +1 -0
  77. package/dist/persistence/reasoning-store.js +440 -0
  78. package/dist/persistence/reasoning-store.js.map +1 -0
  79. package/dist/persistence/schema.d.ts +181 -0
  80. package/dist/persistence/schema.d.ts.map +1 -0
  81. package/dist/persistence/schema.js +186 -0
  82. package/dist/persistence/schema.js.map +1 -0
  83. package/dist/telemetry/bootstrap.d.ts +67 -0
  84. package/dist/telemetry/bootstrap.d.ts.map +1 -0
  85. package/dist/telemetry/bootstrap.js +320 -0
  86. package/dist/telemetry/bootstrap.js.map +1 -0
  87. package/dist/telemetry/index.d.ts +16 -0
  88. package/dist/telemetry/index.d.ts.map +1 -0
  89. package/dist/telemetry/index.js +84 -0
  90. package/dist/telemetry/index.js.map +1 -0
  91. package/dist/telemetry/metrics/agent-metrics.d.ts +109 -0
  92. package/dist/telemetry/metrics/agent-metrics.d.ts.map +1 -0
  93. package/dist/telemetry/metrics/agent-metrics.js +213 -0
  94. package/dist/telemetry/metrics/agent-metrics.js.map +1 -0
  95. package/dist/telemetry/metrics/index.d.ts +51 -0
  96. package/dist/telemetry/metrics/index.d.ts.map +1 -0
  97. package/dist/telemetry/metrics/index.js +100 -0
  98. package/dist/telemetry/metrics/index.js.map +1 -0
  99. package/dist/telemetry/metrics/quality-metrics.d.ts +171 -0
  100. package/dist/telemetry/metrics/quality-metrics.d.ts.map +1 -0
  101. package/dist/telemetry/metrics/quality-metrics.js +259 -0
  102. package/dist/telemetry/metrics/quality-metrics.js.map +1 -0
  103. package/dist/telemetry/metrics/system-metrics.d.ts +129 -0
  104. package/dist/telemetry/metrics/system-metrics.d.ts.map +1 -0
  105. package/dist/telemetry/metrics/system-metrics.js +380 -0
  106. package/dist/telemetry/metrics/system-metrics.js.map +1 -0
  107. package/dist/telemetry/types.d.ts +195 -0
  108. package/dist/telemetry/types.d.ts.map +1 -0
  109. package/dist/telemetry/types.js +90 -0
  110. package/dist/telemetry/types.js.map +1 -0
  111. package/package.json +18 -2
package/README.md CHANGED
@@ -9,11 +9,11 @@
9
9
  <img alt="NPM Downloads" src="https://img.shields.io/npm/dw/agentic-qe">
10
10
 
11
11
 
12
- **Version 1.8.2** (Database Schema Fix) | [Changelog](CHANGELOG.md) | [Issues](https://github.com/proffesor-for-testing/agentic-qe/issues) | [Discussions](https://github.com/proffesor-for-testing/agentic-qe/discussions)
12
+ **Version 1.8.4** (Phase 1 Infrastructure + Critical Fixes) | [Changelog](CHANGELOG.md) | [Issues](https://github.com/proffesor-for-testing/agentic-qe/issues) | [Discussions](https://github.com/proffesor-for-testing/agentic-qe/discussions)
13
13
 
14
- > Enterprise-grade test automation with AI learning, comprehensive skills library (38 QE skills), and intelligent model routing.
14
+ > Enterprise-grade test automation with AI learning, OpenTelemetry observability, persistent event storage, constitutional AI governance, and intelligent model routing.
15
15
 
16
- 🧠 **QE Agent Learning System** | 📚 **38 World-Class QE Skills** | 🎯 **Advanced Flaky Detection** | 💰 **Multi-Model Router** | 🔧 **32 Domain-Specific Tools**
16
+ 🧠 **QE Agent Learning** | 📊 **OpenTelemetry Integration** | 💾 **Event Sourcing** | 📋 **Constitution System** | 📚 **38 QE Skills** | 🎯 **Flaky Detection** | 💰 **Multi-Model Router**
17
17
 
18
18
  </div>
19
19
 
@@ -54,12 +54,13 @@ claude "Use qe-flaky-test-hunter to analyze the last 100 test runs and identify
54
54
  ```
55
55
 
56
56
  **What gets initialized:**
57
+ - ✅ **Phase 1 Infrastructure**: OpenTelemetry, Event Store, Constitution System (v1.8.4)
57
58
  - ✅ Multi-Model Router (70-81% cost savings - opt-in)
58
59
  - ✅ Learning System (20% improvement target)
59
60
  - ✅ Pattern Bank (cross-project reuse)
60
61
  - ✅ ML Flaky Detection (100% accuracy)
61
62
  - ✅ 18 Specialized agent definitions (including qe-code-complexity)
62
- - ✅ 8 TDD subagent definitions (RED/GREEN/REFACTOR phases)
63
+ - ✅ 11 TDD subagent definitions (RED/GREEN/REFACTOR phases + specialized)
63
64
  - ✅ 38 World-class QE skills library
64
65
  - ✅ 8 AQE slash commands
65
66
  - ✅ Configuration directory
@@ -68,9 +69,41 @@ claude "Use qe-flaky-test-hunter to analyze the last 100 test runs and identify
68
69
 
69
70
  ## ✨ Features
70
71
 
72
+ ### 🏗️ Phase 1 Infrastructure (v1.8.4)
73
+
74
+ **Enterprise-Grade Observability & Governance**
75
+
76
+ #### 📊 OpenTelemetry Integration
77
+ - **Full OTEL SDK**: 12 OpenTelemetry packages for comprehensive observability
78
+ - **Auto-Instrumentation**: HTTP, file system, and custom metrics
79
+ - **Metrics Export**: gRPC and HTTP exporters for Grafana, Prometheus, Jaeger
80
+ - **Agent Metrics**: Task completion, success rate, error tracking
81
+ - **Quality Metrics**: Coverage %, defect density, test effectiveness
82
+ - **System Metrics**: Memory, CPU, latency, throughput
83
+
84
+ #### 💾 Event Sourcing & Persistence
85
+ - **Event Store**: SQLite-based event sourcing with correlation tracking
86
+ - **Reasoning Capture**: Agent decision tracking and prompt/response analysis
87
+ - **Metrics Aggregation**: Time-window aggregation (hourly, daily, weekly)
88
+ - **Performance Optimization**: Prepared statements, indexes, connection pooling
89
+ - **Query API**: Time-range queries with pagination support
90
+
91
+ #### 📋 Constitutional AI Governance
92
+ - **JSON Schema Validation**: Type-safe constitution definitions
93
+ - **4 Base Constitutions**: Default, test-generation, code-review, performance
94
+ - **Inheritance & Merge**: Constitution composition with override support
95
+ - **Agent-Specific**: Per-agent constitutional rules and guidelines
96
+ - **Validation Pipeline**: Ensure agents follow constitutional principles
97
+
98
+ **Benefits:**
99
+ - 🔍 **Full Observability**: Track every agent action, metric, and decision
100
+ - 📈 **Data-Driven**: Historical analysis for continuous improvement
101
+ - 🛡️ **Governance**: Constitutional AI ensures quality and compliance
102
+ - 🚀 **Production Ready**: Enterprise-grade persistence and monitoring
103
+
71
104
  ### 🤖 Autonomous Agent Fleet
72
105
  - **18 Specialized Agents**: Expert agents for every QE domain (test generation, coverage analysis, security scanning, performance testing, code complexity analysis)
73
- - **8 TDD Subagents**: Specialized subagents for Test-Driven Development workflow (RED/GREEN/REFACTOR phases + quality validation)
106
+ - **11 TDD Subagents**: Specialized subagents for Test-Driven Development workflow (RED/GREEN/REFACTOR phases + quality validation + analysis)
74
107
  - **AI-Powered Coordination**: Event-driven architecture with intelligent task distribution
75
108
  - **Zero External Dependencies**: Native AQE hooks system (100-500x faster than external coordination)
76
109
  - **Scalable**: From single developer projects to enterprise-scale testing infrastructure
@@ -436,9 +469,9 @@ Model Usage:
436
469
 
437
470
  </details>
438
471
 
439
- **Total: 26 Agents** (18 main agents + 8 TDD subagents)
472
+ **Total: 29 Agents** (18 main agents + 11 TDD subagents)
440
473
 
441
- ### TDD Subagents (8 specialized)
474
+ ### TDD Subagents (11 specialized)
442
475
 
443
476
  <details>
444
477
  <summary><b>Test-Driven Development Subagents</b></summary>
@@ -455,6 +488,12 @@ The test generator orchestrates a complete TDD workflow through specialized suba
455
488
  | **qe-data-generator** | GENERATION | Test data creation | Realistic data generation, constraint satisfaction, edge cases |
456
489
  | **qe-performance-validator** | VALIDATION | Performance checks | SLA validation, benchmark comparison, threshold enforcement |
457
490
  | **qe-security-auditor** | AUDIT | Security validation | Vulnerability detection, compliance checking, threat modeling |
491
+ | **qe-flaky-investigator** | ANALYSIS | Flaky test detection | Pattern detection, timing analysis, stabilization fixes |
492
+ | **qe-coverage-gap-analyzer** | ANALYSIS | Coverage gaps | Risk scoring, gap detection, test recommendations |
493
+ | **qe-test-data-architect-sub** | GENERATION | High-volume data | Schema-aware generation, relationship preservation |
494
+
495
+ **Coordination Protocol:**
496
+ All subagents use a unified coordination protocol with cycle-based memory namespaces (`aqe/tdd/cycle-{id}/*`) ensuring tests written in RED are the same tests validated in GREEN and refactored in REFACTOR. See [Coordination Guide](docs/subagents/coordination-guide.md).
458
497
 
459
498
  **Usage Example:**
460
499
  ```bash
@@ -539,60 +578,52 @@ The test generator automatically delegates to subagents for a complete RED-GREEN
539
578
 
540
579
  ---
541
580
 
542
- ## 📝 What's New in v1.8.2
581
+ ## 📝 What's New in v1.8.3
543
582
 
544
- 🔧 **Database Schema Enhancement** (2025-01-18)
583
+ 🔄 **Phase 4: TDD Subagent Coordination** (2025-01-19)
545
584
 
546
- This release improves the database initialization to create all required tables for the QE learning system, including ReasoningBank integration for advanced pattern matching.
585
+ This release implements comprehensive TDD subagent coordination, solving the disconnected tests/code/refactor issue where RED-GREEN-REFACTOR cycle agents were producing inconsistent outputs.
547
586
 
548
587
  ### Key Improvements
549
- - **Enhanced Database Initialization** - Now creates 10 tables instead of 1 (9x improvement)
550
- - ✅ 6 QE learning tables for pattern storage and quality metrics
551
- - ✅ 2 ReasoningBank tables for semantic pattern search
552
- - ✅ Schema versioning for future migrations
553
- - ✅ 150x faster vector search with HNSW indexing
554
-
555
- - **ReasoningBank Integration** - Advanced pattern matching capabilities
556
- - ✅ Task-type-based pattern storage
557
- - ✅ Semantic similarity search (384-dim embeddings)
558
- - ✅ Local embedding service (no external API needed)
559
- - ✅ Pattern learning from successful executions
560
-
561
- - **Migration Support** - Easy upgrade for existing users
562
- - ✅ Migration script preserves all existing data
563
- - ✅ Automatic backups before migration
564
- - ✅ Data integrity verification
565
-
566
- ### Tables Created
567
- All fresh installations now get complete database schema:
568
- 1. `patterns` - Base vector embeddings
569
- 2. `test_patterns` - QE test patterns with deduplication
570
- 3. `pattern_usage` - Quality metrics tracking
571
- 4. `cross_project_mappings` - Framework translation rules
572
- 5. `pattern_similarity_index` - Fast similarity lookups
573
- 6. `pattern_fts` - Full-text search
574
- 7. `schema_version` - Migration tracking
575
- 8. `reasoning_patterns` - ReasoningBank patterns
576
- 9. `pattern_embeddings` - Vector embeddings
577
- 10. `sqlite_sequence` - Auto-increment tracking
578
-
579
- ### Migration Guide
580
- **Existing users (v1.8.0-1.8.1)**:
581
- ```bash
582
- npm install agentic-qe@1.8.2
583
- npx tsx node_modules/agentic-qe/scripts/migrate-add-qe-tables.ts
584
- ```
585
588
 
586
- **Fresh installations**: All tables created automatically during `aqe init`.
589
+ - **TDD Coordination Protocol** - Memory-based coordination for consistent TDD cycles
590
+ - ✅ Cycle-based memory namespace (`aqe/tdd/cycle-{cycleId}/*`)
591
+ - ✅ File hash validation ensures test file integrity across phases
592
+ - ✅ Handoff gates prevent premature phase transitions
593
+ - ✅ Phase output interfaces for typed contracts
594
+
595
+ - **Runtime Enforcement** - TDDPhaseValidator class validates memory state
596
+ - ✅ Validates memory keys exist before phase transitions
597
+ - ✅ Enforces output schema compliance
598
+ - ✅ Checks file hash integrity across RED→GREEN→REFACTOR
599
+ - ✅ Coverage comparison warnings
600
+
601
+ - **New Subagents (3)** - Specialized quality engineering agents
602
+ - ✅ `qe-flaky-investigator` - Detects flaky tests, analyzes root causes
603
+ - ✅ `qe-coverage-gap-analyzer` - Identifies coverage gaps, risk-scores untested code
604
+ - ✅ `qe-test-data-architect-sub` - High-volume test data generation
605
+
606
+ ### Updated Subagents (8)
607
+ All existing subagents now include coordination protocol:
608
+ - `qe-test-writer`, `qe-test-implementer`, `qe-test-refactorer` (TDD phases)
609
+ - `qe-code-reviewer`, `qe-integration-tester`, `qe-performance-validator`
610
+ - `qe-security-auditor`, `qe-data-generator`
611
+
612
+ ### Testing
613
+ - 22 integration tests for TDD coordination
614
+ - All tests passing
615
+
616
+ ### Documentation
617
+ - Coordination guide at `docs/subagents/coordination-guide.md`
587
618
 
588
619
  ### Impact
589
620
  ✅ **Build Status**: Passing (0 errors)
590
- ✅ **Database Schema**: Complete (10/10 tables)
591
- ✅ **Pattern Storage**: Fully operational
592
- ✅ **Semantic Search**: Enabled (HNSW + SIMD)
621
+ ✅ **TDD Coordination**: Fully operational
622
+ ✅ **Subagents**: 11 total (3 new, 8 updated)
623
+ ✅ **Integration Tests**: 22 passing
593
624
  ❌ **Breaking Changes**: None
594
625
 
595
- **Upgrade from v1.8.1**: Fully backward-compatible. Run `npm install agentic-qe@1.8.2` and `aqe init`.
626
+ **Upgrade**: `npm install agentic-qe@1.8.3`
596
627
 
597
628
  **Previous Releases**: See [CHANGELOG.md](CHANGELOG.md) for complete version history.
598
629
 
@@ -700,7 +731,7 @@ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for deta
700
731
  - ✅ Pattern Bank with cross-project sharing
701
732
  - ✅ ML Flaky Detection (100% accuracy)
702
733
  - ✅ Continuous Improvement Loop
703
- - ✅ 18 specialized agents + 8 TDD subagents
734
+ - ✅ 18 specialized agents + 11 TDD subagents
704
735
  - ✅ Complete TDD workflow automation (RED/GREEN/REFACTOR/REVIEW)
705
736
  - ✅ Multi-framework test execution
706
737
  - ✅ Real-time coverage analysis
@@ -0,0 +1,423 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://agentic-qe.io/schemas/constitution.schema.json",
4
+ "title": "Constitution Schema",
5
+ "description": "Schema for Agentic QE Fleet constitution definitions that govern quality evaluation criteria",
6
+ "type": "object",
7
+ "required": ["id", "name", "version", "description", "principles", "rules", "metrics", "thresholds", "metadata"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "id": {
11
+ "type": "string",
12
+ "description": "Unique identifier for the constitution",
13
+ "pattern": "^[a-z0-9-]+$",
14
+ "minLength": 1,
15
+ "maxLength": 100
16
+ },
17
+ "name": {
18
+ "type": "string",
19
+ "description": "Human-readable name",
20
+ "minLength": 1,
21
+ "maxLength": 200
22
+ },
23
+ "version": {
24
+ "type": "string",
25
+ "description": "Semantic version string",
26
+ "pattern": "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9]+)?$"
27
+ },
28
+ "description": {
29
+ "type": "string",
30
+ "description": "Description of the constitution's purpose",
31
+ "minLength": 1,
32
+ "maxLength": 2000
33
+ },
34
+ "principles": {
35
+ "type": "array",
36
+ "description": "Core quality principles",
37
+ "items": { "$ref": "#/definitions/Principle" },
38
+ "minItems": 1
39
+ },
40
+ "rules": {
41
+ "type": "array",
42
+ "description": "Evaluation rules",
43
+ "items": { "$ref": "#/definitions/Rule" }
44
+ },
45
+ "metrics": {
46
+ "type": "array",
47
+ "description": "Metric definitions",
48
+ "items": { "$ref": "#/definitions/MetricDefinition" }
49
+ },
50
+ "thresholds": {
51
+ "type": "array",
52
+ "description": "Quality thresholds",
53
+ "items": { "$ref": "#/definitions/Threshold" }
54
+ },
55
+ "metadata": {
56
+ "$ref": "#/definitions/ConstitutionMetadata"
57
+ }
58
+ },
59
+ "definitions": {
60
+ "PriorityLevel": {
61
+ "type": "string",
62
+ "enum": ["critical", "high", "medium", "low"],
63
+ "description": "Priority level for principles and rules"
64
+ },
65
+ "SeverityLevel": {
66
+ "type": "string",
67
+ "enum": ["error", "warning", "info"],
68
+ "description": "Severity level for rule violations"
69
+ },
70
+ "AggregationType": {
71
+ "type": "string",
72
+ "enum": ["sum", "avg", "min", "max", "count", "percentile"],
73
+ "description": "Aggregation method for metrics"
74
+ },
75
+ "ConditionOperator": {
76
+ "type": "string",
77
+ "enum": [
78
+ "equals", "not_equals", "greater_than", "less_than",
79
+ "greater_than_or_equal", "less_than_or_equal",
80
+ "contains", "not_contains", "matches",
81
+ "in", "not_in", "exists", "not_exists"
82
+ ],
83
+ "description": "Condition operator for rule evaluation"
84
+ },
85
+ "ActionType": {
86
+ "type": "string",
87
+ "enum": ["fail", "warn", "notify", "log", "block", "require_review", "auto_fix", "escalate"],
88
+ "description": "Action type when rules are triggered"
89
+ },
90
+ "ThresholdMode": {
91
+ "type": "string",
92
+ "enum": ["absolute", "percentage", "relative"],
93
+ "description": "Threshold comparison mode"
94
+ },
95
+ "ConstitutionStatus": {
96
+ "type": "string",
97
+ "enum": ["active", "deprecated", "draft", "archived"],
98
+ "description": "Constitution status"
99
+ },
100
+ "Principle": {
101
+ "type": "object",
102
+ "required": ["id", "name", "description", "priority", "category"],
103
+ "additionalProperties": false,
104
+ "properties": {
105
+ "id": {
106
+ "type": "string",
107
+ "description": "Unique identifier for the principle",
108
+ "pattern": "^[a-z0-9-]+$"
109
+ },
110
+ "name": {
111
+ "type": "string",
112
+ "description": "Human-readable name"
113
+ },
114
+ "description": {
115
+ "type": "string",
116
+ "description": "Detailed description of the principle"
117
+ },
118
+ "priority": { "$ref": "#/definitions/PriorityLevel" },
119
+ "category": {
120
+ "type": "string",
121
+ "description": "Category grouping for the principle"
122
+ },
123
+ "tags": {
124
+ "type": "array",
125
+ "items": { "type": "string" },
126
+ "description": "Optional tags for filtering and search"
127
+ },
128
+ "mandatory": {
129
+ "type": "boolean",
130
+ "description": "Whether this principle is mandatory",
131
+ "default": false
132
+ },
133
+ "relatedPrinciples": {
134
+ "type": "array",
135
+ "items": { "type": "string" },
136
+ "description": "Related principle IDs"
137
+ }
138
+ }
139
+ },
140
+ "RuleCondition": {
141
+ "type": "object",
142
+ "required": ["field", "operator", "value"],
143
+ "additionalProperties": false,
144
+ "properties": {
145
+ "field": {
146
+ "type": "string",
147
+ "description": "The field or metric to evaluate"
148
+ },
149
+ "operator": { "$ref": "#/definitions/ConditionOperator" },
150
+ "value": {
151
+ "oneOf": [
152
+ { "type": "string" },
153
+ { "type": "number" },
154
+ { "type": "boolean" },
155
+ { "type": "array", "items": { "type": "string" } },
156
+ { "type": "array", "items": { "type": "number" } }
157
+ ],
158
+ "description": "Value to compare against"
159
+ },
160
+ "unit": {
161
+ "type": "string",
162
+ "description": "Optional unit for the value"
163
+ },
164
+ "and": {
165
+ "type": "array",
166
+ "items": { "$ref": "#/definitions/RuleCondition" },
167
+ "description": "Nested conditions for complex logic"
168
+ },
169
+ "or": {
170
+ "type": "array",
171
+ "items": { "$ref": "#/definitions/RuleCondition" },
172
+ "description": "Alternative conditions"
173
+ }
174
+ }
175
+ },
176
+ "RuleAction": {
177
+ "type": "object",
178
+ "required": ["type", "message"],
179
+ "additionalProperties": false,
180
+ "properties": {
181
+ "type": { "$ref": "#/definitions/ActionType" },
182
+ "message": {
183
+ "type": "string",
184
+ "description": "Message to display or log"
185
+ },
186
+ "params": {
187
+ "type": "object",
188
+ "description": "Additional parameters for the action"
189
+ },
190
+ "stopProcessing": {
191
+ "type": "boolean",
192
+ "description": "Whether to halt further processing",
193
+ "default": false
194
+ },
195
+ "notify": {
196
+ "type": "array",
197
+ "items": { "type": "string" },
198
+ "description": "Notification targets"
199
+ }
200
+ }
201
+ },
202
+ "Rule": {
203
+ "type": "object",
204
+ "required": ["id", "principleId", "condition", "action", "severity"],
205
+ "additionalProperties": false,
206
+ "properties": {
207
+ "id": {
208
+ "type": "string",
209
+ "description": "Unique identifier for the rule",
210
+ "pattern": "^[a-z0-9-]+$"
211
+ },
212
+ "name": {
213
+ "type": "string",
214
+ "description": "Human-readable name"
215
+ },
216
+ "principleId": {
217
+ "type": "string",
218
+ "description": "Reference to the principle this rule enforces"
219
+ },
220
+ "condition": { "$ref": "#/definitions/RuleCondition" },
221
+ "action": { "$ref": "#/definitions/RuleAction" },
222
+ "severity": { "$ref": "#/definitions/SeverityLevel" },
223
+ "enabled": {
224
+ "type": "boolean",
225
+ "description": "Whether this rule is enabled",
226
+ "default": true
227
+ },
228
+ "description": {
229
+ "type": "string",
230
+ "description": "Description of what this rule checks"
231
+ },
232
+ "remediation": {
233
+ "type": "string",
234
+ "description": "Remediation guidance when rule is violated"
235
+ },
236
+ "examples": {
237
+ "type": "array",
238
+ "items": { "type": "string" },
239
+ "description": "Example of compliant code/configuration"
240
+ }
241
+ }
242
+ },
243
+ "MetricDefinition": {
244
+ "type": "object",
245
+ "required": ["id", "name", "unit", "aggregation"],
246
+ "additionalProperties": false,
247
+ "properties": {
248
+ "id": {
249
+ "type": "string",
250
+ "description": "Unique identifier for the metric",
251
+ "pattern": "^[a-z0-9-]+$"
252
+ },
253
+ "name": {
254
+ "type": "string",
255
+ "description": "Human-readable name"
256
+ },
257
+ "description": {
258
+ "type": "string",
259
+ "description": "Description of what this metric measures"
260
+ },
261
+ "unit": {
262
+ "type": "string",
263
+ "description": "Unit of measurement"
264
+ },
265
+ "aggregation": { "$ref": "#/definitions/AggregationType" },
266
+ "targetValue": {
267
+ "type": "number",
268
+ "description": "Target value to achieve"
269
+ },
270
+ "warningThreshold": {
271
+ "type": "number",
272
+ "description": "Value that triggers a warning"
273
+ },
274
+ "criticalThreshold": {
275
+ "type": "number",
276
+ "description": "Value that triggers a critical alert"
277
+ },
278
+ "dataType": {
279
+ "type": "string",
280
+ "enum": ["number", "percentage", "duration", "count", "ratio"],
281
+ "description": "Data type of the metric value"
282
+ },
283
+ "higherIsBetter": {
284
+ "type": "boolean",
285
+ "description": "Whether higher values are better",
286
+ "default": true
287
+ },
288
+ "formula": {
289
+ "type": "string",
290
+ "description": "Formula for computed metrics"
291
+ },
292
+ "dependencies": {
293
+ "type": "array",
294
+ "items": { "type": "string" },
295
+ "description": "Dependencies on other metrics"
296
+ },
297
+ "percentile": {
298
+ "type": "number",
299
+ "description": "Percentile for percentile-based metrics",
300
+ "minimum": 0,
301
+ "maximum": 100
302
+ }
303
+ }
304
+ },
305
+ "Threshold": {
306
+ "type": "object",
307
+ "required": ["id", "metricId", "mode", "warning", "critical"],
308
+ "additionalProperties": false,
309
+ "properties": {
310
+ "id": {
311
+ "type": "string",
312
+ "description": "Unique identifier for the threshold",
313
+ "pattern": "^[a-z0-9-]+$"
314
+ },
315
+ "metricId": {
316
+ "type": "string",
317
+ "description": "Reference to the metric this threshold applies to"
318
+ },
319
+ "name": {
320
+ "type": "string",
321
+ "description": "Human-readable name"
322
+ },
323
+ "mode": { "$ref": "#/definitions/ThresholdMode" },
324
+ "warning": {
325
+ "type": "number",
326
+ "description": "Warning level value"
327
+ },
328
+ "critical": {
329
+ "type": "number",
330
+ "description": "Critical level value"
331
+ },
332
+ "target": {
333
+ "type": "number",
334
+ "description": "Target value to aim for"
335
+ },
336
+ "blocking": {
337
+ "type": "boolean",
338
+ "description": "Whether to block on threshold violation",
339
+ "default": false
340
+ },
341
+ "period": {
342
+ "type": "string",
343
+ "description": "Time period for threshold evaluation"
344
+ },
345
+ "environments": {
346
+ "type": "array",
347
+ "items": { "type": "string" },
348
+ "description": "Applicable environments"
349
+ }
350
+ }
351
+ },
352
+ "ChangelogEntry": {
353
+ "type": "object",
354
+ "required": ["version", "date", "description"],
355
+ "additionalProperties": false,
356
+ "properties": {
357
+ "version": {
358
+ "type": "string",
359
+ "description": "Version number"
360
+ },
361
+ "date": {
362
+ "type": "string",
363
+ "format": "date-time",
364
+ "description": "Date of change"
365
+ },
366
+ "description": {
367
+ "type": "string",
368
+ "description": "Description of changes"
369
+ },
370
+ "author": {
371
+ "type": "string",
372
+ "description": "Who made the change"
373
+ }
374
+ }
375
+ },
376
+ "ConstitutionMetadata": {
377
+ "type": "object",
378
+ "required": ["createdAt", "updatedAt", "author", "applicableTo", "status"],
379
+ "additionalProperties": false,
380
+ "properties": {
381
+ "createdAt": {
382
+ "type": "string",
383
+ "format": "date-time",
384
+ "description": "When the constitution was created"
385
+ },
386
+ "updatedAt": {
387
+ "type": "string",
388
+ "format": "date-time",
389
+ "description": "When the constitution was last updated"
390
+ },
391
+ "author": {
392
+ "type": "string",
393
+ "description": "Who created or maintains the constitution"
394
+ },
395
+ "applicableTo": {
396
+ "type": "array",
397
+ "items": { "type": "string" },
398
+ "description": "Applicable agent types",
399
+ "minItems": 1
400
+ },
401
+ "inheritsFrom": {
402
+ "type": "string",
403
+ "description": "Parent constitution to inherit from"
404
+ },
405
+ "status": { "$ref": "#/definitions/ConstitutionStatus" },
406
+ "expiresAt": {
407
+ "type": "string",
408
+ "format": "date-time",
409
+ "description": "Optional expiration date"
410
+ },
411
+ "changelog": {
412
+ "type": "array",
413
+ "items": { "$ref": "#/definitions/ChangelogEntry" },
414
+ "description": "Changelog entries"
415
+ },
416
+ "customProperties": {
417
+ "type": "object",
418
+ "description": "Custom properties"
419
+ }
420
+ }
421
+ }
422
+ }
423
+ }