@hviana/sema 0.5.2 → 0.5.4

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 (157) hide show
  1. package/AGENTS.md +115 -53
  2. package/HOW_IT_WORKS.md +291 -184
  3. package/jsr.json +6 -0
  4. package/package.json +1 -1
  5. package/src/mind/bridge.ts +10 -104
  6. package/src/mind/match.ts +497 -7
  7. package/src/mind/{prefix-completion.ts → mechanisms/prefix-completion.ts} +66 -92
  8. package/src/mind/mechanisms/recall.ts +38 -129
  9. package/src/mind/mechanisms/reference.ts +343 -0
  10. package/src/mind/mind.ts +12 -8
  11. package/src/mind/pipeline-mechanism.ts +120 -3
  12. package/src/mind/pipeline.ts +16 -2
  13. package/src/mind/traverse.ts +92 -1
  14. package/src/store.ts +13 -4
  15. package/test/33-multi-candidate.test.mjs +21 -11
  16. package/test/70-prefix-completion.test.mjs +1 -1
  17. package/test/72-prefix-candidate-supply.test.mjs +7 -9
  18. package/test/74-prefix-trap-not-sprung-early.test.mjs +1 -1
  19. package/test/76-reference-binding.test.mjs +543 -0
  20. package/dist/example/demo.d.ts +0 -1
  21. package/dist/example/demo.js +0 -39
  22. package/dist/example/train_base.d.ts +0 -93
  23. package/dist/example/train_base.js +0 -2269
  24. package/dist/src/alphabet.d.ts +0 -7
  25. package/dist/src/alphabet.js +0 -33
  26. package/dist/src/alu/src/alu.d.ts +0 -185
  27. package/dist/src/alu/src/alu.js +0 -440
  28. package/dist/src/alu/src/expr.d.ts +0 -61
  29. package/dist/src/alu/src/expr.js +0 -318
  30. package/dist/src/alu/src/index.d.ts +0 -11
  31. package/dist/src/alu/src/index.js +0 -19
  32. package/dist/src/alu/src/kernel-arith.d.ts +0 -16
  33. package/dist/src/alu/src/kernel-arith.js +0 -264
  34. package/dist/src/alu/src/kernel-bits.d.ts +0 -19
  35. package/dist/src/alu/src/kernel-bits.js +0 -152
  36. package/dist/src/alu/src/kernel-logic.d.ts +0 -4
  37. package/dist/src/alu/src/kernel-logic.js +0 -60
  38. package/dist/src/alu/src/kernel-nd.d.ts +0 -3
  39. package/dist/src/alu/src/kernel-nd.js +0 -208
  40. package/dist/src/alu/src/kernel-numeric.d.ts +0 -54
  41. package/dist/src/alu/src/kernel-numeric.js +0 -366
  42. package/dist/src/alu/src/operation.d.ts +0 -168
  43. package/dist/src/alu/src/operation.js +0 -189
  44. package/dist/src/alu/src/parser.d.ts +0 -221
  45. package/dist/src/alu/src/parser.js +0 -577
  46. package/dist/src/alu/src/resonance.d.ts +0 -55
  47. package/dist/src/alu/src/resonance.js +0 -126
  48. package/dist/src/alu/src/text.d.ts +0 -31
  49. package/dist/src/alu/src/text.js +0 -73
  50. package/dist/src/alu/src/value.d.ts +0 -109
  51. package/dist/src/alu/src/value.js +0 -300
  52. package/dist/src/alu/test/alu.test.d.ts +0 -1
  53. package/dist/src/alu/test/alu.test.js +0 -764
  54. package/dist/src/bytes.d.ts +0 -14
  55. package/dist/src/bytes.js +0 -59
  56. package/dist/src/canon.d.ts +0 -45
  57. package/dist/src/canon.js +0 -85
  58. package/dist/src/config.d.ts +0 -111
  59. package/dist/src/config.js +0 -91
  60. package/dist/src/derive/src/deduction.d.ts +0 -136
  61. package/dist/src/derive/src/deduction.js +0 -159
  62. package/dist/src/derive/src/index.d.ts +0 -8
  63. package/dist/src/derive/src/index.js +0 -11
  64. package/dist/src/derive/src/priority-queue.d.ts +0 -20
  65. package/dist/src/derive/src/priority-queue.js +0 -73
  66. package/dist/src/derive/src/rewrite.d.ts +0 -56
  67. package/dist/src/derive/src/rewrite.js +0 -100
  68. package/dist/src/derive/src/trie.d.ts +0 -90
  69. package/dist/src/derive/src/trie.js +0 -217
  70. package/dist/src/derive/test/derive.test.d.ts +0 -1
  71. package/dist/src/derive/test/derive.test.js +0 -122
  72. package/dist/src/extension.d.ts +0 -37
  73. package/dist/src/extension.js +0 -7
  74. package/dist/src/geometry.d.ts +0 -233
  75. package/dist/src/geometry.js +0 -1089
  76. package/dist/src/index.d.ts +0 -17
  77. package/dist/src/index.js +0 -19
  78. package/dist/src/ingest-cache.d.ts +0 -41
  79. package/dist/src/ingest-cache.js +0 -165
  80. package/dist/src/meter.d.ts +0 -176
  81. package/dist/src/meter.js +0 -274
  82. package/dist/src/mind/articulation.d.ts +0 -6
  83. package/dist/src/mind/articulation.js +0 -99
  84. package/dist/src/mind/attention.d.ts +0 -430
  85. package/dist/src/mind/attention.js +0 -2418
  86. package/dist/src/mind/bridge.d.ts +0 -39
  87. package/dist/src/mind/bridge.js +0 -998
  88. package/dist/src/mind/canonical.d.ts +0 -34
  89. package/dist/src/mind/canonical.js +0 -93
  90. package/dist/src/mind/frame-filler.d.ts +0 -15
  91. package/dist/src/mind/frame-filler.js +0 -535
  92. package/dist/src/mind/graph-search.d.ts +0 -294
  93. package/dist/src/mind/graph-search.js +0 -996
  94. package/dist/src/mind/index.d.ts +0 -9
  95. package/dist/src/mind/index.js +0 -5
  96. package/dist/src/mind/junction.d.ts +0 -137
  97. package/dist/src/mind/junction.js +0 -358
  98. package/dist/src/mind/learning.d.ts +0 -75
  99. package/dist/src/mind/learning.js +0 -265
  100. package/dist/src/mind/match.d.ts +0 -192
  101. package/dist/src/mind/match.js +0 -666
  102. package/dist/src/mind/mechanisms/alu.d.ts +0 -4
  103. package/dist/src/mind/mechanisms/alu.js +0 -36
  104. package/dist/src/mind/mechanisms/cast.d.ts +0 -89
  105. package/dist/src/mind/mechanisms/cast.js +0 -1186
  106. package/dist/src/mind/mechanisms/confluence.d.ts +0 -24
  107. package/dist/src/mind/mechanisms/confluence.js +0 -271
  108. package/dist/src/mind/mechanisms/cover.d.ts +0 -6
  109. package/dist/src/mind/mechanisms/cover.js +0 -232
  110. package/dist/src/mind/mechanisms/extraction.d.ts +0 -33
  111. package/dist/src/mind/mechanisms/extraction.js +0 -327
  112. package/dist/src/mind/mechanisms/recall.d.ts +0 -16
  113. package/dist/src/mind/mechanisms/recall.js +0 -558
  114. package/dist/src/mind/mind.d.ts +0 -386
  115. package/dist/src/mind/mind.js +0 -754
  116. package/dist/src/mind/pipeline-mechanism.d.ts +0 -183
  117. package/dist/src/mind/pipeline-mechanism.js +0 -521
  118. package/dist/src/mind/pipeline.d.ts +0 -49
  119. package/dist/src/mind/pipeline.js +0 -331
  120. package/dist/src/mind/prefix-completion.d.ts +0 -59
  121. package/dist/src/mind/prefix-completion.js +0 -270
  122. package/dist/src/mind/primitives.d.ts +0 -85
  123. package/dist/src/mind/primitives.js +0 -333
  124. package/dist/src/mind/rationale.d.ts +0 -139
  125. package/dist/src/mind/rationale.js +0 -163
  126. package/dist/src/mind/reasoning.d.ts +0 -42
  127. package/dist/src/mind/reasoning.js +0 -305
  128. package/dist/src/mind/recognition.d.ts +0 -20
  129. package/dist/src/mind/recognition.js +0 -696
  130. package/dist/src/mind/resonance.d.ts +0 -35
  131. package/dist/src/mind/resonance.js +0 -365
  132. package/dist/src/mind/trace.d.ts +0 -15
  133. package/dist/src/mind/trace.js +0 -73
  134. package/dist/src/mind/traverse.d.ts +0 -158
  135. package/dist/src/mind/traverse.js +0 -716
  136. package/dist/src/mind/types.d.ts +0 -418
  137. package/dist/src/mind/types.js +0 -179
  138. package/dist/src/rabitq-ivf/src/database.d.ts +0 -113
  139. package/dist/src/rabitq-ivf/src/database.js +0 -201
  140. package/dist/src/rabitq-ivf/src/index.d.ts +0 -7
  141. package/dist/src/rabitq-ivf/src/index.js +0 -4
  142. package/dist/src/rabitq-ivf/src/ivf.d.ts +0 -200
  143. package/dist/src/rabitq-ivf/src/ivf.js +0 -1165
  144. package/dist/src/rabitq-ivf/src/prng.d.ts +0 -19
  145. package/dist/src/rabitq-ivf/src/prng.js +0 -36
  146. package/dist/src/rabitq-ivf/src/rabitq.d.ts +0 -95
  147. package/dist/src/rabitq-ivf/src/rabitq.js +0 -313
  148. package/dist/src/sema.d.ts +0 -41
  149. package/dist/src/sema.js +0 -77
  150. package/dist/src/store-sqlite.d.ts +0 -184
  151. package/dist/src/store-sqlite.js +0 -942
  152. package/dist/src/store.d.ts +0 -762
  153. package/dist/src/store.js +0 -1823
  154. package/dist/src/vec.d.ts +0 -31
  155. package/dist/src/vec.js +0 -109
  156. package/src/mind/frame-filler.ts +0 -604
  157. package/test/69-frame-filler.test.mjs +0 -115
@@ -1,294 +0,0 @@
1
- import type { Store } from "../store.js";
2
- import type { GraphSearchHost } from "./types.js";
3
- /** A recognised form: a span of the query that names a node already in the
4
- * store. `payload` is that node id. */
5
- export interface Site {
6
- start: number;
7
- end: number;
8
- payload: number;
9
- }
10
- /** A perceived leaf of the query tree, carrying the node id it resolves to. */
11
- export interface Leaf {
12
- start: number;
13
- end: number;
14
- bytes: Uint8Array;
15
- node: number | null;
16
- }
17
- /** A COMPUTED span: the result of applying a manual rule (an extension's
18
- * operation — e.g. the `alu` extension's arithmetic) to a recognised stretch
19
- * of the query. Every
20
- * bit of the intelligence — recognising the operator (literally or by
21
- * resonance), parsing the operands, evaluating the operation — is done by the
22
- * caller (src/mind/pipeline.ts), which hands the search the finished result span; the search
23
- * treats it exactly like any other recognised completion (a learned fact that
24
- * happens to be computed rather than stored). `node` is the canonical id of
25
- * the result bytes when the store already holds them, else undefined. */
26
- export interface ComputedResult {
27
- i: number;
28
- j: number;
29
- bytes: Uint8Array;
30
- node?: number;
31
- }
32
- export type GItem = {
33
- kind: "cover";
34
- p: number;
35
- } | {
36
- kind: "form";
37
- i: number;
38
- j: number;
39
- node: number;
40
- via: boolean;
41
- /** Set when this form was born by RECOMPOSING rewritten parts into a deeper
42
- * learned whole (the fuse of ≥2 recognised completions that names an
43
- * edge-bearing node). Its onward continuation is charged at MICRO, not
44
- * STEP: once parts are recomposed into a learned form, following that form
45
- * to its grounded answer is the recomposition completing — so the
46
- * consolidated, more-explanatory reading wins over leaving the parts split.
47
- * See {@link GraphSearch.fuse} and {@link GraphSearch.formRules}. */
48
- rcmp?: boolean;
49
- } | {
50
- kind: "out";
51
- i: number;
52
- j: number;
53
- bytes: Uint8Array;
54
- cover: boolean;
55
- rec: boolean;
56
- node?: number;
57
- /** Set only for a {@link ComputedResult} axiom (an extension's derived
58
- * value, e.g. ALU arithmetic) — as opposed to a genuinely RECOGNISED
59
- * learned form. Both set `rec: true` (a computation bridges the cover
60
- * exactly like a learned terminal answer), but they mean different
61
- * things for `i..j`'s WIDTH: a recognised form's query-span width is
62
- * real evidence of how much of the query's meaning it accounts for
63
- * (liftAnswer's half-dominance framing decision); a computed span's
64
- * width is operand digit-count, uncorrelated with meaning ("1000 - 421"
65
- * is wider than "15 * 7" only because the numbers are bigger, not
66
- * because subtraction is more "the point" of its query). See
67
- * {@link liftAnswer}. */
68
- computed?: boolean;
69
- };
70
- export declare const STEP = 1;
71
- export declare const CONCEPT = 10;
72
- export declare const PASS = 1000;
73
- /** The cheapest local cost in the ladder: a recognised completion bridging into
74
- * the cover. Far below STEP, so connecting two recognised spans never disturbs
75
- * the ordering — and, being the minimum per-position cost, it is the per-byte
76
- * unit of the admissible search heuristic (see {@link GraphSearch.buildSearch}). */
77
- export declare const MICRO = 0.001;
78
- /** One chosen span of the cover, left to right. `node` is the graph node the
79
- * span resolved to (when known) — for a recognised completion it is the chain's
80
- * terminal node, the foothold the bridge walks edges from. */
81
- export interface Seg {
82
- i: number;
83
- j: number;
84
- bytes: Uint8Array;
85
- rec: boolean;
86
- node?: number;
87
- /** See the `computed` field of the "out" {@link GItem} — set only for an
88
- * extension's derived value, never a genuinely recognised learned form. */
89
- computed?: boolean;
90
- }
91
- /** One rule application inside the cover's lightest derivation — the FINEST
92
- * grain of Sema's core reasoning, one node of the adapted A*LD proof tree. `move`
93
- * names which deduction rule fired (the reasoning act); `premises` and
94
- * `conclusion` are the items it consumed and produced, each rendered as a
95
- * positioned, possibly-node-bearing span; `cost` is the rule's local weight
96
- * (STEP for a learned edge, CONCEPT for a synonym hop, 0 for a free fuse, …);
97
- * `order` is its post-order position so a tracer can replay the proof in the
98
- * order it was built (premises before conclusion). */
99
- export interface DerivationStep {
100
- order: number;
101
- move: DerivationMove;
102
- premises: DerivationItem[];
103
- conclusion: DerivationItem;
104
- cost: number;
105
- /** The `order`s of the steps that produced this one's premises — the EXACT
106
- * data-flow edges of the proof tree (a `bridge` names the `ground` whose
107
- * `out` it crossed and the earlier `cover` it extended). A premise that is
108
- * an axiom (a seed leaf/form/computed result, never a rule conclusion) has no
109
- * producer and contributes no edge, so this lists only the derived premises —
110
- * the finest dependency structure the inference holds. */
111
- producers: number[];
112
- }
113
- /** A premise or conclusion of a {@link DerivationStep}, flattened from a {@link
114
- * GItem} into the fields a rationale cares about. */
115
- export interface DerivationItem {
116
- kind: "cover" | "form" | "out";
117
- /** `[i, j)` span for a form/out; for a cover item, `[p, p]`. */
118
- span: [number, number];
119
- /** The bytes an `out` carries (the only item kind that holds output bytes). */
120
- bytes?: Uint8Array;
121
- /** The graph node a form/out resolves to, when known. */
122
- node?: number;
123
- }
124
- /** The reasoning act a derivation rule performs — the human name for which of
125
- * {@link GraphSearch}'s rules fired, recovered from the rule's premise/
126
- * conclusion shape (the rules carry no label, so this classifies by structure,
127
- * the single place that maps rule geometry to a name). */
128
- export type DerivationMove = "axiom" | "follow-edge" | "concept-hop" | "voice" | "ground" | "splice-connector" | "split" | "fuse" | "recompose" | "bridge" | "pool-vote" | "step";
129
- /** The lightest-derivation search over the Sema graph. One instance binds the
130
- * store, `maxGroup` (the fusible span ceiling), and the canonical
131
- * {@link resolve} callback; {@link cover} then solves one query. */
132
- export declare class GraphSearch {
133
- private readonly store;
134
- private readonly maxGroup;
135
- /** The host whose capabilities the search consults: resolve (canonical node
136
- * id of a byte span), recogniseSpan (content-addressed graph lookup for
137
- * recursive completion), and chooseNext (distributional-evidence edge
138
- * disambiguation when a recognised form has multiple continuations). */
139
- private readonly host;
140
- constructor(store: Store, maxGroup: number,
141
- /** The host whose capabilities the search consults: resolve (canonical node
142
- * id of a byte span), recogniseSpan (content-addressed graph lookup for
143
- * recursive completion), and chooseNext (distributional-evidence edge
144
- * disambiguation when a recognised form has multiple continuations). */
145
- host: GraphSearchHost);
146
- /** The hub bound √N (AGENTS §2.8) — the ONE fan-out cap, stated here
147
- * rather than imported from `traverse.ts` because this module is
148
- * deliberately host-based (it holds a bare Store, never a MindContext).
149
- * That is the same write/read-side duplication convention canonical.ts's
150
- * header documents: if the formula changes it must change in BOTH places.
151
- * It is stated ONCE per side, though — the expression used to be spelled
152
- * out at three call sites here, one of them inside a per-item rules
153
- * generator, and they had already drifted on the `Math.max(2, …)` floor. */
154
- private hubBound;
155
- /** Explore the Sema graph for the lightest cover of the query and return its
156
- * chosen spans left-to-right — WITH the derivation's total weight (the g
157
- * value of the goal item, in the exported cost ladder), which think's
158
- * grounding decider compares against the other mechanisms' candidates —
159
- * or null if the query cannot be covered.
160
- *
161
- * The search runs on the query's tree leaves, not flat bytes — leaf-level
162
- * cover axioms, recognised forms as graph entry points — and discovers
163
- * cross-leaf forms by fusing adjacent fragments on demand (the only
164
- * byte-processing it does, and only where a derivation needs it). When
165
- * `substitutions` is given, recognised forms emit substitute bytes directly
166
- * (cost 0) — articulation splicing the asker's wording in.
167
- *
168
- * Any learnt connector between two rewrites is spliced IN by the in-search
169
- * connector rule (see {@link outRules}), so the returned spans already carry
170
- * it — there is no post-pass. */
171
- cover(queryLen: number, sites: ReadonlyArray<Site>, conceptTarget: ReadonlyMap<number, number>, leaves: ReadonlyArray<Leaf>, splits: ReadonlySet<number>, starts: ReadonlySet<number>, substitutions?: ReadonlyMap<number, Uint8Array>, connectors?: ReadonlyMap<string, Uint8Array>, computedResults?: ReadonlyArray<ComputedResult>,
172
- /** When given, receives the lightest derivation's rule applications — the
173
- * full adapted A*LD proof tree as classified {@link DerivationStep}s — for the TOP
174
- * cover only (a recursive recompletion solves its own sub-cover and is not
175
- * reported here, to keep the trace one layer per think). Off by default,
176
- * so the search pays nothing when no one inspects. */
177
- onDerivation?: (steps: DerivationStep[]) => void): {
178
- segs: Seg[];
179
- cost: number;
180
- } | null;
181
- /** Build the deduction system for one span and return its lightest cover's
182
- * chosen spans — the SINGLE routine the query and every produced composite
183
- * run through. `recognition` carries the span's recognised forms; the query
184
- * brings its own (with pre-resolved concepts/connectors), a recursive
185
- * completion re-recognises the produced bytes (edge/fuse only).
186
- *
187
- * No depth limit governs nesting — convergence is INTRINSIC, exactly as in the
188
- * adapted A*LD chart and {@link completeForward}: a completion only recurses into a
189
- * node it has not already entered ({@link recompleteNode}'s cycle guard), and
190
- * the node ids are finite, so the recursion must terminate on its own. A
191
- * decomposition may therefore run as deep as the graph licenses — three
192
- * decomposes, two recomposes, any mix — and stops only when it reaches a node
193
- * that leads nowhere new, never at an arbitrary count. */
194
- private solve;
195
- /** The weighted deduction system the graph exploration solves (the four
196
- * reductions of adapted A*LD live in {@link lightestDerivation}; this only states the
197
- * items, axioms, goal, and rules — see {@link GItem} for the item kinds).
198
- *
199
- * Forms that span across leaves are discovered BY the rules, which fuse
200
- * adjacent fragments toward a known leaf (findLeaf) or branch (findBranch);
201
- * a completion fused with its neighbour may spell a deeper learned form the
202
- * flat probes can't name, recovered canonically by {@link resolve}. */
203
- private buildSearch;
204
- /** cover(p): the BRIDGE rule — extend the cover across any coverable out that
205
- * begins at p, stepping the frontier from p to that out's end.
206
- *
207
- * This is what links the rewritten parts of a multi-form answer. An out is
208
- * either a recognised completion (`rec`, free) or a literal span the query
209
- * carried between known forms — the connective: a space, comma, period,
210
- * newline, or any run of bytes that was never recognised. Bridging a literal
211
- * costs PASS per byte (so the search still prefers to recognise), but it is
212
- * the cheapest — indeed only — way to cross a gap that has no learned form,
213
- * and it KEEPS that connective in the cover chain, so the asker's own linking
214
- * material reappears when it still coheres ("ice, fire" → "cold, hot", not
215
- * "coldhot"). A recognised completion bridges for a tiny ε (1e-3, far below
216
- * STEP), so a single connected span beats two separate ones on coherence
217
- * without disturbing the cost ladder's ordering.
218
- *
219
- * Marks p finalised so the symmetric out-side bridge ({@link outRules}) can
220
- * fire for outs that arrive after their start position is covered. */
221
- private coverRules;
222
- /** The BRIDGE rule, built once for its two arrival orders (cover-first in
223
- * {@link coverRules}, out-first in {@link outRules}): ε for a recognised
224
- * completion; PASS per byte for a literal connective — kept in the cover
225
- * so the asker's own connector survives where it fits. ONE definition of
226
- * the cost expression, so the ladder's application cannot drift between
227
- * the two sides. */
228
- private bridgeRule;
229
- /** The connector-SPLICE rule for an oriented (l, r) pair, or null when the
230
- * pair does not qualify — the ONE body behind {@link outRules}' two
231
- * mirror loops (this-as-left over resolved right partners, this-as-right
232
- * over resolved left partners). Fires only when both sides are
233
- * recognised, r starts at or after l ends, and the gap between them is
234
- * empty or wholly recognised — never across the asker's own literal
235
- * separator. */
236
- private trySplice;
237
- /** form(i,j,node,via): follow the graph out of `node`, or (in articulation)
238
- * emit its substitute voice directly. */
239
- private formRules;
240
- /** Complete a node that an edge produced but that bears no further whole-edge,
241
- * by COVERING ITS OWN BYTES — the very same operation the top query runs.
242
- * Completion is not a special pass: a produced composite ("p1 p2") is just
243
- * another span to cover, and covering it re-applies recognition, edge-follow,
244
- * fusion and recomposition to discover that its parts continue (p1→R1, p2→R2)
245
- * and recompose into a deeper learnt form (→ FINAL). This is why a single
246
- * edge-target needs no bespoke logic — it routes back through {@link solve}.
247
- *
248
- * Re-recognition (not the node's tree children) is what surfaces the learnt
249
- * parts: content-defined chunking may cut "p1 p2" as "p1 p"|"2", so only
250
- * recognising the bytes recovers p1 and p2 as the forms the graph knows.
251
- *
252
- * The recovered answer is accepted only when it MOVED and names a LEARNT node
253
- * ({@link resolve}) — the graph itself gates against re-expanding a contained
254
- * form ("ice is cold" ⊅→ "ice is cold is cold").
255
- *
256
- * Termination is INTRINSIC, not a depth limit: a node already on the
257
- * completion stack ({@link recompleteOpen}) is not re-entered — a self-
258
- * referential recomposition is a cycle that can yield nothing new, so it
259
- * stops there, exactly as {@link completeForward} stops on a revisited edge.
260
- * Distinct node ids are finite and each finished completion is memoised, so a
261
- * legitimate chain runs as deep as the graph licenses and no further. */
262
- private recompleteNode;
263
- /** Per-cover memo of each produced node's completion (so the many terminal
264
- * outs of a long query re-cover each distinct node at most once); reset at the
265
- * top of {@link cover}. */
266
- private recompleteMemo;
267
- /** The nodes currently being re-completed — the recursion stack. A node in
268
- * this set is not re-entered, so a cyclic recomposition terminates naturally
269
- * (the same cycle guard {@link completeForward} uses), with no depth cap. */
270
- private recompleteOpen;
271
- /** out(i,j,bytes,…): index it for the binary rules, then offer splicing a
272
- * learnt connector (the in-search bridge), splitting (at a sub-leaf form
273
- * boundary), bridging (cover(i) ∧ this → cover(j)), and fusing with an
274
- * adjacent finalised out. */
275
- private outRules;
276
- /** Whether the query span [from, to) is wholly covered by RECOGNISED outs —
277
- * the test that lets a connector jump across INTERIOR answers (an N-ary whole)
278
- * but never across the asker's own unrecognised framing (a space or comma the
279
- * asker wrote between parts). Empty span (from === to, the adjacent case) is
280
- * trivially recognised. Otherwise step right-to-left: from `to`, find a
281
- * recognised out ending there and continue from its start, until reaching
282
- * `from`. Greedy-longest is sufficient here — the spans in play are the few
283
- * recognised answers of one query, not a general interval cover. */
284
- private gapRecognised;
285
- /** Fuse two adjacent finalised outs — the search's own discovery of forms
286
- * that cross leaf boundaries. The concatenation may be a known leaf
287
- * (findLeaf, when short enough), or — when both sides resolved — their pair a
288
- * known branch (findBranch); a completion fused with its neighbour may spell
289
- * a deeper learned form, recovered canonically by {@link resolve} (gated on a
290
- * completion being present, so it only runs along chains). The fused span
291
- * lives on as an intermediate out while it could still grow into a form, and
292
- * enters the graph as a form the moment it names a node. */
293
- private fuse;
294
- }