docs(plan): main-loop decoupling audit and W4-D fix list
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
d3ab54f2bd
commit
8c6a922cfb
1 file changed
+16
@@ -0,0 +1,16 @@
|
|||||||
|
# 主线程解耦审计(2026-09-27,只读审计结论 → W4-D 修复清单)
|
||||||
|
|
||||||
|
## 结论
|
||||||
|
生产容器 API 与 worker 分进程;RSS/快照/刮削/入库主链路走任务引擎 + outbox。漏网三类:
|
||||||
|
1. HTTP 请求内同步重活:`POST /library/reconcile`(全量 stat)、`POST /download-cache/cleanup`(删种删数据)、`POST /organization`(planImport 递归 walk)、`POST /capabilities/{id}/invoke` 中 release.search/release.inspect/identity.resolve/catalog.lookup(远程站点/TMDB)、`GET /inventory/media-servers`(串行 Emby)。
|
||||||
|
2. acquisition-organize 后台循环(index.ts)绕过引擎直接调 `submitDownload`、`executeRecord`(Copy/Move)、`cleanupDownloadCache`、`reconcileLibrary`,串行 await;无租约/attemptToken 保护;一次大复制卡住 qB 同步与阈值暂停。
|
||||||
|
3. worker 并发度固定 4(openworkflow-engine.ts),runAgent 整段会话占 1 槽数分钟,与 verifyAndImport 大文件复制抢同一池。
|
||||||
|
事件循环丢租约风险低(复制/哈希流式让出;租约 30s/续租 15s);强制 sha256 路径(目标已存在、跨设备恢复)会全量读两遍。
|
||||||
|
|
||||||
|
## 修复清单(W4-D)
|
||||||
|
- P0 后台循环只编排:sweepPendingImports → enqueue verifyAndImport;sweepReservedPlans → enqueue submitDownload;超阈值清理与 6h 对账 → enqueue(幂等键按时间槽);tick 只剩 syncDownloads + 阈值判断,qB 同步独立定时器。
|
||||||
|
- P0 `/download-cache/cleanup`、`/library/reconcile` 改入队返回 {taskId, runId}(enqueueTracked);前端经任务页/SSE 追踪。
|
||||||
|
- P1 `WORKER_CONCURRENCY` 配置;worker 分组:`--role worker`(io 组:除 runAgent/resolveDecision 外,并发 4)与 `worker:agent`(并发 1–2),`startWorker` 两次各带 versions;模块 start() 循环只在 io 组;entrypoint 起三进程。
|
||||||
|
- P1 capabilities invoke 分级:外部 IO 型能力在 HTTP 路径强制 `AbortSignal.timeout(15s)` + 按站点/TMDB 限并发,或改入队返回 taskId;`POST /organization` dryRun 的 walk 加文件数上限。
|
||||||
|
- P2 fs/copy.ts:highWaterMark 1MiB;强制 sha256 全量比对改子进程 `sha256sum`(仿 ffprobe.ts 的 Deno.Command);executeRecord 打点。
|
||||||
|
- P2 worker 事件循环延迟探针(setInterval 偏差 >5s warn)。
|
||||||
Reference in new issue
Block a user