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:
Yaojia Wang
2026-06-25 12:53:03 +02:00
parent e60eff7aa1
commit bf39f50b2f
33 changed files with 907 additions and 99 deletions

View File

@@ -146,6 +146,9 @@ export interface paths {
*
* `body.directive`可选T4-b是临时本章指令直通 assemble→volatile不持久化
* 无 body 的旧调用方仍可用(向后兼容)。
*
* 项目不存在 → 404在触网关前 fail-fast否则非法 project_id 会静默烧一次付费/限流的
* LLM 调用并返回 200QA C1
*/
post: operations["stream_draft_projects__project_id__chapters__chapter_no__draft_post"];
delete?: never;
@@ -286,7 +289,8 @@ export interface paths {
* Get Outline
* @description 读取已持久化的大纲(逐章,按 chapter_no 升序)。
*
* 项目不存在 → 404项目存在但尚无大纲 → 200 空列表(非 404页面初次访问的常态)。
* 可选 `?volume=N`:只返回该卷的章节(前端按卷切换);不传 → 全部章节(向后兼容)。
* 项目不存在 → 404项目存在但尚无大纲或该卷无章节→ 200 空列表(非 404
* DB `outline.beats` 是 JSONB `{"beats": [...]}` → 解包成裸 `list[str]`(与 POST 响应同形,
* 前端 OpenAPI 类型对齐)。读侧复用 C5 assemble 的 `OutlineRepo`,不写库。
*/
@@ -312,13 +316,15 @@ export interface paths {
};
/**
* List Rules
* @description 规则列表(按读侧顺序)。规则页用
* @description 规则列表(带 id供前端删除 handle。项目不存在 → 404QA MEDIUM此前返误导性空 200
*/
get: operations["list_rules_projects__project_id__rules_get"];
put?: never;
/**
* Create Rule
* @description 新增一条规则201。非法 level / 空 content → FastAPI 422。
* @description 新增一条规则201。非法 level / 空 content → FastAPI 422;项目不存在 → 404
*
* 项目存在性须在 insert 前校验:否则 FK 违例会逃逸成 500QA H2而非干净的 404。
*/
post: operations["create_rule_projects__project_id__rules_post"];
delete?: never;
@@ -327,6 +333,29 @@ export interface paths {
patch?: never;
trace?: never;
};
"/projects/{project_id}/rules/{rule_id}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
post?: never;
/**
* Delete Rule
* @description 删除一条本作品规则204。项目不存在 → 404规则不存在 / 不属于该项目 → 404。
*
* 删规则是**作者显式动作**(不变量 #3规则增删不经 AI 静默写库。repo.delete 只 flush
* 端点提交;删不到行(未知 id / 跨项目)→ 不提交、抛 404。
*/
delete: operations["delete_rule_projects__project_id__rules__rule_id__delete"];
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/projects/{project_id}/style": {
parameters: {
query?: never;
@@ -1671,7 +1700,7 @@ export interface components {
level: "global" | "genre" | "style" | "project";
/**
* Content
* @description 规则正文
* @description 规则正文(首尾空白会被裁剪,不可全空白)
*/
content: string;
};
@@ -1685,9 +1714,16 @@ export interface components {
};
/**
* RuleView
* @description 规则视图创建后回显snake_case
* @description 规则视图(创建后回显 + 列表项snake_case
*
* `id` 是该规则行的稳定主键——前端规则页用它作删除 handleDELETE /rules/{rule_id})。
*/
RuleView: {
/**
* Id
* Format: uuid
*/
id: string;
/** Level */
level: string;
/** Content */
@@ -1859,8 +1895,11 @@ export interface components {
* @description 单条档位路由写入。
*/
TierRoutingInput: {
/** Tier */
tier: string;
/**
* Tier
* @enum {string}
*/
tier: "writer" | "analyst" | "light";
/** Provider */
provider: string;
/** Model */
@@ -2744,7 +2783,9 @@ export interface operations {
};
get_outline_projects__project_id__outline_get: {
parameters: {
query?: never;
query?: {
volume?: number | null;
};
header?: never;
path: {
project_id: string;
@@ -2874,6 +2915,36 @@ export interface operations {
};
};
};
delete_rule_projects__project_id__rules__rule_id__delete: {
parameters: {
query?: never;
header?: never;
path: {
project_id: string;
rule_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Successful Response */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
/** @description Validation Error */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
get_style_projects__project_id__style_get: {
parameters: {
query?: never;