Most software and AI-control pipelines suffer from the same structural flaw: they confuse generation with authorization, and they confuse wall-clock ticks with causal progress.

Whether you are building an autonomous lab instrument, a deterministic simulation engine, or a safety-critical control loop, a candidate state can be smooth, locally coherent, and mathematically valid—and still have zero right to physical or historical consequence.

$$\text{Proposal is not permission.}$$

In this post, we will build KY Engine v1 ($\kappa_{27}$)—a zero-dependency, fail-closed realization kernel in pure Rust built around five strict architectural invariants:

  1. Generated dynamics $\neq$ Realized dynamics: A generator ($\Phi$) only proposes; an admissibility projector ($\Pi_K$) filters; a gate ($\Omega$) judges.
  2. Verdict is not dynamics: The gate $\Omega$ never mutates state. It takes an immutable reference to a projected candidate $\tilde{x}{t+1}$ and returns a typed verdict $d{t+1} \in {\mathrm{OPEN}, \mathrm{HOLD}, \mathrm{KILL}}$.
  3. No raw-to-commit shortcuts: Every transition must traverse the exact type-checked chain $\bigcirc\ (\mathrm{Raw}) \to \diamond\ (\mathrm{Estimate}) \to \square\ (\mathrm{Struct}) \to \hexagon\ (\mathrm{Viability}) \to \odot\ (\mathrm{Committed})$. Jumping straight from $\bigcirc \to \odot$ is an automatic KILL.
  4. Reversible trial ($\oplus$) vs. Irreversible commit ($\lor$): Candidate exploration uses reversible XOR phase masks, whereas realization uses a monotonic OR-fuse latch ($P_{t+1} = P_t \lor \Delta_t$).
  5. Time as a causal coordinate ($\tau$), not a passive clock ($t$): Wall-clock ticks ($t$) count attempts. Causal time ($\tau$) only increments when a transition is authorized (OPEN). On HOLD or KILL, $\Delta\tau = 0$.

1. The Typed Realization Law

In compact notation, people often write $x_{t+1} = \Omega(\Pi_K(\Phi(x_t)))$.
That is a useful glyph, but bad type theory. If $\Omega$ returns a verdict (OPEN, HOLD, KILL), it cannot simultaneously be the state $x_{t+1}$.

Written as strict typed mathematics, the realization step separates into three distinct equations:

$$\tilde{x}_{t+1} = \Pi_K(\Phi(x_t))$$

$$d_{t+1} = \Omega(\tilde{x}_{t+1}, \pi, g, h) \in {\mathrm{OPEN}, \mathrm{HOLD}, \mathrm{KILL}}$$

$$x_{t+1} = \begin{cases} \tilde{x}{t+1}, & d{t+1} = \mathrm{OPEN} \ x_t, & d_{t+1} = \mathrm{HOLD} \quad (\text{while } \tilde{x}{t+1} \text{ enters the } \Gamma\eta \text{ workshop}) \ \bot, & d_{t+1} = \mathrm{KILL} \end{cases}$$

And the causal time coordinate $\tau$ obeys:

$$\tau_{t+1} = \begin{cases} \tau_t + 1, & d_{t+1} = \mathrm{OPEN} \ \tau_t, & d_{t+1} \in {\mathrm{HOLD}, \mathrm{KILL}} \end{cases}$$

Why does this matter?
Because in a state-driven system, noise, rejected spikes, and unanchored proposals do not advance the history of the world. Ten thousand failed attempts (tick = 10_000) with zero authorized commits leave the world at tau = 0.

2. Why HOLD Is an Analytic Workshop ($\Gamma_\eta$), Not Hesitation

A hard binary gate (OPEN / KILL) is discontinuous—it cannot be non-constant and holomorphic on a connected domain. Therefore, any physical or numerical control system needs a two-layer structure:

  • Discrete realization boundary: OPEN and KILL.
  • Analytic transition zone ($\Gamma_\eta$): HOLD.

Inside HOLD:

  1. Clamping (clamp01) tames raw amplitude spikes before they corrupt metric state.
  2. Nash–Moser smoothing ($S_\lambda$) tames derivative noise so that the correction step itself does not destroy the structure it is trying to save.
  3. IKS Coherence ($F(F(s)) = s$) tests whether the candidate can complete a reversible round-trip without structural loss.
  4. Rosetta Identity verifies that the transition preserves identity across representations (model, control, hardware, audit).
  5. E-TOR (Epistemic Turn-Off Rule) enforces that if epistemic uncertainty $\pi$ exceeds threshold $\tau_{\text{risk}}$, controllable actuation is disabled:

$$\pi \ge \tau_{\text{risk}} \implies \forall a \in \Sigma_c:\ a\ \text{disabled}$$

Uncertainty is never allowed to convert itself into an irreversible physical consequence.

3. Complete Zero-Dependency Rust Implementation

Save this as ky_engine_v1_kappa27.rs and run it directly with rustc ky_engine_v1_kappa27.rs && ./ky_engine_v1_kappa27 (or rustc --test ky_engine_v1_kappa27.rs).

//! KY Engine v1 (κ_27) — Fail-Closed Meta-Engine Kernel with Typed Verdict & Causal Time (τ) //! Authority: NONE | Typed Law: //! x̃_{t+1} = Π_K(Φ(x_t)) //! d_{t+1} = Ω(x̃_{t+1}, π, g, h) ∈ {OPEN, HOLD, KILL} //! x_{t+1} = x̃_{t+1} (OPEN) | x_t (HOLD) | ⊥ (KILL) //! τ_{t+1} = τ_t + 1 (OPEN) | τ_t (HOLD, KILL) use std::collections::HashMap; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum LifecycleState { Raw, // ○ Estimate, // ◇ Struct, // □ Viability, // ⬡ Committed, // ◉ } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum GateStatus { Open, Hold, Kill, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum FailureCode { None, IllegalStateTransition, SyntaxError, StructureInvalid, HashChainBroken, Inadmissible, AuditFailed, NonReproducible, IksReversibilityFailed, RosettaIdentityDrift, NashCollapse, NashRegularizableResidual, EtorRiskExceeded, PostCausalBoundaryCrossed, HighUncertainty, } /// Verdict is not dynamics: Ω returns a pure decision (d_{t+1}), not a state. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct GateVerdict { pub decision: GateStatus, pub reason: FailureCode, } #[derive(Debug, Clone)] pub struct Record { pub object_id: u64, pub payload: String, pub lifecycle_state: LifecycleState, pub gate_status: GateStatus, pub structure_valid: bool, pub admissibility_flag: bool, pub audit_required: bool, pub audit_pass: bool, pub reproducible: bool, pub iks_reversible: bool, // F(F(s)) == s pub rosetta_identity_ok: bool, // Identity preservation across layers pub etor_risk_pi: f64, // Epistemic risk π pub etor_threshold_tau: f64, // Threshold τ (π >= τ => disabled) pub pre_commit_g: f64, // Pre-commit boundary g(x) < 0 pub clamped_amplitude: f64, // clamp01(amplitude) ∈ [0.0, 1.0] pub uncertainty_high: bool, pub failure_code: FailureCode, pub integrity_hash: u64, pub or_fuse_latch: u64, // P_{t+1} = P_t ∨ Δ_t (monotonic OR-fuse) pub tau_coord: u64, // Causal time coordinate (τ) at realization } #[derive(Debug, Clone)] pub struct WitnessEvent { pub event_id: u64, pub object_id: u64, pub prev_hash: u64, pub event_hash: u64, pub operation: &'static str, pub result: GateStatus, pub reason_code: FailureCode, pub timestamp: u64, // Wall-clock tick (t) pub tau_coord: u64, // Causal time coordinate (τ) } /// Clamping = amplitude control before meaning: forces raw values into [0, 1]. pub fn clamp01(val: f64) -> f64 { if val.is_nan() || val < 0.0 { 0.0 } else if val > 1.0 { 1.0 } else { val } } /// Reversible phase (XOR: ⊕) vs. Irreversible commit (OR-fuse: ∨) pub struct PhaseCommitLogic; impl PhaseCommitLogic { /// ⊕ = reversible phase/mask: (a ⊕ b) ⊕ b == a pub fn xor_reversible_phase(state_mask: u64, delta_mask: u64) -> u64 { state_mask ^ delta_mask } /// ∨ = irreversible commit (OR-fuse): P_{t+1} = P_t ∨ Δ_t with P_{t+1} ⊇ P_t pub fn or_fuse_commit(prev_latch: u64, delta_mask: u64) -> u64 { prev_latch | delta_mask } } /// IKS: Reversibility is the property. IKS is the test: F(F(s)) == s. pub struct IksCoherenceTest; impl IksCoherenceTest { pub fn involution_transform(s: &str) -> String { s.chars().rev().collect() } pub fn verify_roundtrip(s: &str) -> bool { let f_s = Self::involution_transform(s); let f_f_s = Self::involution_transform(&f_s); f_f_s == s } } /// Operational Nash Operator: N(x) = (r_BR(x), r_embed(x), r_tame(x), r_curv(g)) #[derive(Debug, Clone, Copy)] pub struct NashResidual { pub r_br: f64, pub r_embed: f64, pub r_tame: f64, pub r_curv: f64, } impl NashResidual { pub fn norm(&self) -> f64 { (self.r_br * self.r_br + self.r_embed * self.r_embed + self.r_tame * self.r_tame + self.r_curv * self.r_curv) .sqrt() } /// Nash–Moser smoothing operator (S_λ): tames derivative noise in HOLD zone pub fn smooth_s_lambda(&self, lambda: f64) -> Self { let factor = 1.0 / (1.0 + lambda.max(0.0)); Self { r_br: self.r_br * factor, r_embed: self.r_embed * factor, r_tame: self.r_tame * factor, r_curv: self.r_curv * factor, } } } pub struct NashGate; impl NashGate { pub fn evaluate(residual: &NashResidual, eps: f64, tau: f64, regularizable: bool) -> GateVerdict { let n = residual.norm(); if n <= eps { GateVerdict { decision: GateStatus::Open, reason: FailureCode::None, } } else if n <= tau && regularizable { GateVerdict { decision: GateStatus::Hold, reason: FailureCode::NashRegularizableResidual, } } else { GateVerdict { decision: GateStatus::Kill, reason: FailureCode::NashCollapse, } } } /// 2x2 Nash best-response verification pub fn verify_2x2_best_response(u1: [[i32; 2]; 2], u2: [[i32; 2]; 2], s1: usize, s2: usize) -> GateStatus { let other_s1 = 1 - s1; let other_s2 = 1 - s2; let p1_best = u1[s1][s2] >= u1[other_s1][s2]; let p2_best = u2[s1][s2] >= u2[s1][other_s2]; if p1_best && p2_best { GateStatus::Open } else { GateStatus::Kill } } } pub struct RawInput { pub object_id: u64, pub expression: String, pub audit_flag: bool, // # pub irreversible_flag: bool, // ! pub execute_flag: bool, // ▶ } pub struct Parser; impl Parser { pub fn parse(object_id: u64, input: &str) -> Result<RawInput, FailureCode> { let trimmed = input.trim(); if trimmed.is_empty() { return Err(FailureCode::SyntaxError); } let audit_flag = trimmed.contains('#'); let irreversible_flag = trimmed.contains('!'); let execute_flag = trimmed.contains('▶'); if !execute_flag { return Err(FailureCode::SyntaxError); } Ok(RawInput { object_id, expression: trimmed.to_string(), audit_flag, irreversible_flag, execute_flag, }) } } pub struct Typechecker; impl Typechecker { /// Only ○ -> ◇ -> □ -> ⬡ -> ◉ is allowed. Direct (○ -> ◉) is a forbidden short-circuit (KILL). pub fn verify_transition(from: LifecycleState, to: LifecycleState) -> Result<LifecycleState, FailureCode> { match (from, to) { (LifecycleState::Raw, LifecycleState::Estimate) => Ok(to), (LifecycleState::Estimate, LifecycleState::Struct) => Ok(to), (LifecycleState::Struct, LifecycleState::Viability) => Ok(to), (LifecycleState::Viability, LifecycleState::Committed) => Ok(to), _ => Err(FailureCode::IllegalStateTransition), } } } pub struct GeneratorPhi; impl GeneratorPhi { pub fn generate(raw: RawInput, current_tau: u64) -> Result<Record, FailureCode> { let next_state = Typechecker::verify_transition( LifecycleState::Raw, LifecycleState::Estimate, )?; Ok(Record { object_id: raw.object_id, payload: raw.expression, lifecycle_state: next_state, gate_status: GateStatus::Hold, structure_valid: false, admissibility_flag: false, audit_required: raw.audit_flag, audit_pass: false, reproducible: false, iks_reversible: false, rosetta_identity_ok: false, etor_risk_pi: 0.0, etor_threshold_tau: 0.5, pre_commit_g: -1.0, clamped_amplitude: clamp01(0.5), uncertainty_high: false, failure_code: FailureCode::None, integrity_hash: 0, or_fuse_latch: 0, tau_coord: current_tau, }) } } pub trait WorldRules { fn check_structure(&self, payload: &str) -> bool; fn check_admissibility(&self, payload: &str) -> bool; fn check_audit(&self, payload: &str) -> bool; fn check_reproducible(&self, payload: &str) -> bool; fn check_uncertainty(&self, payload: &str) -> bool; fn check_rosetta_identity(&self, _payload: &str) -> bool { true } fn compute_etor_risk_pi(&self, payload: &str) -> f64 { if self.check_uncertainty(payload) { 0.75 } else { 0.10 } } fn compute_pre_commit_g(&self, _payload: &str) -> f64 { -1.0 } } pub struct ProjectorPi; impl ProjectorPi { pub fn project<R: WorldRules>( mut candidate: Record, rules: &R, prev_hash: u64, ) -> Result<Record, FailureCode> { candidate.lifecycle_state = Typechecker::verify_transition( candidate.lifecycle_state, LifecycleState::Struct, )?; candidate.structure_valid = rules.check_structure(&candidate.payload); candidate.lifecycle_state = Typechecker::verify_transition( candidate.lifecycle_state, LifecycleState::Viability, )?; candidate.admissibility_flag = rules.check_admissibility(&candidate.payload); candidate.audit_pass = if candidate.audit_required { rules.check_audit(&candidate.payload) } else { true }; candidate.reproducible = rules.check_reproducible(&candidate.payload); candidate.iks_reversible = IksCoherenceTest::verify_roundtrip(&candidate.payload); candidate.rosetta_identity_ok = rules.check_rosetta_identity(&candidate.payload); candidate.etor_risk_pi = rules.compute_etor_risk_pi(&candidate.payload); candidate.pre_commit_g = rules.compute_pre_commit_g(&candidate.payload); candidate.uncertainty_high = rules.check_uncertainty(&candidate.payload); candidate.integrity_hash = Self::compute_hash(prev_hash, candidate.object_id, &candidate.payload); Ok(candidate) } pub fn compute_hash(prev_hash: u64, id: u64, payload: &str) -> u64 { let mut hash: u64 = 0xcbf29ce484222325; for b in prev_hash.to_le_bytes().iter().chain(id.to_le_bytes().iter()).chain(payload.as_bytes()) { hash ^= *b as u64; hash = hash.wrapping_mul(0x100000001b3Source:https://dev.to/marius0of1/proposal-is-not-permission-writing-a-fail-closed-realization-kernel-in-pure-rust-where-time-only-16a0

Related posts