memscope_rs/render_engine/dashboard/renderer/evidence.rs
1//! Evidence, risk-confidence and provenance enums shared by dashboard DTOs.
2//!
3//! Kept out of `types.rs` so the DTO definitions stay readable and within the
4//! project line budget. These enums describe *how* a conclusion was reached; they
5//! must not be derived from an allocation identity (plan A11).
6
7use serde::{Deserialize, Serialize};
8
9/// Evidence level for analysis findings — how the conclusion was reached.
10#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
11pub enum EvidenceLevel {
12 /// Directly observed from events (highest confidence)
13 Observed,
14 /// Inferred from multiple data sources with strong correlation
15 Inferred,
16 /// Best-guess heuristic based on type/pattern matching
17 Heuristic,
18 /// No evidence available
19 #[default]
20 Unknown,
21}
22
23/// Risk confidence — how certain the analysis is about a risk finding.
24#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
25pub enum RiskConfidence {
26 /// Bug is confirmed by direct evidence
27 Confirmed,
28 /// Strong evidence but not conclusive
29 Likely,
30 /// Possible but needs more evidence
31 Possible,
32 /// Risk level unknown
33 #[default]
34 Unknown,
35}
36
37/// Pointer provenance — indicates where a pointer originated.
38#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
39pub enum PointerProvenance {
40 /// Fresh allocation from the global allocator
41 Allocator,
42 /// Created via Clone (includes Rc/Arc clone)
43 Clone,
44 /// Wrapped in a smart pointer (Box, Rc, Arc)
45 SmartPointer,
46 /// Address was previously used by a different allocation
47 Reallocation,
48 /// Reallocated address that later leaked
49 ReallocatedThenLeaked,
50 /// Received from FFI boundary
51 FfiInput,
52 /// Sent to FFI boundary
53 FfiOutput,
54 /// Origin unknown
55 #[default]
56 Unknown,
57}
58
59/// Drop expectation — what the analysis expects regarding deallocation.
60#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
61pub enum DropExpectation {
62 /// Normal Rust drop expected
63 NormalDrop,
64 /// ManualDrop — deallocation may be intentionally suppressed
65 ManualDrop,
66 /// mem::forget was called
67 Forgotten,
68 /// Memory should be freed by foreign code
69 ForeignFree,
70 /// Rust should reclaim from foreign code
71 RustReclaim,
72 /// No drop needed (e.g. static data, ZST)
73 NoDropNeeded,
74 /// Drop expectation unknown
75 #[default]
76 Unknown,
77}