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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Tier 2 includes qualifying shell comment blocks at end of file in context
deduplication. Previously those blocks disappeared unless a blank line or
code followed them, which could hide repeated guidance across shell files.

- All-tier CI retains Tier 2's native reports as advisory while preserving
failed and incomplete evaluation outcomes. GitHub `ci status` validates the
pinned evaluation and feedback configuration before reporting readiness,
Expand Down
4 changes: 3 additions & 1 deletion src/skillevaluator/deduplication/utils/chunker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging
import re
from dataclasses import dataclass, field, replace
from itertools import chain
from typing import TYPE_CHECKING

from markdown_it import MarkdownIt
Expand Down Expand Up @@ -310,7 +311,8 @@ def chunk_shell(

comment_start = None
comment_lines: list[str] = []
for i, line in enumerate(lines):
# A final empty sentinel flushes a trailing comment block at end of file.
for i, line in enumerate(chain(lines, ("",))):
stripped = line.strip()
if stripped.startswith("#") and not stripped.startswith("#!"):
if comment_start is None:
Expand Down
28 changes: 28 additions & 0 deletions tests/deduplication/intra_skill/test_intra_skill_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ def test_rejects_invalid_budget(self, budget: object) -> None:


class TestIntraSkillValidatorValidate:
@patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.analyze_cluster")
@patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.LLMClient")
@patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.EmbeddingClient")
def test_duplicate_shell_comments_at_eof_are_compared(
self, mock_embed, _mock_llm, mock_analyze, tmp_path: Path
) -> None:
comments = (
"# Document the required setup before invoking this helper script.\n"
"# Use the configured workspace for every generated output file.\n"
"# Keep the source input unchanged while the helper processes it.\n"
)
(tmp_path / "first.sh").write_text("#!/bin/sh\necho ready\n" + comments, encoding="utf-8")
(tmp_path / "second.sh").write_text("#!/bin/sh\necho ready\n" + comments, encoding="utf-8")
mock_embed.return_value.embed.side_effect = _unit_embeddings(2)
mock_analyze.return_value = LLMVerdict(
verdict="DUPLICATE", confidence=0.9, reasoning="Repeated instructions", suggestion="Consolidate comments"
)

result = IntraSkillValidator().validate(tmp_path)

mock_embed.return_value.embed.assert_called_once()
assert len(mock_embed.return_value.embed.call_args.args[0]) == 2
mock_analyze.assert_called_once()
assert result.passed is False
assert len(result.findings) == 1
assert "first.sh" in result.findings[0].message
assert "second.sh" in result.findings[0].message

def test_collection_log_uses_target_label_without_host_path(self, tmp_path: Path, caplog) -> None:
skill_dir = tmp_path / "nested" / "external-skill"
skill_dir.mkdir(parents=True)
Expand Down
34 changes: 34 additions & 0 deletions tests/deduplication/utils/test_chunker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from __future__ import annotations

import pytest

from skillevaluator.deduplication.utils.chunker import (
ContentChunk,
chunk_file,
Expand Down Expand Up @@ -191,6 +193,38 @@ def test_short_function_excluded(self) -> None:


class TestChunkShell:
@pytest.mark.parametrize("prefix", ["", "#!/bin/sh\necho ready\n"])
@pytest.mark.parametrize("ending", ["", "\n", "\n\n"])
def test_comment_block_at_eof(self, prefix: str, ending: str) -> None:
comments = [
"Document the required setup before invoking this helper script.",
"Use the configured workspace for every generated output file.",
"Keep the source input unchanged while the helper processes it.",
]
content = prefix + "\n".join(f"# {line}" for line in comments) + ending

chunks = chunk_shell(_cf(content, ".sh", "run.sh"), min_chars=80)

assert len(chunks) == 1
assert chunks[0].heading == "(comment)"
assert chunks[0].text == "\n".join(comments)
first_line = len(prefix.splitlines()) + 1
assert (chunks[0].start_line, chunks[0].end_line) == (first_line, first_line + 2)

@pytest.mark.parametrize(
"content",
[
"",
"#!/bin/sh\n",
"# Short\n# Two lines",
"# This first long comment line explains the helper setup in detail.\n"
"# This second long comment line explains the workspace output rules.",
"# A\n# B\n# C",
],
)
def test_eof_comments_keep_existing_filters(self, content: str) -> None:
assert chunk_shell(_cf(content, ".sh", "run.sh"), min_chars=80) == []

def test_function_body(self) -> None:
body = "setup() {\n" + " echo step\n" * 15 + "}\n"
chunks = chunk_shell(_cf(body, ".sh", "run.sh"), min_chars=80)
Expand Down
Loading