Files
Jyotisha/docs/tasks/TASK-rectification-p0-fix-20260915.md
T
Jesse_ChenandClaude Fable 5 4161222b2b docs(tasks): accept f51e494c and file the page.tsx growth-freeze fix
六条缺陷(BUG-699/704/705/706/708/709)全部实现,实现方式与任务书一致:
lookup 三分支(found/missing/unavailable,5xx 不宣告删除也不清 ?c=)、
交付卡保留而只置灰采用、按钮判据用 vargaStyleFollowupRenderable 复用
buildChoiceCard 的同一套门而不是复制条件、「相对支持度」进 MACHINE_VOICE_
LEXICON。文档齐全,生产 7b620c7a 受影响面也核对过了(不受影响)。

Linux 门禁:tsc 0 错;lint 0 error / 119 warning;本轮 8 个合同套件 130 项
全绿;build exit 0、/ 仍 ○ Static;首屏 gzip +0.13%。全量失败 父提交
d3a2c48b 32 → f51e494c 33。

多的一条是 page.tsx 从 1951 涨到 1964 行,撞了 chart-view-route.test.ts 的
<= 1951 上限,即 AGENTS.md §6 的增长冻结。d3a2c48b 绿、f51e494c 红,各跑
两次稳定复现。逻辑本身已经在 lib 里,超的只是十来行接线,搬出去即可,
不得放宽上限。

连带:staging 的 deployment.gitCommit 停在 2d7698ea,其后 6 个含门禁路径的
提交未部署,这条红很可能是原因之一。修好前产品没有环境可以实测。

另记两条无自动化覆盖的欠账:本轮动了数据库结构(新增触发器与函数)但
test:db 没跑,而门禁 workflow 里也不跑 DB 套件;标题与 updated_at 的修补
脚本在 staging 未执行,损坏面数字还空着。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0155nFCgCHtoA7jhSDGmZmMu
2026-09-15 09:23:30 +00:00

152 lines
7.8 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.
# TASK · 验收修复单:`page.tsx` 超出增长冻结上限,门禁红
- 日期:2026-09-15
- 基线 commit`origin/staging` @ `f51e494c`
- 执行分支:`codex/rectification-p0-fix-20260915`
- 来源:Claude 对 `f51e494c`BUG-699 / 704 / 705 / 706 / 708 / 709)的验收
- 规模:把十来行接线从 `page.tsx` 搬出去。**不改任何行为。**
---
## 1. 验收结论摘要
两份任务书的六条缺陷**全部实现且实现方式正确**。Linux 门禁实测:
| 项 | 结果 |
| --- | --- |
| `tsc --noEmit` | 0 错 |
| `npm run lint` | **0 error** / 119 warning(全部既有) |
| 本轮 8 个合同套件 | 130 项 **全绿** |
| `npm run build` | exit 0`/` 仍是 `○ Static` |
| 首屏 JS gzip-9 | 584,413 B(对上一次实测 583,660 B**+0.13%** |
| 全量测试 | 父提交 `d3a2c48b` fail **32**`f51e494c` fail **33** |
多出来的**一条**就是本单要修的。除它之外,失败清单与父提交逐条一致(其中 6 条属于同期另一会话的星历 / 星盘页改动,不在本轮范围)。
## 2. 事故实证
`frontend/tests/chart-view-route.test.ts``page.tsx does not grow to host the chart page`
```js
assert.ok((pageSource.match(/\n/g) ?? []).length <= 1951);
```
实测:
| | `frontend/src/app/page.tsx` 换行数 |
| --- | ---: |
| 父提交 `d3a2c48b` | **1951**(正好卡在上限) |
| `f51e494c` | **1964**+13 |
`d3a2c48b` 上单独跑该文件两次全绿,`f51e494c` 上两次全红,**稳定复现,不是抖动**。
增长来自 BUG-705 的接线,`git diff d3a2c48b..f51e494c -- frontend/src/app/page.tsx` 新增的是:
```
resolveLookupBootstrap, // import
const listedSelection = resolveBootstrapSessionSelection({…});
const lookedUp = await resolveLookupBootstrap({ selection, sessions, defaultSessionId, catalog, signal });
if (controller.signal.aborted) return;
nextSessions = lookedUp.sessions;
const bootstrapSelection = lookedUp.selection;
} else if (lookedUp.notice) { setComposerNotice(lookedUp.notice); }
```
**逻辑本身已经在 lib 里**`resolveLookupBootstrap` 是外部函数,写法是对的),超的只是 `page.tsx` 里这十来行接线。
违反的是 `AGENTS.md` §6
> `frontend/src/app/page.tsx` 已从 4,766 行拆到 2,000 行以下,**不得再增长**:新逻辑进 `frontend/src/hooks/`、`frontend/src/lib/` 或组件。
上限 `1951` 是同期另一会话在 `830799fa` 里按当时行数钉的,等价于「从此不许再长」,与 §6 一致。**不得用「上限是别人钉的」当理由去放宽它。**
### 2.1 连带后果:staging 已经 6 个提交没部署
`GET https://staging.jyotisha.chat/api/health``deployment.gitCommit` = **`2d7698ea`**`fix(chat): keep stored rectification titles on open`)。它之后有 **6 个含门禁路径的提交**未部署,`f51e494c` 是最后一个。
门禁跑 `npm test`,本单这条红会让它失败。**这很可能就是不部署的原因**(也可能还叠加了另一会话星历页那几条,需要执行方看 Gitea 的实际日志确认,不要凭猜写结论)。
在修好之前,产品**没有任何环境可以实测这六条修复**。
---
## 3. 决策记录
1. **修法是把接线搬出 `page.tsx`,不是放宽上限。** `AGENTS.md` §6 是硬约束。
2. 行为**零变化**。BUG-705 的三分支语义(found / missing / unavailable)不得动。
3. 不碰同期另一会话的星历 / 星盘页改动与它们的失败。
---
## 4. 硬红线
1. **不得修改 `chart-view-route.test.ts` 里的 `1951` 上限**,也不得删除或跳过该断言。
2. **不得改变 BUG-705 的行为**`lookup` 三分支、`?c=` 在 unavailable 时保留、404 才清 URL 并报 `SESSION_MISSING_NOTICE`
3. `tsc --noEmit` 0 错;`npm run lint` 0 error。
4. 全量 `npm test` 的失败数必须从 **33 回到 32**,且清单与 `d3a2c48b` 逐条一致。
5. 不得顺手修另一会话那 6 条。
---
## 5. 任务分解
### 任务 1 · 把 bootstrap 选择的接线搬出 `page.tsx`
**1.1** 把「`resolveBootstrapSessionSelection``resolveLookupBootstrap` → 得到最终 `bootstrapSelection` / `nextSessions` / `notice`」这一段合成**一个**调用,放进 `frontend/src/lib/home-bootstrap.ts`(本轮已经在动这个文件)或一个新的 `frontend/src/lib/` 模块。
`page.tsx` 里应当只剩一次 `await` 和几个赋值,净行数**不高于** `d3a2c48b`
**1.2** 允许的落点按 §6 的优先级:`frontend/src/lib/` > `frontend/src/hooks/` > 组件。**不要**为这点接线新开一个 hook——参数式 hook 内部保持 0 个 React hook 的既定模式仍然有效。
**1.3** 搬完复核:`node -e "…(s.match(/\n/g)||[]).length"``page.tsx` 的结果 **≤ 1951**。数字写进 PROGRESS。
**验收标准**
- `npx tsx --test tests/chart-view-route.test.ts` fail=0。
- `npx tsx --test tests/session-lookup-unlisted.test.ts tests/chat-session-url.test.ts` 仍然 fail=0,断言**一条未改**。
- 全量 `npm test` fail=32,清单与 `d3a2c48b` 逐条一致。
- `tsc --noEmit` 0 错、`npm run lint` 0 error。
### 任务 2 · 文档
- `docs/tasks/PROGRESS-rectification-p0-fix-20260915.md`:搬了什么、`page.tsx` 前后行数、全量失败数 33 → 32。
-`PROGRESS-rectification-open-retitles-session-20260915.md` 补一段「验收补正」,写明 Linux 实测数字(本单 §1 的表)与这条超限,以及执行方本机把全量 TAP 记成 Windows 缺口所以没看到。
- **不新增 BUG 编号**:这是红线违反 + 合同测试红,没有用户可感知现象,不进 `docs/BUG_HISTORY.md`。当前最大号是 **BUG-709**;执行中若发现真实回归从 **BUG-710** 起。
- 不动 `CHANGELOG.md`
---
## 6. 让步顺序
1. 若搬进 `home-bootstrap.ts` 会让它承担不该承担的职责,**另开一个 `frontend/src/lib/` 模块**,不要退回 `page.tsx`
2. **绝不让步**:不得放宽或删除 `1951` 上限;不得改 BUG-705 的三分支行为;失败数必须回到 32。
---
## 7. 开工前置命令
```bash
cd /workspace/Jyotisha
git status -sb | head -1
git fetch origin --prune
git worktree add -b codex/rectification-p0-fix-20260915 \
.worktrees/rectification-p0-fix-20260915 origin/staging
cd .worktrees/rectification-p0-fix-20260915/frontend
npm ci
npx tsx --test tests/chart-view-route.test.ts # 应先看到这条红
node -e "console.log((require('fs').readFileSync('src/app/page.tsx','utf8').match(/\n/g)||[]).length)"
```
交付:`git push origin HEAD:staging`,推完核对远端 SHA,**并确认 Gitea 门禁转绿、`/api/health``deployment.gitCommit` 追上 staging head**。
---
## 8. 本轮验收确认的欠账(不属于本单)
| 欠账 | 说明 |
| --- | --- |
| `npm run test:db` 未跑 | 本轮**动了数据库结构**(新增 `touch_chat_session_from_rectification_case` 函数与触发器)。`AGENTS.md` §7.6 要求动表必须真跑 `test:db`。执行方与我都没有 Docker/库连接。**而且 `grep test:db .gitea/workflows/backend-quality-gate.yml` 无命中——门禁也不跑 DB 套件**,这条目前没有任何自动化覆盖。需要产品在 staging 用 `Migrate Staging Database` 流程实跑并确认触发器生效。 |
| 标题与 `updated_at` 修补脚本未执行 | `frontend/scripts/repair-rectification-session-titles.mjs` 默认只读,执行方本机没有 `SCHEMA_DATABASE_URL`**staging 未跑**,损坏面数字还空着。需要产品先不带参数跑看行数,确认后加 `--apply`。 |
| 浏览器 / 真机走查 | `docs/testing/rectification-open-identity-20260915.md``docs/testing/rectification-tiebreak-card-loss-20260915.md` |
| 生产 | 已核对 `7b620c7a` 没有 `use-rectification-surface.ts`,**不受改名影响**,任务 3 不必在生产跑。`updated_at` 回填是否在生产做由产品定,默认不必。 |