jettypod 4.1.2 → 4.1.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.
- package/.nvmrc +1 -0
- package/docs/COMPLETE-TESTING-STRATEGY.md +970 -0
- package/docs/DECISIONS.md +10 -12
- package/docs/NODE_VERSION.md +83 -0
- package/docs/TDD-INFRASTRUCTURE-STRATEGY.md +1374 -0
- package/docs/TESTING-FOR-NON-ENGINEERS.md +1588 -0
- package/docs/TESTING-STRATEGY-AUDIT.md +698 -0
- package/hooks/post-checkout +17 -0
- package/hooks/post-merge +17 -0
- package/hooks/pre-commit +30 -0
- package/jettypod.js +259 -120
- package/lib/coverage-tracker.js +218 -0
- package/lib/database.js +2 -0
- package/lib/db-export.js +192 -0
- package/lib/db-import.js +193 -0
- package/lib/external-transition-handler.js +32 -0
- package/lib/git-hook-helpers.js +174 -0
- package/lib/git-root.js +90 -0
- package/lib/infrastructure-chore-generator.js +45 -0
- package/lib/install-hooks.js +52 -0
- package/lib/jettypod-backup.js +238 -0
- package/lib/merge-lock.js +193 -0
- package/lib/migrations/012-add-worktree-path.js +38 -0
- package/lib/migrations/013-worktrees-table.js +86 -0
- package/lib/migrations/014-migrate-worktree-data.js +161 -0
- package/lib/migrations/015-merge-locks-table.js +67 -0
- package/lib/pattern-finder.js +152 -0
- package/lib/process-manager.js +140 -0
- package/lib/production-standards-reader.js +13 -2
- package/lib/production-standards-writer.js +85 -0
- package/lib/skills/feature-planning/dry-run-validator.js +135 -0
- package/lib/skills/feature-planning/validation-formatter.js +160 -0
- package/lib/smart-conflict-detection.js +168 -0
- package/lib/smart-fetch-rebase.js +614 -0
- package/lib/step-definition-parser.js +76 -0
- package/lib/unit-test-generator.js +232 -0
- package/lib/verification-command-generator.js +66 -0
- package/lib/worktree-diagnostics.js +413 -0
- package/lib/worktree-facade.js +174 -0
- package/lib/worktree-manager.js +636 -0
- package/lib/worktree-reconciler.js +429 -0
- package/package.json +30 -3
- package/skills-templates/external-transition/SKILL.md +34 -3
- package/skills-templates/feature-planning/SKILL.md +190 -24
- package/skills-templates/production-mode/SKILL.md +127 -9
- package/skills-templates/speed-mode/SKILL.md +454 -51
- package/skills-templates/stable-mode/SKILL.md +285 -76
- package/.claude/PROTECT_SKILLS.md +0 -28
- package/.claude/settings.json +0 -24
- package/.claude/settings.local.json +0 -16
- package/.claude/skills/epic-planning/SKILL.md +0 -297
- package/.claude/skills/external-transition/SKILL.md +0 -384
- package/.claude/skills/feature-planning/SKILL.md +0 -464
- package/.claude/skills/production-mode/SKILL.md +0 -369
- package/.claude/skills/speed-mode/SKILL.md +0 -481
- package/.claude/skills/stable-mode/SKILL.md +0 -713
- package/.claude/skills.backup-2025-11-10T23-33-09-368Z/epic-planning/SKILL.md +0 -297
- package/.claude/skills.backup-2025-11-10T23-33-09-368Z/feature-planning/SKILL.md +0 -464
- package/.claude/skills.backup-2025-11-10T23-33-09-368Z/speed-mode/SKILL.md +0 -467
- package/.claude/skills.backup-2025-11-10T23-33-09-368Z/stable-mode/SKILL.md +0 -673
- package/.claude/skills.backup-2025-11-11T16-15-10-070Z/epic-discover/SKILL.md +0 -297
- package/.claude/skills.backup-2025-11-11T16-42-43-212Z/epic-planning/SKILL.md +0 -297
- package/.claude/skills.backup-2025-11-11T16-42-43-212Z/feature-planning/SKILL.md +0 -464
- package/.claude/skills.backup-2025-11-11T16-42-43-212Z/speed-mode/SKILL.md +0 -467
- package/.claude/skills.backup-2025-11-11T16-42-43-212Z/stable-mode/SKILL.md +0 -673
- package/.claude/skills.backup-2025-11-11T17-06-09-783Z/epic-planning/SKILL.md +0 -297
- package/.claude/skills.backup-2025-11-11T17-06-09-783Z/feature-planning/SKILL.md +0 -464
- package/.claude/skills.backup-2025-11-11T17-06-09-783Z/speed-mode/SKILL.md +0 -467
- package/.claude/skills.backup-2025-11-11T17-06-09-783Z/stable-mode/SKILL.md +0 -673
- package/.devpod/current-work.json +0 -10
- package/.devpod/work.db +0 -0
- package/.github/workflows/test-safety.yml +0 -85
- package/.jettypod/config.json +0 -5
- package/.jettypod/current-work.json +0 -10
- package/.jettypod/hooks/README.md +0 -77
- package/.jettypod/hooks/protect-claude-md.js +0 -338
- package/.jettypod/test-work.db +0 -0
- package/.jettypod/work.db +0 -0
- package/CLAUDE.md +0 -49
- package/SPEED-STABLE-AUDIT.md +0 -853
- package/SYSTEM-BEHAVIOR.md +0 -2199
- package/TEST_SAFETY_AUDIT.md +0 -314
- package/TEST_SAFETY_IMPLEMENTATION.md +0 -97
- package/cucumber-report.html +0 -45
- package/dist/devpod-linux +0 -0
- package/dist/devpod-macos +0 -0
- package/dist/devpod-win.exe +0 -0
- package/docs/features/jettypod-standards-explained.md +0 -543
- package/docs/features/standards-inventory.md +0 -257
- package/features/auto-generate-production-chores.feature +0 -13
- package/features/backlog-command.feature +0 -26
- package/features/backlog-filtering-production.feature +0 -10
- package/features/claude-md-protection/steps.js +0 -498
- package/features/decisions/index.js +0 -490
- package/features/decisions/index.test.js +0 -208
- package/features/fix-text-wrapping.feature +0 -42
- package/features/git-hooks/git-hooks.feature +0 -30
- package/features/git-hooks/index.js +0 -93
- package/features/git-hooks/index.test.js +0 -137
- package/features/git-hooks/post-commit +0 -56
- package/features/git-hooks/post-merge +0 -47
- package/features/git-hooks/pre-commit +0 -28
- package/features/git-hooks/simple-steps.js +0 -53
- package/features/git-hooks/simple-test.feature +0 -10
- package/features/git-hooks/steps.js +0 -196
- package/features/jettypod-update-command.feature +0 -46
- package/features/mode-prompts/index.js +0 -95
- package/features/mode-prompts/simple-steps.js +0 -44
- package/features/mode-prompts/simple-test.feature +0 -9
- package/features/mode-prompts/validation.test.js +0 -120
- package/features/multiple-claude-instances.feature +0 -121
- package/features/production-mode-skill.feature +0 -121
- package/features/refactor-mode/steps.js +0 -217
- package/features/refactor-mode.feature +0 -49
- package/features/simplify-external-transition.feature +0 -166
- package/features/skills-update/index.test.js +0 -216
- package/features/step_definitions/backlog-command.steps.js +0 -37
- package/features/step_definitions/fix-text-wrapping.steps.js +0 -271
- package/features/step_definitions/multiple-claude-instances.steps.js +0 -621
- package/features/step_definitions/production-mode-skill.steps.js +0 -862
- package/features/step_definitions/simplify-external-transition.steps.js +0 -370
- package/features/step_definitions/terminal-logo.steps.js +0 -145
- package/features/step_definitions/update-command.steps.js +0 -183
- package/features/support/hooks.js +0 -9
- package/features/terminal-logo/index.js +0 -39
- package/features/terminal-logo/terminal-logo.feature +0 -30
- package/features/update-command/index.js +0 -181
- package/features/update-command/index.test.js +0 -225
- package/features/work-commands/bug-workflow-display.feature +0 -22
- package/features/work-commands/index.js +0 -498
- package/features/work-commands/simple-steps.js +0 -69
- package/features/work-commands/stable-tests.feature +0 -57
- package/features/work-commands/steps.js +0 -1174
- package/features/work-commands/validation.test.js +0 -88
- package/features/work-commands/work-commands.feature +0 -13
- package/features/work-tracking/discovery-validation.test.js +0 -228
- package/features/work-tracking/index.js +0 -1921
- package/features/work-tracking/mode-required.feature +0 -112
- package/features/work-tracking/phase-tracking.test.js +0 -482
- package/features/work-tracking/prototype-tracking.test.js +0 -485
- package/features/work-tracking/tree-view.test.js +0 -310
- package/features/work-tracking/work-set-mode.feature +0 -71
- package/features/work-tracking/work-start-mode.feature +0 -88
- package/full-test.txt +0 -0
- package/lib/bug-workflow.test.js +0 -177
- package/lib/claudemd.test.js +0 -195
- package/lib/config.test.js +0 -511
- package/lib/constants.test.js +0 -164
- package/lib/current-work.test.js +0 -146
- package/lib/database-project-config.test.js +0 -111
- package/lib/database.test.js +0 -106
- package/lib/decisions-generator.test.js +0 -457
- package/lib/decisions-helpers.test.js +0 -310
- package/lib/git-coordinator.js +0 -167
- package/lib/git.test.js +0 -145
- package/lib/migrations/002-default-work-item-modes.test.js +0 -351
- package/lib/production-chore-generator.test.js +0 -432
- package/lib/production-context-detector.test.js +0 -277
- package/lib/production-scenario-appender.test.js +0 -235
- package/lib/production-scenario-validator.test.js +0 -246
- package/lib/production-standards-reader.test.js +0 -270
- package/lib/project-state.test.js +0 -92
- package/lib/push-queue.js +0 -417
- package/lib/queue-processor.js +0 -74
- package/lib/test-helpers.js +0 -202
- package/lib/test-helpers.test.js +0 -255
- package/prototypes/2025-01-11-production-mode-autonomous.js +0 -119
- package/prototypes/2025-01-11-production-mode-collaborative.js +0 -166
- package/prototypes/2025-01-11-production-mode-guided.js +0 -217
- package/prototypes/2025-01-11-production-mode-smart-context.js +0 -347
- package/prototypes/2025-01-11-production-standards-example.md +0 -204
- package/prototypes/2025-11-10-backlog-filtering-tree-aware.js +0 -242
- package/prototypes/test/index.html +0 -1
- package/setup-dist-repo.sh +0 -68
- package/test-production-standards-engine.js +0 -130
- package/test-results.json +0 -2195
- package/test-safety-check.sh +0 -80
- package/work-item-tracking-plan.md +0 -199
- /package/{.jettypod/devpod.db → jettypod.db} +0 -0
package/TEST_SAFETY_AUDIT.md
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
# Test Safety Audit & Remediation Plan
|
|
2
|
-
|
|
3
|
-
## Executive Summary
|
|
4
|
-
The current test suite has critical safety issues that corrupt the production codebase during test runs. This document audits these issues, provides hypotheses for their origins, and outlines a comprehensive remediation plan.
|
|
5
|
-
|
|
6
|
-
## Critical Issues Discovered
|
|
7
|
-
|
|
8
|
-
### 1. Permanent File Modifications
|
|
9
|
-
**Issue:** Tests modify production files without restoration
|
|
10
|
-
- `package.json` gets React dependency added (line 488) - NEVER removed
|
|
11
|
-
- Config files directly modified without proper backup (lines 361-368)
|
|
12
|
-
- No rollback mechanism for file modifications
|
|
13
|
-
|
|
14
|
-
**Impact:** Production dependencies corrupted, package.json permanently altered
|
|
15
|
-
|
|
16
|
-
### 2. Destructive Directory Cleanup
|
|
17
|
-
**Issue:** Test cleanup can delete production directories
|
|
18
|
-
- Previously included `lib/` in cleanup list (fixed)
|
|
19
|
-
- Still includes common directory names that might exist in production
|
|
20
|
-
- Cleanup based on flawed `this.createdTestDirs` tracking
|
|
21
|
-
|
|
22
|
-
**Impact:** Risk of deleting production code
|
|
23
|
-
|
|
24
|
-
### 3. Incomplete Cleanup Tracking
|
|
25
|
-
**Issue:** Many tests create files/directories without tracking them
|
|
26
|
-
- Lines 574-583: Creates subdirectories without adding to `createdTestDirs`
|
|
27
|
-
- Custom-named files outside cleanup patterns remain
|
|
28
|
-
- No verification that cleanup succeeded
|
|
29
|
-
|
|
30
|
-
**Impact:** Test artifacts accumulate, workspace pollution
|
|
31
|
-
|
|
32
|
-
### 4. No Test Isolation
|
|
33
|
-
**Issue:** Tests run directly in production directory
|
|
34
|
-
- No temporary workspace
|
|
35
|
-
- No sandboxing
|
|
36
|
-
- Direct manipulation of real project files
|
|
37
|
-
|
|
38
|
-
**Impact:** Any test failure can leave production in corrupted state
|
|
39
|
-
|
|
40
|
-
### 5. Flawed Backup/Restore Logic
|
|
41
|
-
**Issue:** Config backup only works if file exists initially
|
|
42
|
-
- New project tests delete config entirely
|
|
43
|
-
- Backup might not capture all states
|
|
44
|
-
- No backup for other modified files
|
|
45
|
-
|
|
46
|
-
**Impact:** Original configuration may be lost
|
|
47
|
-
|
|
48
|
-
## Root Cause Analysis
|
|
49
|
-
|
|
50
|
-
### Why These Issues Were Created (Hypotheses)
|
|
51
|
-
|
|
52
|
-
#### 1. **Speed Over Safety Mindset**
|
|
53
|
-
- Likely prioritized getting tests working quickly
|
|
54
|
-
- Direct file manipulation is simpler than proper mocking
|
|
55
|
-
- "It works on my machine" without considering side effects
|
|
56
|
-
|
|
57
|
-
#### 2. **Incomplete Mental Model**
|
|
58
|
-
- Didn't fully consider that tests run in the actual project directory
|
|
59
|
-
- Assumed cleanup would handle everything
|
|
60
|
-
- Didn't anticipate tests being interrupted mid-execution
|
|
61
|
-
|
|
62
|
-
#### 3. **Copy-Paste Pattern Propagation**
|
|
63
|
-
- Initial flawed pattern (like modifying package.json) got copied
|
|
64
|
-
- Each new test followed the existing bad pattern
|
|
65
|
-
- No comprehensive review of test safety
|
|
66
|
-
|
|
67
|
-
#### 4. **Misunderstanding of Test Scope**
|
|
68
|
-
- Treated integration tests like unit tests
|
|
69
|
-
- Didn't properly mock file system operations
|
|
70
|
-
- Confused testing the tool vs testing in production
|
|
71
|
-
|
|
72
|
-
#### 5. **Cleanup as Afterthought**
|
|
73
|
-
- Added cleanup after problems emerged
|
|
74
|
-
- Reactive fixes (like removing lib/) rather than proactive design
|
|
75
|
-
- Band-aid solutions instead of architectural fixes
|
|
76
|
-
|
|
77
|
-
## Comprehensive Remediation Plan
|
|
78
|
-
|
|
79
|
-
### Phase 1: Immediate Fixes (Stop the Bleeding)
|
|
80
|
-
|
|
81
|
-
#### 1.1 Fix package.json Corruption
|
|
82
|
-
```javascript
|
|
83
|
-
// BEFORE TEST
|
|
84
|
-
this.packageBackup = fs.existsSync('package.json')
|
|
85
|
-
? fs.readFileSync('package.json', 'utf-8')
|
|
86
|
-
: null;
|
|
87
|
-
|
|
88
|
-
// AFTER TEST
|
|
89
|
-
if (this.packageBackup) {
|
|
90
|
-
fs.writeFileSync('package.json', this.packageBackup);
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
#### 1.2 Comprehensive File Tracking
|
|
95
|
-
```javascript
|
|
96
|
-
// Track ALL created files
|
|
97
|
-
this.createdFiles = [];
|
|
98
|
-
this.createdDirs = [];
|
|
99
|
-
this.modifiedFiles = new Map(); // filename -> original content
|
|
100
|
-
|
|
101
|
-
// Before any modification
|
|
102
|
-
if (fs.existsSync(file)) {
|
|
103
|
-
this.modifiedFiles.set(file, fs.readFileSync(file, 'utf-8'));
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
#### 1.3 Safe Cleanup Patterns
|
|
108
|
-
```javascript
|
|
109
|
-
After(function() {
|
|
110
|
-
// Restore modified files FIRST
|
|
111
|
-
for (const [file, content] of this.modifiedFiles) {
|
|
112
|
-
fs.writeFileSync(file, content);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Remove created files
|
|
116
|
-
for (const file of this.createdFiles) {
|
|
117
|
-
if (fs.existsSync(file)) {
|
|
118
|
-
fs.unlinkSync(file);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Remove created directories (in reverse order)
|
|
123
|
-
for (const dir of this.createdDirs.reverse()) {
|
|
124
|
-
if (fs.existsSync(dir)) {
|
|
125
|
-
fs.rmSync(dir, { recursive: true });
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Phase 2: Test Isolation Implementation
|
|
132
|
-
|
|
133
|
-
#### 2.1 Create Test Workspace
|
|
134
|
-
```javascript
|
|
135
|
-
Before(function() {
|
|
136
|
-
// Create isolated test directory
|
|
137
|
-
this.testDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jettypod-test-'));
|
|
138
|
-
this.originalCwd = process.cwd();
|
|
139
|
-
process.chdir(this.testDir);
|
|
140
|
-
|
|
141
|
-
// Copy only necessary files
|
|
142
|
-
const filesToCopy = [.jettypod.js', 'lib/', 'package.json'];
|
|
143
|
-
for (const file of filesToCopy) {
|
|
144
|
-
// Copy to test directory
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
After(function() {
|
|
149
|
-
process.chdir(this.originalCwd);
|
|
150
|
-
fs.rmSync(this.testDir, { recursive: true, force: true });
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
#### 2.2 Mock File Operations
|
|
155
|
-
```javascript
|
|
156
|
-
const sinon = require('sinon');
|
|
157
|
-
|
|
158
|
-
Before(function() {
|
|
159
|
-
this.fsStubs = {
|
|
160
|
-
writeFileSync: sinon.stub(fs, 'writeFileSync'),
|
|
161
|
-
readFileSync: sinon.stub(fs, 'readFileSync')
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// Configure stubs to work with virtual file system
|
|
165
|
-
this.virtualFS = new Map();
|
|
166
|
-
|
|
167
|
-
this.fsStubs.writeFileSync.callsFake((path, content) => {
|
|
168
|
-
this.virtualFS.set(path, content);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
this.fsStubs.readFileSync.callsFake((path) => {
|
|
172
|
-
return this.virtualFS.get(path) || fs.readFileSync(path);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
After(function() {
|
|
177
|
-
Object.values(this.fsStubs).forEach(stub => stub.restore());
|
|
178
|
-
});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Phase 3: Comprehensive Test Rewrite
|
|
182
|
-
|
|
183
|
-
#### 3.1 Test Categories
|
|
184
|
-
1. **Unit Tests**: Pure functions, no file system
|
|
185
|
-
2. **Integration Tests**: Use temp directory
|
|
186
|
-
3. **E2E Tests**: Use docker container or VM
|
|
187
|
-
|
|
188
|
-
#### 3.2 Safe Test Patterns
|
|
189
|
-
```javascript
|
|
190
|
-
// NEVER DO THIS
|
|
191
|
-
Given('package.json contains {string} dependency', function(dep) {
|
|
192
|
-
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
193
|
-
pkg.dependencies[dep] = '^18.0.0';
|
|
194
|
-
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// DO THIS INSTEAD
|
|
198
|
-
Given('package.json contains {string} dependency', function(dep) {
|
|
199
|
-
// Create temporary package.json in test directory
|
|
200
|
-
const testPkg = {
|
|
201
|
-
...this.basePackageJson,
|
|
202
|
-
dependencies: {
|
|
203
|
-
...this.basePackageJson.dependencies,
|
|
204
|
-
[dep]: '^18.0.0'
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
fs.writeFileSync(
|
|
208
|
-
path.join(this.testDir, 'package.json'),
|
|
209
|
-
JSON.stringify(testPkg, null, 2)
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Phase 4: Safety Verification
|
|
215
|
-
|
|
216
|
-
#### 4.1 Pre-Test Snapshot
|
|
217
|
-
```javascript
|
|
218
|
-
Before(function() {
|
|
219
|
-
this.snapshot = {
|
|
220
|
-
files: fs.readdirSync('.'),
|
|
221
|
-
config: fs.existsSync('.jettypod/config.json')
|
|
222
|
-
? fs.readFileSync('.jettypod/config.json', 'utf-8')
|
|
223
|
-
: null,
|
|
224
|
-
packageJson: fs.readFileSync('package.json', 'utf-8')
|
|
225
|
-
};
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
After(function() {
|
|
229
|
-
// Verify nothing changed
|
|
230
|
-
const currentFiles = fs.readdirSync('.');
|
|
231
|
-
const addedFiles = currentFiles.filter(f => !this.snapshot.files.includes(f));
|
|
232
|
-
|
|
233
|
-
if (addedFiles.length > 0) {
|
|
234
|
-
throw new Error(`Test leaked files: ${addedFiles.join(', ')}`);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const currentPkg = fs.readFileSync('package.json', 'utf-8');
|
|
238
|
-
if (currentPkg !== this.snapshot.packageJson) {
|
|
239
|
-
throw new Error('package.json was modified!');
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
#### 4.2 CI Safety Checks
|
|
245
|
-
```yaml
|
|
246
|
-
# .github/workflows/test-safety.yml
|
|
247
|
-
- name: Snapshot before tests
|
|
248
|
-
run: |
|
|
249
|
-
find . -type f -name "*.json" | xargs md5sum > before.md5
|
|
250
|
-
|
|
251
|
-
- name: Run tests
|
|
252
|
-
run: npm test
|
|
253
|
-
|
|
254
|
-
- name: Verify no changes
|
|
255
|
-
run: |
|
|
256
|
-
find . -type f -name "*.json" | xargs md5sum > after.md5
|
|
257
|
-
diff before.md5 after.md5
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## Implementation Priority
|
|
261
|
-
|
|
262
|
-
1. **IMMEDIATE (Today)**
|
|
263
|
-
- Add package.json backup/restore
|
|
264
|
-
- Fix directory cleanup tracking
|
|
265
|
-
- Document known issues in README
|
|
266
|
-
|
|
267
|
-
2. **HIGH (This Week)**
|
|
268
|
-
- Implement comprehensive file tracking
|
|
269
|
-
- Add safety verification in After hooks
|
|
270
|
-
- Create test workspace isolation
|
|
271
|
-
|
|
272
|
-
3. **MEDIUM (Next Sprint)**
|
|
273
|
-
- Rewrite tests to use mocking
|
|
274
|
-
- Separate unit/integration/e2e tests
|
|
275
|
-
- Add CI safety checks
|
|
276
|
-
|
|
277
|
-
4. **LONG TERM**
|
|
278
|
-
- Docker-based test environment
|
|
279
|
-
- Complete test isolation framework
|
|
280
|
-
- Automated safety audits
|
|
281
|
-
|
|
282
|
-
## Lessons Learned
|
|
283
|
-
|
|
284
|
-
1. **Never modify production files in tests**
|
|
285
|
-
2. **Always use isolated test environments**
|
|
286
|
-
3. **Track everything you create or modify**
|
|
287
|
-
4. **Cleanup must be guaranteed, not best-effort**
|
|
288
|
-
5. **Test the cleanup itself**
|
|
289
|
-
|
|
290
|
-
## Prevention Measures
|
|
291
|
-
|
|
292
|
-
1. **Code Review Checklist**
|
|
293
|
-
- [ ] No direct modification of package.json
|
|
294
|
-
- [ ] All created files/dirs tracked
|
|
295
|
-
- [ ] Cleanup in After hook
|
|
296
|
-
- [ ] No production directories in cleanup list
|
|
297
|
-
- [ ] Backup before modification
|
|
298
|
-
|
|
299
|
-
2. **Automated Checks**
|
|
300
|
-
- Pre-commit hook to detect dangerous test patterns
|
|
301
|
-
- CI job to verify no file system pollution
|
|
302
|
-
- Regular audit of test safety
|
|
303
|
-
|
|
304
|
-
3. **Developer Guidelines**
|
|
305
|
-
- Always use temp directories for test files
|
|
306
|
-
- Mock file system operations when possible
|
|
307
|
-
- Never assume cleanup will run (test might crash)
|
|
308
|
-
- Test your tests in a clean environment
|
|
309
|
-
|
|
310
|
-
## Conclusion
|
|
311
|
-
|
|
312
|
-
These test safety issues arose from prioritizing speed over correctness, incomplete understanding of test isolation requirements, and pattern propagation without review. The remediation plan provides both immediate fixes and long-term architectural improvements to ensure tests never corrupt production code again.
|
|
313
|
-
|
|
314
|
-
The key insight: **Tests should be completely isolated and leave zero trace after execution.**
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Test Safety Implementation Complete
|
|
2
|
-
|
|
3
|
-
## Executive Summary
|
|
4
|
-
All critical test safety issues from the audit have been successfully remediated. The test suite now runs in complete isolation and cannot corrupt the production codebase.
|
|
5
|
-
|
|
6
|
-
## Implemented Solutions
|
|
7
|
-
|
|
8
|
-
### Phase 1: Immediate Fixes ✅
|
|
9
|
-
- **Package.json Protection**: Backup and restore mechanism prevents permanent modifications
|
|
10
|
-
- **File Tracking**: Comprehensive tracking of all created/modified files
|
|
11
|
-
- **Safe Cleanup**: Only explicitly tracked items are deleted, no dangerous wildcards
|
|
12
|
-
|
|
13
|
-
### Phase 2: Test Isolation ✅
|
|
14
|
-
- **Isolated Workspace**: Tests run in `/tmp/jettypod-test-*` directories
|
|
15
|
-
- **Zero Production Contact**: All operations redirected to test directory
|
|
16
|
-
- **Symlinked Dependencies**: Efficient node_modules access without copying
|
|
17
|
-
|
|
18
|
-
### Phase 3: Proper Patterns ✅
|
|
19
|
-
- **Path Resolution**: All file operations use proper path.join() with test directory
|
|
20
|
-
- **Context Passing**: Every function receives test context for proper isolation
|
|
21
|
-
- **No Direct FS Operations**: All operations scoped to test workspace
|
|
22
|
-
|
|
23
|
-
### Phase 4: Safety Verification ✅
|
|
24
|
-
- **Production Snapshots**: Before/after comparison ensures no modifications
|
|
25
|
-
- **Automatic Restoration**: Any accidental changes are immediately reverted
|
|
26
|
-
- **CI Pipeline**: GitHub Actions workflow validates test safety on every commit
|
|
27
|
-
- **Local Safety Check**: `./test-safety-check.sh` script for pre-commit verification
|
|
28
|
-
|
|
29
|
-
## Key Improvements
|
|
30
|
-
|
|
31
|
-
### Before
|
|
32
|
-
```javascript
|
|
33
|
-
// DANGEROUS - Modifies production directly
|
|
34
|
-
fs.writeFileSync('package.json', modifiedPkg);
|
|
35
|
-
fs.rmSync('lib', { recursive: true }); // Could delete production!
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### After
|
|
39
|
-
```javascript
|
|
40
|
-
// SAFE - Isolated to test directory
|
|
41
|
-
const pkgPath = path.join(this.testDir, 'package.json');
|
|
42
|
-
fs.writeFileSync(pkgPath, modifiedPkg);
|
|
43
|
-
// Only test directory is affected
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Safety Guarantees
|
|
47
|
-
|
|
48
|
-
1. **Production Isolation**: Tests NEVER modify production files
|
|
49
|
-
2. **Automatic Cleanup**: Temp directories removed after each test
|
|
50
|
-
3. **Snapshot Verification**: Production state verified before/after
|
|
51
|
-
4. **Multiple Safety Layers**:
|
|
52
|
-
- Test workspace isolation (primary defense)
|
|
53
|
-
- Production snapshots (verification)
|
|
54
|
-
- Cleanup tracking (fallback)
|
|
55
|
-
- CI validation (continuous monitoring)
|
|
56
|
-
|
|
57
|
-
## Testing the Safety
|
|
58
|
-
|
|
59
|
-
Run safety verification:
|
|
60
|
-
```bash
|
|
61
|
-
./test-safety-check.sh
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Expected output:
|
|
65
|
-
```
|
|
66
|
-
✅ package.json unchanged
|
|
67
|
-
✅ No test artifacts leaked
|
|
68
|
-
✅ All production files unchanged
|
|
69
|
-
✅ SAFETY CHECK PASSED - Production directory is safe!
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Remaining Best Practices
|
|
73
|
-
|
|
74
|
-
While the critical safety issues are resolved, consider these additional improvements:
|
|
75
|
-
|
|
76
|
-
1. **Mock External Services**: Use sinon/jest mocks for external APIs
|
|
77
|
-
2. **Database Isolation**: Use test databases or in-memory DBs
|
|
78
|
-
3. **Environment Variables**: Use `.env.test` for test configuration
|
|
79
|
-
4. **Parallel Test Safety**: Ensure unique temp directories for parallel runs
|
|
80
|
-
5. **Docker Testing**: Consider containerized test environments for ultimate isolation
|
|
81
|
-
|
|
82
|
-
## Verification Checklist
|
|
83
|
-
|
|
84
|
-
- [x] Tests run in isolated `/tmp` directories
|
|
85
|
-
- [x] Production `package.json` never modified
|
|
86
|
-
- [x] No test artifacts in production after tests
|
|
87
|
-
- [x] Cleanup removes all test directories
|
|
88
|
-
- [x] Safety checks pass locally
|
|
89
|
-
- [x] CI pipeline configured
|
|
90
|
-
- [x] Production snapshots working
|
|
91
|
-
- [x] All file operations use test directory paths
|
|
92
|
-
|
|
93
|
-
## Conclusion
|
|
94
|
-
|
|
95
|
-
The test suite is now completely safe. Even catastrophic test failures cannot corrupt production code, as all operations are confined to temporary directories that the OS will eventually clean up regardless.
|
|
96
|
-
|
|
97
|
-
The implementation follows defense-in-depth principles with multiple layers of protection, ensuring production safety even if one layer fails.
|