@hviana/sema 0.1.3 → 0.1.5
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.js +25 -25
- package/dist/example/train_base.d.ts +21 -19
- package/dist/example/train_base.js +1952 -1684
- package/dist/src/alphabet.d.ts +3 -3
- package/dist/src/alphabet.js +27 -24
- package/dist/src/alu/src/alu.d.ts +194 -169
- package/dist/src/alu/src/alu.js +414 -374
- package/dist/src/alu/src/expr.d.ts +43 -36
- package/dist/src/alu/src/expr.js +278 -252
- package/dist/src/alu/src/index.d.ts +98 -9
- package/dist/src/alu/src/index.js +63 -9
- package/dist/src/alu/src/kernel-arith.d.ts +5 -1
- package/dist/src/alu/src/kernel-arith.js +285 -195
- package/dist/src/alu/src/kernel-bits.d.ts +5 -1
- package/dist/src/alu/src/kernel-bits.js +115 -81
- package/dist/src/alu/src/kernel-logic.js +63 -33
- package/dist/src/alu/src/kernel-nd.js +195 -155
- package/dist/src/alu/src/kernel-numeric.d.ts +80 -16
- package/dist/src/alu/src/kernel-numeric.js +331 -259
- package/dist/src/alu/src/operation.d.ts +132 -112
- package/dist/src/alu/src/operation.js +163 -149
- package/dist/src/alu/src/parser.d.ts +175 -168
- package/dist/src/alu/src/parser.js +421 -382
- package/dist/src/alu/src/resonance.d.ts +25 -16
- package/dist/src/alu/src/resonance.js +56 -49
- package/dist/src/alu/src/text.d.ts +7 -3
- package/dist/src/alu/src/text.js +37 -31
- package/dist/src/alu/src/value.d.ts +14 -14
- package/dist/src/alu/src/value.js +160 -150
- package/dist/src/alu/test/alu.test.js +656 -543
- package/dist/src/bytes.d.ts +5 -1
- package/dist/src/bytes.js +40 -33
- package/dist/src/config.d.ts +102 -102
- package/dist/src/config.js +83 -83
- package/dist/src/derive/src/deduction.d.ts +62 -60
- package/dist/src/derive/src/deduction.js +109 -103
- package/dist/src/derive/src/index.d.ts +7 -1
- package/dist/src/derive/src/priority-queue.d.ts +8 -8
- package/dist/src/derive/src/priority-queue.js +61 -57
- package/dist/src/derive/src/rewrite.d.ts +18 -15
- package/dist/src/derive/src/rewrite.js +67 -59
- package/dist/src/derive/src/trie.d.ts +56 -56
- package/dist/src/derive/src/trie.js +179 -175
- package/dist/src/derive/test/derive.test.js +100 -96
- package/dist/src/extension.d.ts +16 -13
- package/dist/src/geometry.d.ts +42 -17
- package/dist/src/geometry.js +266 -235
- package/dist/src/index.d.ts +17 -2
- package/dist/src/index.js +7 -1
- package/dist/src/ingest-cache.d.ts +30 -25
- package/dist/src/ingest-cache.js +127 -108
- package/dist/src/mind/articulation.d.ts +5 -1
- package/dist/src/mind/articulation.js +112 -77
- package/dist/src/mind/attention.d.ts +108 -40
- package/dist/src/mind/attention.js +871 -749
- package/dist/src/mind/canonical.d.ts +19 -4
- package/dist/src/mind/canonical.js +31 -27
- package/dist/src/mind/graph-search.d.ts +225 -201
- package/dist/src/mind/graph-search.js +821 -742
- package/dist/src/mind/index.d.ts +10 -2
- package/dist/src/mind/junction.d.ts +58 -31
- package/dist/src/mind/junction.js +237 -172
- package/dist/src/mind/learning.d.ts +52 -16
- package/dist/src/mind/learning.js +165 -143
- package/dist/src/mind/match.d.ts +69 -20
- package/dist/src/mind/match.js +318 -259
- package/dist/src/mind/mechanisms/alu.js +16 -16
- package/dist/src/mind/mechanisms/cast.d.ts +13 -9
- package/dist/src/mind/mechanisms/cast.js +456 -363
- package/dist/src/mind/mechanisms/confluence.d.ts +12 -8
- package/dist/src/mind/mechanisms/confluence.js +183 -152
- package/dist/src/mind/mechanisms/cover.d.ts +8 -2
- package/dist/src/mind/mechanisms/cover.js +210 -148
- package/dist/src/mind/mechanisms/extraction.d.ts +34 -8
- package/dist/src/mind/mechanisms/extraction.js +288 -234
- package/dist/src/mind/mechanisms/recall.d.ts +10 -6
- package/dist/src/mind/mechanisms/recall.js +185 -126
- package/dist/src/mind/mind.d.ts +154 -129
- package/dist/src/mind/mind.js +288 -258
- package/dist/src/mind/pipeline-mechanism.d.ts +124 -112
- package/dist/src/mind/pipeline-mechanism.js +172 -161
- package/dist/src/mind/pipeline.d.ts +14 -4
- package/dist/src/mind/pipeline.js +189 -125
- package/dist/src/mind/primitives.d.ts +32 -8
- package/dist/src/mind/primitives.js +117 -99
- package/dist/src/mind/rationale.d.ts +98 -86
- package/dist/src/mind/rationale.js +121 -113
- package/dist/src/mind/reasoning.d.ts +13 -2
- package/dist/src/mind/reasoning.js +166 -129
- package/dist/src/mind/recognition.d.ts +4 -1
- package/dist/src/mind/recognition.js +208 -183
- package/dist/src/mind/resonance.d.ts +22 -5
- package/dist/src/mind/resonance.js +0 -0
- package/dist/src/mind/trace.d.ts +25 -6
- package/dist/src/mind/trace.js +58 -50
- package/dist/src/mind/traverse.d.ts +58 -16
- package/dist/src/mind/traverse.js +357 -304
- package/dist/src/mind/types.d.ts +127 -120
- package/dist/src/mind/types.js +69 -60
- package/dist/src/rabitq-hnsw/src/database.d.ts +179 -177
- package/dist/src/rabitq-hnsw/src/database.js +359 -342
- package/dist/src/rabitq-hnsw/src/heap.d.ts +12 -12
- package/dist/src/rabitq-hnsw/src/heap.js +80 -75
- package/dist/src/rabitq-hnsw/src/hnsw.d.ts +103 -103
- package/dist/src/rabitq-hnsw/src/hnsw.js +454 -428
- package/dist/src/rabitq-hnsw/src/index.d.ts +6 -1
- package/dist/src/rabitq-hnsw/src/prng.d.ts +10 -10
- package/dist/src/rabitq-hnsw/src/prng.js +27 -25
- package/dist/src/rabitq-hnsw/src/rabitq.d.ts +69 -69
- package/dist/src/rabitq-hnsw/src/rabitq.js +262 -246
- package/dist/src/rabitq-hnsw/src/store.d.ts +132 -132
- package/dist/src/rabitq-hnsw/src/store.js +843 -752
- package/dist/src/rabitq-hnsw/test/hnsw.test.js +1054 -805
- package/dist/src/sema.d.ts +35 -0
- package/dist/src/sema.js +77 -0
- package/dist/src/store-sqlite.d.ts +166 -144
- package/dist/src/store-sqlite.js +660 -578
- package/dist/src/store.d.ts +630 -593
- package/dist/src/store.js +1581 -1440
- package/dist/src/vec.d.ts +9 -5
- package/dist/src/vec.js +73 -61
- package/package.json +2 -2
- package/src/sema.ts +102 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Permutation, Vec } from "./vec.js";
|
|
2
|
+
/** The one structure. A node's vector is the gist of its whole subtree; it also
|
|
3
|
+
* carries the structure the DAG store interns — its leaf bytes, or its kids. */
|
|
4
|
+
export interface Sema {
|
|
5
|
+
v: Vec;
|
|
6
|
+
leaf: Uint8Array | null;
|
|
7
|
+
kids: Sema[] | null;
|
|
8
|
+
}
|
|
9
|
+
export declare const sema: (
|
|
10
|
+
v: Vec,
|
|
11
|
+
leaf?: Uint8Array | null,
|
|
12
|
+
kids?: Sema[] | null,
|
|
13
|
+
) => Sema;
|
|
14
|
+
/** Whether a node is a CHUNK — a leaf-parent whose children are ALL leaves,
|
|
15
|
+
* the perception tree's smallest grouped unit. The one predicate behind
|
|
16
|
+
* region collection, canonical segmentation seams, and sub-span indexing;
|
|
17
|
+
* named here beside the type so no consumer restates the shape inline. */
|
|
18
|
+
export declare const isChunk: (n: Sema) => n is Sema & {
|
|
19
|
+
kids: Sema[];
|
|
20
|
+
};
|
|
21
|
+
/** The medium: dimension, keyring, and noise source. */
|
|
22
|
+
export interface Space {
|
|
23
|
+
D: number;
|
|
24
|
+
seats: Permutation[];
|
|
25
|
+
rand: () => number;
|
|
26
|
+
maxGroup: number;
|
|
27
|
+
}
|
|
28
|
+
/** Bind one vector into a seat — the elementary half of fold. Used to index an
|
|
29
|
+
* episode from either side and to pour a partner into a form's halo. */
|
|
30
|
+
export declare const bindSeat: (space: Space, v: Vec, seat: number) => Vec;
|
|
31
|
+
/** The company signature of node `id` — the halo's pour unit (see above). */
|
|
32
|
+
export declare function companySignature(space: Space, id: number): Vec;
|
|
33
|
+
/** fold — combine ordered children into one gist.
|
|
34
|
+
* Each child is turned with its seat's own key, superposed, normalized. */
|
|
35
|
+
export declare function fold(space: Space, kids: Vec[]): Vec;
|
package/dist/src/sema.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addInto,
|
|
3
|
+
normalize,
|
|
4
|
+
permute,
|
|
5
|
+
permuteInto,
|
|
6
|
+
randomUnit,
|
|
7
|
+
rng,
|
|
8
|
+
zeros,
|
|
9
|
+
} from "./vec.js";
|
|
10
|
+
export const sema = (v, leaf = null, kids = null) => ({ v, leaf, kids });
|
|
11
|
+
/** Whether a node is a CHUNK — a leaf-parent whose children are ALL leaves,
|
|
12
|
+
* the perception tree's smallest grouped unit. The one predicate behind
|
|
13
|
+
* region collection, canonical segmentation seams, and sub-span indexing;
|
|
14
|
+
* named here beside the type so no consumer restates the shape inline. */
|
|
15
|
+
export const isChunk = (n) =>
|
|
16
|
+
n.kids !== null && n.kids.every((k) => k.kids === null);
|
|
17
|
+
// Reusable permute buffer for fold.
|
|
18
|
+
let _foldBuf = null;
|
|
19
|
+
/** Bind one vector into a seat — the elementary half of fold. Used to index an
|
|
20
|
+
* episode from either side and to pour a partner into a form's halo. */
|
|
21
|
+
export const bindSeat = (space, v, seat) => permute(v, space.seats[seat].fwd);
|
|
22
|
+
// ── Company signatures ──────────────────────────────────────────────────
|
|
23
|
+
//
|
|
24
|
+
// A halo is a superposition of EPISODE SIGNATURES: it answers "who does this
|
|
25
|
+
// form keep company with", and two forms share a concept when they keep the
|
|
26
|
+
// SAME company (the same partner nodes). Pouring the partner's raw GIST was
|
|
27
|
+
// an approximation of that: it worked while the hierarchical fold decorrelated
|
|
28
|
+
// unrelated gists quickly, but any byte-overlap between partners leaks CONTENT
|
|
29
|
+
// similarity into COMPANY similarity, silently shifting the halo null model
|
|
30
|
+
// that conceptThreshold's derivation (unrelated halos ⇒ cosine 0 ± 1/√D)
|
|
31
|
+
// depends on. A signature makes the semantics exact and fold-independent:
|
|
32
|
+
// a deterministic unit vector derived from the partner's IDENTITY, so two
|
|
33
|
+
// halos correlate exactly as much as their company overlaps — never because
|
|
34
|
+
// their partners merely contain similar bytes.
|
|
35
|
+
//
|
|
36
|
+
// Seeded by node id: ids are content-addressed mint order, stable for a given
|
|
37
|
+
// corpus (including checkpoint/resume, which re-derives identical ids), and
|
|
38
|
+
// halos are per-store training artifacts that are never compared across
|
|
39
|
+
// stores.
|
|
40
|
+
const _sigCache = new WeakMap();
|
|
41
|
+
const SIG_CACHE_MAX = 65_536;
|
|
42
|
+
/** The company signature of node `id` — the halo's pour unit (see above). */
|
|
43
|
+
export function companySignature(space, id) {
|
|
44
|
+
let cache = _sigCache.get(space);
|
|
45
|
+
if (!cache) {
|
|
46
|
+
_sigCache.set(space, cache = new Map());
|
|
47
|
+
}
|
|
48
|
+
const hit = cache.get(id);
|
|
49
|
+
if (hit) {
|
|
50
|
+
return hit;
|
|
51
|
+
}
|
|
52
|
+
const v = randomUnit(space.D, rng((id ^ 0x9e3779b9) >>> 0));
|
|
53
|
+
if (cache.size >= SIG_CACHE_MAX) {
|
|
54
|
+
cache.clear(); // flat cap; regeneration is cheap
|
|
55
|
+
}
|
|
56
|
+
cache.set(id, v);
|
|
57
|
+
return v;
|
|
58
|
+
}
|
|
59
|
+
/** fold — combine ordered children into one gist.
|
|
60
|
+
* Each child is turned with its seat's own key, superposed, normalized. */
|
|
61
|
+
export function fold(space, kids) {
|
|
62
|
+
if (kids.length > space.seats.length) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`fold: ${kids.length} children but the keyring has only ${space.seats.length} seats`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const out = zeros(space.D);
|
|
68
|
+
if (!_foldBuf || _foldBuf.length !== space.D) {
|
|
69
|
+
_foldBuf = new Float32Array(space.D);
|
|
70
|
+
}
|
|
71
|
+
const buf = _foldBuf;
|
|
72
|
+
for (let i = 0; i < kids.length; i++) {
|
|
73
|
+
permuteInto(buf, kids[i], space.seats[i].fwd);
|
|
74
|
+
addInto(out, buf);
|
|
75
|
+
}
|
|
76
|
+
return normalize(out);
|
|
77
|
+
}
|
|
@@ -1,149 +1,171 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AbstractStore,
|
|
3
|
+
type NodeId,
|
|
4
|
+
type NodeRec,
|
|
5
|
+
type Store,
|
|
6
|
+
} from "./store.js";
|
|
2
7
|
import { type StoreConfig } from "./config.js";
|
|
3
8
|
export interface SQliteStoreOptions extends Partial<StoreConfig> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
path?: string;
|
|
10
|
+
D?: number;
|
|
11
|
+
/** Fold group size used during training — tells indexSubtree how tight the
|
|
12
|
+
* reach-net epsilon should be (1 − 1/(2·maxGroup)). Defaults to the
|
|
13
|
+
* Mind's geometry.maxGroup. */
|
|
14
|
+
maxGroup?: number;
|
|
15
|
+
/** Query-side RaBitQ estimator precision for both vector indices. */
|
|
16
|
+
queryBits?: number;
|
|
12
17
|
}
|
|
13
18
|
export declare class SQliteStore extends AbstractStore implements Store {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
19
|
+
private readonly opts;
|
|
20
|
+
private readonly vectorCacheMb;
|
|
21
|
+
private readonly vectorSeed;
|
|
22
|
+
private content;
|
|
23
|
+
private halos;
|
|
24
|
+
private sqlite;
|
|
25
|
+
private _inTx;
|
|
26
|
+
private _insertNode;
|
|
27
|
+
private _insertKid;
|
|
28
|
+
private _selContain;
|
|
29
|
+
private _selParents;
|
|
30
|
+
private _selHalo;
|
|
31
|
+
private _upHalo;
|
|
32
|
+
private _selLeaf;
|
|
33
|
+
private _selFlat;
|
|
34
|
+
private _selKids;
|
|
35
|
+
private _selNode;
|
|
36
|
+
private _insertEdge;
|
|
37
|
+
private _selNext;
|
|
38
|
+
private _selPrev;
|
|
39
|
+
private _setMeta;
|
|
40
|
+
private _getMeta;
|
|
41
|
+
private _delMeta;
|
|
42
|
+
private _insSnapshot;
|
|
43
|
+
private _selSnapshot;
|
|
44
|
+
constructor(opts?: SQliteStoreOptions);
|
|
45
|
+
private vectorDbPath;
|
|
46
|
+
private openVectorDB;
|
|
47
|
+
protected _dbOpen(): Promise<void>;
|
|
48
|
+
protected _dbClose(): void;
|
|
49
|
+
protected _dbBeginTx(): void;
|
|
50
|
+
protected _dbCommitTx(): void;
|
|
51
|
+
protected _dbInsertNode(
|
|
52
|
+
id: NodeId,
|
|
53
|
+
leaf: Uint8Array | null,
|
|
54
|
+
kids: Uint8Array | null,
|
|
55
|
+
h: number,
|
|
56
|
+
): void;
|
|
57
|
+
protected _dbGetNode(id: NodeId): NodeRec | null;
|
|
58
|
+
protected _dbFindLeaf(h: number, bytes: Uint8Array): NodeId | null;
|
|
59
|
+
protected _dbFindBranchByLeaf(h: number, bytes: Uint8Array): NodeId | null;
|
|
60
|
+
protected _dbFindBranchByKids(h: number, packed: Uint8Array): NodeId | null;
|
|
61
|
+
protected _dbInsertKid(child: NodeId, parent: NodeId): void;
|
|
62
|
+
protected _dbGetParents(id: NodeId): NodeId[];
|
|
63
|
+
private _selParentsFirst;
|
|
64
|
+
protected _dbGetParentsFirst(id: NodeId, limit: number): NodeId[];
|
|
65
|
+
private _selChain;
|
|
66
|
+
/** {@link Store.chainRun}'s walk as ONE recursive CTE: the whole
|
|
67
|
+
* transparent chain (no edge in or out, exactly one parent) is descended
|
|
68
|
+
* inside SQLite — per-node work is the same three indexed probes as the
|
|
69
|
+
* base class's loop, but without a JS↔SQLite round trip per node, which
|
|
70
|
+
* dominates on the deep single-structure scaffolding this read exists
|
|
71
|
+
* for. */
|
|
72
|
+
protected _chainWalk(id: NodeId, cap: number): NodeId[];
|
|
73
|
+
/** Width of the seq band inside the packed contain rowid: rowid =
|
|
74
|
+
* child·SEQ_SPAN + seq. Page sizes are geometric, so a chain of k live
|
|
75
|
+
* pages needs a base of ≥ 2^k · 4 bytes — seq stays ≤ ~50 for any
|
|
76
|
+
* physically possible list; the append path guards the band anyway. */
|
|
77
|
+
private static readonly SEQ_SPAN;
|
|
78
|
+
private _selContainExists;
|
|
79
|
+
protected _dbContainExists(child: NodeId): boolean;
|
|
80
|
+
private _selContainPages;
|
|
81
|
+
/** The child's page directory — (seq, byte length) per page, O(log fan-in)
|
|
82
|
+
* rows, each read from the cell header without loading the blob. */
|
|
83
|
+
private containPages;
|
|
84
|
+
private _selContainPageSub;
|
|
85
|
+
private _selContainPage;
|
|
86
|
+
private containPage;
|
|
87
|
+
protected _dbGetContainParentsSlice(
|
|
88
|
+
child: NodeId,
|
|
89
|
+
offset: number,
|
|
90
|
+
limit: number,
|
|
91
|
+
): NodeId[];
|
|
92
|
+
private _selContainCount;
|
|
93
|
+
protected _dbGetContainCount(child: NodeId): number;
|
|
94
|
+
protected _dbGetContainParents(child: NodeId): NodeId[];
|
|
95
|
+
private _upsContainPage;
|
|
96
|
+
private _delContainPage;
|
|
97
|
+
protected _dbAppendContain(child: NodeId, parents: NodeId[]): void;
|
|
98
|
+
protected _dbInsertEdge(src: NodeId, dst: NodeId): void;
|
|
99
|
+
protected _dbGetNextEdges(id: NodeId): NodeId[];
|
|
100
|
+
protected _dbGetPrevEdges(id: NodeId): NodeId[];
|
|
101
|
+
private _selNextFirst;
|
|
102
|
+
protected _dbGetNextEdgesFirst(id: NodeId, limit: number): NodeId[];
|
|
103
|
+
private _selPrevFirst;
|
|
104
|
+
protected _dbGetPrevEdgesFirst(id: NodeId, limit: number): NodeId[];
|
|
105
|
+
private _selPrevCount;
|
|
106
|
+
/** {@link Store.prevCount} — one indexed COUNT over idx_edge_dst, never a
|
|
107
|
+
* row materialisation (a common continuation's reverse fan-in is
|
|
108
|
+
* corpus-sized). */
|
|
109
|
+
prevCount(id: NodeId): number;
|
|
110
|
+
private _selSrcExists;
|
|
111
|
+
protected _dbEdgeSrcExists(src: NodeId): boolean;
|
|
112
|
+
protected _dbEdgeDistinctSrcCount(): number;
|
|
113
|
+
protected _dbGetHalo(id: NodeId): {
|
|
114
|
+
vec: Uint8Array;
|
|
115
|
+
mass: number;
|
|
116
|
+
} | null;
|
|
117
|
+
protected _dbUpsertHalo(
|
|
118
|
+
id: NodeId,
|
|
119
|
+
encodedVec: Uint8Array,
|
|
120
|
+
mass: number,
|
|
121
|
+
): void;
|
|
122
|
+
protected _dbGetMeta(key: string): string | null;
|
|
123
|
+
protected _dbSetMeta(key: string, val: string): void;
|
|
124
|
+
protected _dbDeleteMeta(key: string): void;
|
|
125
|
+
protected _dbSaveSnapshot(bytes: Uint8Array): void;
|
|
126
|
+
protected _dbLoadSnapshot(): Uint8Array | null;
|
|
127
|
+
protected _vecContentUpsert(
|
|
128
|
+
entries: Array<{
|
|
129
|
+
id: NodeId;
|
|
130
|
+
vector: Float32Array;
|
|
131
|
+
ef?: number;
|
|
132
|
+
}>,
|
|
133
|
+
): void;
|
|
134
|
+
protected _vecContentQuery(v: Float32Array, k: number, ef: number): Array<{
|
|
135
|
+
id: number;
|
|
136
|
+
distance: number;
|
|
137
|
+
}>;
|
|
138
|
+
protected _vecContentHas(id: NodeId): boolean;
|
|
139
|
+
protected _vecContentSize(): number;
|
|
140
|
+
protected _vecContentLastReads(): number;
|
|
141
|
+
protected _vecContentPhysicalSize(): number;
|
|
142
|
+
protected _vecContentCompact(): void;
|
|
143
|
+
protected _vecContentDeleteMany(ids: NodeId[]): void;
|
|
144
|
+
protected _vecContentEntriesSince(after: number): IterableIterator<{
|
|
145
|
+
ext: NodeId;
|
|
146
|
+
internal: number;
|
|
147
|
+
}>;
|
|
148
|
+
/** {@link AbstractStore._dbEdgeOrHaloIds} — one C-side scan; UNION dedups
|
|
149
|
+
* and (with the ORDER BY) sorts, so the result is ready for the binary-
|
|
150
|
+
* search membership probes and the ascending-id maintenance walks. */
|
|
151
|
+
protected _dbEdgeOrHaloIds(): NodeId[];
|
|
152
|
+
protected _vecHaloUpsert(
|
|
153
|
+
entries: Array<{
|
|
154
|
+
id: NodeId;
|
|
155
|
+
vector: Float32Array;
|
|
156
|
+
}>,
|
|
157
|
+
): void;
|
|
158
|
+
protected _vecHaloQuery(v: Float32Array, k: number, ef: number): Array<{
|
|
159
|
+
id: number;
|
|
160
|
+
distance: number;
|
|
161
|
+
}>;
|
|
162
|
+
protected _vecHaloSize(): number;
|
|
163
|
+
protected _vecHaloPhysicalSize(): number;
|
|
164
|
+
protected _vecHaloCompact(): void;
|
|
165
|
+
/** Pre-fill both vector indices' RAM caches with sequential scans (up to
|
|
166
|
+
* their budget caps) — seconds of streaming instead of the minutes of
|
|
167
|
+
* random point reads a cold training/query session otherwise pays while
|
|
168
|
+
* warming. Optional; call once after open before sustained work.
|
|
169
|
+
* Returns rows warmed. */
|
|
170
|
+
warmVectorCaches(): Promise<number>;
|
|
149
171
|
}
|