@hviana/sema 0.2.4 → 0.2.6
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/package.json +1 -1
- package/src/geometry.ts +52 -3
- package/src/mind/attention.ts +1469 -120
- package/src/mind/index.ts +16 -0
- package/src/mind/junction.ts +125 -16
- package/src/mind/mind.ts +15 -0
- package/src/mind/rationale.ts +12 -4
- package/src/mind/traverse.ts +75 -7
- package/src/mind/types.ts +25 -0
- package/test/51-structural-resonance-ladder.test.mjs +552 -0
- package/test/52-climb-consensus-instrumentation.test.mjs +324 -0
- package/test/53-cross-region-probe-instrumentation.test.mjs +356 -0
- package/dist/example/demo.d.ts +0 -1
- package/dist/example/demo.js +0 -39
- package/dist/example/train_base.d.ts +0 -87
- package/dist/example/train_base.js +0 -2252
- package/dist/src/alphabet.d.ts +0 -7
- package/dist/src/alphabet.js +0 -33
- package/dist/src/alu/src/alu.d.ts +0 -185
- package/dist/src/alu/src/alu.js +0 -440
- package/dist/src/alu/src/expr.d.ts +0 -61
- package/dist/src/alu/src/expr.js +0 -318
- package/dist/src/alu/src/index.d.ts +0 -11
- package/dist/src/alu/src/index.js +0 -19
- package/dist/src/alu/src/kernel-arith.d.ts +0 -16
- package/dist/src/alu/src/kernel-arith.js +0 -264
- package/dist/src/alu/src/kernel-bits.d.ts +0 -19
- package/dist/src/alu/src/kernel-bits.js +0 -152
- package/dist/src/alu/src/kernel-logic.d.ts +0 -4
- package/dist/src/alu/src/kernel-logic.js +0 -60
- package/dist/src/alu/src/kernel-nd.d.ts +0 -3
- package/dist/src/alu/src/kernel-nd.js +0 -208
- package/dist/src/alu/src/kernel-numeric.d.ts +0 -54
- package/dist/src/alu/src/kernel-numeric.js +0 -366
- package/dist/src/alu/src/operation.d.ts +0 -168
- package/dist/src/alu/src/operation.js +0 -189
- package/dist/src/alu/src/parser.d.ts +0 -221
- package/dist/src/alu/src/parser.js +0 -577
- package/dist/src/alu/src/resonance.d.ts +0 -55
- package/dist/src/alu/src/resonance.js +0 -126
- package/dist/src/alu/src/text.d.ts +0 -31
- package/dist/src/alu/src/text.js +0 -73
- package/dist/src/alu/src/value.d.ts +0 -109
- package/dist/src/alu/src/value.js +0 -300
- package/dist/src/alu/test/alu.test.d.ts +0 -1
- package/dist/src/alu/test/alu.test.js +0 -764
- package/dist/src/bytes.d.ts +0 -14
- package/dist/src/bytes.js +0 -59
- package/dist/src/canon.d.ts +0 -26
- package/dist/src/canon.js +0 -57
- package/dist/src/config.d.ts +0 -111
- package/dist/src/config.js +0 -91
- package/dist/src/derive/src/deduction.d.ts +0 -125
- package/dist/src/derive/src/deduction.js +0 -155
- package/dist/src/derive/src/index.d.ts +0 -7
- package/dist/src/derive/src/index.js +0 -11
- package/dist/src/derive/src/priority-queue.d.ts +0 -20
- package/dist/src/derive/src/priority-queue.js +0 -73
- package/dist/src/derive/src/rewrite.d.ts +0 -56
- package/dist/src/derive/src/rewrite.js +0 -100
- package/dist/src/derive/src/trie.d.ts +0 -90
- package/dist/src/derive/src/trie.js +0 -217
- package/dist/src/derive/test/derive.test.d.ts +0 -1
- package/dist/src/derive/test/derive.test.js +0 -122
- package/dist/src/extension.d.ts +0 -37
- package/dist/src/extension.js +0 -7
- package/dist/src/geometry.d.ts +0 -176
- package/dist/src/geometry.js +0 -546
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -18
- package/dist/src/ingest-cache.d.ts +0 -41
- package/dist/src/ingest-cache.js +0 -161
- package/dist/src/mind/articulation.d.ts +0 -6
- package/dist/src/mind/articulation.js +0 -99
- package/dist/src/mind/attention.d.ts +0 -88
- package/dist/src/mind/attention.js +0 -997
- package/dist/src/mind/bridge.d.ts +0 -30
- package/dist/src/mind/bridge.js +0 -569
- package/dist/src/mind/canonical.d.ts +0 -29
- package/dist/src/mind/canonical.js +0 -88
- package/dist/src/mind/graph-search.d.ts +0 -285
- package/dist/src/mind/graph-search.js +0 -956
- package/dist/src/mind/index.d.ts +0 -5
- package/dist/src/mind/index.js +0 -5
- package/dist/src/mind/junction.d.ts +0 -95
- package/dist/src/mind/junction.js +0 -262
- package/dist/src/mind/learning.d.ts +0 -47
- package/dist/src/mind/learning.js +0 -248
- package/dist/src/mind/match.d.ts +0 -126
- package/dist/src/mind/match.js +0 -441
- package/dist/src/mind/mechanisms/alu.d.ts +0 -4
- package/dist/src/mind/mechanisms/alu.js +0 -36
- package/dist/src/mind/mechanisms/cast.d.ts +0 -89
- package/dist/src/mind/mechanisms/cast.js +0 -716
- package/dist/src/mind/mechanisms/confluence.d.ts +0 -24
- package/dist/src/mind/mechanisms/confluence.js +0 -225
- package/dist/src/mind/mechanisms/cover.d.ts +0 -6
- package/dist/src/mind/mechanisms/cover.js +0 -203
- package/dist/src/mind/mechanisms/extraction.d.ts +0 -67
- package/dist/src/mind/mechanisms/extraction.js +0 -387
- package/dist/src/mind/mechanisms/recall.d.ts +0 -13
- package/dist/src/mind/mechanisms/recall.js +0 -325
- package/dist/src/mind/mind.d.ts +0 -274
- package/dist/src/mind/mind.js +0 -572
- package/dist/src/mind/pipeline-mechanism.d.ts +0 -142
- package/dist/src/mind/pipeline-mechanism.js +0 -213
- package/dist/src/mind/pipeline.d.ts +0 -20
- package/dist/src/mind/pipeline.js +0 -217
- package/dist/src/mind/primitives.d.ts +0 -70
- package/dist/src/mind/primitives.js +0 -287
- package/dist/src/mind/rationale.d.ts +0 -134
- package/dist/src/mind/rationale.js +0 -162
- package/dist/src/mind/reasoning.d.ts +0 -34
- package/dist/src/mind/reasoning.js +0 -240
- package/dist/src/mind/recognition.d.ts +0 -20
- package/dist/src/mind/recognition.js +0 -390
- package/dist/src/mind/resonance.d.ts +0 -23
- package/dist/src/mind/resonance.js +0 -0
- package/dist/src/mind/trace.d.ts +0 -15
- package/dist/src/mind/trace.js +0 -73
- package/dist/src/mind/traverse.d.ts +0 -113
- package/dist/src/mind/traverse.js +0 -504
- package/dist/src/mind/types.d.ts +0 -271
- package/dist/src/mind/types.js +0 -130
- package/dist/src/rabitq-ivf/src/database.d.ts +0 -113
- package/dist/src/rabitq-ivf/src/database.js +0 -201
- package/dist/src/rabitq-ivf/src/index.d.ts +0 -7
- package/dist/src/rabitq-ivf/src/index.js +0 -4
- package/dist/src/rabitq-ivf/src/ivf.d.ts +0 -200
- package/dist/src/rabitq-ivf/src/ivf.js +0 -1165
- package/dist/src/rabitq-ivf/src/prng.d.ts +0 -19
- package/dist/src/rabitq-ivf/src/prng.js +0 -36
- package/dist/src/rabitq-ivf/src/rabitq.d.ts +0 -95
- package/dist/src/rabitq-ivf/src/rabitq.js +0 -283
- package/dist/src/sema.d.ts +0 -31
- package/dist/src/sema.js +0 -63
- package/dist/src/store-sqlite.d.ts +0 -184
- package/dist/src/store-sqlite.js +0 -942
- package/dist/src/store.d.ts +0 -663
- package/dist/src/store.js +0 -1618
- package/dist/src/vec.d.ts +0 -31
- package/dist/src/vec.js +0 -109
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { AbstractStore, type NodeId, type NodeRec, type Store } from "./store.js";
|
|
2
|
-
import { type StoreConfig } from "./config.js";
|
|
3
|
-
export interface SQliteStoreOptions extends Partial<StoreConfig> {
|
|
4
|
-
path?: string;
|
|
5
|
-
D?: number;
|
|
6
|
-
/** Fold group size used during training — tells indexSubtree how tight the
|
|
7
|
-
* reach-net epsilon should be (1 − 1/(2·maxGroup)). Defaults to the
|
|
8
|
-
* Mind's geometry.maxGroup. */
|
|
9
|
-
maxGroup?: number;
|
|
10
|
-
/** Query-side RaBitQ estimator precision for both vector indices. */
|
|
11
|
-
queryBits?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class SQliteStore extends AbstractStore implements Store {
|
|
14
|
-
private readonly opts;
|
|
15
|
-
private readonly vectorCacheMb;
|
|
16
|
-
private readonly sqliteCacheMb;
|
|
17
|
-
private readonly vectorSeed;
|
|
18
|
-
private content;
|
|
19
|
-
private halos;
|
|
20
|
-
private sqlite;
|
|
21
|
-
private _inTx;
|
|
22
|
-
/** Bloom filter over every node row's content hash `h`. The dedup probes
|
|
23
|
-
* consult it first: "definitely absent" answers the training hot path's
|
|
24
|
-
* dominant miss case in RAM (profiled: the SQLite probes were 38.7% of
|
|
25
|
-
* ingest wall at 2.9M nodes). INVARIANT: every inserted h is added
|
|
26
|
-
* before the probe that could see it — a false negative would mint a
|
|
27
|
-
* duplicate node and silently break hash-consing. */
|
|
28
|
-
private _bloom;
|
|
29
|
-
/** Dedup probes answered by the filter alone this session (observability). */
|
|
30
|
-
bloomSkips: number;
|
|
31
|
-
private _insertNode;
|
|
32
|
-
private _insertKid;
|
|
33
|
-
private _selContain;
|
|
34
|
-
private _selParents;
|
|
35
|
-
private _selHalo;
|
|
36
|
-
private _upHalo;
|
|
37
|
-
private _selLeaf;
|
|
38
|
-
private _selFlat;
|
|
39
|
-
private _selKids;
|
|
40
|
-
private _selNode;
|
|
41
|
-
private _insertEdge;
|
|
42
|
-
private _selNext;
|
|
43
|
-
private _selPrev;
|
|
44
|
-
private _setMeta;
|
|
45
|
-
private _getMeta;
|
|
46
|
-
private _insCanon;
|
|
47
|
-
private _selCanon;
|
|
48
|
-
private _cntCanon;
|
|
49
|
-
private _selContentFrom;
|
|
50
|
-
private _delMeta;
|
|
51
|
-
private _insSnapshot;
|
|
52
|
-
private _selSnapshot;
|
|
53
|
-
constructor(opts?: SQliteStoreOptions);
|
|
54
|
-
private vectorDbPath;
|
|
55
|
-
private openVectorDB;
|
|
56
|
-
protected _dbOpen(): Promise<void>;
|
|
57
|
-
/** Restore the persisted filter and top up the rows a crash left uncovered
|
|
58
|
-
* (id ≥ stored `upto`); a missing/undersized blob forces a full rebuild.
|
|
59
|
-
* Clean-close sessions restart with a 0-row top-up. */
|
|
60
|
-
private _bloomLoad;
|
|
61
|
-
/** Re-add the hashes of rows with id ≥ `from` (the tail a crash cut off).
|
|
62
|
-
* Re-adding a hash twice only re-sets its bits — never a correctness
|
|
63
|
-
* issue — so overlap with the persisted coverage is harmless. */
|
|
64
|
-
private _bloomTopUp;
|
|
65
|
-
/** Build a fresh filter sized for the current node count from one
|
|
66
|
-
* sequential scan of the h column. Called at open when no usable blob is
|
|
67
|
-
* stored, and again whenever growth saturates the bits-per-key budget. */
|
|
68
|
-
private _bloomRebuild;
|
|
69
|
-
/** Persist the filter with its coverage watermark. Runs inside the
|
|
70
|
-
* caller's transaction when one is open (checkpoint/close both flush
|
|
71
|
-
* first). */
|
|
72
|
-
private _bloomPersist;
|
|
73
|
-
protected _dbClose(): void;
|
|
74
|
-
protected _dbBeginTx(): void;
|
|
75
|
-
protected _dbCommitTx(): void;
|
|
76
|
-
protected _dbInsertNode(id: NodeId, leaf: Uint8Array | null, kids: Uint8Array | null, h: number): void;
|
|
77
|
-
protected _dbGetNode(id: NodeId): NodeRec | null;
|
|
78
|
-
protected _dbFindLeaf(h: number, bytes: Uint8Array): NodeId | null;
|
|
79
|
-
protected _dbFindBranchByLeaf(h: number, bytes: Uint8Array): NodeId | null;
|
|
80
|
-
protected _dbFindBranchByKids(h: number, packed: Uint8Array): NodeId | null;
|
|
81
|
-
protected _dbInsertKid(child: NodeId, parent: NodeId): void;
|
|
82
|
-
protected _dbGetParents(id: NodeId): NodeId[];
|
|
83
|
-
private _selParentsFirst;
|
|
84
|
-
protected _dbGetParentsFirst(id: NodeId, limit: number): NodeId[];
|
|
85
|
-
private _selChain;
|
|
86
|
-
/** {@link Store.chainRun}'s walk as ONE recursive CTE: the whole
|
|
87
|
-
* transparent chain (no edge in or out, exactly one parent) is descended
|
|
88
|
-
* inside SQLite — per-node work is the same three indexed probes as the
|
|
89
|
-
* base class's loop, but without a JS↔SQLite round trip per node, which
|
|
90
|
-
* dominates on the deep single-structure scaffolding this read exists
|
|
91
|
-
* for. */
|
|
92
|
-
protected _chainWalk(id: NodeId, cap: number): NodeId[];
|
|
93
|
-
/** Width of the seq band inside the packed contain rowid: rowid =
|
|
94
|
-
* child·SEQ_SPAN + seq. Page sizes are geometric, so a chain of k live
|
|
95
|
-
* pages needs a base of ≥ 2^k · 4 bytes — seq stays ≤ ~50 for any
|
|
96
|
-
* physically possible list; the append path guards the band anyway. */
|
|
97
|
-
private static readonly SEQ_SPAN;
|
|
98
|
-
private _selContainExists;
|
|
99
|
-
protected _dbContainExists(child: NodeId): boolean;
|
|
100
|
-
private _selContainPages;
|
|
101
|
-
/** The child's page directory — (seq, byte length) per page, O(log fan-in)
|
|
102
|
-
* rows, each read from the cell header without loading the blob. */
|
|
103
|
-
private containPages;
|
|
104
|
-
private _selContainPageSub;
|
|
105
|
-
private _selContainPage;
|
|
106
|
-
private containPage;
|
|
107
|
-
protected _dbGetContainParentsSlice(child: NodeId, offset: number, limit: number): NodeId[];
|
|
108
|
-
private _selContainCount;
|
|
109
|
-
protected _dbGetContainCount(child: NodeId): number;
|
|
110
|
-
protected _dbGetContainParents(child: NodeId): NodeId[];
|
|
111
|
-
private _upsContainPage;
|
|
112
|
-
private _delContainPage;
|
|
113
|
-
protected _dbAppendContain(child: NodeId, parents: NodeId[]): void;
|
|
114
|
-
protected _dbInsertEdge(src: NodeId, dst: NodeId): void;
|
|
115
|
-
protected _dbGetNextEdges(id: NodeId): NodeId[];
|
|
116
|
-
protected _dbGetPrevEdges(id: NodeId): NodeId[];
|
|
117
|
-
private _selNextFirst;
|
|
118
|
-
protected _dbGetNextEdgesFirst(id: NodeId, limit: number): NodeId[];
|
|
119
|
-
private _selPrevFirst;
|
|
120
|
-
protected _dbGetPrevEdgesFirst(id: NodeId, limit: number): NodeId[];
|
|
121
|
-
private _selPrevCount;
|
|
122
|
-
/** {@link Store.prevCount} — one indexed COUNT over idx_edge_dst, never a
|
|
123
|
-
* row materialisation (a common continuation's reverse fan-in is
|
|
124
|
-
* corpus-sized). */
|
|
125
|
-
prevCount(id: NodeId): number;
|
|
126
|
-
private _selSrcExists;
|
|
127
|
-
protected _dbEdgeSrcExists(src: NodeId): boolean;
|
|
128
|
-
protected _dbEdgeDistinctSrcCount(): number;
|
|
129
|
-
protected _dbGetHalo(id: NodeId): {
|
|
130
|
-
vec: Uint8Array;
|
|
131
|
-
mass: number;
|
|
132
|
-
} | null;
|
|
133
|
-
protected _dbUpsertHalo(id: NodeId, encodedVec: Uint8Array, mass: number): void;
|
|
134
|
-
protected _dbGetMeta(key: string): string | null;
|
|
135
|
-
protected _dbSetMeta(key: string, val: string): void;
|
|
136
|
-
protected _dbDeleteMeta(key: string): void;
|
|
137
|
-
canonAdd(h: number, id: number): void;
|
|
138
|
-
canonFind(h: number): number[];
|
|
139
|
-
canonCount(): number;
|
|
140
|
-
eachContent(cb: (id: number, bytes: Uint8Array) => void, fromId?: number): void;
|
|
141
|
-
protected _dbSaveSnapshot(bytes: Uint8Array): void;
|
|
142
|
-
protected _dbLoadSnapshot(): Uint8Array | null;
|
|
143
|
-
protected _vecContentUpsert(entries: Array<{
|
|
144
|
-
id: NodeId;
|
|
145
|
-
vector: Float32Array;
|
|
146
|
-
}>): void;
|
|
147
|
-
protected _vecContentQuery(v: Float32Array, k: number, ef: number): Array<{
|
|
148
|
-
id: number;
|
|
149
|
-
distance: number;
|
|
150
|
-
}>;
|
|
151
|
-
protected _vecContentHas(id: NodeId): boolean;
|
|
152
|
-
protected _vecContentSize(): number;
|
|
153
|
-
protected _vecContentLastReads(): number;
|
|
154
|
-
protected _vecContentPhysicalSize(): number;
|
|
155
|
-
protected _vecContentClusterCount(): number;
|
|
156
|
-
protected _vecContentCompact(): void;
|
|
157
|
-
protected _vecContentDeleteMany(ids: NodeId[]): void;
|
|
158
|
-
protected _vecContentEntriesSince(after: number): IterableIterator<{
|
|
159
|
-
ext: NodeId;
|
|
160
|
-
internal: number;
|
|
161
|
-
}>;
|
|
162
|
-
/** {@link AbstractStore._dbEdgeOrHaloIds} — one C-side scan; UNION dedups
|
|
163
|
-
* and (with the ORDER BY) sorts, so the result is ready for the binary-
|
|
164
|
-
* search membership probes and the ascending-id maintenance walks. */
|
|
165
|
-
protected _dbEdgeOrHaloIds(): NodeId[];
|
|
166
|
-
protected _vecHaloUpsert(entries: Array<{
|
|
167
|
-
id: NodeId;
|
|
168
|
-
vector: Float32Array;
|
|
169
|
-
}>): void;
|
|
170
|
-
protected _vecHaloQuery(v: Float32Array, k: number, ef: number): Array<{
|
|
171
|
-
id: number;
|
|
172
|
-
distance: number;
|
|
173
|
-
}>;
|
|
174
|
-
protected _vecHaloSize(): number;
|
|
175
|
-
protected _vecHaloPhysicalSize(): number;
|
|
176
|
-
protected _vecHaloClusterCount(): number;
|
|
177
|
-
protected _vecHaloCompact(): void;
|
|
178
|
-
/** Pre-fill both vector indices' RAM caches with sequential scans (up to
|
|
179
|
-
* their budget caps) — seconds of streaming instead of the minutes of
|
|
180
|
-
* random point reads a cold training/query session otherwise pays while
|
|
181
|
-
* warming. Optional; call once after open before sustained work.
|
|
182
|
-
* Returns rows warmed. */
|
|
183
|
-
warmVectorCaches(): Promise<number>;
|
|
184
|
-
}
|