@hviana/sema 0.1.4 → 0.1.5

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 (122) hide show
  1. package/dist/example/demo.js +25 -25
  2. package/dist/example/train_base.d.ts +21 -19
  3. package/dist/example/train_base.js +1952 -1684
  4. package/dist/src/alphabet.d.ts +3 -3
  5. package/dist/src/alphabet.js +27 -24
  6. package/dist/src/alu/src/alu.d.ts +194 -169
  7. package/dist/src/alu/src/alu.js +414 -374
  8. package/dist/src/alu/src/expr.d.ts +43 -36
  9. package/dist/src/alu/src/expr.js +278 -252
  10. package/dist/src/alu/src/index.d.ts +98 -9
  11. package/dist/src/alu/src/index.js +63 -9
  12. package/dist/src/alu/src/kernel-arith.d.ts +5 -1
  13. package/dist/src/alu/src/kernel-arith.js +285 -195
  14. package/dist/src/alu/src/kernel-bits.d.ts +5 -1
  15. package/dist/src/alu/src/kernel-bits.js +115 -81
  16. package/dist/src/alu/src/kernel-logic.js +63 -33
  17. package/dist/src/alu/src/kernel-nd.js +195 -155
  18. package/dist/src/alu/src/kernel-numeric.d.ts +80 -16
  19. package/dist/src/alu/src/kernel-numeric.js +331 -259
  20. package/dist/src/alu/src/operation.d.ts +132 -112
  21. package/dist/src/alu/src/operation.js +163 -149
  22. package/dist/src/alu/src/parser.d.ts +175 -168
  23. package/dist/src/alu/src/parser.js +421 -382
  24. package/dist/src/alu/src/resonance.d.ts +25 -16
  25. package/dist/src/alu/src/resonance.js +56 -49
  26. package/dist/src/alu/src/text.d.ts +7 -3
  27. package/dist/src/alu/src/text.js +37 -31
  28. package/dist/src/alu/src/value.d.ts +14 -14
  29. package/dist/src/alu/src/value.js +160 -150
  30. package/dist/src/alu/test/alu.test.js +656 -543
  31. package/dist/src/bytes.d.ts +5 -1
  32. package/dist/src/bytes.js +40 -33
  33. package/dist/src/config.d.ts +102 -102
  34. package/dist/src/config.js +83 -83
  35. package/dist/src/derive/src/deduction.d.ts +62 -60
  36. package/dist/src/derive/src/deduction.js +109 -103
  37. package/dist/src/derive/src/index.d.ts +7 -1
  38. package/dist/src/derive/src/priority-queue.d.ts +8 -8
  39. package/dist/src/derive/src/priority-queue.js +61 -57
  40. package/dist/src/derive/src/rewrite.d.ts +18 -15
  41. package/dist/src/derive/src/rewrite.js +67 -59
  42. package/dist/src/derive/src/trie.d.ts +56 -56
  43. package/dist/src/derive/src/trie.js +179 -175
  44. package/dist/src/derive/test/derive.test.js +100 -96
  45. package/dist/src/extension.d.ts +16 -13
  46. package/dist/src/geometry.d.ts +42 -17
  47. package/dist/src/geometry.js +266 -235
  48. package/dist/src/index.d.ts +17 -2
  49. package/dist/src/index.js +7 -1
  50. package/dist/src/ingest-cache.d.ts +30 -25
  51. package/dist/src/ingest-cache.js +127 -108
  52. package/dist/src/mind/articulation.d.ts +5 -1
  53. package/dist/src/mind/articulation.js +112 -77
  54. package/dist/src/mind/attention.d.ts +108 -40
  55. package/dist/src/mind/attention.js +871 -749
  56. package/dist/src/mind/canonical.d.ts +19 -4
  57. package/dist/src/mind/canonical.js +31 -27
  58. package/dist/src/mind/graph-search.d.ts +225 -201
  59. package/dist/src/mind/graph-search.js +821 -742
  60. package/dist/src/mind/index.d.ts +10 -2
  61. package/dist/src/mind/junction.d.ts +58 -31
  62. package/dist/src/mind/junction.js +237 -172
  63. package/dist/src/mind/learning.d.ts +52 -16
  64. package/dist/src/mind/learning.js +165 -143
  65. package/dist/src/mind/match.d.ts +69 -20
  66. package/dist/src/mind/match.js +318 -259
  67. package/dist/src/mind/mechanisms/alu.js +16 -16
  68. package/dist/src/mind/mechanisms/cast.d.ts +13 -9
  69. package/dist/src/mind/mechanisms/cast.js +456 -363
  70. package/dist/src/mind/mechanisms/confluence.d.ts +12 -8
  71. package/dist/src/mind/mechanisms/confluence.js +183 -152
  72. package/dist/src/mind/mechanisms/cover.d.ts +8 -2
  73. package/dist/src/mind/mechanisms/cover.js +210 -148
  74. package/dist/src/mind/mechanisms/extraction.d.ts +34 -8
  75. package/dist/src/mind/mechanisms/extraction.js +288 -234
  76. package/dist/src/mind/mechanisms/recall.d.ts +10 -6
  77. package/dist/src/mind/mechanisms/recall.js +185 -126
  78. package/dist/src/mind/mind.d.ts +154 -129
  79. package/dist/src/mind/mind.js +288 -258
  80. package/dist/src/mind/pipeline-mechanism.d.ts +124 -112
  81. package/dist/src/mind/pipeline-mechanism.js +172 -161
  82. package/dist/src/mind/pipeline.d.ts +14 -4
  83. package/dist/src/mind/pipeline.js +189 -125
  84. package/dist/src/mind/primitives.d.ts +32 -8
  85. package/dist/src/mind/primitives.js +117 -99
  86. package/dist/src/mind/rationale.d.ts +98 -86
  87. package/dist/src/mind/rationale.js +121 -113
  88. package/dist/src/mind/reasoning.d.ts +13 -2
  89. package/dist/src/mind/reasoning.js +166 -129
  90. package/dist/src/mind/recognition.d.ts +4 -1
  91. package/dist/src/mind/recognition.js +208 -183
  92. package/dist/src/mind/resonance.d.ts +22 -5
  93. package/dist/src/mind/resonance.js +0 -0
  94. package/dist/src/mind/trace.d.ts +25 -6
  95. package/dist/src/mind/trace.js +58 -50
  96. package/dist/src/mind/traverse.d.ts +58 -16
  97. package/dist/src/mind/traverse.js +357 -304
  98. package/dist/src/mind/types.d.ts +127 -120
  99. package/dist/src/mind/types.js +69 -60
  100. package/dist/src/rabitq-hnsw/src/database.d.ts +179 -177
  101. package/dist/src/rabitq-hnsw/src/database.js +359 -342
  102. package/dist/src/rabitq-hnsw/src/heap.d.ts +12 -12
  103. package/dist/src/rabitq-hnsw/src/heap.js +80 -75
  104. package/dist/src/rabitq-hnsw/src/hnsw.d.ts +103 -103
  105. package/dist/src/rabitq-hnsw/src/hnsw.js +454 -428
  106. package/dist/src/rabitq-hnsw/src/index.d.ts +6 -1
  107. package/dist/src/rabitq-hnsw/src/prng.d.ts +10 -10
  108. package/dist/src/rabitq-hnsw/src/prng.js +27 -25
  109. package/dist/src/rabitq-hnsw/src/rabitq.d.ts +69 -69
  110. package/dist/src/rabitq-hnsw/src/rabitq.js +262 -246
  111. package/dist/src/rabitq-hnsw/src/store.d.ts +132 -132
  112. package/dist/src/rabitq-hnsw/src/store.js +843 -752
  113. package/dist/src/rabitq-hnsw/test/hnsw.test.js +1054 -805
  114. package/dist/src/sema.d.ts +13 -9
  115. package/dist/src/sema.js +40 -26
  116. package/dist/src/store-sqlite.d.ts +166 -144
  117. package/dist/src/store-sqlite.js +660 -578
  118. package/dist/src/store.d.ts +630 -593
  119. package/dist/src/store.js +1581 -1440
  120. package/dist/src/vec.d.ts +9 -5
  121. package/dist/src/vec.js +73 -61
  122. package/package.json +2 -2
@@ -17,163 +17,225 @@ import { decodeText, unexplainedLabel } from "../rationale.js";
17
17
  import { rItem, rNode, traceDerivation } from "../trace.js";
18
18
  // ── Concept / connector pre-resolution ──────────────────────────────────────
19
19
  export async function resolveConcepts(ctx, sites) {
20
- const target = new Map();
21
- const visited = new Set();
22
- for (const { payload: n } of sites) {
23
- if (visited.has(n))
24
- continue;
25
- visited.add(n);
26
- if (ctx.store.hasNext(n))
27
- continue;
28
- const hop = await conceptHop(ctx, n);
29
- if (hop !== null)
30
- target.set(n, hop);
20
+ const target = new Map();
21
+ const visited = new Set();
22
+ for (const { payload: n } of sites) {
23
+ if (visited.has(n)) {
24
+ continue;
31
25
  }
32
- if (target.size > 0) {
33
- ctx.trace?.step("resolveConcepts", [...target.keys()].map((n) => rNode(ctx, n, "edgeless-form")), [...target.values()].map((h) => rNode(ctx, h, "concept-sibling")), "borrow a synonym's continuation edge for each edge-less form (a concept/halo hop)");
26
+ visited.add(n);
27
+ if (ctx.store.hasNext(n)) {
28
+ continue;
34
29
  }
35
- return target;
30
+ const hop = await conceptHop(ctx, n);
31
+ if (hop !== null) {
32
+ target.set(n, hop);
33
+ }
34
+ }
35
+ if (target.size > 0) {
36
+ ctx.trace?.step(
37
+ "resolveConcepts",
38
+ [...target.keys()].map((n) => rNode(ctx, n, "edgeless-form")),
39
+ [...target.values()].map((h) => rNode(ctx, h, "concept-sibling")),
40
+ "borrow a synonym's continuation edge for each edge-less form (a concept/halo hop)",
41
+ );
42
+ }
43
+ return target;
36
44
  }
37
45
  export async function resolveConnectors(ctx, sites) {
38
- const links = new Map();
39
- const ordered = [...sites].sort((a, b) => a.start - b.start);
40
- const answerOf = (n) => guidedFirst(ctx, n) ?? n;
41
- const bridgePair = async (l, r) => {
42
- if (l === r || links.has(l + "," + r))
43
- return;
44
- const link = await bridge(ctx, read(ctx, l), read(ctx, r));
45
- if (link !== null)
46
- links.set(l + "," + r, link);
47
- };
48
- for (let i = 0; i + 1 < ordered.length; i++) {
49
- if (ordered[i].end !== ordered[i + 1].start)
50
- continue;
51
- const lefts = [ordered[i].payload, answerOf(ordered[i].payload)];
52
- const rights = [ordered[i + 1].payload, answerOf(ordered[i + 1].payload)];
53
- for (const l of new Set(lefts)) {
54
- for (const r of new Set(rights)) {
55
- await bridgePair(l, r);
56
- await bridgePair(r, l);
57
- }
58
- }
46
+ const links = new Map();
47
+ const ordered = [...sites].sort((a, b) => a.start - b.start);
48
+ const answerOf = (n) => guidedFirst(ctx, n) ?? n;
49
+ const bridgePair = async (l, r) => {
50
+ if (l === r || links.has(l + "," + r)) {
51
+ return;
52
+ }
53
+ const link = await bridge(ctx, read(ctx, l), read(ctx, r));
54
+ if (link !== null) {
55
+ links.set(l + "," + r, link);
59
56
  }
60
- const orderedNodes = [];
61
- const seenN = new Set();
62
- for (const s of ordered) {
63
- const node = guidedFirst(ctx, s.payload) ?? s.payload;
64
- if (seenN.has(node))
65
- continue;
66
- seenN.add(node);
67
- orderedNodes.push({ node, bytes: read(ctx, node) });
57
+ };
58
+ for (let i = 0; i + 1 < ordered.length; i++) {
59
+ if (ordered[i].end !== ordered[i + 1].start) {
60
+ continue;
68
61
  }
69
- if (orderedNodes.length >= 3) {
70
- const first = orderedNodes[0];
71
- const W = ctx.space.maxGroup;
72
- let middleBytes = 0; // Σ bytes of the answers BETWEEN first and m-th
73
- for (let m = 1; m < orderedNodes.length; m++) {
74
- const key = first.node + "," + orderedNodes[m].node;
75
- if (links.has(key)) {
76
- middleBytes += orderedNodes[m].bytes.length;
77
- continue;
78
- }
79
- // The N-ary interior legitimately holds every intermediate answer
80
- // plus one W-quantum of glue per joint — pass that allowance so the
81
- // bridge's phrase-scale cap admits the whole learnt run.
82
- const allowance = middleBytes + (m + 1) * W;
83
- const interior = await bridge(ctx, first.bytes, orderedNodes[m].bytes, allowance);
84
- if (interior !== null)
85
- links.set(key, interior);
86
- middleBytes += orderedNodes[m].bytes.length;
87
- }
62
+ const lefts = [ordered[i].payload, answerOf(ordered[i].payload)];
63
+ const rights = [ordered[i + 1].payload, answerOf(ordered[i + 1].payload)];
64
+ for (const l of new Set(lefts)) {
65
+ for (const r of new Set(rights)) {
66
+ await bridgePair(l, r);
67
+ await bridgePair(r, l);
68
+ }
88
69
  }
89
- if (links.size > 0) {
90
- ctx.trace?.step("resolveConnectors", ordered.map((s) => rItem(read(ctx, s.payload), "answer", s.payload)), [...links.entries()].map(([pair, bytes]) => ({
91
- text: `${pair}: "${decodeText(bytes)}"`,
92
- role: "connector",
93
- })), "the bytes the graph splices between adjacent answers (asked of the gist space)");
70
+ }
71
+ const orderedNodes = [];
72
+ const seenN = new Set();
73
+ for (const s of ordered) {
74
+ const node = guidedFirst(ctx, s.payload) ?? s.payload;
75
+ if (seenN.has(node)) {
76
+ continue;
94
77
  }
95
- return links;
78
+ seenN.add(node);
79
+ orderedNodes.push({ node, bytes: read(ctx, node) });
80
+ }
81
+ if (orderedNodes.length >= 3) {
82
+ const first = orderedNodes[0];
83
+ const W = ctx.space.maxGroup;
84
+ let middleBytes = 0; // Σ bytes of the answers BETWEEN first and m-th
85
+ for (let m = 1; m < orderedNodes.length; m++) {
86
+ const key = first.node + "," + orderedNodes[m].node;
87
+ if (links.has(key)) {
88
+ middleBytes += orderedNodes[m].bytes.length;
89
+ continue;
90
+ }
91
+ // The N-ary interior legitimately holds every intermediate answer
92
+ // plus one W-quantum of glue per joint — pass that allowance so the
93
+ // bridge's phrase-scale cap admits the whole learnt run.
94
+ const allowance = middleBytes + (m + 1) * W;
95
+ const interior = await bridge(
96
+ ctx,
97
+ first.bytes,
98
+ orderedNodes[m].bytes,
99
+ allowance,
100
+ );
101
+ if (interior !== null) {
102
+ links.set(key, interior);
103
+ }
104
+ middleBytes += orderedNodes[m].bytes.length;
105
+ }
106
+ }
107
+ if (links.size > 0) {
108
+ ctx.trace?.step(
109
+ "resolveConnectors",
110
+ ordered.map((s) => rItem(read(ctx, s.payload), "answer", s.payload)),
111
+ [...links.entries()].map(([pair, bytes]) => ({
112
+ text: `${pair}: "${decodeText(bytes)}"`,
113
+ role: "connector",
114
+ })),
115
+ "the bytes the graph splices between adjacent answers (asked of the gist space)",
116
+ );
117
+ }
118
+ return links;
96
119
  }
97
120
  // ── Pipeline mechanism ──────────────────────────────────────────────────────
98
121
  export const coverMechanism = {
99
- name: "cover",
100
- provenance: "cover",
101
- async floor(_ctx, _query, _pre, _worthRunning) {
102
- return 0;
103
- },
104
- async run(ctx, query, pre) {
105
- const { rec, computed } = pre;
106
- // Masking: computed spans are authoritative. Remove recognised sites
107
- // that overlap any computed span before building the cover search.
108
- const sites = computed.length === 0
109
- ? rec.sites
110
- : rec.sites.filter((s) => !computed.some((u) => s.start < u.j && u.i < s.end));
111
- if (computed.length > 0 && sites.length < rec.sites.length) {
112
- ctx.trace?.step("maskByComputation", rec.sites.map((s) => rItem(query.subarray(s.start, s.end), "form", s.payload, [
113
- s.start,
114
- s.end,
115
- ])), sites.map((s) => rItem(query.subarray(s.start, s.end), "form", s.payload, [
116
- s.start,
117
- s.end,
118
- ])), "a computation always wins: recognised forms overlapping a computed span are dropped");
119
- }
120
- if (sites.length === 0 && computed.length === 0)
121
- return [];
122
- const connectors = await resolveConnectors(ctx, sites);
123
- let splits = rec.splits;
124
- if (computed.length > 0) {
125
- splits = new Set(rec.splits);
126
- for (const u of computed) {
127
- splits.add(u.i);
128
- splits.add(u.j);
129
- }
130
- }
131
- const concepts = await resolveConcepts(ctx, sites);
132
- const coverDeps = [
133
- ctx.trace?.lastIndex("recognise"),
134
- ctx.trace?.lastIndex("computeExtensions"),
135
- ctx.trace?.lastIndex("resolveConcepts"),
136
- ctx.trace?.lastIndex("resolveConnectors"),
137
- ].filter((x) => x !== undefined);
138
- // Convert ComputedSpan[] to ComputedResult[] for the graph search.
139
- const computedResults = computed.map((u) => ({
140
- i: u.i,
141
- j: u.j,
142
- bytes: u.bytes,
143
- node: resolve(ctx, u.bytes) ?? undefined,
144
- }));
145
- const tCover = ctx.trace?.enter("cover", [
146
- ...sites.map((s) => rItem(query.subarray(s.start, s.end), "form", s.payload, [
147
- s.start,
148
- s.end,
149
- ])),
150
- ...computedResults.map((u) => rItem(u.bytes, "computed")),
151
- ], coverDeps.length ? coverDeps : undefined);
152
- const solved = ctx.search.cover(query.length, sites, concepts, rec.leaves, splits, undefined, connectors, computedResults, ctx.trace ? (steps) => traceDerivation(ctx, steps) : undefined);
153
- const segs = solved && solved.segs;
154
- tCover?.done(segs === null
155
- ? []
156
- : segs.map((s) => rItem(s.bytes, s.rec ? "chosen" : "bridge", s.node, [s.i, s.j])), segs === null
157
- ? "no cover of the query composed"
158
- : "lightest derivation: the chosen spans, left to right");
159
- if (segs === null)
160
- return [];
161
- const composed = liftAnswer(segs, query.length);
162
- if (composed === null)
163
- return [];
164
- ctx.trace?.step("liftAnswer", segs.map((s) => rItem(s.bytes, s.rec ? "chosen" : "scaffolding", s.node, [s.i, s.j])), [rItem(composed, "answer", resolve(ctx, composed) ?? undefined)], "lift the recognised region out of the asker's framing", tCover ? [tCover.index] : undefined);
165
- // accounted = RECOGNISED cover spans only — PASS-carried bytes
166
- // are priced in cost already; the diagnostic label reflects the
167
- // same distinction.
168
- const accounted = segs
169
- .filter((s) => s.rec)
170
- .map((s) => [s.i, s.j]);
171
- return [{
172
- bytes: composed,
173
- accounted,
174
- moves: 0,
175
- weight: solved.cost, // A*LD derivation's g-value IS the weight
176
- unexplained: unexplainedLabel(query, accounted),
177
- }];
178
- },
122
+ name: "cover",
123
+ provenance: "cover",
124
+ async floor(_ctx, _query, _pre, _worthRunning) {
125
+ return 0;
126
+ },
127
+ async run(ctx, query, pre) {
128
+ const { rec, computed } = pre;
129
+ // Masking: computed spans are authoritative. Remove recognised sites
130
+ // that overlap any computed span before building the cover search.
131
+ const sites = computed.length === 0
132
+ ? rec.sites
133
+ : rec.sites.filter((s) =>
134
+ !computed.some((u) => s.start < u.j && u.i < s.end)
135
+ );
136
+ if (computed.length > 0 && sites.length < rec.sites.length) {
137
+ ctx.trace?.step(
138
+ "maskByComputation",
139
+ rec.sites.map((s) =>
140
+ rItem(query.subarray(s.start, s.end), "form", s.payload, [
141
+ s.start,
142
+ s.end,
143
+ ])
144
+ ),
145
+ sites.map((s) =>
146
+ rItem(query.subarray(s.start, s.end), "form", s.payload, [
147
+ s.start,
148
+ s.end,
149
+ ])
150
+ ),
151
+ "a computation always wins: recognised forms overlapping a computed span are dropped",
152
+ );
153
+ }
154
+ if (sites.length === 0 && computed.length === 0) {
155
+ return [];
156
+ }
157
+ const connectors = await resolveConnectors(ctx, sites);
158
+ let splits = rec.splits;
159
+ if (computed.length > 0) {
160
+ splits = new Set(rec.splits);
161
+ for (const u of computed) {
162
+ splits.add(u.i);
163
+ splits.add(u.j);
164
+ }
165
+ }
166
+ const concepts = await resolveConcepts(ctx, sites);
167
+ const coverDeps = [
168
+ ctx.trace?.lastIndex("recognise"),
169
+ ctx.trace?.lastIndex("computeExtensions"),
170
+ ctx.trace?.lastIndex("resolveConcepts"),
171
+ ctx.trace?.lastIndex("resolveConnectors"),
172
+ ].filter((x) => x !== undefined);
173
+ // Convert ComputedSpan[] to ComputedResult[] for the graph search.
174
+ const computedResults = computed.map((u) => ({
175
+ i: u.i,
176
+ j: u.j,
177
+ bytes: u.bytes,
178
+ node: resolve(ctx, u.bytes) ?? undefined,
179
+ }));
180
+ const tCover = ctx.trace?.enter("cover", [
181
+ ...sites.map((s) =>
182
+ rItem(query.subarray(s.start, s.end), "form", s.payload, [
183
+ s.start,
184
+ s.end,
185
+ ])
186
+ ),
187
+ ...computedResults.map((u) => rItem(u.bytes, "computed")),
188
+ ], coverDeps.length ? coverDeps : undefined);
189
+ const solved = ctx.search.cover(
190
+ query.length,
191
+ sites,
192
+ concepts,
193
+ rec.leaves,
194
+ splits,
195
+ undefined,
196
+ connectors,
197
+ computedResults,
198
+ ctx.trace ? (steps) => traceDerivation(ctx, steps) : undefined,
199
+ );
200
+ const segs = solved && solved.segs;
201
+ tCover?.done(
202
+ segs === null
203
+ ? []
204
+ : segs.map((s) =>
205
+ rItem(s.bytes, s.rec ? "chosen" : "bridge", s.node, [s.i, s.j])
206
+ ),
207
+ segs === null
208
+ ? "no cover of the query composed"
209
+ : "lightest derivation: the chosen spans, left to right",
210
+ );
211
+ if (segs === null) {
212
+ return [];
213
+ }
214
+ const composed = liftAnswer(segs, query.length);
215
+ if (composed === null) {
216
+ return [];
217
+ }
218
+ ctx.trace?.step(
219
+ "liftAnswer",
220
+ segs.map((s) =>
221
+ rItem(s.bytes, s.rec ? "chosen" : "scaffolding", s.node, [s.i, s.j])
222
+ ),
223
+ [rItem(composed, "answer", resolve(ctx, composed) ?? undefined)],
224
+ "lift the recognised region out of the asker's framing",
225
+ tCover ? [tCover.index] : undefined,
226
+ );
227
+ // accounted = RECOGNISED cover spans only — PASS-carried bytes
228
+ // are priced in cost already; the diagnostic label reflects the
229
+ // same distinction.
230
+ const accounted = segs
231
+ .filter((s) => s.rec)
232
+ .map((s) => [s.i, s.j]);
233
+ return [{
234
+ bytes: composed,
235
+ accounted,
236
+ moves: 0,
237
+ weight: solved.cost, // A*LD derivation's g-value IS the weight
238
+ unexplained: unexplainedLabel(query, accounted),
239
+ }];
240
+ },
179
241
  };
@@ -17,29 +17,47 @@ import type { PipelineMechanism, Precomputed } from "../pipeline-mechanism.js";
17
17
  * explained for one mechanism and not the other, and the asymmetry, not
18
18
  * the answers' merits, decided the grounding.) Null when no skill
19
19
  * applies. */
20
- export declare function extractBySkill(ctx: MindContext, query: Uint8Array, pre: Precomputed): Promise<{
20
+ export declare function extractBySkill(
21
+ ctx: MindContext,
22
+ query: Uint8Array,
23
+ pre: Precomputed,
24
+ ): Promise<
25
+ {
21
26
  bytes: Uint8Array;
22
27
  accounted: Array<[number, number]>;
23
28
  unexplained: string;
24
- } | null>;
29
+ } | null
30
+ >;
25
31
  /** Decompose an answer into substrings of its surrounding context, in order —
26
32
  * the STRONG span-shape reading (see the section note above). Returns null
27
33
  * when no greedy longest-run decomposition exists. Adjacent runs that
28
34
  * connect contiguously are merged. */
29
- export declare function answerRunsInContext(_ctx: MindContext, context: Uint8Array, answer: Uint8Array): Array<{
35
+ export declare function answerRunsInContext(
36
+ _ctx: MindContext,
37
+ context: Uint8Array,
38
+ answer: Uint8Array,
39
+ ):
40
+ | Array<{
30
41
  start: number;
31
42
  end: number;
32
43
  ansLen: number;
33
- }> | null;
44
+ }>
45
+ | null;
34
46
  /** Check whether an anchor is a span-shaped skill exemplar: it represents a
35
47
  * fact whose context and answer together form a span-in-context pattern.
36
48
  * If the anchor has a nextOf continuation, that is the answer and the anchor
37
49
  * itself is the context. Otherwise the anchor's prevOf parents provide
38
50
  * candidate contexts, and the longest one whose span is span-shaped wins. */
39
- export declare function skillExemplar(ctx: MindContext, anchor: number, guide?: Vec | null): Promise<{
51
+ export declare function skillExemplar(
52
+ ctx: MindContext,
53
+ anchor: number,
54
+ guide?: Vec | null,
55
+ ): Promise<
56
+ {
40
57
  contextBytes: Uint8Array;
41
58
  answerBytes: Uint8Array;
42
- } | null>;
59
+ } | null
60
+ >;
43
61
  /** Whether the answer is a SPARSE subsequence of the context (bytes in
44
62
  * order, arbitrary gaps) — the OPEN span-shape reading (see the section
45
63
  * note above). This is what lets extraction validate a MULTI-PIECE
@@ -54,7 +72,11 @@ export declare function skillExemplar(ctx: MindContext, anchor: number, guide?:
54
72
  * with the same truth value. The old pre-check re-perceived the context
55
73
  * (a full river fold) per CANDIDATE in skillExemplar's √N-capped loop —
56
74
  * pure cost, no discrimination. */
57
- export declare function isSpanShaped(_ctx: MindContext, context: Uint8Array, answer: Uint8Array): boolean;
75
+ export declare function isSpanShaped(
76
+ _ctx: MindContext,
77
+ context: Uint8Array,
78
+ answer: Uint8Array,
79
+ ): boolean;
58
80
  /** STRICT containment: the answer's resolved node appears in the context's
59
81
  * folded tree, or the answer occurs as one CONTIGUOUS byte run of the
60
82
  * context. This is real evidence the answer was drawn from the context.
@@ -63,5 +85,9 @@ export declare function isSpanShaped(_ctx: MindContext, context: Uint8Array, ans
63
85
  * queries ("cold" is a gap-tolerant subsequence of most sentences holding
64
86
  * c…o…l…d in order), and gating fusion on it silently starved multi-topic
65
87
  * queries of their further points of attention. */
66
- export declare function containsSpan(ctx: MindContext, context: Uint8Array, answer: Uint8Array): boolean;
88
+ export declare function containsSpan(
89
+ ctx: MindContext,
90
+ context: Uint8Array,
91
+ answer: Uint8Array,
92
+ ): boolean;
67
93
  export declare const extractionMechanism: PipelineMechanism;