pub struct HeuristicsBank<const MAX: usize> { /* private fields */ }Expand description
The heuristics bank: a fixed-size array of known motif patterns. Provenance-aware: each entry records where it came from.
Implementations§
Source§impl<const MAX: usize> HeuristicsBank<MAX>
impl<const MAX: usize> HeuristicsBank<MAX>
Sourcepub fn with_canonical_motifs() -> Self
pub fn with_canonical_motifs() -> Self
Create a new bank pre-loaded with the canonical debugging motifs (32 entries, anchored to IEEE 24765 + Avizienis-Laprie-Randell).
Sourcepub fn lookup(
&self,
reason_code: ReasonCode,
drift_persistence: f64,
slew_magnitude: f64,
) -> SemanticDisposition
pub fn lookup( &self, reason_code: ReasonCode, drift_persistence: f64, slew_magnitude: f64, ) -> SemanticDisposition
Per-signal lookup (v0.1 wire shape).
Used at signal-evaluation time inside evaluate_signal. Score
composition is unit-weighted; multi-feature weighting happens at
the episode level (match_episode).
Sourcepub fn match_episode(
&self,
episode: &DebugEpisode,
avg_drift_persistence: f64,
avg_boundary_density: f64,
) -> SemanticDisposition
pub fn match_episode( &self, episode: &DebugEpisode, avg_drift_persistence: f64, avg_boundary_density: f64, ) -> SemanticDisposition
Per-episode lookup (Session 3 addition).
Uses ALL features available at episode close: peak slew (from
episode.structural_signature.peak_slew_magnitude), signal
correlation count, duration in windows, the supplied average
drift persistence and average boundary density. Score
composition: Σ weight_f × feature_f for the five features,
gated by reason_code match plus the min/max range checks on
correlation count and duration windows.
Tie-breakers (deterministic, no FP randomness):
- higher provenance rank wins
(
FieldValidated > DatasetObserved > FrameworkDesign) - lower index in the entries array wins (canonical ordering)
Sourcepub fn match_episode_with_confidence(
&self,
episode: &DebugEpisode,
avg_drift_persistence: f64,
avg_boundary_density: f64,
) -> MatchConfidence
pub fn match_episode_with_confidence( &self, episode: &DebugEpisode, avg_drift_persistence: f64, avg_boundary_density: f64, ) -> MatchConfidence
Per-episode lookup with confidence margin (Phase 6 addition).
Same scoring as match_episode, but additionally tracks the
runner-up scored motif so operators can read the
top-vs-runner-up margin (see MatchConfidence). Tie-breakers
(provenance rank, lower index) are unchanged.
Sourcepub fn match_episode_with_consensus(
&self,
episode: &DebugEpisode,
avg_drift_persistence: f64,
avg_boundary_density: f64,
episode_max_consensus: u8,
max_detectors: u8,
) -> MatchConfidence
pub fn match_episode_with_consensus( &self, episode: &DebugEpisode, avg_drift_persistence: f64, avg_boundary_density: f64, episode_max_consensus: u8, max_detectors: u8, ) -> MatchConfidence
Per-episode lookup with multi-detector consensus context (post-Phase-8 fusion-aware lookup).
Same scoring as match_episode_with_confidence, but additionally
adds a consensus boost: consensus_boost = (episode_max_consensus / max_detectors) * 1.0, summed into the score for every motif
that survives the reason-code + range gates. Result: when multiple
detectors agree, the bank is MORE confident in the typed
interpretation; when only DSFB-structural fired, the bank still
produces the structural motif but with smaller margin (signaling
“this is a structurally-detected anomaly that flat detectors
missed — consider whether DSFB is over-firing or whether the
flat detectors are missing real signal”).
episode_max_consensus is the maximum consensus_count observed
in any (window, signal) cell within the episode’s window range.
max_detectors is the total number of enabled detectors
(typically 12 with all-default fusion).
Sourcepub fn recommended_action(&self, motif: MotifClass) -> PolicyState
pub fn recommended_action(&self, motif: MotifClass) -> PolicyState
Get recommended action for a matched motif
Sourcepub fn entries_iter(&self) -> impl Iterator<Item = &HeuristicEntry>
pub fn entries_iter(&self) -> impl Iterator<Item = &HeuristicEntry>
Iterate over the populated entries in canonical-bank order.
Returns &HeuristicEntry items in the order they were appended
to the bank — the same order used by the deterministic
tie-breaker rule (lower index wins on score ties at the same
provenance rank). Used by the demo feature’s documentation /
figure-rendering layer to emit the 32-motif × 27-tier affinity
matrix without requiring access to the private entries
storage.
Sourcepub fn entry_for(&self, motif: MotifClass) -> Option<&HeuristicEntry>
pub fn entry_for(&self, motif: MotifClass) -> Option<&HeuristicEntry>
Look up an entry by its MotifClass (for documentation /
dashboard rendering of the matched motif’s metadata).
Sourcepub fn effective_min_consensus(
&self,
entry: &HeuristicEntry,
global_min: u8,
) -> u8
pub fn effective_min_consensus( &self, entry: &HeuristicEntry, global_min: u8, ) -> u8
Bank-aware fusion: per-motif effective minimum consensus threshold, derived from the motif entry’s provenance ladder + correlation count.
Direction #4 (provenance-tier rules) + Direction #1 (per-motif consensus) from the Phase-1 panel proposal:
FieldValidatedmotifs trust experience — threshold lowered by 1.DatasetObservedmotifs use the global threshold unchanged.FrameworkDesignmotifs require additional corroboration — threshold raised by 1 (still hypothesis-stage typing).- Multi-service motifs (
min_correlation_count >= 3) require stronger consensus regardless of provenance — extra +1.
Floor of 1 enforced (zero-consensus typing is rejected).
Sourcepub fn effective_min_consensus_for_motif(
&self,
motif: MotifClass,
global_min: u8,
) -> u8
pub fn effective_min_consensus_for_motif( &self, motif: MotifClass, global_min: u8, ) -> u8
Bank-aware fusion convenience: look up the effective per-motif
consensus threshold by MotifClass. Falls back to global_min
if the motif is not in the bank.
Sourcepub fn match_episode_with_tier_affinity(
&self,
episode: &DebugEpisode,
avg_drift_persistence: f64,
avg_boundary_density: f64,
cell_tier_mask: &[u32],
window_tier_mask: &[u32],
num_signals: usize,
max_active_tiers: u8,
episode_max_consensus: u8,
) -> MatchConfidence
pub fn match_episode_with_tier_affinity( &self, episode: &DebugEpisode, avg_drift_persistence: f64, avg_boundary_density: f64, cell_tier_mask: &[u32], window_tier_mask: &[u32], num_signals: usize, max_active_tiers: u8, episode_max_consensus: u8, ) -> MatchConfidence
Phase 2 — Direction #2 (tier-affinity matrix) + Direction #5 (margin feedback). Score each candidate motif using a tier- restricted consensus computed from per-cell + per-window tier-fired bitmasks; motifs whose affinity tiers actually fired score higher than motifs whose affinity tiers were silent.
Inputs:
cell_tier_mask[w * num_signals + s]— bitmask of tiers that contributed at cell (w, s). One bit per tier.window_tier_mask[w]— bitmask of tiers contributing at the window level (multivariate / global detectors).episode_max_consensus— fallback consensus value (used to set the consensus_factor for motifs unmapped by reason-code affinity, i.e.Admissibledefault).
Returns the best-scoring motif, with margin reflecting the
gap between top and runner-up under tier-affinity scoring.
Determinism preserved (deterministic tie-break on provenance
rank then index, identical to match_episode_with_consensus).
Bank-side ablation axes (Phase η.4).
Each flag controls one of the three bank-internal fusion axes
(axes 4 / 7 / 8 of the 9-axis ladder). Default true preserves
pre-Phase-η.4 behaviour exactly. Setting any flag to false
disables that single bank-internal axis for ablation studies.
Sourcepub fn match_episode_with_tier_affinity_axes(
&self,
episode: &DebugEpisode,
avg_drift_persistence: f64,
avg_boundary_density: f64,
cell_tier_mask: &[u32],
window_tier_mask: &[u32],
num_signals: usize,
max_active_tiers: u8,
episode_max_consensus: u8,
use_zero_tier_filter: bool,
use_disambiguator_boost: bool,
use_primary_witness_tier_gate: bool,
) -> MatchConfidence
pub fn match_episode_with_tier_affinity_axes( &self, episode: &DebugEpisode, avg_drift_persistence: f64, avg_boundary_density: f64, cell_tier_mask: &[u32], window_tier_mask: &[u32], num_signals: usize, max_active_tiers: u8, episode_max_consensus: u8, use_zero_tier_filter: bool, use_disambiguator_boost: bool, use_primary_witness_tier_gate: bool, ) -> MatchConfidence
Phase η.4 — full per-axis ablation entry point.
Identical to match_episode_with_tier_affinity but with three
extra ablation flags:
use_zero_tier_filter(axis 4) — drop motifs whose affinity tiers are all silent in the episode range.use_disambiguator_boost(axis 7) — multiplicative boost when distinguishing tiers fire (motif AND NOT confuser).use_primary_witness_tier_gate(axis 8) — drop motifs whose declaredprimary_witness_tiersare silent.
Theorem 9 preservation: each flag toggles a deterministic
branch; same (episode, masks, flags) triple → same
MatchConfidence byte-for-byte.