Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

fix(paths): preserve whitespace in Git repository roots (#743)

Afloat85f39def06ab
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c0e6760..5cc200d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,6 +46,9 @@ All notable changes to SkillEvaluator are documented in this file.
release binary.
- Malformed optional trajectory `final_metrics` leave condition usage unavailable
and no longer abort fresh or reused Tier 3 result collection.
+- Git repository-root lookups preserve trailing whitespace in directory names
+ instead of resolving a different path, keeping report links, repository context,
+ and generated-results ignore entries tied to the actual checkout.
- Rebuilding validation results after severity overrides or scanner finding
deduplication no longer repeatedly scans accumulated independent diagnostics;
diagnostic order, duplicate-warning options and summary counts are preserved.
diff --git a/src/skillevaluator/_ci_onboarding_git.py b/src/skillevaluator/_ci_onboarding_git.py
index 871572c0..f3b5a5c4 100644
--- a/src/skillevaluator/_ci_onboarding_git.py
+++ b/src/skillevaluator/_ci_onboarding_git.py
@@ -33,23 +33,32 @@ class SetupError(Exception):
"""A safely described setup failure."""
-def run(args: list[str], *, cwd: Path | None = None, optional: bool = False, timeout: int = 60) -> str:
+def run(
+ args: list[str],
+ *,
+ cwd: Path | None = None,
+ optional: bool = False,
+ timeout: int = 60,
+ preserve_newlines: bool = False,
+) -> str:
env = {k: v for k, v in os.environ.items() if not k.startswith("GIT_")}
env["GIT_TERMINAL_PROMPT"] = "0"
if args[0] in {"gh", "git"}:
env["GH_HOST"] = "github.com"
env.pop("GH_REPO", None)
try:
- result = subprocess.run(args, cwd=cwd, env=env, text=True, capture_output=True, timeout=timeout)
+ result = subprocess.run(
+ args, cwd=cwd, env=env, text=not preserve_newlines, capture_output=True, timeout=timeout
+ )
except (OSError, subprocess.TimeoutExpired) as exc:
raise SetupError(f"Could not run {args[0]}; check that it is installed and responsive.") from exc
if result.returncode and not optional:
# Do not echo subprocess stderr: authentication helpers can include credentials.
raise SetupError(f"{args[0]} could not complete this step. Check authentication, access and repository state.")
- return result.stdout if not result.returncode else ""
+ return os.fsdecode(result.stdout) if not result.returncode else ""
-def git(repo: Path, *args: str, optional: bool = False, network: bool = False) -> str:
+def git(repo: Path, *args: str, optional: bool = False, network: bool = False, preserve_newlines: bool = False) -> str:
command = ["git", "-c", "core.hooksPath=/dev/null", "-c", "core.fsmonitor=false"]
if not network:
command += ["-c", "protocol.allow=never"]
@@ -63,7 +72,7 @@ def git(repo: Path, *args: str, optional: bool = False, network: bool = False) -
"credential.https://github.com.helper=!gh auth git-credential",
]
try:
- return run([*command, *args], cwd=repo, optional=optional)
+ return run([*command, *args], cwd=repo, optional=optional, preserve_newlines=preserve_newlines)
except SetupError as exc:
if network and args and args[0] == "push":
raise SetupError(
@@ -75,7 +84,9 @@ def git(repo: Path, *args: str, optional: bool = False, network: bool = False) -
def repository_root(path: Path) -> Path:
repo = path.resolve(strict=True)
- top = Path(git(repo, "rev-parse", "--show-toplevel").strip()).resolve(strict=True)
+ top = Path(git(repo, "rev-parse", "--show-toplevel", preserve_newlines=True).removesuffix("\n")).resolve(
+ strict=True
+ )
if top != repo:
raise SetupError("Run from the Git repository root, or pass that root using --repo.")
return repo
diff --git a/src/skillevaluator/tier3/grader_validation.py b/src/skillevaluator/tier3/grader_validation.py
index f1480e0b..75b79c05 100644
--- a/src/skillevaluator/tier3/grader_validation.py
+++ b/src/skillevaluator/tier3/grader_validation.py
@@ -479,7 +479,7 @@ def _verifier_git_provenance(paths):
)
if result.returncode or len(result.stdout) > 256 * 1024:
raise ValueError("Git source identity unavailable")
- return result.stdout.decode("utf-8").strip()
+ return result.stdout.decode("utf-8").removesuffix("\n")
try:
repository = Path(git(paths[0].parent, "rev-parse", "--show-toplevel")).resolve()
diff --git a/src/skillevaluator/tier3/results_location.py b/src/skillevaluator/tier3/results_location.py
index d4718665..7aec72fa 100644
--- a/src/skillevaluator/tier3/results_location.py
+++ b/src/skillevaluator/tier3/results_location.py
@@ -1146,7 +1146,7 @@ def git_root_for(path: Path) -> Path | None:
if result.returncode != 0:
return None
# Raw file-name bytes: decode them the way Python encodes paths, not with the locale code page.
- root = os.fsdecode(result.stdout).strip()
+ root = os.fsdecode(result.stdout).removesuffix("\n")
return Path(root).resolve() if root else None
diff --git a/src/skillevaluator/utils/helpers.py b/src/skillevaluator/utils/helpers.py
index d71acec2..84b501d1 100644
--- a/src/skillevaluator/utils/helpers.py
+++ b/src/skillevaluator/utils/helpers.py
@@ -155,7 +155,7 @@ def resolve_git_root(local_path: Path) -> Path | None:
subprocess.check_output(
["git", "rev-parse", "--show-toplevel"], cwd=str(working_dir), stderr=subprocess.DEVNULL
)
- ).strip()
+ ).removesuffix("\n")
except (subprocess.CalledProcessError, FileNotFoundError, OSError):
return None
return Path(root).resolve() if root else None
diff --git a/src/skillevaluator/utils/path_security.py b/src/skillevaluator/utils/path_security.py
index 0feb8df1..10eed549 100644
--- a/src/skillevaluator/utils/path_security.py
+++ b/src/skillevaluator/utils/path_security.py
@@ -89,7 +89,7 @@ def find_git_repo_root(path: Path) -> Path | None:
check=False,
)
# Raw file-name bytes: decode them the way Python encodes paths, not with the locale code page.
- root = os.fsdecode(result.stdout).strip()
+ root = os.fsdecode(result.stdout).removesuffix("\n")
if result.returncode == 0 and root:
return Path(root).resolve()
except Exception:
diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py
index 8a36180c..62edcbf1 100644
--- a/tests/utils/test_helpers.py
+++ b/tests/utils/test_helpers.py
@@ -11,6 +11,8 @@ from unittest.mock import patch
import pytest
+from skillevaluator._ci_onboarding_git import repository_root
+from skillevaluator.tier3.grader_validation import _verifier_git_provenance
from skillevaluator.tier3.results_location import git_root_for
from skillevaluator.utils import find_skills_in_directory, get_skill_name_from_path
from skillevaluator.utils.helpers import (
@@ -269,6 +271,33 @@ def test_every_git_root_lookup_names_a_non_ascii_root(tmp_path: Path, monkeypatc
assert lookup(repo_root / "skills") == repo_root.resolve()
[email protected](sys.platform == "win32", reason="Windows strips trailing whitespace in directory names")
[email protected]("folder", ["repo ", "repo\t", "repo\n", "repo\r"])
[email protected]("lookup", [resolve_git_root, find_git_repo_root, git_root_for], ids=lambda f: f.__name__)
+def test_every_git_root_lookup_preserves_trailing_whitespace(tmp_path: Path, folder: str, lookup) -> None:
+ repo_root = tmp_path / folder
+ _init_git_repo(repo_root, "[email protected]:example/project.git")
+ skill_dir = repo_root / "skills"
+ skill_dir.mkdir()
+
+ assert lookup(skill_dir) == repo_root.resolve()
+
+
[email protected](sys.platform == "win32", reason="Windows strips trailing whitespace in directory names")
[email protected]("folder", ["repo ", "repo\t", "repo\n", "repo\r"])
[email protected]("consumer", ["ci-onboarding", "verifier-provenance"])
+def test_additional_git_root_consumers_preserve_trailing_whitespace(tmp_path: Path, folder: str, consumer) -> None:
+ repo_root = tmp_path / folder
+ commit = _init_git_repo(repo_root, "[email protected]:example/project.git")
+ if consumer == "ci-onboarding":
+ assert repository_root(repo_root) == repo_root.resolve()
+ else:
+ tracked = repo_root / "README.md"
+ assert _verifier_git_provenance([tracked]) == {"verifier_git_commit": commit, "verifier_git_dirty": False}
+ tracked.write_text("changed content\n")
+ assert _verifier_git_provenance([tracked]) == {"verifier_git_commit": commit, "verifier_git_dirty": True}
+
+
class TestResolveGitRemoteUrl:
"""Tests for the Git remote URL resolver used in HTML report links."""