Skip to main content

lsp_max/runtime/control_plane/
powl_model.rs

1//! Declared POWL process model for lsp-max server instances.
2//! The declared model is the ΔP — what the server claims it does.
3//! wasm4pm checks actual execution against this declaration.
4
5use wasm4pm_compat::powl::Powl;
6
7/// The declared POWL process model for an lsp-max server instance.
8/// Holds the structural description of lawful operations the server performs.
9#[derive(Debug, Clone, Default)]
10pub struct DeclaredPowlModel {
11    /// Human-readable name for this model (e.g. "lsp-max-initialize-flow")
12    pub name: String,
13    /// The declared POWL structure. None until the server registers its process model.
14    pub model: Option<Powl>,
15    /// Minimum fitness threshold for admission (0.0–1.0)
16    pub fitness_threshold: f64,
17}
18
19impl DeclaredPowlModel {
20    pub fn new(name: impl Into<String>) -> Self {
21        DeclaredPowlModel {
22            name: name.into(),
23            model: None,
24            fitness_threshold: 0.8,
25        }
26    }
27
28    pub fn with_fitness_threshold(mut self, threshold: f64) -> Self {
29        self.fitness_threshold = threshold.clamp(0.0, 1.0);
30        self
31    }
32}