feat: add owned dependency preparation and reproducible environment evidence

This commit is contained in:
Agent Workbench Dev
2026-11-01 23:44:45 +08:00
parent e259ddc8da
commit a94807fa60
48 changed files with 1302 additions and 159 deletions
+9
View File
@@ -0,0 +1,9 @@
export const ENVIRONMENT_ACTIVE = new Set(['queued','running','stopping']);
export const environmentPlanSeal = plan => Object.fromEntries(['schemaVersion','id','sessionId','projectId','taskId','runId','diagnosticId','root','workspace','sourceFingerprint','nodeIdentity','dependencyInputs','registry','scripts','offline','timeoutMs','invocation','configFiles','cacheDirectory','lifecycle','installScriptPackages','packageCount'].map(key=>[key,plan[key]]));
export function unresolvedEnvironments(store,projectId) {
return [...(store.core.environment_job?.values() ?? [])].filter(job=>job.projectId===projectId
&& (ENVIRONMENT_ACTIVE.has(job.status) || job.requiresVerification && !job.reconciliation));
}
export function assertEnvironmentsResolved(store,projectId) {
if (unresolvedEnvironments(store,projectId).length) throw Object.assign(new Error('工程依赖正在准备或中断结果待核对,请先处理所属环境记录。'),{status:409});
}
+2 -1
View File
@@ -57,7 +57,8 @@ export function evaluationSeal(batch) {
export function evaluationSampleSeal(batch, sample) {
return { schemaVersion: 1, batchId: batch.id, batchFingerprint: batch.fingerprint, sampleId: sample.id, groupId: sample.groupId,
baseCommit: batch.source.head, definition: evaluationSeal(batch).samples.find(value => value.id === sample.id),
files: sample.files, commands: sample.commands, children: sample.children };
files: sample.files, commands: sample.commands, children: sample.children,
...(sample.environmentInputs ? { environmentInputs:sample.environmentInputs } : {}) };
}
export function evaluationSummary(batch) {
const outcomes = batch.samples.map(sample => sample.report?.summary ?? { original: sample.baselineAttemptedAt ? 'unknown' : 'pending', candidate: ['failed','stopped','unknown'].includes(sample.status) ? sample.status : ['candidate_running','candidate_complete','awaiting_review','paused','collecting','adopting','sealed'].includes(sample.status) ? 'unknown' : 'pending' });
+1
View File
@@ -7,6 +7,7 @@ export const ACTIVE_STATES = new Set(['running', 'awaiting_approval', 'stopping'
export const CORE_KINDS = ['task', 'run', 'step', 'tool', 'artifact', 'check_plan', 'check_job', 'delivery_plan', 'delivery_job', 'change_set', 'context_plan', 'workspace', 'research_target', 'research_job', 'engine_job', 'engine_run', 'browser_plan', 'browser_job', 'task_plan', 'task_proof', 'memory', 'task_checkpoint', 'mcp_job', 'collaboration', 'worker', 'input_attachment'];
CORE_KINDS.push('resume_plan');
CORE_KINDS.push('evaluation');
CORE_KINDS.push('environment_diagnostic','environment_plan','environment_job');
export const timestamp = () => new Date().toISOString();
export const isId = value => typeof value === 'string' && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(value);
+1 -1
View File
@@ -46,7 +46,7 @@ export function updateTaskContract(task, instruction) {
if (current.checks === 'skip') task.constraints.push('用户明确要求无需测试;不得自动扩大为工程测试任务。');
}
export const DIAGNOSTIC_TOOLS = new Set(['inspect_session', 'inspect_project', 'list_files', 'read_file', 'search_files', 'read_artifact', 'inspect_task_plan', 'read_browser_result', 'read_registered_skill',
export const DIAGNOSTIC_TOOLS = new Set(['diagnose_environment','inspect_session', 'inspect_project', 'list_files', 'read_file', 'search_files', 'read_artifact', 'inspect_task_plan', 'read_browser_result', 'read_registered_skill',
'inspect_engine_checks', 'list_research_targets', 'read_research_evidence']);
export const AUTOMATIC_CHECK_TOOLS = new Set(['plan_checks', 'run_checks', 'plan_browser', 'run_browser']);
+1 -1
View File
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
import { isId, accountedTokens, emptyUsage } from './execution.mjs';
import { selectedEngineInput } from './engine-execution.mjs';
export const WORKER_TOOLS = new Set(['inspect_session', 'inspect_project', 'index_project', 'query_code', 'read_artifact',
export const WORKER_TOOLS = new Set(['diagnose_environment','plan_environment','prepare_environment','inspect_session', 'inspect_project', 'index_project', 'query_code', 'read_artifact',
'list_files', 'read_file', 'search_files', 'propose_file', 'propose_patch', 'prepare_change_set', 'plan_checks', 'run_checks']);
export const COLLABORATION_ACTIVE = new Set(['preparing', 'starting', 'running', 'stopping', 'collecting', 'merge_preparing', 'reconciling']);
export const COLLABORATION_CLOSED = new Set(['completed', 'discarded', 'resolved_external']);
+2
View File
@@ -1,4 +1,5 @@
import fs from 'node:fs';
import { assertEnvironmentsResolved } from './environment.mjs';
import path from 'node:path';
export const WORKSPACE_ACTIVE = new Set(['creating', 'verifying', 'registering']);
@@ -18,6 +19,7 @@ export function unresolvedWorkspaces(store, projectId, { exceptId = null, includ
}
export function assertWorkspacesResolved(store, projectId, options) {
assertEnvironmentsResolved(store, projectId);
if (unresolvedWorkspaces(store, projectId, options).length) throw conflict(
'这个项目的Git隔离工作区正在准备、创建或结果待核对,请先在所属会话处理工作区记录。');
}