Files
maestro/src/model/types.ts
T
wangjia 217eb6aa1f feat(merge): 自动合并失败时建最高优先级补救任务来完成合并
decide 端 exec_review accept→merge 冲突失败时,不再只是报错留在闸:
自动建一个 P0 easy 补救任务(operations 写明分支/目标/冲突详情与解冲突步骤),
自治项目会自动领取去解决。幂等:补救任务 id 记到原任务 result.mergeTaskId,
已有未结束补救任务则复用不重复建;结束(done/cancelled)后允许新建。

- model/types: TaskResult 加 mergeTaskId 字段
- mappers/orchestrator: 同步透传/补 null
- store.ensureMergeRemediationTask + store.test 覆盖(P0/easy/ready/operations/幂等/可重建)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 09:13:30 +08:00

105 lines
3.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { Complexity } from './complexity.js';
import type { TaskStatus, GateKind } from './status.js';
export type Id = string;
/** 层级上限:一般 ≤3 层,极复杂 ≤4 层 */
export const DEFAULT_MAX_DEPTH = 3;
export const HARD_MAX_DEPTH = 4;
/** 自动执行边界(Easy 任务由后台执行器自动跑到什么程度) */
export type Autonomy = 'manual' | 'auto-easy' | 'auto-approved';
export interface Project {
id: Id;
name: string;
repoPath: string;
defaultBranch: string;
verifyCmd: string | null; // 执行后的校验命令(build/test/lint
autonomy: Autonomy;
model: string | null;
concurrency: number; // 每项目并发执行上限
status: 'active' | 'paused';
logo: string | null; // 自定义 logoURL/仓库内相对路径;null=自动解析)
sortOrder: number; // 侧栏排序(小在前)
createdAt: string;
lastSyncAt: string | null; // 最近一次 todo.json 同步完成时间
}
export interface ApprovalRecord {
gate: GateKind;
action: 'accept' | 'reject';
actor: string;
reason: string | null; // reject 必填(改进意见)
at: string;
}
/** 复审结论:approve=建议通过 / reject=建议拒绝 / null=未复审(复审失败或旧数据) */
export type ReviewVerdict = 'approve' | 'reject';
export interface TaskResult {
branch: string | null;
worktree: string | null;
diffSummary: string | null;
commits: string[];
prUrl: string | null; // 合并后写 merged:<mergeCommit>(复用字段记录合并产物)
summary: string | null; // code review 报告(markdown),旧数据缺省 null
verdict: ReviewVerdict | null; // code review 结论,解析不到 / 复审失败 = null
securitySummary: string | null; // 安全审计报告(markdown),旧数据缺省 null
securityVerdict: ReviewVerdict | null; // 安全审计结论,解析不到 / 审计失败 = null
mergeTaskId: string | null; // 自动合并失败时建的最高优先级补救任务 id(幂等标记)
}
export interface Task {
id: Id;
projectId: Id;
parentId: Id | null;
depth: number; // 1..4
title: string;
complexity: Complexity;
status: TaskStatus;
priority: number;
deps: Id[]; // 兄弟依赖(同层)
// 三选一产出(按复杂度)
plan: string | null; // Hard:分析 + 拆解说明
spec: string | null; // Medium:改动内容 + 为什么
operations: string | null; // Easy:将执行的操作
approvals: ApprovalRecord[];
result: TaskResult | null;
assignee: 'agent' | 'human' | null;
createdAt: string;
updatedAt: string;
}
export type RunKind = 'planner' | 'executor' | 'reviewer' | 'security';
export type RunStatus = 'started' | 'succeeded' | 'failed' | 'cancelled';
export interface Run {
id: Id;
taskId: Id;
kind: RunKind; // planner(产出拆解/方案)| executor(执行改动)| reviewercode review| security(安全审计)
worktree: string | null;
branch: string | null;
status: RunStatus;
startedAt: string;
endedAt: string | null;
transcriptRef: string | null; // agent 转录日志文件路径
claudeSessionId: string | null;
error: string | null;
}
export type EventType =
| 'task.created' | 'task.updated' | 'status.changed'
| 'approval.requested' | 'approval.granted' | 'approval.rejected'
| 'run.started' | 'run.finished'
| 'project.synced';
export interface Event {
id: Id;
projectId: Id;
taskId: Id | null;
type: EventType;
payload: Record<string, unknown>;
at: string;
}