Skip to main content

KernelMetricsSnapshot

Struct KernelMetricsSnapshot 

Source
#[non_exhaustive]
pub struct KernelMetricsSnapshot {
Show 29 fields pub steps_total: u64, pub cases_in_memory: usize, pub case_memory_capacity: usize, pub strategies_in_memory: usize, pub active_modules: usize, pub retained_patch_history: usize, pub average_prediction_error: f64, pub adaptation_score: f64, pub error_damping: f64, pub explore_bonus: f64, pub risk_tolerance: f64, pub max_risk: f64, pub self_modify_enabled: bool, pub l2_enabled: bool, pub l2_in_fixed_point: bool, pub l2_defensive_mode: bool, pub l2_gate_state: L2GateState, pub l2_dwell_steps: u64, pub l2_alignment_score: f64, pub l2_alpha: f64, pub l2_beta: f64, pub l2_lyapunov_potential: f64, pub l2_dayan_residual: f64, pub l2_lyapunov_veto: bool, pub l2_meta_cache_hit: bool, pub l2_meta_cache_entries: usize, pub l2_commit_cooldown_remaining: u64, pub l2_negative_consequence_streak: u32, pub l2_last_consequence_score: f64,
}
Available on crate feature std only.
Expand description

Read-only, in-memory operational metrics for export to monitoring systems.

The snapshot contains only counts, scalar gauges, and gate state. It does not include user goals, state paths, or other persisted content, and taking it performs no I/O or memory sampling. Counts named retained_* describe bounded in-memory history rather than lifetime totals.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§steps_total: u64

Total number of kernel steps completed in the current persisted state.

§cases_in_memory: usize

Number of cases currently resident in case memory.

§case_memory_capacity: usize

Configured capacity of case memory.

§strategies_in_memory: usize

Number of strategies currently resident in strategy memory.

§active_modules: usize

Number of active cognitive modules.

§retained_patch_history: usize

Number of patches retained in the bounded L1 patch history.

§average_prediction_error: f64

Current average prediction error.

§adaptation_score: f64

Current adaptation score.

§error_damping: f64

Current error-damping factor.

§explore_bonus: f64

Current exploration bonus.

§risk_tolerance: f64

Current risk tolerance.

§max_risk: f64

Maximum risk permitted by the active policy.

§self_modify_enabled: bool

Whether L1 self-modification is enabled.

§l2_enabled: bool

Whether the L2 meta-controller is enabled.

§l2_in_fixed_point: bool

Whether L2 is currently in a fixed-point regime.

§l2_defensive_mode: bool

Whether L2 is operating in defensive mode.

§l2_gate_state: L2GateState

Current L2 gate state.

§l2_dwell_steps: u64

Number of steps spent in the current L2 regime or arm.

§l2_alignment_score: f64

Most recent L2 alignment score.

§l2_alpha: f64

L2 policy learning-rate parameter.

§l2_beta: f64

L2 policy regularization parameter.

§l2_lyapunov_potential: f64

Current Lyapunov stability potential.

§l2_dayan_residual: f64

Residual used by the L2 Dayan stability calculation.

§l2_lyapunov_veto: bool

Whether the stability monitor vetoed an L2 change.

§l2_meta_cache_hit: bool

Whether the most recent L2 lookup hit the meta-cache.

§l2_meta_cache_entries: usize

Number of entries currently held by the L2 meta-cache.

§l2_commit_cooldown_remaining: u64

Steps remaining before another L2 policy commit is allowed.

§l2_negative_consequence_streak: u32

Number of consecutive negative consequences observed by L2.

§l2_last_consequence_score: f64

Most recent consequence score observed by L2.

Implementations§

Source§

impl KernelMetricsSnapshot

Source

pub fn to_prometheus_text(&self) -> String

Formats every field in this snapshot as Prometheus text exposition.

The output is a single, unlabeled sample per field. steps_total is a counter; all other values are gauges because they describe current state, bounded resident counts, or the most recently observed scores. Boolean fields are encoded as 0 or 1. The L2 gate state is encoded as 0 for dormant and 1 for active. Non-finite floating-point values are exported as 0 so that the exposition never contains NaN or an infinity token. HELP strings are escaped according to the Prometheus text format. This exporter adds no metrics beyond fields already held by the snapshot and performs no I/O.

This method is available only with the crate’s std feature, like the product-facing Kernel API. It does not change the no_std build or add an allocation requirement to that path.

§Examples
use omega_cognitive_kernel::{persist::MemoryStateStore, Kernel};

fn main() -> omega_cognitive_kernel::Result<()> {
    let kernel = Kernel::open_with_store(Box::new(MemoryStateStore::new()))?;
    let text = kernel.metrics_snapshot().to_prometheus_text();
    assert!(text.contains("# TYPE omega_kernel_steps_total counter\n"));
    assert!(text.contains("omega_kernel_steps_total 0\n"));
    assert!(!text.contains("NaN"));
    assert!(!text.contains("Inf"));
    Ok(())
}

Trait Implementations§

Source§

impl Clone for KernelMetricsSnapshot

Source§

fn clone(&self) -> Self

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 KernelMetricsSnapshot

Source§

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

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

impl PartialEq for KernelMetricsSnapshot

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for KernelMetricsSnapshot

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

impl StructuralPartialEq for KernelMetricsSnapshot

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more