BUG-729: dropped history rounds leave an omission marker in the model-visible summary slot. BUG-730: checkpoint threshold is 0.4 of historyBudgetChars (128k still 16,000). BUG-731: session_full new chat copies owned context_summary on the server; clients send only continued_from_session_id.
61 lines
5.3 KiB
Markdown
61 lines
5.3 KiB
Markdown
# PROGRESS · 普通聊天的三条记忆缺口(2026-09-16)
|
||
|
||
工作树:`.worktrees/consultation-context-memory-20260915`
|
||
分支:`codex/consultation-context-memory-20260915`
|
||
任务书基线:`origin/staging` @ `6b3248bf`;开工时本 worktree 在 `11893c7f`(任务书已合入 staging)。
|
||
本机 Windows。Skill **未 bump**。未改 `frontend/src/app/page.tsx`、数据库、依赖。
|
||
|
||
开工核对:`docs/BUG_HISTORY.md` 最大号 **BUG-720**。校正四单预占 721–726、external-evidence-cache 预占 727/728,本单使用预占 **BUG-729 / 730 / 731**,无冲突。
|
||
|
||
## 任务状态
|
||
|
||
| 任务 | 状态 | BUG |
|
||
| --- | --- | --- |
|
||
| 5.2 写摘要阈值跟着预算走 | 完成 | BUG-730 |
|
||
| 5.1 丢整轮必须留痕 | 完成 | BUG-729 |
|
||
| 5.3 写满时静默继承摘要 | 完成 | BUG-731 |
|
||
| 5.4 Bug 历史 | 完成 | 729/730/731 |
|
||
|
||
## 实现要点
|
||
|
||
- **BUG-730**:删除写死的 `CONSULTATION_HISTORY_TAIL_MAX_CHARS = 16_000`。新函数 `consultationHistoryCheckpointChars(window)` = `floor(historyBudgetChars(window) × 0.4)`,并运行时断言阈值 < 预算。128k 仍是 16,000。`shouldCheckpoint` / `checkpointSessionContextSummary` 吃 `contextWindow`;consult 把会话模型窗口传进去。
|
||
- **BUG-729**:`droppedCount > 0` 时在 `consultationUserTurnContent` 的摘要槽追加与 `omissionMarker` 同风格的说明。有摘要:「更早的 N 轮问答已并入上面的会话摘要」;无摘要:「更早的 N 轮问答未能进入本轮上下文,结论尚未并入会话摘要」。`droppedCount === 0` 不加。`route.ts` 四条用户回合都读 `historyWindow.droppedCount`。
|
||
- **BUG-731**:`chatSessionCreateSchema` 增加可选 `continued_from_session_id`(保持 `.strict()`,**不加** `context_summary`)。`POST /api/sessions` 按当前用户读源会话摘要,读到才写入新行;读不到 / 别人的 / 空都静默跳过,仍 201。`continueInNewChat` 把当前会话 id 传给 `startNewChat`。界面无新文案。
|
||
|
||
未改摘要机制本身(800 汉字、15 秒 ref 计时器、乐观并发、结算后异步)。未用 `AbortSignal.timeout()` 替换摘要超时。未把 `messages` 加回列表 GET。未动数据库。
|
||
|
||
## 既有断言改动
|
||
|
||
| 文件 | 原值 | 新值 | 原因 |
|
||
| --- | --- | --- | --- |
|
||
| `session-context-summary.test.ts` | `CONSULTATION_HISTORY_TAIL_MAX_CHARS === 16_000`;`shouldCheckpoint` 只测 15_999 / 16_001 | `consultationHistoryCheckpointChars(128_000) === 16_000`;另测 64k 阈值 2_400 | BUG-730:阈值由预算派生,128k 行为与改前一致 |
|
||
| `chat-session-write.test.ts` 源码合同 | `const { id, updated_at: _ignoredClientClock, ...values } = parsed.data` | 另拆 `continued_from_session_id`,不随 values 插入 | 该字段不是表列 |
|
||
| `chat-session-url.test.ts` / `composer-isolation-contract.test.ts` | 切片起点 `async function startNewChat()` | `async function startNewChat(` | 可带来源会话 id |
|
||
| `consultation-context-cache-contract.test.ts` | 检查点不传窗口 | 传 `sessionContextWindow`;历史文件不得再出现字面量 `16_000` | BUG-730 |
|
||
|
||
128k 检查点阈值:**原值 16,000 / 新值 16,000 / 原因** 比例 0.4 × 预算 40,000。未弱化其它既有断言。
|
||
|
||
## 测试
|
||
|
||
| 命令 | 结果 |
|
||
| --- | --- |
|
||
| `./node_modules/.bin/tsc --noEmit` | **0 错** |
|
||
| `npm run lint` | **0 error**(119 条既有 warning;本单未新增 error) |
|
||
| 本单相关 `npx tsx --test`(history / summary / cache contract / chat-session-write / authority / url / composer-isolation / consultation-context) | **69 pass / 0 fail** |
|
||
| `npx tsx --test tests/consultation*.test.ts tests/chat-session-*.test.ts tests/session-*.test.ts` | 264 项 / 252 pass / **12 fail**:3 个文件级失败 + 9 条 methodology,全是 Windows `SkillPackageRegistryError`(EPERM symlink),与本单文件无关 |
|
||
| `npm test`(`tests/*.test.ts tests/*.test.tsx`) | `# tests 3110 / # pass 3023 / # fail 73 / # skipped 14`。失败清单不含本单文件。对照近期同机 `PROGRESS-chart-page-blocking-open-20260915.md` 的 fail **73**,**零新增失败** |
|
||
| `page.tsx` | 未改 |
|
||
| `npm run build` | compile + TypeScript 过;Collecting page data 死在既有 `SkillPackageRegistryError`(EPERM symlink `/api/daily-starlanguage`),与本单无关。未能从本机构建表确认 `/` 的 `○ Static` 与首屏 gzip。源码:`page.tsx` 无 `force-dynamic`;既有合同「home stays a client-read query on a static route」本单相关套件已绿 |
|
||
|
||
## 环境缺口
|
||
|
||
- 本机 Windows 无开发者模式 symlink:`skill-package-registry` 建 live runtime alias 报 EPERM。因此 `next build` 收集页面数据失败;若干 consult/methodology/skill-binding 测试整文件红。Linux CI / staging 不受影响。
|
||
- 无 Docker:`tests/database-*.test.ts` 照常红,与基线同类。
|
||
- 无登录态、无 Chrome:写满后「开新对话」的静默继承未做浏览器走查。界面无新文案,源码合同已锁「开新对话」按钮与禁止「接着上次聊」类句子。
|
||
|
||
## 收尾限制
|
||
|
||
- 摘要失败仍只 `console.warn("session context summary failed")`,不打印摘要正文。
|
||
- 侧栏「新建对话」不带 `continued_from_session_id`,只有写满出口的「开新对话」会静默继承。
|
||
- 源会话属于别人或没有摘要时新行 `context_summary` 为空,接口仍 201。
|