Skip to content

Commit f161b70

Browse files
Tomauskaszrng1995
andauthored
Fix false local references from slash-separated prose (#451)
* fix: ignore slash-separated prose references Signed-off-by: Tomas <[email protected]> * fix(references): preserve root-level paths Context: Plain reference matching required a directory segment after an explicit `./`, so `./guide` produced no candidate even though the prefix disambiguates the path from prose. Changes: - Allow zero or more directory segments between `./` and the final path component. - Add the root-level extensionless case to the existing explicit-path regression matrix. Impact: Root-level extensionless references with an explicit `./` resolve again. Unprefixed slash-separated prose remains excluded, and nested explicit paths keep their existing behavior. Validation: - `uv run --extra dev pytest -q tests/nodes/test_security_remediation.py::test_plain_local_reference_requires_an_explicit_path_signal`: 3 passed. - Focused reference-resolver set: 10 passed. - Ruff on the changed source and test files: passed. - `git diff --check`: passed. Notes: None. Signed-off-by: Tomas <[email protected]> * test(references): cover model/provider prose Context: Issue #450 lists model/provider as ordinary slash-separated prose that must not become a local file reference. Changes: - Add model/provider to the existing plain-prose reference regression case. Impact: Extend the false-positive contract coverage without changing production reference parsing. Validation: - Focused reference suite: 14 passed, 57 deselected. - Lint: All checks passed. - Format check: 193 files already formatted. - Build: source distribution and wheel built successfully. - git diff --check: passed. Notes: Bare dotted tokens remain excluded because versions, domains, and identifiers are ambiguous with root-level filenames. Signed-off-by: Tomas <[email protected]> * test(references): guard dotted prose Context: Bare dotted tokens are ambiguous with root-level filenames and can fabricate missing references for versions, domains, or ecosystem names. Changes: - Add SkillSpector 2.10.0, node.js, and example.com to the plain-prose negative reference case. Impact: Protect the partial-analysis boundary from a future broad match of unquoted dotted prose. Validation: - Focused reference suite: 14 passed, 57 deselected. - Ruff check: All checks passed. - git diff --check: passed. Notes: Root-level filenames remain available through quotes, code spans, Markdown links, or an explicit ./ prefix. Signed-off-by: Tomas <[email protected]> --------- Signed-off-by: Tomas <[email protected]> Co-authored-by: Tomas <[email protected]> Co-authored-by: Narendran Raghavan <[email protected]>
1 parent 03e8f56 commit f161b70

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎src/skillspector/references.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class ReferenceResolutionResult:
4444

4545

4646
_PLAIN_RELATIVE_PATH = re.compile(
47-
r"(?<![\w:/.-])((?:\./)?(?:[A-Za-z0-9_.-]+/)+[A-Za-z0-9_.-]+(?:\.[A-Za-z0-9]{1,12})?)(?![\w/.-])"
47+
r"(?<![\w:/.-])((?:\./(?:[A-Za-z0-9_.-]+/)*[A-Za-z0-9_.-]+|"
48+
r"(?:[A-Za-z0-9_.-]+/)+[A-Za-z0-9_.-]+\.[A-Za-z0-9]{1,12}))(?![\w/.-])"
4849
)
4950

5051

‎tests/nodes/test_security_remediation.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,43 @@ def test_full_body_reference_resolver_handles_markdown_and_unique_basename(
352352
assert all(record["status"] == "resolved" for record in records)
353353

354354

355+
def test_plain_slash_separated_prose_is_not_a_reference(tmp_path: Path) -> None:
356+
records = resolve_bundle_references(
357+
tmp_path,
358+
source_path="SKILL.md",
359+
source_text=(
360+
"Compare reads/writes, environment/profile settings, operation/node behavior, "
361+
"and model/provider options. SkillSpector 2.10.0 supports node.js; see example.com."
362+
),
363+
known_paths=["SKILL.md"],
364+
)
365+
366+
assert records == []
367+
368+
369+
@pytest.mark.parametrize(
370+
("source_text", "target_path"),
371+
[
372+
("Read references/guide.md before continuing.", "references/guide.md"),
373+
("Read ./guide before continuing.", "guide"),
374+
("Read ./references/guide before continuing.", "references/guide"),
375+
],
376+
)
377+
def test_plain_local_reference_requires_an_explicit_path_signal(
378+
tmp_path: Path, source_text: str, target_path: str
379+
) -> None:
380+
records = resolve_bundle_references(
381+
tmp_path,
382+
source_path="SKILL.md",
383+
source_text=source_text,
384+
known_paths=["SKILL.md", target_path],
385+
)
386+
387+
assert len(records) == 1
388+
assert records[0]["status"] == "resolved"
389+
assert records[0]["target_path"] == target_path
390+
391+
355392
def test_reference_resolver_rejects_external_and_parent_escape(tmp_path: Path) -> None:
356393
records = resolve_bundle_references(
357394
tmp_path,

0 commit comments

Comments
 (0)