Skip to main content

HeuristicsBank

Struct HeuristicsBank 

Source
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>

Source

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).

Source

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).

Source

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):

  1. higher provenance rank wins (FieldValidated > DatasetObserved > FrameworkDesign)
  2. lower index in the entries array wins (canonical ordering)
Source

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.

Source

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).

Source

pub fn recommended_action(&self, motif: MotifClass) -> PolicyState

Get recommended action for a matched motif

Source

pub fn count(&self) -> usize

Number of entries currently populated.

Source

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.

Source

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).

Source

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:

  • FieldValidated motifs trust experience — threshold lowered by 1.
  • DatasetObserved motifs use the global threshold unchanged.
  • FrameworkDesign motifs 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).

Source

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.

Source

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. Admissible default).

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.

Source

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 declared primary_witness_tiers are silent.

Theorem 9 preservation: each flag toggles a deterministic branch; same (episode, masks, flags) triple → same MatchConfidence byte-for-byte.

Trait Implementations§

Source§

impl<const MAX: usize> Default for HeuristicsBank<MAX>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const MAX: usize> Freeze for HeuristicsBank<MAX>

§

impl<const MAX: usize> RefUnwindSafe for HeuristicsBank<MAX>

§

impl<const MAX: usize> Send for HeuristicsBank<MAX>

§

impl<const MAX: usize> Sync for HeuristicsBank<MAX>

§

impl<const MAX: usize> Unpin for HeuristicsBank<MAX>

§

impl<const MAX: usize> UnsafeUnpin for HeuristicsBank<MAX>

§

impl<const MAX: usize> UnwindSafe for HeuristicsBank<MAX>

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> 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, 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.