Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6302247
chore: sync acceptance sources with current main
codezzzsleep Nov 19, 2026
390e9e6
feat: bind per-check acceptance references to fixed gate evidence
codezzzsleep Nov 19, 2026
5ed41d7
feat: offer bound evidence references to acceptance reviewers
codezzzsleep Nov 19, 2026
beac21a
docs: explain compatible acceptance evidence references
codezzzsleep Nov 19, 2026
603b55e
fix: preserve committed acceptance retries while checking new references
codezzzsleep Nov 19, 2026
8e67254
fix: surface structured acceptance validation errors to reviewers
codezzzsleep Nov 19, 2026
f9d74c2
fix: compare evidence reference choices by their bindings
codezzzsleep Nov 19, 2026
4fd0986
ci: revalidate PR #572 against current upstream
codezzzsleep Nov 21, 2026
20fca18
fix: retain current requirement delivery in acceptance evidence input
codezzzsleep Nov 21, 2026
d2ff638
merge: integrate current main into acceptance evidence
codezzzsleep Nov 23, 2026
2c0f75d
test: preserve fixed evidence for assigned review-only actors
codezzzsleep Nov 23, 2026
95321bc
test: run acceptance evidence regressions in release gates
codezzzsleep Nov 23, 2026
395b8f0
merge: refresh acceptance evidence against current upstream
codezzzsleep Nov 23, 2026
9f23f5d
merge: align acceptance evidence with synchronized upstream
codezzzsleep Nov 23, 2026
688c516
fix: compare queued PR lint against the actual merge base
codezzzsleep Nov 23, 2026
413dd0d
fix: keep acceptance retries compatible with empty evidence references
codezzzsleep Nov 24, 2026
e799b52
fix: align task error messages with upstream dispatch
codezzzsleep Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 80 additions & 13 deletions client/main/pi-session/acceptance-turn.js

Large diffs are not rendered by default.

128 changes: 110 additions & 18 deletions client/main/pi-session/task-input.js

Large diffs are not rendered by default.

125 changes: 123 additions & 2 deletions client/tests/acceptance-turn.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,72 @@ function fixture(t, overrides = {}) {
return { context, calls, notices, runtime, request, cwd };
}

function reviewTimeline() {
return { schemaVersion: 1, revision: 'timeline-v1', executionContextIncluded: true, rows: [
{ kind: 'requirement', at: null, text: 'Original target: 400 words.' },
{ kind: 'supplement', at: '2026-11-15T01:00:00Z', text: 'Updated target: 200 words.' },
{ kind: 'rework', at: '2026-11-15T02:00:00Z', text: 'Returned for revision: 300 words.' },
{ kind: 'supplement', at: '2026-11-15T03:00:00Z', text: 'Latest target: 250 words.' },
] };
}

for (const mode of ['manual', 'auto']) test(`${mode} review includes supplemental and rejection history without promoting the generated draft`, async t => {
const f = fixture(t, { requirementTimeline: reviewTimeline(), requirementTimelineRevision: 'timeline-v1' });
const draft = '【自动验收】\nOriginal target: 400 words.';
const turn = await prepare({ identity: {}, taskId: 't', instruction: draft,
requested: { acceptanceMode: mode, acceptanceDraft: draft, acceptanceInstruction: 'Check spelling.' },
runtime: f.runtime, request: f.request });
for (const text of ['Original target: 400', 'Updated target: 200', 'Returned for revision: 300', 'Latest target: 250']) {
assert.ok(turn.text.includes(text), text);
assert.ok(turn.displayText.includes(text), text);
}
assert.match(turn.text, /真实记录时间最新/);
assert.equal(turn.text.split('Original target: 400').length - 1, 1);
assert.match(turn.text, /本轮验收人新增说明.*\nCheck spelling/);
assert.match(turn.text, /保持原验收标准的 criterion 编号/);
await turn.beforeTurn();
if (mode === 'auto') {
fs.writeFileSync(turn.reportPath, JSON.stringify({ verdict: 'approve', summary: 'Checked the latest target',
checks: [{ criterion: 'c1', result: 'pass', evidence: 'Latest supplemental target from 03:00 is 250 words; counted 250.' }] }));
await turn.afterTurn('completed');
assert.equal(f.calls.find(c => c.body).body.requirementTimelineRevision, 'timeline-v1');
assert.doesNotMatch(JSON.stringify(f.calls.find(c => c.body).body), /local:model|apiKey|requirementTimeline":/);
}
});

test('queued and completed analysis reject changed supplemental history even when artifact and requirement versions stay unchanged', async t => {
const f = fixture(t, { requirementTimeline: reviewTimeline(), requirementTimelineRevision: 'timeline-v1' });
const turn = await prepare({ identity: {}, taskId: 't', runtime: f.runtime, request: f.request });
f.context.requirementTimeline.rows.push({ kind: 'rework', at: '2026-11-15T04:00:00Z', text: 'A later correction.' });
await assert.rejects(turn.beforeTurn(), /补充说明或退回意见/);
await assert.rejects(turn.afterTurn('completed', {}), /补充说明或退回意见/);
assert.equal(f.notices.length, 0);
assert.ok(f.calls.every(c => !c.body));
});

test('incomplete or mismatched history packets cannot silently fall back to the original requirement', async t => {
for (const timeline of [{ schemaVersion: 2, rows: [] }, { ...reviewTimeline(), revision: 'different' }]) {
const f = fixture(t, { requirementTimeline: timeline, requirementTimelineRevision: 'timeline-v1' });
await assert.rejects(prepare({ identity: {}, taskId: 't', runtime: f.runtime, request: f.request }), /格式或版本不完整/);
assert.ok(f.calls.every(c => !c.body));
}
});

test('prompt compaction preserves every supplemental record or rejects instead of dropping conflicting requirements', async t => {
const timeline = reviewTimeline();
timeline.rows[1].text = 'EARLY-SUPPLEMENT-' + 'x'.repeat(7000) + '-SUPPLEMENT-END';
const f = fixture(t, { requirementTimeline: timeline, requirementTimelineRevision: timeline.revision,
artifact: { manifest: 'Large delivery manifest '.repeat(4000) } });
const turn = await prepare({ identity: {}, taskId: 't', requested: { acceptanceMode: 'auto' },
runtime: f.runtime, request: f.request });
assert.ok(turn.text.includes(timeline.rows[1].text));
assert.ok(turn.text.includes('Latest target: 250 words.'));
assert.ok(turn.text.length <= 50000);
timeline.rows[1].text = 'x'.repeat(51000) + 'Latest critical sentence.';
await assert.rejects(prepare({ identity: {}, taskId: 't', runtime: f.runtime, request: f.request }), /超过.*限制/);
assert.ok(f.calls.every(c => !c.body));
});

test('人工分析使用验收提示与固定版本,完成后不提交决策或执行原需求', async t => {
const f = fixture(t);
const turn = await prepare({ identity: {}, taskId: 't', instruction: '检查文风',
Expand All @@ -32,7 +98,9 @@ test('人工分析使用验收提示与固定版本,完成后不提交决策
assert.match(turn.text, /交付成果/);
assert.match(turn.text, /验收确认卡/);
assert.deepEqual(turn.attachmentIds, ['file-a']);
assert.equal(turn.afterTurn, undefined);
assert.equal(typeof turn.afterTurn, 'function');
await turn.afterTurn('stopped');
assert.equal(f.notices.length, 0);
assert.ok(f.calls.every(c => !c.body));
});

Expand All @@ -56,6 +124,57 @@ test('自动验收仅在本轮成功并提供完整报告后提交当前固定
assert.doesNotMatch(f.notices[0][1], /c1:/);
});

test('automatic review offers bound evidence references to the model and retains them in the report', async t => {
const ref = { kind: 'file', ref: 'file-a', fingerprint: 'a'.repeat(64) };
const f = fixture(t, { evidenceRefOptions: [ref] });
const turn = await prepare({ identity: {}, taskId: 't', requested: { acceptanceMode: 'auto' },
runtime: f.runtime, request: f.request });
assert.match(turn.text, /evidenceRefs/);
assert.ok(turn.text.includes(ref.fingerprint));
assert.doesNotMatch(turn.displayText, /evidenceRefs|fingerprint|file-a/);
const refs = [{ ...ref, note: 'Checked the fixed file contents' }];
fs.writeFileSync(turn.reportPath, JSON.stringify({ verdict: 'approve', summary: 'Counted 400 words',
checks: [{ criterion: 'c1', result: 'pass', evidence: 'Read the entire file and counted 400 words', evidenceRefs: refs }] }));
await turn.afterTurn('completed');
assert.deepEqual(f.calls.find(call => call.body).body.report.checks[0].evidenceRefs, refs);
});

test('large review context omits complete reference choices without truncating identities or fingerprints', async t => {
const refs = Array.from({ length: 100 }, (_, i) => ({ kind: 'file', ref: 'file-' + i + '-' + 'x'.repeat(180), fingerprint: 'a'.repeat(64) }));
const f = fixture(t, { evidenceRefOptions: refs, artifact: { manifest: 'Large manifest '.repeat(4000) } });
const turn = await prepare({ identity: {}, taskId: 't', requested: { acceptanceMode: 'auto' },
runtime: f.runtime, request: f.request });
const section = turn.text.split('可选 evidenceRefs(内部版本引用):\n')[1].split('\n\n')[0];
const emitted = section.split('\n').filter(line => line.startsWith('{')).map(line => JSON.parse(line));
assert.ok(emitted.length > 0 && emitted.length < refs.length);
for (const ref of emitted) assert.ok(refs.some(source => JSON.stringify(source) === JSON.stringify(ref)));
assert.ok(turn.text.length <= 50000);
assert.doesNotMatch(turn.displayText, /fingerprint|file-0/);
});

test('queued automatic review rejects changed reference choices or a Hub that no longer supports them', async t => {
for (const change of ['changed', 'unsupported']) {
const f = fixture(t, { evidenceRefOptions: [{ kind: 'file', ref: 'file-a', fingerprint: 'a'.repeat(64) }] });
const turn = await prepare({ identity: {}, taskId: 't', requested: { acceptanceMode: 'auto' },
runtime: f.runtime, request: f.request });
if (change === 'changed') f.context.evidenceRefOptions[0].fingerprint = 'b'.repeat(64);
else delete f.context.evidenceRefOptions;
await assert.rejects(turn.beforeTurn(), /验收版本已变化/);
assert.ok(f.calls.every(call => !call.body));
}
});

test('queued automatic review accepts equivalent reference choices in a different list or object-field order', async t => {
const refs = [{ kind: 'file', ref: 'file-a', fingerprint: 'a'.repeat(64) },
{ kind: 'text', ref: 'artifact:v1:text', fingerprint: 'b'.repeat(64) }];
const f = fixture(t, { evidenceRefOptions: refs });
const turn = await prepare({ identity: {}, taskId: 't', requested: { acceptanceMode: 'auto' },
runtime: f.runtime, request: f.request });
f.context.evidenceRefOptions = refs.toReversed().map(ref => ({ fingerprint: ref.fingerprint, ref: ref.ref, kind: ref.kind }));
await turn.beforeTurn();
assert.ok(f.calls.every(call => !call.body));
});

test('停止、失败、缺报告和标准不足都不自动批准', async t => {
const f = fixture(t);
const turn = await prepare({ identity: {}, taskId: 't', requested: { acceptanceMode: 'auto' },
Expand All @@ -73,7 +192,9 @@ test('manual-only deliveries reject automatic review before execution, including
const options = { identity: {}, taskId: 't', requested: { acceptanceMode: 'auto' }, runtime: f.runtime, request: f.request };
await assert.rejects(prepare(options), /手动验收/);
const analysis = await prepare({ ...options, requested: {} });
assert.equal(analysis.afterTurn, undefined);
assert.equal(typeof analysis.afterTurn, 'function');
await analysis.afterTurn('failed');
assert.equal(f.notices.length, 0);
f.context.readiness.requiresHumanConfirmation = false;
const queued = await prepare(options);
f.context.readiness.requiresHumanConfirmation = true;
Expand Down
Loading
Loading