pi-gauntlet 4.13.2 → 5.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.
- package/CHANGELOG.md +10 -0
- package/README.md +8 -8
- package/agents/spec-council-member.md +6 -2
- package/agents/spec-council-synthesizer.md +1 -1
- package/package.json +1 -1
- package/skills/brainstorming/SKILL.md +4 -3
- package/skills/chase-bug/SKILL.md +320 -0
- package/skills/dispatching-parallel-agents/SKILL.md +1 -1
- package/skills/roasting-the-spec/SKILL.md +19 -13
- package/skills/shape-ticket/SKILL.md +32 -16
- package/skills/writing-skills/SKILL.md +3 -3
- package/skills/systematic-debugging/SKILL.md +0 -151
- package/skills/systematic-debugging/condition-based-waiting-example.ts +0 -158
- package/skills/systematic-debugging/condition-based-waiting.md +0 -115
- package/skills/systematic-debugging/defense-in-depth.md +0 -122
- package/skills/systematic-debugging/find-polluter.sh +0 -63
- package/skills/systematic-debugging/reference/rationalizations.md +0 -61
- package/skills/systematic-debugging/root-cause-tracing.md +0 -169
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Bisection script to find which test creates unwanted files/state
|
|
3
|
-
# Usage: ./find-polluter.sh <file_or_dir_to_check> <test_pattern>
|
|
4
|
-
# Example: ./find-polluter.sh '.git' 'src/**/*.test.ts'
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
if [ $# -ne 2 ]; then
|
|
9
|
-
echo "Usage: $0 <file_to_check> <test_pattern>"
|
|
10
|
-
echo "Example: $0 '.git' 'src/**/*.test.ts'"
|
|
11
|
-
exit 1
|
|
12
|
-
fi
|
|
13
|
-
|
|
14
|
-
POLLUTION_CHECK="$1"
|
|
15
|
-
TEST_PATTERN="$2"
|
|
16
|
-
|
|
17
|
-
echo "🔍 Searching for test that creates: $POLLUTION_CHECK"
|
|
18
|
-
echo "Test pattern: $TEST_PATTERN"
|
|
19
|
-
echo ""
|
|
20
|
-
|
|
21
|
-
# Get list of test files
|
|
22
|
-
TEST_FILES=$(find . -path "$TEST_PATTERN" | sort)
|
|
23
|
-
TOTAL=$(echo "$TEST_FILES" | wc -l | tr -d ' ')
|
|
24
|
-
|
|
25
|
-
echo "Found $TOTAL test files"
|
|
26
|
-
echo ""
|
|
27
|
-
|
|
28
|
-
COUNT=0
|
|
29
|
-
for TEST_FILE in $TEST_FILES; do
|
|
30
|
-
COUNT=$((COUNT + 1))
|
|
31
|
-
|
|
32
|
-
# Skip if pollution already exists
|
|
33
|
-
if [ -e "$POLLUTION_CHECK" ]; then
|
|
34
|
-
echo "⚠️ Pollution already exists before test $COUNT/$TOTAL"
|
|
35
|
-
echo " Skipping: $TEST_FILE"
|
|
36
|
-
continue
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
|
-
echo "[$COUNT/$TOTAL] Testing: $TEST_FILE"
|
|
40
|
-
|
|
41
|
-
# Run the test
|
|
42
|
-
npm test "$TEST_FILE" > /dev/null 2>&1 || true
|
|
43
|
-
|
|
44
|
-
# Check if pollution appeared
|
|
45
|
-
if [ -e "$POLLUTION_CHECK" ]; then
|
|
46
|
-
echo ""
|
|
47
|
-
echo "🎯 FOUND POLLUTER!"
|
|
48
|
-
echo " Test: $TEST_FILE"
|
|
49
|
-
echo " Created: $POLLUTION_CHECK"
|
|
50
|
-
echo ""
|
|
51
|
-
echo "Pollution details:"
|
|
52
|
-
ls -la "$POLLUTION_CHECK"
|
|
53
|
-
echo ""
|
|
54
|
-
echo "To investigate:"
|
|
55
|
-
echo " npm test $TEST_FILE # Run just this test"
|
|
56
|
-
echo " cat $TEST_FILE # Review test code"
|
|
57
|
-
exit 1
|
|
58
|
-
fi
|
|
59
|
-
done
|
|
60
|
-
|
|
61
|
-
echo ""
|
|
62
|
-
echo "✅ No polluter found - all tests clean!"
|
|
63
|
-
exit 0
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# Debugging Rationalizations & Red Flags
|
|
2
|
-
|
|
3
|
-
## Common Rationalizations
|
|
4
|
-
|
|
5
|
-
| Excuse | Reality |
|
|
6
|
-
|--------|---------|
|
|
7
|
-
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
|
|
8
|
-
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
|
|
9
|
-
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
|
|
10
|
-
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
|
|
11
|
-
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
|
|
12
|
-
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
|
|
13
|
-
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
|
|
14
|
-
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
|
|
15
|
-
|
|
16
|
-
## Red Flags — STOP and Follow Process
|
|
17
|
-
|
|
18
|
-
If you catch yourself thinking:
|
|
19
|
-
- "Quick fix for now, investigate later"
|
|
20
|
-
- "Just try changing X and see if it works"
|
|
21
|
-
- "Add multiple changes, run tests"
|
|
22
|
-
- "Skip the test, I'll manually verify"
|
|
23
|
-
- "It's probably X, let me fix that"
|
|
24
|
-
- "I don't fully understand but this might work"
|
|
25
|
-
- "Pattern says X but I'll adapt it differently"
|
|
26
|
-
- "Here are the main problems: [lists fixes without investigation]"
|
|
27
|
-
- Proposing solutions before tracing data flow
|
|
28
|
-
- "One more fix attempt" (when already tried 2+)
|
|
29
|
-
- Each fix reveals new problem in different place
|
|
30
|
-
|
|
31
|
-
**ALL of these mean: STOP. Return to Phase 1.**
|
|
32
|
-
|
|
33
|
-
**If 3+ fixes failed:** Question the architecture (see Phase 4.5)
|
|
34
|
-
|
|
35
|
-
## Your Human Partner's Signals You're Doing It Wrong
|
|
36
|
-
|
|
37
|
-
**Watch for these redirections:**
|
|
38
|
-
- "Is that not happening?" — You assumed without verifying
|
|
39
|
-
- "Will it show us...?" — You should have added evidence gathering
|
|
40
|
-
- "Stop guessing" — You're proposing fixes without understanding
|
|
41
|
-
- "Ultrathink this" — Question fundamentals, not just symptoms
|
|
42
|
-
- "We're stuck?" (frustrated) — Your approach isn't working
|
|
43
|
-
|
|
44
|
-
**When you see these:** STOP. Return to Phase 1.
|
|
45
|
-
|
|
46
|
-
## Quick Reference
|
|
47
|
-
|
|
48
|
-
| Phase | Key Activities | Success Criteria |
|
|
49
|
-
|-------|---------------|------------------|
|
|
50
|
-
| **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
|
|
51
|
-
| **2. Pattern** | Find working examples, compare | Identify differences |
|
|
52
|
-
| **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
|
|
53
|
-
| **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
|
|
54
|
-
|
|
55
|
-
## Real-World Impact
|
|
56
|
-
|
|
57
|
-
From debugging sessions:
|
|
58
|
-
- Systematic approach: 15-30 minutes to fix
|
|
59
|
-
- Random fixes approach: 2-3 hours of thrashing
|
|
60
|
-
- First-time fix rate: 95% vs 40%
|
|
61
|
-
- New bugs introduced: Near zero vs common
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
# Root Cause Tracing
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom.
|
|
6
|
-
|
|
7
|
-
**Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source.
|
|
8
|
-
|
|
9
|
-
## When to Use
|
|
10
|
-
|
|
11
|
-
```dot
|
|
12
|
-
digraph when_to_use {
|
|
13
|
-
"Bug appears deep in stack?" [shape=diamond];
|
|
14
|
-
"Can trace backwards?" [shape=diamond];
|
|
15
|
-
"Fix at symptom point" [shape=box];
|
|
16
|
-
"Trace to original trigger" [shape=box];
|
|
17
|
-
"BETTER: Also add defense-in-depth" [shape=box];
|
|
18
|
-
|
|
19
|
-
"Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"];
|
|
20
|
-
"Can trace backwards?" -> "Trace to original trigger" [label="yes"];
|
|
21
|
-
"Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"];
|
|
22
|
-
"Trace to original trigger" -> "BETTER: Also add defense-in-depth";
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**Use when:**
|
|
27
|
-
- Error happens deep in execution (not at entry point)
|
|
28
|
-
- Stack trace shows long call chain
|
|
29
|
-
- Unclear where invalid data originated
|
|
30
|
-
- Need to find which test/code triggers the problem
|
|
31
|
-
|
|
32
|
-
## The Tracing Process
|
|
33
|
-
|
|
34
|
-
### 1. Observe the Symptom
|
|
35
|
-
```
|
|
36
|
-
Error: git init failed in ~/project/packages/core
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 2. Find Immediate Cause
|
|
40
|
-
**What code directly causes this?**
|
|
41
|
-
```typescript
|
|
42
|
-
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### 3. Ask: What Called This?
|
|
46
|
-
```typescript
|
|
47
|
-
WorktreeManager.createSessionWorktree(projectDir, sessionId)
|
|
48
|
-
→ called by Session.initializeWorkspace()
|
|
49
|
-
→ called by Session.create()
|
|
50
|
-
→ called by test at Project.create()
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 4. Keep Tracing Up
|
|
54
|
-
**What value was passed?**
|
|
55
|
-
- `projectDir = ''` (empty string!)
|
|
56
|
-
- Empty string as `cwd` resolves to `process.cwd()`
|
|
57
|
-
- That's the source code directory!
|
|
58
|
-
|
|
59
|
-
### 5. Find Original Trigger
|
|
60
|
-
**Where did empty string come from?**
|
|
61
|
-
```typescript
|
|
62
|
-
const context = setupCoreTest(); // Returns { tempDir: '' }
|
|
63
|
-
Project.create('name', context.tempDir); // Accessed before beforeEach!
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Adding Stack Traces
|
|
67
|
-
|
|
68
|
-
When you can't trace manually, add instrumentation:
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
// Before the problematic operation
|
|
72
|
-
async function gitInit(directory: string) {
|
|
73
|
-
const stack = new Error().stack;
|
|
74
|
-
console.error('DEBUG git init:', {
|
|
75
|
-
directory,
|
|
76
|
-
cwd: process.cwd(),
|
|
77
|
-
nodeEnv: process.env.NODE_ENV,
|
|
78
|
-
stack,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
await execFileAsync('git', ['init'], { cwd: directory });
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Critical:** Use `console.error()` in tests (not logger - may not show)
|
|
86
|
-
|
|
87
|
-
**Run and capture:**
|
|
88
|
-
```bash
|
|
89
|
-
npm test 2>&1 | grep 'DEBUG git init'
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**Analyze stack traces:**
|
|
93
|
-
- Look for test file names
|
|
94
|
-
- Find the line number triggering the call
|
|
95
|
-
- Identify the pattern (same test? same parameter?)
|
|
96
|
-
|
|
97
|
-
## Finding Which Test Causes Pollution
|
|
98
|
-
|
|
99
|
-
If something appears during tests but you don't know which test:
|
|
100
|
-
|
|
101
|
-
Use the bisection script `find-polluter.sh` in this directory:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
./find-polluter.sh '.git' 'src/**/*.test.ts'
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Runs tests one-by-one, stops at first polluter. See script for usage.
|
|
108
|
-
|
|
109
|
-
## Real Example: Empty projectDir
|
|
110
|
-
|
|
111
|
-
**Symptom:** `.git` created in `packages/core/` (source code)
|
|
112
|
-
|
|
113
|
-
**Trace chain:**
|
|
114
|
-
1. `git init` runs in `process.cwd()` ← empty cwd parameter
|
|
115
|
-
2. WorktreeManager called with empty projectDir
|
|
116
|
-
3. Session.create() passed empty string
|
|
117
|
-
4. Test accessed `context.tempDir` before beforeEach
|
|
118
|
-
5. setupCoreTest() returns `{ tempDir: '' }` initially
|
|
119
|
-
|
|
120
|
-
**Root cause:** Top-level variable initialization accessing empty value
|
|
121
|
-
|
|
122
|
-
**Fix:** Made tempDir a getter that throws if accessed before beforeEach
|
|
123
|
-
|
|
124
|
-
**Also added defense-in-depth:**
|
|
125
|
-
- Layer 1: Project.create() validates directory
|
|
126
|
-
- Layer 2: WorkspaceManager validates not empty
|
|
127
|
-
- Layer 3: NODE_ENV guard refuses git init outside tmpdir
|
|
128
|
-
- Layer 4: Stack trace logging before git init
|
|
129
|
-
|
|
130
|
-
## Key Principle
|
|
131
|
-
|
|
132
|
-
```dot
|
|
133
|
-
digraph principle {
|
|
134
|
-
"Found immediate cause" [shape=ellipse];
|
|
135
|
-
"Can trace one level up?" [shape=diamond];
|
|
136
|
-
"Trace backwards" [shape=box];
|
|
137
|
-
"Is this the source?" [shape=diamond];
|
|
138
|
-
"Fix at source" [shape=box];
|
|
139
|
-
"Add validation at each layer" [shape=box];
|
|
140
|
-
"Bug impossible" [shape=doublecircle];
|
|
141
|
-
"NEVER fix just the symptom" [shape=octagon, style=filled, fillcolor=red, fontcolor=white];
|
|
142
|
-
|
|
143
|
-
"Found immediate cause" -> "Can trace one level up?";
|
|
144
|
-
"Can trace one level up?" -> "Trace backwards" [label="yes"];
|
|
145
|
-
"Can trace one level up?" -> "NEVER fix just the symptom" [label="no"];
|
|
146
|
-
"Trace backwards" -> "Is this the source?";
|
|
147
|
-
"Is this the source?" -> "Trace backwards" [label="no - keeps going"];
|
|
148
|
-
"Is this the source?" -> "Fix at source" [label="yes"];
|
|
149
|
-
"Fix at source" -> "Add validation at each layer";
|
|
150
|
-
"Add validation at each layer" -> "Bug impossible";
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**NEVER fix just where the error appears.** Trace back to find the original trigger.
|
|
155
|
-
|
|
156
|
-
## Stack Trace Tips
|
|
157
|
-
|
|
158
|
-
**In tests:** Use `console.error()` not logger - logger may be suppressed
|
|
159
|
-
**Before operation:** Log before the dangerous operation, not after it fails
|
|
160
|
-
**Include context:** Directory, cwd, environment variables, timestamps
|
|
161
|
-
**Capture stack:** `new Error().stack` shows complete call chain
|
|
162
|
-
|
|
163
|
-
## Real-World Impact
|
|
164
|
-
|
|
165
|
-
From debugging session (2025-10-03):
|
|
166
|
-
- Found root cause through 5-level trace
|
|
167
|
-
- Fixed at source (getter validation)
|
|
168
|
-
- Added 4 layers of defense
|
|
169
|
-
- 1847 tests passed, zero pollution
|