@hviana/sema 0.4.0 → 0.4.2

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 (154) hide show
  1. package/CONTRIBUTING.md +92 -10
  2. package/LICENSE.md +2 -2
  3. package/package.json +1 -1
  4. package/src/ingest-cache.ts +4 -0
  5. package/src/meter.ts +5 -0
  6. package/src/mind/attention.ts +18 -1
  7. package/src/mind/bridge.ts +292 -54
  8. package/src/mind/junction.ts +21 -7
  9. package/src/mind/match.ts +92 -1
  10. package/src/mind/mechanisms/cast.ts +12 -0
  11. package/src/mind/mechanisms/confluence.ts +30 -1
  12. package/src/mind/mechanisms/cover.ts +36 -4
  13. package/src/mind/mechanisms/recall.ts +21 -44
  14. package/src/mind/mind.ts +39 -2
  15. package/src/mind/pipeline-mechanism.ts +86 -4
  16. package/src/mind/pipeline.ts +1 -1
  17. package/src/mind/reasoning.ts +15 -8
  18. package/src/mind/recognition.ts +40 -0
  19. package/src/mind/resonance.ts +0 -0
  20. package/src/mind/traverse.ts +17 -15
  21. package/src/mind/types.ts +10 -0
  22. package/test/49-natural-units-synonym-bridge.test.mjs +56 -15
  23. package/dist/example/demo.d.ts +0 -1
  24. package/dist/example/demo.js +0 -39
  25. package/dist/example/train_base.d.ts +0 -87
  26. package/dist/example/train_base.js +0 -2252
  27. package/dist/src/alphabet.d.ts +0 -7
  28. package/dist/src/alphabet.js +0 -33
  29. package/dist/src/alu/src/alu.d.ts +0 -185
  30. package/dist/src/alu/src/alu.js +0 -440
  31. package/dist/src/alu/src/expr.d.ts +0 -61
  32. package/dist/src/alu/src/expr.js +0 -318
  33. package/dist/src/alu/src/index.d.ts +0 -11
  34. package/dist/src/alu/src/index.js +0 -19
  35. package/dist/src/alu/src/kernel-arith.d.ts +0 -16
  36. package/dist/src/alu/src/kernel-arith.js +0 -264
  37. package/dist/src/alu/src/kernel-bits.d.ts +0 -19
  38. package/dist/src/alu/src/kernel-bits.js +0 -152
  39. package/dist/src/alu/src/kernel-logic.d.ts +0 -4
  40. package/dist/src/alu/src/kernel-logic.js +0 -60
  41. package/dist/src/alu/src/kernel-nd.d.ts +0 -3
  42. package/dist/src/alu/src/kernel-nd.js +0 -208
  43. package/dist/src/alu/src/kernel-numeric.d.ts +0 -54
  44. package/dist/src/alu/src/kernel-numeric.js +0 -366
  45. package/dist/src/alu/src/operation.d.ts +0 -168
  46. package/dist/src/alu/src/operation.js +0 -189
  47. package/dist/src/alu/src/parser.d.ts +0 -221
  48. package/dist/src/alu/src/parser.js +0 -577
  49. package/dist/src/alu/src/resonance.d.ts +0 -55
  50. package/dist/src/alu/src/resonance.js +0 -126
  51. package/dist/src/alu/src/text.d.ts +0 -31
  52. package/dist/src/alu/src/text.js +0 -73
  53. package/dist/src/alu/src/value.d.ts +0 -109
  54. package/dist/src/alu/src/value.js +0 -300
  55. package/dist/src/alu/test/alu.test.d.ts +0 -1
  56. package/dist/src/alu/test/alu.test.js +0 -764
  57. package/dist/src/bytes.d.ts +0 -14
  58. package/dist/src/bytes.js +0 -59
  59. package/dist/src/canon.d.ts +0 -26
  60. package/dist/src/canon.js +0 -57
  61. package/dist/src/config.d.ts +0 -111
  62. package/dist/src/config.js +0 -91
  63. package/dist/src/derive/src/deduction.d.ts +0 -136
  64. package/dist/src/derive/src/deduction.js +0 -159
  65. package/dist/src/derive/src/index.d.ts +0 -8
  66. package/dist/src/derive/src/index.js +0 -11
  67. package/dist/src/derive/src/priority-queue.d.ts +0 -20
  68. package/dist/src/derive/src/priority-queue.js +0 -73
  69. package/dist/src/derive/src/rewrite.d.ts +0 -56
  70. package/dist/src/derive/src/rewrite.js +0 -100
  71. package/dist/src/derive/src/trie.d.ts +0 -90
  72. package/dist/src/derive/src/trie.js +0 -217
  73. package/dist/src/derive/test/derive.test.d.ts +0 -1
  74. package/dist/src/derive/test/derive.test.js +0 -122
  75. package/dist/src/extension.d.ts +0 -37
  76. package/dist/src/extension.js +0 -7
  77. package/dist/src/geometry.d.ts +0 -175
  78. package/dist/src/geometry.js +0 -823
  79. package/dist/src/index.d.ts +0 -17
  80. package/dist/src/index.js +0 -19
  81. package/dist/src/ingest-cache.d.ts +0 -41
  82. package/dist/src/ingest-cache.js +0 -161
  83. package/dist/src/meter.d.ts +0 -171
  84. package/dist/src/meter.js +0 -269
  85. package/dist/src/mind/articulation.d.ts +0 -6
  86. package/dist/src/mind/articulation.js +0 -99
  87. package/dist/src/mind/attention.d.ts +0 -414
  88. package/dist/src/mind/attention.js +0 -2065
  89. package/dist/src/mind/bridge.d.ts +0 -39
  90. package/dist/src/mind/bridge.js +0 -738
  91. package/dist/src/mind/canonical.d.ts +0 -34
  92. package/dist/src/mind/canonical.js +0 -93
  93. package/dist/src/mind/graph-search.d.ts +0 -294
  94. package/dist/src/mind/graph-search.js +0 -996
  95. package/dist/src/mind/index.d.ts +0 -9
  96. package/dist/src/mind/index.js +0 -5
  97. package/dist/src/mind/junction.d.ts +0 -134
  98. package/dist/src/mind/junction.js +0 -331
  99. package/dist/src/mind/learning.d.ts +0 -75
  100. package/dist/src/mind/learning.js +0 -270
  101. package/dist/src/mind/match.d.ts +0 -166
  102. package/dist/src/mind/match.js +0 -565
  103. package/dist/src/mind/mechanisms/alu.d.ts +0 -4
  104. package/dist/src/mind/mechanisms/alu.js +0 -36
  105. package/dist/src/mind/mechanisms/cast.d.ts +0 -89
  106. package/dist/src/mind/mechanisms/cast.js +0 -773
  107. package/dist/src/mind/mechanisms/confluence.d.ts +0 -24
  108. package/dist/src/mind/mechanisms/confluence.js +0 -225
  109. package/dist/src/mind/mechanisms/cover.d.ts +0 -6
  110. package/dist/src/mind/mechanisms/cover.js +0 -203
  111. package/dist/src/mind/mechanisms/extraction.d.ts +0 -33
  112. package/dist/src/mind/mechanisms/extraction.js +0 -300
  113. package/dist/src/mind/mechanisms/recall.d.ts +0 -16
  114. package/dist/src/mind/mechanisms/recall.js +0 -388
  115. package/dist/src/mind/mind.d.ts +0 -330
  116. package/dist/src/mind/mind.js +0 -594
  117. package/dist/src/mind/pipeline-mechanism.d.ts +0 -172
  118. package/dist/src/mind/pipeline-mechanism.js +0 -382
  119. package/dist/src/mind/pipeline.d.ts +0 -49
  120. package/dist/src/mind/pipeline.js +0 -275
  121. package/dist/src/mind/primitives.d.ts +0 -66
  122. package/dist/src/mind/primitives.js +0 -306
  123. package/dist/src/mind/rationale.d.ts +0 -139
  124. package/dist/src/mind/rationale.js +0 -163
  125. package/dist/src/mind/reasoning.d.ts +0 -40
  126. package/dist/src/mind/reasoning.js +0 -272
  127. package/dist/src/mind/recognition.d.ts +0 -20
  128. package/dist/src/mind/recognition.js +0 -463
  129. package/dist/src/mind/resonance.d.ts +0 -23
  130. package/dist/src/mind/resonance.js +0 -0
  131. package/dist/src/mind/trace.d.ts +0 -15
  132. package/dist/src/mind/trace.js +0 -73
  133. package/dist/src/mind/traverse.d.ts +0 -124
  134. package/dist/src/mind/traverse.js +0 -649
  135. package/dist/src/mind/types.d.ts +0 -323
  136. package/dist/src/mind/types.js +0 -130
  137. package/dist/src/rabitq-ivf/src/database.d.ts +0 -113
  138. package/dist/src/rabitq-ivf/src/database.js +0 -201
  139. package/dist/src/rabitq-ivf/src/index.d.ts +0 -7
  140. package/dist/src/rabitq-ivf/src/index.js +0 -4
  141. package/dist/src/rabitq-ivf/src/ivf.d.ts +0 -200
  142. package/dist/src/rabitq-ivf/src/ivf.js +0 -1165
  143. package/dist/src/rabitq-ivf/src/prng.d.ts +0 -19
  144. package/dist/src/rabitq-ivf/src/prng.js +0 -36
  145. package/dist/src/rabitq-ivf/src/rabitq.d.ts +0 -95
  146. package/dist/src/rabitq-ivf/src/rabitq.js +0 -283
  147. package/dist/src/sema.d.ts +0 -31
  148. package/dist/src/sema.js +0 -63
  149. package/dist/src/store-sqlite.d.ts +0 -184
  150. package/dist/src/store-sqlite.js +0 -942
  151. package/dist/src/store.d.ts +0 -678
  152. package/dist/src/store.js +0 -1703
  153. package/dist/src/vec.d.ts +0 -31
  154. package/dist/src/vec.js +0 -109
@@ -1,414 +0,0 @@
1
- import type { DerivationStep } from "./graph-search.js";
2
- import type { AncestorReach, Attention, AttentionRead, DFMode, MindContext, Region, RegionVote, SaturationInfo, SaturationStop } from "./types.js";
3
- import { type StructuralPart } from "../geometry.js";
4
- import { type JunctionSynonymSides } from "./junction.js";
5
- import type { Vec } from "../vec.js";
6
- /** How the newly-added graded junction ladder (junction.ts / attention.ts's
7
- * {@link CrossRegionTier}) is reported on a `junctionVotes` entry. The
8
- * instrumentation spec this implements predates that ladder and only knew
9
- * two tiers ("exact" | "synonym"); with the richer `CrossRegionTier` now
10
- * the real shape of a junction vote's provenance, `junctionVotes[].tier`
11
- * reports it DIRECTLY (the tier as-is: "exact" | "single-synonym" |
12
- * "double-synonym" | "structural-resonance") rather than collapsing every
13
- * non-exact tier into a lossy "synonym" bucket — the whole point of
14
- * exposing `tier` here is to let a debugger tell a halo-sibling
15
- * substitution apart from a structural-resonance ANN guess, which the
16
- * spec's original two-value type cannot do. */
17
- export type ClimbConsensusJunctionTier = CrossRegionTier;
18
- export type RegionOutcome = "voted" | "no-ann-hit" | "no-structural-reach" | "saturated-abstention" | "nonpositive-df-weight" | "contrastive-margin-rejection";
19
- /** The best DIFFERENT-conclusion rival the contrastive-margin gate found
20
- * while scanning an ordinary (approximate) region's ANN hits — spec §1.
21
- * Its roots/saturation/contextsReached are already available through
22
- * `reaches` (serialiseReaches) for `node`; not duplicated here. */
23
- export interface ConsensusContrastiveRivalTrace {
24
- node: number;
25
- rank: number;
26
- score: number;
27
- }
28
- export interface ConsensusRegionTrace {
29
- index: number;
30
- source: "perceived" | "recognised";
31
- span: [number, number];
32
- chunk: boolean;
33
- known: boolean;
34
- canonicalId?: number;
35
- canonicalUsable: boolean;
36
- canonicalFailed: boolean;
37
- annQueried: boolean;
38
- annHitsReturned: number;
39
- annHitsExamined: number;
40
- selected?: {
41
- source: "canonical" | "ann";
42
- node: number;
43
- rank?: number;
44
- score: number;
45
- fallback?: "orphan" | "saturated-tie";
46
- };
47
- reachNode?: number;
48
- outcome: RegionOutcome;
49
- idf?: number;
50
- dfWeight?: number;
51
- contrastiveMargin?: number;
52
- contrastiveNoiseFloor?: number;
53
- contrastiveRival?: ConsensusContrastiveRivalTrace;
54
- mutualWeight?: number;
55
- voteWeightPerRoot?: number;
56
- focusWeightPerRoot?: number;
57
- ordinaryVoteProduced: boolean;
58
- superseded: boolean;
59
- }
60
- export interface ConsensusReachTrace {
61
- node: number;
62
- roots: number[];
63
- contextsReached: number;
64
- saturated: boolean;
65
- saturation?: SaturationStop;
66
- /** Nodes the climb processed — see {@link AncestorReach.visited}. Absent
67
- * on payloads recorded before this field existed. */
68
- visited?: number;
69
- /** Maximum ascent distance — see {@link AncestorReach.maxDepth}. */
70
- maxDepth?: number;
71
- }
72
- export type AnchorRejectionReason = "below-natural-break" | "below-consensus-floor" | "leading-saturation";
73
- export interface ConsensusAnchorTrace {
74
- anchor: number;
75
- rank: number;
76
- pooledVote: number;
77
- idfVote: number;
78
- candidateBreadth: number;
79
- contributingVotes: number;
80
- contributingEvidence: number;
81
- breadth: number;
82
- contributingSpans: Array<[number, number]>;
83
- clusters: number;
84
- commit: {
85
- status: "root" | "overlap" | "rejected";
86
- dominant: boolean;
87
- passesNaturalBreak?: boolean;
88
- passesConsensusFloor?: boolean;
89
- pastLeadingSaturation?: boolean;
90
- rejectionReasons: AnchorRejectionReason[];
91
- };
92
- }
93
- export interface JunctionVoteTrace {
94
- container: number;
95
- span: [number, number];
96
- roots: number[];
97
- sourceRegionIndices: number[];
98
- explainedAwayRegionIndices: number[];
99
- absorbed: number;
100
- tier?: ClimbConsensusJunctionTier;
101
- /** Zero-based index into `crossRegion.probes` — the probe this vote was
102
- * produced from (spec §8). */
103
- probe: number;
104
- confidence: number;
105
- /** "Evidence bytes" — the container-coverage byte count (the existing
106
- * `bestCov` variable at the push site). */
107
- evidenceBytes: number;
108
- mutualWeight: number;
109
- voteWeightPerRoot: number;
110
- }
111
- /** Whether one DAG/synonym tier attempt was even made for a probe, and how
112
- * many candidate containers it returned — spec §2/§3. */
113
- export interface CrossRegionTierAttemptTrace {
114
- attempted: boolean;
115
- candidatesReturned: number;
116
- }
117
- /** Aggregate outcome of the container-selection loop for a DAG/synonym tier
118
- * that returned at least one container — spec §4. Only aggregate counts
119
- * and the final outcome are recorded, never every candidate. */
120
- export interface CrossRegionStructuralTrace {
121
- tier: "exact" | "single-synonym" | "double-synonym";
122
- selfEvidenceRejected: number;
123
- contradictionRejected: number;
124
- passedGuards: number;
125
- selectedNode?: number;
126
- outcome: "all-rejected" | "saturated" | "no-roots" | "nonpositive-idf" | "accepted";
127
- }
128
- /** One retained structural-resonance variant that actually issued its own
129
- * ANN query — spec §5. */
130
- export interface StructuralResonanceVariantTrace {
131
- kind: StructuralVariant["kind"];
132
- semanticConfidence: number;
133
- leftSiblingId?: number;
134
- rightSiblingId?: number;
135
- annHitsReturned: number;
136
- }
137
- /** One merged structural-resonance proposal actually examined via
138
- * edgeAncestors — spec §5. Retains node/variant/scores, but NOT
139
- * roots/saturation/contextsReached/idf (already in `reaches`). */
140
- export interface StructuralResonanceCandidateTrace {
141
- node: number;
142
- variant: StructuralVariant["kind"];
143
- leftSiblingId?: number;
144
- rightSiblingId?: number;
145
- annScore: number;
146
- semanticConfidence: number;
147
- effectiveScore: number;
148
- outcome: "saturated" | "no-roots" | "nonpositive-idf" | "same-as-endpoint" | "same-as-selected" | "selected" | "contrastive-rival";
149
- }
150
- export interface StructuralResonanceTrace {
151
- variantBudget: number;
152
- variants: StructuralResonanceVariantTrace[];
153
- mergedProposals: number;
154
- examined: StructuralResonanceCandidateTrace[];
155
- contrastiveMargin?: number;
156
- noiseFloor: number;
157
- outcome: "ineligible" | "empty" | "no-valid-proposal" | "margin-rejected" | "accepted";
158
- ineligibleReasons?: Array<"between-region" | "not-both-strong" | "not-both-known" | "gap-too-large">;
159
- }
160
- /** One cross-region pair the ladder actually probed — spec §2. Exactly one
161
- * of these is pushed per pair that incremented `probes`. */
162
- export interface CrossRegionProbeTrace {
163
- leftRegionIndex: number;
164
- rightRegionIndex: number;
165
- betweenRegionIndices: number[];
166
- exact: CrossRegionTierAttemptTrace;
167
- singleSynonym: CrossRegionTierAttemptTrace;
168
- doubleSynonym: CrossRegionTierAttemptTrace;
169
- structural?: CrossRegionStructuralTrace;
170
- resonance?: StructuralResonanceTrace;
171
- outcome: "accepted" | "structural-rejected" | "resonance-ineligible" | "resonance-rejected";
172
- }
173
- export interface ClimbConsensusData {
174
- version: 1;
175
- cache: {
176
- hit: boolean;
177
- detailAvailable: boolean;
178
- };
179
- config: {
180
- annK: number;
181
- crossRegionProbeLimit: number;
182
- mode: DFMode;
183
- corpusN?: number;
184
- dimension?: number;
185
- hubBound?: number;
186
- estimatorNoise?: number;
187
- naturalBreak?: number;
188
- consensusFloor?: number;
189
- };
190
- candidates: {
191
- perceived: number;
192
- recognised: number;
193
- total: number;
194
- };
195
- regions?: ConsensusRegionTrace[];
196
- reaches?: ConsensusReachTrace[];
197
- crossRegion?: {
198
- eligibleRegions: number;
199
- maximalRegions: number;
200
- probeLimit: number;
201
- probesAttempted: number;
202
- junctionVotes: JunctionVoteTrace[];
203
- supersededOrdinaryVotes: number;
204
- probes: CrossRegionProbeTrace[];
205
- stopReason: "insufficient-regions" | "probe-limit" | "pairs-exhausted";
206
- };
207
- saturation?: {
208
- regionIntervals: Array<{
209
- start: number;
210
- end: number;
211
- }>;
212
- hasLeading: boolean;
213
- leadingEnd: number;
214
- };
215
- pooling?: {
216
- inputVotes: number;
217
- eligibleVotes: number;
218
- saturationMaskedVotes: number;
219
- };
220
- anchors?: ConsensusAnchorTrace[];
221
- result: AttentionRead;
222
- }
223
- /** The mutable collection buffers threaded through one traced consensus
224
- * climb — allocated exactly once, in {@link computeAttention}, only when
225
- * `ctx.trace` is set. Every field mirrors a `ClimbConsensusData` array/map,
226
- * built incrementally as the pipeline runs so commit-time decisions (in
227
- * particular) are recorded LIVE, not reconstructed afterward. */
228
- interface TraceDraft {
229
- perceivedCount: number;
230
- regions: ConsensusRegionTrace[];
231
- crossRegionJunctionVotes: JunctionVoteTrace[];
232
- crossRegionSummary?: {
233
- eligibleRegions: number;
234
- maximalRegions: number;
235
- probeLimit: number;
236
- probesAttempted: number;
237
- stopReason?: "insufficient-regions" | "probe-limit" | "pairs-exhausted";
238
- };
239
- crossRegionProbes: CrossRegionProbeTrace[];
240
- supersededOrdinaryVotes: number;
241
- saturation?: {
242
- regionIntervals: Array<{
243
- start: number;
244
- end: number;
245
- }>;
246
- hasLeading: boolean;
247
- leadingEnd: number;
248
- };
249
- pooling?: {
250
- inputVotes: number;
251
- eligibleVotes: number;
252
- saturationMaskedVotes: number;
253
- };
254
- anchors: ConsensusAnchorTrace[];
255
- }
256
- /** The config/corpus context {@link traceAttention} needs to fill in
257
- * `ClimbConsensusData.config` and `.result` at whichever exit fires —
258
- * threaded down from {@link computeAttention} rather than re-derived, so
259
- * every emission point reports the SAME numbers the real climb used. */
260
- interface ClimbConsensusCfg {
261
- k: number;
262
- mode: DFMode;
263
- perceivedCount: number;
264
- totalRegions: number;
265
- N?: number;
266
- reachMemo?: ReadonlyMap<number, AncestorReach>;
267
- naturalBreak?: number;
268
- consensusFloor?: number;
269
- }
270
- /** Climb the query's perceived byte regions up the structural DAG via
271
- * resonance, pool the evidence, and return only the ROOT points of
272
- * attention — those that cleared commitVotes' significance floor. */
273
- export declare function climbAttention(ctx: MindContext, query: Uint8Array, k: number, mode?: DFMode): Promise<Attention[]>;
274
- /** Full read-out of one consensus climb: both the roots (dominant points of
275
- * attention) and the entire ranked list. Cached via ctx.climbMemo, ALWAYS —
276
- * see {@link recognise} for why this memo (and recognise()'s own) must
277
- * never be skipped while tracing: computeAttention's collectRegions walks
278
- * the query's perceived tree via the same foldTree whose subtree-resolution
279
- * fast path makes a second call on identical bytes non-idempotent once
280
- * ctx._resolvedSubtrees is warm (which a multi-turn conversation's shared
281
- * prefix subtrees guarantee by the second turn). A cache hit still emits
282
- * a trace step — abbreviated, since the full per-sub-region voting detail
283
- * {@link traceAttention} builds isn't preserved by the cached read-out —
284
- * so a traced response is never silently blacked out for a repeated
285
- * query. */
286
- export declare function climbAttentionAll(ctx: MindContext, query: Uint8Array, k: number, mode?: DFMode): Promise<AttentionRead>;
287
- export declare function computeAttention(ctx: MindContext, query: Uint8Array, k: number, mode: DFMode): Promise<AttentionRead>;
288
- export declare function collectRegions(ctx: MindContext, query: Uint8Array): Region[];
289
- export declare function voteRegions(ctx: MindContext, query: Uint8Array, regions: readonly Region[], k: number, mode: DFMode, N: number, reachMemo?: Map<number, AncestorReach>, td?: TraceDraft): Promise<{
290
- votes: RegionVote[];
291
- saturated: boolean[];
292
- voters: Array<{
293
- id: number;
294
- score: number;
295
- w: number;
296
- } | null>;
297
- }>;
298
- /** The consensus vote as EVIDENCE POOLING, not shortest path: each surviving
299
- * region is an axiom; it contributes to every root it climbed to (or, for a
300
- * terminal answer node, to the contexts that lead to it) by a `combine:
301
- * "sum"` rule, so independent regions corroborating the same anchor ADD
302
- * rather than compete to be the cheapest route (see {@link Rule.combine} in
303
- * derive/src/deduction.ts). Run through the very engine {@link
304
- * GraphSearch} covers with — `lightestDerivation` — so a pooled-evidence
305
- * decision is, like a followed edge or a spliced connector, one weighted
306
- * rule of the SAME deduction system, not a separate hand-rolled tally that
307
- * merely logs alongside it. `votesIdf`/`support` are the same two
308
- * read-outs {@link commitVotes} always gated on; only how they accumulate
309
- * changed. */
310
- export declare function poolVotes(ctx: MindContext, regionVotes: readonly RegionVote[], sat: SaturationInfo, N: number, td?: TraceDraft): {
311
- votes: Map<number, number>;
312
- votesIdf: Map<number, number>;
313
- support: Map<number, {
314
- start: number;
315
- end: number;
316
- w: number;
317
- }>;
318
- /** Per-anchor SCALE-INVARIANT support: Σ RegionVote.absorbed over the
319
- * distinct contributing regions — see Attention.breadth. */
320
- regionSupport: Map<number, number>;
321
- /** Per-anchor contributing region spans — see Attention.clusters. */
322
- regionSpans: Map<number, Array<[number, number]>>;
323
- steps: DerivationStep[];
324
- };
325
- export declare function commitVotes(ctx: MindContext, pooled: {
326
- votes: Map<number, number>;
327
- votesIdf: Map<number, number>;
328
- support: Map<number, {
329
- start: number;
330
- end: number;
331
- w: number;
332
- }>;
333
- regionSupport: Map<number, number>;
334
- regionSpans: Map<number, Array<[number, number]>>;
335
- steps: DerivationStep[];
336
- }, sat: SaturationInfo, regions: readonly Region[], regionVoter: ReadonlyArray<{
337
- id: number;
338
- score: number;
339
- w: number;
340
- } | null>, N: number, td?: TraceDraft, cfg?: ClimbConsensusCfg): AttentionRead;
341
- export declare function detectSaturated(ctx: MindContext, regions: ReadonlyArray<{
342
- start: number;
343
- end: number;
344
- chunk?: boolean;
345
- }>, saturated: ReadonlyArray<boolean>): SaturationInfo;
346
- export declare function canonicalChunkId(ctx: MindContext, regionBytes: Uint8Array, N: number, reachMemo?: Map<number, AncestorReach>): number | null;
347
- export declare function naturalBreak(votes: number[]): number;
348
- export type CrossRegionTier = "exact" | "single-synonym" | "double-synonym" | "structural-resonance";
349
- export interface StructuralVariant {
350
- left: StructuralPart;
351
- right: StructuralPart;
352
- kind: "exact-exact" | "left-synonym" | "right-synonym" | "double-synonym";
353
- semanticConfidence: number;
354
- leftSiblingId?: number;
355
- rightSiblingId?: number;
356
- }
357
- export interface StructuralResonanceProposal {
358
- id: number;
359
- annScore: number;
360
- semanticConfidence: number;
361
- effectiveScore: number;
362
- variant: StructuralVariant["kind"];
363
- leftSiblingId?: number;
364
- rightSiblingId?: number;
365
- }
366
- /** A sibling gist cached in the shared, climb-wide memo alongside the
367
- * COMPLETE stored byte length it was reconstructed from — the length is
368
- * required to tell whether a cache hit is still valid under a probe whose
369
- * `maxSiblingBytes` bound is smaller than the one that first cached it. */
370
- interface CachedSiblingGist {
371
- gist: Vec;
372
- length: number;
373
- }
374
- /** Build, bound and order every mandatory structural variant (§7-8): the
375
- * exact/exact composition is always kept; up to `ctx.cfg.haloQueryK`
376
- * synonym variants (single- and double-synonym combined, one shared
377
- * budget) are appended, ordered by confidence, then kind, then sibling id.
378
- * Variant selection is entirely lightweight (see {@link
379
- * buildStructuralVariantSpecs}); a sibling's bytes are read and perceived
380
- * only for specs actually retained, and at most once per sibling id per
381
- * climb via `siblingGistMemo`. */
382
- export declare function buildStructuralVariants(ctx: MindContext, ra: Region, rb: Region, sides: JunctionSynonymSides, siblingGistMemo: Map<number, CachedSiblingGist>): {
383
- variants: StructuralVariant[];
384
- exactLeft: StructuralPart;
385
- exactRight: StructuralPart;
386
- };
387
- export declare function structuralResonance(ctx: MindContext, query: Uint8Array, ra: Region, rb: Region, sides: JunctionSynonymSides, siblingGistMemo: Map<number, CachedSiblingGist>, k: number, N: number, reachMemo: Map<number, AncestorReach>,
388
- /** Each side's OWN individual climb roots (from voteRegions), when it cast
389
- * one — the self-evidence backstop structural-resonance needs and the
390
- * exact tier gets for free from literal byte containment (§11's whole
391
- * premise: recover a JOINT context neither side votes for alone). A
392
- * candidate whose reach is exactly one side's own conclusion is not new
393
- * evidence of a joint whole; it is that side's resonance rediscovering
394
- * itself through a synthetic gist still dominated by its own direction. */
395
- ownRootsA: readonly number[] | undefined, ownRootsB: readonly number[] | undefined, trace?: StructuralResonanceTrace): Promise<{
396
- proposal: StructuralResonanceProposal;
397
- reach: AncestorReach;
398
- idf: number;
399
- } | null>;
400
- /** Emit the "climbConsensus" step — the human-readable note this always
401
- * produced, now paired (when `ctx.trace` and `cfg` are both present) with
402
- * the structured {@link ClimbConsensusData} payload on the SAME step's
403
- * `data` field. Every exit of {@link computeAttention} funnels through
404
- * here, so instrumentation and the existing rationale text can never drift
405
- * apart — see the instrumentation spec's §9 "every exit path". */
406
- export declare function traceAttention(ctx: MindContext, regions: ReadonlyArray<{
407
- start: number;
408
- end: number;
409
- }>, regionVoter: ReadonlyArray<{
410
- id: number;
411
- score: number;
412
- w: number;
413
- } | null>, roots: ReadonlyArray<Attention>, steps?: ReadonlyArray<DerivationStep>, td?: TraceDraft, cfg?: ClimbConsensusCfg, ranked?: ReadonlyArray<Attention>): void;
414
- export {};