fix(qa): 实施 4 组设计型 QA 项——规则删除/codex 角色/大纲卷过滤/文风回炉锚点
#5 规则 DELETE + id:暴露 RuleView.id(PK);新增 DELETE /projects/{id}/rules/{rule_id} (项目/规则不存在→404,成功→204,按 (id,project_id) 限定);rule_repo 加 list_for_project/delete;RulesPage 每条加删除(乐观删+回滚+toast)。assemble 侧 RuleView(缓存前缀)不动,列表另立 RuleListItemView。 #7 codex 角色 relations:写侧本已持久化、读端点 _existing_characters 硬编码 []。 加 _relations_from_jsonb 解析 {name,kind,note},CodexPage 渲染关系 chip。 #8 角色入库幂等:SqlCharacterWriteRepo.create 改 (project_id,name) app 层 upsert—— 重复入库改更新而非插入;不加 UNIQUE/迁移(线上已有重复行会让约束迁移失败)。 #1 大纲卷过滤:GET /outline 支持可选 ?volume(无参=全部,向后兼容);OutlineEditor 加「查看:全部/卷N」筛选,与生成目标卷解耦。 H3/#9 文风回炉锚点:StyleDriftSegment 加 text(逐字命中段),style.md 指示审稿输出; 前端按内容锚点定位回炉目标(idx 仅排序),命中失败 → 提示「无法定位该段」而非 静默 no-op。style golden fixture 已重生成。 契约变更已 pnpm gen:api(RuleView.id / DELETE rules / outline ?volume)。无迁移 (alembic 无漂移)。门禁绿:ruff/mypy(210)/alembic/pytest 760 · 前端 tsc/lint/vitest 329。
This commit is contained in:
@@ -46,8 +46,11 @@ export interface PaceReport {
|
||||
}
|
||||
|
||||
// 文风漂移(第四审,C4 扩 T4.2):整体相似度 score + 段级漂移。
|
||||
// `text` = 该漂移段从草稿逐字摘录的原文(内容锚,供前端内容匹配定位回炉目标,
|
||||
// 不靠位置 idx;旧数据/降级可为空串)。
|
||||
export interface StyleDriftSegment {
|
||||
idx: number;
|
||||
text: string;
|
||||
score: number;
|
||||
label: string | null;
|
||||
}
|
||||
@@ -89,6 +92,7 @@ export interface StyleEvent {
|
||||
score: number;
|
||||
segments: {
|
||||
idx: number;
|
||||
text?: string | null;
|
||||
score: number;
|
||||
label?: string | null;
|
||||
}[];
|
||||
@@ -176,7 +180,14 @@ function asStyleSegments(v: unknown): StyleEvent["data"]["segments"] {
|
||||
if (!Array.isArray(v)) return [];
|
||||
return v.flatMap((x) =>
|
||||
isRecord(x) && typeof x.idx === "number" && typeof x.score === "number"
|
||||
? [{ idx: x.idx, score: x.score, label: nullableString(x.label) }]
|
||||
? [
|
||||
{
|
||||
idx: x.idx,
|
||||
text: nullableString(x.text),
|
||||
score: x.score,
|
||||
label: nullableString(x.label),
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}
|
||||
@@ -360,6 +371,7 @@ export function reduceReview(
|
||||
score: event.data.score,
|
||||
segments: event.data.segments.map((s) => ({
|
||||
idx: s.idx,
|
||||
text: s.text ?? "",
|
||||
score: s.score,
|
||||
label: s.label ?? null,
|
||||
})),
|
||||
|
||||
@@ -8,15 +8,28 @@ import {
|
||||
} from "./sse";
|
||||
|
||||
describe("parseReviewBlock — style (C4 扩 T4.2)", () => {
|
||||
it("parses a style frame", () => {
|
||||
it("parses a style frame carrying the text anchor", () => {
|
||||
const evt = parseReviewBlock(
|
||||
'event:style\ndata:{"score":87,"segments":[{"idx":3,"score":60,"label":"口语化"}]}',
|
||||
'event:style\ndata:{"score":87,"segments":[{"idx":3,"text":"原文锚","score":60,"label":"口语化"}]}',
|
||||
);
|
||||
expect(evt).toEqual({
|
||||
event: "style",
|
||||
data: {
|
||||
score: 87,
|
||||
segments: [{ idx: 3, score: 60, label: "口语化" }],
|
||||
segments: [{ idx: 3, text: "原文锚", score: 60, label: "口语化" }],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("defaults missing segment text to null when parsing", () => {
|
||||
const evt = parseReviewBlock(
|
||||
'event:style\ndata:{"score":87,"segments":[{"idx":3,"score":60}]}',
|
||||
);
|
||||
expect(evt).toEqual({
|
||||
event: "style",
|
||||
data: {
|
||||
score: 87,
|
||||
segments: [{ idx: 3, text: null, score: 60, label: null }],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -32,17 +45,20 @@ describe("reduceReview — style (replace-style like pace)", () => {
|
||||
it("sets style report and marks reviewing", () => {
|
||||
const evt: ReviewSseEvent = {
|
||||
event: "style",
|
||||
data: { score: 80, segments: [{ idx: 1, score: 50, label: "突兀" }] },
|
||||
data: {
|
||||
score: 80,
|
||||
segments: [{ idx: 1, text: "原文锚", score: 50, label: "突兀" }],
|
||||
},
|
||||
};
|
||||
const out = reduceReview(initialReviewState, evt);
|
||||
expect(out.phase).toBe("reviewing");
|
||||
expect(out.style).toEqual({
|
||||
score: 80,
|
||||
segments: [{ idx: 1, score: 50, label: "突兀" }],
|
||||
segments: [{ idx: 1, text: "原文锚", score: 50, label: "突兀" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("replaces (not accumulates) the style report and defaults label null", () => {
|
||||
it("replaces (not accumulates) the style report and defaults text/label", () => {
|
||||
const first = reduceReview(initialReviewState, {
|
||||
event: "style",
|
||||
data: { score: 70, segments: [{ idx: 0, score: 40 }] },
|
||||
@@ -51,7 +67,12 @@ describe("reduceReview — style (replace-style like pace)", () => {
|
||||
event: "style",
|
||||
data: { score: 95, segments: [] },
|
||||
});
|
||||
expect(first.style?.segments[0]).toEqual({ idx: 0, score: 40, label: null });
|
||||
expect(first.style?.segments[0]).toEqual({
|
||||
idx: 0,
|
||||
text: "",
|
||||
score: 40,
|
||||
label: null,
|
||||
});
|
||||
expect(second.style).toEqual({ score: 95, segments: [] });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user