test: drive workspace review continuation from recorded results
This commit is contained in:
@@ -50,14 +50,17 @@ test('isolated model Task applies a batch, executes real checks and commits at t
|
||||
if (!input?.messages) return { data: [{ id: 'workspace-http-fixture' }] };
|
||||
const lastUser = input.messages.findLastIndex(value => value.role === 'user'), results = input.messages.slice(lastUser + 1)
|
||||
.filter(value => value.role === 'tool').map(value => JSON.parse(value.content));
|
||||
if (!results.length) return completion([call('plan-' + mode, 'plan_checks', {})]);
|
||||
if (results.length === 1) return completion([call('check-' + mode, 'run_checks', { plan_id: results[0].id })]);
|
||||
if (results.length === 2 && mode === 'repair') return completion([
|
||||
const feedback = input.messages.filter(value => value.role === 'system').map(value => { try { return JSON.parse(value.content.split('\n').at(-1)); } catch { return {}; } })
|
||||
.find(value => value.latest_tools)?.data.entries.map(entry => entry.result);
|
||||
const latestResults = feedback ?? results, latest = latestResults.at(-1);
|
||||
if (!latest || mode === 'delivery' && latest.change_set_id) return completion([call('plan-' + mode, 'plan_checks', {})]);
|
||||
if (latest.id && Array.isArray(latest.checks)) return completion([call('check-' + mode, 'run_checks', { plan_id: latest.id })]);
|
||||
if (latest.check_status === 'failed' && mode === 'repair') return completion([
|
||||
call('isolate-add', 'propose_file', { path: 'src/add.mjs', content: "import { sum } from './math.mjs';\nexport const add = sum;\n", reason: 'Repair only the isolated module' }),
|
||||
call('isolate-math', 'propose_file', { path: 'src/math.mjs', content: 'export const sum = (a,b) => a+b;\n', reason: 'Add isolated arithmetic helper' }),
|
||||
]);
|
||||
if (results.length === 4 && mode === 'repair') return completion([call('isolate-batch', 'prepare_change_set', { change_ids: results.filter(value => value.change_id).map(value => value.change_id) })]);
|
||||
if (results.length === 2 && mode === 'delivery') return completion([
|
||||
if (latest.change_id && mode === 'repair') return completion([call('isolate-batch', 'prepare_change_set', { change_ids: latestResults.filter(value => value.change_id).map(value => value.change_id) })]);
|
||||
if (latest.check_status === 'passed' && mode === 'delivery') return completion([
|
||||
call('isolated-delivery-plan', 'plan_delivery', { message: 'feat: repair isolated addition' }),
|
||||
call('after-review-must-not-run', 'run_command', { command: "Set-Content -LiteralPath 'AFTER-REVIEW.txt' -Value 'unexpected'", reason: 'This deferred call must be interrupted at review' }),
|
||||
]);
|
||||
@@ -78,11 +81,14 @@ test('isolated model Task applies a batch, executes real checks and commits at t
|
||||
const taskId = session.execution.task.id, batch = session.execution.changeSets.at(-1);
|
||||
await host.api(route + '/change-sets/' + batch.id + '/apply', { fingerprint: batch.fingerprint });
|
||||
await until(async () => { session = await host.api(route); return session.execution.changeSets.at(-1).status === 'completed'; });
|
||||
assert.equal(session.status, 'paused'); assert.equal(session.execution.task.verification.status, 'failed');
|
||||
assert.equal(session.messages.filter(value => value.role === 'user').length, 1);
|
||||
mode = 'delivery'; await host.api(route + '/continue-reviewed', {});
|
||||
await until(async () => { session = await host.api(route); return session.status === 'awaiting_approval'; });
|
||||
await host.api(route + '/approvals/' + session.approvals.at(-1).id, { allow: true });
|
||||
await until(async () => { session = await host.api(route); return session.execution.run.stopReason === 'git_review'; }, 30000);
|
||||
assert.equal(session.execution.task.id, taskId); assert.equal(session.execution.checks.at(-1).status, 'passed');
|
||||
assert.equal(session.execution.run.source, 'review-action'); assert.equal(session.messages.filter(value => value.role === 'user').length, 1);
|
||||
assert.equal(session.execution.checks.at(-1).results[0].tests.passed, 3);
|
||||
assert.equal(session.approvals.length, 2); assert.equal(fs.existsSync(path.join(plan.root, 'AFTER-REVIEW.txt')), false);
|
||||
const requests = model.requests.length, deliveryPlan = session.execution.deliveryPlans.at(-1);
|
||||
|
||||
Reference in New Issue
Block a user