Skip to main content

bistun_core/
ops.rs

1// Bistun Linguistic Metadata Service (LMS)
2// Copyright (C) 2026  Francis Xavier Wazeter IV
3
4#![cfg(feature = "ops")]
5
6//! # Operational Models
7//! Crate: bistun-core
8//! Ref: [007-LMS-OPS]
9//! Location: `crates/bistun-core/src/ops.rs`
10//!
11//! **Why**: This module centralizes the Service Level models required for SDK operational monitoring and telemetry.
12//! **Impact**: Defines the standard states the system can exist in and the metrics reported to observability sinks.
13
14use serde::{Deserialize, Serialize};
15
16/// Represents the operational health and readiness of the SDK.
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
18pub enum SdkState {
19    /// The manager is initializing and attempting to load data.
20    Bootstrapping,
21    /// The manager is fully hydrated and operating normally.
22    Ready,
23    /// The manager failed to hydrate and is running in Circuit Breaker mode.
24    Degraded,
25}
26
27/// Tracks the operational health and synchronization history of the capability engine.
28///
29/// Time: O(1) | Space: O(1)
30#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
31pub struct SyncMetrics {
32    /// Unix timestamp of the last time the worker attempted to fetch a snapshot.
33    pub last_attempted_sync: u64,
34    /// Unix timestamp of the last time the worker successfully hot-swapped a valid snapshot.
35    pub last_successful_sync: u64,
36    /// The cumulative number of failed hydration attempts since boot.
37    pub sync_error_count: u64,
38}
39
40/// Tracks the runtime resolution telemetry for the Capability Engine.
41/// Ref: [007-LMS-OPS]
42///
43/// Time: O(1) | Space: O(1)
44#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
45pub struct ResolutionMetrics {
46    /// Total number of manifests generated.
47    pub total_manifests_resolved: u64,
48    /// Total number of logical rules successfully synthesized.
49    pub rule_synthesis_count: u64,
50    /// Number of times the High-Water Mark algorithm successfully resolved a rule conflict.
51    pub rule_conflict_resolved_total: u64,
52    /// Number of times Phase 2.5 (Resource Bridge) failed to map an ID to a URI.
53    pub resource_resolution_failures: u64,
54}