musubi-sdd 3.0.0 → 3.0.1

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 (57) hide show
  1. package/bin/musubi-browser.js +0 -0
  2. package/bin/musubi-convert.js +0 -0
  3. package/bin/musubi-gui.js +0 -0
  4. package/bin/musubi-validate.js +0 -10
  5. package/package.json +1 -1
  6. package/src/templates/agents/claude-code/skills/ai-ml-engineer/mlops-guide.md +350 -0
  7. package/src/templates/agents/claude-code/skills/ai-ml-engineer/model-card-template.md +246 -0
  8. package/src/templates/agents/claude-code/skills/api-designer/api-patterns.md +336 -0
  9. package/src/templates/agents/claude-code/skills/api-designer/openapi-template.md +376 -0
  10. package/src/templates/agents/claude-code/skills/bug-hunter/root-cause-analysis.md +177 -0
  11. package/src/templates/agents/claude-code/skills/change-impact-analyzer/dependency-graph-patterns.md +348 -0
  12. package/src/templates/agents/claude-code/skills/change-impact-analyzer/impact-analysis-template.md +246 -0
  13. package/src/templates/agents/claude-code/skills/cloud-architect/aws-patterns.md +239 -0
  14. package/src/templates/agents/claude-code/skills/cloud-architect/azure-patterns.md +300 -0
  15. package/src/templates/agents/claude-code/skills/cloud-architect/terraform-templates/azure-webapp.tf +337 -0
  16. package/src/templates/agents/claude-code/skills/code-reviewer/best-practices.md +155 -0
  17. package/src/templates/agents/claude-code/skills/code-reviewer/review-checklist.md +184 -0
  18. package/src/templates/agents/claude-code/skills/code-reviewer/review-standards.md +272 -0
  19. package/src/templates/agents/claude-code/skills/constitution-enforcer/constitutional-articles.md +449 -0
  20. package/src/templates/agents/claude-code/skills/constitution-enforcer/phase-minus-one-gates.md +375 -0
  21. package/src/templates/agents/claude-code/skills/database-administrator/backup-recovery.md +331 -0
  22. package/src/templates/agents/claude-code/skills/database-administrator/tuning-guide.md +314 -0
  23. package/src/templates/agents/claude-code/skills/database-schema-designer/schema-patterns.md +335 -0
  24. package/src/templates/agents/claude-code/skills/devops-engineer/ci-cd-templates.md +443 -0
  25. package/src/templates/agents/claude-code/skills/devops-engineer/pipeline-templates/github-actions.yml +311 -0
  26. package/src/templates/agents/claude-code/skills/devops-engineer/pipeline-templates/gitlab-ci.yml +255 -0
  27. package/src/templates/agents/claude-code/skills/orchestrator/patterns.md +266 -0
  28. package/src/templates/agents/claude-code/skills/orchestrator/selection-matrix.md +185 -0
  29. package/src/templates/agents/claude-code/skills/performance-engineer/optimization-playbook.md +306 -0
  30. package/src/templates/agents/claude-code/skills/performance-optimizer/benchmark-template.md +272 -0
  31. package/src/templates/agents/claude-code/skills/performance-optimizer/optimization-patterns.md +273 -0
  32. package/src/templates/agents/claude-code/skills/project-manager/agile-ceremonies.md +283 -0
  33. package/src/templates/agents/claude-code/skills/project-manager/project-templates.md +345 -0
  34. package/src/templates/agents/claude-code/skills/quality-assurance/qa-plan-template.md +219 -0
  35. package/src/templates/agents/claude-code/skills/release-coordinator/feature-flag-guide.md +312 -0
  36. package/src/templates/agents/claude-code/skills/release-coordinator/release-plan-template.md +230 -0
  37. package/src/templates/agents/claude-code/skills/requirements-analyst/ears-format.md +259 -0
  38. package/src/templates/agents/claude-code/skills/requirements-analyst/validation-rules.md +359 -0
  39. package/src/templates/agents/claude-code/skills/security-auditor/audit-checklists.md +243 -0
  40. package/src/templates/agents/claude-code/skills/security-auditor/owasp-top-10.md +349 -0
  41. package/src/templates/agents/claude-code/skills/security-auditor/vulnerability-patterns.md +295 -0
  42. package/src/templates/agents/claude-code/skills/site-reliability-engineer/incident-response-template.md +286 -0
  43. package/src/templates/agents/claude-code/skills/site-reliability-engineer/observability-patterns.md +359 -0
  44. package/src/templates/agents/claude-code/skills/site-reliability-engineer/slo-sli-guide.md +302 -0
  45. package/src/templates/agents/claude-code/skills/software-developer/solid-principles.md +348 -0
  46. package/src/templates/agents/claude-code/skills/software-developer/test-first-workflow.md +370 -0
  47. package/src/templates/agents/claude-code/skills/steering/auto-update-rules.md +328 -0
  48. package/src/templates/agents/claude-code/skills/system-architect/adr-template.md +295 -0
  49. package/src/templates/agents/claude-code/skills/system-architect/c4-model-guide.md +328 -0
  50. package/src/templates/agents/claude-code/skills/technical-writer/doc-templates/documentation-templates.md +436 -0
  51. package/src/templates/agents/claude-code/skills/test-engineer/ears-test-mapping.md +444 -0
  52. package/src/templates/agents/claude-code/skills/test-engineer/test-types.md +425 -0
  53. package/src/templates/agents/claude-code/skills/traceability-auditor/coverage-matrix-template.md +131 -0
  54. package/src/templates/agents/claude-code/skills/traceability-auditor/gap-detection-rules.md +227 -0
  55. package/src/templates/agents/claude-code/skills/ui-ux-designer/accessibility-guidelines.md +318 -0
  56. package/src/templates/agents/claude-code/skills/ui-ux-designer/design-system-components.md +345 -0
  57. package/src/validators/constitutional-validator.js +494 -0
@@ -0,0 +1,425 @@
1
+ # Test Types Guide
2
+
3
+ ## Overview
4
+
5
+ This guide covers the different types of tests used in MUSUBI SDD and when to apply each type.
6
+
7
+ ---
8
+
9
+ ## Test Pyramid
10
+
11
+ ```
12
+ ╱╲
13
+ ╱ ╲
14
+ ╱ E2E╲ ← Fewest tests (slow, expensive)
15
+ ╱──────╲
16
+ ╱ ╲
17
+ ╱Integration╲ ← More tests (medium speed)
18
+ ╱────────────╲
19
+ ╱ ╲
20
+ ╱ Unit Tests ╲ ← Most tests (fast, cheap)
21
+ ╱──────────────────╲
22
+
23
+ Speed: ◀── Slow ──────────────── Fast ──▶
24
+ Cost: ◀── Expensive ──────────── Cheap ──▶
25
+ Confidence: ◀── High ───────────────── Low ───▶
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Unit Tests
31
+
32
+ ### Purpose
33
+ Test individual units (functions, methods, classes) in isolation.
34
+
35
+ ### Characteristics
36
+ - Fast execution (milliseconds)
37
+ - Dependencies are mocked
38
+ - Test single behavior per test
39
+ - High code coverage
40
+
41
+ ### When to Use
42
+ - Testing business logic
43
+ - Testing algorithms
44
+ - Testing edge cases
45
+ - Testing error handling
46
+
47
+ ### Example
48
+ ```typescript
49
+ // tests/services/calculator.test.ts
50
+ describe('Calculator', () => {
51
+ describe('add', () => {
52
+ it('should add two positive numbers', () => {
53
+ const calc = new Calculator();
54
+ expect(calc.add(2, 3)).toBe(5);
55
+ });
56
+
57
+ it('should handle negative numbers', () => {
58
+ const calc = new Calculator();
59
+ expect(calc.add(-2, 3)).toBe(1);
60
+ });
61
+
62
+ it('should return 0 when adding number to its negative', () => {
63
+ const calc = new Calculator();
64
+ expect(calc.add(5, -5)).toBe(0);
65
+ });
66
+ });
67
+ });
68
+ ```
69
+
70
+ ### Best Practices
71
+ - One assertion per test (when practical)
72
+ - Use descriptive test names
73
+ - Follow AAA pattern (Arrange, Act, Assert)
74
+ - Mock external dependencies
75
+
76
+ ---
77
+
78
+ ## Integration Tests
79
+
80
+ ### Purpose
81
+ Test how multiple components work together.
82
+
83
+ ### Characteristics
84
+ - Medium speed (seconds)
85
+ - Uses real or test databases
86
+ - Tests component interactions
87
+ - Validates data flow
88
+
89
+ ### When to Use
90
+ - Testing API endpoints
91
+ - Testing database operations
92
+ - Testing service interactions
93
+ - Testing middleware chains
94
+
95
+ ### Example
96
+ ```typescript
97
+ // tests/integration/auth.test.ts
98
+ describe('Authentication Flow', () => {
99
+ let app: Express;
100
+ let db: TestDatabase;
101
+
102
+ beforeAll(async () => {
103
+ db = await TestDatabase.connect();
104
+ app = createApp({ database: db });
105
+ });
106
+
107
+ afterAll(async () => {
108
+ await db.disconnect();
109
+ });
110
+
111
+ describe('POST /api/auth/login', () => {
112
+ it('should authenticate user and return token', async () => {
113
+ // Arrange
114
+ await db.createUser({
115
+ email: 'test@example.com',
116
+ password: 'hashed_password'
117
+ });
118
+
119
+ // Act
120
+ const response = await request(app)
121
+ .post('/api/auth/login')
122
+ .send({
123
+ email: 'test@example.com',
124
+ password: 'password123'
125
+ });
126
+
127
+ // Assert
128
+ expect(response.status).toBe(200);
129
+ expect(response.body.token).toBeDefined();
130
+ expect(response.body.user.email).toBe('test@example.com');
131
+ });
132
+
133
+ it('should reject invalid credentials', async () => {
134
+ const response = await request(app)
135
+ .post('/api/auth/login')
136
+ .send({
137
+ email: 'test@example.com',
138
+ password: 'wrongpassword'
139
+ });
140
+
141
+ expect(response.status).toBe(401);
142
+ expect(response.body.error).toBe('Invalid credentials');
143
+ });
144
+ });
145
+ });
146
+ ```
147
+
148
+ ### Best Practices
149
+ - Use test database (not production)
150
+ - Clean database between tests
151
+ - Test both success and error paths
152
+ - Verify side effects (database state, events)
153
+
154
+ ---
155
+
156
+ ## End-to-End (E2E) Tests
157
+
158
+ ### Purpose
159
+ Test complete user journeys through the application.
160
+
161
+ ### Characteristics
162
+ - Slow execution (minutes)
163
+ - Uses real browser/environment
164
+ - Tests full system
165
+ - Highest confidence
166
+
167
+ ### When to Use
168
+ - Critical user journeys
169
+ - Happy path validation
170
+ - Regression testing
171
+ - Pre-release verification
172
+
173
+ ### Example
174
+ ```typescript
175
+ // tests/e2e/checkout.test.ts
176
+ describe('Checkout Flow', () => {
177
+ it('should complete purchase successfully', async () => {
178
+ // Navigate to product
179
+ await page.goto('/products/123');
180
+
181
+ // Add to cart
182
+ await page.click('[data-testid="add-to-cart"]');
183
+
184
+ // Go to cart
185
+ await page.click('[data-testid="cart-icon"]');
186
+ expect(await page.textContent('.cart-count')).toBe('1');
187
+
188
+ // Proceed to checkout
189
+ await page.click('[data-testid="checkout-button"]');
190
+
191
+ // Fill shipping info
192
+ await page.fill('[name="address"]', '123 Main St');
193
+ await page.fill('[name="city"]', 'New York');
194
+ await page.fill('[name="zip"]', '10001');
195
+
196
+ // Fill payment info
197
+ await page.fill('[name="cardNumber"]', '4111111111111111');
198
+ await page.fill('[name="expiry"]', '12/25');
199
+ await page.fill('[name="cvv"]', '123');
200
+
201
+ // Complete order
202
+ await page.click('[data-testid="place-order"]');
203
+
204
+ // Verify success
205
+ await page.waitForSelector('.order-confirmation');
206
+ expect(await page.textContent('.order-number')).toMatch(/ORD-\d+/);
207
+ });
208
+ });
209
+ ```
210
+
211
+ ### Best Practices
212
+ - Focus on critical paths
213
+ - Keep tests minimal (expensive to run)
214
+ - Use stable selectors (data-testid)
215
+ - Handle async operations properly
216
+
217
+ ---
218
+
219
+ ## Component Tests (Frontend)
220
+
221
+ ### Purpose
222
+ Test React/Vue/Angular components in isolation.
223
+
224
+ ### Characteristics
225
+ - Fast execution
226
+ - Tests rendering and interactions
227
+ - Mocks external services
228
+ - Uses testing library
229
+
230
+ ### Example
231
+ ```typescript
232
+ // tests/components/LoginForm.test.tsx
233
+ import { render, screen, fireEvent } from '@testing-library/react';
234
+ import { LoginForm } from './LoginForm';
235
+
236
+ describe('LoginForm', () => {
237
+ it('should render email and password fields', () => {
238
+ render(<LoginForm onSubmit={jest.fn()} />);
239
+
240
+ expect(screen.getByLabelText('Email')).toBeInTheDocument();
241
+ expect(screen.getByLabelText('Password')).toBeInTheDocument();
242
+ expect(screen.getByRole('button', { name: 'Login' })).toBeInTheDocument();
243
+ });
244
+
245
+ it('should call onSubmit with form data', async () => {
246
+ const handleSubmit = jest.fn();
247
+ render(<LoginForm onSubmit={handleSubmit} />);
248
+
249
+ fireEvent.change(screen.getByLabelText('Email'), {
250
+ target: { value: 'test@example.com' }
251
+ });
252
+ fireEvent.change(screen.getByLabelText('Password'), {
253
+ target: { value: 'password123' }
254
+ });
255
+ fireEvent.click(screen.getByRole('button', { name: 'Login' }));
256
+
257
+ expect(handleSubmit).toHaveBeenCalledWith({
258
+ email: 'test@example.com',
259
+ password: 'password123'
260
+ });
261
+ });
262
+
263
+ it('should show validation error for invalid email', async () => {
264
+ render(<LoginForm onSubmit={jest.fn()} />);
265
+
266
+ fireEvent.change(screen.getByLabelText('Email'), {
267
+ target: { value: 'invalid-email' }
268
+ });
269
+ fireEvent.blur(screen.getByLabelText('Email'));
270
+
271
+ expect(await screen.findByText('Invalid email format')).toBeInTheDocument();
272
+ });
273
+ });
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Contract Tests
279
+
280
+ ### Purpose
281
+ Verify API contracts between services.
282
+
283
+ ### Characteristics
284
+ - Tests API schema compliance
285
+ - Uses Pact or similar
286
+ - Consumer-driven contracts
287
+ - Prevents breaking changes
288
+
289
+ ### Example
290
+ ```typescript
291
+ // tests/contracts/user-api.pact.ts
292
+ describe('User API Contract', () => {
293
+ const provider = new Pact({
294
+ consumer: 'WebApp',
295
+ provider: 'UserService'
296
+ });
297
+
298
+ beforeAll(() => provider.setup());
299
+ afterAll(() => provider.finalize());
300
+
301
+ describe('GET /users/:id', () => {
302
+ it('should return user by ID', async () => {
303
+ // Define expected interaction
304
+ await provider.addInteraction({
305
+ state: 'user with ID 123 exists',
306
+ uponReceiving: 'a request for user 123',
307
+ withRequest: {
308
+ method: 'GET',
309
+ path: '/users/123'
310
+ },
311
+ willRespondWith: {
312
+ status: 200,
313
+ body: {
314
+ id: '123',
315
+ name: like('John Doe'),
316
+ email: like('john@example.com')
317
+ }
318
+ }
319
+ });
320
+
321
+ // Execute request
322
+ const response = await userClient.getUser('123');
323
+
324
+ // Verify
325
+ expect(response.id).toBe('123');
326
+ await provider.verify();
327
+ });
328
+ });
329
+ });
330
+ ```
331
+
332
+ ---
333
+
334
+ ## Performance Tests
335
+
336
+ ### Purpose
337
+ Verify system performance under load.
338
+
339
+ ### Characteristics
340
+ - Tests response times
341
+ - Tests throughput
342
+ - Tests under stress
343
+ - Identifies bottlenecks
344
+
345
+ ### Example (k6)
346
+ ```javascript
347
+ // tests/performance/api-load.js
348
+ import http from 'k6/http';
349
+ import { check, sleep } from 'k6';
350
+
351
+ export const options = {
352
+ stages: [
353
+ { duration: '30s', target: 20 }, // Ramp up
354
+ { duration: '1m', target: 20 }, // Stay at 20
355
+ { duration: '30s', target: 50 }, // Ramp up more
356
+ { duration: '1m', target: 50 }, // Stay at 50
357
+ { duration: '30s', target: 0 }, // Ramp down
358
+ ],
359
+ thresholds: {
360
+ http_req_duration: ['p(95)<200'], // 95% < 200ms
361
+ http_req_failed: ['rate<0.01'], // <1% errors
362
+ },
363
+ };
364
+
365
+ export default function() {
366
+ const response = http.get('http://api.example.com/users');
367
+
368
+ check(response, {
369
+ 'status is 200': (r) => r.status === 200,
370
+ 'response time < 200ms': (r) => r.timings.duration < 200,
371
+ });
372
+
373
+ sleep(1);
374
+ }
375
+ ```
376
+
377
+ ---
378
+
379
+ ## Test Naming Convention
380
+
381
+ ### Format
382
+ ```
383
+ describe('[Subject]', () => {
384
+ describe('[Method/Action]', () => {
385
+ it('should [expected behavior] when [condition]', () => {});
386
+ });
387
+ });
388
+ ```
389
+
390
+ ### Examples
391
+ ```typescript
392
+ // Good names
393
+ it('should return user when credentials are valid')
394
+ it('should throw InvalidCredentialsError when password is wrong')
395
+ it('should send welcome email when user registers')
396
+
397
+ // Bad names
398
+ it('test login')
399
+ it('works')
400
+ it('should work correctly')
401
+ ```
402
+
403
+ ---
404
+
405
+ ## Test Organization
406
+
407
+ ```
408
+ tests/
409
+ ├── unit/ # Unit tests
410
+ │ ├── services/
411
+ │ ├── models/
412
+ │ └── utils/
413
+ ├── integration/ # Integration tests
414
+ │ ├── api/
415
+ │ ├── database/
416
+ │ └── services/
417
+ ├── e2e/ # End-to-end tests
418
+ │ ├── flows/
419
+ │ └── journeys/
420
+ ├── contracts/ # Contract tests
421
+ ├── performance/ # Performance tests
422
+ └── fixtures/ # Shared test data
423
+ ├── users.json
424
+ └── orders.json
425
+ ```
@@ -0,0 +1,131 @@
1
+ # Coverage Matrix Template
2
+
3
+ ## Overview
4
+
5
+ Template for creating traceability coverage matrices that ensure 100% compliance with Constitutional Article V.
6
+
7
+ ---
8
+
9
+ ## Full Traceability Matrix
10
+
11
+ ```markdown
12
+ # Traceability Matrix: [Feature Name]
13
+
14
+ **Date**: YYYY-MM-DD
15
+ **Version**: 1.0
16
+ **Status**: Complete | In Progress
17
+
18
+ ## Forward Traceability (Requirements → Implementation)
19
+
20
+ | REQ ID | Description | Design Ref | Task ID | Code Files | Test Files | Status |
21
+ |--------|-------------|------------|---------|------------|------------|--------|
22
+ | REQ-001 | User login | AUTH-SVC | P1-001 | auth/login.ts | auth/login.test.ts | ✅ |
23
+ | REQ-002 | Password reset | AUTH-SVC | P1-002 | auth/reset.ts | auth/reset.test.ts | ✅ |
24
+ | REQ-003 | 2FA support | AUTH-SVC | - | - | - | ❌ |
25
+
26
+ ## Backward Traceability (Tests → Requirements)
27
+
28
+ | Test ID | Test Description | Code File | REQ ID | Status |
29
+ |---------|-----------------|-----------|--------|--------|
30
+ | T-001 | Login success | auth/login.ts | REQ-001 | ✅ |
31
+ | T-002 | Login failure | auth/login.ts | REQ-001 | ✅ |
32
+ | T-003 | Session timeout | auth/session.ts | - | ⚠️ Orphan |
33
+
34
+ ## Coverage Summary
35
+
36
+ | Metric | Current | Target | Status |
37
+ |--------|---------|--------|--------|
38
+ | Requirements with Design | 100% | 100% | ✅ |
39
+ | Requirements with Code | 67% | 100% | ❌ |
40
+ | Requirements with Tests | 67% | 100% | ❌ |
41
+ | Overall Traceability | 67% | 100% | ❌ |
42
+
43
+ ## Gaps Identified
44
+
45
+ ### Missing Implementations
46
+ | REQ ID | Description | Action Required |
47
+ |--------|-------------|-----------------|
48
+ | REQ-003 | 2FA support | Create design & tasks |
49
+
50
+ ### Orphaned Tests
51
+ | Test ID | Description | Action Required |
52
+ |---------|-------------|-----------------|
53
+ | T-003 | Session timeout | Add requirement or remove |
54
+
55
+ ## Recommendations
56
+ 1. Implement REQ-003 or mark as deferred
57
+ 2. Create requirement for session timeout test
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Quick Coverage Report
63
+
64
+ ```markdown
65
+ # Coverage Report: [Feature]
66
+
67
+ ## At a Glance
68
+
69
+ 📊 **Overall: 67%** ❌ (Target: 100%)
70
+
71
+ | Stage | Coverage |
72
+ |-------|----------|
73
+ | REQ → Design | ████████░░ 80% |
74
+ | Design → Tasks | ██████████ 100% |
75
+ | Tasks → Code | ██████░░░░ 60% |
76
+ | Code → Tests | ████████░░ 80% |
77
+
78
+ ## Critical Gaps
79
+
80
+ 🔴 REQ-003: No implementation
81
+ 🔴 REQ-007: No tests
82
+
83
+ ## Next Actions
84
+
85
+ 1. [ ] Assign REQ-003 to developer
86
+ 2. [ ] Create tests for REQ-007
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Automated Matrix Generation
92
+
93
+ ```python
94
+ # generate_matrix.py
95
+
96
+ def generate_traceability_matrix(feature_name):
97
+ """Generate traceability matrix for a feature."""
98
+
99
+ requirements = parse_requirements(f"storage/features/{feature_name}/requirements.md")
100
+ design = parse_design(f"storage/features/{feature_name}/design.md")
101
+ tasks = parse_tasks(f"storage/features/{feature_name}/tasks.md")
102
+ code_files = find_code_files(f"src/{feature_name}/")
103
+ test_files = find_test_files(f"tests/{feature_name}/")
104
+
105
+ matrix = []
106
+ for req in requirements:
107
+ row = {
108
+ 'req_id': req.id,
109
+ 'description': req.description,
110
+ 'design_ref': find_design_ref(req.id, design),
111
+ 'task_id': find_task_ref(req.id, tasks),
112
+ 'code_files': find_code_ref(req.id, code_files),
113
+ 'test_files': find_test_ref(req.id, test_files),
114
+ 'status': calculate_status(row)
115
+ }
116
+ matrix.append(row)
117
+
118
+ return matrix
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Status Indicators
124
+
125
+ | Icon | Meaning |
126
+ |------|---------|
127
+ | ✅ | Fully traced |
128
+ | ⚠️ | Partially traced |
129
+ | ❌ | Not traced |
130
+ | 🔄 | In progress |
131
+ | ⏸️ | Deferred |