#[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,
}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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.steps_total: u64Total number of kernel steps completed in the current persisted state.
cases_in_memory: usizeNumber of cases currently resident in case memory.
case_memory_capacity: usizeConfigured capacity of case memory.
strategies_in_memory: usizeNumber of strategies currently resident in strategy memory.
active_modules: usizeNumber of active cognitive modules.
retained_patch_history: usizeNumber of patches retained in the bounded L1 patch history.
average_prediction_error: f64Current average prediction error.
adaptation_score: f64Current adaptation score.
error_damping: f64Current error-damping factor.
explore_bonus: f64Current exploration bonus.
risk_tolerance: f64Current risk tolerance.
max_risk: f64Maximum risk permitted by the active policy.
self_modify_enabled: boolWhether L1 self-modification is enabled.
l2_enabled: boolWhether the L2 meta-controller is enabled.
l2_in_fixed_point: boolWhether L2 is currently in a fixed-point regime.
l2_defensive_mode: boolWhether L2 is operating in defensive mode.
l2_gate_state: L2GateStateCurrent L2 gate state.
l2_dwell_steps: u64Number of steps spent in the current L2 regime or arm.
l2_alignment_score: f64Most recent L2 alignment score.
l2_alpha: f64L2 policy learning-rate parameter.
l2_beta: f64L2 policy regularization parameter.
l2_lyapunov_potential: f64Current Lyapunov stability potential.
l2_dayan_residual: f64Residual used by the L2 Dayan stability calculation.
l2_lyapunov_veto: boolWhether the stability monitor vetoed an L2 change.
l2_meta_cache_hit: boolWhether the most recent L2 lookup hit the meta-cache.
l2_meta_cache_entries: usizeNumber of entries currently held by the L2 meta-cache.
l2_commit_cooldown_remaining: u64Steps remaining before another L2 policy commit is allowed.
l2_negative_consequence_streak: u32Number of consecutive negative consequences observed by L2.
l2_last_consequence_score: f64Most recent consequence score observed by L2.
Implementations§
Source§impl KernelMetricsSnapshot
impl KernelMetricsSnapshot
Sourcepub fn to_prometheus_text(&self) -> String
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(())
}