feat(review): 人物塑造 advisory 审(第五审,仅建议不阻断验收)
写→审链新增第五审「人物塑造」(灵感③/D2):advisory 单维——仅建议、不阻断
验收(不进 conflicts、不碰 assert_conflicts_resolved、不入 REVIEW_RESERVED_NAMES);
只做人物塑造、不做氛围。
- SPEC characterization_spec(analyst,reads=("characters",),writes=())+
prompts/characterization.md(只读、显式忽略文本长度与辞藻华丽度、引用逐字片段+置信度)
- schema CharacterizationReview{issues[...]}(全字段默认值守解析韧性)+ 注册 catalog
- 计数三处 22→23 + regen prompt_hashes.json(仅加一条)
- DB chapter_reviews 加 characterization JSONB nullable 列(迁移 f6a7b8c9d0e1)
- 接线:graph REVIEW_SPECS 追加 · chain ReviewRecordRepo · collect(extract/record) ·
review_repo(Protocol/Sql/_to_view/ReviewView) · sse(event/factory/section) · normalize 自动纳入
- 契约 ReviewHistoryItem 加 characterization(gen:api 已重生成)
- 前端 sse/history/useReviewStream + CharacterizationPanel(只展示无裁决 UI、置信度降序+低置信折叠)+ ReviewReport 挂面板
- 测试 test_characterization_does_not_block_accept + 计数/golden + collect/normalize + 前端 reducer/normalize/parse
守不变量 #2/#3/#9;依赖 ⑧(motive/appearance 作客观锚点)。
This commit is contained in:
@@ -60,6 +60,22 @@ export interface StyleDriftReport {
|
||||
segments: StyleDriftSegment[];
|
||||
}
|
||||
|
||||
// 人物塑造(灵感③ advisory 单维):只读建议,不阻断验收(无裁决 UI)。
|
||||
// 以人物卡 motive/appearance 为客观锚点;每条带逐字引用 quote + 置信度 confidence。
|
||||
export interface CharacterizationIssue {
|
||||
character: string;
|
||||
aspect: string;
|
||||
where: string;
|
||||
quote: string;
|
||||
diagnosis: string;
|
||||
suggestion: string;
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
export interface CharacterizationReport {
|
||||
issues: CharacterizationIssue[];
|
||||
}
|
||||
|
||||
export interface SectionEvent {
|
||||
event: "section";
|
||||
data: { name: string; status: SectionStatus };
|
||||
@@ -98,6 +114,10 @@ export interface StyleEvent {
|
||||
}[];
|
||||
};
|
||||
}
|
||||
export interface CharacterizationEvent {
|
||||
event: "characterization";
|
||||
data: { issues: CharacterizationIssue[] };
|
||||
}
|
||||
export interface DoneEvent {
|
||||
event: "done";
|
||||
data: { length: number };
|
||||
@@ -112,6 +132,7 @@ export type ReviewSseEvent =
|
||||
| ForeshadowEvent
|
||||
| PaceEvent
|
||||
| StyleEvent
|
||||
| CharacterizationEvent
|
||||
| DoneEvent
|
||||
| ErrorEvent;
|
||||
|
||||
@@ -121,6 +142,7 @@ const KNOWN_EVENTS = new Set([
|
||||
"foreshadow",
|
||||
"pace",
|
||||
"style",
|
||||
"characterization",
|
||||
"done",
|
||||
"error",
|
||||
]);
|
||||
@@ -176,6 +198,34 @@ function asPaceIssues(v: unknown): PaceIssue[] {
|
||||
);
|
||||
}
|
||||
|
||||
function asNumber(v: unknown, fallback = 0): number {
|
||||
return typeof v === "number" && Number.isFinite(v) ? v : fallback;
|
||||
}
|
||||
|
||||
function asStringField(v: unknown): string {
|
||||
return typeof v === "string" ? v : "";
|
||||
}
|
||||
|
||||
// 收窄人物塑造 issues(每字段安全默认,advisory 韧性;缺字段不丢整条)。
|
||||
export function asCharacterizationIssues(v: unknown): CharacterizationIssue[] {
|
||||
if (!Array.isArray(v)) return [];
|
||||
return v.flatMap((x) =>
|
||||
isRecord(x)
|
||||
? [
|
||||
{
|
||||
character: asStringField(x.character),
|
||||
aspect: asStringField(x.aspect),
|
||||
where: asStringField(x.where),
|
||||
quote: asStringField(x.quote),
|
||||
diagnosis: asStringField(x.diagnosis),
|
||||
suggestion: asStringField(x.suggestion),
|
||||
confidence: asNumber(x.confidence),
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}
|
||||
|
||||
function asStyleSegments(v: unknown): StyleEvent["data"]["segments"] {
|
||||
if (!Array.isArray(v)) return [];
|
||||
return v.flatMap((x) =>
|
||||
@@ -248,6 +298,11 @@ function narrowReviewEvent(event: string, data: unknown): ReviewSseEvent | null
|
||||
},
|
||||
}
|
||||
: null;
|
||||
case "characterization":
|
||||
return {
|
||||
event: "characterization",
|
||||
data: { issues: asCharacterizationIssues(data.issues) },
|
||||
};
|
||||
case "done":
|
||||
return typeof data.length === "number"
|
||||
? { event: "done", data: { length: data.length } }
|
||||
@@ -320,6 +375,7 @@ export interface ReviewStreamState {
|
||||
foreshadow: ForeshadowSuggestion[];
|
||||
pace: PaceReport | null;
|
||||
style: StyleDriftReport | null;
|
||||
characterization: CharacterizationReport | null;
|
||||
error: { code: string; message: string; request_id?: string | null } | null;
|
||||
}
|
||||
|
||||
@@ -330,6 +386,7 @@ export const initialReviewState: ReviewStreamState = {
|
||||
foreshadow: [],
|
||||
pace: null,
|
||||
style: null,
|
||||
characterization: null,
|
||||
error: null,
|
||||
};
|
||||
|
||||
@@ -377,6 +434,12 @@ export function reduceReview(
|
||||
})),
|
||||
},
|
||||
};
|
||||
case "characterization":
|
||||
return {
|
||||
...state,
|
||||
phase: "reviewing",
|
||||
characterization: { issues: event.data.issues.map((i) => ({ ...i })) },
|
||||
};
|
||||
case "done":
|
||||
return { ...state, phase: "done" };
|
||||
case "error":
|
||||
|
||||
Reference in New Issue
Block a user