22 lines
2.0 KiB
JavaScript
22 lines
2.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { fixture, launchWorkbench } from './helpers.mjs';
|
|
import { beginPlanTask, completeRead } from './fixtures/task-plan-fixture.mjs';
|
|
|
|
test('requirements HTTP binds selection, enforces optimistic revisions, restores original proofs and leaves provider history untouched', async t => {
|
|
const f = fixture(t); beginPlanTask(f, '研究当前README.md,不修改。'); const read = completeRead(f), taskId = f.session.taskId, runId = f.session.runId;
|
|
const original = structuredClone(f.session.providerMessages); f.store.close();
|
|
let host = await launchWorkbench(t, f.data); const route = '/sessions/' + f.session.id;
|
|
const input = { taskId, runId, expected_revision: 0, requirements: [{ key: 'research', title: '研究原文件', criterion: '依据真实读取', kind: 'analysis', tools: ['read_file'], method: 'evidence',
|
|
source: { kind: 'goal', id: taskId, start: 0, end: 7 } }] };
|
|
await assert.rejects(host.api(route + '/requirements?taskId=wrong'), /所选任务/);
|
|
await assert.rejects(host.api(route + '/requirements', { ...input, runId: taskId }), /原任务或运行/);
|
|
const saved = await host.api(route + '/requirements', input); assert.equal(saved.requirements.items[0].status, 'pending');
|
|
await assert.rejects(host.api(route + '/requirements', input), /修订/);
|
|
const result = await host.api(route + '/requirement-proofs', { taskId, runId, expected_revision: 1, key: 'research', evidence_id: read.id });
|
|
assert.equal(result.requirements.all_resolved, true);
|
|
const before = await host.api(route + '/export'); await host.close(); host = await launchWorkbench(t, f.data);
|
|
const restored = await host.api(route + '/requirements?taskId=' + taskId); assert.equal(restored.all_resolved, true); assert.equal(restored.history.length, 1);
|
|
const after = await host.api(route + '/export'); assert.deepEqual(after.session.providerMessages, original); assert.deepEqual(before.session.providerMessages, original);
|
|
});
|