Skip to main content

Module audit_keys

Module audit_keys 

Source
Expand description

Stable per-finding keys and audit ledgers that compare head results against a base snapshot, plus helpers that annotate output JSON with introduced-vs-pre-existing attribution.

Structs§

AuditComparison
One-pass audit comparison shared by attribution, verdict, and annotations.
AuditDomainLedger
Stable-key membership for one non-dead-code audit domain.
AuditFindingRecord
One dead-code finding classified for audit comparison.
DeadCodeAuditLedger
Exhaustive dead-code comparison ledger shared by audit verdict and output.

Functions§

annotate_dead_code_json
Insert "introduced": bool into every dead-code finding object in the serialized JSON by re-deriving each key and testing membership against the base snapshot. JSON arrays must be in the same order as the typed results collections they were serialized from.
annotate_domain_demotions_json
Attach a demotion_reason to demoted entries of an audit JSON array, matching entries to demoted membership by array position. Non-demoted entries are left untouched so output without demotions stays byte-identical (issue #2220).
annotate_domain_json
Attach precomputed introduced membership to an audit JSON array.
annotate_dupes_json
Insert "introduced": bool into each clone_groups object in serialized duplication JSON, matching groups to the typed report by array position.
annotate_health_json
Insert "introduced": bool into each findings and styling_findings object in serialized health JSON, matching entries to the typed report by array position.
annotate_stale_suppressions_json
Annotate the sole legacy dead-code collection without a typed introduced field. Every wrapper-backed collection is annotated from the persisted AuditComparison instead.
dead_code_audit_ledger
Build the exhaustive dead-code comparison ledger once for an audit run.
dead_code_keys
dead_code_keys, retain_introduced_dead_code. Non-exhaustive siblings the compiler will NOT flag (wire manually when a finding type is added): annotate_dead_code_json (same key formats, this file) and the per-collection off filter branches in crates/engine/src/dead_code.rs (apply_rule_severities). The severity of each record comes from the RuleSeverity table in crates/engine/src/effective_severity.rs, whose visitors are exhaustive. TypeScript mirror: editors/vscode/scripts/codegen-contracts.mjs derives backwards-compatible aliases from fallow schema ts_alias rows.
dupe_group_key
Attribution key for one clone group: dupe:<sorted files joined by |>:<tokens>:<lines>:<fragment hash>. The fragment hash keeps distinct groups spanning the same files apart; line positions are excluded so a group survives shifts within its files.
dupes_keys
Attribution key set for every clone group in a duplication report.
health_finding_key
Attribution key for one complexity finding: complexity:<path>:<function>:<exceeded metric>. Line numbers are deliberately excluded so a finding survives unrelated edits above it.
health_keys
Attribution key set for every complexity finding in a health report.
preexisting_dupe_group_keys
Keys of clone groups whose every instance lies entirely outside the diff’s added lines: no instance range contains an added line, so the changeset did not write the duplicated text, and the group only became reportable (under a new attribution key) because the changeset removed code elsewhere; deduplicating one region can create or re-shape a clone group across files (issue #2164). New-only gating demotes these groups to inherited so a clone-removal refactor is not failed by the duplication it did not write. An instance whose path cannot be mapped into the diff’s namespace is treated as touched, so its group keeps gating.
relative_key_path
Canonical path form used inside attribution keys: root-relative with forward slashes on every platform. Paths outside root keep their simplified absolute form so keys stay unique.
remap_keys_for_renames
Remap root-relative path tokens inside base-snapshot attribution keys so a finding on a renamed file matches its base counterpart under the old path.
retain_introduced_dead_code
Retain only findings whose audit key was NOT present in base (i.e. was introduced on the current branch).
styling_finding_key
Attribution key for one styling finding: styling:<code>:<sub kind>:<path>:<line>:<value>.
styling_keys
Attribution key set for every styling finding in a health report.