Files
Jyotisha/docs/tasks/PROGRESS-rectification-request-dossier-cache-20260915.md
T
jesse-ux b9c053778a
Independent Staging Quality Gate / validate (push) Canceled after 2m18s
Independent Staging Quality Gate / publish (push) Canceled after 0s
fix(rectification): 请求内 Case 档案只读投影写即失效缓存
同一请求里 dossier/compute 按 (fn, userId, caseId) 合并重复读,其它 RPC 与 .from 立即失效。路由入口各包一处,零调用点改动。
2026-09-16 07:32:34 +08:00

74 lines
4.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PROGRESS · 一轮对话把整份 Case 档案从数据库取 3.4 次(2026-09-15 / 2026-09-16
工作树:`.worktrees/rectification-request-dossier-cache-20260915`
分支:`codex/rectification-request-dossier-cache-20260915`
任务书基线:`6b3248bf`;代码基线 `origin/staging` @ `e4788dfc`(含 failure-attribution `8b982baf`、engine-memoization BUG-721、settled-render BUG-725
本机 Windows。
Skill **未 bump**。未改 `frontend/src/app/page.tsx`、SQL、轮询间隔、GET 投影形状、计费口径、`docs/tasks/README.md` 状态列。未 push `HEAD:staging`
## 开工基线
| 项 | 数字 |
| --- | --- |
| `frontend/src/app/page.tsx` | **1879** 行(未改) |
| 最大 BUG 号 | **BUG-725**(本单占用 **BUG-726**;任务书预占 726,开工时 722–724 已落库,随后 721/725 也合入 staging |
| `tsc --noEmit` | 收尾 **0 错** |
| `npm run lint` | **0 error**(全仓既有 warning;本单文件 0 warning |
`frontend/node_modules` 已是指向主仓的 junction,未新建。
## 任务状态
| 任务 | 状态 | 说明 |
| --- | --- | --- |
| 5.1 请求作用域缓存包装器 | 完成 | `withRectificationRequestCache`;写即失效;缓存 in-flight promise |
| 5.2 路由入口接线 | 完成 | agent / regenerate / Case GET / repair-exit POST / accept POST 各一处 |
| 5.3 前后计数 | 完成 | 见下表;预算断言钉在路由预取 + 证据轮 `≤ 4` |
| 5.4 Bug 历史 | 完成 | BUG-726 |
## 实现要点
- 新模块 `frontend/src/lib/rectification-agentic/v9/request-cache.ts`。Map 在每次 `withRectificationRequestCache` 的闭包里,不挂模块作用域、不挂 `globalThis`
- 白名单:`get_agentic_rectification_case_dossier``get_agentic_rectification_case_compute`。键是 `(fn, p_user_id, p_case_id)`
- 其它 `rpc``clear` 再转发。Proxy 透传 `.from(...)` 等属性,访问时同样清空。类型用 `as T` 保留 Supabase 客户端形状,**没有为过类型去改业务代码**,也没有收缩成只包 `rpc`
- 调用点零改动。`fakeAccounting` 默认不包缓存(`requestCache` / `RECTIFICATION_REQUEST_CACHE=1` 显式打开);计数导出默认关闭(`countRpc` / `RECTIFICATION_RPC_COUNT=1`)。
## 改前 / 改后 dossier RPC 计数
测法:`fakeAccounting` 按实例聚合,只计打过 dossier 或 compute 的场景。改后用 `RECTIFICATION_REQUEST_CACHE=1` 包上同一批测试客户端。既有断言一条未改。
| 路径 | 场景数 | 改前 dossier(均值) | 改后 dossier(均值) | 改前 compute(均值) | 改后 compute(均值) |
| --- | ---: | ---: | ---: | ---: | ---: |
| Agent 轮(`rectification-v9-stream.test.ts` | 41 | 143**3.49** | 143**3.49** | 270.66 | 270.66 |
| 点选题(`rectification-answer-choice.test.ts` | 15 | 31**2.07** | 30**2.00** | 171.13 | 151.00 |
| 路由预取 + 证据轮(新预算断言) | 1 | 5 | **4** | — | — |
Agent 轮套件数字没降:这些测试的 fake stream 不执行真实工具,每次 `loadV9CaseDossier` 之间都夹着 skill identity / append / run phase 等非白名单 RPC,按「写即失效」必须重读。生产路径上路由先读档案、再进 `runV9AgentTurn` 再读一次,中间无写,预算断言覆盖这一跳(5→4)。点选题套件 dossier 31→30、compute 17→15。
## 既有断言改动
无。stream 50 / answer-choice 34 一条未改仍全绿。
## 测试
| 命令 | 结果 |
| --- | --- |
| `tsc --noEmit` | **0 错** |
| 本单文件 eslint | **0 error / 0 warning** |
| `npm run lint` | **0 error**(全仓既有 warning 同量级) |
| `tests/rectification-request-dossier-cache.test.ts` | **8 / 8 绿** |
| `rectification-v9-stream.test.ts` | **50 / 50 绿** |
| `rectification-answer-choice.test.ts` | **34 / 34 绿** |
| `tests/rectification-*.test.ts` + `agentic-rectification-*.test.ts` | **1263 pass / 1 fail / 9 skipped**。唯一失败是既有 `rectification-v9-agent.test.ts` Windows `symlinkSync` EPERM,与本单无关 |
| `page.tsx` | 仍 1879 行,未改 |
| 全量 `npm test` | `# tests 3197 / # pass 3114 / # fail 69 / # skipped 14`。比 failure-attribution 进度记录的 3189/3104/71/14 多本单 8 条绿;失败仍是无 Docker 的 database-*、部署/Caddy/shell、Windows symlink EPERM。不含本单定向套件 |
| `npx next build --webpack` | **Compiled successfully** + TypeScript 37s 过。Collecting page data 死在既有 `/api/consult` skill runtime symlink EPERM。不伪装成 `/` ○ Static 已核过 |
## 环境缺口
- 无 Docker:数据库套件红,不伪装成通过。
- 无登录态、无 Chrome:浏览器级验收不在本单。
- Windows 无 symlink 权限:`rectification-v9-agent.test.ts` 与部分 skill runtime 路径 EPERM。本机 Node 只能建 junction。
- `next build`:webpack 编译在本机可过;收集页面数据时 skill runtime symlink 仍可能 EPERM(既有缺口)。不伪装成 `/` ○ Static 已核过。