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.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
fix(tier3): mask skill and home paths and keep more text in feedback chat evidence (#364)
Narendran Raghavan4fd19a8d1c37
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1d35f05a..8cd60544 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -31,10 +31,12 @@ All notable changes to SkillEvaluator are documented in this file.scores, measured agent tokens and seconds, execution errors, and the report'ssaved feedback, without evaluating again or regenerating LLM feedback. It usesthe configured `SKILL_EVAL_LLM_PROVIDER` and `SKILL_EVAL_LLM_MODEL`, sends the- run ID instead of the local path, redacts credential-shaped text, and writes- nothing to disk. No request is sent before the first question. `LLMClient`- gains `chat(messages)` for multi-turn requests with the same retries and typed- errors as `completions()`.+ run ID instead of the local path, writes the evaluated skill's directory as+ its name and the home directory as `~`, leaves URL spans unchanged during+ local-path scrubbing, redacts credential-shaped text, and writes nothing to+ disk. No request is sent before the first question.+ `LLMClient` gains `chat(messages)` for multi-turn requests with the same+ retries and typed errors as `completions()`.- Opt-in `LLM_JUDGE_FALLBACK_POLICY` and `LLM_JUDGE_RETRY_POLICY` for the Tier 3standard judges. `LLM_JUDGE_FALLBACK_POLICY=replace` lets only the judgediff --git a/docs/cli-reference.mdx b/docs/cli-reference.mdxindex 651b60c6..1bc4958a 100644--- a/docs/cli-reference.mdx+++ b/docs/cli-reference.mdx@@ -642,9 +642,16 @@ run's compact evidence to that provider. The evidence names the run by its IDinstead of its local path. In every text field, such as errors, warnings, casequestions and saved feedback, an absolute path that ends in the run's directoryis replaced with that ID. This covers the path a copied run had on the machine-where it ran, unless that path contains a space. Credential-shaped text is-redacted before the text is shortened, and a shortened field ends in-`...<truncated>`. The command writes nothing to disk.+where it ran, also when it starts with `~user/`, `$HOME/`, `${HOME}/` or+`%USERPROFILE%\`, unless that path contains a space. A path joined to it, such as+`/usr/bin` in `PATH=/usr/bin:/home/ci/results/RUN_ID`, is kept. A root right after+`,` `;` `:` `=` `(` `[` or `{` starts a new path, so a directory name that ends in+one of those characters before a `/` is read as two paths and only the second is+replaced. The evaluated skill's directory+is replaced with its name and your home directory with `~`; the skill directory+is known when you pass `--skill` or the run is in the skill's `evals/results`+directory. Credential-shaped text is redacted before the text is shortened, and+a shortened field ends in `...<truncated>`. The command writes nothing to disk.No request is sent before the first question, so the command exits 0immediately when standard input is empty. Piped input sends each line as adiff --git a/src/skillevaluator/evaluation/tier3_feedback_chat.py b/src/skillevaluator/evaluation/tier3_feedback_chat.pyindex 31e0e92a..0b10a4fa 100644--- a/src/skillevaluator/evaluation/tier3_feedback_chat.py+++ b/src/skillevaluator/evaluation/tier3_feedback_chat.py@@ -32,7 +32,7 @@ from skillevaluator.inference.diagnostics import llm_failure_diagnosticfrom skillevaluator.inference.types import LLMClientError, LLMClientRefusedError, LLMClientTruncatedErrorfrom skillevaluator.logging_config import get_loggerfrom skillevaluator.provider_config import ProviderConfigurationError, resolve_llm_provider-from skillevaluator.utils.redaction import redact_sensitive_text+from skillevaluator.utils.redaction import credential_safe_cut, redact_sensitive_textlogger = get_logger(__name__)@@ -52,7 +52,8 @@ _MAX_EXPLANATION_CHARS = 600_MAX_CASE_EVIDENCE_CHARS = 300_000# A field is masked over ``limit * 4 + 256`` characters, cut back to the last# whitespace. Text with no whitespace after its limit is masked over this many-# characters instead, so the token that crosses the limit is kept.+# characters instead, so the token that crosses the limit is kept; past this+# window it is cut back to the last punctuation no credential contains._MAX_UNBROKEN_MASK_CHARS = 65_536# Ends every shortened field, as in ``redact_sensitive_text(max_len=...)``._TRUNCATED_MARKER = "...<truncated>"@@ -245,68 +246,195 @@ def _finite_score(value: Any) -> float | None:return round(number, 4) if number is not None else None+# Characters that continue a name, so a root right after one is not a root (``a/b`` is not ``/b``).+_NAME_CHARS = "_.~-"+# An absolute-path root: POSIX or UNC, the home of this or another user (``~/``,+# ``~alice/``), a drive letter, or a home variable.+_ABSOLUTE_PATH_ROOT = re.compile(r"[\\/]|~[\w.-]*[\\/]|[A-Za-z]:[\\/]|(?:\$HOME|\$\{HOME\}|%USERPROFILE%)[\\/]")+# A root right after one of these starts a path of its own: ``/opt/bin,/home/a``,+# ``--out=/home/a``, ``log(/home/a)``. A colon counts unless it is a drive letter's.+_PATH_LIST_SEPARATORS = ",;:=([{"+_FILE_URL_LOCALHOST_PATH_RE = re.compile(r"(?i)\b(?P<prefix>file://localhost)(?P<path>/\S*)")+_URL_SPAN_RE = re.compile(r"(?i)\b(?!file:)[a-z][a-z0-9+.-]*://\S+")++def _starts_absolute_path(value: str, index: int) -> bool:- """Whether a POSIX, home, UNC or drive-letter absolute path starts at ``index``.+ """Whether a POSIX, home, UNC, drive-letter or home-variable absolute path starts at ``index``.The character before it must not belong to a name, so ``a/b`` is not read as ``/b``."""- if index and (value[index - 1].isalnum() or value[index - 1] in "_.~-"):+ if value[index] not in "/\\~$%" and value[index + 1 : index + 2] != ":":+ return False+ if index and (value[index - 1].isalnum() or value[index - 1] in _NAME_CHARS):return False- head = value[index : index + 3]- if head[:1] in ("/", "\\"):+ return _ABSOLUTE_PATH_ROOT.match(value, index) is not None+++def _follows_path_separator(value: str, index: int) -> bool:+ """Whether the character before ``index`` ends an earlier path or option.++ The colon of a drive letter (``C:\\``) does not: it belongs to the path.+ """+ if not index or value[index - 1] not in _PATH_LIST_SEPARATORS:+ return False+ if value[index - 1] != ":":return True- if head[:1] == "~":- return head[1:2] in ("/", "\\")- return len(head) == 3 and head[0].isascii() and head[0].isalpha() and head[1] == ":" and head[2] in "/\\"+ letter = index - 2+ is_drive = (+ letter >= 0+ and value[letter].isascii()+ and value[letter].isalpha()+ and (letter == 0 or not (value[letter - 1].isalnum() or value[letter - 1] in _NAME_CHARS + "/\\"))+ )+ return not is_drive+++def _path_start(value: str, start: int, end: int) -> int | None:+ """Where the absolute path that ends at ``end`` starts, searching from ``start``.++ It starts at the first root, unless a later root follows a path separator+ (``/opt/bin,/home/a``, ``PATH=/usr/bin:/home/a``); then that later root+ starts it and the text before it is kept. A separator that is not followed+ by a root (``/home/a/my(project)``) is part of the path.+ """+ for index in range(end, start, -1):+ if (+ value[index - 1] in _PATH_LIST_SEPARATORS+ and _follows_path_separator(value, index)+ and _starts_absolute_path(value, index)+ ):+ return index+ return next((index for index in range(start, end + 1) if _starts_absolute_path(value, index)), None)+++def _path_spellings(path: Path) -> set[str]:+ """``path`` as written natively, with ``/``, and with ``\\`` escaped as in JSON."""+ native = str(path)+ return {native, path.as_posix(), native.replace("\\", "\\\\")}+++def _home_dir() -> Path | None:+ try:+ return Path.home()+ except (KeyError, OSError, RuntimeError):+ return None+++def _local_skill_dir(skill_path: Path, run_dir: Path) -> Path | None:+ """The evaluated skill's directory on this machine, when it is known.++ An explicit ``--skill`` is already resolved. An inferred skill is only the+ recorded name, but a run kept in the skill's own ``evals/results``+ directory still names the skill directory.+ """+ if skill_path.is_absolute():+ return skill_path+ candidate = run_dir.parent.parent.parent+ if (+ run_dir.parent.name == "results"+ and run_dir.parent.parent.name == "evals"+ and candidate.name+ and _name_key(candidate.name) == _name_key(skill_path.name)+ ):+ return candidate+ return None@dataclass(frozen=True)class _Scrubber:- """Replace the run's host path with its ID and redact credentials in text sent to the provider."""+ """Replace local paths and redact credentials in text sent to the provider.++ The run's directory becomes its ID, the evaluated skill's directory its+ name, and the home directory ``~``.+ """- host_paths: tuple[str, ...]+ # This machine's paths, longest first, as one alternation; group ``p<n>``+ # is replaced with ``replacements[n]``.+ local_paths: re.Pattern[str] | None+ replacements: tuple[str, ...]run_id: str# A separator, then the run ID as a whole path segment (not ``<id>_old`` or ``<id>.log``).run_reference: re.Pattern[str]@classmethod- def for_run(cls, run_dir: Path) -> _Scrubber:- paths = (str(run_dir), run_dir.as_posix())+ def for_run(cls, run_dir: Path, *, skill_dir: Path | None = None, home: Path | None = None) -> _Scrubber:run_id = run_dir.name+ # The run directory is replaced wherever it occurs, as a prefix of+ # longer names too. The skill and home directories are replaced only as+ # whole paths, so ``/home/alice2`` is not read as ``~2``.+ entries: dict[str, tuple[str, bool]] = {}+ for spelling in (str(run_dir), run_dir.as_posix()):+ entries.setdefault(spelling, (run_id, False))+ for directory, replacement in ((skill_dir, skill_dir.name if skill_dir else ""), (home, "~")):+ if directory is not None and replacement:+ for spelling in _path_spellings(directory):+ entries.setdefault(spelling, (replacement, True))+ ordered = sorted(+ ((spelling, *entry) for spelling, entry in entries.items() if len(spelling) > 1),+ key=lambda entry: len(entry[0]),+ reverse=True,+ )+ alternatives = [+ rf"(?<![\w.~-])(?P<p{index}>{re.escape(spelling)})(?![\w-]|\.\w)"+ if whole+ else rf"(?P<p{index}>{re.escape(spelling)})"+ for index, (spelling, _replacement, whole) in enumerate(ordered)+ ]return cls(- tuple(dict.fromkeys(path for path in paths if len(path) > 1)),+ re.compile("|".join(alternatives)) if alternatives else None,+ tuple(replacement for _spelling, replacement, _whole in ordered),run_id,re.compile(r"[\\/]" + re.escape(run_id) + r"(?![\w-]|\.\w)"),)- def paths(self, value: str) -> str:- """``value`` with each absolute path that ends in the run's directory replaced by the run ID.+ def _local(self, match: re.Match[str]) -> str:+ return self.replacements[int(str(match.lastgroup)[1:])]- This run's own path is replaced first, spaces included. A copied run- keeps its ID, so the path it had on another machine is found by its- last segment: the path starts at the first absolute-path root after- the preceding whitespace or quote. Such a path that contains a space- is not recognized. Relative paths are kept.+ def paths(self, value: str) -> str:+ """``value`` with local paths replaced, and each absolute path that ends in the run's directory.++ This machine's run, skill and home directories are replaced first,+ spaces included; the longest wins. A copied run keeps its ID, so the+ path it had on another machine is found by its last segment: the path+ starts at the first absolute-path root after the preceding whitespace+ or quote, or at a later root that follows ``,;:=([{``. Such a path+ that contains a space is not recognized. Relative paths are kept.+ URL spans through the next whitespace are left unchanged."""- for host_path in self.host_paths:- value = value.replace(host_path, self.run_id)- if not self.run_id or self.run_id not in value:- return value++ def scrub_segment(segment: str) -> str:+ if self.local_paths is not None:++ def scrub_localhost_file_url(match: re.Match[str]) -> str:+ path = self.local_paths.sub(self._local, match.group("path"))+ return f"{match.group('prefix')}/{path.lstrip('/')}"++ segment = _FILE_URL_LOCALHOST_PATH_RE.sub(scrub_localhost_file_url, segment)+ segment = self.local_paths.sub(self._local, segment)+ if not self.run_id or self.run_id not in segment:+ return segment+ pieces: list[str] = []+ done = floor = 0+ for match in self.run_reference.finditer(segment):+ start = match.start()+ # The walk back stops at the previous match, so the scan stays linear.+ while start > floor and not segment[start - 1].isspace() and segment[start - 1] not in "\"'`<>|":+ start -= 1+ root = _path_start(segment, start, match.start())+ floor = match.end()+ if root is not None:+ pieces.extend((segment[done:root], self.run_id))+ done = match.end()+ pieces.append(segment[done:])+ return "".join(pieces)+pieces: list[str] = []- done = floor = 0- for match in self.run_reference.finditer(value):- start = match.start()- # The walk back stops at the previous match, so the scan stays linear.- while start > floor and not value[start - 1].isspace() and value[start - 1] not in "\"'`<>|":- start -= 1- root = next(- (index for index in range(start, match.start() + 1) if _starts_absolute_path(value, index)), None- )- floor = match.end()- if root is not None:- pieces.extend((value[done:root], self.run_id))- done = match.end()- pieces.append(value[done:])+ done = 0+ for match in _URL_SPAN_RE.finditer(value):+ pieces.append(scrub_segment(value[done : match.start()]))+ pieces.append(match.group())+ done = match.end()+ pieces.append(scrub_segment(value[done:]))return "".join(pieces)def text(self, value: str, limit: int | None = None) -> str:@@ -317,7 +445,10 @@ class _Scrubber:bounded window, as in the plugin evidence helpers, and drops thetoken cut at the window's edge. When that token starts before``limit`` (compact JSON, a minified error), a larger window is masked- so the field is not blanked. A shortened field ends in the marker.+ so the field is not blanked. Text longer than that window is cut at+ its last punctuation that no credential contains (``,`` ``"`` ``}``),+ so a long minified body keeps its prefix too. A shortened field ends+ in the marker."""value = self.paths(value)if limit is None:@@ -325,6 +456,9 @@ class _Scrubber:window = limit * 4 + 256if len(value) > window and not any(char.isspace() for char in value[limit:window]):window = max(window, _MAX_UNBROKEN_MASK_CHARS)+ if len(value) > window:+ masked = redact_sensitive_text(value[: credential_safe_cut(value, window)])+ return masked[: limit - len(_TRUNCATED_MARKER)] + _TRUNCATED_MARKERmasked = redact_sensitive_text(value, max_input_chars=window)if len(masked) <= limit and len(value) <= window:return masked@@ -569,15 +703,18 @@ def _scrub(value: Any, scrub: _Scrubber) -> Any:return value-def compact_run_context(payload: dict[str, Any], *, run_dir: Path) -> dict[str, Any]:+def compact_run_context(+ payload: dict[str, Any], *, run_dir: Path, skill_dir: Path | None = None, home: Path | None = None+) -> dict[str, Any]:"""Trim the payload to the evidence the feedback chat may cite.Only the run id is included, not the run's host path. Absolute paths that- end in the run's directory (here, or where a copied run first ran) and- credential-shaped text are masked in each string before it is shortened, so- a cut cannot leave part of either behind.+ end in the run's directory (here, or where a copied run first ran), the+ skill directory ``skill_dir`` (written as its name), the ``home`` directory+ (written as ``~``) and credential-shaped text are masked in each string+ before it is shortened, so a cut cannot leave part of any of them behind."""- scrub = _Scrubber.for_run(run_dir)+ scrub = _Scrubber.for_run(run_dir, skill_dir=skill_dir, home=home)runtime_seconds = _finite_number(payload.get("runtime_seconds"))if runtime_seconds is not None and runtime_seconds <= 0.0:runtime_seconds = None@@ -685,7 +822,10 @@ def open_feedback_session(skill_path: Path, run_dir: Path) -> Tier3FeedbackSessirun_dir = assert_completed_run_dir(run_dir)resolve_llm_provider()payload = load_agent_eval_payload(skill_path, run_dir)- return Tier3FeedbackSession(run_context=compact_run_context(payload, run_dir=run_dir))+ context = compact_run_context(+ payload, run_dir=run_dir, skill_dir=_local_skill_dir(skill_path, run_dir), home=_home_dir()+ )+ return Tier3FeedbackSession(run_context=context)__all__ = [diff --git a/src/skillevaluator/utils/redaction.py b/src/skillevaluator/utils/redaction.pyindex 82718a1a..cc10ff7a 100644--- a/src/skillevaluator/utils/redaction.py+++ b/src/skillevaluator/utils/redaction.py@@ -134,6 +134,10 @@ _PEM_REDACTIONS = ("private-key-<redacted>",),)+# Every token pattern below (the JWT and ``_REDACTIONS``) matches only letters,+# digits and ``_TOKEN_PUNCTUATION``. ``credential_safe_cut`` relies on that: a new+# pattern that takes other characters inside a token must widen this set.+_TOKEN_PUNCTUATION = "._~+/=-"# A JWT used to start at any ``\beyJ``, so in a run of JWT characters such as# "eyJ-" * n every "-eyJ" was a start, and each start scanned to the end of the run# looking for ".". Now a match starts only at the beginning of a run. The part of@@ -284,6 +288,28 @@ def redact_sensitive_text(value: str, *, max_len: int | None = None, max_input_creturn out+def credential_safe_cut(value: str, end: int) -> int:+ """Return how much of ``value[:end]`` can be redacted on its own, from 0 to ``end``.++ The cut follows the last whitespace or punctuation character that no token+ pattern takes inside a token, so no credential is left partly before it.+ Cut assignments, authorization headers and private keys are still redacted+ to the end. A cut inside a URL's user info would leave the part before it+ unredacted, so the cut moves in front of a ``://`` that only user-info+ characters follow.+ """+ index = min(end, len(value)) - 1+ while index >= 0:+ char = value[index]+ if char.isspace() or not (char.isalnum() or char in _TOKEN_PUNCTUATION):+ scheme = value.rfind("://", 0, index)+ if scheme < 0 or any(part.isspace() or part in "/?#" for part in value[scheme + 3 : index + 1]):+ return index + 1+ index = scheme+ index -= 1+ return 0++def redact_printable_text(value: str, *, max_len: int | None = None, max_input_chars: int | None = None) -> str:"""Strip terminal controls before masking credentials they may have split."""return redact_sensitive_text(strip_terminal_controls(value), max_len=max_len, max_input_chars=max_input_chars)diff --git a/tests/evaluation/test_tier3_feedback_chat.py b/tests/evaluation/test_tier3_feedback_chat.pyindex f3a6109f..8cbefc9f 100644--- a/tests/evaluation/test_tier3_feedback_chat.py+++ b/tests/evaluation/test_tier3_feedback_chat.py@@ -315,7 +315,18 @@ def test_context_masks_the_path_a_copied_run_had_elsewhere(tmp_path: Path) -> Nof"see ~/acme-skill/results/{RUN_ID}, then ({windows}\\jobs).",kept,],- }+ },+ "opencode": {+ "execution_errors": [+ f"see ~builder/acme-skill/results/{RUN_ID}/jobs, $HOME/acme-skill/{RUN_ID}, "+ f"${{HOME}}/acme-skill/{RUN_ID} and %USERPROFILE%\\acme-skill\\{RUN_ID}",+ # A path joined to another path or option keeps the other one.+ f"tried /opt/tool/bin,{posix}/jobs; PATH=/usr/bin:{posix} log:/var/log/x({posix}) "+ f"PATH=C:\\bin;{windows}",+ # A separator that does not start another absolute path is part of this one.+ f"in /home/ci-runner/my(project),v2/{RUN_ID}",+ ],+ },},}@@ -330,11 +341,80 @@ def test_context_masks_the_path_a_copied_run_had_elsewhere(tmp_path: Path) -> Noassert errors[2] == f"see {RUN_ID}, then ({RUN_ID}\\jobs)."# A relative path and other names that only start with the run ID are left alone.assert errors[3] == kept- (row,) = context["cases"]+ assert context["agents"]["opencode"]["execution_errors"] == [+ f"see {RUN_ID}/jobs, {RUN_ID}, {RUN_ID} and {RUN_ID}",+ f"tried /opt/tool/bin,{RUN_ID}/jobs; PATH=/usr/bin:{RUN_ID} log:/var/log/x({RUN_ID}) PATH=C:\\bin;{RUN_ID}",+ f"in {RUN_ID}",+ ]+ (row, _other_agent_row) = context["cases"]assert row["question"] == f"Read {RUN_ID}/inputs/a.txt"assert row["ground_truth"] == f"path={RUN_ID}"+def test_context_replaces_the_skill_and_home_directories(tmp_path: Path) -> None:+ # Paths outside the run directory still name the user and where the skill lives.+ home = tmp_path / "home" / "alice"+ skill = home / "work" / "acme-skill"+ run = skill / "evals" / "results" / RUN_ID+ payload = {+ "dataset": [{"id": "case-1", "question": f"Read {skill / 'references' / 'a.md'}"}],+ "agents": {+ "codex": {+ "execution_errors": [+ f"Skill validation failed: {skill / 'SKILL.md'} missing name",+ f"cache {home / '.cache'} is full; see {run / 'jobs'}",+ f"kept {home}-old, {skill}2 and {home.parent}",+ ],+ }+ },+ }++ context = compact_run_context(payload, run_dir=run, skill_dir=skill, home=home)++ errors = context["agents"]["codex"]["execution_errors"]+ assert errors[0] == f"Skill validation failed: {Path('acme-skill') / 'SKILL.md'} missing name"+ assert errors[1] == f"cache {Path('~') / '.cache'} is full; see {Path(RUN_ID) / 'jobs'}"+ # A directory whose name only starts with the same name is a different directory.+ assert errors[2] == f"kept {home}-old, {Path('~') / 'work' / 'acme-skill2'} and {home.parent}"+ assert context["cases"][0]["question"] == f"Read {Path('acme-skill') / 'references' / 'a.md'}"+++def test_context_leaves_url_path_values_unchanged_while_scrubbing_other_paths(tmp_path: Path) -> None:+ home = tmp_path / "home" / "alice"+ skill = home / "work" / "acme-skill"+ query_url = f"https://example.test/?path={skill / 'guide'}"+ fragment_url = f"https://example.test/guide#{home / 'work' / 'acme-skill' / 'references' / 'a.md'}"+ file_url = f"file:///{skill.as_posix().lstrip('/')}/SKILL.md"+ localhost_file_url = f"file://localhost/{skill.as_posix().lstrip('/')}/SKILL.md"+ payload = {+ "dataset": [+ {"id": "query", "question": query_url, "ground_truth": ""},+ {"id": "fragment", "question": fragment_url, "ground_truth": ""},+ {"id": "file", "question": file_url, "ground_truth": ""},+ {"id": "localhost-file", "question": localhost_file_url, "ground_truth": ""},+ ],+ "agents": {"codex": {"execution_errors": [f"Failed at {skill / 'SKILL.md'}; URL: {query_url}"]}},+ }++ context = compact_run_context(+ payload,+ run_dir=skill / "evals" / "results" / RUN_ID,+ skill_dir=skill,+ home=home,+ )++ questions = {case["entry_id"]: case["question"] for case in context["cases"]}+ scrubbed_skill_path = Path("acme-skill") / "SKILL.md"+ file_prefix = "file:///" if skill.drive else "file://"+ assert questions == {+ "query": query_url,+ "fragment": fragment_url,+ "file": f"{file_prefix}{scrubbed_skill_path.as_posix()}",+ "localhost-file": f"file://localhost/{scrubbed_skill_path.as_posix()}",+ }+ assert context["agents"]["codex"]["execution_errors"] == [f"Failed at {scrubbed_skill_path}; URL: {query_url}"]++def test_context_redacts_credentials_but_keeps_measurements() -> None:payload = {"agents": {@@ -452,20 +532,25 @@ def test_context_keeps_long_text_without_spaces() -> None:ground_truth = json.dumps({"files": [f"src/module_{index}.py" for index in range(60)]}, separators=(",", ":"))minified = "{" + ",".join(f'"k{index}":"v{index}"' for index in range(400)) + "}"token_inside = "x" * (limits._MAX_ERROR_CHARS - 100) + "," + _FAKE_GITHUB_TOKEN + "," + "y" * 3000+ # Longer than the larger window, so it is cut at punctuation no credential contains.+ long_minified = "{" + ",".join(f'"k{index}":"v{index}"' for index in range(8000)) + "}"+ # A cut inside a URL's user info could leave part of it, so the cut moves in front of the URL.+ user_info = "Error: https://alice:" + "p" * 30 + "," + "q" * 70_000 + "@host.example/x"payload = {"dataset": [{"id": "case-1", "question": "Which files? " + minified, "ground_truth": ground_truth}],"agents": {"codex": {"execution_errors": [minified, "Error: " + minified, token_inside, "z" * 100_000],"trials": [{"entry_id": "case-1", "overall": 1.0, "warnings": [minified]}],- }+ },+ "opencode": {"execution_errors": ["Error: " + long_minified, user_info]},},}context = compact_run_context(payload, run_dir=_PRIVATE_RUN)assert len(ground_truth) > limits._MAX_GROUND_TRUTH_CHARS * 4 + 256- (row,) = context["cases"]+ (row, _other_agent_row) = context["cases"]errors = context["agents"]["codex"]["execution_errors"]for text, prefix, limit in ((row["ground_truth"], '{"files":["src/module_0.py",', limits._MAX_GROUND_TRUTH_CHARS),@@ -481,6 +566,12 @@ def test_context_keeps_long_text_without_spaces() -> None:assert errors[2].startswith("x" * 100) and "github-token-<redacted>" in errors[2]# Past the larger window the cut token is still dropped, and the field says so.assert errors[3] == "...<truncated>"+ assert len(long_minified) > limits._MAX_UNBROKEN_MASK_CHARS+ long_error, user_info_error = context["agents"]["opencode"]["execution_errors"]+ assert long_error.startswith('Error: {"k0":"v0","k1":"v1",')+ assert long_error.endswith("...<truncated>")+ assert len(long_error) == limits._MAX_ERROR_CHARS+ assert user_info_error == "Error: ...<truncated>"# -- case summaries -------------------------------------------------------------@@ -791,6 +882,30 @@ def test_open_feedback_session(monkeypatch: pytest.MonkeyPatch, tmp_path: Path)assert session.run_context["run_id"] == RUN_ID[email protected]("explicit", [False, True], ids=["inferred-skill", "explicit-skill"])+def test_open_feedback_session_replaces_the_skill_and_home_directories(+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path, explicit: bool+) -> None:+ home = tmp_path / "home" / "alice"+ skill = home / "work" / "acme-skill"+ # An inferred skill is only a name; a run in the skill's evals/results still names its directory.+ # An explicit --skill also covers a run kept under another results directory.+ run = home / "results" / "acme-skill" / RUN_ID if explicit else skill / "evals" / "results" / RUN_ID+ monkeypatch.setenv("HOME", str(home))+ monkeypatch.setenv("USERPROFILE", str(home))+ error = f"Skill validation failed: {skill / 'SKILL.md'} missing name; cache {home / '.cache'}"+ payload = {"skill_name": "acme-skill", "agents": {"codex": {"execution_errors": [error]}}}+ monkeypatch.setattr(tier3_feedback_chat, "assert_completed_run_dir", lambda run: run)+ monkeypatch.setattr(tier3_feedback_chat, "load_agent_eval_payload", lambda *_: payload)+ monkeypatch.setattr(tier3_feedback_chat, "resolve_llm_provider", lambda: None)++ session = open_feedback_session(skill if explicit else Path("acme-skill"), run)++ assert session.run_context["agents"]["codex"]["execution_errors"] == [+ f"Skill validation failed: {Path('acme-skill') / 'SKILL.md'} missing name; cache {Path('~') / '.cache'}"+ ]++def test_open_feedback_session_rejects_misconfigured_provider(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:monkeypatch.setenv("SKILL_EVAL_LLM_PROVIDER", "openai")monkeypatch.delenv("OPENAI_API_KEY", raising=False)diff --git a/tests/test_redaction_assignments.py b/tests/test_redaction_assignments.pyindex 915f4260..3985ddbd 100644--- a/tests/test_redaction_assignments.py+++ b/tests/test_redaction_assignments.py@@ -9,7 +9,7 @@ import timeimport pytest-from skillevaluator.utils.redaction import redact_sensitive_text+from skillevaluator.utils.redaction import credential_safe_cut, redact_sensitive_text@pytest.mark.parametrize(@@ -184,3 +184,42 @@ def test_redact_sensitive_text_redacts_value_after_long_key_run() -> None:assert elapsed < 1.0, f"redaction took {elapsed:.2f}s"assert redacted == f"{prefix}token=<redacted>\n{prefix}secret:<redacted>"+++ ("source", "end", "expected"),+ [+ pytest.param('{"a":"b","c":"d"}', 12, 12, id="after-punctuation"),+ pytest.param('{"a":"b","c":"dddd"}', 16, 14, id="before-a-cut-value"),+ pytest.param("ab cd", 5, 3, id="after-whitespace"),+ pytest.param("x" * 10, 10, 0, id="no-cut-point"),+ pytest.param("a=b/c+d~e.f-g_h", 15, 0, id="token-punctuation-is-not-a-cut-point"),+ pytest.param("x,https://alice:p,ss", 20, 2, id="before-url-user-info"),+ pytest.param("x,https://host/p,q", 18, 17, id="after-url-authority"),+ ],+)+def test_credential_safe_cut_points(source: str, end: int, expected: int) -> None:+ assert credential_safe_cut(source, end) == expected+++# Built at runtime so secret scanners never see a literal credential.+ ("credential", "secret"),+ [+ pytest.param("ghp_" + "a" * 36, "ghp_", id="github"),+ pytest.param("ghs_" + "b" * 20 + "." + "c" * 20, "ghs_", id="github-stateless"),+ pytest.param("AKIA" + "IOSFODNN7EXAMPLE", "AKIA", id="aws"),+ pytest.param("sk-" + "d" * 24, "sk-", id="sk"),+ pytest.param("eyJ" + "e" * 12 + ".eyJ" + "f" * 12 + "." + "g" * 12, "eyJ", id="jwt"),+ pytest.param("Bearer " + "h/+=" * 6, "h/+=", id="bearer"),+ pytest.param("https://alice:p,ss;[email protected]/x", "alice", id="url-user-info"),+ pytest.param('password:"jjjj,kkkk;llll"', "jjjj", id="quoted-assignment"),+ ],+)+def test_credential_safe_cut_never_leaves_part_of_a_credential(credential: str, secret: str) -> None:+ text = "Error:{" + credential + "}"+ start = len("Error:{")+ for end in range(start + 1, start + len(credential)):+ cut = credential_safe_cut(text, end)+ assert cut <= end+ assert secret not in redact_sensitive_text(text[:cut]), text[:cut]