Skip to main content

ScanReport

Struct ScanReport 

Source
pub struct ScanReport {
Show 16 fields pub antigens: Vec<AntigenDeclaration>, pub presentations: Vec<Presentation>, pub immunities: Vec<Immunity>, pub tolerances: Vec<Toleration>, pub lineage_edges: Vec<LineageEdge>, pub deferred_defenses: Vec<DeferredDefense>, pub convergent_evidences: Vec<ConvergentEvidence>, pub recurrent_declarations: Vec<RecurrentDeclaration>, pub mucosal_declarations: Vec<MucosalDeclaration>, pub prescriptive_declarations: Vec<PrescriptiveDeclaration>, pub defenses: Vec<Defense>, pub generates_declarations: Vec<GeneratesDeclaration>, pub marked_unknowns: Vec<MarkedUnknown>, pub files_scanned: usize, pub parse_failures: Vec<ParseFailure>, pub scan_coverage: Option<ScanCoverage>,
}
Expand description

Aggregate result of scanning a workspace.

Fields§

§antigens: Vec<AntigenDeclaration>

All discovered antigen declarations.

§presentations: Vec<Presentation>

All discovered #[presents] sites + synthetic fingerprint matches. Distinguish the two via Presentation::match_kind.

§immunities: Vec<Immunity>

All discovered #[immune] sites.

§tolerances: Vec<Toleration>

All discovered #[antigen_tolerance] sites. W6a.

§lineage_edges: Vec<LineageEdge>

All discovered #[descended_from] edges.

#[serde(default)] so older reports deserialize cleanly with an empty edge list (additive change, not breaking).

§deferred_defenses: Vec<DeferredDefense>

All discovered deferred-defense declarations: #[anergy], #[immunosuppress], #[poxparty], #[orient]. ADR-023.

#[serde(default)] so pre-v0.2 reports deserialize cleanly.

§convergent_evidences: Vec<ConvergentEvidence>

All discovered convergent-evidence declarations: #[diagnostic], #[clonal], #[igg], #[crossreactive], #[polyclonal], #[monoclonal], #[adcc]. ADR-024.

#[serde(default)] so pre-v0.2 reports deserialize cleanly.

§recurrent_declarations: Vec<RecurrentDeclaration>

All discovered recurrent-emergence declarations: #[itch], #[recurrence_anchor], #[crystallize], #[chronic], #[saturate], #[strand]. ADR-024 §Family 2.

#[serde(default)] so pre-recurrent reports deserialize cleanly.

§mucosal_declarations: Vec<MucosalDeclaration>

All discovered mucosal-boundary declarations: #[mucosal], #[mucosal_delegate], #[mucosal_tolerant]. ADR-027 + Amendment 1.

#[serde(default)] so pre-mucosal reports deserialize cleanly.

§prescriptive_declarations: Vec<PrescriptiveDeclaration>

All discovered prescriptive work-orchestration declarations: #[panel], #[rx], #[refer], #[biopsy], #[ddx], #[triage], #[culture], #[quarantine]. ADR-033 (extends ADR-024). The audit projects each to a four-valued WorkVerdict (the board).

#[serde(default)] so pre-prescriptive reports deserialize cleanly.

§defenses: Vec<Defense>

All discovered #[defended_by(X)] code-tier witness registrations (ADR-029). Each records that a test/proptest function declares it defends a failure-class; cargo antigen audit cross-references these to the #[presents(X)] sites they cover to compute the immune-state verdict. Immunity is observed, not declared.

#[serde(default)] so pre-ADR-029 reports deserialize cleanly.

§generates_declarations: Vec<GeneratesDeclaration>

All discovered #[antigen_generates(X, ...)] declarations on macro definitions (ADR-014). The generates-synthesis pass connects these to macro invocation sites and emits synthetic presentations.

#[serde(default)] so pre-ADR-014 reports deserialize cleanly.

§marked_unknowns: Vec<MarkedUnknown>

All discovered marked-unknown markers (#[aura] / #[dread] / #[red_flag], ADR-041) — the felt-but-unnamed dangers. These are the scan-time half of ADR-039’s Finding; they surface at the dial’s non-gating floor (never gate, never nag). #[serde(default)] so pre-ADR-041 reports deserialize cleanly.

§files_scanned: usize

Files scanned successfully.

§parse_failures: Vec<ParseFailure>

Files that failed to parse.

§scan_coverage: Option<ScanCoverage>

Member-aware scan coverage (v0.3): which workspace member crates were enumerated vs actually scanned. None for a flat scan_workspace scan (which has no member concept) — preserves byte-identical JSON for flat-scan consumers via skip_serializing_if. Some only from scan_workspace_multi_crate.

This is the substrate for ignorance detection (regulatory tier): a member that exists in the workspace but was NOT scanned is a region where #[presents] sites go unseen — ignored, not defended. The coverage record makes that frontier explicit so a downstream audit can surface it. The audit/verdict layer is ADR scope; this field is the floor it stands on.

Implementations§

Source§

impl ScanReport

Source

pub fn unaddressed_presentations(&self) -> Vec<UnaddressedPresentation>

Find presentations that lack a corresponding immunity declaration.

W3 — structural item-identity matching. A Presentation and an Immunity “address each other” when:

  • they reference the same antigen_type, AND
  • they’re in the same source file, AND
  • their item_target values are equal (i.e., they’re applied to the same Rust item).

This replaces the pre-W3 20-line proximity heuristic, which produced false positives in multi-impl files (immunity on impl X matched presentation on impl Y if their attributes happened to be within 20 lines) and false negatives when long doc-comments separated paired declarations on the same item.

Cross-file matching remains out of scope here — different items can share names across modules, and the structural identity of an “item” extends to its containing module path. That’s future territory (cross-crate scan + #[descended_from] propagation).

Source

pub fn partitioned_presentations(&self) -> PartitionedPresentations

Unaddressed presentations split by confidence tier.

Equivalent to calling unaddressed_presentations and partitioning by MatchKind, but in a single pass and with doc guidance on what each bucket means for CI gates.

See PartitionedPresentations for the distinction between explicit (CI-gateable) and inferred (human-triage).

Source

pub fn orphaned_tolerances(&self) -> Vec<&Toleration>

Tolerances whose named antigen is no longer declared in the scanned workspace. Per ADR-011 §Mechanics + ATK-A2-009 (the stale-tolerance orphan check, the biology cognate “peripheral suppression continuing after the antigen it suppressed is no longer present”).

Cross-crate antigens are not yet handled — for now, an “orphan” is a tolerance whose antigen type_name doesn’t appear in any AntigenDeclaration in the same scan. Consumers using cross-crate antigens may produce false positives here; that’s the recognized v0.1 limitation.

Source

pub fn orphaned_lineage_edges(&self) -> Vec<&LineageEdge>

Lineage edges whose parent antigen is not present in the scan.

ATK-A3-003 — parallel to ScanReport::orphaned_tolerances.

A #[descended_from(Parent)] declaration whose Parent is no longer declared in the scanned workspace (rename, removal, or — for v0.1 — a parent that lives in a not-yet-scanned crate) is a semantic warning, not a structural error: the scan completed correctly, but the declaration references something that isn’t there. Surfaced via this query method rather than emitted into parse_failures so callers (CLI, audit tooling, IDE plugins) choose the severity, the same channel discipline used for orphaned tolerances.

Cross-crate antigens are not yet handled — for now, an “orphan” is a lineage edge whose parent doesn’t appear as a type_name in any AntigenDeclaration in the same scan. Consumers using cross-crate antigens may produce false positives here; that’s the recognized v0.1 limitation.

See also ScanReport::dangling_child_lineage_edges for the dual case (child missing rather than parent missing).

Source

pub fn dangling_child_lineage_edges(&self) -> Vec<&LineageEdge>

Lineage edges whose CHILD has no AntigenDeclaration in the scan.

BUG-A3-002 fix. The dual of ScanReport::orphaned_lineage_edgesorphaned checks the parent endpoint, dangling checks the child endpoint.

A struct or enum bearing #[descended_from(Parent)] without its own #[antigen] declaration is structurally incoherent: it claims to inherit into the antigen system without being a participant itself. The propagation walk (D1.5) cannot meaningfully attach inherited presentations to a non-antigen child — the descendant has no record in ScanReport::antigens for inheritance to flow into.

Surfaced as a semantic warning, not a parse_failure — the declaration is structurally well-formed; only the relationship to the antigen registry is missing. Caller (CLI, audit tooling) chooses severity, mirroring the orphaned_tolerances / orphaned_lineage_edges channel discipline.

The propagation walk skips edges flagged by this query the same way it skips edges flagged by orphaned_lineage_edges.

Source

pub fn stamp_canonical_path(&mut self, crate_id: &str)

Stamp canonical_path (and parent_canonical_path / child_canonical_path on lineage edges) on every record in this report that does not already have one.

ADR-017 (Option A — caller stamps post-scan). Called by the cargo-metadata-driven --include-deps driver after running scan_workspace on a dependency crate root: the driver knows the dependency’s canonical path ("<crate-name>@<version>"), but the directory scanner doesn’t, so the driver stamps the canonical path on every record post-scan.

Idempotent + non-overwriting: records whose canonical_path (or relevant lineage-edge endpoint) is already Some(_) are left unchanged. This protects records that were stamped during an earlier (e.g., nested) scan from being silently re-keyed.

crate_id is expected to be in the ADR-017 format "<crate-name>@<version>" (e.g., "serde@1.0.193"); the method does not validate the format — that’s the driver’s responsibility.

Source

pub const fn total_declarations(&self) -> usize

Total count of antigen-related declarations found.

Trait Implementations§

Source§

impl Clone for ScanReport

Source§

fn clone(&self) -> ScanReport

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScanReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScanReport

Source§

fn default() -> ScanReport

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ScanReport

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ScanReport

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.