oden-forge 2.4.0 โ 3.0.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.
- package/.claude/commands/oden/adr.md +241 -0
- package/.claude/commands/oden/architect.md +332 -8
- package/.claude/commands/oden/context.md +573 -0
- package/.claude/commands/oden/test.md +858 -0
- package/.claude/commands/oden/work.md +131 -0
- package/.claude/epics/living-quality-gates-implementation/work-session.md +54 -0
- package/.claude/memory/compliance-rules.yaml +140 -0
- package/.claude/memory/index.md +96 -0
- package/.claude/memory/knowledge/context-preservation-design.md +249 -0
- package/.claude/memory/knowledge/stream-d-completion-report.md +219 -0
- package/.claude/memory/patterns/README.md +159 -0
- package/.claude/memory/patterns/common-functions.md +121 -0
- package/.claude/memory/patterns/duplicate-report.md +14 -0
- package/.claude/memory/sessions/20260327-snapshot.md +64 -0
- package/.claude/scripts/context-preservation.sh +447 -0
- package/README.md +156 -145
- package/package.json +14 -11
- package/MIGRATION.md +0 -410
- package/install.sh +0 -231
|
@@ -0,0 +1,858 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test
|
|
3
|
+
description: Mandatory testing gates with 80% coverage enforcement
|
|
4
|
+
type: command
|
|
5
|
+
created: 2026-03-27T07:09:22Z
|
|
6
|
+
updated: 2026-03-27T07:09:22Z
|
|
7
|
+
version: 3.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# /oden:test - Living Quality Gates Testing
|
|
11
|
+
|
|
12
|
+
**MANDATORY TESTING ENFORCEMENT** - Transform testing from optional to required.
|
|
13
|
+
|
|
14
|
+
## Quick Reference
|
|
15
|
+
|
|
16
|
+
| Command | Purpose |
|
|
17
|
+
|---------|---------|
|
|
18
|
+
| `/oden:test run [target]` | Execute tests with coverage gates |
|
|
19
|
+
| `/oden:test coverage` | Check coverage against 80% threshold |
|
|
20
|
+
| `/oden:test strategy [module]` | Generate test strategy from specs |
|
|
21
|
+
| `/oden:test generate [module]` | Auto-generate tests from specs |
|
|
22
|
+
| `/oden:test gates` | Review enforcement configuration |
|
|
23
|
+
| `/oden:test enforce` | Setup pre-commit test hooks |
|
|
24
|
+
|
|
25
|
+
## Core Philosophy: Tests-First Enforcement
|
|
26
|
+
|
|
27
|
+
> **"No code ships without tests. No commits pass without 80% coverage."**
|
|
28
|
+
|
|
29
|
+
### Living Quality Gates
|
|
30
|
+
- **Pre-commit hooks** block commits below threshold
|
|
31
|
+
- **Coverage trending** tracks improvement over time
|
|
32
|
+
- **Test quality metrics** beyond just line coverage
|
|
33
|
+
- **Enforcement automation** reduces human oversight burden
|
|
34
|
+
|
|
35
|
+
## Commands
|
|
36
|
+
|
|
37
|
+
### 1. /oden:test run [target]
|
|
38
|
+
|
|
39
|
+
Execute tests with mandatory coverage gates.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
TARGET=${1:-"all"}
|
|
43
|
+
COVERAGE_THRESHOLD=80
|
|
44
|
+
|
|
45
|
+
# Get current datetime
|
|
46
|
+
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
47
|
+
|
|
48
|
+
echo "๐งช MANDATORY TESTING GATES - Oden v3"
|
|
49
|
+
echo "Target: $TARGET | Threshold: ${COVERAGE_THRESHOLD}% | $CURRENT_DATE"
|
|
50
|
+
echo ""
|
|
51
|
+
|
|
52
|
+
# Detect testing framework
|
|
53
|
+
detect_test_framework() {
|
|
54
|
+
if [ -f "package.json" ]; then
|
|
55
|
+
# Node.js projects
|
|
56
|
+
if grep -q "jest" package.json; then
|
|
57
|
+
echo "jest"
|
|
58
|
+
elif grep -q "vitest" package.json; then
|
|
59
|
+
echo "vitest"
|
|
60
|
+
elif grep -q "mocha" package.json; then
|
|
61
|
+
echo "mocha"
|
|
62
|
+
else
|
|
63
|
+
echo "npm"
|
|
64
|
+
fi
|
|
65
|
+
elif [ -f "go.mod" ]; then
|
|
66
|
+
echo "go"
|
|
67
|
+
elif [ -f "Cargo.toml" ]; then
|
|
68
|
+
echo "rust"
|
|
69
|
+
elif [ -f "Gemfile" ]; then
|
|
70
|
+
echo "ruby"
|
|
71
|
+
elif [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
|
|
72
|
+
echo "python"
|
|
73
|
+
elif [ -f "pubspec.yaml" ]; then
|
|
74
|
+
echo "flutter"
|
|
75
|
+
else
|
|
76
|
+
echo "unknown"
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
FRAMEWORK=$(detect_test_framework)
|
|
81
|
+
echo "๐ Detected framework: $FRAMEWORK"
|
|
82
|
+
|
|
83
|
+
# Execute tests with coverage
|
|
84
|
+
run_tests_with_coverage() {
|
|
85
|
+
case $FRAMEWORK in
|
|
86
|
+
"jest")
|
|
87
|
+
echo "๐งช Running Jest with coverage..."
|
|
88
|
+
npm test -- --coverage --coverageReporters=text-summary --coverageReporters=json-summary 2>&1 | tee /tmp/test-output.txt
|
|
89
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
90
|
+
;;
|
|
91
|
+
"vitest")
|
|
92
|
+
echo "๐งช Running Vitest with coverage..."
|
|
93
|
+
npx vitest run --coverage 2>&1 | tee /tmp/test-output.txt
|
|
94
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
95
|
+
;;
|
|
96
|
+
"go")
|
|
97
|
+
echo "๐งช Running Go tests with coverage..."
|
|
98
|
+
go test -v -coverprofile=coverage.out ./... 2>&1 | tee /tmp/test-output.txt
|
|
99
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
100
|
+
if [ $TEST_EXIT -eq 0 ]; then
|
|
101
|
+
go tool cover -func=coverage.out | tail -1
|
|
102
|
+
fi
|
|
103
|
+
;;
|
|
104
|
+
"rust")
|
|
105
|
+
echo "๐งช Running Cargo tests..."
|
|
106
|
+
cargo test 2>&1 | tee /tmp/test-output.txt
|
|
107
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
108
|
+
;;
|
|
109
|
+
"python")
|
|
110
|
+
echo "๐งช Running Python tests with coverage..."
|
|
111
|
+
if command -v pytest >/dev/null; then
|
|
112
|
+
pytest --cov --cov-report=term-missing 2>&1 | tee /tmp/test-output.txt
|
|
113
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
114
|
+
else
|
|
115
|
+
python -m unittest discover 2>&1 | tee /tmp/test-output.txt
|
|
116
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
117
|
+
fi
|
|
118
|
+
;;
|
|
119
|
+
"ruby")
|
|
120
|
+
echo "๐งช Running RSpec tests..."
|
|
121
|
+
bundle exec rspec 2>&1 | tee /tmp/test-output.txt
|
|
122
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
123
|
+
;;
|
|
124
|
+
"flutter")
|
|
125
|
+
echo "๐งช Running Flutter tests..."
|
|
126
|
+
flutter test --coverage 2>&1 | tee /tmp/test-output.txt
|
|
127
|
+
TEST_EXIT=${PIPESTATUS[0]}
|
|
128
|
+
;;
|
|
129
|
+
*)
|
|
130
|
+
echo "โ Unknown testing framework. Framework: $FRAMEWORK"
|
|
131
|
+
echo "Supported: jest, vitest, mocha, go, rust, python, ruby, flutter"
|
|
132
|
+
exit 1
|
|
133
|
+
;;
|
|
134
|
+
esac
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
# Extract coverage percentage
|
|
138
|
+
extract_coverage() {
|
|
139
|
+
if [ -f "coverage/coverage-summary.json" ]; then
|
|
140
|
+
# Jest/Vitest JSON coverage
|
|
141
|
+
node -e "
|
|
142
|
+
try {
|
|
143
|
+
const cov = JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json'));
|
|
144
|
+
const lines = cov.total.lines.pct;
|
|
145
|
+
const funcs = cov.total.functions.pct;
|
|
146
|
+
const branches = cov.total.branches.pct;
|
|
147
|
+
const statements = cov.total.statements.pct;
|
|
148
|
+
console.log(\`Lines: \${lines}% | Functions: \${funcs}% | Branches: \${branches}% | Statements: \${statements}%\`);
|
|
149
|
+
console.log(\`Overall: \${Math.min(lines, funcs, branches, statements)}%\`);
|
|
150
|
+
} catch(e) { console.log('Coverage: N/A'); }
|
|
151
|
+
" > /tmp/coverage-report.txt
|
|
152
|
+
|
|
153
|
+
# Extract minimum coverage
|
|
154
|
+
COVERAGE=$(node -e "
|
|
155
|
+
try {
|
|
156
|
+
const cov = JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json'));
|
|
157
|
+
const min = Math.min(cov.total.lines.pct, cov.total.functions.pct, cov.total.branches.pct, cov.total.statements.pct);
|
|
158
|
+
console.log(Math.floor(min));
|
|
159
|
+
} catch(e) { console.log('0'); }
|
|
160
|
+
")
|
|
161
|
+
elif [ -f "coverage.out" ]; then
|
|
162
|
+
# Go coverage
|
|
163
|
+
COVERAGE=$(go tool cover -func=coverage.out | tail -1 | awk '{print $3}' | sed 's/%//' | cut -d. -f1)
|
|
164
|
+
else
|
|
165
|
+
# Parse from test output
|
|
166
|
+
COVERAGE=$(grep -o "[0-9]\+%" /tmp/test-output.txt | tail -1 | sed 's/%//' || echo "0")
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
if [ -z "$COVERAGE" ] || [ "$COVERAGE" = "" ]; then
|
|
170
|
+
COVERAGE=0
|
|
171
|
+
fi
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
# Run tests
|
|
175
|
+
echo "๐ Executing tests..."
|
|
176
|
+
run_tests_with_coverage
|
|
177
|
+
|
|
178
|
+
# Extract coverage
|
|
179
|
+
extract_coverage
|
|
180
|
+
|
|
181
|
+
echo ""
|
|
182
|
+
echo "๐ COVERAGE ANALYSIS"
|
|
183
|
+
if [ -f "/tmp/coverage-report.txt" ]; then
|
|
184
|
+
cat /tmp/coverage-report.txt
|
|
185
|
+
fi
|
|
186
|
+
echo "Minimum Coverage: ${COVERAGE}%"
|
|
187
|
+
echo "Required Threshold: ${COVERAGE_THRESHOLD}%"
|
|
188
|
+
|
|
189
|
+
# Coverage gate enforcement
|
|
190
|
+
if [ "$COVERAGE" -lt "$COVERAGE_THRESHOLD" ]; then
|
|
191
|
+
echo ""
|
|
192
|
+
echo "โ COVERAGE GATE FAILED"
|
|
193
|
+
echo "Current: ${COVERAGE}% | Required: ${COVERAGE_THRESHOLD}%"
|
|
194
|
+
echo "Gap: $((COVERAGE_THRESHOLD - COVERAGE))% coverage needed"
|
|
195
|
+
echo ""
|
|
196
|
+
echo "๐ง REMEDIATION:"
|
|
197
|
+
echo "1. Run: /oden:test generate [module] - Auto-generate missing tests"
|
|
198
|
+
echo "2. Run: /oden:test strategy [module] - Plan comprehensive testing"
|
|
199
|
+
echo "3. Manual: Write tests for uncovered code paths"
|
|
200
|
+
echo ""
|
|
201
|
+
echo "๐ก Most impactful areas to test:"
|
|
202
|
+
if [ -f "/tmp/test-output.txt" ]; then
|
|
203
|
+
# Extract uncovered lines/functions from output
|
|
204
|
+
grep -E "not covered|uncovered|0%" /tmp/test-output.txt | head -5 || echo " Check coverage report for specific gaps"
|
|
205
|
+
fi
|
|
206
|
+
echo ""
|
|
207
|
+
exit 1
|
|
208
|
+
fi
|
|
209
|
+
|
|
210
|
+
# Test execution gate
|
|
211
|
+
if [ "$TEST_EXIT" -ne 0 ]; then
|
|
212
|
+
echo ""
|
|
213
|
+
echo "โ TEST EXECUTION FAILED"
|
|
214
|
+
echo "Exit code: $TEST_EXIT"
|
|
215
|
+
echo ""
|
|
216
|
+
echo "๐ง REMEDIATION:"
|
|
217
|
+
echo "/oden:debug - Queue-based debug orchestration for test failures"
|
|
218
|
+
echo ""
|
|
219
|
+
exit 1
|
|
220
|
+
fi
|
|
221
|
+
|
|
222
|
+
# Success
|
|
223
|
+
echo ""
|
|
224
|
+
echo "โ
ALL GATES PASSED"
|
|
225
|
+
echo "Coverage: ${COVERAGE}% (โฅ${COVERAGE_THRESHOLD}%)"
|
|
226
|
+
echo "Tests: PASSING"
|
|
227
|
+
echo ""
|
|
228
|
+
echo "๐ฏ Quality metrics tracked for continuous improvement"
|
|
229
|
+
|
|
230
|
+
# Store coverage trend
|
|
231
|
+
mkdir -p .claude/metrics/coverage
|
|
232
|
+
echo "${CURRENT_DATE},${COVERAGE}" >> .claude/metrics/coverage/history.csv
|
|
233
|
+
|
|
234
|
+
echo ""
|
|
235
|
+
echo "๐ COVERAGE TREND"
|
|
236
|
+
if [ -f ".claude/metrics/coverage/history.csv" ]; then
|
|
237
|
+
echo "Recent coverage history:"
|
|
238
|
+
tail -5 .claude/metrics/coverage/history.csv | while IFS=',' read timestamp coverage; do
|
|
239
|
+
echo " $(echo $timestamp | cut -d'T' -f1): ${coverage}%"
|
|
240
|
+
done
|
|
241
|
+
fi
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 2. /oden:test coverage
|
|
245
|
+
|
|
246
|
+
Check current coverage against threshold.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
echo "๐ COVERAGE ANALYSIS - Oden v3"
|
|
250
|
+
echo ""
|
|
251
|
+
|
|
252
|
+
# Quick coverage check without running tests
|
|
253
|
+
check_existing_coverage() {
|
|
254
|
+
if [ -f "coverage/coverage-summary.json" ]; then
|
|
255
|
+
node -e "
|
|
256
|
+
try {
|
|
257
|
+
const cov = JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json'));
|
|
258
|
+
console.log('๐ CURRENT COVERAGE:');
|
|
259
|
+
console.log('Lines: ' + cov.total.lines.pct + '%');
|
|
260
|
+
console.log('Functions: ' + cov.total.functions.pct + '%');
|
|
261
|
+
console.log('Branches: ' + cov.total.branches.pct + '%');
|
|
262
|
+
console.log('Statements: ' + cov.total.statements.pct + '%');
|
|
263
|
+
const min = Math.min(cov.total.lines.pct, cov.total.functions.pct, cov.total.branches.pct, cov.total.statements.pct);
|
|
264
|
+
console.log('\\nOverall (min): ' + Math.floor(min) + '%');
|
|
265
|
+
console.log('Threshold: 80%');
|
|
266
|
+
if (min >= 80) {
|
|
267
|
+
console.log('Status: โ
PASSING');
|
|
268
|
+
} else {
|
|
269
|
+
console.log('Status: โ BELOW THRESHOLD');
|
|
270
|
+
console.log('Gap: ' + (80 - Math.floor(min)) + '% needed');
|
|
271
|
+
}
|
|
272
|
+
} catch(e) {
|
|
273
|
+
console.log('โ No coverage report found');
|
|
274
|
+
console.log('Run: /oden:test run');
|
|
275
|
+
}
|
|
276
|
+
"
|
|
277
|
+
elif [ -f "coverage.out" ]; then
|
|
278
|
+
echo "๐ GO COVERAGE:"
|
|
279
|
+
go tool cover -func=coverage.out | tail -10
|
|
280
|
+
else
|
|
281
|
+
echo "โ No coverage report found"
|
|
282
|
+
echo ""
|
|
283
|
+
echo "๐ง Generate coverage report:"
|
|
284
|
+
echo "/oden:test run"
|
|
285
|
+
fi
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
check_existing_coverage
|
|
289
|
+
|
|
290
|
+
echo ""
|
|
291
|
+
echo "๐ COVERAGE TREND"
|
|
292
|
+
if [ -f ".claude/metrics/coverage/history.csv" ]; then
|
|
293
|
+
echo "Last 10 coverage measurements:"
|
|
294
|
+
tail -10 .claude/metrics/coverage/history.csv | while IFS=',' read timestamp coverage; do
|
|
295
|
+
date_part=$(echo $timestamp | cut -d'T' -f1)
|
|
296
|
+
if [ "$coverage" -ge 80 ]; then
|
|
297
|
+
echo " $date_part: ${coverage}% โ
"
|
|
298
|
+
else
|
|
299
|
+
echo " $date_part: ${coverage}% โ"
|
|
300
|
+
fi
|
|
301
|
+
done
|
|
302
|
+
else
|
|
303
|
+
echo "No coverage history. Run /oden:test run to start tracking."
|
|
304
|
+
fi
|
|
305
|
+
|
|
306
|
+
echo ""
|
|
307
|
+
echo "๐ฏ QUALITY GATES STATUS"
|
|
308
|
+
echo "Coverage Threshold: 80% (enforced)"
|
|
309
|
+
echo "Test Execution: Required to pass"
|
|
310
|
+
echo "Pre-commit Hooks: $([ -f '.git/hooks/pre-commit' ] && echo 'Installed โ
' || echo 'Missing โ ๏ธ')"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 3. /oden:test strategy [module]
|
|
314
|
+
|
|
315
|
+
Generate comprehensive test strategy from specs.
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
MODULE=${1:-""}
|
|
319
|
+
|
|
320
|
+
if [ -z "$MODULE" ]; then
|
|
321
|
+
echo "โ Module required. Usage: /oden:test strategy [module]"
|
|
322
|
+
echo ""
|
|
323
|
+
echo "Available modules:"
|
|
324
|
+
find docs/reference/modules -name "*.md" 2>/dev/null | sed 's|.*/||' | sed 's|\.md||' | head -10 || echo " No modules found in docs/reference/modules/"
|
|
325
|
+
exit 1
|
|
326
|
+
fi
|
|
327
|
+
|
|
328
|
+
echo "๐งช GENERATING TEST STRATEGY: $MODULE"
|
|
329
|
+
echo ""
|
|
330
|
+
|
|
331
|
+
# Check if module spec exists
|
|
332
|
+
SPEC_FILE="docs/reference/modules/${MODULE}.md"
|
|
333
|
+
if [ ! -f "$SPEC_FILE" ]; then
|
|
334
|
+
echo "โ Module spec not found: $SPEC_FILE"
|
|
335
|
+
echo "Available specs:"
|
|
336
|
+
find docs/reference/modules -name "*.md" 2>/dev/null | head -10 || echo " No module specs found"
|
|
337
|
+
exit 1
|
|
338
|
+
fi
|
|
339
|
+
|
|
340
|
+
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
341
|
+
|
|
342
|
+
# Create test strategy document
|
|
343
|
+
mkdir -p .claude/testing/strategies
|
|
344
|
+
STRATEGY_FILE=".claude/testing/strategies/${MODULE}-test-strategy.md"
|
|
345
|
+
|
|
346
|
+
cat > "$STRATEGY_FILE" << EOF
|
|
347
|
+
---
|
|
348
|
+
module: $MODULE
|
|
349
|
+
type: test-strategy
|
|
350
|
+
created: $CURRENT_DATE
|
|
351
|
+
updated: $CURRENT_DATE
|
|
352
|
+
coverage_target: 80%
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
# Test Strategy: $MODULE
|
|
356
|
+
|
|
357
|
+
Generated from module specification: $SPEC_FILE
|
|
358
|
+
|
|
359
|
+
## ๐ฏ Testing Objectives
|
|
360
|
+
|
|
361
|
+
### Coverage Requirements
|
|
362
|
+
- **Minimum**: 80% coverage across all metrics
|
|
363
|
+
- **Lines**: 80%+
|
|
364
|
+
- **Functions**: 80%+
|
|
365
|
+
- **Branches**: 80%+
|
|
366
|
+
- **Statements**: 80%+
|
|
367
|
+
|
|
368
|
+
### Quality Goals
|
|
369
|
+
- All public APIs tested
|
|
370
|
+
- All error conditions covered
|
|
371
|
+
- All business logic validated
|
|
372
|
+
- Integration points verified
|
|
373
|
+
|
|
374
|
+
## ๐ Test Categories
|
|
375
|
+
|
|
376
|
+
### 1. Unit Tests
|
|
377
|
+
**Scope**: Individual functions/methods in isolation
|
|
378
|
+
|
|
379
|
+
\`\`\`
|
|
380
|
+
Files to test:
|
|
381
|
+
EOF
|
|
382
|
+
|
|
383
|
+
# Extract code files from spec
|
|
384
|
+
grep -E "^\s*-\s*\`" "$SPEC_FILE" | head -20 >> "$STRATEGY_FILE" || echo " [Extract from module implementation]" >> "$STRATEGY_FILE"
|
|
385
|
+
|
|
386
|
+
cat >> "$STRATEGY_FILE" << EOF
|
|
387
|
+
|
|
388
|
+
Coverage target: 90% (unit tests should have highest coverage)
|
|
389
|
+
\`\`\`
|
|
390
|
+
|
|
391
|
+
### 2. Integration Tests
|
|
392
|
+
**Scope**: Module interactions and data flow
|
|
393
|
+
|
|
394
|
+
\`\`\`
|
|
395
|
+
Integration points:
|
|
396
|
+
EOF
|
|
397
|
+
|
|
398
|
+
# Extract integration points from spec
|
|
399
|
+
grep -iE "integrat|depend|connect|call" "$SPEC_FILE" | head -10 >> "$STRATEGY_FILE" || echo " [Extract from module dependencies]" >> "$STRATEGY_FILE"
|
|
400
|
+
|
|
401
|
+
cat >> "$STRATEGY_FILE" << EOF
|
|
402
|
+
|
|
403
|
+
Coverage target: 70%
|
|
404
|
+
\`\`\`
|
|
405
|
+
|
|
406
|
+
### 3. End-to-End Tests
|
|
407
|
+
**Scope**: Complete user workflows through this module
|
|
408
|
+
|
|
409
|
+
\`\`\`
|
|
410
|
+
User scenarios:
|
|
411
|
+
EOF
|
|
412
|
+
|
|
413
|
+
# Extract user stories from spec
|
|
414
|
+
grep -iE "user|story|scenario|workflow" "$SPEC_FILE" | head -10 >> "$STRATEGY_FILE" || echo " [Extract from module user stories]" >> "$STRATEGY_FILE"
|
|
415
|
+
|
|
416
|
+
cat >> "$STRATEGY_FILE" << EOF
|
|
417
|
+
|
|
418
|
+
Coverage target: 60%
|
|
419
|
+
\`\`\`
|
|
420
|
+
|
|
421
|
+
## ๐ง Test Generation Plan
|
|
422
|
+
|
|
423
|
+
### Phase 1: Core Functionality
|
|
424
|
+
1. Generate unit tests for all exported functions
|
|
425
|
+
2. Test all public API endpoints
|
|
426
|
+
3. Validate all data transformations
|
|
427
|
+
|
|
428
|
+
### Phase 2: Edge Cases
|
|
429
|
+
1. Error conditions and exceptions
|
|
430
|
+
2. Boundary value testing
|
|
431
|
+
3. Input validation edge cases
|
|
432
|
+
|
|
433
|
+
### Phase 3: Integration
|
|
434
|
+
1. Database interactions (if applicable)
|
|
435
|
+
2. External service calls (if applicable)
|
|
436
|
+
3. Module-to-module communication
|
|
437
|
+
|
|
438
|
+
### Phase 4: Performance
|
|
439
|
+
1. Load testing for critical paths
|
|
440
|
+
2. Memory usage validation
|
|
441
|
+
3. Response time benchmarks
|
|
442
|
+
|
|
443
|
+
## ๐ Success Metrics
|
|
444
|
+
|
|
445
|
+
### Must-Have (Blocking)
|
|
446
|
+
- [ ] 80%+ coverage across all metrics
|
|
447
|
+
- [ ] All tests passing
|
|
448
|
+
- [ ] No critical paths uncovered
|
|
449
|
+
|
|
450
|
+
### Should-Have (Quality)
|
|
451
|
+
- [ ] 90%+ unit test coverage
|
|
452
|
+
- [ ] All error conditions tested
|
|
453
|
+
- [ ] Performance benchmarks established
|
|
454
|
+
|
|
455
|
+
### Could-Have (Excellence)
|
|
456
|
+
- [ ] Mutation testing coverage > 80%
|
|
457
|
+
- [ ] Property-based test coverage
|
|
458
|
+
- [ ] Chaos engineering validation
|
|
459
|
+
|
|
460
|
+
## ๐ Implementation Commands
|
|
461
|
+
|
|
462
|
+
\`\`\`bash
|
|
463
|
+
# Generate tests from this strategy
|
|
464
|
+
/oden:test generate $MODULE
|
|
465
|
+
|
|
466
|
+
# Execute full test suite
|
|
467
|
+
/oden:test run $MODULE
|
|
468
|
+
|
|
469
|
+
# Check coverage compliance
|
|
470
|
+
/oden:test coverage
|
|
471
|
+
\`\`\`
|
|
472
|
+
|
|
473
|
+
## ๐ Notes
|
|
474
|
+
|
|
475
|
+
- Strategy generated from: $SPEC_FILE
|
|
476
|
+
- Review and customize based on module specifics
|
|
477
|
+
- Update as module implementation evolves
|
|
478
|
+
- Integrate with Definition of Done requirements
|
|
479
|
+
EOF
|
|
480
|
+
|
|
481
|
+
echo "โ
Test strategy created: $STRATEGY_FILE"
|
|
482
|
+
echo ""
|
|
483
|
+
echo "๐ STRATEGY SUMMARY"
|
|
484
|
+
grep -E "^###|Coverage target:" "$STRATEGY_FILE"
|
|
485
|
+
echo ""
|
|
486
|
+
echo "๐ Next steps:"
|
|
487
|
+
echo "1. Review strategy: cat $STRATEGY_FILE"
|
|
488
|
+
echo "2. Generate tests: /oden:test generate $MODULE"
|
|
489
|
+
echo "3. Execute tests: /oden:test run $MODULE"
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### 4. /oden:test generate [module]
|
|
493
|
+
|
|
494
|
+
Auto-generate tests from specifications.
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
MODULE=${1:-""}
|
|
498
|
+
|
|
499
|
+
if [ -z "$MODULE" ]; then
|
|
500
|
+
echo "โ Module required. Usage: /oden:test generate [module]"
|
|
501
|
+
exit 1
|
|
502
|
+
fi
|
|
503
|
+
|
|
504
|
+
echo "๐ค AUTO-GENERATING TESTS: $MODULE"
|
|
505
|
+
echo ""
|
|
506
|
+
|
|
507
|
+
SPEC_FILE="docs/reference/modules/${MODULE}.md"
|
|
508
|
+
STRATEGY_FILE=".claude/testing/strategies/${MODULE}-test-strategy.md"
|
|
509
|
+
|
|
510
|
+
# Verify inputs exist
|
|
511
|
+
if [ ! -f "$SPEC_FILE" ]; then
|
|
512
|
+
echo "โ Module spec not found: $SPEC_FILE"
|
|
513
|
+
echo "Run: /oden:spec $MODULE"
|
|
514
|
+
exit 1
|
|
515
|
+
fi
|
|
516
|
+
|
|
517
|
+
if [ ! -f "$STRATEGY_FILE" ]; then
|
|
518
|
+
echo "โ ๏ธ No test strategy found. Generating..."
|
|
519
|
+
/oden:test strategy "$MODULE"
|
|
520
|
+
fi
|
|
521
|
+
|
|
522
|
+
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
523
|
+
|
|
524
|
+
# Use Task agent for intelligent test generation
|
|
525
|
+
use_task_agent() {
|
|
526
|
+
cat > /tmp/test-generation.md << EOF
|
|
527
|
+
# Test Generation Task: $MODULE
|
|
528
|
+
|
|
529
|
+
## Context
|
|
530
|
+
Module: $MODULE
|
|
531
|
+
Spec: $SPEC_FILE
|
|
532
|
+
Strategy: $STRATEGY_FILE
|
|
533
|
+
Target Coverage: 80%+
|
|
534
|
+
|
|
535
|
+
## Requirements
|
|
536
|
+
1. Generate comprehensive test suite for $MODULE
|
|
537
|
+
2. Include unit, integration, and E2E tests
|
|
538
|
+
3. Cover all code paths and edge cases
|
|
539
|
+
4. Follow TDD best practices
|
|
540
|
+
5. Use appropriate testing framework for project
|
|
541
|
+
|
|
542
|
+
## Inputs
|
|
543
|
+
- Module specification with business logic
|
|
544
|
+
- Test strategy with coverage requirements
|
|
545
|
+
- Existing codebase for framework detection
|
|
546
|
+
- Quality gates enforcement (80% minimum)
|
|
547
|
+
|
|
548
|
+
## Outputs
|
|
549
|
+
- Complete test files ready for execution
|
|
550
|
+
- Test utilities and helpers if needed
|
|
551
|
+
- Mock/fixture data for realistic testing
|
|
552
|
+
- Documentation of test coverage plan
|
|
553
|
+
|
|
554
|
+
## Success Criteria
|
|
555
|
+
- All generated tests execute successfully
|
|
556
|
+
- Coverage meets or exceeds 80% threshold
|
|
557
|
+
- Tests follow project conventions
|
|
558
|
+
- Edge cases and error conditions covered
|
|
559
|
+
EOF
|
|
560
|
+
|
|
561
|
+
# Delegate to specialized test generation agent
|
|
562
|
+
echo "๐ค Delegating to test-engineer agent for intelligent generation..."
|
|
563
|
+
|
|
564
|
+
# Task agent would analyze specs and generate appropriate tests
|
|
565
|
+
# This is a placeholder for the actual agent call
|
|
566
|
+
echo "Task: Generate comprehensive test suite for $MODULE module"
|
|
567
|
+
echo "Requirements:"
|
|
568
|
+
echo "- Read module spec: $SPEC_FILE"
|
|
569
|
+
echo "- Follow test strategy: $STRATEGY_FILE"
|
|
570
|
+
echo "- Target 80%+ coverage"
|
|
571
|
+
echo "- Generate unit + integration + E2E tests"
|
|
572
|
+
echo "- Use project's testing framework"
|
|
573
|
+
echo ""
|
|
574
|
+
|
|
575
|
+
echo "โ ๏ธ Manual test generation required:"
|
|
576
|
+
echo "1. Review module spec: $SPEC_FILE"
|
|
577
|
+
echo "2. Follow test strategy: $STRATEGY_FILE"
|
|
578
|
+
echo "3. Create test files in appropriate directory"
|
|
579
|
+
echo "4. Verify with: /oden:test run $MODULE"
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
use_task_agent
|
|
583
|
+
|
|
584
|
+
echo ""
|
|
585
|
+
echo "โ
Test generation initiated for $MODULE"
|
|
586
|
+
echo "๐ Next steps:"
|
|
587
|
+
echo "1. Review generated tests"
|
|
588
|
+
echo "2. Run: /oden:test run $MODULE"
|
|
589
|
+
echo "3. Check coverage: /oden:test coverage"
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### 5. /oden:test gates
|
|
593
|
+
|
|
594
|
+
Review enforcement configuration.
|
|
595
|
+
|
|
596
|
+
```bash
|
|
597
|
+
echo "๐ก๏ธ TESTING ENFORCEMENT GATES - Oden v3"
|
|
598
|
+
echo ""
|
|
599
|
+
|
|
600
|
+
echo "๐ CURRENT CONFIGURATION"
|
|
601
|
+
echo "Coverage Threshold: 80% (mandatory)"
|
|
602
|
+
echo "Test Execution: Required for all commits"
|
|
603
|
+
echo "Framework Auto-Detection: Enabled"
|
|
604
|
+
echo ""
|
|
605
|
+
|
|
606
|
+
echo "๐ง GATE STATUS"
|
|
607
|
+
|
|
608
|
+
# Check pre-commit hooks
|
|
609
|
+
if [ -f ".git/hooks/pre-commit" ]; then
|
|
610
|
+
if grep -q "oden:test" ".git/hooks/pre-commit" 2>/dev/null; then
|
|
611
|
+
echo "Pre-commit Testing: โ
ENABLED"
|
|
612
|
+
else
|
|
613
|
+
echo "Pre-commit Testing: โ ๏ธ PARTIAL (custom hooks found)"
|
|
614
|
+
fi
|
|
615
|
+
else
|
|
616
|
+
echo "Pre-commit Testing: โ MISSING"
|
|
617
|
+
fi
|
|
618
|
+
|
|
619
|
+
# Check coverage tracking
|
|
620
|
+
if [ -f ".claude/metrics/coverage/history.csv" ]; then
|
|
621
|
+
RECORDS=$(wc -l < .claude/metrics/coverage/history.csv)
|
|
622
|
+
echo "Coverage Tracking: โ
ACTIVE ($RECORDS records)"
|
|
623
|
+
else
|
|
624
|
+
echo "Coverage Tracking: โ ๏ธ NOT STARTED"
|
|
625
|
+
fi
|
|
626
|
+
|
|
627
|
+
# Check test strategies
|
|
628
|
+
STRATEGIES=$(find .claude/testing/strategies -name "*.md" 2>/dev/null | wc -l)
|
|
629
|
+
if [ "$STRATEGIES" -gt 0 ]; then
|
|
630
|
+
echo "Test Strategies: โ
$STRATEGIES modules planned"
|
|
631
|
+
else
|
|
632
|
+
echo "Test Strategies: โ ๏ธ NONE CREATED"
|
|
633
|
+
fi
|
|
634
|
+
|
|
635
|
+
echo ""
|
|
636
|
+
echo "๐ฏ ENFORCEMENT RULES"
|
|
637
|
+
echo ""
|
|
638
|
+
echo "MANDATORY (Blocking):"
|
|
639
|
+
echo "- โ
80% minimum coverage across all metrics"
|
|
640
|
+
echo "- โ
All tests must pass before commit"
|
|
641
|
+
echo "- โ
Framework auto-detection for consistency"
|
|
642
|
+
echo "- โ
Coverage trend tracking for improvement"
|
|
643
|
+
echo ""
|
|
644
|
+
echo "RECOMMENDED (Quality):"
|
|
645
|
+
echo "- ๐ Test strategies for complex modules"
|
|
646
|
+
echo "- ๐ Pre-commit hooks for automated enforcement"
|
|
647
|
+
echo "- ๐ Regular coverage review and improvement"
|
|
648
|
+
echo ""
|
|
649
|
+
|
|
650
|
+
echo "๐ SETUP ENFORCEMENT"
|
|
651
|
+
echo "Run: /oden:test enforce - Install all enforcement mechanisms"
|
|
652
|
+
echo ""
|
|
653
|
+
|
|
654
|
+
echo "๐ FRAMEWORK SUPPORT"
|
|
655
|
+
echo "Detected frameworks with coverage support:"
|
|
656
|
+
echo "- Node.js: Jest, Vitest, Mocha"
|
|
657
|
+
echo "- Go: Built-in test + coverage"
|
|
658
|
+
echo "- Rust: Cargo test"
|
|
659
|
+
echo "- Python: pytest, unittest"
|
|
660
|
+
echo "- Ruby: RSpec"
|
|
661
|
+
echo "- Flutter: flutter test --coverage"
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### 6. /oden:test enforce
|
|
665
|
+
|
|
666
|
+
Setup mandatory testing enforcement.
|
|
667
|
+
|
|
668
|
+
```bash
|
|
669
|
+
echo "๐ก๏ธ SETTING UP MANDATORY TEST ENFORCEMENT"
|
|
670
|
+
echo ""
|
|
671
|
+
|
|
672
|
+
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
673
|
+
|
|
674
|
+
# Create enforcement infrastructure
|
|
675
|
+
setup_enforcement() {
|
|
676
|
+
# 1. Create metrics directory
|
|
677
|
+
echo "๐ Setting up coverage tracking..."
|
|
678
|
+
mkdir -p .claude/metrics/coverage
|
|
679
|
+
|
|
680
|
+
# 2. Create pre-commit hook
|
|
681
|
+
echo "๐ง Installing pre-commit test hook..."
|
|
682
|
+
mkdir -p .git/hooks
|
|
683
|
+
|
|
684
|
+
cat > .git/hooks/pre-commit << 'EOF'
|
|
685
|
+
#!/bin/bash
|
|
686
|
+
# Oden v3 Mandatory Testing Gate
|
|
687
|
+
# Auto-generated by /oden:test enforce
|
|
688
|
+
|
|
689
|
+
echo "๐งช MANDATORY TESTING GATE"
|
|
690
|
+
echo "Running tests before commit..."
|
|
691
|
+
|
|
692
|
+
# Run tests with coverage enforcement
|
|
693
|
+
if ! ./.claude/commands/oden/test.md run >/dev/null 2>&1; then
|
|
694
|
+
echo ""
|
|
695
|
+
echo "โ COMMIT BLOCKED: Tests failed or coverage below 80%"
|
|
696
|
+
echo ""
|
|
697
|
+
echo "๐ง Fix tests:"
|
|
698
|
+
echo "/oden:test run - Check test failures"
|
|
699
|
+
echo "/oden:test coverage - Review coverage gaps"
|
|
700
|
+
echo "/oden:debug - Queue-based debugging"
|
|
701
|
+
echo ""
|
|
702
|
+
exit 1
|
|
703
|
+
fi
|
|
704
|
+
|
|
705
|
+
echo "โ
Tests passed - commit proceeding"
|
|
706
|
+
EOF
|
|
707
|
+
|
|
708
|
+
chmod +x .git/hooks/pre-commit
|
|
709
|
+
|
|
710
|
+
# 3. Create enforcement config
|
|
711
|
+
cat > .claude/testing/enforcement.json << EOF
|
|
712
|
+
{
|
|
713
|
+
"version": "3.0.0",
|
|
714
|
+
"enabled": true,
|
|
715
|
+
"created": "$CURRENT_DATE",
|
|
716
|
+
"updated": "$CURRENT_DATE",
|
|
717
|
+
"rules": {
|
|
718
|
+
"coverage_threshold": 80,
|
|
719
|
+
"require_tests": true,
|
|
720
|
+
"block_commits": true,
|
|
721
|
+
"track_trends": true
|
|
722
|
+
},
|
|
723
|
+
"frameworks": [
|
|
724
|
+
"jest", "vitest", "mocha", "go", "rust", "python", "ruby", "flutter"
|
|
725
|
+
],
|
|
726
|
+
"gates": {
|
|
727
|
+
"pre_commit": true,
|
|
728
|
+
"coverage_tracking": true,
|
|
729
|
+
"test_execution": true
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
EOF
|
|
733
|
+
|
|
734
|
+
# 4. Create initial coverage baseline
|
|
735
|
+
echo "๐ Establishing coverage baseline..."
|
|
736
|
+
if command -v node >/dev/null && [ -f "package.json" ]; then
|
|
737
|
+
# Try to get initial coverage
|
|
738
|
+
if npm test -- --coverage --silent >/dev/null 2>&1; then
|
|
739
|
+
echo "โ
Initial coverage baseline established"
|
|
740
|
+
else
|
|
741
|
+
echo "โ ๏ธ Baseline will be set on first successful test run"
|
|
742
|
+
fi
|
|
743
|
+
fi
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
setup_enforcement
|
|
747
|
+
|
|
748
|
+
echo ""
|
|
749
|
+
echo "โ
ENFORCEMENT SETUP COMPLETE"
|
|
750
|
+
echo ""
|
|
751
|
+
echo "๐ INSTALLED:"
|
|
752
|
+
echo "- โ
Pre-commit test hook (.git/hooks/pre-commit)"
|
|
753
|
+
echo "- โ
Coverage tracking (.claude/metrics/coverage/)"
|
|
754
|
+
echo "- โ
Enforcement config (.claude/testing/enforcement.json)"
|
|
755
|
+
echo ""
|
|
756
|
+
echo "๐ก๏ธ ACTIVE GATES:"
|
|
757
|
+
echo "- Coverage threshold: 80% (mandatory)"
|
|
758
|
+
echo "- Test execution: Required before commit"
|
|
759
|
+
echo "- Framework detection: Automatic"
|
|
760
|
+
echo "- Trend tracking: Enabled"
|
|
761
|
+
echo ""
|
|
762
|
+
echo "๐ VERIFICATION:"
|
|
763
|
+
echo "Try committing changes - tests will run automatically"
|
|
764
|
+
echo "Or test manually: /oden:test run"
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
## Integration with Definition of Done
|
|
768
|
+
|
|
769
|
+
This testing system enforces the Definition of Done through:
|
|
770
|
+
|
|
771
|
+
### 1. **Mandatory Gates**
|
|
772
|
+
- **Pre-commit hooks** prevent commits without tests
|
|
773
|
+
- **80% coverage threshold** blocks insufficient testing
|
|
774
|
+
- **Automatic framework detection** ensures consistency
|
|
775
|
+
|
|
776
|
+
### 2. **Quality Metrics**
|
|
777
|
+
- **Coverage trending** tracks improvement over time
|
|
778
|
+
- **Test quality analysis** beyond simple line coverage
|
|
779
|
+
- **Framework-agnostic** support for all major tech stacks
|
|
780
|
+
|
|
781
|
+
### 3. **Integration Points**
|
|
782
|
+
- **`/oden:work` pipeline** includes automated test execution
|
|
783
|
+
- **`/oden:debug` orchestration** handles test failures
|
|
784
|
+
- **Epic completion** requires all tests passing
|
|
785
|
+
|
|
786
|
+
## Real Project Context (64 Findings)
|
|
787
|
+
|
|
788
|
+
This system addresses critical gaps identified:
|
|
789
|
+
|
|
790
|
+
### Before (Critical Problems)
|
|
791
|
+
- **0.1% test coverage** across entire codebase
|
|
792
|
+
- **9,500 LOC dead code** accumulation (no refactoring safety)
|
|
793
|
+
- **No testing enforcement** in development workflow
|
|
794
|
+
- **Manual testing only** - inconsistent and error-prone
|
|
795
|
+
|
|
796
|
+
### After (Enforced Solution)
|
|
797
|
+
- **80% minimum coverage** automatically enforced
|
|
798
|
+
- **Pre-commit test gates** prevent regression introduction
|
|
799
|
+
- **Framework detection** eliminates setup friction
|
|
800
|
+
- **Coverage trending** drives continuous improvement
|
|
801
|
+
|
|
802
|
+
## Error Handling
|
|
803
|
+
|
|
804
|
+
### Coverage Below Threshold
|
|
805
|
+
```bash
|
|
806
|
+
โ COVERAGE GATE FAILED
|
|
807
|
+
Current: 67% | Required: 80%
|
|
808
|
+
Gap: 13% coverage needed
|
|
809
|
+
|
|
810
|
+
๐ง REMEDIATION:
|
|
811
|
+
1. /oden:test generate [module] - Auto-generate missing tests
|
|
812
|
+
2. /oden:test strategy [module] - Plan comprehensive testing
|
|
813
|
+
3. Manual: Write tests for uncovered code paths
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
### Test Execution Failures
|
|
817
|
+
```bash
|
|
818
|
+
โ TEST EXECUTION FAILED
|
|
819
|
+
Exit code: 1
|
|
820
|
+
|
|
821
|
+
๐ง REMEDIATION:
|
|
822
|
+
/oden:debug - Queue-based debug orchestration for test failures
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
### Framework Not Supported
|
|
826
|
+
```bash
|
|
827
|
+
โ Unknown testing framework. Framework: unknown
|
|
828
|
+
Supported: jest, vitest, mocha, go, rust, python, ruby, flutter
|
|
829
|
+
|
|
830
|
+
๐ง REMEDIATION:
|
|
831
|
+
Add framework detection or configure manually
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
## Success Metrics
|
|
835
|
+
|
|
836
|
+
### Immediate (Blocking)
|
|
837
|
+
- **80%+ coverage** across all metrics (lines, functions, branches, statements)
|
|
838
|
+
- **All tests passing** before any commit
|
|
839
|
+
- **Framework auto-detection** working correctly
|
|
840
|
+
- **Pre-commit enforcement** preventing bad commits
|
|
841
|
+
|
|
842
|
+
### Trending (Quality)
|
|
843
|
+
- **Coverage improvement** over time (tracked in `.claude/metrics/coverage/history.csv`)
|
|
844
|
+
- **Test execution speed** optimization
|
|
845
|
+
- **Test quality metrics** beyond coverage (mutation testing, property-based)
|
|
846
|
+
- **Developer adoption** of test-first approach
|
|
847
|
+
|
|
848
|
+
### Integration (System)
|
|
849
|
+
- **`/oden:work` pipeline** includes testing automatically
|
|
850
|
+
- **Definition of Done** enforces testing requirements
|
|
851
|
+
- **Epic completion** blocked by insufficient testing
|
|
852
|
+
- **Code refactoring** enabled by comprehensive test harness
|
|
853
|
+
|
|
854
|
+
---
|
|
855
|
+
|
|
856
|
+
**Version**: 3.0.0 | **Created**: 2026-03-27T07:09:22Z | **Updated**: 2026-03-27T07:09:22Z
|
|
857
|
+
|
|
858
|
+
**Living Quality Gates**: Transform testing from optional to mandatory with automated enforcement and continuous improvement tracking.
|