Files
Jyotisha/docs/tasks/TASK-rectification-code-split-20260926.md
T

42 lines
2.7 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 · 生时校正代码拆分(只搬不改)+ 增长上限(2026-09-26)
## 基线
- 排在 `TASK-rectification-fewer-probes-card-20260926` 与 `TASK-rectification-telemetry-20260926` **都合入之后**的 `origin/staging`。分支 `codex/rectification-code-split-20260926`。
## 事故实证(09-26 盘点,`origin/staging` 3ce11ee0)
| 文件 | 行数 | 说明 |
| --- | --- | --- |
| `frontend/src/components/rectification-agentic-chat.tsx` | 2043 | 组件本体约 1620 行;useState 35、useRef 16、useEffect 7、useLayoutEffect 2、useCallback 12 |
| `frontend/src/app/api/rectification/agent/route.ts` | 1077 | `POST` 约 926 行 |
| `frontend/src/lib/rectification-agentic/v9/agent-run.ts` | 1400 | `runV9AgentTurn` 约 1047 行 |
- 无任何行数 / hook 数增长上限(对比首页 `home-shell-growth-contract.test.ts`)。
- 79 个测试文件把这些文件当源码文本读,其中 42 个用 `indexOf` / `sourceBetween` 共 269 处切片;这类测试多次让门禁翻红(BUG-308、342、736、933、940、975、1014、692、748)。
## 决策记录(产品 2026-09-26)
- D1 **只搬代码不改行为**(同首页拆分 `TASK-home-page-split-20260925` 的做法):
- 聊天组件:按职责拆出 hook(快照同步、提交与流、选择题、时间轴 / 范围)与展示组件;参数式 lib 函数内部不调用 React hook。
- `POST`:按分支拆成独立处理函数(打字回答、选择题、开场、只读、交付),`route.ts` 只做装配。
- `runV9AgentTurn`:按阶段拆(准备、单次尝试、收尾、重跑),行为逐行一致。
- D2 目标:聊天组件本体 ≤ 900 行、useState ≤ 20;`POST` ≤ 250 行;`runV9AgentTurn` ≤ 300 行(达不到按让步写明)。
- D3 加增长合同测试(与首页同型:行数基线 + 150 余量、hook 数上限),锁住成果。
- D4 **切源码字符串的测试改为调用被抽出的函数**(行为断言等价或更强);不得删除测试来"解决"断言;每条改写三栏。
## 硬红线
1. 行为零变化:全量前端测试(Node 22)失败名单与开工基线逐条一致、新增 0;Python 快速门通过;首页 / 各页 `○ Static`、gzip ±2%。
2. 不改接口、数据库、Skill、文案、打分。
3. 不得用挤行 / 删注释凑行数(AGENTS §6)。
4. 分阶段提交(组件、路由、agent-run 各自可单独回滚),每阶段都跑全量。
## 任务分解
- T1 聊天组件拆分 + 增长合同。
- T2 路由拆分 + 增长合同。
- T3 agent-run 拆分 + 增长合同。
- T4 切片测试改调用函数(随各阶段进行)。
- T5 记录:CHANGELOG(无用户可见变化)、PROGRESS(每阶段行数 / hook 数 / 测试对比);不开 BUG 号。