chore(task): archive 08-25-rc-p0-contract-baseline

This commit is contained in:
2026-08-25 16:53:04 +08:00
parent e7bc7f82b1
commit d7c2e13124
26 changed files with 792 additions and 3 deletions

View File

@@ -0,0 +1 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}

View File

@@ -0,0 +1 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}

View File

@@ -0,0 +1,85 @@
# Phase 3 执行计划
## Step 1 — 枚举现有分流逻辑(定 schema 之前)
- [x]`blender/generate_scene.py:796-834` 全部道路分支
- [x] 列出每个 `source` 的处理方式:直接渲染 / 按属性分流 / 跳过
- [ ] 已知分流:
- `center_lines``color != "white"``center_lines` 材质;
`color == "white"``native_center_line_white`
- `lane_separators``color != "yellow"``lane_separators`
`color == "yellow"``native_lane_separator_yellow`
- [x] 确认 `lane_centerlines` / `connectors` 确实未被消费(→ `role: "semantic"`
- [x] 产出 `research/native-layer-consumption-matrix.md`
**门槛**manifest schema 能表达矩阵里的每一行,无"特例硬编码"残留。
## Step 2 — 定 manifest schema 并落契约
- [ ] 按父任务 `design.md` §3.2 定稿 schema
- [ ] 写入编译器仓库契约文档,版本标为 `native-road-package/v1.1`
- [ ] 记录v1.1 起 `manifest.json` 为必需输出
## Step 3 — 编译器侧:生成 manifest
- [ ] 编译器内建立图层注册表(单一事实源),`compileGeometry` 的输出键与之对应
- [ ]`manifest.json` 到 outDir
- [ ] 编译器自校验manifest 声明的每个 `source` 都必须有对应 geojson 文件,
反之亦然(缺一即报错,不静默)
- [ ] parity此步只**新增** manifest.json其余文件应逐字节不变
```bash
# 只应多出 manifest.json
node scripts/road-parity.js --config config/areas/fengshu-er-road.json \
--compare .../baseline/fengshu-er-road.json
```
## Step 4 — Blender 侧:抽模块 + 读 manifest
- [ ] 新建 `blender/osmassets/native_roads.py`
- [ ]`generate_scene.py:796-834` 的道路分支迁入
- [ ] 改为读 manifest 遍历;`role == "semantic"` 跳过
- [ ] `splitBy` 通用化实现,替掉两处硬编码 lambda
- [ ] **加断言**manifest 里的 `materialLayer` 若不在 `catalog.MATERIALS` /
`ROAD_LAYERS` 中,直接 raise不静默跳过风险表第二条
- [ ] 删除 `catalog.NATIVE_ROAD_LAYERS`
- [ ] `generate_scene.py` 只保留一行调用
## Step 5 — 验证
```bash
# .blend 结构摘要对基线
npm run build:area -- --config config/areas/fengshu-er-road.json
# 走 artifact-parity-guide 的结构摘要比对
# 三区域跑通
for a in fengshu-er-road hanyang-block nantaizi-lake-innovation-valley; do
npm run build:area -- --config config/areas/$a.json || echo "FAIL $a"
done
# 建筑/植被/水体未被改动
git diff --stat -- blender/osmassets/ | grep -vE "native_roads|catalog"
```
- [ ] 渲染预览图人工对照(结构摘要粒度不足的兜底)
## Step 6 — AC3.4 实测(可扩展性证明)
这一步是整个 Phase 3 的价值证明,不可跳过。
- [ ] 编译器加一个 throwaway 图层 `debug_probe.geojson`(几个矩形即可)
+ manifest 声明 `role: "marking"`,复用现有材质槽
- [ ] **不改宿主任何代码**,跑 blender 阶段
- [ ] 确认 Blender 场景中出现该图层几何
- [ ] 截图/记录证据到任务 `research/`
- [ ] 回滚 throwaway 图层
## Review Gate
AC3.1AC3.7 全绿,特别是 AC3.4 有实测证据。
## Rollback
- 恢复 `catalog.NATIVE_ROAD_LAYERS``generate_scene.py` 恢复内联分支
- `manifest.json` 可保留输出(无消费方时无害)
- 编译器侧图层注册表保留(它本身是改进)

View File

@@ -0,0 +1,90 @@
# Phase 3道路与建筑渲染分离
父任务:`.trellis/tasks/08-25-road-compiler-extraction/`
技术设计:父任务 `design.md` §3含 manifest 形状与 Blender 侧改造方案)
## Goal
让编译器自声明图层Blender 改为读 manifest 而非硬编码表;
道路渲染从 `generate_scene.py` 抽离为独立模块,建筑/植被/水体保持原位。
**这是全案价值最高的一步** —— 它把一张跨仓库重复的表变成生成物,
使"编译器加图层忘了改宿主"这类静默错误在结构上不可能。
## 背景:当前的静默错误风险
`blender/osmassets/catalog.py:53``NATIVE_ROAD_LAYERS` 有 10 项,
而编译器写 12 个 geojson —— `lane_centerlines``connectors` 是语义层不参与渲染。
**但这个事实只存在于这张表的省略里,编译器侧没有任何声明。**
拆仓库之后,这张表和它描述的对象分处两个仓库,漂移只是时间问题。
`.trellis/spec/pipeline/index.md` 首页已经把图层表标为「最容易出静默错误」。
## Requirements
### R3.1 编译器输出 layer manifest
`<outDir>/manifest.json`,形状见父任务 `design.md` §3.2。要点:
- 每个图层声明 `source`geojson 文件名)、`role`、以及渲染角色所需的 `materialLayer`
- `role: "semantic"` 显式标记不渲染的图层 —— 把省略变成声明
- `splitBy` 表达按属性分流到不同材质的逻辑
(当前 `generate_scene.py:815-819` 硬编码的 `color != "white"` / `color == "yellow"`
- 材质本体颜色、z 高度、贴图)**仍归宿主** `catalog.py::MATERIALS`
编译器不懂渲染,只声明"我有哪些图层、什么角色、该用哪个材质槽"
### R3.2 Blender 侧改造
- `generate_scene.py` 内道路分支抽为 `blender/osmassets/native_roads.py`
- 新模块读 manifest 遍历,不再查硬编码表
- 删除 `catalog.NATIVE_ROAD_LAYERS`
- 建筑(`handle_building` / `dispatch_ways`)、植被、水体**保持原位不动**
### R3.3 契约版本处理
新增 `manifest.json` 是**向后兼容的增量**(旧消费方忽略未知文件即可),
但 Blender 改为依赖它之后就成了必需项。
- 契约文档记录:`manifest.json` 自 v1.1 起为必需输出
- 宿主声明所需最低契约版本
### R3.4 跨层一致性检查
`.trellis/spec/guides/cross-layer-thinking-guide.md`
本改动同时触碰 JS编译器输出、PythonBlender 消费)、契约文档三层,
必须走该指南的检查清单。
## Acceptance Criteria
- [ ] AC3.1 编译器输出 `manifest.json`,三区域均含全部 12 图层声明
- [ ] AC3.2 `catalog.NATIVE_ROAD_LAYERS` 已删除Blender 无硬编码道路图层表
- [ ] AC3.3 `.blend` 结构摘要对 Phase 0 基线一致
(走 `.trellis/spec/guides/artifact-parity-guide.md`
- [ ] AC3.4 **实测**:向编译器加一个 throwaway 图层 + manifest 声明,
不改宿主任何代码,跑 blender 阶段确认它被渲染出来;验证后回滚该图层
(父任务 AC5见 design §3.4
- [ ] AC3.5 `role: "semantic"` 的图层被 Blender 正确跳过(不产生几何)
- [ ] AC3.6 `center_lines` 的 white/非 white 与 `lane_separators` 的 yellow/非 yellow
分流行为与改造前一致
- [ ] AC3.7 建筑/植被/水体渲染代码未被修改(`git diff` 验证范围)
## 依赖与顺序
- **前置**Phase 2 完成编译器已独立manifest 才有"跨仓库契约"的意义)
- 与 Phase 4 无依赖,可并行
- 完成本阶段后,父任务 Goal 中的「道路与建筑渲染分离」才算达成
## 风险
| 风险 | 缓解 |
|---|---|
| `splitBy` 表达力不足,覆盖不了现有分流逻辑 | 先枚举 `generate_scene.py` 里全部分流分支,再定 manifest schema |
| 材质槽名在两侧漂移 | manifest 里的 `materialLayer` 必须能被宿主校验Blender 侧加断言,未知材质槽直接报错而非静默跳过 |
| `.blend` 结构摘要对比粒度不够,漏掉几何差异 | 除结构摘要外,加渲染预览图人工对照 |
## Out of Scope
- 材质定义搬去编译器(材质属渲染,归宿主)
- osm2streets legacy 图层表 `ROAD_LAYERS` 的改动
- 建筑/植被/水体渲染逻辑

View File

@@ -0,0 +1,34 @@
# Native Road 图层消费矩阵
调研日期2026-08-25
## 证据
- 编译器在 `scripts/compile-native-roads.js:57,65-76` 声明并写出 12 个图层。
- Blender 在 `blender/generate_scene.py:796-834` 遍历
`catalog.NATIVE_ROAD_LAYERS`,只消费其中 10 个图层。
- 当前映射及基础高度来自 `blender/osmassets/catalog.py:53-64``ROAD_LAYERS`
## 当前消费与 manifest 目标
| 编译器 source | 当前 Blender 行为 | 当前材质槽 / z 来源 | manifest 目标 |
|---|---|---|---|
| `road_surface` | 直接渲染 | `road_surface` / `ROAD_LAYERS.road_surface` | `role: surface`, `materialLayer: road_surface` |
| `edge_lines` | 直接渲染 | `lane_separators` / `ROAD_LAYERS.lane_separators` | `role: marking`, `materialLayer: lane_separators` |
| `intersection_surface` | 直接渲染 | `intersection_surface` / `ROAD_LAYERS.intersection_surface` | `role: surface`, `materialLayer: intersection_surface` |
| `sidewalk_surface` | 直接渲染 | `sidewalks` / `ROAD_LAYERS.sidewalks` | `role: surface`, `materialLayer: sidewalks` |
| `lane_separators` | 按 `color` 分流 | 非 yellow: `lane_separators`; yellow: `native_lane_separator_yellow`; z 取 `lane_separators` | `role: marking`, `materialLayer: lane_separators`, `splitBy.color`yellow 特例) |
| `center_lines` | 按 `color` 分流 | 非 white: `center_lines`; white: `native_center_line_white`; z 取 `center_lines` | `role: marking`, `materialLayer: center_lines`, `splitBy.color`white 特例) |
| `direction_arrows` | 直接渲染 | `lane_arrows_webscale` / `ROAD_LAYERS.lane_arrows_webscale` | `role: marking`, `materialLayer: lane_arrows_webscale` |
| `turn_arrows` | 直接渲染 | `lane_arrows_webscale` / `ROAD_LAYERS.lane_arrows_webscale` | `role: marking`, `materialLayer: lane_arrows_webscale` |
| `crosswalks` | 直接渲染 | `crosswalks` / `ROAD_LAYERS.crosswalks` | `role: marking`, `materialLayer: crosswalks` |
| `vehicle_stop_lines` | 直接渲染 | `vehicle_stop_lines` / `ROAD_LAYERS.vehicle_stop_lines` | `role: marking`, `materialLayer: vehicle_stop_lines` |
| `lane_centerlines` | 不进入 Blender 遍历 | 无 | `role: semantic`Blender 跳过 |
| `connectors` | 不进入 Blender 遍历 | 无 | `role: semantic`Blender 跳过 |
## 结论与实施约束
- manifest 必须声明全部 12 个编译器图层,不能再用“未出现在列表中”表达不渲染。
- `role: semantic` 的两个图层不得读取 GeoJSON 或创建 Blender 几何。
- `splitBy` 至少需表达属性 `color` 的精确匹配与默认分支,且分流后沿用同一个基础材质槽的 z 值。
- Blender 消费 manifest 时,未知 `materialLayer`、缺失 source 文件、或 source 未在 manifest 声明都必须报错;不能静默跳过。

View File

@@ -0,0 +1,26 @@
{
"id": "rc-p3-render-separation",
"name": "rc-p3-render-separation",
"title": "Phase 3道路与建筑渲染分离",
"description": "编译器输出 layer manifest 自声明图层Blender 改为读 manifest道路渲染从 generate_scene.py 抽离,消除跨仓库重复图层表",
"status": "planning",
"dev_type": null,
"scope": null,
"package": null,
"priority": "P2",
"creator": "dingkang",
"assignee": "dingkang",
"createdAt": "2026-08-25",
"completedAt": null,
"branch": null,
"base_branch": "main",
"worktree_path": null,
"commit": null,
"pr_url": null,
"subtasks": [],
"children": [],
"parent": "08-25-road-compiler-extraction",
"relatedFiles": [],
"notes": "",
"meta": {}
}