From 73a82741132ebfdd2ab25af451b8abdfe850ab02 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Sat, 20 Jun 2026 11:37:38 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=20goalAudit=20stub?= =?UTF-8?q?=20=E5=8F=8A=E5=85=B6=E6=B5=8B=E8=AF=95=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 src/services/goal/goalAudit.ts(导出 COMPLETION_AUDIT_RULES/BLOCKED_AUDIT_RULES/isGoalTerminal 等未引用的 stub) - 同步移除 tests/integration/goal-lifecycle.test.ts 中对 goalAudit 的 import 和一个测试用例(budget_limited is terminal) Co-Authored-By: glm-5.2 --- src/services/goal/goalAudit.ts | 33 ----------------- tests/integration/goal-lifecycle.test.ts | 46 ------------------------ 2 files changed, 79 deletions(-) delete mode 100644 src/services/goal/goalAudit.ts diff --git a/src/services/goal/goalAudit.ts b/src/services/goal/goalAudit.ts deleted file mode 100644 index 4181163f3..000000000 --- a/src/services/goal/goalAudit.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Audit rules constants for goal completion and blocked assessment. - * Shared by prompt templates and integration tests. - */ -import { BLOCKED_CONSECUTIVE_THRESHOLD, MAX_GOAL_TURNS } from './goalState.js' -import type { GoalStatus } from '../../types/logs.js' - -export { BLOCKED_CONSECUTIVE_THRESHOLD, MAX_GOAL_TURNS } - -export const COMPLETION_AUDIT_RULES = [ - 'Derive concrete requirements from the objective and any referenced files.', - 'Preserve the original scope — do not redefine success around what is already done.', - 'For every explicit requirement, identify authoritative evidence (test output, file content, command result).', - 'Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.', - 'Treat uncertain or indirect evidence as "not achieved".', - 'The audit must PROVE completion, not merely fail to find remaining work.', -] as const - -export const BLOCKED_AUDIT_RULES = [ - 'The same blocking condition must persist across at least 3 consecutive continuation turns.', - '"Difficult", "slow", or "partially incomplete" is NOT blocked.', - 'Only genuinely insurmountable obstacles qualify (missing credentials, external service down, etc.).', -] as const - -export function isGoalTerminal(status: GoalStatus): boolean { - return ( - status === 'complete' || - status === 'blocked' || - status === 'budget_limited' || - status === 'usage_limited' || - status === 'max_turns' - ) -} diff --git a/tests/integration/goal-lifecycle.test.ts b/tests/integration/goal-lifecycle.test.ts index 5f4b9bfbc..bc78863dc 100644 --- a/tests/integration/goal-lifecycle.test.ts +++ b/tests/integration/goal-lifecycle.test.ts @@ -38,12 +38,6 @@ import { buildGoalContextBlock, } from '../../src/services/goal/prompts' -import { - COMPLETION_AUDIT_RULES, - BLOCKED_AUDIT_RULES, - isGoalTerminal, -} from '../../src/services/goal/goalAudit' - const TEST_SESSION = 'test-integration-session' beforeEach(() => { @@ -123,10 +117,6 @@ describe('Goal lifecycle: budget limiting', () => { expect(getGoal(TEST_SESSION)!.status).toBe('budget_limited') expect(getGoal(TEST_SESSION)!.tokensUsed).toBe(55_000) }) - - test('budget_limited is terminal', () => { - expect(isGoalTerminal('budget_limited')).toBe(true) - }) }) describe('Goal lifecycle: usage limiting', () => { @@ -135,10 +125,6 @@ describe('Goal lifecycle: usage limiting', () => { markUsageLimited(TEST_SESSION) expect(getGoal(TEST_SESSION)!.status).toBe('usage_limited') }) - - test('usage_limited is terminal', () => { - expect(isGoalTerminal('usage_limited')).toBe(true) - }) }) describe('Goal lifecycle: blocked attempts', () => { @@ -197,20 +183,6 @@ describe('Goal lifecycle: turn limits', () => { }) }) -describe('isGoalTerminal', () => { - test('active and paused are NOT terminal', () => { - expect(isGoalTerminal('active')).toBe(false) - expect(isGoalTerminal('paused')).toBe(false) - }) - - test('complete, blocked, budget_limited, usage_limited are terminal', () => { - expect(isGoalTerminal('complete')).toBe(true) - expect(isGoalTerminal('blocked')).toBe(true) - expect(isGoalTerminal('budget_limited')).toBe(true) - expect(isGoalTerminal('usage_limited')).toBe(true) - }) -}) - describe('Goal prompt templates', () => { test('continuation prompt contains objective and audit rules', () => { const goal = setGoal('Build dashboard', { @@ -256,24 +228,6 @@ describe('Goal prompt templates', () => { }) }) -describe('Audit rules consistency', () => { - test('completion audit has 6 rules', () => { - expect(COMPLETION_AUDIT_RULES.length).toBe(6) - }) - - test('blocked audit has 3 rules', () => { - expect(BLOCKED_AUDIT_RULES.length).toBe(3) - }) - - test('continuation prompt embeds all completion audit rules', () => { - const goal = setGoal('Audit check', { sessionId: TEST_SESSION }) - const prompt = buildContinuationPrompt(goal) - for (const rule of COMPLETION_AUDIT_RULES) { - expect(prompt).toContain(rule) - } - }) -}) - describe('Format helpers', () => { test('formatGoalStatusLabel returns human-readable labels', () => { expect(formatGoalStatusLabel('active')).toBe('Active')