fix(ingest): autoApproveExec 传错 id 致自动合并不触发(线上实测捕获)
condition 误把 taskId 传给 autoApproveExecOn(projectId) → getProject(taskId)=null → 永远 false,自动合并从不触发(任务卡 exec_review)。 重构为 shouldAutoApproveExec(store, task, codeV, secV),内部读 task.projectId 自取项目, 杜绝传错 id;补单测覆盖。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+19
-1
@@ -4,7 +4,7 @@ import { mkdtempSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { Store } from '../src/store/index.js';
|
||||
import { ingestRun } from '../src/daemon/ingest.js';
|
||||
import { ingestRun, shouldAutoApproveExec } from '../src/daemon/ingest.js';
|
||||
import { appendOutbox, type OutboxPayload } from '../src/executor/protocol.js';
|
||||
import { branchFor, worktreeDirFor } from '../src/executor/worktree.js';
|
||||
|
||||
@@ -304,6 +304,24 @@ test('autoApprovePlan:含 medium 子任务 → 不放行(改动面/复杂度
|
||||
});
|
||||
});
|
||||
|
||||
test('shouldAutoApproveExec:双 approve + auto-approved + 开关 → true;任一不满足 → false', () => {
|
||||
const s = new Store(':memory:');
|
||||
const p = s.createProject({ name: 'aae', repoPath: '/tmp/aae-' + Math.random(), autonomy: 'auto-approved' });
|
||||
const t = s.createTask({ projectId: p.id, title: 'x', complexity: 'easy' });
|
||||
// 开关默认关 → false
|
||||
assert.equal(shouldAutoApproveExec(s, t, 'approve', 'approve'), false, '开关关');
|
||||
s.patchProject(p.id, { autoApproveExec: true });
|
||||
// 现在满足三条件 → true(函数读 task.projectId 自取项目,传错 id 不可能)
|
||||
assert.equal(shouldAutoApproveExec(s, t, 'approve', 'approve'), true);
|
||||
// verdict 任一非 approve → false
|
||||
assert.equal(shouldAutoApproveExec(s, t, 'approve', 'reject'), false);
|
||||
assert.equal(shouldAutoApproveExec(s, t, null, 'approve'), false);
|
||||
// 非 auto-approved → false
|
||||
s.patchProject(p.id, { autonomy: 'auto-easy' });
|
||||
assert.equal(shouldAutoApproveExec(s, t, 'approve', 'approve'), false);
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('ingest planner failed:走 failPlanAttempt(退避,任务留 speccing,不进 failed)', () => {
|
||||
withTmpDataDir(() => {
|
||||
const { store, taskId, runId } = setupPlanning('medium');
|
||||
|
||||
Reference in New Issue
Block a user