clm-kernel 0.0.14

Cubical Logic Model (CLM) sovereign execution engine, CPN-VM, and Cordis spatiotemporal substrate
Documentation
#![allow(unused_imports)]
use super::*;

// ── Testing & Verification ──────────────────────────────────

pub(super) fn dispatch_testing_verification(module_path: &str) -> Option<InternalFn> {
    match module_path {
        // Testing & Verification
        "clm_rust_core::prove::prove_tests" => Some(|clm_root, clm_file| {
            let args = get_clm_args(clm_file)?;
            let file = if args.is_empty() { clm_file } else { &args[0] };
            crate::prove::prove_tests(file, clm_root)
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_past_execution" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_past_execution()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_init_tridb" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_init_tridb()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_evaluator_functions" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_evaluator_functions()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_type_system" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_type_system()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_monadic_pcards" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_monadic_pcards()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_symbol_extraction" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_symbol_extraction()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_symbol_adapter_integration" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_symbol_adapter_integration()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_handle_indirection" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_handle_indirection()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_hash_migration" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_hash_migration()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_baldwin_operators" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_baldwin_operators()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_mcard_kernel" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_mcard_kernel()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_monadic_pcard_check_precondition" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_monadic_pcard_check_precondition()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_monadic_pcard_resolve_handle" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_monadic_pcard_resolve_handle()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_monadic_pcard_execute_payload" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_monadic_pcard_execute_payload()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_monadic_pcard_validate_postcondition" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_monadic_pcard_validate_postcondition()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_pcard_monad_composition" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_pcard_monad_composition()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_function_failures" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_function_failures()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_vcard_pre" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_vcard_pre()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_agent_containment" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_agent_containment()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_ephemeral_sessions" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_ephemeral_sessions()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint79_identity_hardening" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint79_identity_hardening()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_browser_portability" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_browser_portability()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_memdb_dispatch" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_memdb_dispatch()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint58_validation_chains" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint58_validation_chains()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint77_boundary_guards" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint77_boundary_guards()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint143_layer4_boundary" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint143_layer4_boundary()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint143_type_levels" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint143_type_levels()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint78_zero_fs_hermetic" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint78_zero_fs_hermetic()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint82_future_hardening" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint82_future_hardening()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint82_multilanguage" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint82_multilanguage()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sql_parameterized" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sql_parameterized()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_compose_nets_flattening" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_compose_nets_flattening()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_petri_invariants" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_petri_invariants()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_native_petri_vm_parity" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_native_petri_vm_parity()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_kernel_bootstrap_net" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_kernel_bootstrap_net()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_petri_math" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_petri_math()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint43_kenotic_petri" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint43_kenotic_petri()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_compiled_adapters" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_compiled_adapters()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint59_sandbox_isolation" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint59_sandbox_isolation()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_llm_codegen" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_llm_codegen()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_compose_nets_liveness" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_compose_nets_liveness()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_react_agent" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_react_agent()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint45_repl_showcase" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint45_repl_showcase()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint32_polyglot" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint32_polyglot()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_multi_language_benchmark" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_multi_language_benchmark()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_declarative_libraries" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_declarative_libraries()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_llm_adapter" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_llm_adapter()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_compose_functions" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_compose_functions()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_compose_conditions" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_compose_conditions()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_petri_net_suite" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_petri_net_suite()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_token_duality" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_token_duality()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_petri_binding_suite" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_petri_binding_suite()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint44_sovereign_accountability" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint44_sovereign_accountability()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_equivalence_assessment" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_equivalence_assessment()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_finetuning_sequence" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_finetuning_sequence()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_content_interpreter" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_content_interpreter()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_decomposition" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_decomposition()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_file_to_mcard" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_file_to_mcard()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint40_storage_equivalence" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint40_storage_equivalence()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_content_resolution_ioc" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_content_resolution_ioc()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_dependency_graph" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_dependency_graph()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint38_directory_equivalence" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint38_directory_equivalence()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_modelfile_sequence" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_modelfile_sequence()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_past_execution_layer2" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_past_execution_layer2()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_namespace_sync" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_namespace_sync()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_chat_interface" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_chat_interface()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_route_handle" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_route_handle()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_namespace_mapping" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_namespace_mapping()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_mdns_peer_discovery" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_mdns_peer_discovery()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_net_transport" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_net_transport()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_sprint42_decentralized_discovery" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_sprint42_decentralized_discovery()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_memorize_mcard" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_memorize_mcard()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_polyglot_ingest" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_polyglot_ingest()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_modular_adapters" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_modular_adapters()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_internal_dispatch_zerofs" => Some(|_clm_root, _clm_file| {
            crate::integration::run_integration_internal_dispatch_zerofs()
                .map(|out| (0, out))
        }),
        "clm_rust_core::integration::test_polyglot_sla_sandboxing" => Some(|clm_root, clm_file| {
            crate::integration::run_integration_polyglot_sla_sandboxing(clm_root, clm_file)
                .map(|out| (0, out))
        }),
        "clm_rust_core::test::math_op" => Some(|clm_root, _clm_file| {
            let payload_str = crate::cross_cutting::context::CLMContext::get_scoped_or_env("CLM_PAYLOAD")
                .unwrap_or_else(|| "0".to_string());
            let val = if payload_str.starts_with('{') {
                let v: serde_json::Value = serde_json::from_str(&payload_str).unwrap_or(serde_json::json!({}));
                v.get("val").and_then(|x| x.as_i64()).unwrap_or(0)
            } else if payload_str.contains(':') {
                let v: serde_json::Value = serde_yaml::from_str(&payload_str).unwrap_or(serde_json::json!({}));
                v.get("val").and_then(|x| x.as_i64()).unwrap_or(0)
            } else {
                payload_str.trim().parse::<i64>().unwrap_or(0)
            };

            let result = val + 2;

            let now = crate::utils::now_iso8601();
            let writer_arc = crate::db::get_writer_connection("content_memory", clm_root)
                .map_err(|e| format!("DB Error: {}", e))?;
            let conn = writer_arc.lock().map_err(|e| e.to_string())?;
            conn.execute(
                "INSERT INTO card (hash, content, g_time) VALUES (?, ?, ?)",
                rusqlite::params![format!("sha256:test_math_{}", val), format!("result: {}", result), now],
            ).map_err(|e| format!("DB Insert failed: {}", e))?;

            Ok((0, format!("result: {}", result)))
        }),
        "clm_rust_core::test::compiled_op" => Some(|clm_root, _clm_file| {
            let payload_str = crate::cross_cutting::context::CLMContext::get_scoped_or_env("CLM_PAYLOAD")
                .unwrap_or_else(|| "0".to_string());
            let val = if payload_str.starts_with('{') {
                let v: serde_json::Value = serde_json::from_str(&payload_str).unwrap_or(serde_json::json!({}));
                v.get("val").and_then(|x| x.as_i64()).unwrap_or(0)
            } else if payload_str.contains(':') {
                let v: serde_json::Value = serde_yaml::from_str(&payload_str).unwrap_or(serde_json::json!({}));
                v.get("val").and_then(|x| x.as_i64()).unwrap_or(0)
            } else {
                payload_str.trim().parse::<i64>().unwrap_or(0)
            };

            let result = val + 2;

            let now = crate::utils::now_iso8601();
            let writer_arc = crate::db::get_writer_connection("content_memory", clm_root)
                .map_err(|e| format!("DB Error: {}", e))?;
            let conn = writer_arc.lock().map_err(|e| e.to_string())?;
            conn.execute(
                "INSERT INTO card (hash, content, g_time) VALUES (?, ?, ?)",
                rusqlite::params![format!("sha256:test_math_{}", val), format!("result: {}", result), now],
            ).map_err(|e| format!("DB Insert failed: {}", e))?;

            Ok((0, format!("result: {}", result)))
        }),
        "clm_rust_core::test::braid_t1" => Some(|clm_root, _clm_file| {
            let now = crate::utils::now_iso8601();
            let writer_arc = crate::db::get_writer_connection("content_memory", clm_root)
                .map_err(|e| format!("DB Error: {}", e))?;
            let conn = writer_arc.lock().map_err(|e| e.to_string())?;
            conn.execute(
                "INSERT OR REPLACE INTO card (hash, content, g_time) VALUES (?, ?, ?)",
                rusqlite::params!["sha256:mark_c", "val: 10", now],
            ).map_err(|e| format!("DB Insert failed: {}", e))?;
            Ok((0, "val: 10".to_string()))
        }),
        "clm_rust_core::test::braid_t2" => Some(|clm_root, _clm_file| {
            let now = crate::utils::now_iso8601();
            let writer_arc = crate::db::get_writer_connection("content_memory", clm_root)
                .map_err(|e| format!("DB Error: {}", e))?;
            let conn = writer_arc.lock().map_err(|e| e.to_string())?;
            conn.execute(
                "INSERT OR REPLACE INTO card (hash, content, g_time) VALUES (?, ?, ?)",
                rusqlite::params!["sha256:mark_d", "val: 20", now],
            ).map_err(|e| format!("DB Insert failed: {}", e))?;
            Ok((0, "val: 20".to_string()))
        }),
        _ => None,
    }
}