Repository navigation
feat(reporting): reconcile stable finding IDs across report formats - #310
Conversation
Each reporter derived its own totals. The JSON report emitted raw validator error and warning counts, the Markdown report labelled the same raw sum "Total Issues", and the HTML summary counted every finding record for its Findings number, tier cards and verdict sentence. One run could therefore show different counts per format, and nothing said whether records from two validators, or one check firing on several lines, were one problem or many. Findings also had no ID a CI consumer could track across runs. Give every Finding a stable finding_id (SEF-, a SHA-256 of normalized category, check name, message and suggestion, independent of location and severity) and an occurrence_id (SEO-, which adds file path, line number and line content). Identical findings in different files or skills share one finding_id. A new reporting.finding_summary module groups raw findings by finding_id across validators, keeps every distinct occurrence, and returns one set of counts: raw occurrences, distinct occurrences, unique findings, duplicates removed and occurrences grouped, with raw and unique severity breakdowns. Errors and warnings with no finding behind them (failed gates, scanner and execution errors) are counted separately through additional_errors and additional_warnings, so such a run never reads as zero issues. The JSON report adds top-level finding_counts, finding_groups and message_counts, per-result finding_counts, and both IDs on each finding. The HTML report embeds the same objects. Its redesigned summary (tier cards, Findings and Blocking critical + high numbers, verdict sentence, skill badges and gate policy line) counts unique findings at their highest severity, and shows the occurrence, raw-record and no-finding breakdown under the Findings number when it differs. The Markdown summary uses the same wording, adds a Finding Reconciliation table ordered most severe first so the row cap never hides a critical finding, and lists both IDs in finding details. The informational message count leaves out the [OK] lines recorded for passed checks. Existing total_errors, total_warnings, severity_counts and skills[].issue_count are unchanged. CI removes detected credentials from a report after it is written. The runner and the publisher now recompute finding IDs and groups from the redacted text, so no published ID is hashed from a removed value. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Automated review: 8 findings (0 P1, 2 P2, 6 P3); 8 posted inline.
No conflicted files. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The redactor also masks database userinfo (for example postgresql+psycopg2://, mongodb+srv:// and rediss:// URLs) that the PII collector does not name, so a run with an empty token set could keep IDs hashed from the unmasked line. The runner and the publisher now refresh every JSON report's IDs after redaction. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Secret detection writes "in <file>:<line>" into its message and the PII scan appends "- N occurrences (...)" when it folds repeats of one value, so their finding_id changed whenever a line moved. The identity now leaves out the finding's own location and the PII occurrence list; the visible message is unchanged. Docs and the CHANGELOG say which text stays in the ID. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The PII scan folds repeats of one value into a single finding and lists every file and line in metadata.occurrences, but reconciliation counted one occurrence for it. Each listed location now becomes an occurrence with its own occurrence_id; duplicates_removed counts locations that repeat one already counted, and the HTML Findings detail line appears when occurrences differ from unique findings. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a finding Tier workflows record a stage skipped by configuration, such as LLM checks under --no-llm, as a "Workflow scope:" warning. It notes scope, not a problem, but it made every --no-llm run show "1 warning without a finding" under the HTML Findings number and in Markdown Total Issues. independent_warnings now leaves it out; raw total_warnings still counts it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The per-skill view merged entries by message, file and suggestion, so two different checks with the same text became one entry that kept the first finding_id but listed the second check's occurrence ID. The merge key now includes finding_id, so every ID on an entry belongs to that finding and the entry count matches the skill badge. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lation Add tests that a backslash path gets the same occurrence_id as its "/" form, that one finding reported with no line and at line 3 sorts into one group with two occurrences, and that a finding reported as medium and as high keeps "high" in JSON finding_groups, the HTML embedded data, Markdown Total Issues and the Blocking critical + high number. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The HTML report's embedded and exported data now counts summary.total_issues as unique findings plus errors and warnings with no finding, not raw errors plus warnings. Say so in the CHANGELOG and the CI integration guide, and name the fields that keep the raw count. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
One thing needs a fix before merge: counting each folded PII location double counts the first one in a folder run, so the reports disagree with their own message. Two minor notes are inline. The ID, CI refresh, workflow note and HTML merge changes otherwise read correctly.
No conflicts. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g IDs - merge_with_prefix prefixes each metadata occurrences[].file like file_path (on a copy), so a folded PII finding in a folder run no longer counts its own location twice. - finding_id strips the secret detection "in <file>:<line>" also when a folder run or plugin scan changed file_path but not the message. - finding_groups occurrences no longer copy line_content; the source line stays on the finding with the same occurrence_id. - The secret identity test follows main's suggestion, which names the file, so a secret in another file is another finding. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gate policy totals read advisory_by_tier, so the list was only appended to. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ccurrence payload - merge_with_prefix prefixes metadata occurrences[].file like file_path, so a folder run no longer counts a folded location twice. - Occurrence entries drop line_content (already in results[].findings[]), keeping reports under the CI size cap. - Remove the unused advisory_results list in the HTML payload builder. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
…ding-ids Conflicted: src/skillevaluator/models/result.py (kept the local occurrence prefixing). Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
No conflicts. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The runner passed the native HTML report through text redaction only, so its embedded report data kept finding and occurrence IDs hashed from text that still held the credential. Render it from the redacted, refreshed JSON, as the Markdown and SARIF copies already are. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A plugin scan rewrites a member finding's file_path with "/" separators, while a Gitleaks message on Windows names the path with backslashes. The location was then left in the identity text, so the finding_id changed when the line moved. Compare the two with "/" separators. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
No conflicts. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
Follow-up on the current head. merge_with_prefix now prefixes occurrences[].file, so a folder run counts a folded location once. The occurrence entries no longer carry line_content, and the unused list is gone. I also read the Windows-separator match in the finding identity and the CI change that renders the redacted HTML from the refreshed JSON, and both look right. Nothing further from me.
Resolve CHANGELOG.md conflicts by keeping both main's Unreleased entries and this PR's stable finding ID and finding-count entries. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
Resolve the CHANGELOG.md conflict: keep main's report finding-count entry (#310) and add this PR's baseline-trial drill-down entry after it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Reports now count findings one way, and every finding has stable IDs.
Findinghas two new properties, andFinding.to_dict()emits both:finding_id(SEF-plus 20 hex characters) is a SHA-256 of the category, check name, message and suggestion. Case and extra whitespace are ignored. It does not include location or severity, so it stays the same when a finding moves to another line or file, or when a policy or verifier changes its severity.in <file>:<line>in a secret detection message, and the— N occurrences (...)list the PII scan appends when it folds repeats of one value. The secret location is also left out when a folder run ([skill]prefix) or a plugin scan (member directory) has changed the finding'sfile_pathbut not its message, by matching the message's path against the end offile_path. The visible message is unchanged. Other message and suggestion text stays in the ID: script lint names the script in its messages and secret detection names the file in its suggestion, so the same problem in two files has two IDs.occurrence_id(SEO-...) adds the file path (with/separators), line number and line content, so it identifies one location. Line0and "no line" give different IDs.Finding.location_occurrence_id(file, line)gives the ID at another location a finding lists.finding_id, so they count as one unique finding with one occurrence per location. A three-skill collection that misses the same description field reads "1 unique finding / 3 occurrences", and each skill shows 1 finding.reporting/finding_summary.py.summarize_findingsgroups raw findings byfinding_idacross validators. Each group keeps every distinct occurrence and the highest severity. A finding that lists its repeated locations inmetadata["occurrences"](the PII scan folds repeats of one value this way) contributes one occurrence per listed location, so its Occurrences count matches the "N occurrences" in its message.ValidationResult.merge_with_prefixnow prefixes each listedoccurrences[].filethe same way asfile_path(on a copy of the metadata), so a folder run does not count the finding's own location twice.raw_occurrences(raw records),distinct_occurrences,unique_findings,duplicates_removed(reported locations that repeat one already counted),occurrences_grouped,raw_by_severityandunique_by_severity.merge_finding_summariescombines per-result summaries without hashing again.summarize_messagesreturnsindependent_errorsandindependent_warnings: error and warning strings with noFindingbehind them, such as failed gates (fail_gate), scanner and execution errors, and a missing or failed scanner. Strings that only mirror a finding are not counted, so nothing is counted twice. It uses the existingadditional_errorsandadditional_warningshelpers. TheWorkflow scope:note a tier workflow records when configuration skips a stage (for example LLM checks under--no-llm) is not counted as an independent warning; the rawtotal_warningsstill counts it. It also returnsinformational: informational messages, not counting the[OK]line thatadd_successrecords for each passed check (those checks are insuccess_details).total_issue_countanddescribe_issue_countsgive the HTML and Markdown reports one count and one wording.groups_by_display_priorityorders groups most severe first for capped human-readable lists. Machine output stays ordered byfinding_id.refresh_finding_identitiesrecomputes a JSON report's IDs and groups from its current finding text (see CI redaction below).finding_counts,finding_groupsandmessage_counts.finding_counts.finding_idandoccurrence_id.finding_groups[].occurrences[]entry hasoccurrence_id,validator,file_pathandline_number. The source line is not copied there; it stays on the finding inresults[].findings[]with the sameoccurrence_id, so a check that fires on many lines does not double the report size.total_errors,total_warnings,severity_counts,skills[].issue_count,legacyand thenullmetadata convention are unchanged.main.finding_counts,finding_groupsandmessage_countsas the JSON report.summary.total_issuescounts unique findings plus independent errors and warnings, withraw_finding_occurrences,distinct_finding_occurrencesandduplicates_removedbeside it.resultshas both IDs. In the per-skill view, an entry that merges the same finding on several lines carriesfinding_idand anoccurrence_idslist with every merged location, instead of a singleoccurrence_id. The merge key includesfinding_id, so two different checks with the same text stay separate entries and every ID on an entry belongs to its finding.max_findings_showncap.ci/secret_redaction.py) and the publisher (ci/publish_reports.py) remove detected credentials from a report after it is written. They now callrefresh_finding_identitieson every JSON report after redacting, whether or not a credential token was collected, so no published ID is hashed from text that held a removed value (a short password could otherwise be confirmed by hashing guesses). The refresh is unconditional because the redactor also masks database userinfo, such aspostgresql+psycopg2://,mongodb+srv://orrediss://URLs, that the PII collector does not name. Only fields the report already has are replaced, so retained reports written before this change keep their shape.docs/ci-integration.mdxdocuments the new JSON fields, how the IDs are derived, the cross-skill grouping, the CI recomputation, and which counts are unique or raw.docs/reports.mdxupdates the HTML definition of a finding. CHANGELOG entries under Unreleased / Added and Unreleased / Changed.Why
Each reporter used to compute its own totals:
total_errorsandtotal_warnings.len(findings)for its Findings number, tier cards and verdict sentence, while its per-skill view merged repeated findings within one validator.So one validation run could show different issue counts depending on the format. When two validators flagged the same line, or one check fired on several lines, nothing in any report said whether the records were one problem, several locations of one problem, or duplicates. Findings also had no identifier, so a CI consumer could not track a finding across runs or match it between validators without building its own key.
Example: one check fires on lines 8 and 12, and a second validator reports line 8 again. JSON, Markdown and the HTML summary used to report 3. Now Markdown reports "1 unique finding (1 high) / 2 occurrences / 3 raw records" with 1 duplicate reconciled, the HTML Findings number reads 1 (1 high) with the same breakdown under it, and the JSON report and the HTML report's embedded data contain the same
finding_countsandfinding_groups.The JSON report only gains fields; its existing raw fields keep their values. One existing field changes meaning:
summary.total_issuesin the HTML report's embedded and exported data now counts unique findings plus errors and warnings with no finding, not raw errors plus warnings; the raw finding count is beside it insummary.raw_finding_occurrencesandfinding_counts.raw_occurrences. The CHANGELOG anddocs/ci-integration.mdxsay so. What changes for readers is the issue and finding counts in the Markdown summary and the HTML summary. For a run where no finding repeats, the numbers are the same as before, except that theWorkflow scope:note recorded for a stage skipped by configuration (for example LLM checks under--no-llm) is no longer counted as an issue.Not changed in this PR: the JSON
skills[].issue_countand the HTML contributor totals still count raw records, as dototal_errors,total_warningsandseverity_counts. The CI index and PR comment read those raw fields and are unchanged.Kept from public
main's verdict-led layout (tier cards, KPIs, Fix first, gate policy) instead of the older header and dashboard elements._markdown_untrusted_table_cell. Finding text in a PR comment cannot inject HTML, links or@-mentions, or break the table. A test pins this.fail_gate, scanner and execution errors, incomplete scans) are counted throughadditional_errorsandadditional_warnings, so a run that fails a gate or leaves a scan incomplete without any finding never reads as zero issues.allow_nan=False,default=str, the existing top-level fields and the legacymetadata: nullfor findings without metadata are all unchanged. Findings are serialized throughFinding.to_dict(), once per finding.partialFingerprintsin this PR. That would change how code-scanning services de-duplicate alerts, so it should be its own decision. The CLI reporter is also unchanged.Tests
New tests in
tests/reporting/test_reporters.py. All fail on currentmainexcepttest_findings_kpi_has_no_detail_line_when_every_record_is_unique, which guards that the new breakdown line stays hidden when nothing repeats.test_finding_identity_is_semantic_and_occurrence_identity_is_location_bound: case, whitespace, severity and line changes keepfinding_idand changeoccurrence_id. Both IDs appear into_dict(), and one knownfinding_idvalue is pinned.test_occurrence_identity_distinguishes_line_zero_from_no_line.test_occurrence_identity_uses_forward_slashes:scripts\\run.pyandscripts/run.pyget the sameoccurrence_id.test_occurrences_with_and_without_a_line_number_sort_without_error: one finding with no line and at line 3 gives 1 unique finding with 2 occurrences, and the JSON, Markdown and HTML reporters render it.test_secret_finding_id_ignores_the_location_written_into_its_message: a Gitleaks hit atscripts/run.py:10and:11, as reported directly, aftermerge_with_prefix([alpha] scripts/run.py) and after plugin member attribution (skills/alpha/scripts/run.py), keeps onefinding_idand gets six occurrence IDs; the message still names the location. A hit inscripts/other.pyhas anotherfinding_id, because the suggestion names the file.test_repeated_pii_finding_id_survives_line_moves: a repeated personal path keeps itsfinding_idwhen a blank line moves it, and matches the ID of a single occurrence.test_reconciled_finding_keeps_its_highest_severity_in_every_format: one finding reported as medium by one validator and high by another ishighin JSONfinding_groups(merged path) and in the HTML embedded data (single-pass path), and Markdown reads "1 unique finding (1 high)"; one validator reporting it as medium then high gives Blocking critical + high 1.test_finding_reconciliation_contract_matches_json_markdown_and_html: three records give one finding, two occurrences and one duplicate; JSON and HTML embeddedfinding_counts,finding_groupsandmessage_countsare identical; per-result counts and raw totals are kept;Finding.to_dict()runs once per finding; the Markdown summary, reconciliation row and IDs match; the HTML Findings number, its breakdown line, the severity line, the Blocking number, the verdict sentence, the legend, the Fix first note and the skill badge all count one unique finding; a per-skill HTML entry that merges two lines lists both occurrence IDs.test_tier1_dashboard_reconciles_only_tier1_findings: with a Tier 2 finding in the run, the embedded summary counts both tiers, the Tier 1 card and Findings number count only Tier 1, the Tier 2 card keeps its own count, and the gate policy adds up each tier's unique findings.test_tier1_dashboard_counts_only_tier1_errors_without_findings: a Tier 2 error with no finding appears in the embedded summary, not in the Tier 1 tab.test_issue_counts_include_errors_and_warnings_without_findings: a failed gate, an incomplete scan with an error, and an incomplete scan with a warning each report one issue in JSONmessage_counts, the embedded HTML summary, the HTML Findings breakdown (under the Changes required or Incomplete verdict) and the Markdown summary.test_issue_counts_put_errors_without_findings_after_unique_findings: findings and a failed gate in one run show both.test_findings_kpi_has_no_detail_line_when_every_record_is_unique.test_workflow_scope_note_is_not_an_issue_without_a_finding: a passing result with the--no-llmscope note shows Findings 0 with no detail line,message_counts.independent_warnings0, rawtotal_warnings1, and Markdown Total Issues with no warning.test_folded_pii_finding_counts_each_listed_location_as_an_occurrence: a personal path on two lines gives one group with 2 occurrences (one of them the finding's ownoccurrence_id) in JSON, HTML and the Markdown table, 0 duplicates, and a detail line under the HTML Findings number; refreshing the IDs of the unredacted report changes nothing.test_folded_pii_finding_in_a_folder_run_counts_each_location_once: an email repeated on two lines of one skill in a two-skill folder gives one group with 2 occurrences, both under[support] SKILL.md, and the Markdown row reads 2;merge_with_prefixdoes not change the original finding's metadata.test_finding_group_occurrences_do_not_copy_the_source_line: group occurrences carry onlyoccurrence_id,validator,file_pathandline_number, the finding with the sameoccurrence_idkeeps the source line, and the JSON report holds the source line once per finding.test_html_skill_entries_merge_only_occurrences_of_one_finding: two checks with the same message and suggestion stay two per-skill entries, each listing only its own occurrence IDs, and the count matches the skill badge.test_same_finding_in_several_skills_counts_once_with_one_occurrence_per_skill: three skills merged withmerge_with_prefixgive 1 unique finding and 3 occurrences in JSON, Markdown and HTML; each skill badge shows 1 finding; JSONskills[]keeps raw counts.test_markdown_reconciliation_table_lists_the_most_severe_findings_first: a critical finding that falls past the 10-row cap infinding_idorder is listed first; JSONfinding_groupsstay in ID order.test_message_counts_leave_out_passed_check_lines.test_markdown_finding_reconciliation_escapes_untrusted_text: pipes, HTML, link syntax and@-mentions in a finding message or validator name stay inert, and the row keeps five cells.tests/reporting/test_report_redesign.py: the legend pin now checks the new definition of a finding.tests/reporting/test_mixed_execution_errors.py:message_countsand the Markdown "Total Issues" row for the mixed, errors-only and finding-only runs, so an errors-only run reports its analysis error, and the skipped catalog comparison's workflow scope note stays a raw warning without counting as a warning without a finding.test_additional_warnings_excludes_only_existing_finding_messages_without_mutation: warning strings that mirror a finding are left out, including aftermerge_with_prefix.tests/validators/test_pii_grouping.py:test_folder_run_counts_folded_locations_oncechecks that aftermerge_with_prefixevery listed occurrence of a folded email is under the finding's prefixedfile_path, and that the folder result has the same number of distinct occurrences as the single-skill result.tests/ci/test_secret_redaction.py:test_redacted_report_does_not_keep_ids_hashed_from_the_credential: another scanner's finding quotes a detected credential; after the runner's redaction, neither of its original IDs appears in the JSON, and every ID and group matches the redacted text.test_refreshing_ids_keeps_the_shape_of_reports_written_before_ids.test_ids_are_refreshed_when_only_database_userinfo_is_masked: a skill whose only credential is apostgresql+psycopg2://URL gives no collected token; another scanner's finding quoting it is masked and gets IDs from the masked line in the runner's JSON, and a retained report that still quotes the URL with its old IDs is masked and refreshed by the publisher.test_runner_and_retained_publisher_never_export_detected_valuealso checks that the runner's JSON and the publisher's retained JSON carry IDs that match their redacted text.The new CI checks fail when the refresh calls are removed; the database userinfo check fails when either refresh is limited to runs with collected tokens.
Validation (branch head merged with current
main):pytest -n 8 tests/reporting tests/models tests/validators/test_pii_grouping.py: 1265 passed.pytest -n 8 tests/validators tests/golden tests/ci: 3864 passed, 4 skipped.main'ssrc: 21 of the 22 newtest_reporters.pytests fail (23 of 24 cases with parameters), as do the newtest_pii_grouping.pytest and the changedtest_mixed_execution_errors.pyandtest_report_redesign.pypins;tests/ci/test_secret_redaction.pycannot import the new module. Mutations that drop the/normalization, the line-number sort guard, or either severity escalation each fail a new test.ruff check .: clean.ruff format --checkon the changed Python files: already formatted.scripts/check_oss_boundary.py: passed.🤖 Generated with Claude Code