Skip to main content

qualia_core_db/
wasm_capabilities.rs

1//! Compile-time capability declarations for the supported WebAssembly profiles.
2//!
3//! This is the source of truth used by browser metadata and packaging docs. A
4//! capability belongs here only when its profile is covered by a wasm32 build.
5
6pub const ONTOLOGY_KERNEL: &[&str] = &[
7    "nquin-48-byte-abi",
8    "q-hash",
9    "n3-parser",
10    "shacl-property-validation",
11    "deontic-logic",
12    "epistemic-logic",
13    "paraconsistent-routing",
14    "temporal-ltl",
15    "description-logic",
16    "answer-set-programming",
17    "linear-logic",
18    "interaction-governance",
19    "yaml-ld-q42",
20    "hcf-ingest",
21];
22
23pub const PORTAL: &[&str] = &[
24    "nquin-48-byte-abi",
25    "q-hash",
26    "json-ingest",
27    "json-ld-ingest",
28    "json-ld-serialize",
29    "json-ld-context-digest",
30    "rdfc-1.0-status",
31    "vendor-nquin-cbor",
32    "tensor-10d",
33    "spatial-encoding",
34    "webgpu-viewport",
35    "acoustic-plane",
36    "n3-parser",
37    "turtle-parser",
38    "rdf-serialization",
39    "ntriples-query",
40    "query-compiler",
41    "shacl-property-validation",
42    "shacl-graph-validation",
43    "deontic-logic",
44    "epistemic-logic",
45    "paraconsistent-routing",
46    "temporal-ltl",
47    "description-logic",
48    "answer-set-programming",
49    "linear-logic",
50    "interaction-governance",
51    "lww-crdt",
52    "yaml-ld-q42",
53    "hcf-ingest",
54    "bioinformatics",
55    "clinical-risk",
56    "organic-chemistry",
57    "economics",
58    "computational-geometry",
59    "q42-kernel-sparql-extensions",
60    "symbolic-logic",
61    "numerical-solvers",
62    "control-theory",
63    "geometric-algebra",
64    "quantum-dft",
65];
66
67pub const LOGIC: &[&str] = &[
68    "nquin-48-byte-abi",
69    "q-hash",
70    "n3-parser",
71    "turtle-parser",
72    "rdf-serialization",
73    "ntriples-query",
74    "query-compiler",
75    "shacl-property-validation",
76    "deontic-logic",
77    "epistemic-logic",
78    "paraconsistent-routing",
79    "temporal-ltl",
80    "description-logic",
81    "answer-set-programming",
82    "linear-logic",
83    "interaction-governance",
84    "lww-crdt",
85    "yaml-ld-q42",
86    "hcf-ingest",
87    "bioinformatics",
88    "clinical-risk",
89    "organic-chemistry",
90    "computational-geometry",
91    "economics",
92    "q42-kernel-sparql-extensions",
93    "symbolic-logic",
94    "numerical-solvers",
95    "control-theory",
96    "geometric-algebra",
97    "quantum-dft",
98];
99
100pub const SCIENTIFIC: &[&str] = &[
101    "nquin-48-byte-abi",
102    "q-hash",
103    "n3-parser",
104    "turtle-parser",
105    "rdf-serialization",
106    "ntriples-query",
107    "query-compiler",
108    "shacl-property-validation",
109    "deontic-logic",
110    "epistemic-logic",
111    "paraconsistent-routing",
112    "temporal-ltl",
113    "description-logic",
114    "answer-set-programming",
115    "linear-logic",
116    "interaction-governance",
117    "lww-crdt",
118    "yaml-ld-q42",
119    "hcf-ingest",
120    "bioinformatics",
121    "clinical-risk",
122    "organic-chemistry",
123    "economics",
124    "computational-geometry",
125    "q42-kernel-sparql-extensions",
126    "symbolic-logic",
127    "numerical-solvers",
128    "control-theory",
129    "geometric-algebra",
130    "quantum-dft",
131];
132
133pub const LLM: &[&str] = &[
134    "nquin-48-byte-abi",
135    "q-hash",
136    "n3-parser",
137    "turtle-parser",
138    "rdf-serialization",
139    "ntriples-query",
140    "query-compiler",
141    "shacl-property-validation",
142    "deontic-logic",
143    "epistemic-logic",
144    "paraconsistent-routing",
145    "temporal-ltl",
146    "description-logic",
147    "answer-set-programming",
148    "linear-logic",
149    "interaction-governance",
150    "lww-crdt",
151    "yaml-ld-q42",
152    "hcf-ingest",
153    "bioinformatics",
154    "clinical-risk",
155    "organic-chemistry",
156    "economics",
157    "symbolic-logic",
158    "numerical-solvers",
159    "control-theory",
160    "geometric-algebra",
161    "quantum-dft",
162    "gguf-parser",
163    "q42-model-container",
164    "webgpu-inference",
165    "streaming-decode",
166];
167
168pub const PLAYGROUND: &[&str] = &[
169    "nquin-48-byte-abi",
170    "q-hash",
171    "json-ld-ingest",
172    "json-ld-serialize",
173    "json-ld-context-digest",
174    "rdfc-1.0-status",
175    "vendor-nquin-cbor",
176    "n3-parser",
177    "turtle-parser",
178    "rdf-serialization",
179    "ntriples-query",
180    "query-compiler",
181    "shacl-property-validation",
182    "shacl-graph-validation",
183    "deontic-logic",
184    "epistemic-logic",
185    "paraconsistent-routing",
186    "temporal-ltl",
187    "description-logic",
188    "answer-set-programming",
189    "linear-logic",
190    "interaction-governance",
191    "lww-crdt",
192    "yaml-ld-q42",
193    "hcf-ingest",
194    "bioinformatics",
195    "clinical-risk",
196    "organic-chemistry",
197    "economics",
198    "computational-geometry",
199    "q42-kernel-sparql-extensions",
200    "symbolic-logic",
201    "numerical-solvers",
202    "control-theory",
203    "geometric-algebra",
204    "quantum-dft",
205    "wasm-playground-api",
206];
207
208pub const FULL: &[&str] = &[
209    "nquin-48-byte-abi",
210    "q-hash",
211    "json-ingest",
212    "json-ld-ingest",
213    "json-ld-serialize",
214    "json-ld-context-digest",
215    "rdfc-1.0-status",
216    "vendor-nquin-cbor",
217    "tensor-10d",
218    "spatial-encoding",
219    "webgpu-viewport",
220    "acoustic-plane",
221    "n3-parser",
222    "turtle-parser",
223    "rdf-serialization",
224    "ntriples-query",
225    "query-compiler",
226    "shacl-property-validation",
227    "shacl-graph-validation",
228    "deontic-logic",
229    "epistemic-logic",
230    "paraconsistent-routing",
231    "temporal-ltl",
232    "description-logic",
233    "answer-set-programming",
234    "linear-logic",
235    "interaction-governance",
236    "lww-crdt",
237    "yaml-ld-q42",
238    "hcf-ingest",
239    "bioinformatics",
240    "clinical-risk",
241    "organic-chemistry",
242    "economics",
243    "computational-geometry",
244    "q42-kernel-sparql-extensions",
245    "symbolic-logic",
246    "numerical-solvers",
247    "control-theory",
248    "geometric-algebra",
249    "quantum-dft",
250    "gguf-parser",
251    "q42-model-container",
252    "webgpu-inference",
253    "streaming-decode",
254    "wasm-playground-api",
255];
256
257/// WebCivics decision-evidence package (JSON-LD / SHACL / modal / SPARQL / Civics stats).
258///
259/// Deliberately omits WebGPU viewport, acoustic plane, tensor-10d demos, GGUF/LLM,
260/// and heavy science (DFT/GA/full bio). Prefer this profile for Civics.au Node/browser
261/// admission over `wasm-logic` (which currently pulls scientific → gpu-runtime).
262pub const WEBCIVICS: &[&str] = &[
263    "nquin-48-byte-abi",
264    "q-hash",
265    "json-ingest",
266    "json-ld-ingest",
267    "json-ld-serialize",
268    "json-ld-context-digest",
269    "rdfc-1.0-status",
270    "vendor-nquin-cbor",
271    "package-exposure-manifest",
272    "n3-parser",
273    "turtle-parser",
274    "rdf-serialization",
275    "solid-rdf-media-types",
276    "solid-leave-migrate",
277    "solid-qualia-return",
278    "json-ld-compact-serialize",
279    "ntriples-query",
280    "query-compiler",
281    "shacl-property-validation",
282    "shacl-graph-validation",
283    "deontic-logic",
284    "epistemic-logic",
285    "paraconsistent-routing",
286    "temporal-ltl",
287    "description-logic",
288    "answer-set-programming",
289    "linear-logic",
290    "interaction-governance",
291    "values-personhood-guard",
292    "lww-crdt",
293    "economics",
294    "q42-kernel-sparql-extensions",
295    "symbolic-logic",
296    "numerical-solvers",
297    "device-storage-policy",
298    "opfs-primary-vault",
299    "backup-folder-link",
300    "regression-verification",
301    "multiple-ols",
302    "jarque-bera",
303    "breusch-pagan",
304    "durbin-watson",
305    "vif",
306    "influence-diagnostics",
307    "ramsey-reset",
308    "chow-test",
309    "logit-lda",
310];
311
312/// Capabilities that must **not** be advertised as browser-available (UE-035/044/045).
313///
314/// Listed so Civics / packaging never confuse absence with a silent stub success.
315/// BFV HE stays native: unaudited upstream `fhe`, large binary, and local-first
316/// key material — see `docs/manuals/privacy-engine.md` § Browser policy.
317pub const NATIVE_ONLY: &[&str] = &[
318    "solvers-qpu",
319    "specialized-libs-qpu-bridge",
320    "privacy-he-bfv",
321    "privacy-dp-calibrated-releases", // available native; browser omits until policy revisit
322    "cryptographic-library-full",
323    "machine-learning-heavy",
324    "engineering-cfd",
325    "quantum-biology",
326    "daemon-filesystem-volumes",
327    "nvme-zns-csd",
328    "ble-mesh",
329    "ebpf-wfp-network-filter",
330    "directml-vulkan-native-inference",
331];
332
333/// Stable profile label for diagnostics and package manifests.
334pub const fn compiled_profile() -> &'static str {
335    if cfg!(feature = "wasm-full") {
336        "full"
337    } else if cfg!(feature = "wasm-webcivics") {
338        "webcivics"
339    } else if cfg!(all(
340        feature = "wasm-ontology",
341        not(any(
342            feature = "portal",
343            feature = "wasm-webcivics",
344            feature = "wasm-logic",
345            feature = "wasm-scientific",
346            feature = "wasm-llm",
347            feature = "wasm-full",
348            feature = "wasm-webcivics"
349        ))
350    )) {
351        "ontology-mcp-kernel"
352    } else if cfg!(feature = "portal") {
353        "portal"
354    } else if cfg!(feature = "wasm-llm") {
355        "llm"
356    } else if cfg!(feature = "wasm-playground") {
357        "playground"
358    } else if cfg!(feature = "wasm-webcivics") {
359        "webcivics"
360    } else if cfg!(feature = "wasm-logic") {
361        "logic"
362    } else if cfg!(feature = "wasm-scientific") {
363        "scientific"
364    } else {
365        "core"
366    }
367}
368
369/// Capabilities contributed by the selected top-level profile.
370pub const fn compiled_capabilities() -> &'static [&'static str] {
371    if cfg!(feature = "wasm-full") {
372        FULL
373    } else if cfg!(feature = "wasm-webcivics") {
374        WEBCIVICS
375    } else if cfg!(all(
376        feature = "wasm-ontology",
377        not(any(
378            feature = "portal",
379            feature = "wasm-webcivics",
380            feature = "wasm-logic",
381            feature = "wasm-scientific",
382            feature = "wasm-llm",
383            feature = "wasm-full",
384            feature = "wasm-webcivics"
385        ))
386    )) {
387        ONTOLOGY_KERNEL
388    } else if cfg!(feature = "portal") {
389        PORTAL
390    } else if cfg!(feature = "wasm-llm") {
391        LLM
392    } else if cfg!(feature = "wasm-playground") {
393        PLAYGROUND
394    } else if cfg!(feature = "wasm-webcivics") {
395        WEBCIVICS
396    } else if cfg!(feature = "wasm-logic") {
397        LOGIC
398    } else if cfg!(feature = "wasm-scientific") {
399        SCIENTIFIC
400    } else {
401        &[]
402    }
403}
404
405/// Native-only register (never advertised as present in a WASM profile).
406pub const fn native_only_capabilities() -> &'static [&'static str] {
407    NATIVE_ONLY
408}
409
410#[cfg(test)]
411mod tests {
412    use super::*;
413
414    #[test]
415    fn native_only_includes_qpu_and_bfv() {
416        assert!(NATIVE_ONLY.contains(&"solvers-qpu"));
417        assert!(NATIVE_ONLY.contains(&"privacy-he-bfv"));
418        assert!(!compiled_capabilities().contains(&"privacy-he-bfv"));
419    }
420
421    #[test]
422    fn webcivics_excludes_gpu_and_llm_capabilities() {
423        for forbidden in [
424            "webgpu-viewport",
425            "webgpu-inference",
426            "gguf-parser",
427            "streaming-decode",
428            "acoustic-plane",
429            "tensor-10d",
430            "quantum-dft",
431        ] {
432            assert!(
433                !WEBCIVICS.contains(&forbidden),
434                "{forbidden} must not appear in WEBCIVICS"
435            );
436        }
437        assert!(WEBCIVICS.contains(&"json-ld-ingest"));
438        assert!(WEBCIVICS.contains(&"shacl-graph-validation"));
439        assert!(WEBCIVICS.contains(&"deontic-logic"));
440        assert!(WEBCIVICS.contains(&"package-exposure-manifest"));
441        assert!(WEBCIVICS.contains(&"solid-rdf-media-types"));
442        assert!(WEBCIVICS.contains(&"solid-leave-migrate"));
443        assert!(WEBCIVICS.contains(&"solid-qualia-return"));
444        assert!(WEBCIVICS.contains(&"json-ld-compact-serialize"));
445        assert!(WEBCIVICS.contains(&"rdf-serialization"));
446        assert!(WEBCIVICS.contains(&"device-storage-policy"));
447        assert!(WEBCIVICS.contains(&"opfs-primary-vault"));
448        assert!(WEBCIVICS.contains(&"backup-folder-link"));
449        assert!(WEBCIVICS.contains(&"regression-verification"));
450        assert!(WEBCIVICS.contains(&"multiple-ols"));
451        assert!(WEBCIVICS.contains(&"jarque-bera"));
452        assert!(WEBCIVICS.contains(&"vif"));
453    }
454
455    #[test]
456    fn native_only_disjoint_from_full_advertised() {
457        for name in NATIVE_ONLY {
458            assert!(
459                !FULL.contains(name),
460                "{name} must not appear in FULL advertised list"
461            );
462        }
463    }
464}