From 623481fd2c2233ad17539ab6f967932b0ec454ad Mon Sep 17 00:00:00 2001 From: que01 Date: Mon, 31 Aug 2026 13:13:09 +0800 Subject: [PATCH] chore(task): correct the elementId premise and split the first gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Measured rather than assumed: grouping the 48 stripes by crossing_node_id yields exactly 8 groups of 6, and no crossing maps to more than one road. The uniqueness is structural — compileControlMarkings() iterates model.crossings and each pass emits one group from one candidate — so crosswalk:node/ is already a stable group id and needs no compiler change. The earlier claim that no group id existed conflated the crossing node (node/-26452, the pedestrian crossing) with the junction node (node/1140799725). Different ids. Grouping client-side therefore reads a published identifier rather than clustering by proximity, which is what the PRD forbids. The missing affects entries are real and unchanged, but they only degrade drag highlighting; they do not block selection. The two are now separate steps, and selection moves first because it costs nothing on the server. Co-Authored-By: Claude Opus 5 (1M context) --- .../08-28-crosswalk-element-editor/design.md | 40 ++++++++++++------- .../implement.md | 32 ++++++++------- .../08-28-crosswalk-element-editor/task.json | 2 +- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.trellis/tasks/08-28-crosswalk-element-editor/design.md b/.trellis/tasks/08-28-crosswalk-element-editor/design.md index b1e7055..cc64e5b 100644 --- a/.trellis/tasks/08-28-crosswalk-element-editor/design.md +++ b/.trellis/tasks/08-28-crosswalk-element-editor/design.md @@ -39,26 +39,36 @@ interface EditableElement { 第一阶段发布 `position` 与 `length` / `width`:位置沿用现有 `junction-crosswalk-inset`,尺寸需要新的回写规则(见「尺寸的语义」)。`rotation` **不在本任务范围**,理由见文末。 -## `affects` 与 `elementId` 是同一个洞 +## `elementId` 已经存在 -`junctionAffects()`(`direct-edit-solver.js:628`)构造的是 +实测:48 条条带按 `crossing_node_id` 分组恰好得到 8 组、每组 6 条,且没有任何 +crossing 对应多条道路。唯一性是结构性的——`compileControlMarkings()` 的循环是 +`for (const crossing of model.crossings)`,每次迭代由单个 `crosswalkCandidate` +产出一组。 + +因此 **`crosswalk:node/` 就是稳定的组标识**,无需新增编译器字段。 +条带 `native_id` 形如 `crosswalk:node/-26452:1`,组前缀直接可用; +`crossing_node_id` 也已在 feature 属性里。 + +客户端据此分组**不构成** PRD 禁止的「按经纬度近似聚类」——它读的是已发布的稳定 +标识,不是空间猜测。 + +> 早期分析曾断言组标识缺失,理由是「同一节点的多个进口共用它」。那是把 +> **crossing 节点**(`node/-26452`,人行横道)与 **junction 节点** +> (`node/1140799725`,路口)混为一谈了。两者不是同一个 id。 + +## `affects` 缺失仍是真问题 + +上一节不影响这一节。`junctionAffects()`(`direct-edit-solver.js:628`)构造的是 `junctionSurfaceId + roadAffects + connectors`,**从不加入 crosswalk 或 stop-line**。 实测在有 48 条斑马线的区域,`junction-crosswalk-inset` 手柄的 `affects` 共 59 项, -其中 crosswalk **为 0**。 +crosswalk 为 **0**。 -成因是同一个:斑马线 feature id 用的是 `crosswalk:node/:<序号>`, -而求解器手上没有「进口 → 斑马线组」的映射。那个关系只存在于编译器的 -`compileControlMarkings()` 内部,从未对外发布。 +成因是求解器手上没有「进口 → crossing」的映射:该关系在编译器的 +`compileControlMarkings()` 内部由 `arrivalEndpointIds` 与距离阈值算出,从未对外发布。 -因此下面三件事是一次工作,不是三次: - -| 症状 | 需要的东西 | -| --- | --- | -| `affects` 不含斑马线,拖拽高亮会亮错 | 进口 ↔ 斑马线组映射 | -| 没有稳定 `elementId` | 同上 | -| 点条带无法选中整组 | 同上 | - -补上映射并随 manifest 发布,三者一起解决。这也是第一阶段的第一个门禁。 +后果限于**拖拽高亮会亮错一片**(PRD 第 2 条要求高亮受影响对象)。 +它**不阻塞选中**,因为选中走的是上一节的组标识。两者是独立的两步。 ## 编辑与预览 diff --git a/.trellis/tasks/08-28-crosswalk-element-editor/implement.md b/.trellis/tasks/08-28-crosswalk-element-editor/implement.md index d874d92..39a973c 100644 --- a/.trellis/tasks/08-28-crosswalk-element-editor/implement.md +++ b/.trellis/tasks/08-28-crosswalk-element-editor/implement.md @@ -12,31 +12,33 @@ - 添加失败优先的测试:同组 stripe 需要稳定共享 `elementId`,不同 crossing 不得共享;空编辑输出与基线字节一致。 - 门禁:能证明一个具体 feature 无歧义回链到一个 junction approach 和 crossing。 -## 1. 进口 ↔ 斑马线组映射(第一门禁) +## 1. 元素选择(纯客户端) -`design.md` 已论证 `affects` 不含斑马线、缺少 `elementId`、无法整组选中是**同一个洞**: -求解器没有「进口 → 斑马线组」的映射,该关系只存在于编译器内部。 +`design.md` 已实测确认 `crosswalk:node/` 就是稳定组标识, +条带属性里已有 `crossing_node_id`。**本步不需要改编译器。** -- 编译器为每组斑马线写稳定的组标识与回链属性,随 stripe feature 发布。 -- 求解器建立并消费该映射,使 `junctionAffects()` 不再遗漏 crosswalk。 -- 在 direct-edit 响应中增量发布按 selection/element 获取的元素 manifest,不扩大现有道路 handle 的职责。 -- 验证:编译器单测(同组共享、跨组不共享、重编译后稳定)、API 测试。 -- **门禁**:`junction-crosswalk-inset` 手柄的 `affects` 必须包含它实际移动的那 6 条 crosswalk feature。当前实测为 0,这是本步是否成立的判据。失败即停——后面每一步都依赖这个映射。 - -## 2. 元素选择 - -- 客户端建立 `ElementSelection` 纯状态与 feature 点击适配;点击任一条带选中整组、点空白清除。 -- 选择状态由 App / 编辑会话持有,不写入 baseline source。 +- 客户端建立 `ElementSelection` 纯状态:从 feature 属性推出组标识,不做空间聚类。 +- 点击任一条带选中整组、点空白清除;选择状态由 App / 编辑会话持有,不写 baseline source。 - 元素选中与道路选择可并存,但两组控件不得竞争同一 pointer 手势。 -- 验证:客户端 selection 单元测试;手测切换、取消、与道路级手柄共存。 +- 验证:客户端 selection 单元测试(同组共享、跨组不共享、重编译后稳定)。 +- **门禁**:一个具体 feature 无歧义回链到一个组,且组内条带数与编译输出一致。 -## 3. 选中框与移动 +## 2. 选中框与移动 - 渲染矩形虚线选框(框住整组 6 条)+ 移动抓手,接已有 `junction-crosswalk-inset`。 - 控件走 `App.tsx` 既有的三个出口 `draftValue()` / `settleValue()` / `abandonGesture()`,**不新建第二条预览或 undo 链路**(见 `.trellis/spec/frontend/direct-edit-client.md` §11)。 - 安装时不得影响道路 handle 的 hit-test。 - **门禁**:一次非空元素编辑可在正式重编译结果中观察到斑马线位置变化。只交付 UI 不算通过。 +## 3. 修正 `affects`(服务端) + +独立于第 1 步——选中不依赖它,但拖拽高亮依赖。 + +- 求解器建立并消费「进口 → crossing」映射,使 `junctionAffects()` 不再遗漏 crosswalk。 + 该关系目前只存在于 `compileControlMarkings()` 内部(`arrivalEndpointIds` + 距离阈值)。 +- 验证:API 测试。 +- **门禁**:`junction-crosswalk-inset` 手柄的 `affects` 必须包含它实际移动的那 6 条 crosswalk feature。当前实测为 0。 + ## 4. 编译器尺寸参数化 斑马线几何目前全是字面量(`native-road.js:1264`:长 3m、宽 0.45m、间距 0.9m、6 条)。 diff --git a/.trellis/tasks/08-28-crosswalk-element-editor/task.json b/.trellis/tasks/08-28-crosswalk-element-editor/task.json index 0f38772..9b72057 100644 --- a/.trellis/tasks/08-28-crosswalk-element-editor/task.json +++ b/.trellis/tasks/08-28-crosswalk-element-editor/task.json @@ -3,7 +3,7 @@ "name": "crosswalk-element-editor", "title": "斑马线元素级编辑器实验", "description": "", - "status": "planning", + "status": "in_progress", "dev_type": null, "scope": null, "package": null,