feat: journal reviewed multi-file changes and recover interrupted batches
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
export const CHANGE_SET_OPEN = new Set(['prepared', 'applying', 'rolling_back', 'unknown', 'partial']);
|
||||
export const CHANGE_SET_ACTIVE = new Set(['applying', 'rolling_back']);
|
||||
|
||||
export function unresolvedChangeSets(store, projectId, { includePrepared = false, exceptId = null } = {}) {
|
||||
return [...(store.core.change_set?.values() ?? [])].filter(value => value.projectId === projectId && value.id !== exceptId
|
||||
&& (value.requiresVerification || CHANGE_SET_ACTIVE.has(value.status) || includePrepared && value.status === 'prepared'));
|
||||
}
|
||||
|
||||
export function assertChangeSetsResolved(store, projectId, options) {
|
||||
if (unresolvedChangeSets(store, projectId, options).length) throw Object.assign(
|
||||
new Error('项目有待审查或结果待核对的多文件变更集,请先在所属任务中处理批次。'), { status: 409 });
|
||||
}
|
||||
|
||||
export function assertProposalUnsealed(store, change) {
|
||||
const set = change.changeSetId ? store.core.change_set?.get(change.changeSetId) : null;
|
||||
if (set && CHANGE_SET_OPEN.has(set.status)) throw Object.assign(
|
||||
new Error('这项提案已经封存到多文件变更集,请审查整个批次,或先撤销未执行的批次。'), { status: 409 });
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
|
||||
|
||||
export const EXECUTION_SCHEMA = 1;
|
||||
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'];
|
||||
export const CORE_KINDS = ['task', 'run', 'step', 'tool', 'artifact', 'check_plan', 'check_job', 'delivery_plan', 'delivery_job', 'change_set'];
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user