- 续审 Agent 声明(AgentSpec) + 结构化输出契约(ContinuityReview/Conflict 五类) - LangGraph 并行审子图(可扩四审) + collect 落 chapter_reviews 留痕 + review SSE(section/conflict) - 验收-side Repository:章节 accepted 版本晋升 + digest append-only + 审稿留痕/裁决 - API:review(SSE) + reviews 历史 + accept(单原子事务:晋升 version + 终稿 digest + 裁决留痕) - 冲突 gate:未决裁决拦截(CONFLICT_UNRESOLVED);digest 从终稿提炼(不变量#4) - 前端:审稿报告页 + 冲突就地标注 + 裁决(采纳/忽略/手改) + 未决禁验收 + 「本次将更新」清单 - M2 E2E:真实 DB + 多档位 mock 网关零 token 走通 写→审→裁决→验收→摘要入库 - 多 agent 协同台账(PROGRESS.md) + 共享记忆(memory/contracts·decisions·gotchas)
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import type { ReviewHistoryItem } from "@/lib/api/types";
|
|
import { latestReview, normalizeConflicts } from "./history";
|
|
|
|
const item = (
|
|
conflicts: Record<string, unknown>[],
|
|
): ReviewHistoryItem => ({
|
|
id: "00000000-0000-0000-0000-000000000001",
|
|
project_id: "00000000-0000-0000-0000-000000000002",
|
|
chapter_no: 128,
|
|
conflicts,
|
|
});
|
|
|
|
describe("normalizeConflicts", () => {
|
|
it("tightens loose dicts into ReviewConflict, preserving order", () => {
|
|
const out = normalizeConflicts(
|
|
item([
|
|
{
|
|
type: "设定违例",
|
|
where: "第4段",
|
|
refs: ["第30章"],
|
|
suggestion: "统一血脉",
|
|
},
|
|
{ type: "时间线倒错", where: "第8段", refs: [], suggestion: "调整" },
|
|
]),
|
|
);
|
|
expect(out).toEqual([
|
|
{ type: "设定违例", where: "第4段", refs: ["第30章"], suggestion: "统一血脉" },
|
|
{ type: "时间线倒错", where: "第8段", refs: [], suggestion: "调整" },
|
|
]);
|
|
});
|
|
|
|
it("fills safe defaults for missing/wrong-typed fields", () => {
|
|
const out = normalizeConflicts(item([{ where: 42, refs: "x" }]));
|
|
expect(out).toEqual([
|
|
{ type: "未分类", where: "", refs: [], suggestion: "" },
|
|
]);
|
|
});
|
|
|
|
it("returns [] for undefined item or missing conflicts", () => {
|
|
expect(normalizeConflicts(undefined)).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("latestReview", () => {
|
|
it("returns first item (history is newest-first)", () => {
|
|
const a = item([]);
|
|
const b = item([]);
|
|
expect(latestReview([a, b])).toBe(a);
|
|
expect(latestReview([])).toBeUndefined();
|
|
expect(latestReview(undefined)).toBeUndefined();
|
|
});
|
|
});
|