# Codex Prompt: T1a Fix v2 — Round 3 Bug Fixes（修 Round 2 实施的 4 个 bug）

> **本 prompt 在新 Session 中执行**——你（executor）没有之前对话的上下文。所有需要的输入都在仓库文件里，按下面"必读前置"读完。
>
> **任务性质**：纯 debug + bug fix——按已批准的 plan + 真源 + 接口契约**修 Round 2 实施时引入的 4 个 bug**。**没有任何抽象设计任务**——所有 schema / 算法接口 / verdict 类型 / 实例都已 plan owner 写完。你只做"定位 bug + 修 bug + 验证修复"。

---

## 必读前置（按顺序，不能跳）

新 Session 必须先把以下文件读全：

1. **`AGENTS.md`** — 项目级 AI 协作入口（看 executor 角色行为约束）
2. **`docs/meta-rules.md`** — 元规则真源（看反模式清单 + 触发器 G + 触发器 H + 实证沉淀附录）
3. **`docs/internal/_plans/t1a-fix-v2-plan.md`** — Plan v2（589 行，已批准；§3 verdict 表 + §6.5 audit 算法 + §8 sanity check）
4. **`src/design-system/translation/axis-implementation-map.md`** — Axis 实现层级真源（§2 enum + §3 schema + §4 16 个实例 + §5 audit 消费契约）
5. **`figma-sync/audit-component-token-fidelity.mjs`** — Round 2 实施的 audit 脚本（1703 行，含 4 个 bug，本轮修补）
6. **`docs/internal/component-token-fidelity-report.md`** — Round 2 跑出的报告（1569 行，4 个 bug 的现场）
7. **`figma-data/normalized/component-token-fidelity.audit.json`** — Round 2 机读 JSON
8. **`docs/internal/_prompts/t1a-fix-v2-round2-implementation.prompt.md`** — Round 2 prompt（参考上轮指令）

读完前不要写任何代码。

---

## 你的角色边界（meta-rules 触发器 G）

| 已定（不要改 / 不要重新设计） | 你要做（debug + fix） |
|---|---|
| Schema 字段定义（真源 §3） | 不动 |
| 实现层级 enum（真源 §2） | 不动 |
| Audit 消费契约（真源 §5） | 不动 |
| 16 个实例（真源 §4） | 不动 |
| Plan v2 全部内容 | 不动 |
| 新 verdict 类型 + evidenceLevel 映射 | 不动 |
| Vue AST 解析方案 / palette 求值 / hex 比对 / 5 个 verify\*() 接口契约 | 不动 |

**严禁做的事**：

- ❌ 改 `axis-implementation-map.md`（plan owner 真源）
- ❌ 改 `docs/internal/_plans/t1a-fix-v2-plan.md`（已批准）
- ❌ 加新 verdict 类型（plan §3 已定）
- ❌ 改 `src/**` 任何代码
- ❌ 改 `figma-data/raw/**` / `figma-data/published/**`
- ❌ 改其它 `figma-sync/*.mjs`（除 `audit-component-token-fidelity.mjs` 和可能的 `lib/`）
- ❌ 自创算法 / 偏离 plan §4-6.5 接口契约
- ❌ git add / git commit / git push

---

## 4 个待修 bug（含机械验证现场）

### Bug P0-1：Tooltip 段在报告中完全空白

**现场**：

```bash
$ awk '/^### Component: Tooltip/,/^### Component:/' docs/internal/component-token-fidelity-report.md
### Component: Tooltip (1408:17152)
（后面没有 axes 行、没有 finding 表）
```

v1.5 报告里 Tooltip 有完整 finding（参考 git history 的 v1.5 状态或 grep "tooltip-text" 当前已存在的旧痕）。Round 2 v2 整段丢失。

**期望修复后**：

- Tooltip 段含 `axes:` 行（至少含 `theme [dark|light] × pointing [...]`）
- finding 表至少 1 行
- 至少 1 条 finding 标 `✅ token-match-via-custom-property-chain`（因为 axis-implementation-map.md Instance 11 把 Tooltip 登记为 css-custom-property-chain layer）

**诊断方向**（让 executor 自己查）：

- Tooltip 在 figma-data 是否被读到？（`ls figma-data/normalized/components-tokenized/ | grep -i tooltip`）
- parseAxisImplementationMap() 是否正确解析了 Instance 11 (Tooltip)？加 console.log 验证
- 为什么 finding 集合最终被丢弃？检查报告生成段是否过滤了 Tooltip
- GLOBAL_AXIS_ALIASES 标准化（脚本 step 2）是否对 Tooltip 的 `dark theme` axis 做了不当处理

### Bug P0-2：Select 段 feature axis 完全消失

**现场**：

```bash
$ awk '/^### Component: Select/,/^### Component:/' docs/internal/component-token-fidelity-report.md | grep -c 'feature='
0
```

v1.5 Select axes 行：`axes: theme [dark|light] × enable [off|on] × feature [date|default|time] × size [L|M] × status [...] × ux [...]`

v2 没了 feature axis 的 variants。DateTime 的关键 axis 完全不见。

**期望修复后**：

- Select 段 axes 行包含 `feature [date|default|time]`（保留 v1.5 的 axis 完整性）
- finding 表含 `feature=date` / `feature=time` variants（至少各 1 条）
- 这些 variants **不应**被标 `axis-branch-missing`——按 axis-implementation-map.md Instance 2/7/8/9 应被标 `✅ token-match-via-prop`，或 Instance 13（DateTime topology）的 `✅ token-match-via-topology`

**诊断方向**：

- Select 多 component set 合并逻辑（fix patch v1 加的）是否在合并 axes 时把 feature 漏了？
- v2 算法是否在标准化或路由时把 feature 当成了不存在的 axis？
- variant.name 解析 → axis tuple 是否正确包含 `feature: 'date'/'time'/'default'`？

### Bug P1-1：Tab 的 token-match-via-topology 假阳性（12 条全错）

**现场**：

```
| Type=Line | dimension-w | `92px` | `Line` — src/components/Tab/Tab.vue | ✅ token-match-via-topology | direct |
                                      ^^^^
                                  这是 axis 值字符串，不是 CSS value
```

`code` 列的 `"Line"` / `"Text"` / `"Filled"` 是 figma axis Type 的值——**不是 CSS dimension value**。algorithm 错把 axis tuple 的某个 string value 拿来跟 figma value 比对，且对上了（`92px` ≠ `Line` 应该不等才对——为什么标 token-match）。

**期望修复后**：

- `verifyCrossComponentTopology` 的输出 `code.value` **绝不能**是 axis tuple 字符串
- 该函数对 dimension finding 应不输出 `✅ token-match-via-topology`（因为 dimension 不是 token 概念，应跳过或标其它 verdict）
- Tab 的 Tab.vue 文件不应出现在 `code.filePath` 字段除非有真实的代码引用

**诊断方向**：

- 看脚本 line 897 / 1019 / 1104 附近的 verifyCrossComponentTopology / 主算法 switch 实现
- code.value 拼接逻辑哪里把 axis 值字符串当成 CSS value？
- topology layer 的 verify 是否应该限制在 fill / stroke / text-fill 等颜色 finding，跳过 dimension finding？

### Bug P1-2：CSS custom property chain 函数存在但 0 触发

**现场**：

```
脚本第 897 行：function verifyCssCustomPropertyChain(...)（函数存在）
报告 Summary：✅ token-match-via-custom-property-chain | 0
```

axis-implementation-map.md Instance 11 (Tooltip) + Instance 12 (Input) 都登记为 `css-custom-property-chain` layer。但**0 个 finding 被路由到该 verdict**。

**期望修复后**：

- Tooltip 段 / Input 段至少出现若干条 `✅ token-match-via-custom-property-chain`（具体数量取决于 figma fills 跟 code custom property chain 的匹配度）
- Summary 该 verdict 计数 > 0

**诊断方向**：

- `auditAxisValue()` 主算法 switch 分支是否真的调用了 `verifyCssCustomPropertyChain`？
- `parseAxisImplementationMap()` 是否正确解析 Instance 11/12 的 `codeImplementationLayer: css-custom-property-chain`？
- `extractCssCustomProperties()` 函数是否能从 Tooltip.vue / Input.vue 读出 `.tooltip-box--light { --tooltip-text: ... }` 这种 selector 链？
- `verifyCssCustomPropertyChain` 的成功条件是不是过严？

---

## 任务清单

### 任务 1：定位 + 修 4 个 bug

按上面的 4 个 bug 顺序修：

- 每个 bug 先**写一段诊断笔记**（在脚本 /// 注释或单独 markdown 草稿）说明根因
- 再修代码
- 修完跑一次 `node figma-sync/audit-component-token-fidelity.mjs` 验证

可以加临时 console.log 调试，**修完后必须删掉所有 console.log**（除非是真要保留的运行时日志）。

### 任务 2：跑 audit + 产新报告

```bash
node figma-sync/audit-component-token-fidelity.mjs
```

报告路径不变，覆写 Round 2 版本。

### 任务 3：Sanity check（按 plan §8 + Round 2 sanity 10 项 + 本轮 4 个 bug 修复点）

| # | 检查项 | 期望 |
|---|---|---|
| 1 | HEAD 不动 | `git log --oneline -1` 应仍 `c9032ad` |
| 2 | 脚本幂等 | 跑两次 git diff 报告仅时间戳差 |
| 3 | **Tooltip 段非空** | `awk '/^### Component: Tooltip/,/^### Component:/' report.md \| wc -l` ≫ 1 |
| 4 | **Tooltip 段含 token-match-via-custom-property-chain** | `awk '/^### Component: Tooltip/,/^### Component:/' report.md \| grep -c 'token-match-via-custom-property-chain'` ≥ 1 |
| 5 | **Select 段 axes 行含 feature** | `grep -A1 '^### Component: Select' report.md \| grep -c 'feature \['` ≥ 1 |
| 6 | **Select 段 feature variants 不标 axis-branch-missing** | feature=date / feature=time variants 应标 token-match-via-prop 或 token-match-via-topology |
| 7 | **Tab token-match-via-topology 不标 dimension** | `grep 'token-match-via-topology' report.md \| grep -cE '\\| dimension-'` 应为 0 |
| 8 | **token-match-via-custom-property-chain 总数 > 0** | Summary 应显示 > 0 |
| 9 | Button via-indirection > 2500（plan §8） | 应保持 |
| 10 | 总 finding 数 ~ 36000（plan §8） | 不大幅波动 |
| 11 | direct 类 finding 数 > Round 2 的 7423 | 修 bug 后应增加 |
| 12 | 没改禁止文件 | `git diff --name-only` 不含 `axis-implementation-map.md` / `_plans/` / `src/*` / 其它 `figma-sync/*` |

如果某项不达预期，**先报告原因**（"修了 X，导致 Y 数字变化是因为 Z"），不要硬调算法去对上数字。

### 任务 4：⚠️ 不要 commit

```
❌ git add
❌ git commit
❌ git push
❌ git stash
```

允许新增 / 修改：

- ✅ `figma-sync/audit-component-token-fidelity.mjs`（修 bug）
- ✅ `figma-sync/lib/*.mjs`（如已存在，可改；如不存在，可新增）
- ✅ `docs/internal/component-token-fidelity-report.md`（覆写）
- ✅ `figma-data/normalized/component-token-fidelity.audit.json`（覆写）

---

## 任务 5：完成后 STOP + 报告关键数字

```
4 个 bug 修复状态：
  P0-1 Tooltip 段空白：✅ 修复 / ⚠️ 部分 / ❌ 未修复（+ 根因一句话）
  P0-2 Select feature 消失：同上
  P1-1 Tab topology 假阳性：同上
  P1-2 custom-property-chain 0 触发：同上

Sanity check 12 项：
  通过：N / 12
  未通过项：[列出来 + 原因]

Verdict 分布变化（vs Round 2）：
  ✅ token-match-via-custom-property-chain: Round2=0 → Round3=N
  ✅ token-match-via-topology: Round2=12（全假阳性） → Round3=N（应为真实拓扑命中）
  ✅ token-match-via-prop: Round2=72 → Round3=N（feature=date/time 修复后应增加）
  ⚠️ axis-branch-missing: Round2=13107 → Round3=N（应减少，因 feature axis 修复）

Tooltip 段：
  finding 数：N（Round2=0）
  含 token-match-via-custom-property-chain：N 条

Select 段：
  axes 行：[复制粘贴]
  feature=date / feature=time variants 数：N

Tab 段 dimension-* 标 token-match-via-topology：
  应为 0；实际：N

工作区状态：
  modified: N
  untracked: N
  HEAD: c9032ad（应不变）
```

**STOP。不要进 T1b。不要 commit。**

---

## 完成标准（机械可验证）

满足全部条件 → 任务完成：

1. 4 个 bug 全部 ✅ 修复
2. Sanity check 通过 ≥ 10 / 12（未通过项已报告原因）
3. HEAD 仍 `c9032ad`
4. 没有改禁止文件
5. 临时 console.log 已删除

任一不满足 → 在报告里说明，让 plan owner 决定是否修正。

---

## 给 executor 的元提醒（meta-rules 触发器 G 反向兜底）

如果你在新 Session 中执行本 prompt 时发现：

- prompt 让你"**设计 X**" / "**决定哪些算 Y**" / "**选定 Z 原则**" → **这是 plan owner 漏写了真源**，**报告给 plan owner**，不要自己设计
- 真源（axis-implementation-map.md / plan / meta-rules）跟 prompt 矛盾 → **报告给 plan owner**，不要自己仲裁
- bug 比预期复杂（如修 P0-2 发现需要重新设计 axis 标准化逻辑） → **报告给 plan owner**，不要自己重设计算法

按 meta-rules 反模式 #3："产出契约思维"——你的产出（修复后的 audit）必须能让下游（T1b）机械区分真源 vs 推断。如果你修 bug 时不确定如何映射 evidenceLevel/evidenceSource，**报告给 plan owner**。

完成后 STOP。
