docs: mark phase 2 complete
Records the risk policy as decided -- low_write only, high_write and destructive refused outright with no confirmation flow, unclassified actions defaulting to destructive so a missing classification fails closed. Also records the measured fact-pack leak (filesystem path, quality profile id, internal row id and a raw byte count all reaching the model), and the three problems found while building it: the sqlite3 context manager not closing connections, the five call sites writing a status the new CHECK constraint rejects, and fallback_answer maintaining a diverged second copy of the receipt.
This commit is contained in:
@@ -265,7 +265,36 @@ commits:`e18f4de` 迁移框架 / 事务 / upsert / 索引 · `5de5933` `contra
|
|||||||
**验收**:全新库与既有库都能升到目标 `user_version`;有一个测试从 v0 schema
|
**验收**:全新库与既有库都能升到目标 `user_version`;有一个测试从 v0 schema
|
||||||
升级并断言迁移生效;并发 upsert 测试不再抛 `IntegrityError`。
|
升级并断言迁移生效;并发 upsert 测试不再抛 `IntegrityError`。
|
||||||
|
|
||||||
### 阶段 2 · Service 层与控制账本接通(约 2 天)
|
### 阶段 2 · Service 层与控制账本接通 —— ✅ 已完成 2026-08-28
|
||||||
|
|
||||||
|
commits:`e25e82a` service + 策略引擎 · `63b430e` factpack 白名单 ·
|
||||||
|
`95151a3` 状态机约束 + 清理死表。测试 92 → 108。
|
||||||
|
生产库 v3 → v4,`integrity_check` ok,75 行活动历史完整保留。
|
||||||
|
|
||||||
|
**风险策略**(按你的决定:不做二次确认):
|
||||||
|
`low_write` 允许;`high_write` 与 `destructive` 直接拒绝;**未分类的动作默认按
|
||||||
|
destructive 处理**,所以漏分类会 fail closed。拒绝本身作为 `plan.refused`
|
||||||
|
事件入账 —— 否则一次被拦下的破坏性请求除了用户看到的那句话之外不留痕迹。
|
||||||
|
|
||||||
|
**修掉的跨渠道不一致(P1-13)**:Web 的"收集"对电影/剧集**根本不调适配器**,
|
||||||
|
只把候选标为 selected;Telegram 按钮则完全绕过账本直连适配器。
|
||||||
|
现在有测试驱动同一决定走两个渠道并断言账本记录逐字段相同。
|
||||||
|
|
||||||
|
**fact pack 实测泄露**(生产 Sonarr 数据):`path=/mnt/unRaid/tv4k/...`、
|
||||||
|
`quality_profile_id=7`、`id=53`、`size_on_disk=670740549289` 全部进入过模型上下文。
|
||||||
|
白名单投影后 681 → 406 字节,回答质量反而提升(大小改为 `624.7 GB`)。
|
||||||
|
|
||||||
|
**过程中发现的三个问题**:
|
||||||
|
|
||||||
|
1. `Database.backup` 每次调用泄漏两个连接 —— `sqlite3` 的连接
|
||||||
|
context manager 只提交/回滚事务,**不关闭连接**。已改用 `closing()`。
|
||||||
|
靠 `-W error::ResourceWarning` 跑测试暴露出来的。
|
||||||
|
2. 加上 CHECK 约束立刻抓出五处 `finish_job(..., "success")` 与枚举
|
||||||
|
`"succeeded"` 不符 —— 正是约束存在的意义。
|
||||||
|
3. `fallback_answer` 在重复 service 已拥有的回执措辞,且两份已经漂移:
|
||||||
|
它无论有无文件都说"已加入并触发搜索"。现已改为直接复用回执。
|
||||||
|
|
||||||
|
### 阶段 2 原始清单(供对照)
|
||||||
|
|
||||||
1. `curator/service.py`:唯一写路径 + 架构 §7 四档风险策略引擎;
|
1. `curator/service.py`:唯一写路径 + 架构 §7 四档风险策略引擎;
|
||||||
每个写操作落 `Intent → Plan → Command → WorkflowJob → Event` + 幂等键。
|
每个写操作落 `Intent → Plan → Command → WorkflowJob → Event` + 幂等键。
|
||||||
|
|||||||
Reference in New Issue
Block a user