Skip to main content

qualia_core_db/governance/webizen/
mod.rs

1//! Webizen VM — the Rights-Ontology governance gate over LLM/graph operations.
2//!
3//! Library-ized from the former `webizen.rs` (pure code motion, no behaviour change):
4//! * [`arena`]     — the 42MB zero-allocation SLG tabling arena + N3 rule firing.
5//! * [`opcode`]    — the `SlgOpcode` WAM instruction set.
6//! * [`vm`]        — `VmFrame`, the VM helpers, and `execute_vm_frame`.
7//! * [`agreement`] — agreement DIDs + the personhood-category-error guard.
8//!
9//! The full public surface is re-exported here, so every external path
10//! (`crate::governance::webizen::<Item>`) resolves exactly as before.
11
12use crate::domains::financial::tax_schema::TaxRuleSchema;
13use crate::modalities::logic::deontic::{
14    compile_norm_quin, evaluate_deontic_contract, harvest_defeater_fingerprints,
15    norm_has_active_defeater, DeonticStatus, DeonticVerdict, DEFEATER_BIT, MAX_DEFEATER_SLOTS,
16    OP_PERMIT,
17};
18use crate::modalities::spatio_temporal;
19use crate::modalities::temporal_ltl::{self, LtlFormula};
20use crate::modalities::{
21    abductive, argumentation, asp, ctl, defeasible, dialectical, dl, epistemic, fuzzy, linear,
22    manifold, modal, paraconsistent, probabilistic,
23};
24use crate::NQuin;
25
26macro_rules! vm_log {
27    ($($arg:tt)*) => {
28        if cfg!(feature = "vm_tracing") {
29            println!($($arg)*);
30        }
31    };
32}
33
34// 42MB = 44,040,192 bytes
35const SLG_ARENA_SIZE: usize = 42 * 1024 * 1024;
36const QUIN_SIZE: usize = 48;
37const MAX_SLOTS: usize = SLG_ARENA_SIZE / QUIN_SIZE; // 917,504 slots
38
39use crate::modalities::logic::n3_compiler::{
40    compile_rule_to_zero_heap, CompiledRule, CompiledTerm, CompiledTriple,
41};
42use crate::modalities::logic::n3_parser::Rule;
43
44/// The 42MB Static Tabling Arena for SLG Resolution
45/// Implemented as a Zero-Allocation Static Ring-Buffer Arena
46const RECENT_SLOT_RING: usize = 512;
47
48// ── Guard-rule grounding (forward chaining) bounds ──────────────────────────────
49/// Max distinct variables bound per guard rule (premise + conclusion).
50const MAX_RULE_VARS: usize = 16;
51/// Max conclusion triples staged across one `fire_guard_rules` pass.
52const MAX_GUARD_CONCLUSIONS: usize = 256;
53/// Recursion-depth ceiling for the premise join (premise triple count).
54const MAX_PREMISE_DEPTH: usize = 16;
55/// Max forward-chaining rounds (fixpoint cap) for `fire_guard_rules`.
56const MAX_FIXPOINT_ROUNDS: usize = 16;
57
58mod agreement;
59mod arena;
60mod opcode;
61mod vm;
62
63#[cfg(test)]
64mod tests;
65
66pub use agreement::*;
67pub use arena::*;
68pub use opcode::*;
69pub use vm::*;