clm-kernel 0.0.8

Cubical Logic Model (CLM) sovereign execution engine, CPN-VM, and Cordis spatiotemporal substrate
Documentation
use super::*;

    #[test]
    fn test_subsumption_verification_soundness() {
        let old_ast = serde_json::json!({
            "abstract_spec": {
                "invariants": {
                    "preconditions": ["pre_a", "pre_b"],
                    "postconditions": ["post_x"]
                }
            }
        });

        // Valid replacement: weaker precondition (pre_a only) and stronger postcondition (post_x, post_y)
        let compliant_new_ast = serde_json::json!({
            "abstract_spec": {
                "invariants": {
                    "preconditions": ["pre_a"],
                    "postconditions": ["post_x", "post_y"]
                }
            }
        });

        let res = verify_subsumption(&old_ast, &compliant_new_ast);
        assert!(res.is_ok());
        let report = res.unwrap();
        assert!(report.pre_subsumed);
        assert!(report.post_subsumed);
        assert!(report.subsumption_valid);

        // Invalid replacement: stronger precondition (requires extra pre_c)
        let breaking_pre_ast = serde_json::json!({
            "abstract_spec": {
                "invariants": {
                    "preconditions": ["pre_a", "pre_c"],
                    "postconditions": ["post_x"]
                }
            }
        });
        assert!(verify_subsumption(&old_ast, &breaking_pre_ast).is_err());

        // Invalid replacement: weaker postcondition (missing post_x)
        let breaking_post_ast = serde_json::json!({
            "abstract_spec": {
                "invariants": {
                    "preconditions": ["pre_a"],
                    "postconditions": ["post_z"]
                }
            }
        });
        assert!(verify_subsumption(&old_ast, &breaking_post_ast).is_err());
    }

    #[test]
    fn test_dynamic_baldwin_fiber_lifecycle() {
        let ctx = crate::fiber::Context::root();
        let fiber = ctx.create_fiber("test_fiber", vec!["effect_1".to_string()]).unwrap();
        assert_eq!(fiber.get_state(), crate::fiber::FiberState::Pending);

        // Augment: satisfy effect_1
        augment_fiber(&ctx, "test_fiber", "effect_1").unwrap();
        assert_eq!(fiber.get_state(), crate::fiber::FiberState::Active);

        // Split: create child fiber in isolated context
        let split_res = split_fiber(&ctx, "test_fiber", &["effect_1"]);
        assert!(split_res.is_ok());

        // Exclude: cleanly terminate and remove
        exclude_fiber(&ctx, "test_fiber").unwrap();
        assert!(ctx.get_fiber("test_fiber").is_none());
    }