From 3893783e4c63f2960714a8fd9a4bfd1cac14df4f Mon Sep 17 00:00:00 2001 From: jesse-ux Date: Wed, 14 Oct 2026 07:41:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=E6=95=B0=E6=8D=AE=E5=BA=93=E5=BE=80?= =?UTF-8?q?=E8=BF=94=E5=AF=B9=E7=85=A7=E8=84=9A=E6=9C=AC=E6=8C=AA=E5=87=BA?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E4=BC=9A=E6=89=93=E5=8C=85=E7=9A=84=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 脚本从 frontend/scripts 挪到 frontend/tests,不再从会被打包的目录引用测试夹具。业务代码没动,对照数字没重跑。tsc 通过,lint 0 个错误(125 条原有警告),镜像导入守卫 2 通过、0 失败。 Co-Authored-By: Grok (agent loop) --- docs/BUG_HISTORY.md | 10 +++++----- .../PROGRESS-node-runtime-resources-20261013.md | 16 +++++++++++++++- docs/tasks/README.md | 2 +- .../node-runtime-resources-ab-20261013.md | 2 +- .../bench-local-pg-roundtrips.ts | 4 ++-- 5 files changed, 24 insertions(+), 10 deletions(-) rename frontend/{scripts => tests}/bench-local-pg-roundtrips.ts (98%) diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 2e84189b..3d96f10c 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -15304,17 +15304,17 @@ ## BUG-1140 | staging 镜像打包失败:`frontend/scripts` 下的研究脚本引用了 `frontend/tests` 的夹具 - 状态:resolved(修复已推 staging;以门禁 publish 通过与 `/api/health` 部署版本为最终证据) -- 首次发现 / 最近更新:2026-10-01 / 2026-10-01 +- 首次发现 / 最近更新:2026-10-01 / 2026-10-14 - 影响面:Gitea `backend-quality-gate` 的 publish 作业(`deploy/railway-web.Dockerfile` 构建阶段 `npm run build`)。validate 通过、publish 失败,未部署,staging 停在上一版。 - 用户现象:盘型口径(BUG-1115~1117、1131)推送后 staging 不更新。 - 触发条件:`frontend/scripts/rectification-segment-persisted-replay.ts`(盘型口径研究的 PG 持久回放 harness)`import … from "../tests/helpers/postgres-fixture.ts"`。web 镜像只复制 `frontend/src`、`frontend/scripts` 等,不复制 `frontend/tests`;`frontend/tsconfig.json` 的 include 为 `**/*.ts`,`next build` 类型检查覆盖 scripts,于是 `TS2307 Cannot find module '../tests/helpers/postgres-fixture.ts'`。 - 根因:本地与验收机都有 `frontend/tests`,`tsc --noEmit` 与 `next build` 均通过,门禁 validate 也在完整检出上跑,没有任何一步按镜像的复制清单构建。 - 修复:harness 移到 `frontend/tests/research/rectification-segment-persisted-replay.ts`(相对路径随之调整),Python driver `scripts/research/varga_resolution_persisted_replay.py` 指向新路径;新增 `frontend/tests/runtime-sources-no-test-imports.test.ts`:`src/` 与 `scripts/` 不得 import / `new URL` 引用 `tests/`。 - 验证:按 `railway-web.Dockerfile` 的 COPY 清单从提交 `git archive` 出构建目录,修复前 `npm run build` 报上述 TS2307、exit 1,修复后 exit 0、`/` Static;守卫测试 2/2,且对旧 harness 文本判定为违规;移动后 harness 1 例 ±10 冒烟 `runner_exit=0`。 -- 防复发:守卫测试进 `npm test`(门禁 validate 必跑);错误台账 ERR-113。 -- 相关记录:BUG-1115~1117、BUG-1131。 -- 复发自:无 -- 修复版本:`codex/staging-publish-fix-20261001`。 +- 防复发:守卫测试进 `npm test`(门禁 validate 必跑);错误台账 ERR-113。2026-10-14 这道守卫在合入前拦住了同一形状:issue #58 的往返对照脚本曾放在 `frontend/scripts/` 并导入测试夹具。脚本改放到 `frontend/tests/bench-local-pg-roundtrips.ts`,文件名不是 `.test.ts`,不会被全量测试收进去。业务代码没有改。原任务书里的旧路径保持不动。 +- 相关记录:BUG-1115~1117、BUG-1131、BUG-1327。 +- 复发自:无。2026-10-14 是同一形状,被守卫拦住,未进测试环境。 +- 修复版本:`codex/staging-publish-fix-20261001`。2026-10-14 的同类挪动在 `codex/node-runtime-resources-20261013`。 ## BUG-1141 | 生时校正缺少度数级时间信号(角度类技法研究) diff --git a/docs/tasks/PROGRESS-node-runtime-resources-20261013.md b/docs/tasks/PROGRESS-node-runtime-resources-20261013.md index 0ba46761..c2203a2d 100644 --- a/docs/tasks/PROGRESS-node-runtime-resources-20261013.md +++ b/docs/tasks/PROGRESS-node-runtime-resources-20261013.md @@ -2,6 +2,8 @@ issue #58。分支 `codex/node-runtime-resources-20261013`。 +2026-10-14 按修复单把往返对照脚本从 `frontend/scripts/bench-local-pg-roundtrips.ts` 挪到 `frontend/tests/bench-local-pg-roundtrips.ts`。文件名不是 `.test.ts`,全量测试不会自动收进去。业务代码没有改,对照数字没有重跑。原任务书里的旧路径保持不动。 + 任务书基线写的是 `77057a819`,计划评论里的基线是 `2994588ad4d858dead4835943e5883c5aa2b03f8`。本分支实际从当时的 `origin/staging` `66cd60081f37a57680274633fcb3fb942d01bb2f` 拉出。没有因此停下来问产品,改动仍按任务书做。 ## 做了什么 @@ -54,6 +56,18 @@ issue #58。分支 `codex/node-runtime-resources-20261013`。 | 本单测试 | `tsx --test` 任务书点名的文件加登录缓存测试 | 134 通过,0 失败,0 取消 | | 真库身份 | `database-local-postgres-session-setup.test.ts` | 1 通过。事务内角色和身份生效,连接归还后再借出时身份已空 | | 数据库套件 | `npm run test:db`,两开关先关后开 | 各 81 / 通过 68 / 失败 13 / 取消 0,名称与已知清单一致 | -| 往返对照 | `scripts/bench-local-pg-roundtrips.ts` | 见上,`payloadMismatch` false | +| 往返对照 | `tests/bench-local-pg-roundtrips.ts`(按修复单从 `scripts/` 挪来) | 见上,`payloadMismatch` false。数字未重跑 | 没有跑前端全量 `npm test`、Python 快速门、`next build`。生产内存曲线要等部署后看。真机两台设备改密码的步骤在 `docs/testing/node-runtime-resources-20261013.md`,登录缓存默认关着,那份清单的第 2 步要先把开关打开才看得到。 + +## 2026-10-14 修复单 + +按 `docs/tasks/TASK-node-runtime-resources-fix-20261014.md`:先合并最新 `origin/staging`,再把对照脚本挪进测试目录。业务代码没有改。对照数字没有重跑。 + +和上一版 `4c3485bc` 比,网页业务目录里多出来的只有合并进来的校正提速改动(`frontend/src/lib/rectification-agentic/v9/engine-client.ts`),不是这单写的。这单自己的提交不碰 `frontend/src`。 + +| 检查 | 命令 | 结果 | +| --- | --- | --- | +| 类型 | `tsc --noEmit -p frontend` | 通过,退出码 0 | +| 规范 | `npm run lint`(在 frontend) | 0 error,125 条原有 warning,未改 | +| 镜像导入守卫 | `tsx --test tests/runtime-sources-no-test-imports.test.ts` | 2 通过,0 失败,0 取消 | diff --git a/docs/tasks/README.md b/docs/tasks/README.md index 33e9ffb0..e2ca4650 100644 --- a/docs/tasks/README.md +++ b/docs/tasks/README.md @@ -469,7 +469,7 @@ | --- | --- | --- | --- | --- | | `TASK-rect-scoring-perf-20261013.md` | `PROGRESS-rect-scoring-perf-20261013.md` | 校正打分提速:引导窗口平方扫描、候选不变量重复算、响应带无读取点字段、候选数上限 241(BUG-1323~1325、1345) | 待验收 | `codex/rect-scoring-perf-20261013` | | `TASK-node-runtime-resources-20261013.md` | `PROGRESS-node-runtime-resources-20261013.md` | 报告 worker abort 监听泄漏、本地 PG 适配层往返与元数据缓存、无上限内存表、用户端会话读缓存(BUG-1326~1328、1346,PG 与缓存部分 A/B) | 待验收 | `codex/node-runtime-resources-20261013` | -| `TASK-node-runtime-resources-fix-20261014.md` | — | **#58 第 1 次打回**:`4c3485bc` 其余全过;压测脚本放在 `frontend/scripts/` 却从 `frontend/tests/` 导入,镜像构建会失败(BUG-1140 形状,任务书指定的路径有误)。挪到 `frontend/tests/` 下非 `.test` 文件名 | 待领取 | `codex/node-runtime-resources-20261013` | +| `TASK-node-runtime-resources-fix-20261014.md` | `PROGRESS-node-runtime-resources-20261013.md` | **#58 第 1 次打回**:`4c3485bc` 其余全过;压测脚本放在 `frontend/scripts/` 却从 `frontend/tests/` 导入,镜像构建会失败(BUG-1140 形状,任务书指定的路径有误)。挪到 `frontend/tests/` 下非 `.test` 文件名 | 待验收 | `codex/node-runtime-resources-20261013` | | `TASK-home-sidebar-rerender-20261013.md` | — | 流式回答时侧栏每帧整栏重渲染(BUG-1329,A/B) | 待领取 | `codex/home-sidebar-rerender-20261013` | | `TASK-home-sidebar-rerender-fix-20261014.md` | — | **#59 第 1 次打回**:`63509431` 其余全过;`chat-navigation-a11y-contract` 按源码文本断言 `onOpenBilling` 旧写法未跟改(§7.8) | 待领取 | `codex/home-sidebar-rerender-20261013` | | `TASK-api-disk-cache-retention-20261013.md` | — | API 磁盘缓存只进不出、VedAstro 审计文件留存出生资料、失败快照久缓存、缓存键规范化(BUG-1330~1332,A/B) | 待领取 | `codex/api-disk-cache-retention-20261013` | diff --git a/docs/testing/node-runtime-resources-ab-20261013.md b/docs/testing/node-runtime-resources-ab-20261013.md index 22d59c80..f4904fae 100644 --- a/docs/testing/node-runtime-resources-ab-20261013.md +++ b/docs/testing/node-runtime-resources-ab-20261013.md @@ -1,6 +1,6 @@ # 本地数据库往返对照(2026-10-14) -环境:Windows,Docker 29.8.0,Node v22.23.2。脚本 `frontend/scripts/bench-local-pg-roundtrips.ts`。库是测试用的临时 Postgres,数据是虚构用户。每组 50 遍,重复 3 组,先各热身 1 遍。往返数是每组平均值的中位数。耗时中位数是三组中位数的中位数。p95 是全部 150 遍的单遍耗时。 +环境:Windows,Docker 29.8.0,Node v22.23.2。脚本 `frontend/tests/bench-local-pg-roundtrips.ts`(2026-10-14 按修复单从 `frontend/scripts/` 挪来,数字未重跑)。库是测试用的临时 Postgres,数据是虚构用户。每组 50 遍,重复 3 组,先各热身 1 遍。往返数是每组平均值的中位数。耗时中位数是三组中位数的中位数。p95 是全部 150 遍的单遍耗时。 判定用第二次运行(输出里带三组原始数)。第一次运行同样是 49 降到 32,中位数 89.51 毫秒降到 32.70 毫秒,内容一致,方向相同。 diff --git a/frontend/scripts/bench-local-pg-roundtrips.ts b/frontend/tests/bench-local-pg-roundtrips.ts similarity index 98% rename from frontend/scripts/bench-local-pg-roundtrips.ts rename to frontend/tests/bench-local-pg-roundtrips.ts index 51746bcd..d6557b31 100644 --- a/frontend/scripts/bench-local-pg-roundtrips.ts +++ b/frontend/tests/bench-local-pg-roundtrips.ts @@ -1,6 +1,6 @@ /** * Count local-Postgres adapter roundtrips for a fictional homepage plus consult write. - * Run from frontend/: npx tsx scripts/bench-local-pg-roundtrips.ts + * Run from frontend/: npx tsx tests/bench-local-pg-roundtrips.ts * Prints JSON. Does not print connection strings. */ import { spawnSync } from "node:child_process"; @@ -13,7 +13,7 @@ import { createLocalPostgresDataClient, localPostgresPoolForTests, } from "../src/lib/db/local-postgres-client-core.ts"; -import { startPostgresFixture } from "../tests/helpers/postgres-fixture.ts"; +import { startPostgresFixture } from "./helpers/postgres-fixture.ts"; const userId = "018f4e6d-7a11-7000-8000-0000000000bb"; const sessionId = "018f4e6d-7a11-7000-8000-0000000000cc";