@hviana/sema 0.2.6 → 0.2.8
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.
- package/dist/example/demo.d.ts +1 -0
- package/dist/example/demo.js +39 -0
- package/dist/example/train_base.d.ts +87 -0
- package/dist/example/train_base.js +2252 -0
- package/dist/src/alphabet.d.ts +7 -0
- package/dist/src/alphabet.js +33 -0
- package/dist/src/alu/src/alu.d.ts +185 -0
- package/dist/src/alu/src/alu.js +440 -0
- package/dist/src/alu/src/expr.d.ts +61 -0
- package/dist/src/alu/src/expr.js +318 -0
- package/dist/src/alu/src/index.d.ts +11 -0
- package/dist/src/alu/src/index.js +19 -0
- package/dist/src/alu/src/kernel-arith.d.ts +16 -0
- package/dist/src/alu/src/kernel-arith.js +264 -0
- package/dist/src/alu/src/kernel-bits.d.ts +19 -0
- package/dist/src/alu/src/kernel-bits.js +152 -0
- package/dist/src/alu/src/kernel-logic.d.ts +4 -0
- package/dist/src/alu/src/kernel-logic.js +60 -0
- package/dist/src/alu/src/kernel-nd.d.ts +3 -0
- package/dist/src/alu/src/kernel-nd.js +208 -0
- package/dist/src/alu/src/kernel-numeric.d.ts +54 -0
- package/dist/src/alu/src/kernel-numeric.js +366 -0
- package/dist/src/alu/src/operation.d.ts +168 -0
- package/dist/src/alu/src/operation.js +189 -0
- package/dist/src/alu/src/parser.d.ts +221 -0
- package/dist/src/alu/src/parser.js +577 -0
- package/dist/src/alu/src/resonance.d.ts +55 -0
- package/dist/src/alu/src/resonance.js +126 -0
- package/dist/src/alu/src/text.d.ts +31 -0
- package/dist/src/alu/src/text.js +73 -0
- package/dist/src/alu/src/value.d.ts +109 -0
- package/dist/src/alu/src/value.js +300 -0
- package/dist/src/alu/test/alu.test.d.ts +1 -0
- package/dist/src/alu/test/alu.test.js +764 -0
- package/dist/src/bytes.d.ts +14 -0
- package/dist/src/bytes.js +59 -0
- package/dist/src/canon.d.ts +26 -0
- package/dist/src/canon.js +57 -0
- package/dist/src/config.d.ts +111 -0
- package/dist/src/config.js +91 -0
- package/dist/src/derive/src/deduction.d.ts +125 -0
- package/dist/src/derive/src/deduction.js +155 -0
- package/dist/src/derive/src/index.d.ts +7 -0
- package/dist/src/derive/src/index.js +11 -0
- package/dist/src/derive/src/priority-queue.d.ts +20 -0
- package/dist/src/derive/src/priority-queue.js +73 -0
- package/dist/src/derive/src/rewrite.d.ts +56 -0
- package/dist/src/derive/src/rewrite.js +100 -0
- package/dist/src/derive/src/trie.d.ts +90 -0
- package/dist/src/derive/src/trie.js +217 -0
- package/dist/src/derive/test/derive.test.d.ts +1 -0
- package/dist/src/derive/test/derive.test.js +122 -0
- package/dist/src/extension.d.ts +37 -0
- package/dist/src/extension.js +7 -0
- package/dist/src/geometry.d.ts +202 -0
- package/dist/src/geometry.js +575 -0
- package/dist/src/index.d.ts +16 -0
- package/dist/src/index.js +18 -0
- package/dist/src/ingest-cache.d.ts +41 -0
- package/dist/src/ingest-cache.js +161 -0
- package/dist/src/mind/articulation.d.ts +6 -0
- package/dist/src/mind/articulation.js +99 -0
- package/dist/src/mind/attention.d.ts +405 -0
- package/dist/src/mind/attention.js +1829 -0
- package/dist/src/mind/bridge.d.ts +30 -0
- package/dist/src/mind/bridge.js +569 -0
- package/dist/src/mind/canonical.d.ts +29 -0
- package/dist/src/mind/canonical.js +88 -0
- package/dist/src/mind/graph-search.d.ts +285 -0
- package/dist/src/mind/graph-search.js +956 -0
- package/dist/src/mind/index.d.ts +7 -0
- package/dist/src/mind/index.js +5 -0
- package/dist/src/mind/junction.d.ts +124 -0
- package/dist/src/mind/junction.js +317 -0
- package/dist/src/mind/learning.d.ts +47 -0
- package/dist/src/mind/learning.js +248 -0
- package/dist/src/mind/match.d.ts +126 -0
- package/dist/src/mind/match.js +441 -0
- package/dist/src/mind/mechanisms/alu.d.ts +4 -0
- package/dist/src/mind/mechanisms/alu.js +36 -0
- package/dist/src/mind/mechanisms/cast.d.ts +89 -0
- package/dist/src/mind/mechanisms/cast.js +716 -0
- package/dist/src/mind/mechanisms/confluence.d.ts +24 -0
- package/dist/src/mind/mechanisms/confluence.js +225 -0
- package/dist/src/mind/mechanisms/cover.d.ts +6 -0
- package/dist/src/mind/mechanisms/cover.js +203 -0
- package/dist/src/mind/mechanisms/extraction.d.ts +67 -0
- package/dist/src/mind/mechanisms/extraction.js +387 -0
- package/dist/src/mind/mechanisms/recall.d.ts +13 -0
- package/dist/src/mind/mechanisms/recall.js +325 -0
- package/dist/src/mind/mind.d.ts +276 -0
- package/dist/src/mind/mind.js +572 -0
- package/dist/src/mind/pipeline-mechanism.d.ts +142 -0
- package/dist/src/mind/pipeline-mechanism.js +213 -0
- package/dist/src/mind/pipeline.d.ts +20 -0
- package/dist/src/mind/pipeline.js +217 -0
- package/dist/src/mind/primitives.d.ts +70 -0
- package/dist/src/mind/primitives.js +287 -0
- package/dist/src/mind/rationale.d.ts +139 -0
- package/dist/src/mind/rationale.js +163 -0
- package/dist/src/mind/reasoning.d.ts +34 -0
- package/dist/src/mind/reasoning.js +240 -0
- package/dist/src/mind/recognition.d.ts +20 -0
- package/dist/src/mind/recognition.js +390 -0
- package/dist/src/mind/resonance.d.ts +23 -0
- package/dist/src/mind/resonance.js +0 -0
- package/dist/src/mind/trace.d.ts +15 -0
- package/dist/src/mind/trace.js +73 -0
- package/dist/src/mind/traverse.d.ts +113 -0
- package/dist/src/mind/traverse.js +568 -0
- package/dist/src/mind/types.d.ts +289 -0
- package/dist/src/mind/types.js +130 -0
- package/dist/src/rabitq-ivf/src/database.d.ts +113 -0
- package/dist/src/rabitq-ivf/src/database.js +201 -0
- package/dist/src/rabitq-ivf/src/index.d.ts +7 -0
- package/dist/src/rabitq-ivf/src/index.js +4 -0
- package/dist/src/rabitq-ivf/src/ivf.d.ts +200 -0
- package/dist/src/rabitq-ivf/src/ivf.js +1165 -0
- package/dist/src/rabitq-ivf/src/prng.d.ts +19 -0
- package/dist/src/rabitq-ivf/src/prng.js +36 -0
- package/dist/src/rabitq-ivf/src/rabitq.d.ts +95 -0
- package/dist/src/rabitq-ivf/src/rabitq.js +283 -0
- package/dist/src/sema.d.ts +31 -0
- package/dist/src/sema.js +63 -0
- package/dist/src/store-sqlite.d.ts +184 -0
- package/dist/src/store-sqlite.js +942 -0
- package/dist/src/store.d.ts +663 -0
- package/dist/src/store.js +1618 -0
- package/dist/src/vec.d.ts +31 -0
- package/dist/src/vec.js +109 -0
- package/package.json +1 -1
- package/src/mind/attention.ts +178 -63
- package/test/51-structural-resonance-ladder.test.mjs +6 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** A half-open byte span of a query an extension computed, and the canonical
|
|
2
|
+
* result bytes it is authoritative for. */
|
|
3
|
+
export interface ComputedSpan {
|
|
4
|
+
i: number;
|
|
5
|
+
j: number;
|
|
6
|
+
bytes: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
/** The generic capabilities the mind lends every extension — nothing here
|
|
9
|
+
* names any particular extension, and every member is machinery the mind
|
|
10
|
+
* already has:
|
|
11
|
+
*
|
|
12
|
+
* MEANING (resonance and grounding — the same mechanisms recall uses):
|
|
13
|
+
* • meaningOf — which of some labelled forms does a span mean? Pure gist
|
|
14
|
+
* nearness; the extension supplies its own vocabulary and gives the answer
|
|
15
|
+
* its own reading.
|
|
16
|
+
* • continuation — the grounded form the corpus continues a form to (the
|
|
17
|
+
* continuation fixpoint recall grounds answers with), or null when the
|
|
18
|
+
* form leads nowhere. The mind answers only "where does this form lead?";
|
|
19
|
+
* what that continuation MEANS is the extension's business.
|
|
20
|
+
*
|
|
21
|
+
* GEOMETRY (the perception tree's own structure):
|
|
22
|
+
* • segment — coherent runs by the alphabet-space merge the perception tree
|
|
23
|
+
* uses, so an extension's notion of "separator" is the learnt geometry's.
|
|
24
|
+
* • reach — the river's grouping capacity (maxGroup), bounding how far apart
|
|
25
|
+
* two spans may sit and still be read as one construction. */
|
|
26
|
+
export interface ExtensionHost {
|
|
27
|
+
meaningOf(bytes: Uint8Array, anchors: ReadonlyArray<{
|
|
28
|
+
name: string;
|
|
29
|
+
form: Uint8Array;
|
|
30
|
+
}>): Promise<string | null>;
|
|
31
|
+
continuation(bytes: Uint8Array): Promise<Uint8Array | null>;
|
|
32
|
+
segment(bytes: Uint8Array): Array<{
|
|
33
|
+
i: number;
|
|
34
|
+
j: number;
|
|
35
|
+
}>;
|
|
36
|
+
reach: number;
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// extension.ts — shared types for computational extensions.
|
|
2
|
+
//
|
|
3
|
+
// Extensions (ALU, user computation packs) implement the PipelineMechanism
|
|
4
|
+
// interface (pipeline-mechanism.ts) — this file holds only the types that
|
|
5
|
+
// both the extension author and the pipeline need, without coupling either
|
|
6
|
+
// to a specific mechanism.
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { Vec } from "./vec.js";
|
|
2
|
+
import { Sema, Space } from "./sema.js";
|
|
3
|
+
import { Alphabet } from "./alphabet.js";
|
|
4
|
+
/** The store's geometric identity bar: cosine ≥ 1 − 1/√D is the similarity at
|
|
5
|
+
* which `intern` already treats two gists as the SAME node. Recall reuses it
|
|
6
|
+
* to accept a near-identical query, and the climb to accept a containing form —
|
|
7
|
+
* one derived constant, never a tuned threshold. NOTE: this fixed bar is
|
|
8
|
+
* the ESTIMATOR floor of an identity claim; a whole-span claim over a span
|
|
9
|
+
* longer than the perception quantum must use the scale-aware
|
|
10
|
+
* {@link identityBar}, which converts the tolerated fraction into bytes. */
|
|
11
|
+
export declare function mergeThreshold(D: number): number;
|
|
12
|
+
/** The scale-aware IDENTITY bar for a whole-span resonance claim over a span
|
|
13
|
+
* of `len` bytes. Under the linear fold a cosine reads "fraction of aligned
|
|
14
|
+
* shared bytes", so a FIXED cosine bar admits a byte budget that grows with
|
|
15
|
+
* the span: 1 − 1/√D over a 4·√D-byte span tolerates four whole river
|
|
16
|
+
* windows of foreign content while still claiming "near-identical". An
|
|
17
|
+
* identity claim may tolerate at most ONE river window W — the perception
|
|
18
|
+
* quantum, the same single-window budget near-dedup's differsByOneWindow
|
|
19
|
+
* grants — so the bar is 1 − W/len, floored at mergeThreshold(D), below
|
|
20
|
+
* which the RaBitQ estimator cannot certify identity anyway. This is the
|
|
21
|
+
* angle+magnitude form of the identity test: the ANGLE carries the shared
|
|
22
|
+
* fraction, the span's MAGNITUDE (√len, the linear fold's own norm) converts
|
|
23
|
+
* the tolerated fraction into tolerated bytes. Derived from W, D and the
|
|
24
|
+
* span; never tuned. */
|
|
25
|
+
export declare function identityBar(D: number, maxGroup: number, len: number): number;
|
|
26
|
+
/** The reach bar: half a river quantum, derived from the fold's own geometry.
|
|
27
|
+
* A branch folds up to `maxGroup` children, so two forms that differ in ONE
|
|
28
|
+
* whole child — the smallest distinction perception can mean — sit at cosine
|
|
29
|
+
* ≈ 1 − 1/maxGroup. Half that quantum, 1 − 1/(2·maxGroup), is closer than any
|
|
30
|
+
* single-child difference can be: a positional echo of the same content.
|
|
31
|
+
*
|
|
32
|
+
* Recall uses this as its confidence floor: a query whose nearest resonant
|
|
33
|
+
* form sits below this bar is structurally unrelated to everything in the store
|
|
34
|
+
* — further than any single-child variant — and the system returns null rather
|
|
35
|
+
* than fabricate an answer from an unrelated form. Derived, never tuned. */
|
|
36
|
+
export declare function reachThreshold(maxGroup: number): number;
|
|
37
|
+
/** The estimator's own noise floor: 1/√D — ONE standard deviation of the
|
|
38
|
+
* cosine between two independent random vectors in D dimensions (the same σ
|
|
39
|
+
* {@link significanceBar} takes three of). It is the smallest difference in
|
|
40
|
+
* cosine that is distinguishable from the rotation-uniformised RaBitQ
|
|
41
|
+
* estimation error (see the MEASUREMENT CAVEAT above): a contrastive margin
|
|
42
|
+
* below it is quantisation noise, not evidence. The consensus climb gates a
|
|
43
|
+
* region's vote on its discriminative margin clearing this floor — the
|
|
44
|
+
* minimal "above noise" bar, one σ, not the stricter 3σ relatedness bar.
|
|
45
|
+
* Derived, never tuned. */
|
|
46
|
+
export declare function estimatorNoise(D: number): number;
|
|
47
|
+
/** The statistical-significance bar for whole-query resonance: 3/√D.
|
|
48
|
+
* In D dimensions the expected cosine of two independent random vectors is 0
|
|
49
|
+
* with standard deviation 1/√D. A cosine ≥ 3/√D is three standard deviations
|
|
50
|
+
* above chance — the query is statistically related to the store, not merely
|
|
51
|
+
* sharing random byte noise. Below this bar the consensus climb (which trusts
|
|
52
|
+
* sub-region resonance) is skipped: there is no evidence the query belongs to
|
|
53
|
+
* the same distribution as the stored content. Derived, never tuned. */
|
|
54
|
+
export declare function significanceBar(D: number): number;
|
|
55
|
+
/** The concept (halo) threshold: the cosine above which two nodes share a
|
|
56
|
+
* distributional concept. A halo is a superposition of episode signatures in
|
|
57
|
+
* D-dimensional space, so the expected cosine between two unrelated halos is 0
|
|
58
|
+
* with standard deviation 1/√D. The structural midpoint 0.5 separates "more
|
|
59
|
+
* similar than not" from noise; the +0.5/√D term adds one half-sigma margin
|
|
60
|
+
* that vanishes as D → ∞, accounting for the wider noise band at lower D
|
|
61
|
+
* without inventing a tuned constant. At D=1024 this gives 0.516, within
|
|
62
|
+
* 3% of 0.5 — existing behavior is preserved while threshold and D move
|
|
63
|
+
* together. Derived, never tuned. */
|
|
64
|
+
export declare function conceptThreshold(D: number): number;
|
|
65
|
+
/** The HALF-DOMINANCE predicate: whether a part covering `partLen` of a
|
|
66
|
+
* whole of `wholeLen` covers STRICTLY more than half of it. A span that
|
|
67
|
+
* dominates its whole can no longer discriminate the whole's own content —
|
|
68
|
+
* the one test behind liftAnswer's keep-the-frame rule, collectRegions'
|
|
69
|
+
* wrapper exclusion, and CAST's frame-depth majority (each cites this).
|
|
70
|
+
* CAST's frame-FRACTION gate is the deliberately CLOSED variant (≥ ½ is
|
|
71
|
+
* already unusable there) and stays inline where it is documented.
|
|
72
|
+
* Derived from the structural midpoint, never tuned. */
|
|
73
|
+
export declare function dominates(partLen: number, wholeLen: number): boolean;
|
|
74
|
+
/** The consensus-vote significance floor: ln(N) + 1/2, where N is the number
|
|
75
|
+
* of learnt contexts (edge sources). A single region's IDF-weighted vote for
|
|
76
|
+
* an anchor reached through c contexts is at most ln(N/c) ≤ ln(N); the +1/2
|
|
77
|
+
* demands the pooled vote exceed what ONE maximally-specific region could
|
|
78
|
+
* contribute by half a unit — i.e. genuine corroboration beyond a lone
|
|
79
|
+
* region's echo at this corpus scale. The ONE floor both consumers gate on:
|
|
80
|
+
* recallByResonance trusting a climb anchor, and commitVotes admitting a
|
|
81
|
+
* further point of attention. Defined once here so the two can never
|
|
82
|
+
* drift apart. Derived from N, never tuned. */
|
|
83
|
+
export declare function consensusFloor(N: number): number;
|
|
84
|
+
/** The coverage bar for the reach (interior) index, when vector-similarity
|
|
85
|
+
* gating is used. Returns the concept threshold — the structural midpoint
|
|
86
|
+
* (~0.5 at D=1024) where two forms are "more similar than not."
|
|
87
|
+
*
|
|
88
|
+
* Currently UNUSED in the hot training path: interior nodes are indexed
|
|
89
|
+
* unconditionally (hash-cons dedup bounds the index naturally).
|
|
90
|
+
* Post-hoc structural compaction ({@link Store.compactContentIndex})
|
|
91
|
+
* replaces runtime coverage gating with a batch pass that removes
|
|
92
|
+
* structurally-isolated entries. Derived, never tuned. */
|
|
93
|
+
export declare function coverageBar(_maxGroup: number, D: number): number;
|
|
94
|
+
export interface Folded {
|
|
95
|
+
tree: Sema;
|
|
96
|
+
/** Byte length of the subtree — carried incrementally so the stable-prefix
|
|
97
|
+
* boundary scan never re-walks subtrees (the old per-level walk was
|
|
98
|
+
* O(n log n) over the whole input). */
|
|
99
|
+
len: number;
|
|
100
|
+
}
|
|
101
|
+
export interface Grid {
|
|
102
|
+
width: number;
|
|
103
|
+
height: number;
|
|
104
|
+
channels: number;
|
|
105
|
+
data: Uint8Array;
|
|
106
|
+
dims?: number[];
|
|
107
|
+
}
|
|
108
|
+
/** Find the longest prefix of `bytes` whose leaf-id signature matches a
|
|
109
|
+
* known branch via `lookup`. Returns the byte-length of that prefix, or 0. */
|
|
110
|
+
export declare function knownPrefixLength(bytes: Uint8Array, leafAt: (i: number) => number | null, lookup: (leafIds: number[]) => number | null): number;
|
|
111
|
+
/** Bytes → Sema tree. `leafAt` and `lookup` are store capabilities for
|
|
112
|
+
* detecting previously-stored prefixes so the river can split at the
|
|
113
|
+
* correct boundary. Pass them through from `perceive`; the geometry
|
|
114
|
+
* computes the stable prefix internally.
|
|
115
|
+
*
|
|
116
|
+
* `boundaries` is the CALLER-computed stable-prefix boundary set (§10.3):
|
|
117
|
+
* strictly-increasing proper byte offsets, each the length of a prefix that
|
|
118
|
+
* is already a stored whole-stream form. When given, the fold splits into
|
|
119
|
+
* the segments between consecutive boundaries — each folded independently,
|
|
120
|
+
* exactly as it folded when it was learned — and the segment roots join
|
|
121
|
+
* LEFT-NESTED (((s₀·s₁)·s₂)…), so every learnt cumulative-context root
|
|
122
|
+
* reappears as an identical subtree (and, by hash-consing, the very same
|
|
123
|
+
* node) inside the grown stream. This is what lets a conversation's next
|
|
124
|
+
* turn extend perception instead of refolding it: identical prefixes
|
|
125
|
+
* produce identical subtrees regardless of what follows them. */
|
|
126
|
+
export declare function bytesToTree(space: Space, alphabet: Alphabet, bytes: Uint8Array, leafAt?: (i: number) => number | null, lookup?: (leafIds: number[]) => number | null, boundaries?: readonly number[]): Sema;
|
|
127
|
+
/** A stable-prefix fold's reusable state: the segment edge offsets and each
|
|
128
|
+
* segment's independently-folded root ({@link riverFoldRaw} output). A
|
|
129
|
+
* grown stream whose boundary set EXTENDS a previous fold's reuses every
|
|
130
|
+
* matching segment's Folded unchanged (segments fold independently by
|
|
131
|
+
* construction, so reuse is bit-identical to refolding) and folds only the
|
|
132
|
+
* new right-edge segment — O(turn) per extension, the stable-prefix
|
|
133
|
+
* counterpart of {@link FoldPyramid}. Purely a cache: the produced tree
|
|
134
|
+
* never depends on cache state. */
|
|
135
|
+
export interface StableFold {
|
|
136
|
+
edges: number[];
|
|
137
|
+
segs: Folded[];
|
|
138
|
+
}
|
|
139
|
+
/** {@link stablePrefixFold} with incremental segment reuse — same cuts, same
|
|
140
|
+
* segment folds, same left-nested join, same single root normalize; `prev`
|
|
141
|
+
* only elides recomputing segments whose [start,end) offsets it already
|
|
142
|
+
* folded over a byte-identical prefix (the caller keys the cache by
|
|
143
|
+
* content). Requires a non-empty effective boundary set. */
|
|
144
|
+
export declare function stablePrefixFoldIncremental(space: Space, alphabet: Alphabet, bytes: Uint8Array, boundaries: readonly number[], prev?: StableFold): {
|
|
145
|
+
tree: Sema;
|
|
146
|
+
fold: StableFold;
|
|
147
|
+
};
|
|
148
|
+
/** Plain river fold WITHOUT the final root normalize — the segment-level
|
|
149
|
+
* building block of {@link stablePrefixFold} (interiors must keep their
|
|
150
|
+
* byte-proportional magnitude; only the whole perception's root is ever
|
|
151
|
+
* normalized). Exported so callers that COMPOSE already-existing structural
|
|
152
|
+
* parts into a hypothetical synthetic root (see {@link composeStructuralGist})
|
|
153
|
+
* can feed the same raw primitive instead of duplicating its mathematics. */
|
|
154
|
+
export declare function riverFoldRaw(space: Space, row: Folded[]): Folded;
|
|
155
|
+
/** One already-existing structural vector to compose, paired with the byte
|
|
156
|
+
* span (query-slot) length it stands in for. `len`, not the vector's own
|
|
157
|
+
* magnitude, is what {@link composeStructuralGist} restores — the composed
|
|
158
|
+
* slot's NATURAL span, exactly as the linear river fold would carry it. */
|
|
159
|
+
export interface StructuralPart {
|
|
160
|
+
v: Vec;
|
|
161
|
+
len: number;
|
|
162
|
+
}
|
|
163
|
+
/** Synthesize a hypothetical internal structure from already-existing
|
|
164
|
+
* structural vectors — NOT from bytes. This is the raw positional
|
|
165
|
+
* composition the linear river fold already uses (see the folding header
|
|
166
|
+
* above): each part is positionally bound into its own seat, its natural
|
|
167
|
+
* span magnitude is preserved, the parts are linearly superposed, and only
|
|
168
|
+
* the final synthetic root is normalized. It never calls {@link gistOf}
|
|
169
|
+
* (there is no `gistOf` here — geometry.ts has no store), never perceives a
|
|
170
|
+
* concatenated byte string, and never interns or stores a new node: the
|
|
171
|
+
* result is an opaque, ungrounded Vec for an ANN probe only. */
|
|
172
|
+
export declare function composeStructuralGist(space: Space, parts: readonly StructuralPart[]): Vec;
|
|
173
|
+
/** The PLAIN fold's full level pyramid — every level's item list, bottom
|
|
174
|
+
* (leaves) to top (root). Left-grouped folding is RADIX-ALIGNED: the item
|
|
175
|
+
* at level L, index i, covers exactly bytes [i·mg^L, (i+1)·mg^L) whenever
|
|
176
|
+
* it is a FULL block, and a full block folds bit-identically in ANY byte
|
|
177
|
+
* string that contains it at that offset. So a string extended by a
|
|
178
|
+
* suffix (a conversation's accumulated context) reuses every full block of
|
|
179
|
+
* its prefix's pyramid and refolds only the right edge of each level —
|
|
180
|
+
* O(suffix + depth·mg) per extension instead of O(whole), with the
|
|
181
|
+
* produced tree BIT-IDENTICAL to a from-scratch plain fold (same nodes,
|
|
182
|
+
* same FP ops; reused subtrees are shared objects, and Sema nodes are
|
|
183
|
+
* never mutated). Purely an implementation cache: structure and numerics
|
|
184
|
+
* never depend on whether a pyramid was available. */
|
|
185
|
+
export interface FoldPyramid {
|
|
186
|
+
levels: Array<Array<{
|
|
187
|
+
tree: Sema;
|
|
188
|
+
len: number;
|
|
189
|
+
}>>;
|
|
190
|
+
bytes: number;
|
|
191
|
+
}
|
|
192
|
+
/** Plain bytes→tree (identical to capability-less {@link bytesToTree}) that
|
|
193
|
+
* also RETURNS its pyramid, reusing `prev` — the pyramid of a PROPER
|
|
194
|
+
* prefix of `bytes` (caller guarantees content match and
|
|
195
|
+
* prev.bytes < bytes.length). */
|
|
196
|
+
export declare function bytesToTreePyramid(space: Space, alphabet: Alphabet, bytes: Uint8Array, prev?: FoldPyramid): {
|
|
197
|
+
tree: Sema;
|
|
198
|
+
pyramid: FoldPyramid;
|
|
199
|
+
};
|
|
200
|
+
export declare function hilbertBytes(grid: Grid): Uint8Array;
|
|
201
|
+
export declare function gridToTree(space: Space, alphabet: Alphabet, grid: Grid): Sema;
|
|
202
|
+
export declare function stackGrids(frames: Grid[]): Grid;
|