1 import Base 2 import ./Console.bend as Console 3 4 # Pure checkpoint policy. Console.get_env maps an unset value to "", so the 5 # non-empty guard distinguishes disabled injection from an exact empty match. 6 def nonempty(value: String) -> Bool: 7 match value: 8 case SNil{}: False{} 9 case SCon{_, _}: True{} 10 11 def enabled(+configured: String, requested: String) -> Bool: 12 Bool.and(nonempty(configured), String.eq(configured, requested)) 13 14 # Irreducible host boundary: emit an unbuffered marker and stop this process. 15 def stop(name: String) -> IO(Result<&1, &1, U32 & String, Unit>): 16 import "./effs/crash_point.c" 17 import "./effs/crash_point.js" 18 19 def hit_decision(active: Bool, name: String) -> IO(Result<&1, &1, U32 & String, Unit>): 20 match active: 21 case True{}: 22 stop(name) 23 case False{}: 24 IO.pure(Result<&1, &1, U32 & String, Unit>, Done{Unit{}}) 25 26 # Test-only checkpoint. Environment lookup and activation policy stay in Bend; 27 # only marker emission and SIGSTOP remain in the host twins. 28 def hit(+name: String) -> IO(Result<&1, &1, U32 & String, Unit>): 29 do IO>: 30 configured : String <- IO.try(String, Console.get_env("MYLSM_CRASH_POINT")) 31 hit_decision(enabled(configured, name), name)