Skip to content

Commit e5ceb61

Browse files
authored
Merge pull request #637 from drakeo338/claude/633-baseline-every-occurrence
fix(baseline): fingerprint every occurrence of a deduplicated finding
2 parents 2226747 + ae931d3 commit e5ceb61

5 files changed

Lines changed: 51 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### 2.12.0 (Unreleased)
22
### Features/Bug Fixes
3+
* fix(baseline): fingerprint every occurrence of a deduplicated finding so the next scan suppresses all of them (#633)
34
* fix(security): retain incomplete coverage for runtime-selected commands and remeasure active Git clones strictly (#514)
45
* fix(scan): preserve required-input failures and multiline prompt uncertainty (#563)
56
* fix(analyzer): preserve Perl print literal ownership and explain referenced-artifact limitations (#615)

‎src/skillspector/cli.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3211,7 +3211,9 @@ def baseline(
32113211
state = _scan_state(input_path, FormatChoice.json, no_llm)
32123212
state["baseline_path"] = os.path.abspath(output.expanduser())
32133213
result = graph.invoke(state)
3214-
findings = effective_findings(result)
3214+
# Fingerprint every occurrence the next scan checks. The reported
3215+
# findings are deduplicated and keep only one occurrence's evidence.
3216+
findings = result["active_findings"]
32153217
data = build_baseline_dict(
32163218
findings,
32173219
reason=reason,

‎src/skillspector/nodes/report.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,7 @@ def report(state: SkillspectorState) -> dict[str, object]:
18401840
"report_body": report_body,
18411841
"filtered_findings": reported_findings,
18421842
"suppressed_findings": suppressed,
1843+
"active_findings": active_findings,
18431844
"execution_successful": execution_successful,
18441845
"analysis_completeness": dict(analysis_completeness),
18451846
"transitive_targets_scanned": transitive_targets_scanned,

‎src/skillspector/state.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ class SkillspectorState(TypedDict, total=False):
307307
baseline_path: str | None
308308
show_suppressed: bool
309309
suppressed_findings: list[object]
310+
# Kept findings as baseline suppression saw them: one per occurrence, before
311+
# deduplication compacts them. `skillspector baseline` fingerprints these so
312+
# every occurrence the next scan checks has its own entry.
313+
active_findings: list[Finding]
310314

311315
# Model IDs per LLM-using node: e.g. {"default": "...", "meta_analyzer": "..."}
312316
model_config: dict[str, str]

‎tests/unit/test_cli.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,46 @@ def test_cli_baseline_generate_then_scan_round_trip(tmp_path: Path) -> None:
10131013
assert data["risk_assessment"]["score"] == 0
10141014

10151015

1016+
def test_cli_baseline_round_trip_suppresses_every_occurrence_of_a_repeated_match(
1017+
tmp_path: Path,
1018+
) -> None:
1019+
"""A match compacted across files is fingerprinted once per occurrence (#633)."""
1020+
skill = tmp_path / "demo"
1021+
(skill / "references").mkdir(parents=True)
1022+
(skill / "SKILL.md").write_text(
1023+
"---\nname: demo\ndescription: A demo skill for the baseline reproduction.\n---\n\n"
1024+
"# Demo\n\n"
1025+
"The upstream service deletes unused files, and the link dies with no warning.\n",
1026+
encoding="utf-8",
1027+
)
1028+
(skill / "references" / "notes.md").write_text(
1029+
"# Notes\n\nThe mirror drops stale entries with no warning.\n",
1030+
encoding="utf-8",
1031+
)
1032+
baseline_file = tmp_path / "baseline.yaml"
1033+
1034+
plain = runner.invoke(app, ["scan", str(skill), "--no-llm", "--format", "json"])
1035+
assert plain.exit_code == 0, plain.output
1036+
reported = [
1037+
(issue["id"], issue["location"]["file"]) for issue in json.loads(plain.stdout)["issues"]
1038+
]
1039+
assert sorted(reported) == [("AR2", "SKILL.md"), ("AR2", "references/notes.md")]
1040+
1041+
gen = runner.invoke(app, ["baseline", str(skill), "--no-llm", "--output", str(baseline_file)])
1042+
assert gen.exit_code == 0, gen.output
1043+
1044+
scan = runner.invoke(
1045+
app,
1046+
["scan", str(skill), "--no-llm", "--format", "json", "--baseline", str(baseline_file)],
1047+
)
1048+
assert scan.exit_code == 0, scan.output
1049+
data = json.loads(scan.stdout)
1050+
assert data["issues"] == []
1051+
assert sorted((item["id"], item["location"]["file"]) for item in data["suppressed"]) == sorted(
1052+
reported
1053+
)
1054+
1055+
10161056
def test_cli_baseline_regeneration_excludes_in_tree_output(tmp_path: Path) -> None:
10171057
"""Regeneration cannot fingerprint findings created by the old output file."""
10181058
skill = tmp_path / "skill"
@@ -6163,6 +6203,7 @@ def test_cli_baseline_command_excludes_filtered_out_findings(tmp_path: Path) ->
61636203
"findings": [Finding(rule_id="SQP-1", message="one", file="SKILL.md")],
61646204
"filtered_findings": [],
61656205
"suppressed_findings": [],
6206+
"active_findings": [],
61666207
"file_cache": {"SKILL.md": source},
61676208
"risk_score": 0,
61686209
}
@@ -6188,6 +6229,7 @@ def test_cli_baseline_uses_local_cache_for_provider_excluded_findings(tmp_path:
61886229
"findings": [finding],
61896230
"filtered_findings": [finding],
61906231
"suppressed_findings": [],
6232+
"active_findings": [finding],
61916233
"file_cache": {"SKILL.md": "# Baseline helper\n"},
61926234
"local_file_cache": {
61936235
"SKILL.md": "# Baseline helper\n",

0 commit comments

Comments
 (0)