create-shhs 1.0.0 → 1.1.0

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,481 @@
1
+ # Definition of Done
2
+
3
+ **Version:** 1.0.0
4
+ **Authority:** Constitution Article VI
5
+ **Status:** ENFORCED
6
+
7
+ ---
8
+
9
+ ## Purpose
10
+
11
+ This document defines the **mandatory conditions** that MUST be satisfied before any code can be merged.
12
+
13
+ No shortcuts. No exceptions. No "I'll fix it later."
14
+
15
+ ---
16
+
17
+ ## Merge Gates
18
+
19
+ Code cannot be merged unless it passes ALL gates in sequence.
20
+
21
+ ```
22
+ Gate 1: Contractual Compliance
23
+
24
+ Gate 2: Structural Compliance
25
+
26
+ Gate 3: Behavioral Compliance
27
+
28
+ Gate 4: Domain Approval
29
+
30
+ Gate 5: Fitness Compliance
31
+
32
+ MERGE ALLOWED
33
+ ```
34
+
35
+ Any gate failure = **automatic merge block**.
36
+
37
+ ---
38
+
39
+ ## Gate 1: Contractual Compliance
40
+
41
+ **Enforced By:** Root Architect / Automated Check
42
+
43
+ ### Conditions
44
+
45
+ - [ ] Feature contract exists in `.ai/features/[feature-name].feature`
46
+ - [ ] All cucumber scenarios in the contract pass
47
+ - [ ] Implementation scope matches contract (no undocumented features added)
48
+ - [ ] No contract scenarios are skipped or marked pending
49
+
50
+ ### Validation Command
51
+
52
+ ```bash
53
+ npm run test:cucumber -- .ai/features/[feature-name].feature
54
+ ```
55
+
56
+ ### Failure Actions
57
+
58
+ If cucumber scenarios fail:
59
+ 1. BLOCK merge
60
+ 2. Developer must fix implementation to satisfy contract
61
+ 3. Re-run validation
62
+
63
+ If scope exceeds contract:
64
+ 1. BLOCK merge
65
+ 2. Options:
66
+ - Remove out-of-scope code
67
+ - Root Architect amends contract via ADR
68
+
69
+ ### Veto Authority
70
+
71
+ Root Architect can veto if:
72
+ - Contract was bypassed
73
+ - Scope creep detected
74
+ - Feature diverges from architectural intent
75
+
76
+ ---
77
+
78
+ ## Gate 2: Structural Compliance
79
+
80
+ **Enforced By:** Static Reviewer + Fitness Enforcer
81
+
82
+ ### Conditions
83
+
84
+ #### Static Reviewer Checks
85
+
86
+ - [ ] No layer violations (e.g., presentation importing database)
87
+ - [ ] No forbidden imports (per `.ai/memory/anti-patterns.md`)
88
+ - [ ] No boundary breaches (bounded contexts remain isolated)
89
+ - [ ] Complexity metrics within bounds (functions <15 cyclomatic complexity)
90
+ - [ ] TDD evidence (test files committed before implementation files)
91
+
92
+ #### Fitness Enforcer Checks
93
+
94
+ - [ ] All fitness functions pass (no BLOCK-severity violations)
95
+ - [ ] Dependency limits respected (per `.ai/architecture/governance/fitness/rules.json`)
96
+ - [ ] No cross-domain database access
97
+ - [ ] Module centrality within threshold
98
+
99
+ ### Validation Commands
100
+
101
+ ```bash
102
+ # Static Review
103
+ npm run lint:architecture
104
+
105
+ # Fitness Enforcement
106
+ npm run fitness:enforce -- --mode prevent
107
+ ```
108
+
109
+ ### Failure Actions
110
+
111
+ If Static Reviewer fails:
112
+ 1. BLOCK merge
113
+ 2. Developer must refactor to fix violations
114
+ 3. Violations must be documented in report
115
+
116
+ If Fitness Enforcer fails (PREVENT mode):
117
+ 1. BLOCK merge
118
+ 2. Options:
119
+ - Fix violation
120
+ - Request ADR exemption (requires justification)
121
+
122
+ ### Veto Authority
123
+
124
+ Static Reviewer: VETO on layer violations
125
+ Fitness Enforcer: VETO on BLOCK-severity fitness violations
126
+
127
+ ---
128
+
129
+ ## Gate 3: Behavioral Compliance
130
+
131
+ **Enforced By:** QA Validator
132
+
133
+ ### Conditions
134
+
135
+ - [ ] All cucumber scenarios pass
136
+ - [ ] All Playwright E2E tests pass (if applicable to critical flow)
137
+ - [ ] All unit tests pass
138
+ - [ ] All integration tests pass
139
+ - [ ] Code coverage ≥ threshold (project default: 80%)
140
+ - [ ] No regressions (previously passing tests still pass)
141
+ - [ ] No flaky tests (tests pass 3 consecutive runs)
142
+
143
+ ### Validation Commands
144
+
145
+ ```bash
146
+ # Unit + Integration Tests
147
+ npm test
148
+
149
+ # E2E Tests
150
+ npm run test:e2e
151
+
152
+ # Coverage
153
+ npm test -- --coverage
154
+ ```
155
+
156
+ ### Failure Actions
157
+
158
+ If tests fail:
159
+ 1. BLOCK merge
160
+ 2. Developer must fix failing tests
161
+ 3. Re-run full test suite
162
+
163
+ If coverage below threshold:
164
+ 1. BLOCK merge
165
+ 2. Developer must add tests to meet threshold
166
+
167
+ If regressions detected:
168
+ 1. BLOCK merge
169
+ 2. Options:
170
+ - Fix implementation to restore passing tests
171
+ - Update tests if requirements changed (requires ADR)
172
+
173
+ ### Veto Authority
174
+
175
+ QA Validator: VETO on any test failure or coverage miss
176
+
177
+ ---
178
+
179
+ ## Gate 4: Domain Approval
180
+
181
+ **Enforced By:** Domain Architect
182
+
183
+ ### Conditions
184
+
185
+ - [ ] Bounded context integrity maintained
186
+ - [ ] No unauthorized cross-domain coupling
187
+ - [ ] Public API contracts respected
188
+ - [ ] Domain models remain consistent
189
+ - [ ] No domain logic leaked into infrastructure layer
190
+
191
+ ### Validation Process
192
+
193
+ Domain Architect manually reviews:
194
+ 1. Changes to domain models
195
+ 2. New cross-domain dependencies
196
+ 3. Public API modifications
197
+ 4. Domain event flows
198
+
199
+ ### Failure Actions
200
+
201
+ If domain integrity violated:
202
+ 1. BLOCK merge
203
+ 2. Domain Architect provides feedback
204
+ 3. Developer refactors to maintain domain boundaries
205
+
206
+ If cross-domain coupling introduced:
207
+ 1. BLOCK merge
208
+ 2. Options:
209
+ - Remove coupling
210
+ - Create ADR to justify coupling (requires strong rationale)
211
+
212
+ ### Veto Authority
213
+
214
+ Domain Architect: VETO on domain boundary violations
215
+
216
+ ---
217
+
218
+ ## Gate 5: Fitness Compliance
219
+
220
+ **Enforced By:** Fitness Enforcer (automated)
221
+
222
+ ### Conditions
223
+
224
+ - [ ] No BLOCK-severity fitness violations
225
+ - [ ] Dependency graph complexity within limits
226
+ - [ ] Module coupling score acceptable
227
+ - [ ] No god modules detected (>30% incoming dependencies)
228
+
229
+ ### Validation Command
230
+
231
+ ```bash
232
+ npm run fitness:enforce -- --mode prevent
233
+ ```
234
+
235
+ ### Failure Actions
236
+
237
+ If fitness violations detected:
238
+ 1. BLOCK merge
239
+ 2. Report generated in `.ai/reports/fitness-violations.json`
240
+ 3. Developer must remediate violations
241
+
242
+ ### Veto Authority
243
+
244
+ Fitness Enforcer: VETO on BLOCK-severity violations (unless ADR exemption exists)
245
+
246
+ ---
247
+
248
+ ## Artefacts Required
249
+
250
+ Before merge, the following artefacts must exist:
251
+
252
+ | Artefact | Location | Owner |
253
+ |----------|----------|-------|
254
+ | Feature contract | `.ai/features/[name].feature` | Root Architect |
255
+ | ADR (if architectural) | `.ai/ADR/ADR-XXXX-title.md` | Root Architect |
256
+ | Test files | `src/**/*.test.ts` | Developer |
257
+ | Cucumber scenarios | `.ai/features/*.feature` | Root Architect |
258
+ | Playwright tests (if critical flow) | `tests/e2e/**/*.spec.ts` | Developer |
259
+ | Static review report | `.ai/reports/static-review.json` | Static Reviewer |
260
+ | QA validation report | `.ai/reports/qa-validation.json` | QA Validator |
261
+ | Fitness enforcement report | `.ai/reports/fitness-results.json` | Fitness Enforcer |
262
+ | Domain approval | `.ai/reports/domain-approval.md` | Domain Architect |
263
+
264
+ ---
265
+
266
+ ## Merge Process
267
+
268
+ ### Step 1: Developer Self-Check
269
+
270
+ Before requesting review:
271
+
272
+ ```bash
273
+ # Run all validations locally
274
+ npm run validate:all
275
+ ```
276
+
277
+ This runs:
278
+ - Linting
279
+ - Tests
280
+ - Coverage check
281
+ - Fitness enforcement (DETECT mode)
282
+
283
+ ### Step 2: Submit for Review
284
+
285
+ Create pull request with:
286
+ - Link to feature contract
287
+ - Summary of changes
288
+ - Test coverage report
289
+ - Any ADR references
290
+
291
+ ### Step 3: Automated Gate Checks
292
+
293
+ CI/CD pipeline runs:
294
+ 1. Static Reviewer
295
+ 2. Fitness Enforcer
296
+ 3. QA Validator (tests)
297
+
298
+ ### Step 4: Manual Reviews
299
+
300
+ - Domain Architect reviews domain changes
301
+ - Root Architect reviews if ADR compliance questioned
302
+
303
+ ### Step 5: Merge Decision
304
+
305
+ Merge ONLY IF:
306
+ - All automated gates: ✅ PASS
307
+ - All manual reviews: ✅ APPROVED
308
+ - All artefacts present
309
+
310
+ ---
311
+
312
+ ## Bypass Conditions
313
+
314
+ ### Emergency Hotfix
315
+
316
+ **Criteria:**
317
+ - Production is down
318
+ - Critical security vulnerability
319
+ - Data loss imminent
320
+
321
+ **Process:**
322
+ 1. Incident declared by on-call engineer
323
+ 2. Hotfix branch created
324
+ 3. Minimum fix implemented
325
+ 4. Only Gate 3 (tests) enforced
326
+ 5. Post-incident: Full gate compliance required in follow-up PR
327
+
328
+ **Authority:** Requires approval from:
329
+ - Domain Architect
330
+ - Root Architect
331
+ - Engineering lead
332
+
333
+ ### Legacy Code Migration
334
+
335
+ **Criteria:**
336
+ - Code pre-dates SHHS adoption
337
+ - Incremental migration in progress
338
+
339
+ **Process:**
340
+ 1. ADR created documenting migration plan
341
+ 2. Exemptions granted in `.ai/architecture/governance/fitness/exemptions.json`
342
+ 3. Each exemption has expiration date
343
+ 4. Monthly review of exemptions
344
+
345
+ **Authority:** Root Architect + Architecture Reviewer
346
+
347
+ ---
348
+
349
+ ## Continuous Improvement
350
+
351
+ ### Quarterly Gate Review
352
+
353
+ Every 3 months, Architecture Reviewer evaluates:
354
+ - Are gates too strict? (blocking valid work)
355
+ - Are gates too lenient? (letting debt through)
356
+ - Should new gates be added?
357
+ - Should thresholds be adjusted?
358
+
359
+ ### Metrics Tracking
360
+
361
+ Track over time:
362
+ - Merge success rate (first attempt)
363
+ - Most common gate failures
364
+ - Time from PR creation to merge
365
+ - Gate bypass frequency
366
+
367
+ Metrics inform gate tuning.
368
+
369
+ ---
370
+
371
+ ## Roles and Veto Rights
372
+
373
+ | Role | Gate | Veto Power | Override Condition |
374
+ |------|------|------------|-------------------|
375
+ | Root Architect | 1 | ✅ YES | Unanimous Architecture Review Board |
376
+ | Static Reviewer | 2 | ✅ YES | ADR exemption |
377
+ | Fitness Enforcer | 2, 5 | ✅ YES | ADR exemption |
378
+ | QA Validator | 3 | ✅ YES | None (tests must pass) |
379
+ | Domain Architect | 4 | ✅ YES | ADR + unanimous approval |
380
+
381
+ **Architecture Review Board:** Root Architect + Domain Architect + Architecture Reviewer
382
+
383
+ ---
384
+
385
+ ## Enforcement
386
+
387
+ ### Automated Enforcement
388
+
389
+ CI/CD pipeline **blocks merge** if gates fail.
390
+
391
+ ```yaml
392
+ # .github/workflows/gates.yml
393
+ name: Merge Gates
394
+
395
+ on: pull_request
396
+
397
+ jobs:
398
+ gate-1-contract:
399
+ runs-on: ubuntu-latest
400
+ steps:
401
+ - name: Validate Feature Contract
402
+ run: npm run validate:contract
403
+
404
+ gate-2-structure:
405
+ runs-on: ubuntu-latest
406
+ steps:
407
+ - name: Static Review
408
+ run: npm run lint:architecture
409
+ - name: Fitness Enforcement
410
+ run: npm run fitness:enforce -- --mode prevent
411
+
412
+ gate-3-behavior:
413
+ runs-on: ubuntu-latest
414
+ steps:
415
+ - name: Run Tests
416
+ run: npm test -- --coverage
417
+ - name: Run E2E Tests
418
+ run: npm run test:e2e
419
+
420
+ gate-4-domain:
421
+ runs-on: ubuntu-latest
422
+ steps:
423
+ - name: Domain Review Required
424
+ run: echo "Manual review required"
425
+
426
+ gate-5-fitness:
427
+ runs-on: ubuntu-latest
428
+ steps:
429
+ - name: Final Fitness Check
430
+ run: npm run fitness:enforce -- --mode prevent
431
+ ```
432
+
433
+ ### Manual Enforcement
434
+
435
+ Domain Architect review is REQUIRED for merge.
436
+
437
+ GitHub branch protection rules:
438
+ - Require status checks to pass
439
+ - Require review from Domain Architect
440
+ - Require linear history (no merge commits)
441
+
442
+ ---
443
+
444
+ ## Consequences of Bypass
445
+
446
+ If code is merged without satisfying Definition of Done:
447
+
448
+ 1. **Immediate Rollback**
449
+ - Code reverted immediately
450
+ - Incident created
451
+
452
+ 2. **Post-Mortem**
453
+ - Why were gates bypassed?
454
+ - What prevented gates from catching the issue?
455
+
456
+ 3. **Process Improvement**
457
+ - Update gates to prevent recurrence
458
+ - Add new fitness function if needed
459
+
460
+ ---
461
+
462
+ ## Summary Checklist
463
+
464
+ Before merging, verify:
465
+
466
+ - [ ] Gate 1: Feature contract exists and passes
467
+ - [ ] Gate 2: Static review and fitness enforcement pass
468
+ - [ ] Gate 3: All tests pass, coverage meets threshold
469
+ - [ ] Gate 4: Domain Architect approval
470
+ - [ ] Gate 5: No fitness violations
471
+ - [ ] All required artefacts generated
472
+ - [ ] No exemptions expired
473
+ - [ ] CI/CD pipeline green
474
+
475
+ **If ALL boxes checked: MERGE ALLOWED**
476
+
477
+ **If ANY box unchecked: MERGE BLOCKED**
478
+
479
+ ---
480
+
481
+ **END OF DEFINITION OF DONE**
@@ -0,0 +1,210 @@
1
+ # Knowledge Base
2
+
3
+ **Last Updated:** 2026-02-24
4
+ **Maintained By:** Knowledge Curator
5
+ **Status:** Living Document
6
+
7
+ ---
8
+
9
+ ## Purpose
10
+
11
+ This document contains verified technical constraints, library-specific anti-patterns, and stack limitations discovered through Context7 queries and architectural validation.
12
+
13
+ **Source of Truth Hierarchy:**
14
+ 1. Official library documentation (via Context7)
15
+ 2. This knowledge base (as cache)
16
+ 3. Developer assumptions (lowest priority)
17
+
18
+ ---
19
+
20
+ ## Stack Constraints
21
+
22
+ ### [Library Name] — Version X.Y.Z
23
+
24
+ **Last Validated:** YYYY-MM-DD
25
+
26
+ #### Hard Constraints
27
+
28
+ | Constraint | Evidence | Impact |
29
+ |------------|----------|--------|
30
+ | [Description of limitation] | [Docs URL + quote] | [Architectural implications] |
31
+
32
+ **Example:**
33
+ | Constraint | Evidence | Impact |
34
+ |------------|----------|--------|
35
+ | React Server Components cannot use `useState` or `useEffect` | [React Docs: Server Components](https://react.dev/reference/rsc/server-components) — "Server Components run only on the server and cannot use hooks" | Any interactive UI must be split into Client Components |
36
+
37
+ #### Recommended Patterns
38
+
39
+ - **Pattern:** [Name]
40
+ - **Use Case:** [When to apply]
41
+ - **Implementation:** [Code example or reference]
42
+ - **Source:** [Docs URL]
43
+
44
+ #### Anti-Patterns
45
+
46
+ - **Anti-Pattern:** [Name]
47
+ - **Symptom:** [What developers try to do]
48
+ - **Why It Fails:** [Technical reason]
49
+ - **Evidence:** [Docs quote]
50
+ - **Correct Approach:** [Alternative]
51
+
52
+ ---
53
+
54
+ ## Framework-Specific Knowledge
55
+
56
+ ### Next.js
57
+
58
+ **Version:** [Current project version]
59
+ **Last Validated:** YYYY-MM-DD
60
+
61
+ #### Constraints
62
+
63
+ - [Constraint 1]
64
+ - [Constraint 2]
65
+
66
+ #### Recommended Patterns
67
+
68
+ - [Pattern 1]
69
+ - [Pattern 2]
70
+
71
+ #### Anti-Patterns
72
+
73
+ - [Anti-Pattern 1]
74
+ - [Anti-Pattern 2]
75
+
76
+ ---
77
+
78
+ ### Playwright
79
+
80
+ **Version:** [Current project version]
81
+ **Last Validated:** YYYY-MM-DD
82
+
83
+ #### Constraints
84
+
85
+ - [Constraint 1]
86
+ - [Constraint 2]
87
+
88
+ #### Recommended Patterns
89
+
90
+ - [Pattern 1]
91
+ - [Pattern 2]
92
+
93
+ #### Anti-Patterns
94
+
95
+ - [Anti-Pattern 1]
96
+ - [Anti-Pattern 2]
97
+
98
+ ---
99
+
100
+ ## Database Constraints
101
+
102
+ ### PostgreSQL
103
+
104
+ **Version:** [Current project version]
105
+ **Last Validated:** YYYY-MM-DD
106
+
107
+ #### Constraints
108
+
109
+ - [Constraint 1]
110
+ - [Constraint 2]
111
+
112
+ #### Recommended Patterns
113
+
114
+ - [Pattern 1]
115
+ - [Pattern 2]
116
+
117
+ #### Anti-Patterns
118
+
119
+ - [Anti-Pattern 1]
120
+ - [Anti-Pattern 2]
121
+
122
+ ---
123
+
124
+ ## Testing Stack
125
+
126
+ ### Jest
127
+
128
+ **Version:** [Current project version]
129
+ **Last Validated:** YYYY-MM-DD
130
+
131
+ #### Constraints
132
+
133
+ - [Constraint 1]
134
+ - [Constraint 2]
135
+
136
+ #### Recommended Patterns
137
+
138
+ - [Pattern 1]
139
+ - [Pattern 2]
140
+
141
+ #### Anti-Patterns
142
+
143
+ - [Anti-Pattern 1]
144
+ - [Anti-Pattern 2]
145
+
146
+ ---
147
+
148
+ ## Validation History
149
+
150
+ | Date | Library | Version | Validator | Status |
151
+ |------|---------|---------|-----------|--------|
152
+ | YYYY-MM-DD | [Name] | X.Y.Z | Knowledge Curator | ✅ Validated |
153
+
154
+ ---
155
+
156
+ ## Invalidation Schedule
157
+
158
+ Libraries require revalidation when:
159
+
160
+ 1. **Version Upgrade:** Immediately upon dependency version change
161
+ 2. **Major Framework Release:** Within 1 week of release
162
+ 3. **Time Decay:** Every 6 months if no changes
163
+
164
+ ### Next Revalidation Dates
165
+
166
+ | Library | Current Version | Next Revalidation | Reason |
167
+ |---------|-----------------|-------------------|--------|
168
+ | [Name] | X.Y.Z | YYYY-MM-DD | 6-month cycle |
169
+
170
+ ---
171
+
172
+ ## Curator Notes
173
+
174
+ ### [Date: YYYY-MM-DD]
175
+
176
+ **Topic:** [What was validated]
177
+ **Finding:** [Key insight]
178
+ **Action Taken:** [Update to knowledge base or ADR flagged]
179
+
180
+ ---
181
+
182
+ ## Bootstrap Instructions
183
+
184
+ When adopting SHHS for a new project:
185
+
186
+ 1. **Identify Stack:** List all major dependencies
187
+ 2. **Query Context7:** For each dependency, query current version constraints
188
+ 3. **Populate Constraints:** Fill in framework-specific sections above
189
+ 4. **Validate ADRs:** Ensure existing ADRs don't violate discovered constraints
190
+ 5. **Set Revalidation Schedule:** Add all libraries to invalidation schedule
191
+
192
+ ---
193
+
194
+ ## Integration with SHHS Pipeline
195
+
196
+ ```
197
+ Knowledge Curator validates proposal
198
+
199
+ Updates this knowledge base
200
+
201
+ Root Architect references constraints in ADR
202
+
203
+ Developer implements within documented constraints
204
+ ```
205
+
206
+ This knowledge base is the immune system against outdated assumptions.
207
+
208
+ ---
209
+
210
+ **END OF KNOWLEDGE BASE**