fix: resolve outside_scope design links inside the explicit --root

WEB-00's probe and the Preview fixture exposed a real boundary: when an entry's
nearest CLI project root is a subdirectory, a component link like
`../shared/x.mq.md` is reported as outside_scope without candidate_path even
though it is inside the design command's explicit --root.

Design now derives the physical candidate from the public reference URL only for
that state, resolves it relative to the source module, requires the canonical
target to stay inside --root, and still verifies the exact anchor through the
target module's Analysis. No private loader, file search or label guessing is
introduced; other states keep failing with the candidate diagnostic.

Adds a real-CLI contract test and records the rule/limitation in the evidence.

Refs cflmy/marqdo-web-design#1, cflmy/marqdo#6
This commit was merged in pull request #6.
This commit is contained in:
cflmy committed 2026-11-27 08:52:17 +08:00
1 parent 495d2e4bf7
commit 2f18dede85
3 files changed
+67 -11

No files matched your search

+9
View File
@@ -42,6 +42,15 @@ MARQDO_BIN=<verified marqdo> scripts/ci.sh
- 资源上限与合同建议对齐:文档 100 / 定义 200 / 实例 1000 / 深度 12 / 每行槽 12 / 场景 32 / 转移 128 / 单文件 1 MiB / 总输入 16 MiB;handoff 增加 inputs/events/scenarios/transitions/dependencies/acceptance。
- 测试增至 14 个真实 CLI 契约用例,覆盖上述正例与主要负例(重复 input/event、非法状态、非叶子场景、场景内容指向组件、不可达状态、缺交互、依赖未知/环、空验收、每行槽上限、单文件上限)。
## 补充候选 3:显式 --root 内的 outside_scope 链接
WEB-00 探测发现一个真实边界:CLI 的最近项目根由 entry 父目录决定,组件引用 `../shared/x.mq.md` 时 Analysis 会标 `outside_scope` 且不提供 `candidate_path`,即使目标在设计命令的显式 `--root` 内。Design 的处理(不调用私有 loader、不搜索文件):
- 仅当 reference `state == outside_scope` 且 URL 是不含 scheme、不以 `/` 开头的相对路径时,用公开 URL 的路径部分相对**来源模块目录**解析;
- 解析结果必须 canonicalize 到显式 `--root` 内,否则 `web.link.outside_root`;
- 精确 anchor 仍由目标模块 Analysis 的 anchors 验证;
- 该规则支撑合同 §2 的 `--root` 设计范围;未发现 CLI 私有字段需求,记录为 Design 解释规则(后续若 CLI Analysis 提供显式 root-relative candidate 可简化)。
## 补充候选 2:内容投影、并发一致性与安全边界
- **内容投影**:`ContentBlock`/`ContentLink` 只从 Analysis AST 的结构节点与源码 byte span 投影;raw HTML 一律成为 `[raw HTML as inert text]` 占位,绝不当活动 HTML;组件 `内容` 场景内容均带 block/link span,Preview 不需要自行解析 Markdown。