feat: add durable isolated Git workspaces and source-bound delivery

This commit is contained in:
Agent Workbench Dev
2026-10-29 23:22:30 +08:00
parent 7d60dc9c55
commit 7d9bfb85da
22 changed files with 1038 additions and 26 deletions
+6
View File
@@ -6,6 +6,8 @@ import { StringDecoder } from 'node:string_decoder';
import { inspectProject, createCheckList } from './project-inspector.mjs';
import { safePath } from '../server/files.mjs';
import { assertChangeSetsResolved } from '../shared/contracts/change-sets.mjs';
import { assertWorkspacesResolved } from '../shared/contracts/workspaces.mjs';
import { verifyWorkspaceProject } from './workspaces/git-workspaces.mjs';
const at = () => new Date().toISOString();
const conflict = message => Object.assign(new Error(message), { status: 409 });
@@ -54,6 +56,8 @@ export class CheckRunner {
async plan(session, names) {
assertChangeSetsResolved(this.store, session.projectId);
assertWorkspacesResolved(this.store, session.projectId, { includePrepared: true });
await verifyWorkspaceProject(this.store, this.store.project(session.projectId));
if (!session.taskId || !session.runId) throw conflict('先发送一个项目任务,再识别本任务的检查计划。');
const identity = { taskId: session.taskId, runId: session.runId };
const inspection = await inspectProject(this.store.project(session.projectId));
@@ -81,6 +85,7 @@ export class CheckRunner {
async start(session, planId, { signal, source = 'user' } = {}) {
assertChangeSetsResolved(this.store, session.projectId, { includePrepared: true });
assertWorkspacesResolved(this.store, session.projectId, { includePrepared: true });
const plan = this.planFor(session, planId);
if (this.projectActive(session.projectId) || this.projectBusy(session.projectId, source === 'agent' ? session.id : null)) throw conflict('同一项目正在执行任务或检查,请等待结束后再运行。');
if (session.changes.some(change => ['pending', 'conflict'].includes(change.status))) throw conflict('先应用或撤回本任务的待审查改动,再检查实际工程。');
@@ -104,6 +109,7 @@ export class CheckRunner {
async execute(session, plan, job, run, signal) {
const task = this.store.core.task.get(job.taskId);
try {
await verifyWorkspaceProject(this.store, this.store.project(session.projectId));
const before = await inspectProject(this.store.project(session.projectId));
signal.throwIfAborted();
if (before.fingerprint !== plan.fingerprint) throw conflict('检查计划创建后工程或Git基线已变化,请重新识别再执行。');