@hviana/sema 0.1.0 → 0.1.1
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 +2216 -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 +212 -0
- package/dist/src/alu/src/parser.js +469 -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/config.d.ts +114 -0
- package/dist/src/config.js +96 -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 +137 -0
- package/dist/src/geometry.js +430 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.js +21 -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 +72 -0
- package/dist/src/mind/attention.js +894 -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 +270 -0
- package/dist/src/mind/graph-search.js +847 -0
- package/dist/src/mind/index.d.ts +5 -0
- package/dist/src/mind/index.js +5 -0
- package/dist/src/mind/junction.d.ts +95 -0
- package/dist/src/mind/junction.js +262 -0
- package/dist/src/mind/learning.d.ts +47 -0
- package/dist/src/mind/learning.js +201 -0
- package/dist/src/mind/match.d.ts +111 -0
- package/dist/src/mind/match.js +422 -0
- package/dist/src/mind/mechanisms/alu.d.ts +4 -0
- package/dist/src/mind/mechanisms/alu.js +29 -0
- package/dist/src/mind/mechanisms/cast.d.ts +35 -0
- package/dist/src/mind/mechanisms/cast.js +447 -0
- package/dist/src/mind/mechanisms/confluence.d.ts +24 -0
- package/dist/src/mind/mechanisms/confluence.js +213 -0
- package/dist/src/mind/mechanisms/cover.d.ts +6 -0
- package/dist/src/mind/mechanisms/cover.js +179 -0
- package/dist/src/mind/mechanisms/extraction.d.ts +67 -0
- package/dist/src/mind/mechanisms/extraction.js +342 -0
- package/dist/src/mind/mechanisms/recall.d.ts +13 -0
- package/dist/src/mind/mechanisms/recall.js +151 -0
- package/dist/src/mind/mind.d.ts +147 -0
- package/dist/src/mind/mind.js +300 -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 +185 -0
- package/dist/src/mind/primitives.d.ts +43 -0
- package/dist/src/mind/primitives.js +162 -0
- package/dist/src/mind/rationale.d.ts +134 -0
- package/dist/src/mind/rationale.js +162 -0
- package/dist/src/mind/reasoning.d.ts +15 -0
- package/dist/src/mind/reasoning.js +162 -0
- package/dist/src/mind/recognition.d.ts +20 -0
- package/dist/src/mind/recognition.js +223 -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 +100 -0
- package/dist/src/mind/traverse.js +447 -0
- package/dist/src/mind/types.d.ts +174 -0
- package/dist/src/mind/types.js +84 -0
- package/dist/src/rabitq-hnsw/src/database.d.ts +200 -0
- package/dist/src/rabitq-hnsw/src/database.js +388 -0
- package/dist/src/rabitq-hnsw/src/heap.d.ts +22 -0
- package/dist/src/rabitq-hnsw/src/heap.js +89 -0
- package/dist/src/rabitq-hnsw/src/hnsw.d.ts +125 -0
- package/dist/src/rabitq-hnsw/src/hnsw.js +474 -0
- package/dist/src/rabitq-hnsw/src/index.d.ts +10 -0
- package/dist/src/rabitq-hnsw/src/index.js +6 -0
- package/dist/src/rabitq-hnsw/src/prng.d.ts +19 -0
- package/dist/src/rabitq-hnsw/src/prng.js +36 -0
- package/dist/src/rabitq-hnsw/src/rabitq.d.ts +95 -0
- package/dist/src/rabitq-hnsw/src/rabitq.js +283 -0
- package/dist/src/rabitq-hnsw/src/store.d.ts +162 -0
- package/dist/src/rabitq-hnsw/src/store.js +825 -0
- package/dist/src/rabitq-hnsw/test/hnsw.test.d.ts +1 -0
- package/dist/src/rabitq-hnsw/test/hnsw.test.js +948 -0
- package/dist/src/store-sqlite.d.ts +149 -0
- package/dist/src/store-sqlite.js +702 -0
- package/dist/src/store.d.ts +638 -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
|
@@ -0,0 +1,149 @@
|
|
|
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 vectorSeed;
|
|
17
|
+
private content;
|
|
18
|
+
private halos;
|
|
19
|
+
private sqlite;
|
|
20
|
+
private _inTx;
|
|
21
|
+
private _insertNode;
|
|
22
|
+
private _insertKid;
|
|
23
|
+
private _selContain;
|
|
24
|
+
private _selParents;
|
|
25
|
+
private _selHalo;
|
|
26
|
+
private _upHalo;
|
|
27
|
+
private _selLeaf;
|
|
28
|
+
private _selFlat;
|
|
29
|
+
private _selKids;
|
|
30
|
+
private _selNode;
|
|
31
|
+
private _insertEdge;
|
|
32
|
+
private _selNext;
|
|
33
|
+
private _selPrev;
|
|
34
|
+
private _setMeta;
|
|
35
|
+
private _getMeta;
|
|
36
|
+
private _delMeta;
|
|
37
|
+
private _insSnapshot;
|
|
38
|
+
private _selSnapshot;
|
|
39
|
+
constructor(opts?: SQliteStoreOptions);
|
|
40
|
+
private vectorDbPath;
|
|
41
|
+
private openVectorDB;
|
|
42
|
+
protected _dbOpen(): Promise<void>;
|
|
43
|
+
protected _dbClose(): void;
|
|
44
|
+
protected _dbBeginTx(): void;
|
|
45
|
+
protected _dbCommitTx(): void;
|
|
46
|
+
protected _dbInsertNode(id: NodeId, leaf: Uint8Array | null, kids: Uint8Array | null, h: number): void;
|
|
47
|
+
protected _dbGetNode(id: NodeId): NodeRec | null;
|
|
48
|
+
protected _dbFindLeaf(h: number, bytes: Uint8Array): NodeId | null;
|
|
49
|
+
protected _dbFindBranchByLeaf(h: number, bytes: Uint8Array): NodeId | null;
|
|
50
|
+
protected _dbFindBranchByKids(h: number, packed: Uint8Array): NodeId | null;
|
|
51
|
+
protected _dbInsertKid(child: NodeId, parent: NodeId): void;
|
|
52
|
+
protected _dbGetParents(id: NodeId): NodeId[];
|
|
53
|
+
private _selParentsFirst;
|
|
54
|
+
protected _dbGetParentsFirst(id: NodeId, limit: number): NodeId[];
|
|
55
|
+
private _selChain;
|
|
56
|
+
/** {@link Store.chainRun}'s walk as ONE recursive CTE: the whole
|
|
57
|
+
* transparent chain (no edge in or out, exactly one parent) is descended
|
|
58
|
+
* inside SQLite — per-node work is the same three indexed probes as the
|
|
59
|
+
* base class's loop, but without a JS↔SQLite round trip per node, which
|
|
60
|
+
* dominates on the deep single-structure scaffolding this read exists
|
|
61
|
+
* for. */
|
|
62
|
+
protected _chainWalk(id: NodeId, cap: number): NodeId[];
|
|
63
|
+
/** Width of the seq band inside the packed contain rowid: rowid =
|
|
64
|
+
* child·SEQ_SPAN + seq. Page sizes are geometric, so a chain of k live
|
|
65
|
+
* pages needs a base of ≥ 2^k · 4 bytes — seq stays ≤ ~50 for any
|
|
66
|
+
* physically possible list; the append path guards the band anyway. */
|
|
67
|
+
private static readonly SEQ_SPAN;
|
|
68
|
+
private _selContainExists;
|
|
69
|
+
protected _dbContainExists(child: NodeId): boolean;
|
|
70
|
+
private _selContainPages;
|
|
71
|
+
/** The child's page directory — (seq, byte length) per page, O(log fan-in)
|
|
72
|
+
* rows, each read from the cell header without loading the blob. */
|
|
73
|
+
private containPages;
|
|
74
|
+
private _selContainPageSub;
|
|
75
|
+
private _selContainPage;
|
|
76
|
+
private containPage;
|
|
77
|
+
protected _dbGetContainParentsSlice(child: NodeId, offset: number, limit: number): NodeId[];
|
|
78
|
+
private _selContainCount;
|
|
79
|
+
protected _dbGetContainCount(child: NodeId): number;
|
|
80
|
+
protected _dbGetContainParents(child: NodeId): NodeId[];
|
|
81
|
+
private _upsContainPage;
|
|
82
|
+
private _delContainPage;
|
|
83
|
+
protected _dbAppendContain(child: NodeId, parents: NodeId[]): void;
|
|
84
|
+
protected _dbInsertEdge(src: NodeId, dst: NodeId): void;
|
|
85
|
+
protected _dbGetNextEdges(id: NodeId): NodeId[];
|
|
86
|
+
protected _dbGetPrevEdges(id: NodeId): NodeId[];
|
|
87
|
+
private _selNextFirst;
|
|
88
|
+
protected _dbGetNextEdgesFirst(id: NodeId, limit: number): NodeId[];
|
|
89
|
+
private _selPrevFirst;
|
|
90
|
+
protected _dbGetPrevEdgesFirst(id: NodeId, limit: number): NodeId[];
|
|
91
|
+
private _selPrevCount;
|
|
92
|
+
/** {@link Store.prevCount} — one indexed COUNT over idx_edge_dst, never a
|
|
93
|
+
* row materialisation (a common continuation's reverse fan-in is
|
|
94
|
+
* corpus-sized). */
|
|
95
|
+
prevCount(id: NodeId): number;
|
|
96
|
+
private _selSrcExists;
|
|
97
|
+
protected _dbEdgeSrcExists(src: NodeId): boolean;
|
|
98
|
+
protected _dbEdgeDistinctSrcCount(): number;
|
|
99
|
+
protected _dbGetHalo(id: NodeId): {
|
|
100
|
+
vec: Uint8Array;
|
|
101
|
+
mass: number;
|
|
102
|
+
} | null;
|
|
103
|
+
protected _dbUpsertHalo(id: NodeId, encodedVec: Uint8Array, mass: number): void;
|
|
104
|
+
protected _dbGetMeta(key: string): string | null;
|
|
105
|
+
protected _dbSetMeta(key: string, val: string): void;
|
|
106
|
+
protected _dbDeleteMeta(key: string): void;
|
|
107
|
+
protected _dbSaveSnapshot(bytes: Uint8Array): void;
|
|
108
|
+
protected _dbLoadSnapshot(): Uint8Array | null;
|
|
109
|
+
protected _vecContentUpsert(entries: Array<{
|
|
110
|
+
id: NodeId;
|
|
111
|
+
vector: Float32Array;
|
|
112
|
+
ef?: number;
|
|
113
|
+
}>): void;
|
|
114
|
+
protected _vecContentQuery(v: Float32Array, k: number, ef: number): Array<{
|
|
115
|
+
id: number;
|
|
116
|
+
distance: number;
|
|
117
|
+
}>;
|
|
118
|
+
protected _vecContentHas(id: NodeId): boolean;
|
|
119
|
+
protected _vecContentSize(): number;
|
|
120
|
+
protected _vecContentLastReads(): number;
|
|
121
|
+
protected _vecContentPhysicalSize(): number;
|
|
122
|
+
protected _vecContentCompact(): void;
|
|
123
|
+
protected _vecContentDeleteMany(ids: NodeId[]): void;
|
|
124
|
+
protected _vecContentEntriesSince(after: number): IterableIterator<{
|
|
125
|
+
ext: NodeId;
|
|
126
|
+
internal: number;
|
|
127
|
+
}>;
|
|
128
|
+
/** {@link AbstractStore._dbEdgeOrHaloIds} — one C-side scan; UNION dedups
|
|
129
|
+
* and (with the ORDER BY) sorts, so the result is ready for the binary-
|
|
130
|
+
* search membership probes and the ascending-id maintenance walks. */
|
|
131
|
+
protected _dbEdgeOrHaloIds(): NodeId[];
|
|
132
|
+
protected _vecHaloUpsert(entries: Array<{
|
|
133
|
+
id: NodeId;
|
|
134
|
+
vector: Float32Array;
|
|
135
|
+
}>): void;
|
|
136
|
+
protected _vecHaloQuery(v: Float32Array, k: number, ef: number): Array<{
|
|
137
|
+
id: number;
|
|
138
|
+
distance: number;
|
|
139
|
+
}>;
|
|
140
|
+
protected _vecHaloSize(): number;
|
|
141
|
+
protected _vecHaloPhysicalSize(): number;
|
|
142
|
+
protected _vecHaloCompact(): void;
|
|
143
|
+
/** Pre-fill both vector indices' RAM caches with sequential scans (up to
|
|
144
|
+
* their budget caps) — seconds of streaming instead of the minutes of
|
|
145
|
+
* random point reads a cold training/query session otherwise pays while
|
|
146
|
+
* warming. Optional; call once after open before sustained work.
|
|
147
|
+
* Returns rows warmed. */
|
|
148
|
+
warmVectorCaches(): Promise<number>;
|
|
149
|
+
}
|