diff --git a/crates/intent/src/graph_references.rs b/crates/intent/src/graph_references.rs index a66cf2d..7ad24fa 100644 --- a/crates/intent/src/graph_references.rs +++ b/crates/intent/src/graph_references.rs @@ -701,10 +701,11 @@ fn req_traces_in(document: &Document) -> Vec { { cursor += 1; } + let contains_placeholder = bytes.get(cursor) == Some(&b'<'); while cursor > target_start && bytes[cursor - 1] == b'.' { cursor -= 1; } - if cursor > target_start { + if cursor > target_start && !contains_placeholder { traces.push(ReqTrace { written: line[target_start..cursor].to_string(), range: line_start + found..line_start + cursor, diff --git a/crates/intent/tests/intent_check.rs b/crates/intent/tests/intent_check.rs index 1a9b198..6c444e4 100644 --- a/crates/intent/tests/intent_check.rs +++ b/crates/intent/tests/intent_check.rs @@ -468,7 +468,7 @@ fn graph_json_recognizes_all_supported_requirement_definition_forms() { .expect("requirements"); fs::write( h.repo.join("context/intent/spec.md"), - "# Spec\n\nThis builds on [requirements](./requirements.md).\n\nAPP-R02 and R03 constrain the graph.\nreq: APP-R02\nreq: \nreq: #\n", + "# Spec\n\nThis builds on [requirements](./requirements.md).\n\nAPP-R02 and R03 constrain the graph.\nreq: APP-R02\nreq: \nreq: #\nreq: requirements.md#\nreq: APP-\n", ) .expect("spec"); @@ -511,15 +511,16 @@ fn graph_json_recognizes_all_supported_requirement_definition_forms() { "missing resolved citation for {target}" ); } - assert!( - references.iter().all(|reference| { - reference["syntax"] != "req_trace" - || !reference["written_target"] - .as_str() - .is_some_and(|target| target.contains('<') || target.contains('>')) - }), - "template placeholders must not become requirement traces" + let traces = references + .iter() + .filter(|reference| reference["syntax"] == "req_trace") + .collect::>(); + assert_eq!( + traces.len(), + 1, + "template placeholders must not become requirement traces: {traces:#?}" ); + assert_eq!(traces[0]["written_target"], "APP-R02"); } #[test]