# PROGRESS · 采用旁白超时改为可清理的 ref 计时器(2026-09-04) 工作树:`.worktrees/rectification-adopt-narration-fix2-20260904` 分支:`codex/rectification-adopt-narration-fix2-20260904` 基线:任务书写 `13dded9f`;本工作树从当时 `origin/staging` `5c9e9879`(修复单 2 文档提交)拉出。 任务书:`docs/tasks/TASK-rectification-adopt-narration-fix2-20260904.md` 未改决策逻辑、未改提示词、未改 Python、未 bump Skill。未提交、未 push。 | 任务 | 状态 | BUG | | --- | --- | --- | | 5.1 超时改为可清理的 ref 计时器 | 完成 | BUG-523 | ## 开工复现 本机 Node 24.15.0。`tsx --test` 因 IPC socket 撑住事件循环,超时用例看起来能过。独立脚本复现了 unref 计时器: ``` const s = AbortSignal.timeout(30); await Promise.race([new Promise(() => {}), new Promise((_, rej) => s.addEventListener("abort", () => rej(s.reason)))]); # abort 从未触发 exit=13 ``` 任务书在 Node 20.19 / CI Node 22 上的套件实测见 `PROGRESS-rectification-adopt-narration-fix-20260904.md` 更正节(pass 6 / cancelled 4 / exit 1)。 ## 实现要点 - `composedAbortSignal` 返回 `{ signal, dispose }`:`setTimeout` + `AbortController`(不 unref);外部 `signal` 的 abort 转发到 controller;`dispose()` `clearTimeout` 并移除外部监听。 - `whenAborted` 同样返回 `dispose`,在 `finally` 里与 composed 一起清掉 abort 监听。 - `deliverAdoptNarration` 的 `Promise.race` 包在 `try / finally`;超时仍走 `template:model_error`。 - 源码不再出现 `AbortSignal.timeout`。 ## 偏离 无。5.3 婚恋标签仍按修复单 1 推迟。 ## 测试 `npx`/`tsx --test tests/rectification-adopt-narration-20260904.test.ts`: ``` # tests 11 # pass 11 # fail 0 # cancelled 0 # skipped 0 # todo 0 exit=0 ``` (Node spec 报告器打印为 `ℹ tests` 等六行,含义相同。比修复前多 1 条「调用完不留活跃计时器」。) `tsc --noEmit`:0 错,exit=0。 `npm run lint`:0 error,74 warning(既有),exit=0。 定向套件 `tests/rectification-*.test.ts tests/agentic-rectification-*.test.ts tests/birth-time-rectification-contract.test.ts`: ``` # tests 872 # pass 872 # fail 0 # cancelled 0 # skipped 0 # todo 0 exit=0 ``` (基线任务书写 871;本单 +1 条计时器用例。) `npm test`(全量 `tests/*.test.ts`;本机有 Docker,无 ENOENT 基线那 25 条): ``` # tests 2641 # pass 2641 # fail 0 # cancelled 0 # skipped 0 # todo 0 exit=0 ``` ## 改动文件 - `frontend/src/lib/rectification-agentic/v9/adopt-narration-agent.ts` - `frontend/tests/rectification-adopt-narration-20260904.test.ts` - `docs/BUG_HISTORY.md`(BUG-523) - `docs/tasks/PROGRESS-rectification-adopt-narration-fix-20260904.md`(更正) - `docs/tasks/README.md` - 本文件