@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
|
@@ -11,7 +11,12 @@ import type { AncestorReach, MindContext } from "./types.js";
|
|
|
11
11
|
* repeatedly — regions sharing a chunk, and canonicalChunkId probing each
|
|
12
12
|
* chunk's prefixes — so without the memo every repeat re-pays the full
|
|
13
13
|
* fan-out reads. */
|
|
14
|
-
export declare function edgeAncestors(
|
|
14
|
+
export declare function edgeAncestors(
|
|
15
|
+
ctx: MindContext,
|
|
16
|
+
id: number,
|
|
17
|
+
contextCount: number,
|
|
18
|
+
memo?: Map<number, AncestorReach>,
|
|
19
|
+
): AncestorReach;
|
|
15
20
|
/** Convenience: forward edges of a node. */
|
|
16
21
|
export declare function nextOf(ctx: MindContext, id: number): number[];
|
|
17
22
|
/** Convenience: reverse edges of a node. */
|
|
@@ -32,7 +37,12 @@ export declare function leadsSomewhere(ctx: MindContext, id: number): boolean;
|
|
|
32
37
|
* half-dominance convention (geometry.dominates(reach, N)): content
|
|
33
38
|
* reaching a corpus MINORITY of contexts discriminates (an entity, a
|
|
34
39
|
* filler); content reaching a majority is frame scaffolding. */
|
|
35
|
-
export declare function reachOf(
|
|
40
|
+
export declare function reachOf(
|
|
41
|
+
ctx: MindContext,
|
|
42
|
+
id: number,
|
|
43
|
+
contextCount: number,
|
|
44
|
+
memo?: Map<number, AncestorReach>,
|
|
45
|
+
): number;
|
|
36
46
|
/** The corpus scale N — the count of DISTINCT learnt contexts, floored at 2
|
|
37
47
|
* so its derived readings (ln N in the consensus floor, √N in the hub bound)
|
|
38
48
|
* stay meaningful on a near-empty store. The one definition every consumer
|
|
@@ -48,31 +58,55 @@ export declare function hubBound(ctx: MindContext): number;
|
|
|
48
58
|
* §8.6). A node connected to more than √N others is a hub whose individual
|
|
49
59
|
* connections carry ~no discriminative information; materialising or scoring
|
|
50
60
|
* them all would make single decisions scale with the corpus. */
|
|
51
|
-
export declare function hubCap<T>(
|
|
61
|
+
export declare function hubCap<T>(
|
|
62
|
+
ctx: MindContext,
|
|
63
|
+
ids: readonly T[],
|
|
64
|
+
): readonly T[];
|
|
52
65
|
/** Whether `descendant` lies within `ancestor`'s subtree — a structural DAG
|
|
53
66
|
* relation read off the hash-consed `kids` lists, by a bounded explicit-stack
|
|
54
67
|
* descent. Used by articulation to keep a voice from revoicing a fragment
|
|
55
68
|
* OF that voice. */
|
|
56
|
-
export declare function contains(
|
|
69
|
+
export declare function contains(
|
|
70
|
+
ctx: MindContext,
|
|
71
|
+
ancestor: number,
|
|
72
|
+
descendant: number,
|
|
73
|
+
): boolean;
|
|
57
74
|
/** The best-scoring item by cosine against `query`, among items scoring at
|
|
58
75
|
* or above `threshold` — the shared arg-max every Pattern-A "which of these
|
|
59
76
|
* resonates best" decision reduces to. `strict` picks the tie-break a
|
|
60
77
|
* caller needs: `true` keeps the first-seen leader on a tie (`>`), the
|
|
61
78
|
* default lets a later equal score take it (`>=`). */
|
|
62
|
-
export declare function argmaxBy<T>(
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
export declare function argmaxBy<T>(
|
|
80
|
+
items: Iterable<T>,
|
|
81
|
+
scoreOf: (item: T) => number,
|
|
82
|
+
threshold: number,
|
|
83
|
+
strict?: boolean,
|
|
84
|
+
): {
|
|
85
|
+
item: T;
|
|
86
|
+
score: number;
|
|
65
87
|
} | null;
|
|
66
|
-
export declare function argmaxCosine<T>(
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
export declare function argmaxCosine<T>(
|
|
89
|
+
query: Vec,
|
|
90
|
+
items: Iterable<T>,
|
|
91
|
+
vecOf: (item: T) => Vec | null | undefined,
|
|
92
|
+
threshold: number,
|
|
93
|
+
strict?: boolean,
|
|
94
|
+
): {
|
|
95
|
+
item: T;
|
|
96
|
+
score: number;
|
|
69
97
|
} | null;
|
|
70
98
|
/** The guided-or-first continuation of a node, as answer-shaped bytes source:
|
|
71
99
|
* chooseNext under the response guide, falling back to the FIRST-inserted
|
|
72
100
|
* edge — the one no-guide convention chooseNext, project() and the search's
|
|
73
101
|
* formRules all share. undefined when the node has no continuation. */
|
|
74
|
-
export declare function guidedFirst(
|
|
75
|
-
|
|
102
|
+
export declare function guidedFirst(
|
|
103
|
+
ctx: MindContext,
|
|
104
|
+
id: number,
|
|
105
|
+
): number | undefined;
|
|
106
|
+
export declare function guidedNext(
|
|
107
|
+
ctx: MindContext,
|
|
108
|
+
node: number,
|
|
109
|
+
): number | undefined;
|
|
76
110
|
/** Disambiguate among a node's learnt continuations by distributional
|
|
77
111
|
* support. NOTE the `guide` contract: its VALUE is deliberately unused —
|
|
78
112
|
* only its PRESENCE gates disambiguation (a null guide means no query is in
|
|
@@ -85,7 +119,11 @@ export declare function guidedNext(ctx: MindContext, node: number): number | und
|
|
|
85
119
|
* that their perceived gists ARE semantically meaningful — and which
|
|
86
120
|
* therefore scores by guide cosine. The two directions consult different
|
|
87
121
|
* halves of the evidence on purpose. */
|
|
88
|
-
export declare function chooseNext(
|
|
122
|
+
export declare function chooseNext(
|
|
123
|
+
ctx: MindContext,
|
|
124
|
+
id: number,
|
|
125
|
+
guide?: Vec | null,
|
|
126
|
+
): number | undefined;
|
|
89
127
|
/** The perceived gist of a candidate node, through the session gist cache.
|
|
90
128
|
* Re-gisting a candidate is a full river fold of its bytes — the measured
|
|
91
129
|
* recall bottleneck (a hub context offers up to √N continuations, EACH
|
|
@@ -94,7 +132,11 @@ export declare function chooseNext(ctx: MindContext, id: number, guide?: Vec | n
|
|
|
94
132
|
* every "score node ids against a guide" decision (chooseAmong here, the
|
|
95
133
|
* bridge's junction pick) so they share ONE cache and one convention. */
|
|
96
134
|
export declare function candidateGist(ctx: MindContext, c: number): Vec | null;
|
|
97
|
-
export declare function chooseAmong(
|
|
98
|
-
|
|
99
|
-
|
|
135
|
+
export declare function chooseAmong(
|
|
136
|
+
ctx: MindContext,
|
|
137
|
+
candidates: readonly number[],
|
|
138
|
+
guide: Vec,
|
|
139
|
+
): {
|
|
140
|
+
id: number;
|
|
141
|
+
score: number;
|
|
100
142
|
};
|