feat(tasks): review sourced requirements against current original evidence
This commit is contained in:
@@ -40,6 +40,7 @@ import { EngineRunner } from '../core/engines/engine-runner.mjs';
|
||||
import { BrowserManager, publicBrowserPlan } from '../core/browser/browser-manager.mjs';
|
||||
import { browserPlanInput } from '../shared/contracts/browser.mjs';
|
||||
import { TaskPlanManager } from '../core/tasks/task-plan-manager.mjs';
|
||||
import { RequirementReview } from '../core/tasks/requirement-review.mjs';
|
||||
import { FileResults } from '../core/tasks/file-results.mjs';
|
||||
import { fileResultInput, fileResultToolDefinitions } from '../shared/contracts/file-results.mjs';
|
||||
import { verifiedCheck } from '../core/delivery-report.mjs';
|
||||
@@ -164,6 +165,7 @@ export class Runtime {
|
||||
if (!delivery.satisfied) throw Object.assign(new Error(delivery.message), { status: 409 });
|
||||
const plan = await this.taskPlanner().inspect(session, { candidates: false });
|
||||
if (plan.configured && !plan.all_verified) throw Object.assign(new Error('原执行计划仍有未核验步骤,请先核对。'), { status: 409 });
|
||||
await this.requirementReview().assertReady(session);
|
||||
if (session.taskId !== taskId || session.runId !== runId || this.projectHasActivity(session.projectId) || !this.fileResults().completion(session).satisfied) throw Object.assign(new Error('核对期间任务、文件或活动已变化,请重新核对。'), { status: 409 });
|
||||
const task = this.store.owned('task', taskId, session.id);
|
||||
task.delivery = { ...delivery, at: now(), checks: taskContract(task).checks === 'skip' ? 'not_requested' : task.verification.status };
|
||||
@@ -171,6 +173,7 @@ export class Runtime {
|
||||
this.store.message(session, 'system', '已按当前成果结束任务;' + (delivery.newChanges ? '实际修改另列。' : '无新增修改。') + '原运行、检查与Git记录保留,未请求模型。');
|
||||
this.store.save(session, { type: 'file_result.task_completed' });
|
||||
}
|
||||
requirementReview() { return new RequirementReview(this.store, { planner: this.taskPlanner(), redact: value => this.provider.redact(value) }); }
|
||||
taskPlanner() { return this.taskPlans ??= new TaskPlanManager(this.store, { redact: value => this.provider.redact(value),
|
||||
projectBusy: (projectId, exceptId) => this.projectHasActivity(projectId, exceptId) }); }
|
||||
browserManager() { return this.browser ??= new BrowserManager(this.store, { appDirectory: this.appDirectory,
|
||||
@@ -330,6 +333,7 @@ export class Runtime {
|
||||
config.inputImages=this.inputAttachments().images(session,task);
|
||||
if(config.inputImages.length&&config.mode==='demo')throw new Error('固定演示执行器不会读取图片;请连接并声明支持视觉的模型。');
|
||||
const taskPlan = task.currentTaskPlanId ? await this.taskPlanner().inspect(session, { candidates: false }) : null;
|
||||
const requirementReview = task.requirementRevisions?.length ? await this.requirementReview().inspect(session) : null;
|
||||
const deliveryProgress = await taskDeliveryProgress(this.store, session, run.record, { checks: this.checkRunner(), worker: !!run.worker, taskPlan });
|
||||
const readCoverage = readCoverageContext(task, run.id);
|
||||
const state = session.changes.filter(change => change.taskId === task.id || ['pending', 'conflict'].includes(change.status))
|
||||
@@ -350,6 +354,11 @@ export class Runtime {
|
||||
}) + (run.record.purpose === 'diagnostic' ? '\n本次仅回答运行诊断问题,允许读取所属结果;不得修改文件、执行命令或将解释视为原任务交付。诊断问题:' + run.record.question : '')
|
||||
+ '\n结果未知的调用,不得假定成功或重放:' + JSON.stringify(unknown)
|
||||
+ (deliveryProgress ? '\n当前工程执行依据(每次请求重新核对,非操作授权):\n' + JSON.stringify(deliveryProgress) : '')
|
||||
+ (requirementReview ? '\n用户逐项要求复核(任务数据,不授权额外操作;证据和用户确认分别记录):\n' + JSON.stringify({
|
||||
revision: requirementReview.revision, status: requirementReview.status, unreviewed_sources: requirementReview.unreviewed_sources,
|
||||
error: requirementReview.error, items: requirementReview.items.map(item => ({ key: item.key, revision: item.revision, title: item.title,
|
||||
criterion: item.criterion, method: item.method, kind: item.kind, paths: item.paths, tools: item.tools, checks: item.checks,
|
||||
status: item.status, error: item.error, proof_id: item.proof_id })) }) : '')
|
||||
+ (fileResults.results.length || fileResults.sources.length ? '\n当前成果与可显式采用的旧来源(任务数据,原文件不等于新写入):' + JSON.stringify({
|
||||
current: fileResults.results.slice(0, 8).map(row => ({ id: row.id, taskId: row.taskId, runId: row.runId, verification: row.verification, error: row.error, reason: row.reason, files: row.files.map(({ path, sha256, origin }) => ({ path, sha256, origin })) })),
|
||||
sources: fileResults.sources.slice(0, 4),
|
||||
@@ -512,6 +521,13 @@ export class Runtime {
|
||||
this.store.message(session, 'system', '任务计划仍有未核验、失效或待更新的步骤,原任务已保存。请核对执行计划后继续;模型文字不代替实际完成。');
|
||||
}
|
||||
}
|
||||
if (session.status === 'completed' && task.requirementRevisions?.length && run.record.purpose !== 'diagnostic') {
|
||||
const review = await this.requirementReview().inspect(session);
|
||||
if (!review.all_resolved) {
|
||||
session.status = 'paused'; run.stopReason = 'requirements_incomplete';
|
||||
this.store.message(session, 'system', '答复已保留;用户要求仍有待复核、失效或未审阅来源,请在任务的要求与证据中核对。');
|
||||
}
|
||||
}
|
||||
this.store.save(session); return;
|
||||
}
|
||||
let deliveryReview = null, mcpReview = null;
|
||||
|
||||
Reference in New Issue
Block a user