@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,430 +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) is never
277
- * gated on tracing. The short of it: computeAttention's collectRegions
278
- * votes over what walking the query's perceived tree EMITS, and foldTree's
279
- * subtree-resolution fast path used to skip that walk on a warm cache, so a
280
- * second climb over identical bytes saw less evidence than the first — which
281
- * a conversation's shared prefix subtrees guaranteed by the second turn.
282
- * foldTree now takes that fast path only when nothing is watching the walk
283
- * (see primitives.ts), so the climb is idempotent on its own and this memo
284
- * is an accelerator again. It stays unconditional anyway: attaching a trace
285
- * must not change which regions attention weighs.
286
- *
287
- * A cache hit still emits a trace step — abbreviated, since the full
288
- * per-sub-region voting detail {@link traceAttention} builds isn't preserved
289
- * by the cached read-out — so a traced response is never silently blacked
290
- * out for a repeated query. */
291
- export declare function climbAttentionAll(ctx: MindContext, query: Uint8Array, k: number, mode?: DFMode): Promise<AttentionRead>;
292
- export declare function computeAttention(ctx: MindContext, query: Uint8Array, k: number, mode: DFMode): Promise<AttentionRead>;
293
- export declare function collectRegions(ctx: MindContext, query: Uint8Array): Region[];
294
- export declare function voteRegions(ctx: MindContext, query: Uint8Array, regions: readonly Region[], k: number, mode: DFMode, N: number, reachMemo?: Map<number, AncestorReach>, td?: TraceDraft): Promise<{
295
- votes: RegionVote[];
296
- saturated: boolean[];
297
- voters: Array<{
298
- id: number;
299
- score: number;
300
- w: number;
301
- } | null>;
302
- }>;
303
- /** The consensus vote as EVIDENCE POOLING, not shortest path: each surviving
304
- * region is an axiom; it contributes to every root it climbed to (or, for a
305
- * terminal answer node, to the contexts that lead to it) by a `combine:
306
- * "sum"` rule, so independent regions corroborating the same anchor ADD
307
- * rather than compete to be the cheapest route (see {@link Rule.combine} in
308
- * derive/src/deduction.ts). Run through the very engine {@link
309
- * GraphSearch} covers with — `lightestDerivation` — so a pooled-evidence
310
- * decision is, like a followed edge or a spliced connector, one weighted
311
- * rule of the SAME deduction system, not a separate hand-rolled tally that
312
- * merely logs alongside it. `votesIdf`/`support` are the same two
313
- * read-outs {@link commitVotes} always gated on; only how they accumulate
314
- * changed. */
315
- export declare function poolVotes(ctx: MindContext, regionVotes: readonly RegionVote[], sat: SaturationInfo, N: number, td?: TraceDraft): {
316
- votes: Map<number, number>;
317
- votesIdf: Map<number, number>;
318
- support: Map<number, {
319
- start: number;
320
- end: number;
321
- w: number;
322
- }>;
323
- /** Per-anchor SCALE-INVARIANT support: Σ RegionVote.absorbed over the
324
- * distinct contributing regions — see Attention.breadth. */
325
- regionSupport: Map<number, number>;
326
- /** Per-anchor contributing region spans — see Attention.clusters. */
327
- regionSpans: Map<number, Array<[number, number]>>;
328
- /** Per-anchor count of contributing region VOTES (pooled axioms), which is
329
- * not the length of `regionSpans`: a joint binding is one vote sitting in
330
- * several places. */
331
- regionAxioms: Map<number, number>;
332
- /** Per-anchor LARGEST single-region contribution — see Attention.peak. */
333
- regionPeak: Map<number, number>;
334
- /** Anchors with support from at least one NON-corroborating region. */
335
- anchored: Set<number>;
336
- steps: DerivationStep[];
337
- };
338
- export declare function commitVotes(ctx: MindContext, pooled: {
339
- votes: Map<number, number>;
340
- votesIdf: Map<number, number>;
341
- support: Map<number, {
342
- start: number;
343
- end: number;
344
- w: number;
345
- }>;
346
- regionSupport: Map<number, number>;
347
- regionSpans: Map<number, Array<[number, number]>>;
348
- regionAxioms: Map<number, number>;
349
- regionPeak: Map<number, number>;
350
- anchored: Set<number>;
351
- steps: DerivationStep[];
352
- }, sat: SaturationInfo, regions: readonly Region[], regionVoter: ReadonlyArray<{
353
- id: number;
354
- score: number;
355
- w: number;
356
- } | null>, N: number, td?: TraceDraft, cfg?: ClimbConsensusCfg): AttentionRead;
357
- export declare function detectSaturated(ctx: MindContext, regions: ReadonlyArray<{
358
- start: number;
359
- end: number;
360
- chunk?: boolean;
361
- }>, saturated: ReadonlyArray<boolean>): SaturationInfo;
362
- export declare function canonicalChunkId(ctx: MindContext, regionBytes: Uint8Array, N: number, reachMemo?: Map<number, AncestorReach>): number | null;
363
- export declare function naturalBreak(votes: number[]): number;
364
- export type CrossRegionTier = "exact" | "single-synonym" | "double-synonym" | "structural-resonance";
365
- export interface StructuralVariant {
366
- left: StructuralPart;
367
- right: StructuralPart;
368
- kind: "exact-exact" | "left-synonym" | "right-synonym" | "double-synonym";
369
- semanticConfidence: number;
370
- leftSiblingId?: number;
371
- rightSiblingId?: number;
372
- }
373
- export interface StructuralResonanceProposal {
374
- id: number;
375
- annScore: number;
376
- semanticConfidence: number;
377
- effectiveScore: number;
378
- variant: StructuralVariant["kind"];
379
- leftSiblingId?: number;
380
- rightSiblingId?: number;
381
- }
382
- /** A sibling gist cached in the shared, climb-wide memo alongside the
383
- * COMPLETE stored byte length it was reconstructed from — the length is
384
- * required to tell whether a cache hit is still valid under a probe whose
385
- * `maxSiblingBytes` bound is smaller than the one that first cached it. */
386
- interface CachedSiblingGist {
387
- gist: Vec;
388
- length: number;
389
- }
390
- /** Build, bound and order every mandatory structural variant (§7-8): the
391
- * exact/exact composition is always kept; up to `ctx.cfg.haloQueryK`
392
- * synonym variants (single- and double-synonym combined, one shared
393
- * budget) are appended, ordered by confidence, then kind, then sibling id.
394
- * Variant selection is entirely lightweight (see {@link
395
- * buildStructuralVariantSpecs}); a sibling's bytes are read and perceived
396
- * only for specs actually retained, and at most once per sibling id per
397
- * climb via `siblingGistMemo`. */
398
- export declare function buildStructuralVariants(ctx: MindContext, ra: Region, rb: Region, sides: JunctionSynonymSides, siblingGistMemo: Map<number, CachedSiblingGist>): {
399
- variants: StructuralVariant[];
400
- exactLeft: StructuralPart;
401
- exactRight: StructuralPart;
402
- };
403
- 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>,
404
- /** Each side's OWN individual climb roots (from voteRegions), when it cast
405
- * one — the self-evidence backstop structural-resonance needs and the
406
- * exact tier gets for free from literal byte containment (§11's whole
407
- * premise: recover a JOINT context neither side votes for alone). A
408
- * candidate whose reach is exactly one side's own conclusion is not new
409
- * evidence of a joint whole; it is that side's resonance rediscovering
410
- * itself through a synthetic gist still dominated by its own direction. */
411
- ownRootsA: readonly number[] | undefined, ownRootsB: readonly number[] | undefined, trace?: StructuralResonanceTrace): Promise<{
412
- proposal: StructuralResonanceProposal;
413
- reach: AncestorReach;
414
- idf: number;
415
- } | null>;
416
- /** Emit the "climbConsensus" step — the human-readable note this always
417
- * produced, now paired (when `ctx.trace` and `cfg` are both present) with
418
- * the structured {@link ClimbConsensusData} payload on the SAME step's
419
- * `data` field. Every exit of {@link computeAttention} funnels through
420
- * here, so instrumentation and the existing rationale text can never drift
421
- * apart — see the instrumentation spec's §9 "every exit path". */
422
- export declare function traceAttention(ctx: MindContext, regions: ReadonlyArray<{
423
- start: number;
424
- end: number;
425
- }>, regionVoter: ReadonlyArray<{
426
- id: number;
427
- score: number;
428
- w: number;
429
- } | null>, roots: ReadonlyArray<Attention>, steps?: ReadonlyArray<DerivationStep>, td?: TraceDraft, cfg?: ClimbConsensusCfg, ranked?: ReadonlyArray<Attention>): void;
430
- export {};