qualia_core_db/governance/webizen/opcode.rs
1/// The Opcodes for the Lightweight Warren Abstract Machine (WAM) variant.
2/// `f64` parameters require `PartialEq` only — `Eq` is not derived.
3#[derive(Debug, Clone, Copy, PartialEq)]
4pub enum SlgOpcode {
5 // ── Core WAM ─────────────────────────────────────────────────────────────
6 CheckTable,
7 CheckDefeaters,
8 CheckSubsumption,
9 BranchWorld,
10 /// Deprecated — use `CheckMinInclusive`.
11 CheckThreshold,
12 ConsumeFact,
13 /// Linear-logic **zero-knowledge–gated** resource exhaustion: like `ConsumeFact`, but the
14 /// cryptographic-token resource `(subject_reg, predicate_reg, object_reg)` is spent **only**
15 /// if a verified zk-entitlement marker `(subject_reg, q42:zkVerified, q42:true)` is live in
16 /// the arena. Absent the proof, or if the token is already spent, the frame fails (`None`).
17 /// Delegates to `modalities::linear::zk_gated_consume`.
18 ZkConsumeFact,
19 Unify,
20 Call,
21 Return,
22 ApplyTaxSchema,
23 Halt,
24 /// sh:Warning terminal — emits diagnostic but does not halt ingestion.
25 WarnOnly,
26
27 // ── Standard SHACL numeric range ─────────────────────────────────────────
28 CheckMinInclusive(f64),
29 CheckMaxInclusive(f64),
30 CheckMinExclusive(f64),
31 CheckMaxExclusive(f64),
32
33 // ── Standard SHACL cardinality ────────────────────────────────────────────
34 CheckMinCount(u32),
35 CheckMaxCount(u32),
36
37 // ── Standard SHACL string ─────────────────────────────────────────────────
38 CheckMinLength(u32),
39 CheckMaxLength(u32),
40 /// Pattern stored as q_hash of the regex string; compared against literal hash.
41 CheckPattern(u64),
42
43 // ── Standard SHACL value constraints ──────────────────────────────────────
44 /// q_hash of the single expected value.
45 CheckHasValue(u64),
46 /// q_hash of a referenced node-shape IRI.
47 CheckNodeShape(u64),
48 /// Negation: passes only if the referenced shape would FAIL.
49 CheckNotShape(u64),
50 /// OR-branch: records a passing `rdf:type` match without failing the frame.
51 SoftCheckNodeShape(u64),
52 /// Fails unless at least one preceding `SoftCheckNodeShape` matched.
53 RequireAnyShape,
54 /// Validates inline literal tag on `object_reg` (0=IRI, 1=int, 2=decimal, 3=bool).
55 CheckObjectDatatype(u8),
56
57 // ── Native: physics ───────────────────────────────────────────────────────
58 NativeThermodynamics,
59 NativeOdeSolver,
60 /// RK4 ODE time-stepper with chaining support
61 /// Parameters packed: step_size (lower 32 bits) | num_steps (upper 32 bits)
62 NativeRk4Step(u64),
63 NativeQuantumDft,
64 /// `qualia:predictReceptorBinding` — PINN binding affinity.
65 NativeReceptorBinding,
66 /// Compile semantic constraints into blind QUBO matrix (Core 2).
67 NativeQuboCompile,
68 /// Emit linear QUBO bias: (var_index, f32_bits).
69 NativeQuboEmitLinear(u8, u32),
70 /// Emit quadratic coupler: (var_a, var_b, f32_bits).
71 NativeQuboEmitCoupler(u8, u8, u32),
72 /// Egress to remote QPU: 0=annealer, 1=gate-model. Yields frame to Core 3.
73 NativeQuantumEgress(u8),
74 /// Ingress: collapse provider JSON into provenance Quins.
75 NativeQuantumIngress,
76
77 // ── Native: biosciences ───────────────────────────────────────────────────
78 /// `qualia:alignNucleotideSequence` — Smith-Waterman with BLAST nucleotide matrix.
79 NativeNucleotideAlign,
80 /// Deprecated form — routes to `NativeNucleotideAlign`.
81 NativeBioinformatics,
82 /// `qualia:alignProteinSequence` — BLOSUM62 (0) or PAM250 (1).
83 NativeProteinAlign(u8),
84 /// `qualia:computeKmerFrequency` — k-mer size embedded as parameter.
85 NativeKmerFrequency(u8),
86 /// `qualia:validateFastaRecord`.
87 NativeFastaValidation,
88 /// `qualia:evaluateGeneExpression`.
89 NativeGeneExpression,
90 /// `qualia:computeMetaboliteSimilarity` — Tanimoto fingerprint check.
91 NativeMetaboliteSimilarity,
92
93 // ── Native: biomedical ────────────────────────────────────────────────────
94 /// `qualia:computeRiskScore` — 0=Framingham, 1=CHA₂DS₂-VASc, 2=SCORE2.
95 /// Frame registers cannot carry a complete clinical input; the opcode holds
96 /// rather than inventing lipids, region, or omitted booleans.
97 NativeClinicalRisk(u8),
98 /// `qualia:evaluateLongitudinalTrend` — sliding window in days.
99 NativeLongitudinalTrend(u32),
100 /// `qualia:evaluateDrugInteraction`.
101 NativeDrugInteraction,
102 /// `qualia:checkContraindication`.
103 NativeContraindication,
104 /// `qualia:validateFhirObservation` — LOINC code hash.
105 NativeFhirObservation(u64),
106
107 // ── Native: economics ─────────────────────────────────────────────────────
108 NativeEconomics,
109
110 // ── Native: organic chemistry ─────────────────────────────────────────────
111 /// `qualia:validateSmiles` — structural SMILES validity.
112 NativeSmilesValidation,
113 /// `qualia:validateInchi` — InChI / InChIKey format check.
114 NativeInchiValidation,
115 /// `qualia:computeMolecularWeight` — exact MW from SMILES; param = max allowed Da (bits of f64).
116 NativeMolecularWeight(u64),
117 /// `qualia:computeLogP` — Crippen LogP; param = max allowed × 100 as i32 (stored as u32 bits).
118 NativeLogP(u32),
119 /// `qualia:computeTPSA` — Ertl TPSA; param = max Ų (as u32).
120 NativeTPSA(u32),
121 /// `qualia:evaluateLipinski` — Rule-of-Five drug-likeness filter.
122 NativeLipinskiFilter,
123 /// `qualia:evaluateVeber` — Veber oral-bioavailability filter.
124 NativeVeberFilter,
125 /// `qualia:evaluateGhose` — Ghose drug-likeness filter.
126 NativeGhoseFilter,
127 /// `qualia:evaluateEgan` — Egan passive-absorption filter.
128 NativeEganFilter,
129 /// `qualia:detectFunctionalGroups` — returns set of detected functional group hashes.
130 NativeFunctionalGroups,
131 /// `qualia:computePka` — functional-group-based pKa estimation.
132 NativePkaEstimate,
133 /// `qualia:computeChiralCenters` — count sp3 C with 4 distinct substituents.
134 NativeChiralCenters,
135 /// `qualia:generateCircularFingerprint` — Morgan fingerprint; param = radius.
136 NativeCircularFingerprint(u8),
137 /// `qualia:computeArrheniusRate` — k = A·exp(−Ea/RT); param encodes temperature K as u32.
138 NativeArrhenius(u32),
139 /// `qualia:computeGibbsEnergy` — ΔG = ΔH − TΔS.
140 NativeGibbsEnergy,
141 /// `qualia:computeEquilibrium` — K = exp(−ΔG°/RT).
142 NativeEquilibrium,
143 /// `qualia:computeHendersonHasselbalch` — pH from pKa + concentration ratio.
144 NativeHendersonHasselbalch,
145 /// `qualia:computeAtomEconomy` — Trost 1991 green metric.
146 NativeAtomEconomy,
147 /// `qualia:computeEFactor` — Sheldon waste-per-product metric.
148 NativeEFactor,
149 /// `qualia:computeGreenMetrics` — full suite: AE, E-factor, PMI, RME, CE.
150 NativeGreenMetrics,
151
152 // ── Native: Phase 5 Scientific ────────────────────────────────────────────
153 NativeComputeCrcl,
154 NativeComputeEgfr,
155 NativeEvaluatePkModel,
156 NativeComputeSofaScore,
157 NativeTranslateDna,
158 NativeIsoelectricPoint,
159 NativePeptideCleavage,
160 NativeBbbPermeation,
161 NativeLigandEfficiency,
162 NativeLLE,
163 NativeIsotopeDistribution,
164
165 // ── Native: deontic and epistemic ─────────────────────────────────────────
166 NativeDeonticEval,
167 NativeEpistemicEval(u8),
168
169 // ── Native: advanced logics ───────────────────────────────────────────────
170 NativeLinearConsume,
171 NativeAspStableModels,
172 NativeParaconsistentIsolate,
173 NativeDialecticalSynthesis,
174 /// Probabilistic gate: the goal quin's f32 belief weight (in `metadata`) must
175 /// be ≥ the threshold (param = `f32::to_bits`).
176 NativeProbabilisticThreshold(u32),
177 /// Description-logic gate: `frame.subject_reg ⊑ frame.object_reg` over the arena
178 /// TBox (transitive `rdfs:subClassOf` closure).
179 NativeDlSubsumption,
180 /// Argumentation gate (Dung grounded semantics): the goal argument
181 /// (`frame.subject_reg`) must be justified — in the grounded extension built
182 /// from `arg:asserts` / `arg:attacks` quins in the arena.
183 NativeArgumentationGrounded,
184 /// Metric-temporal gate (MTL "within"): `target` (`frame.object_reg`) must
185 /// occur within the param window of the earliest `trigger` (`frame.predicate_reg`);
186 /// event timestamps are in each quin's `metadata`.
187 NativeMtlWithin(u32),
188 /// Contrary-to-duty gate (dyadic deontic): if the party (`frame.subject_reg`)
189 /// breached the primary obligation (`frame.predicate_reg`), the reparation
190 /// (`frame.object_reg`) must be fulfilled.
191 NativeContraryToDuty,
192 /// Causal-necessity gate (but-for): `frame.subject_reg` must be a necessary
193 /// cause of `frame.object_reg` from origin `frame.context_reg`.
194 NativeCausalNecessary,
195 /// Abductive gate: the observation (`frame.object_reg`) must have an explanatory
196 /// hypothesis (backward `abduces:explains` chain) in the arena.
197 NativeAbduce,
198 /// Closed-world / negation-as-failure gate: passes iff the frame goal is ABSENT
199 /// from the arena (its negation holds by default).
200 NativeClosedWorld,
201 /// Fuzzy-conjunction gate: the Gödel t-norm (min) of the truth degrees of all
202 /// quins with predicate `frame.predicate_reg` must be ≥ the param threshold.
203 NativeFuzzyConjunction(u32),
204 /// CTL EF gate: from `frame.subject_reg`, SOME path reaches a state satisfying
205 /// `frame.object_reg` (branching-time reachability over `ctl:next`/`ctl:holds`).
206 NativeCtlExistsFinally,
207 /// CTL AG gate: EVERY state reachable from `frame.subject_reg` satisfies the
208 /// invariant `frame.object_reg`.
209 NativeCtlAlwaysGlobally,
210 /// Modal □ gate: `frame.object_reg` holds in ALL worlds accessible from
211 /// `frame.subject_reg` (`modal:accesses`/`modal:holds`).
212 NativeModalNecessary,
213 /// Modal ◇ gate: `frame.object_reg` holds in SOME world accessible from
214 /// `frame.subject_reg`.
215 NativeModalPossible,
216 /// RCC-8 spatial gate: the topological relation between region `frame.subject_reg`
217 /// and region `frame.object_reg` (each = boundary-point quins) must equal the
218 /// param (0=DC,1=EC,2=PO,3=TPP,4=TPPi,5=NTPP,6=NTPPi,7=EQ).
219 NativeRcc8(u8),
220 /// RCC-8 fact-emitting assertion: if the relation holds, asserts a derived fact.
221 NativeRcc8Assert(u8),
222 /// Fact-emitting temporal interval relation assertion.
223 NativeAllenIntervalAssert(u8),
224 /// qapp-facing dynamic N3 rule registration
225 NativeRegisterRule,
226 /// M-of-N steward quorum gate
227 NativeStewardQuorum(u8),
228 /// Governed canvas placement gate
229 NativeCanvasPlacement,
230
231 // ── Native: cognitive ai (ACT-R) ──────────────────────────────────────────
232 NativeRetrieveByActivation,
233 NativeDecayMetadata,
234 NativeUnless,
235
236 // ── Native: temporal logic (LTL) ──────────────────────────────────────────
237 NativeLtlGlobally,
238 NativeLtlFinally,
239 NativeLtlNext,
240 NativeLtlUntil,
241 NativeLtlRelease,
242 /// Evaluate a threshold proposition projected from chronological 10D
243 /// manifold states through the existing LTL evaluator.
244 ///
245 /// `mode`: 0=Globally, 1=Finally, 2=Next.
246 /// `dimension`: `manifold::ManifoldDimension()` discriminant.
247 /// `threshold_bits`: IEEE-754 f32 threshold.
248 /// `at_least`: true for >=, false for <=.
249 NativeManifoldLtl {
250 mode: u8,
251 dimension: u8,
252 threshold_bits: u32,
253 at_least: bool,
254 },
255 /// Derive topology facts from 10D states and execute the bounded real ASP
256 /// stable-model evaluator. The selected model bitset is bound to object_reg.
257 NativeManifoldAsp,
258
259 // ── Native: spatio-temporal (Allen Interval) ──────────────────────────────
260 NativeAllenInterval(u8),
261
262 // ── Native: geometric and spatial topology ────────────────────────────────
263 NativeLorentzDistance,
264 NativeTropicalDistance,
265 NativeVerifyProofOfLocation,
266
267 // ── Native: calculus modality ──────────────────────────────────────────────
268 /// `calc:SimpsonsIntegration` — CPU-based Simpson's rule (start_bits, end_bits, step_size_bits, kahan_bits)
269 NativeCalcSimpsons(u64, u64, u32, u32),
270 /// `calc:TrapezoidalIntegration` — CPU-based trapezoidal rule (start_bits, end_bits, step_size_bits, kahan_bits)
271 NativeCalcTrapezoidal(u64, u64, u32, u32),
272 /// `calc:GpuIntegration` — GPU-accelerated integration via WebGPU (start_bits, end_bits, step_size_bits, kahan_bits)
273 NativeCalcGpu(u64, u64, u32, u32),
274}