pub struct Finding {
pub check_id: String,
pub code: String,
pub severity: FindingSeverity,
pub title: String,
pub message: String,
pub location: Option<FindingLocation>,
pub evidence: Option<Value>,
pub docs_url: Option<String>,
pub fingerprint: Option<String>,
}Expand description
A finding reported by the sensor.
Findings use a (check_id, code) tuple for identity. Combined with
tool.name this forms the triple (tool, check_id, code) used for
buildfix routing and cockpit policy (e.g., ("tokmd", "risk", "hotspot")).
§Examples
use tokmd_envelope::{Finding, FindingSeverity, FindingLocation};
let finding = Finding::new(
"risk", "hotspot",
FindingSeverity::Warn,
"High-churn file",
"src/lib.rs modified 42 times in 30 days",
).with_location(FindingLocation::path_line("src/lib.rs", 1));
assert_eq!(finding.check_id, "risk");
assert_eq!(finding.code, "hotspot");
assert!(finding.location.is_some());Fields§
§check_id: StringCheck category (e.g., “risk”, “contract”, “gate”).
code: StringFinding code within the category (e.g., “hotspot”, “coupling”).
severity: FindingSeveritySeverity level.
title: StringShort title for the finding.
message: StringDetailed message describing the finding.
location: Option<FindingLocation>Source location (if applicable).
evidence: Option<Value>Additional evidence data.
docs_url: Option<String>Documentation URL for this finding type.
fingerprint: Option<String>Stable identity fingerprint for deduplication and buildfix routing. BLAKE3 hash of (tool_name, check_id, code, location.path).
Implementations§
Source§impl Finding
impl Finding
Sourcepub fn new(
check_id: impl Into<String>,
code: impl Into<String>,
severity: FindingSeverity,
title: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn new( check_id: impl Into<String>, code: impl Into<String>, severity: FindingSeverity, title: impl Into<String>, message: impl Into<String>, ) -> Self
Create a new finding with required fields.
Sourcepub fn with_location(self, location: FindingLocation) -> Self
pub fn with_location(self, location: FindingLocation) -> Self
Add a location to the finding.
Sourcepub fn with_evidence(self, evidence: Value) -> Self
pub fn with_evidence(self, evidence: Value) -> Self
Add evidence to the finding.
Sourcepub fn with_docs_url(self, url: impl Into<String>) -> Self
pub fn with_docs_url(self, url: impl Into<String>) -> Self
Add a documentation URL to the finding.
Sourcepub fn compute_fingerprint(&self, tool_name: &str) -> String
pub fn compute_fingerprint(&self, tool_name: &str) -> String
Compute a stable fingerprint from (tool_name, check_id, code, path).
Returns first 16 bytes (32 hex chars) of a BLAKE3 hash for compactness.
§Examples
use tokmd_envelope::{Finding, FindingSeverity, FindingLocation};
let f = Finding::new("risk", "hotspot", FindingSeverity::Warn, "Churn", "high")
.with_location(FindingLocation::path("src/lib.rs"));
let fp = f.compute_fingerprint("tokmd");
assert_eq!(fp.len(), 32);
// Same inputs produce same fingerprint
let f2 = Finding::new("risk", "hotspot", FindingSeverity::Warn, "Churn", "high")
.with_location(FindingLocation::path("src/lib.rs"));
assert_eq!(f2.compute_fingerprint("tokmd"), fp);Sourcepub fn with_fingerprint(self, tool_name: &str) -> Self
pub fn with_fingerprint(self, tool_name: &str) -> Self
Auto-compute and set fingerprint. Builder pattern.