Loading...
Loading...
Compare original and translation side by side
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST未完成根本原因调查,严禁进行任何修复For EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify environment/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks
THEN analyze evidence to identify failing component
THEN investigate that specific component# Layer 1: Workflow
echo "=== Secrets available in workflow: ==="
echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
# Layer 2: Build script
echo "=== Env vars in build script: ==="
env | grep IDENTITY || echo "IDENTITY not in environment"
# Layer 3: Signing script
echo "=== Keychain state: ==="
security list-keychains
security find-identity -v
# Layer 4: Actual signing
codesign --sign "$IDENTITY" --verbose=4 "$APP"针对每个组件边界:
- 记录进入组件的数据
- 记录离开组件的数据
- 验证环境/配置的传递
- 检查每一层的状态
运行一次以收集证据,确定问题出在哪个环节
然后分析证据,找出故障组件
再针对该组件进行调查# Layer 1: Workflow
echo "=== Secrets available in workflow: ==="
echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
# Layer 2: Build script
echo "=== Env vars in build script: ==="
env | grep IDENTITY || echo "IDENTITY not in environment"
# Layer 3: Signing script
echo "=== Keychain state: ==="
security list-keychains
security find-identity -v
# Layer 4: Actual signing
codesign --sign "$IDENTITY" --verbose=4 "$APP"| Excuse | Reality |
|---|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
| 借口 | 实际情况 |
|---|---|
| “问题很简单,不需要遵循流程” | 简单问题也有根本原因。此流程处理简单Bug的速度很快。 |
| “紧急情况,没时间走流程” | 系统化调试比盲目猜测更快。 |
| “先试试这个,之后再调查” | 第一次修复会定下模式。从一开始就做对。 |
| “确认修复有效后再写测试” | 未测试的修复无法持久。先写测试能验证修复效果。 |
| “同时做多个修复更省时间” | 无法确定哪个变更起作用。还会引入新Bug。 |
| “参考内容太长,我调整一下模式” | 一知半解必然导致Bug。请完整阅读参考内容。 |
| “我看到问题了,我来修复” | 看到症状≠理解根本原因。 |
| “再试一次修复”(已经失败2次以上) | 3次以上失败=架构问题。质疑模式,不要继续修复。 |
| Phase | Key Activities | Success Criteria |
|---|---|---|
| 1. Root Cause | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
| 2. Pattern | Find working examples, compare | Identify differences |
| 3. Hypothesis | Form theory, test minimally | Confirmed or new hypothesis |
| 4. Implementation | Create test, fix, verify | Bug resolved, tests pass |
| 阶段 | 核心活动 | 成功标准 |
|---|---|---|
| 1. 根本原因调查 | 阅读错误信息、复现问题、检查变更、收集证据 | 理解问题是什么以及为什么会发生 |
| 2. 模式分析 | 寻找可用示例、对比参考实现 | 识别差异 |
| 3. 假设与测试 | 形成理论、最小化测试 | 验证假设或形成新假设 |
| 4. 实施修复 | 创建测试用例、修复、验证 | Bug解决,测试通过 |
Error: git init failed in /Users/jesse/project/packages/coreawait execFileAsync('git', ['init'], { cwd: projectDir })WorktreeManager.createSessionWorktree(projectDir, sessionId)
→ called by Session.initializeWorkspace()
→ called by Session.create()
→ called by test at Project.create()projectDir = ''cwdprocess.cwd()const context = setupCoreTest() // Returns { tempDir: '' }
Project.create('name', context.tempDir) // Accessed before beforeEach!Error: git init failed in /Users/jesse/project/packages/coreawait execFileAsync('git', ['init'], { cwd: projectDir })WorktreeManager.createSessionWorktree(projectDir, sessionId)
→ called by Session.initializeWorkspace()
→ called by Session.create()
→ called by test at Project.create()projectDir = ''cwdprocess.cwd()const context = setupCoreTest() // Returns { tempDir: '' }
Project.create('name', context.tempDir) // 在beforeEach之前就被访问了!async function gitInit(directory: string) {
const stack = new Error().stack
console.error('DEBUG git init:', {
directory,
cwd: process.cwd(),
nodeEnv: process.env.NODE_ENV,
stack,
})
await execFileAsync('git', ['init'], { cwd: directory })
}console.error()new Error().stackasync function gitInit(directory: string) {
const stack = new Error().stack
console.error('DEBUG git init:', {
directory,
cwd: process.cwd(),
nodeEnv: process.env.NODE_ENV,
stack,
})
await execFileAsync('git', ['init'], { cwd: directory })
}console.error()new Error().stackundefinedundefined
**NEVER fix just where the error appears.** Trace back to find the original
trigger.
**切勿仅在错误出现的位置修复。** 反向追踪找到最初的触发点。function createProject(name: string, workingDirectory: string) {
if (!workingDirectory || workingDirectory.trim() === '') {
throw new Error('workingDirectory cannot be empty')
}
if (!existsSync(workingDirectory)) {
throw new Error(`workingDirectory does not exist: ${workingDirectory}`)
}
}function initializeWorkspace(projectDir: string, sessionId: string) {
if (!projectDir) {
throw new Error('projectDir required for workspace initialization')
}
}async function gitInit(directory: string) {
if (process.env.NODE_ENV === 'test') {
const normalized = normalize(resolve(directory))
const tmpDir = normalize(resolve(tmpdir()))
if (!normalized.startsWith(tmpDir)) {
throw new Error(`Refusing git init outside temp dir during tests`)
}
}
}async function gitInit(directory: string) {
logger.debug('About to git init', {
directory,
cwd: process.cwd(),
stack: new Error().stack,
})
}function createProject(name: string, workingDirectory: string) {
if (!workingDirectory || workingDirectory.trim() === '') {
throw new Error('workingDirectory cannot be empty')
}
if (!existsSync(workingDirectory)) {
throw new Error(`workingDirectory does not exist: ${workingDirectory}`)
}
}function initializeWorkspace(projectDir: string, sessionId: string) {
if (!projectDir) {
throw new Error('projectDir required for workspace initialization')
}
}async function gitInit(directory: string) {
if (process.env.NODE_ENV === 'test') {
const normalized = normalize(resolve(directory))
const tmpDir = normalize(resolve(tmpdir()))
if (!normalized.startsWith(tmpDir)) {
throw new Error(`Refusing git init outside temp dir during tests`)
}
}
}async function gitInit(directory: string) {
logger.debug('About to git init', {
directory,
cwd: process.cwd(),
stack: new Error().stack,
})
}