@hviana/sema 0.5.3 → 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 (143) hide show
  1. package/AGENTS.md +6 -6
  2. package/HOW_IT_WORKS.md +16 -0
  3. package/jsr.json +1 -1
  4. package/package.json +1 -1
  5. package/src/mind/match.ts +81 -0
  6. package/src/mind/mechanisms/recall.ts +29 -3
  7. package/test/76-reference-binding.test.mjs +72 -0
  8. package/dist/example/demo.d.ts +0 -1
  9. package/dist/example/demo.js +0 -39
  10. package/dist/example/train_base.d.ts +0 -93
  11. package/dist/example/train_base.js +0 -2269
  12. package/dist/src/alphabet.d.ts +0 -7
  13. package/dist/src/alphabet.js +0 -33
  14. package/dist/src/alu/src/alu.d.ts +0 -185
  15. package/dist/src/alu/src/alu.js +0 -440
  16. package/dist/src/alu/src/expr.d.ts +0 -61
  17. package/dist/src/alu/src/expr.js +0 -318
  18. package/dist/src/alu/src/index.d.ts +0 -11
  19. package/dist/src/alu/src/index.js +0 -19
  20. package/dist/src/alu/src/kernel-arith.d.ts +0 -16
  21. package/dist/src/alu/src/kernel-arith.js +0 -264
  22. package/dist/src/alu/src/kernel-bits.d.ts +0 -19
  23. package/dist/src/alu/src/kernel-bits.js +0 -152
  24. package/dist/src/alu/src/kernel-logic.d.ts +0 -4
  25. package/dist/src/alu/src/kernel-logic.js +0 -60
  26. package/dist/src/alu/src/kernel-nd.d.ts +0 -3
  27. package/dist/src/alu/src/kernel-nd.js +0 -208
  28. package/dist/src/alu/src/kernel-numeric.d.ts +0 -54
  29. package/dist/src/alu/src/kernel-numeric.js +0 -366
  30. package/dist/src/alu/src/operation.d.ts +0 -168
  31. package/dist/src/alu/src/operation.js +0 -189
  32. package/dist/src/alu/src/parser.d.ts +0 -221
  33. package/dist/src/alu/src/parser.js +0 -577
  34. package/dist/src/alu/src/resonance.d.ts +0 -55
  35. package/dist/src/alu/src/resonance.js +0 -126
  36. package/dist/src/alu/src/text.d.ts +0 -31
  37. package/dist/src/alu/src/text.js +0 -73
  38. package/dist/src/alu/src/value.d.ts +0 -109
  39. package/dist/src/alu/src/value.js +0 -300
  40. package/dist/src/alu/test/alu.test.d.ts +0 -1
  41. package/dist/src/alu/test/alu.test.js +0 -764
  42. package/dist/src/bytes.d.ts +0 -14
  43. package/dist/src/bytes.js +0 -59
  44. package/dist/src/canon.d.ts +0 -45
  45. package/dist/src/canon.js +0 -85
  46. package/dist/src/config.d.ts +0 -111
  47. package/dist/src/config.js +0 -91
  48. package/dist/src/derive/src/deduction.d.ts +0 -136
  49. package/dist/src/derive/src/deduction.js +0 -159
  50. package/dist/src/derive/src/index.d.ts +0 -8
  51. package/dist/src/derive/src/index.js +0 -11
  52. package/dist/src/derive/src/priority-queue.d.ts +0 -20
  53. package/dist/src/derive/src/priority-queue.js +0 -73
  54. package/dist/src/derive/src/rewrite.d.ts +0 -56
  55. package/dist/src/derive/src/rewrite.js +0 -100
  56. package/dist/src/derive/src/trie.d.ts +0 -90
  57. package/dist/src/derive/src/trie.js +0 -217
  58. package/dist/src/derive/test/derive.test.d.ts +0 -1
  59. package/dist/src/derive/test/derive.test.js +0 -122
  60. package/dist/src/extension.d.ts +0 -37
  61. package/dist/src/extension.js +0 -7
  62. package/dist/src/geometry.d.ts +0 -233
  63. package/dist/src/geometry.js +0 -1089
  64. package/dist/src/index.d.ts +0 -17
  65. package/dist/src/index.js +0 -19
  66. package/dist/src/ingest-cache.d.ts +0 -41
  67. package/dist/src/ingest-cache.js +0 -165
  68. package/dist/src/meter.d.ts +0 -176
  69. package/dist/src/meter.js +0 -274
  70. package/dist/src/mind/articulation.d.ts +0 -6
  71. package/dist/src/mind/articulation.js +0 -99
  72. package/dist/src/mind/attention.d.ts +0 -430
  73. package/dist/src/mind/attention.js +0 -2418
  74. package/dist/src/mind/bridge.d.ts +0 -37
  75. package/dist/src/mind/bridge.js +0 -907
  76. package/dist/src/mind/canonical.d.ts +0 -34
  77. package/dist/src/mind/canonical.js +0 -93
  78. package/dist/src/mind/graph-search.d.ts +0 -294
  79. package/dist/src/mind/graph-search.js +0 -996
  80. package/dist/src/mind/index.d.ts +0 -9
  81. package/dist/src/mind/index.js +0 -5
  82. package/dist/src/mind/junction.d.ts +0 -137
  83. package/dist/src/mind/junction.js +0 -358
  84. package/dist/src/mind/learning.d.ts +0 -75
  85. package/dist/src/mind/learning.js +0 -265
  86. package/dist/src/mind/match.d.ts +0 -351
  87. package/dist/src/mind/match.js +0 -959
  88. package/dist/src/mind/mechanisms/alu.d.ts +0 -4
  89. package/dist/src/mind/mechanisms/alu.js +0 -36
  90. package/dist/src/mind/mechanisms/cast.d.ts +0 -89
  91. package/dist/src/mind/mechanisms/cast.js +0 -1186
  92. package/dist/src/mind/mechanisms/confluence.d.ts +0 -24
  93. package/dist/src/mind/mechanisms/confluence.js +0 -271
  94. package/dist/src/mind/mechanisms/cover.d.ts +0 -6
  95. package/dist/src/mind/mechanisms/cover.js +0 -232
  96. package/dist/src/mind/mechanisms/extraction.d.ts +0 -33
  97. package/dist/src/mind/mechanisms/extraction.js +0 -327
  98. package/dist/src/mind/mechanisms/prefix-completion.d.ts +0 -22
  99. package/dist/src/mind/mechanisms/prefix-completion.js +0 -243
  100. package/dist/src/mind/mechanisms/recall.d.ts +0 -16
  101. package/dist/src/mind/mechanisms/recall.js +0 -460
  102. package/dist/src/mind/mechanisms/reference.d.ts +0 -6
  103. package/dist/src/mind/mechanisms/reference.js +0 -296
  104. package/dist/src/mind/mind.d.ts +0 -386
  105. package/dist/src/mind/mind.js +0 -754
  106. package/dist/src/mind/pipeline-mechanism.d.ts +0 -238
  107. package/dist/src/mind/pipeline-mechanism.js +0 -622
  108. package/dist/src/mind/pipeline.d.ts +0 -49
  109. package/dist/src/mind/pipeline.js +0 -343
  110. package/dist/src/mind/primitives.d.ts +0 -85
  111. package/dist/src/mind/primitives.js +0 -333
  112. package/dist/src/mind/rationale.d.ts +0 -139
  113. package/dist/src/mind/rationale.js +0 -163
  114. package/dist/src/mind/reasoning.d.ts +0 -42
  115. package/dist/src/mind/reasoning.js +0 -305
  116. package/dist/src/mind/recognition.d.ts +0 -20
  117. package/dist/src/mind/recognition.js +0 -696
  118. package/dist/src/mind/resonance.d.ts +0 -35
  119. package/dist/src/mind/resonance.js +0 -365
  120. package/dist/src/mind/trace.d.ts +0 -15
  121. package/dist/src/mind/trace.js +0 -73
  122. package/dist/src/mind/traverse.d.ts +0 -196
  123. package/dist/src/mind/traverse.js +0 -806
  124. package/dist/src/mind/types.d.ts +0 -418
  125. package/dist/src/mind/types.js +0 -179
  126. package/dist/src/rabitq-ivf/src/database.d.ts +0 -113
  127. package/dist/src/rabitq-ivf/src/database.js +0 -201
  128. package/dist/src/rabitq-ivf/src/index.d.ts +0 -7
  129. package/dist/src/rabitq-ivf/src/index.js +0 -4
  130. package/dist/src/rabitq-ivf/src/ivf.d.ts +0 -200
  131. package/dist/src/rabitq-ivf/src/ivf.js +0 -1165
  132. package/dist/src/rabitq-ivf/src/prng.d.ts +0 -19
  133. package/dist/src/rabitq-ivf/src/prng.js +0 -36
  134. package/dist/src/rabitq-ivf/src/rabitq.d.ts +0 -95
  135. package/dist/src/rabitq-ivf/src/rabitq.js +0 -313
  136. package/dist/src/sema.d.ts +0 -41
  137. package/dist/src/sema.js +0 -77
  138. package/dist/src/store-sqlite.d.ts +0 -184
  139. package/dist/src/store-sqlite.js +0 -942
  140. package/dist/src/store.d.ts +0 -762
  141. package/dist/src/store.js +0 -1823
  142. package/dist/src/vec.d.ts +0 -31
  143. package/dist/src/vec.js +0 -109
@@ -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 {};