2.2 KiB
2.2 KiB
实施计划:约束范围校验与重放失效
实施顺序
- 在
direct-edit-solver.js搜索所有 manifest 与 apply 分支中的范围常量,建立 anchor/context-aware range resolver,并为 road/junction kind 迁移已有边界。 - 让
makeRoadHandles()/makeJunctionHandles()从该 resolver 填充value.min/value.max;road edge 使用单向 road 和该 side 的 profile,移除 segment 总宽0.45公式。 - 在
applyRoadConstraint()、applyJunctionConstraint()写入前调用相同 resolver,越界使用 kind 明确的 blocking diagnostic,保留现有 rollback snapshot 行为。 - 扩展
reconcileConstraints():已解析、可重放的值若落在新几何范围外则变为stale,并发出range-out-of-bounds;锚点缺失变为anchor-missing,不破坏 pending/conflicted 逻辑。 - 确认
rebaseEdits()的现有 constraint 明细透传 reason;必要时为 response contract 补稳定字段和测试。 - 追加 unit tests:外缘 extrema、直接越界诊断、manifest/solver 同源、几何缩窄后的 stale、不参与求解、anchor stale reason、既有 exact 回归。
- 追加 API integration tests:
editPreview()越界诊断与rebaseEdits()reason/counts。 - 按项目质量门槛运行 format、unit/integration/client/build;对真实 import 做只读 rebase 审计并记录受影响约束数。
验证命令
npm run format:check
npm run test
npm run test:client
npm run build
测试重点不只比较 manifest 数字,还要把 manifest 的每个端点实际提交给 resolver,确认没有 blocking diagnostic。重放测试必须断言 stale constraint 未出现在 road profile / junction plan。
风险点与回退
- 风险文件:
src/compile/direct-edit-solver.js。范围 helper 若错误共享 segment 与 direction 宽度,会再次出现 handle / solver 不一致;新增 fixture-style unit case 固化双向道路场景。 - 兼容性:保留 v2 文档、constraint kind、status 集合与 API 主字段。reason 仅增加细分值。
- 回退:本改动不迁移或覆写存储。若真实目录审计发现意外大量 stale,回退代码即可恢复旧行为,原始 edit documents 不受影响。