Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions python/tests/test_strix_scenario_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ def test_public_exception_message_redacts_windows_paths():
assert "<external>/missing.yaml" in sanitized


def test_public_path_prefers_repo_relative_windows_paths(monkeypatch):
module = _load_module()
root = module.PureWindowsPath("C:/repo")
scenario = module.PureWindowsPath("C:/repo/sim/scenarios/a.yaml")

monkeypatch.setattr(module, "ROOT", root)

assert module.public_path(scenario) == "sim\\scenarios\\a.yaml"


def test_public_scenarios_satisfy_contract():
module = _load_module()
scenario_dir = Path(__file__).resolve().parents[2] / "sim" / "scenarios"
Expand Down
4 changes: 2 additions & 2 deletions scripts/strix_scenario_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def public_path(path: Path) -> str:
"""Return a report-safe path without leaking local checkout layout."""

path_str = str(path)
if path.is_relative_to(ROOT):
return str(path.relative_to(ROOT))
if re.match(r"^[A-Za-z]:[\\/]", path_str) or path_str.startswith("\\\\"):
name = PureWindowsPath(path_str).name or "."
return f"<external>/{name}"
if path.is_relative_to(ROOT):
return str(path.relative_to(ROOT))
if path.is_absolute():
name = path.name or "."
return f"<external>/{name}"
Expand Down
Loading