@factoidal/core 0.7.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/CHANGELOG.md +616 -1
  2. package/NOTICE +2 -21
  3. package/README.md +123 -993
  4. package/api.d.ts +53 -0
  5. package/api.js +5 -0
  6. package/api.mjs +56 -0
  7. package/bin/engine.mjs +38 -19
  8. package/bin/ext.mjs +16 -20
  9. package/bin/factoidal.mjs +667 -118
  10. package/bin/pack.mjs +37 -0
  11. package/bin/serve-worker.mjs +32 -0
  12. package/bin/serve.mjs +423 -0
  13. package/bin/store-worker-host.mjs +1 -1
  14. package/bin/store.mjs +1 -1
  15. package/browser.d.ts +114 -507
  16. package/browser.js +155 -2257
  17. package/docs/fuseki-replacement.md +108 -0
  18. package/fn.d.ts +25 -96
  19. package/fn.js +131 -240
  20. package/index.d.ts +620 -260
  21. package/index.js +4 -234
  22. package/index.mjs +180 -84
  23. package/l4-assets/l4factoidal.js +47 -7
  24. package/l4-assets/l4factoidal.mjs +1 -1
  25. package/l4-assets/l4factoidal.wasm +0 -0
  26. package/l4-assets/version.json +11 -7
  27. package/lib/api.mjs +2337 -0
  28. package/lib/browser-engine.mjs +69 -0
  29. package/lib/dataset.mjs +471 -0
  30. package/lib/delta-log-hosts.mjs +191 -0
  31. package/lib/lean-entry.mjs +213 -0
  32. package/lib/pure.mjs +98 -0
  33. package/lib/store.mjs +115 -0
  34. package/lib/version.mjs +5 -0
  35. package/lws/README.md +137 -0
  36. package/lws/persist.mjs +78 -0
  37. package/lws/server.mjs +416 -0
  38. package/package.json +59 -61
  39. package/rdfjs.js +5 -536
  40. package/rdfjs.mjs +517 -0
  41. package/sample-store.d.ts +8 -16
  42. package/sample-store.mjs +39 -29
  43. package/solid/client/README.md +100 -0
  44. package/solid/client/index.mjs +293 -0
  45. package/solid/server/README.md +96 -0
  46. package/solid/server/index.mjs +395 -0
  47. package/store-host/deno.mjs +8 -0
  48. package/store-host/index.mjs +12 -0
  49. package/store-host/node.mjs +8 -0
  50. package/xmpp/README.md +107 -0
  51. package/xmpp/index.mjs +229 -0
  52. package/browser-wasm.js +0 -872
  53. package/factoidal-npm-entry.js +0 -15477
  54. package/factoidal-npm-entry.wasm.assets/code-5a7fc68f2ab1323718b8.wasm +0 -0
  55. package/factoidal-npm-entry.wasm.js +0 -455
  56. package/factoidal.js +0 -13118
  57. package/factoidal.wasm.assets/code-bbe6099bfb5b10c4c3ab.wasm +0 -0
  58. package/factoidal.wasm.js +0 -457
  59. package/hacl-init.js +0 -92
  60. package/hacl-wasm/FStar.wasm +0 -0
  61. package/hacl-wasm/Hacl_Bignum.wasm +0 -0
  62. package/hacl-wasm/Hacl_Bignum25519_51.wasm +0 -0
  63. package/hacl-wasm/Hacl_Bignum_Base.wasm +0 -0
  64. package/hacl-wasm/Hacl_Curve25519_51.wasm +0 -0
  65. package/hacl-wasm/Hacl_Ed25519.wasm +0 -0
  66. package/hacl-wasm/Hacl_Ed25519_PrecompTable.wasm +0 -0
  67. package/hacl-wasm/Hacl_Hash_Base.wasm +0 -0
  68. package/hacl-wasm/Hacl_Hash_SHA2.wasm +0 -0
  69. package/hacl-wasm/Hacl_IntTypes_Intrinsics.wasm +0 -0
  70. package/hacl-wasm/LowStar_Endianness.wasm +0 -0
  71. package/hacl-wasm/WasmSupport.wasm +0 -0
  72. package/hacl-wasm/api.js +0 -775
  73. package/hacl-wasm/api.json +0 -3787
  74. package/hacl-wasm/layouts.json +0 -1
  75. package/hacl-wasm/loader.js +0 -568
  76. package/hacl-wasm/shell.js +0 -12
  77. package/l4-core.d.ts +0 -159
  78. package/l4-core.js +0 -188
  79. package/l4.d.ts +0 -50
  80. package/l4.js +0 -104
  81. package/lib/api.js +0 -2300
  82. package/lib/engine-js.js +0 -165
  83. package/lib/engine-wasm.js +0 -300
  84. package/sample-store/CURRENT +0 -1
  85. package/sample-store/gen-1/manifest.sbm2 +0 -0
  86. package/sample-store/gen-1/manifest.tsv +0 -14
  87. package/sample-store/gen-1/predicate-0.ibk3 +0 -0
  88. package/sample-store/gen-1/predicate-0.ibk3.merkle +0 -1
  89. package/sample-store/gen-1/predicate-0.ibk3.oli2 +0 -0
  90. package/sample-store/gen-1/predicate-0.ibk3.oli2.merkle +0 -1
  91. package/sample-store/gen-1/predicate-0.ibk3.sri2 +0 -0
  92. package/sample-store/gen-1/predicate-0.ibk3.sri2.merkle +0 -1
  93. package/sample-store/gen-1/predicate-0.ibk3.tli1 +0 -0
  94. package/sample-store/gen-1/predicate-0.ibk3.tli1.merkle +0 -0
  95. package/sample-store/gen-1/predicate-1.ibk3 +0 -0
  96. package/sample-store/gen-1/predicate-1.ibk3.merkle +0 -0
  97. package/sample-store/gen-1/predicate-1.ibk3.oli2 +0 -0
  98. package/sample-store/gen-1/predicate-1.ibk3.oli2.merkle +0 -0
  99. package/sample-store/gen-1/predicate-1.ibk3.sri2 +0 -0
  100. package/sample-store/gen-1/predicate-1.ibk3.sri2.merkle +0 -1
  101. package/sample-store/gen-1/predicate-1.ibk3.tli1 +0 -0
  102. package/sample-store/gen-1/predicate-1.ibk3.tli1.merkle +0 -1
  103. package/sample-store/gen-1/predicate-10.ibk3 +0 -0
  104. package/sample-store/gen-1/predicate-10.ibk3.merkle +0 -1
  105. package/sample-store/gen-1/predicate-10.ibk3.oli2 +0 -0
  106. package/sample-store/gen-1/predicate-10.ibk3.oli2.merkle +0 -0
  107. package/sample-store/gen-1/predicate-10.ibk3.sri2 +0 -0
  108. package/sample-store/gen-1/predicate-10.ibk3.sri2.merkle +0 -1
  109. package/sample-store/gen-1/predicate-10.ibk3.tli1 +0 -0
  110. package/sample-store/gen-1/predicate-10.ibk3.tli1.merkle +0 -1
  111. package/sample-store/gen-1/predicate-11.ibk3 +0 -0
  112. package/sample-store/gen-1/predicate-11.ibk3.merkle +0 -0
  113. package/sample-store/gen-1/predicate-11.ibk3.oli2 +0 -0
  114. package/sample-store/gen-1/predicate-11.ibk3.oli2.merkle +0 -1
  115. package/sample-store/gen-1/predicate-11.ibk3.sri2 +0 -0
  116. package/sample-store/gen-1/predicate-11.ibk3.sri2.merkle +0 -1
  117. package/sample-store/gen-1/predicate-11.ibk3.tli1 +0 -0
  118. package/sample-store/gen-1/predicate-11.ibk3.tli1.merkle +0 -1
  119. package/sample-store/gen-1/predicate-12.ibk3 +0 -0
  120. package/sample-store/gen-1/predicate-12.ibk3.merkle +0 -1
  121. package/sample-store/gen-1/predicate-12.ibk3.oli2 +0 -0
  122. package/sample-store/gen-1/predicate-12.ibk3.oli2.merkle +0 -1
  123. package/sample-store/gen-1/predicate-12.ibk3.sri2 +0 -0
  124. package/sample-store/gen-1/predicate-12.ibk3.sri2.merkle +0 -1
  125. package/sample-store/gen-1/predicate-12.ibk3.tli1 +0 -0
  126. package/sample-store/gen-1/predicate-12.ibk3.tli1.merkle +0 -1
  127. package/sample-store/gen-1/predicate-2.ibk3 +0 -0
  128. package/sample-store/gen-1/predicate-2.ibk3.merkle +0 -1
  129. package/sample-store/gen-1/predicate-2.ibk3.oli2 +0 -0
  130. package/sample-store/gen-1/predicate-2.ibk3.oli2.merkle +0 -1
  131. package/sample-store/gen-1/predicate-2.ibk3.sri2 +0 -0
  132. package/sample-store/gen-1/predicate-2.ibk3.sri2.merkle +0 -0
  133. package/sample-store/gen-1/predicate-2.ibk3.tli1 +0 -0
  134. package/sample-store/gen-1/predicate-2.ibk3.tli1.merkle +0 -0
  135. package/sample-store/gen-1/predicate-3.ibk3 +0 -0
  136. package/sample-store/gen-1/predicate-3.ibk3.merkle +0 -1
  137. package/sample-store/gen-1/predicate-3.ibk3.oli2 +0 -0
  138. package/sample-store/gen-1/predicate-3.ibk3.oli2.merkle +0 -1
  139. package/sample-store/gen-1/predicate-3.ibk3.sri2 +0 -0
  140. package/sample-store/gen-1/predicate-3.ibk3.sri2.merkle +0 -1
  141. package/sample-store/gen-1/predicate-3.ibk3.tli1 +0 -0
  142. package/sample-store/gen-1/predicate-3.ibk3.tli1.merkle +0 -1
  143. package/sample-store/gen-1/predicate-4.ibk3 +0 -0
  144. package/sample-store/gen-1/predicate-4.ibk3.merkle +0 -0
  145. package/sample-store/gen-1/predicate-4.ibk3.oli2 +0 -0
  146. package/sample-store/gen-1/predicate-4.ibk3.oli2.merkle +0 -1
  147. package/sample-store/gen-1/predicate-4.ibk3.sri2 +0 -0
  148. package/sample-store/gen-1/predicate-4.ibk3.sri2.merkle +0 -1
  149. package/sample-store/gen-1/predicate-4.ibk3.tli1 +0 -0
  150. package/sample-store/gen-1/predicate-4.ibk3.tli1.merkle +0 -2
  151. package/sample-store/gen-1/predicate-5.ibk3 +0 -0
  152. package/sample-store/gen-1/predicate-5.ibk3.merkle +0 -1
  153. package/sample-store/gen-1/predicate-5.ibk3.oli2 +0 -0
  154. package/sample-store/gen-1/predicate-5.ibk3.oli2.merkle +0 -1
  155. package/sample-store/gen-1/predicate-5.ibk3.sri2 +0 -0
  156. package/sample-store/gen-1/predicate-5.ibk3.sri2.merkle +0 -1
  157. package/sample-store/gen-1/predicate-5.ibk3.tli1 +0 -0
  158. package/sample-store/gen-1/predicate-5.ibk3.tli1.merkle +0 -1
  159. package/sample-store/gen-1/predicate-6.ibk3 +0 -0
  160. package/sample-store/gen-1/predicate-6.ibk3.merkle +0 -1
  161. package/sample-store/gen-1/predicate-6.ibk3.oli2 +0 -0
  162. package/sample-store/gen-1/predicate-6.ibk3.oli2.merkle +0 -1
  163. package/sample-store/gen-1/predicate-6.ibk3.sri2 +0 -0
  164. package/sample-store/gen-1/predicate-6.ibk3.sri2.merkle +0 -1
  165. package/sample-store/gen-1/predicate-6.ibk3.tli1 +0 -0
  166. package/sample-store/gen-1/predicate-6.ibk3.tli1.merkle +0 -0
  167. package/sample-store/gen-1/predicate-7.ibk3 +0 -0
  168. package/sample-store/gen-1/predicate-7.ibk3.merkle +0 -0
  169. package/sample-store/gen-1/predicate-7.ibk3.oli2 +0 -0
  170. package/sample-store/gen-1/predicate-7.ibk3.oli2.merkle +0 -2
  171. package/sample-store/gen-1/predicate-7.ibk3.sri2 +0 -0
  172. package/sample-store/gen-1/predicate-7.ibk3.sri2.merkle +0 -1
  173. package/sample-store/gen-1/predicate-7.ibk3.tli1 +0 -0
  174. package/sample-store/gen-1/predicate-7.ibk3.tli1.merkle +0 -1
  175. package/sample-store/gen-1/predicate-8.ibk3 +0 -0
  176. package/sample-store/gen-1/predicate-8.ibk3.merkle +0 -1
  177. package/sample-store/gen-1/predicate-8.ibk3.oli2 +0 -0
  178. package/sample-store/gen-1/predicate-8.ibk3.oli2.merkle +0 -1
  179. package/sample-store/gen-1/predicate-8.ibk3.sri2 +0 -0
  180. package/sample-store/gen-1/predicate-8.ibk3.sri2.merkle +0 -1
  181. package/sample-store/gen-1/predicate-8.ibk3.tli1 +0 -0
  182. package/sample-store/gen-1/predicate-8.ibk3.tli1.merkle +0 -1
  183. package/sample-store/gen-1/predicate-9.ibk3 +0 -0
  184. package/sample-store/gen-1/predicate-9.ibk3.merkle +0 -1
  185. package/sample-store/gen-1/predicate-9.ibk3.oli2 +0 -0
  186. package/sample-store/gen-1/predicate-9.ibk3.oli2.merkle +0 -1
  187. package/sample-store/gen-1/predicate-9.ibk3.sri2 +0 -0
  188. package/sample-store/gen-1/predicate-9.ibk3.sri2.merkle +0 -3
  189. package/sample-store/gen-1/predicate-9.ibk3.tli1 +0 -0
  190. package/sample-store/gen-1/predicate-9.ibk3.tli1.merkle +0 -2
  191. package/select.d.ts +0 -116
  192. package/select.js +0 -492
  193. package/version.json +0 -102
  194. package/wasm.d.ts +0 -130
  195. package/wasm.js +0 -158
package/l4-core.d.ts DELETED
@@ -1,159 +0,0 @@
1
- // TypeScript declarations for 'factoidal/l4-core' — the typed core
2
- // API served by the Lean 4 engine (L4Factoidal compiled to
3
- // WebAssembly) instead of the F* extraction. Assets resolve through
4
- // the 'factoidal/l4' ladder: @factoidal/lean, $FACTOIDAL_L4_ASSETS,
5
- // then the repository checkout.
6
-
7
- import {
8
- DataFactory,
9
- DataInput,
10
- DataFormat,
11
- Dataset,
12
- ParseOptions,
13
- QueryOptions,
14
- SerializeOptions,
15
- Bindings,
16
- ShaclValidateResult,
17
- } from './index';
18
-
19
- export {
20
- Dataset,
21
- DataFactory,
22
- DataInput,
23
- DataFormat,
24
- ParseOptions,
25
- QueryOptions,
26
- SerializeOptions,
27
- Bindings,
28
- };
29
-
30
- export function parse(text: string, options?: ParseOptions): Promise<Dataset>;
31
- export function query(
32
- data: DataInput,
33
- sparql: string,
34
- options?: QueryOptions
35
- ): Promise<Bindings[] | boolean | Dataset>;
36
- export function update(data: DataInput, sparql: string): Promise<Dataset>;
37
- export function serialize(
38
- data: DataInput,
39
- options?: SerializeOptions
40
- ): Promise<string>;
41
- export function canonicalize(data: DataInput): Promise<string>;
42
- export function graphs(data: DataInput): Promise<string[]>;
43
- export function canonicalHash(data: DataInput): Promise<string>;
44
- export function owlClosure(
45
- data: DataInput,
46
- options?: { regime?: 'RDFS' | 'OWL-RL' }
47
- ): Promise<Dataset>;
48
- export function coreRdfsClosure(data: DataInput): Promise<Dataset>;
49
- export function coreRdfsCheck(data: DataInput): Promise<boolean>;
50
- export function rhoDfClosure(data: DataInput): Promise<Dataset>;
51
- export function rhoDfFragmentCheck(data: DataInput): Promise<boolean>;
52
- export function rdfsPlusClosure(data: DataInput): Promise<Dataset>;
53
-
54
- // Lean-only: formal/fstar has no CL/IKL parser, so `clParse` does not
55
- // exist on index.d.ts/wasm.d.ts. Reads Common Logic Interchange Format
56
- // text (ISO/IEC 24707:2018), with the IKL `that`-operator extension,
57
- // and reports its shape -- it never produces RDF. `pureCL` is a
58
- // DIALECT flag, not a validity or quality signal: true while the text
59
- // stays inside ISO/IEC 24707 Common Logic, false once it uses IKL's
60
- // `that` operator. A CLIF text that fails to parse rejects instead of
61
- // returning either value.
62
- export function clParse(clifText: string): Promise<{
63
- ok: boolean;
64
- sentences: number;
65
- pureCL: boolean;
66
- normalized: string;
67
- }>;
68
-
69
- // Lean-only, same reason as clParse. Reads CLIF text and writes it
70
- // back out in canonical spacing. `roundTripProved` is ALWAYS `false`:
71
- // `clif_roundTrip` (CL/ClifAdequacy.lean) is an OPEN lemma -- the
72
- // fragment boundary `marksLexable` is MEASURED, not proved. The field
73
- // is surfaced, not dropped or defaulted away, so a caller does not
74
- // have to go find that out.
75
- export function clSerialize(clifText: string): Promise<{
76
- ok: boolean;
77
- clif: string;
78
- sentences: number;
79
- roundTripProved: false;
80
- }>;
81
-
82
- // Lean-only, same reason as clParse. Alpha-normalises CLIF text: the
83
- // canonical representative of each sentence's bound-variable-renaming
84
- // equivalence class -- IKL GUIDE Appendix B condition (1), renaming a
85
- // bound variable does not change the proposition expressed. Two
86
- // sentences that differ only in bound-variable names produce
87
- // byte-identical `clif` output.
88
- export function clAlphaNorm(clifText: string): Promise<{
89
- ok: boolean;
90
- clif: string;
91
- sentences: number;
92
- }>;
93
-
94
- // Lean-only, same reason as clParse. Hayes's reduction of IKL to
95
- // Common Logic (danbri/factoidal#625), over a whole text.
96
- //
97
- // `preserves: "satisfiability"` -- the reduction preserves
98
- // satisfiability, NOT equivalence. It suits entailment and consistency
99
- // testing; it is not a transformation to apply to data you intend to
100
- // keep.
101
- //
102
- // `noIntrusion` IS the proof hypothesis `CL.noIntrSs [] []` decides,
103
- // not a paraphrase of it. The transformation runs and returns output
104
- // either way; when `noIntrusion` is `false`, `tails_satisfiable` /
105
- // `normalize_preserves` do not cover that output.
106
- export function clNormalize(clifText: string): Promise<{
107
- ok: boolean;
108
- head: string[];
109
- tail: string[];
110
- clif: string;
111
- sentences: number;
112
- thatCount: number;
113
- noIntrusion: boolean;
114
- preserves: 'satisfiability';
115
- provedUnder: string;
116
- }>;
117
-
118
- // clFiniteSat is DEFERRED from this typed surface (owner decision,
119
- // 2026-08-26), not excluded: it takes a caller-supplied finite-
120
- // interpretation JSON encoding that has no user yet. Reachable only
121
- // through the raw dispatch ABI (`l4.call('clFiniteSat', [interpJson,
122
- // clifText])`), which needs no typed shape commitment here.
123
-
124
- // Present on the surface, NOT implemented by the Lean engine: each
125
- // rejects with an engine-capability error so an engine swap fails
126
- // loudly rather than with `undefined is not a function`.
127
- // capabilities() reports the truth per feature.
128
- export function shaclValidate(
129
- data: DataInput,
130
- shapes: DataInput
131
- ): Promise<ShaclValidateResult>;
132
- export function shexValidate(
133
- data: DataInput,
134
- schema: string,
135
- shapeMap: string
136
- ): Promise<unknown>;
137
- // Served by the Lean engine when the resolved wasm carries the ops
138
- // (dispatch ABI `owlIsConsistent` / `owlEntails`, formal/lean4 issue
139
- // 586); same three-valued envelopes as index.d.ts. An older bundle
140
- // rejects with an "unknown op" error.
141
- export function owlIsConsistent(
142
- data: DataInput,
143
- options?: { format?: string; fuel?: number | string }
144
- ): Promise<{ consistent: boolean | null; reason?: string }>;
145
- export function owlEntails(
146
- premise: DataInput,
147
- conclusion: DataInput,
148
- options?: { format?: string; fuel?: number | string }
149
- ): Promise<{
150
- entailed: boolean | null;
151
- via: 'closure' | 'refutation';
152
- reason?: string;
153
- }>;
154
-
155
- export function capabilities(): Promise<Record<string, boolean | string>>;
156
- export const dataFactory: DataFactory;
157
- export const engine: 'lean4-wasm';
158
- export function available(): boolean;
159
- export const version: string;
package/l4-core.js DELETED
@@ -1,188 +0,0 @@
1
- // factoidal — Node entry point for the **Lean 4** engine.
2
- //
3
- // The same typed public API shape as index.js / wasm.js (parse /
4
- // query / update / serialize / canonicalize / dataFactory / Dataset /
5
- // the closure and checker family), served by the Lean 4 extraction
6
- // compiled to WebAssembly (L4Factoidal — formal/lean4/) instead of
7
- // the F* extraction. Asset resolution is l4.js's three-step ladder:
8
- // @factoidal/lean, $FACTOIDAL_L4_ASSETS, then the repository checkout.
9
- //
10
- // const factoidal = require('@factoidal/core/l4-core');
11
- // const ds = await factoidal.parse('<a> <b> "c" .', { format: 'ntriples' });
12
- //
13
- // Surface: the subset capabilities() reports. Operations the Lean
14
- // engine does not implement (SHACL, ShEx, HDT, COTTAS, VC crypto,
15
- // entailment-regime query modes, tableauMaterialise /
16
- // tableauDlInconsistent, RML/CSVW/JSON-LD/RIF) reject with a clear
17
- // engine-capability error rather than silently falling back to the F*
18
- // engine — the point of this entry is that everything it answers came
19
- // through the Lean extraction. See ./select.js (factoidal/select) for
20
- // an explicit, observable lean/fstar/lean1st/fstar1st/slowcompareboth
21
- // switch built on top of this and ./index.js (issue #618); this module
22
- // itself never falls back. owlIsConsistent / owlEntails ARE served
23
- // (the three-valued OWL DL verdict, formal/lean4 issue 586) when the
24
- // resolved wasm carries the ops — an older bundle answers "unknown op",
25
- // which surfaces as the entryResult error, so probe the `ops`
26
- // reflection before relying on them. The export list mirrors wasm.js
27
- // so callers can swap engines by import path alone.
28
-
29
- 'use strict';
30
-
31
- const { buildApi } = require('./lib/api.js');
32
- const rdfjs = require('./rdfjs.js');
33
- const l4 = require('./l4.js');
34
- const pkg = require('./package.json');
35
-
36
- const NOT_SUPPORTED =
37
- 'factoidal/l4-core: this operation is not implemented by the Lean 4 ' +
38
- 'engine (see capabilities()); use the F* engine entry points for it. ' +
39
- 'If the Lean assets are missing, npm install @factoidal/lean or set ' +
40
- 'FACTOIDAL_L4_ASSETS.';
41
-
42
- // The entry-ABI method names lib/api.js dispatches on, mapped onto the
43
- // Lean wasm module's single dispatch export. Methods absent from this
44
- // list are deliberately absent from the entry object: api.js
45
- // typeof-guards each one and capabilities() reports the truth.
46
- //
47
- // The resolved wasm's full dispatch surface has 21 ops
48
- // (`bin/linux-x86_64/l4factoidal ops`); this list wires 16 of them.
49
- // `clParse` reads CLIF text into a CL syntax tree and reports its
50
- // shape (sentence count, CL-vs-IKL dialect, canonical re-serialisation)
51
- // -- it never produces RDF, so it is NOT part of the IKL-to-RDF
52
- // projection family below. `clSerialize`, `clAlphaNorm` and
53
- // `clNormalize` join it as the same kind of entry (CLIF text in, CLIF/
54
- // CL text out, never RDF) -- see lib/api.js's doc comments on each for
55
- // what their answers are worth (clSerialize's `roundTripProved: false`,
56
- // clNormalize's `preserves`/`noIntrusion`). All four are Lean-only
57
- // entries in the typed capability table (formal/fstar has no CL/IKL
58
- // parser at all); see ./select.js, which throws on `backend:'fstar'`
59
- // for each rather than answering from Lean silently.
60
- //
61
- // `clFiniteSat` (the fifth CL/IKL op) is DEFERRED from this typed
62
- // layer, not excluded (owner decision, 2026-08-26): it takes a
63
- // caller-supplied finite-interpretation JSON encoding that has no user
64
- // yet, and a typed wrapper would freeze that shape before we know
65
- // whether it is right. It stays reachable only through the raw
66
- // dispatch ABI (`l4.call('clFiniteSat', [interpJson, clifText])`) --
67
- // see lib/api.js's comment next to the other three clNormalize/
68
- // clAlphaNorm/clSerialize wrappers for the same note.
69
- //
70
- // The IKL-to-RDF projection ("direction B": `clToDataset`,
71
- // `queryWithIklService`) was removed from the engine source on
72
- // 2026-08-26 (https://github.com/danbri/factoidal/issues/626): both
73
- // ops went through the deleted `CL/ToRdf.lean`, whose content-addressed
74
- // proposition graph names were never asked for. They had already been held off this JS surface by owner
75
- // decision (https://github.com/danbri/factoidal/issues/618 — "I don't
76
- // want npm code for direction b at this stage ... Take it out of npm
77
- // for now."), and there is now nothing to wire. The compiled wasm
78
- // artifact still CONTAINS both ops until it is rebuilt
79
- // (https://github.com/danbri/factoidal/issues/627) — it is ahead of
80
- // its source. The same #618 ruling is why an x-ikl-<suffix>
81
- // entailment-regime family is rejected in lib/api.js's query() and
82
- // fn.js's entail().
83
- //
84
- // CORRECTION 2026-08-26: an earlier version of this comment listed
85
- // `clParse` alongside those two and cited #618 as the reason for all
86
- // three. That misattributed a decision the owner did not make --
87
- // `clParse` was unwired only because nobody had decided to wrap it,
88
- // which is why it is wired above instead of here.
89
- //
90
- // A second group is withheld for an unrelated, non-owner reason:
91
- //
92
- // - dataset handles (`datasetOpen`/`datasetQuery`/`datasetUpdate`/
93
- // `datasetSerialize`/`datasetClose`): ordinary RDF dataset handles,
94
- // not part of the CL/IKL decision above. Held back only because
95
- // lib/api.js has no typed wrapper shape for a stateful handle yet
96
- // (every existing typed op is request/response) — a scope
97
- // judgement, not an owner ruling. Wiring these in is a reasonable
98
- // follow-up.
99
- const OPS = [
100
- 'parseToDatasetJson',
101
- 'queryDataset',
102
- 'updateDataset',
103
- 'serializeNQuads',
104
- 'serializeTurtle',
105
- 'canonicalizeToNQuads',
106
- 'owlClosure',
107
- 'owlIsConsistent',
108
- 'owlEntails',
109
- 'rhoDfClosure',
110
- 'rhoDfFragmentCheck',
111
- 'rdfsPlusClosure',
112
- 'clParse',
113
- 'clSerialize',
114
- 'clAlphaNorm',
115
- 'clNormalize',
116
- ];
117
-
118
- async function loadLeanEntry() {
119
- const eng = await l4.loadL4();
120
- if (typeof eng.call !== 'function') {
121
- throw new Error(
122
- 'factoidal/l4-core: the resolved Lean wasm module predates the ' +
123
- 'dispatch ABI (no call export); update @factoidal/lean or ' +
124
- 'FACTOIDAL_L4_ASSETS to a build with l4_call'
125
- );
126
- }
127
- const entry = { abiVersion: '1' };
128
- for (const op of OPS) {
129
- // lib/api.js's entryResult() takes the envelope as a JSON STRING
130
- // (entry_jsoo.ml's wire shape). The Lean loader's call() parses the
131
- // envelope and throws on {"ok":false}; re-encode both outcomes so
132
- // this entry object is wire-compatible with the F* one.
133
- entry[op] = (...args) => {
134
- try {
135
- return JSON.stringify(eng.call(op, args.map(String)));
136
- } catch (err) {
137
- return JSON.stringify({
138
- ok: false,
139
- error: String((err && err.message) || err),
140
- });
141
- }
142
- };
143
- }
144
- return entry;
145
- }
146
-
147
- const api = buildApi({
148
- engineName: 'l4',
149
- loadEntry: loadLeanEntry,
150
- runCli: async () => ({ exitCode: 1, stdout: '', stderr: NOT_SUPPORTED }),
151
- });
152
-
153
- module.exports = {
154
- parse: api.parse,
155
- query: api.query,
156
- update: api.update,
157
- serialize: api.serialize,
158
- canonicalize: api.canonicalize,
159
- graphs: api.graphs,
160
- canonicalHash: api.canonicalHash,
161
- owlClosure: api.owlClosure,
162
- coreRdfsClosure: api.coreRdfsClosure,
163
- coreRdfsCheck: api.coreRdfsCheck,
164
- rhoDfClosure: api.rhoDfClosure,
165
- rhoDfFragmentCheck: api.rhoDfFragmentCheck,
166
- rdfsPlusClosure: api.rdfsPlusClosure,
167
- // Lean-only: formal/fstar has no CL/IKL parser, so these are NOT
168
- // exported from index.js/wasm.js. See the OPS comment above.
169
- clParse: api.clParse,
170
- clSerialize: api.clSerialize,
171
- clAlphaNorm: api.clAlphaNorm,
172
- clNormalize: api.clNormalize,
173
- // Served by the Lean engine's dispatch ABI when the resolved wasm
174
- // carries the ops (see the header note).
175
- owlIsConsistent: api.owlIsConsistent,
176
- owlEntails: api.owlEntails,
177
- // Not implemented by this engine — kept on the surface so a caller
178
- // swapping engines gets the pinned capability error, not
179
- // `undefined is not a function`.
180
- shaclValidate: api.shaclValidate,
181
- shexValidate: api.shexValidate,
182
- capabilities: api.capabilities,
183
- Dataset: rdfjs.Dataset,
184
- dataFactory: rdfjs.dataFactory,
185
- engine: 'lean4-wasm',
186
- available: l4.available,
187
- version: pkg.version,
188
- };
package/l4.d.ts DELETED
@@ -1,50 +0,0 @@
1
- // TypeScript declarations for factoidal/l4 — the Lean 4 (L4Factoidal)
2
- // engine compiled to WebAssembly, bundled in this package's l4-assets/
3
- // since issue #618. See l4.js for the asset-resolution ladder and
4
- // docs/designissues/2026-08-22-npm-l4-module-packaging.md for why the
5
- // wasm was split out originally and why that no longer applies.
6
-
7
- /** A term in SPARQL Query Results JSON shape, plus `var` for patterns. */
8
- export interface L4Term {
9
- type: 'uri' | 'literal' | 'bnode' | 'var';
10
- value: string;
11
- datatype?: string;
12
- 'xml:lang'?: string;
13
- }
14
-
15
- export interface L4Triple {
16
- subject: L4Term;
17
- predicate: L4Term;
18
- object: L4Term;
19
- }
20
-
21
- /** SPARQL 1.1 Query Results JSON document. */
22
- export interface L4ResultsDoc {
23
- head: { vars: string[] };
24
- results: { bindings: Array<Record<string, L4Term>> };
25
- }
26
-
27
- /** Result of the narrow canonical-block predicate scan. */
28
- export interface L4IBK2PredicateScan {
29
- rows: number;
30
- ntriples: string;
31
- }
32
-
33
- /** Result of a source-scoped current IBK3 predicate scan. */
34
- export interface L4IBK3PredicateScan extends L4IBK2PredicateScan {
35
- format: 'IBK3';
36
- blankNodeScope: string;
37
- }
38
-
39
- export interface L4Engine {
40
- version(): string;
41
- bgpQuery(triples: L4Triple[], bgp: L4Triple[]): Promise<L4ResultsDoc> | L4ResultsDoc;
42
- }
43
-
44
- export const engine: 'lean4-wasm';
45
- export function available(): boolean;
46
- export function loadL4(): Promise<L4Engine>;
47
- export function version(): Promise<string>;
48
- export function bgpQuery(triples: L4Triple[], bgp: L4Triple[]): Promise<L4ResultsDoc>;
49
- export function scanIBK2Predicate(ibk2Hex: string, predicateIri: string): Promise<L4IBK2PredicateScan>;
50
- export function scanIBK3Predicate(ibk3Hex: string, predicateIri: string, blankNodeScope: string): Promise<L4IBK3PredicateScan>;
package/l4.js DELETED
@@ -1,104 +0,0 @@
1
- // factoidal/l4 — the Lean 4 engine (L4Factoidal compiled to wasm32)
2
- // behind the same package namespace as the F*-extracted engines.
3
- //
4
- // const l4 = require('factoidal/l4'); // or import('factoidal/l4')
5
- // await l4.version(); // "L4Factoidal ..."
6
- // await l4.bgpQuery(triples, bgp); // SPARQL results JSON
7
- //
8
- // BUNDLED since issue #618: `@factoidal/core` now ships the Lean wasm
9
- // directly under `l4-assets/` (l4factoidal.{js,mjs,wasm} + version.json
10
- // — l4-assets/version.json, not this package's own version.json, which
11
- // stays the F* engine's), so one `npm install @factoidal/core` gets
12
- // both engines. The +23%-tarball objection that shaped the earlier
13
- // companion-package split
14
- // (docs/designissues/2026-08-22-npm-l4-module-packaging.md) no longer
15
- // applies once measured against the real 21-op dispatch surface — see
16
- // that doc's "issue #618: option A after all" section for the full
17
- // argument. This module is now a resolver over FOUR sources, first hit
18
- // wins:
19
- //
20
- // 1. this package's own l4-assets/ (the normal case, since #618);
21
- // 2. the companion package `@factoidal/lean` (never published — kept
22
- // only as a manual-override path for anyone pinning an older
23
- // Lean build against a newer core; see npm/factoidal-lean/README.md);
24
- // 3. $FACTOIDAL_L4_ASSETS — a directory holding
25
- // l4factoidal.{js,mjs,wasm} (custom deployments);
26
- // 4. the repository checkout layout (docs/web/hub/assets/l4/) —
27
- // what the hub tests and in-repo development use.
28
- //
29
- // Every source's three files must stay together and keep their names:
30
- // the Emscripten glue resolves the .wasm sidecar from its own basename
31
- // (see skills/lean4-wasm-export, "the naming trap").
32
- //
33
- // API surface mirrors docs/web/hub/assets/l4/l4factoidal.js (phase-1
34
- // ABI: version + bgpQuery + narrow block scans). New exports appear here when they are
35
- // added to formal/lean4/Wasm/Exports.lean and the wasm is rebuilt.
36
-
37
- 'use strict';
38
-
39
- const { existsSync } = require('node:fs');
40
- const path = require('node:path');
41
- const { pathToFileURL } = require('node:url');
42
-
43
- function resolveLoader() {
44
- const inPkg = path.join(__dirname, 'l4-assets', 'l4factoidal.js');
45
- if (existsSync(inPkg)) return inPkg;
46
- try {
47
- return require.resolve('@factoidal/lean/l4factoidal.js');
48
- } catch { /* not installed */ }
49
- const env = process.env.FACTOIDAL_L4_ASSETS;
50
- if (env && existsSync(path.join(env, 'l4factoidal.js'))) {
51
- return path.join(env, 'l4factoidal.js');
52
- }
53
- const repo = path.join(__dirname, '..', '..', 'docs', 'web', 'hub', 'assets', 'l4', 'l4factoidal.js');
54
- if (existsSync(repo)) return repo;
55
- return null;
56
- }
57
-
58
- let l4Promise = null;
59
-
60
- async function loadL4() {
61
- if (l4Promise) return l4Promise;
62
- const loaderPath = resolveLoader();
63
- if (!loaderPath) {
64
- throw new Error(
65
- 'factoidal/l4: Lean engine assets not found. They normally ship in ' +
66
- "this package's own l4-assets/ directory — if it is missing, this " +
67
- 'checkout/install is incomplete. Otherwise set FACTOIDAL_L4_ASSETS ' +
68
- 'to a directory containing l4factoidal.js, l4factoidal.mjs and ' +
69
- 'l4factoidal.wasm, or install the (unpublished, override-only) ' +
70
- 'companion package @factoidal/lean.');
71
- }
72
- l4Promise = import(pathToFileURL(loaderPath).href).then((m) => m.loadL4());
73
- return l4Promise;
74
- }
75
-
76
- module.exports = {
77
- engine: 'lean4-wasm',
78
- /** True when the wasm assets are resolvable without loading them. */
79
- available: () => resolveLoader() !== null,
80
- /** Load (once) and return the low-level engine handle. */
81
- loadL4,
82
- /** Engine identification string from the Lean side. */
83
- version: async () => (await loadL4()).version(),
84
- /**
85
- * Evaluate a basic graph pattern over an in-memory triple list.
86
- * Arguments and result use SPARQL Query Results JSON term shapes;
87
- * see docs/web/hub/36-lean-in-the-browser.md for worked examples.
88
- */
89
- bgpQuery: async (triples, bgp) => (await loadL4()).bgpQuery(triples, bgp),
90
- /**
91
- * Validate a canonical IBK2 artifact and selectively scan one predicate.
92
- * `ibk2Hex` is a diagnostic transport; high-throughput users should use a
93
- * future bounded-buffer worker ABI rather than converting block bytes to hex.
94
- */
95
- scanIBK2Predicate: async (ibk2Hex, predicateIri) =>
96
- (await loadL4()).call('scanIBK2Predicate', [ibk2Hex, predicateIri]),
97
- /**
98
- * Validate and scan one current IBK3 artifact. `blankNodeScope` identifies
99
- * the RDF source/dataset import unit: reuse it across that unit's predicate
100
- * blocks, and never reuse it for an unrelated input document.
101
- */
102
- scanIBK3Predicate: async (ibk3Hex, predicateIri, blankNodeScope) =>
103
- (await loadL4()).call('scanIBK3Predicate', [ibk3Hex, predicateIri, blankNodeScope]),
104
- };