musubix 1.0.1 → 1.0.3

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.
@@ -0,0 +1,412 @@
1
+ # Constitutional Governance
2
+
3
+ **Version**: 1.0
4
+ **Status**: Immutable
5
+ **Enforcement**: Mandatory via `constitution-enforcer` skill
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ This document defines the 9 Constitutional Articles that govern all development activities in this project. These articles are **immutable** and must be enforced at every stage of the SDD workflow.
12
+
13
+ **Enforcement Agent**: The `constitution-enforcer` skill validates compliance with these articles before proceeding to implementation.
14
+
15
+ ---
16
+
17
+ ## Article I: Library-First Principle
18
+
19
+ **Statement**: All new features SHALL begin as independent libraries before integration into applications.
20
+
21
+ ### Requirements
22
+
23
+ - Every feature MUST start as a standalone library
24
+ - Libraries MUST have their own test suites
25
+ - Libraries MUST be independently deployable
26
+ - Libraries MUST NOT depend on application code
27
+ - Libraries MAY be published to package registries
28
+
29
+ ### Rationale
30
+
31
+ - Enforces modularity and reusability
32
+ - Prevents tight coupling
33
+ - Enables independent testing and versioning
34
+ - Facilitates code sharing across projects
35
+
36
+ ### Validation Checklist
37
+
38
+ - [ ] Feature implemented as library in `/lib` or separate package
39
+ - [ ] Library has independent package.json (if applicable)
40
+ - [ ] Library has dedicated test suite
41
+ - [ ] Library exports public API
42
+ - [ ] No imports from application code
43
+
44
+ ---
45
+
46
+ ## Article II: CLI Interface Mandate
47
+
48
+ **Statement**: All libraries SHALL expose functionality through CLI interfaces.
49
+
50
+ ### Requirements
51
+
52
+ - Every library MUST provide a CLI interface
53
+ - CLI MUST expose all primary functionality
54
+ - CLI MUST follow consistent argument conventions
55
+ - CLI MUST provide help text and usage examples
56
+ - CLI MAY delegate to library API
57
+
58
+ ### Rationale
59
+
60
+ - Enables scriptability and automation
61
+ - Facilitates testing and debugging
62
+ - Improves developer experience
63
+ - Enables integration with CI/CD pipelines
64
+
65
+ ### Validation Checklist
66
+
67
+ - [ ] Library provides CLI entry point (bin/ or scripts/)
68
+ - [ ] CLI documented with --help flag
69
+ - [ ] CLI supports common operations
70
+ - [ ] CLI uses consistent argument patterns (flags, options)
71
+ - [ ] CLI exit codes follow conventions (0=success, non-zero=error)
72
+
73
+ ---
74
+
75
+ ## Article III: Test-First Imperative
76
+
77
+ **Statement**: Tests SHALL be written before implementation (Red-Green-Blue cycle).
78
+
79
+ ### Requirements
80
+
81
+ - Tests MUST be written before production code
82
+ - Tests MUST follow Red-Green-Blue cycle:
83
+ 1. **Red**: Write failing test
84
+ 2. **Green**: Write minimal code to pass
85
+ 3. **Blue**: Refactor with confidence
86
+ - Tests MUST cover all EARS requirements
87
+ - Test coverage MUST exceed 80%
88
+ - Integration tests MUST use real services (see Article IX)
89
+
90
+ ### Rationale
91
+
92
+ - Ensures requirements are testable
93
+ - Prevents over-engineering
94
+ - Provides executable specifications
95
+ - Enables safe refactoring
96
+
97
+ ### Validation Checklist
98
+
99
+ - [ ] Tests exist before implementation
100
+ - [ ] All EARS requirements have corresponding tests
101
+ - [ ] Test coverage ≥ 80%
102
+ - [ ] Tests follow Red-Green-Blue evidence (git history)
103
+ - [ ] No production code without tests
104
+
105
+ ---
106
+
107
+ ## Article IV: EARS Requirements Format
108
+
109
+ **Statement**: All requirements SHALL use EARS (Easy Approach to Requirements Syntax) format.
110
+
111
+ ### Requirements
112
+
113
+ - Requirements MUST use one of 5 EARS patterns:
114
+ 1. **Event-driven**: `WHEN [event], the [system] SHALL [response]`
115
+ 2. **State-driven**: `WHILE [state], the [system] SHALL [response]`
116
+ 3. **Unwanted behavior**: `IF [error], THEN the [system] SHALL [response]`
117
+ 4. **Optional features**: `WHERE [feature enabled], the [system] SHALL [response]`
118
+ 5. **Ubiquitous**: `The [system] SHALL [requirement]`
119
+ - Requirements MUST be unambiguous
120
+ - Requirements MUST include acceptance criteria
121
+ - Requirements MUST be traceable to design and tests
122
+
123
+ ### Rationale
124
+
125
+ - Eliminates ambiguity
126
+ - Improves testability
127
+ - Enables traceability
128
+ - Standardizes requirements format
129
+
130
+ ### Validation Checklist
131
+
132
+ - [ ] All requirements use EARS patterns
133
+ - [ ] Requirements are unambiguous (single interpretation)
134
+ - [ ] Acceptance criteria defined
135
+ - [ ] Requirements mapped to tests (see `traceability-auditor`)
136
+ - [ ] Requirements reviewed by stakeholders
137
+
138
+ **Reference**: See `steering/rules/ears-format.md` for complete EARS guide.
139
+
140
+ ---
141
+
142
+ ## Article V: Traceability Mandate
143
+
144
+ **Statement**: 100% traceability SHALL be maintained between Requirements ↔ Design ↔ Code ↔ Tests.
145
+
146
+ ### Requirements
147
+
148
+ - Every requirement MUST map to:
149
+ - Design decisions (architecture, API, database)
150
+ - Implementation (source files, functions)
151
+ - Tests (test cases, scenarios)
152
+ - Every test MUST reference requirement ID
153
+ - Design documents MUST include requirements coverage matrix
154
+ - Task breakdowns MUST map to requirements
155
+
156
+ ### Rationale
157
+
158
+ - Ensures nothing is missed
159
+ - Validates completeness
160
+ - Enables impact analysis
161
+ - Facilitates audits and compliance
162
+
163
+ ### Validation Checklist
164
+
165
+ - [ ] Requirements have unique IDs (REQ-XXX-NNN)
166
+ - [ ] Design documents include requirements matrix
167
+ - [ ] Code comments reference requirement IDs
168
+ - [ ] Tests reference requirement IDs in descriptions
169
+ - [ ] `traceability-auditor` validation passes
170
+
171
+ **Enforcement Agent**: Use `traceability-auditor` skill to validate coverage.
172
+
173
+ ---
174
+
175
+ ## Article VI: Project Memory (Steering System)
176
+
177
+ **Statement**: All skills SHALL consult project memory (steering files) before making decisions.
178
+
179
+ ### Requirements
180
+
181
+ - `steering/structure.md` MUST define architecture patterns
182
+ - `steering/tech.md` MUST define technology stack
183
+ - `steering/product.md` MUST define business context
184
+ - All skills MUST read steering files before executing
185
+ - Steering files MUST be kept up-to-date
186
+ - Changes to steering REQUIRE stakeholder approval
187
+
188
+ ### Rationale
189
+
190
+ - Ensures consistency across skills
191
+ - Provides project context to AI agents
192
+ - Prevents architectural drift
193
+ - Enables autonomous decision-making
194
+
195
+ ### Validation Checklist
196
+
197
+ - [ ] Steering files exist and are current
198
+ - [ ] Skill reads steering files before execution
199
+ - [ ] Decisions align with steering context
200
+ - [ ] Changes to steering are documented
201
+ - [ ] Steering sync performed regularly
202
+
203
+ **Management Agent**: Use `steering` skill to generate/update project memory.
204
+
205
+ ---
206
+
207
+ ## Article VII: Simplicity Gate (Phase -1 Gate)
208
+
209
+ **Statement**: Projects SHALL start with maximum 3 sub-projects initially.
210
+
211
+ ### Requirements
212
+
213
+ - Initial architecture MUST NOT exceed 3 projects
214
+ - Projects = independently deployable units
215
+ - Additional projects require Phase -1 Gate approval
216
+ - Complexity MUST be justified with:
217
+ - Business requirements
218
+ - Technical constraints
219
+ - Team capacity analysis
220
+
221
+ ### Rationale
222
+
223
+ - Prevents premature complexity
224
+ - Reduces coordination overhead
225
+ - Enables faster iteration
226
+ - Forces prioritization
227
+
228
+ ### Validation Checklist
229
+
230
+ - [ ] Project count ≤ 3 initially
231
+ - [ ] Each project has clear purpose
232
+ - [ ] Projects are independently deployable
233
+ - [ ] Additional projects require approval gate
234
+ - [ ] Complexity justified in design.md
235
+
236
+ **Phase -1 Gate**: Requires `system-architect` + `project-manager` approval before exceeding 3 projects.
237
+
238
+ ---
239
+
240
+ ## Article VIII: Anti-Abstraction Gate (Phase -1 Gate)
241
+
242
+ **Statement**: Framework features SHALL be used directly without custom abstraction layers.
243
+
244
+ ### Requirements
245
+
246
+ - MUST use framework APIs directly
247
+ - MUST NOT create custom abstractions over frameworks
248
+ - MUST NOT build "wrapper libraries" around frameworks
249
+ - Abstractions require Phase -1 Gate approval with:
250
+ - Multi-framework support justification
251
+ - Team expertise analysis
252
+ - Migration path documentation
253
+
254
+ ### Rationale
255
+
256
+ - Prevents over-engineering
257
+ - Reduces maintenance burden
258
+ - Leverages framework best practices
259
+ - Enables framework updates
260
+
261
+ ### Validation Checklist
262
+
263
+ - [ ] Framework APIs used directly in application code
264
+ - [ ] No custom wrapper libraries around frameworks
265
+ - [ ] Framework-specific features leveraged
266
+ - [ ] Abstractions justified with multi-framework need
267
+ - [ ] Team has framework expertise
268
+
269
+ **Phase -1 Gate**: Requires `system-architect` + `software-developer` approval for abstraction layers.
270
+
271
+ **Example Violations**:
272
+
273
+ - Creating `MyDatabase` wrapper around Prisma/TypeORM
274
+ - Building custom `HttpClient` wrapper around axios/fetch
275
+ - Implementing custom `Logger` abstraction over framework logging
276
+
277
+ **Valid Abstractions**:
278
+
279
+ - Multi-framework support (e.g., database library supporting Prisma AND TypeORM)
280
+ - Domain-specific abstractions (e.g., `PaymentGateway` interface with multiple providers)
281
+
282
+ ---
283
+
284
+ ## Article IX: Integration-First Testing
285
+
286
+ **Statement**: Integration tests SHALL use real services; mocks are discouraged.
287
+
288
+ ### Requirements
289
+
290
+ - Integration tests MUST use real databases, APIs, services
291
+ - Test databases MUST be isolated (containers, test schemas)
292
+ - External APIs MUST use sandbox/test environments
293
+ - Mocks ALLOWED only when:
294
+ - External service unavailable in test environment
295
+ - External service has usage limits/costs
296
+ - External service has no test environment
297
+ - Mock usage REQUIRES justification in test documentation
298
+
299
+ ### Rationale
300
+
301
+ - Tests real system behavior
302
+ - Catches integration issues early
303
+ - Validates actual service interactions
304
+ - Builds confidence in deployment
305
+
306
+ ### Validation Checklist
307
+
308
+ - [ ] Integration tests use real databases (Docker, test schema)
309
+ - [ ] External APIs use test/sandbox environments
310
+ - [ ] Mocks justified with unavailability/cost reasons
311
+ - [ ] Test data cleanup automated
312
+ - [ ] Tests pass against real services
313
+
314
+ **Tools**: Docker Compose, Testcontainers, test database schemas
315
+
316
+ ---
317
+
318
+ ## Phase -1 Gates
319
+
320
+ **Phase -1 Gates** are validation checkpoints that occur BEFORE implementation begins. They enforce constitutional compliance.
321
+
322
+ ### Gate Triggers
323
+
324
+ Gates are triggered when:
325
+
326
+ - Project count exceeds 3 (Article VII)
327
+ - Custom abstraction layers proposed (Article VIII)
328
+ - EARS requirements incomplete (Article IV)
329
+ - Traceability gaps detected (Article V)
330
+
331
+ ### Gate Process
332
+
333
+ 1. **Detection**: `constitution-enforcer` skill detects violation
334
+ 2. **Documentation**: Proposer documents justification
335
+ 3. **Review**: Required skills review proposal
336
+ 4. **Approval**: Stakeholders approve/reject
337
+ 5. **Proceed**: Implementation continues only after approval
338
+
339
+ ### Required Reviewers
340
+
341
+ | Gate | Required Skills | Stakeholders |
342
+ | ------------------------------- | ---------------------------------------- | --------------------------- |
343
+ | Simplicity (Article VII) | `system-architect`, `project-manager` | Tech lead, Product owner |
344
+ | Anti-Abstraction (Article VIII) | `system-architect`, `software-developer` | Tech lead, Senior engineer |
345
+ | EARS Compliance (Article IV) | `requirements-analyst` | Product owner, QA lead |
346
+ | Traceability (Article V) | `traceability-auditor` | QA lead, Compliance officer |
347
+
348
+ ---
349
+
350
+ ## Enforcement
351
+
352
+ ### Validation Agent
353
+
354
+ The `constitution-enforcer` skill automatically validates compliance:
355
+
356
+ ```bash
357
+ # Validate before implementation
358
+ @constitution-enforcer validate requirements.md
359
+ @constitution-enforcer validate design.md
360
+ ```
361
+
362
+ ### Validation Stages
363
+
364
+ | Stage | Articles Validated | Trigger |
365
+ | -------------- | -------------------- | ----------------- |
366
+ | Requirements | IV, V | Before design |
367
+ | Design | I, II, VI, VII, VIII | Before tasks |
368
+ | Implementation | III, V | Before commit |
369
+ | Testing | III, V, IX | Before deployment |
370
+
371
+ ### Violation Response
372
+
373
+ 1. **Blocker**: Implementation MUST NOT proceed
374
+ 2. **Documentation**: Violation documented in design.md
375
+ 3. **Resolution**: Either fix violation OR trigger Phase -1 Gate
376
+ 4. **Re-validation**: `constitution-enforcer` re-runs validation
377
+
378
+ ---
379
+
380
+ ## Amendment Process
381
+
382
+ **Constitutional articles are IMMUTABLE**. Amendments require:
383
+
384
+ 1. Unanimous stakeholder agreement
385
+ 2. Documentation of rationale
386
+ 3. Update to this file with version increment
387
+ 4. Update to `constitution-enforcer` skill validation logic
388
+ 5. Communication to all team members
389
+
390
+ **Version History**:
391
+
392
+ - v1.0 (Initial) - 9 Articles established
393
+
394
+ ---
395
+
396
+ ## Summary
397
+
398
+ | Article | Principle | Enforced By |
399
+ | ------- | ------------------- | ----------------------------------------------- |
400
+ | I | Library-First | `constitution-enforcer` |
401
+ | II | CLI Interface | `constitution-enforcer` |
402
+ | III | Test-First | `constitution-enforcer`, `test-engineer` |
403
+ | IV | EARS Format | `constitution-enforcer`, `requirements-analyst` |
404
+ | V | Traceability | `traceability-auditor` |
405
+ | VI | Project Memory | All skills (steering system) |
406
+ | VII | Simplicity Gate | `constitution-enforcer` (Phase -1) |
407
+ | VIII | Anti-Abstraction | `constitution-enforcer` (Phase -1) |
408
+ | IX | Integration Testing | `test-engineer` |
409
+
410
+ ---
411
+
412
+ **Powered by MUSUBI** - Constitutional governance for specification-driven development.