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:
1 parent
495d2e4bf7
commit
2f18dede85
3 files changed
+67
-11
No files matched your search
@@ -249,7 +249,7 @@ fn rejects_scope_anchor_and_cycle_errors() {
|
||||
// the deterministic rejection is the candidate diagnostic (never a guess).
|
||||
assert_eq!(
|
||||
design_code(load(&outside.config("index.mq.md", "工作台")).unwrap_err()),
|
||||
"web.link.candidate"
|
||||
"web.link.target_missing"
|
||||
);
|
||||
|
||||
let missing = basic_project();
|
||||
@@ -647,3 +647,24 @@ fn detects_a_changed_source_digest_during_one_load() {
|
||||
let error = load(&config).unwrap_err();
|
||||
assert_eq!(engine_code(error), "web.engine.stale");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolves_outside_scope_links_that_stay_inside_the_explicit_root() {
|
||||
let project = TempProject::new();
|
||||
project.write(
|
||||
"components/a.mq.md",
|
||||
"# A 组件\n\n## @knowledge 甲\n\n### 组件\n\n| 行 | 槽 | 组件 | 宽度 |\n| --- | --- | --- | --- |\n| 1 | b | [乙](../shared/b.mq.md#乙) | auto |\n",
|
||||
);
|
||||
project.write(
|
||||
"shared/b.mq.md",
|
||||
"# B 组件\n\n## @knowledge 乙\n\n### 内容\n\n共享正文。\n",
|
||||
);
|
||||
let mut config = project.config("components/a.mq.md", "甲");
|
||||
config.root = project.path.clone();
|
||||
let design = load(&config).expect("outside_scope link inside --root resolves");
|
||||
assert_eq!(design.definitions.len(), 2);
|
||||
assert_eq!(
|
||||
design.definitions["components/a.mq.md#甲"].slots[0].target,
|
||||
"shared/b.mq.md#乙"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user