@hviana/sema 0.4.0 → 0.4.2

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.
Files changed (154) hide show
  1. package/CONTRIBUTING.md +92 -10
  2. package/LICENSE.md +2 -2
  3. package/package.json +1 -1
  4. package/src/ingest-cache.ts +4 -0
  5. package/src/meter.ts +5 -0
  6. package/src/mind/attention.ts +18 -1
  7. package/src/mind/bridge.ts +292 -54
  8. package/src/mind/junction.ts +21 -7
  9. package/src/mind/match.ts +92 -1
  10. package/src/mind/mechanisms/cast.ts +12 -0
  11. package/src/mind/mechanisms/confluence.ts +30 -1
  12. package/src/mind/mechanisms/cover.ts +36 -4
  13. package/src/mind/mechanisms/recall.ts +21 -44
  14. package/src/mind/mind.ts +39 -2
  15. package/src/mind/pipeline-mechanism.ts +86 -4
  16. package/src/mind/pipeline.ts +1 -1
  17. package/src/mind/reasoning.ts +15 -8
  18. package/src/mind/recognition.ts +40 -0
  19. package/src/mind/resonance.ts +0 -0
  20. package/src/mind/traverse.ts +17 -15
  21. package/src/mind/types.ts +10 -0
  22. package/test/49-natural-units-synonym-bridge.test.mjs +56 -15
  23. package/dist/example/demo.d.ts +0 -1
  24. package/dist/example/demo.js +0 -39
  25. package/dist/example/train_base.d.ts +0 -87
  26. package/dist/example/train_base.js +0 -2252
  27. package/dist/src/alphabet.d.ts +0 -7
  28. package/dist/src/alphabet.js +0 -33
  29. package/dist/src/alu/src/alu.d.ts +0 -185
  30. package/dist/src/alu/src/alu.js +0 -440
  31. package/dist/src/alu/src/expr.d.ts +0 -61
  32. package/dist/src/alu/src/expr.js +0 -318
  33. package/dist/src/alu/src/index.d.ts +0 -11
  34. package/dist/src/alu/src/index.js +0 -19
  35. package/dist/src/alu/src/kernel-arith.d.ts +0 -16
  36. package/dist/src/alu/src/kernel-arith.js +0 -264
  37. package/dist/src/alu/src/kernel-bits.d.ts +0 -19
  38. package/dist/src/alu/src/kernel-bits.js +0 -152
  39. package/dist/src/alu/src/kernel-logic.d.ts +0 -4
  40. package/dist/src/alu/src/kernel-logic.js +0 -60
  41. package/dist/src/alu/src/kernel-nd.d.ts +0 -3
  42. package/dist/src/alu/src/kernel-nd.js +0 -208
  43. package/dist/src/alu/src/kernel-numeric.d.ts +0 -54
  44. package/dist/src/alu/src/kernel-numeric.js +0 -366
  45. package/dist/src/alu/src/operation.d.ts +0 -168
  46. package/dist/src/alu/src/operation.js +0 -189
  47. package/dist/src/alu/src/parser.d.ts +0 -221
  48. package/dist/src/alu/src/parser.js +0 -577
  49. package/dist/src/alu/src/resonance.d.ts +0 -55
  50. package/dist/src/alu/src/resonance.js +0 -126
  51. package/dist/src/alu/src/text.d.ts +0 -31
  52. package/dist/src/alu/src/text.js +0 -73
  53. package/dist/src/alu/src/value.d.ts +0 -109
  54. package/dist/src/alu/src/value.js +0 -300
  55. package/dist/src/alu/test/alu.test.d.ts +0 -1
  56. package/dist/src/alu/test/alu.test.js +0 -764
  57. package/dist/src/bytes.d.ts +0 -14
  58. package/dist/src/bytes.js +0 -59
  59. package/dist/src/canon.d.ts +0 -26
  60. package/dist/src/canon.js +0 -57
  61. package/dist/src/config.d.ts +0 -111
  62. package/dist/src/config.js +0 -91
  63. package/dist/src/derive/src/deduction.d.ts +0 -136
  64. package/dist/src/derive/src/deduction.js +0 -159
  65. package/dist/src/derive/src/index.d.ts +0 -8
  66. package/dist/src/derive/src/index.js +0 -11
  67. package/dist/src/derive/src/priority-queue.d.ts +0 -20
  68. package/dist/src/derive/src/priority-queue.js +0 -73
  69. package/dist/src/derive/src/rewrite.d.ts +0 -56
  70. package/dist/src/derive/src/rewrite.js +0 -100
  71. package/dist/src/derive/src/trie.d.ts +0 -90
  72. package/dist/src/derive/src/trie.js +0 -217
  73. package/dist/src/derive/test/derive.test.d.ts +0 -1
  74. package/dist/src/derive/test/derive.test.js +0 -122
  75. package/dist/src/extension.d.ts +0 -37
  76. package/dist/src/extension.js +0 -7
  77. package/dist/src/geometry.d.ts +0 -175
  78. package/dist/src/geometry.js +0 -823
  79. package/dist/src/index.d.ts +0 -17
  80. package/dist/src/index.js +0 -19
  81. package/dist/src/ingest-cache.d.ts +0 -41
  82. package/dist/src/ingest-cache.js +0 -161
  83. package/dist/src/meter.d.ts +0 -171
  84. package/dist/src/meter.js +0 -269
  85. package/dist/src/mind/articulation.d.ts +0 -6
  86. package/dist/src/mind/articulation.js +0 -99
  87. package/dist/src/mind/attention.d.ts +0 -414
  88. package/dist/src/mind/attention.js +0 -2065
  89. package/dist/src/mind/bridge.d.ts +0 -39
  90. package/dist/src/mind/bridge.js +0 -738
  91. package/dist/src/mind/canonical.d.ts +0 -34
  92. package/dist/src/mind/canonical.js +0 -93
  93. package/dist/src/mind/graph-search.d.ts +0 -294
  94. package/dist/src/mind/graph-search.js +0 -996
  95. package/dist/src/mind/index.d.ts +0 -9
  96. package/dist/src/mind/index.js +0 -5
  97. package/dist/src/mind/junction.d.ts +0 -134
  98. package/dist/src/mind/junction.js +0 -331
  99. package/dist/src/mind/learning.d.ts +0 -75
  100. package/dist/src/mind/learning.js +0 -270
  101. package/dist/src/mind/match.d.ts +0 -166
  102. package/dist/src/mind/match.js +0 -565
  103. package/dist/src/mind/mechanisms/alu.d.ts +0 -4
  104. package/dist/src/mind/mechanisms/alu.js +0 -36
  105. package/dist/src/mind/mechanisms/cast.d.ts +0 -89
  106. package/dist/src/mind/mechanisms/cast.js +0 -773
  107. package/dist/src/mind/mechanisms/confluence.d.ts +0 -24
  108. package/dist/src/mind/mechanisms/confluence.js +0 -225
  109. package/dist/src/mind/mechanisms/cover.d.ts +0 -6
  110. package/dist/src/mind/mechanisms/cover.js +0 -203
  111. package/dist/src/mind/mechanisms/extraction.d.ts +0 -33
  112. package/dist/src/mind/mechanisms/extraction.js +0 -300
  113. package/dist/src/mind/mechanisms/recall.d.ts +0 -16
  114. package/dist/src/mind/mechanisms/recall.js +0 -388
  115. package/dist/src/mind/mind.d.ts +0 -330
  116. package/dist/src/mind/mind.js +0 -594
  117. package/dist/src/mind/pipeline-mechanism.d.ts +0 -172
  118. package/dist/src/mind/pipeline-mechanism.js +0 -382
  119. package/dist/src/mind/pipeline.d.ts +0 -49
  120. package/dist/src/mind/pipeline.js +0 -275
  121. package/dist/src/mind/primitives.d.ts +0 -66
  122. package/dist/src/mind/primitives.js +0 -306
  123. package/dist/src/mind/rationale.d.ts +0 -139
  124. package/dist/src/mind/rationale.js +0 -163
  125. package/dist/src/mind/reasoning.d.ts +0 -40
  126. package/dist/src/mind/reasoning.js +0 -272
  127. package/dist/src/mind/recognition.d.ts +0 -20
  128. package/dist/src/mind/recognition.js +0 -463
  129. package/dist/src/mind/resonance.d.ts +0 -23
  130. package/dist/src/mind/resonance.js +0 -0
  131. package/dist/src/mind/trace.d.ts +0 -15
  132. package/dist/src/mind/trace.js +0 -73
  133. package/dist/src/mind/traverse.d.ts +0 -124
  134. package/dist/src/mind/traverse.js +0 -649
  135. package/dist/src/mind/types.d.ts +0 -323
  136. package/dist/src/mind/types.js +0 -130
  137. package/dist/src/rabitq-ivf/src/database.d.ts +0 -113
  138. package/dist/src/rabitq-ivf/src/database.js +0 -201
  139. package/dist/src/rabitq-ivf/src/index.d.ts +0 -7
  140. package/dist/src/rabitq-ivf/src/index.js +0 -4
  141. package/dist/src/rabitq-ivf/src/ivf.d.ts +0 -200
  142. package/dist/src/rabitq-ivf/src/ivf.js +0 -1165
  143. package/dist/src/rabitq-ivf/src/prng.d.ts +0 -19
  144. package/dist/src/rabitq-ivf/src/prng.js +0 -36
  145. package/dist/src/rabitq-ivf/src/rabitq.d.ts +0 -95
  146. package/dist/src/rabitq-ivf/src/rabitq.js +0 -283
  147. package/dist/src/sema.d.ts +0 -31
  148. package/dist/src/sema.js +0 -63
  149. package/dist/src/store-sqlite.d.ts +0 -184
  150. package/dist/src/store-sqlite.js +0 -942
  151. package/dist/src/store.d.ts +0 -678
  152. package/dist/src/store.js +0 -1703
  153. package/dist/src/vec.d.ts +0 -31
  154. package/dist/src/vec.js +0 -109
@@ -1,124 +0,0 @@
1
- import { Vec } from "../vec.js";
2
- import type { AncestorReach, MindContext } from "./types.js";
3
- /** The reach memo this response should use — see the note above.
4
- *
5
- * A TRACED response always gets a fresh, empty one. `AncestorReach`'s
6
- * `visited`/`maxDepth`/`saturation` fields are populated only when a trace
7
- * is attached, so an entry deposited by an untraced earlier turn would
8
- * silently black out the reach detail of a later traced one; and the trace's
9
- * reach payload is serialised by ITERATING this map, which must therefore
10
- * hold what THIS climb consulted, not the whole conversation's history.
11
- * Consistent with AGENTS §2.11: a traced response is a different machine —
12
- * never benchmark with a trace attached. */
13
- export declare function sharedReachMemo(ctx: MindContext): Map<number, AncestorReach>;
14
- /** Climb the structural DAG from a node to its edge-bearing ancestor contexts.
15
- * Ascent stops at hub nodes (parents > √N) — their reach is non-discriminative.
16
- * When the start node has no structural parents, climbs from containment parents
17
- * (sub-span flat branches inheriting their chunks' context).
18
- *
19
- * `memo`, when given, caches whole climbs by start id for the duration of ONE
20
- * query (the store is read-only while a query is in flight, so a climb is a
21
- * pure function of the id). The consensus pipeline climbs the SAME anchors
22
- * repeatedly — regions sharing a chunk, and canonicalChunkId probing each
23
- * chunk's prefixes — so without the memo every repeat re-pays the full
24
- * fan-out reads. */
25
- export declare function edgeAncestors(ctx: MindContext, id: number, contextCount: number, memo?: Map<number, AncestorReach>): AncestorReach;
26
- /** Convenience: forward edges of a node. */
27
- export declare function nextOf(ctx: MindContext, id: number): number[];
28
- /** Convenience: reverse edges of a node. */
29
- export declare function prevOf(ctx: MindContext, id: number): number[];
30
- /** The uniform-expectation floor on a byte atom's corpus commonality: N
31
- * learnt contexts, each at least one perception chunk of up to W of the 256
32
- * possible byte values, contain a given atom in ≥ N·W/256 contexts on
33
- * average. An atom's TRUE containment is unmeasurable (atoms carry no
34
- * kid/contain links by construction), so this floor is the honest stand-in:
35
- * derived entirely from the corpus scale N, the perception window W, and
36
- * the alphabet size — never tuned. */
37
- export declare function atomReach(ctx: MindContext, contextCount: number): number;
38
- /** Whether a byte atom is a hub at this corpus scale — its commonality floor
39
- * {@link atomReach} exceeds the hub bound √N. Below it (small stores) an
40
- * atom votes and is recognised exactly as any stored form; above it the
41
- * alphabet is scaffolding everywhere and abstains. */
42
- export declare function atomIsHub(ctx: MindContext, contextCount: number): boolean;
43
- /** Whether a node LEADS SOMEWHERE — it bears a continuation edge or a halo.
44
- * The admission predicate recognition filters sites with (HOW_IT_WORKS
45
- * §15.3): a form that leads nowhere contributes nothing to any derivation.
46
- * Runs once per candidate span on the recognition hot path — `hasNext` is
47
- * cached per response (the same flat-branch ids are probed across prefix
48
- * variants by canonicalChunkId). `hasHalo` is not cached: it's a single
49
- * indexed point probe per candidate, and the candidates that reach this
50
- * check have already been filtered by hasNext above in edgeAncestors. */
51
- export declare function leadsSomewhere(ctx: MindContext, id: number): boolean;
52
- /** The structural IDF read of ONE node: how many distinct learnt contexts
53
- * its containment/edge climb reaches, or Infinity when it reaches none or
54
- * saturates (no usable identity evidence). The number every
55
- * discriminative-vs-scaffolding decision derives from — paired with the
56
- * half-dominance convention (geometry.dominates(reach, N)): content
57
- * reaching a corpus MINORITY of contexts discriminates (an entity, a
58
- * filler); content reaching a majority is frame scaffolding. */
59
- export declare function reachOf(ctx: MindContext, id: number, contextCount: number, memo?: Map<number, AncestorReach>): number;
60
- /** The corpus scale N — the count of DISTINCT learnt contexts, floored at 2
61
- * so its derived readings (ln N in the consensus floor, √N in the hub bound)
62
- * stay meaningful on a near-empty store. The one definition every consumer
63
- * of "how big is this corpus?" reads. */
64
- export declare function corpusN(ctx: MindContext): number;
65
- /** The hub bound √N itself (≥ 2 always, since N is floored at 2) — for
66
- * consumers that pass it to the store's LIMITed reads instead of capping a
67
- * materialised list. {@link hubCap} is the list-side reading of the same
68
- * convention. */
69
- export declare function hubBound(ctx: MindContext): number;
70
- /** Cap a candidate list at the hub bound √N (insertion order) — the ONE
71
- * fan-out convention every walk and disambiguation uses (see HOW_IT_WORKS
72
- * §8.6). A node connected to more than √N others is a hub whose individual
73
- * connections carry ~no discriminative information; materialising or scoring
74
- * them all would make single decisions scale with the corpus. */
75
- export declare function hubCap<T>(ctx: MindContext, ids: readonly T[]): readonly T[];
76
- /** Whether `descendant` lies within `ancestor`'s subtree — a structural DAG
77
- * relation read off the hash-consed `kids` lists, by a bounded explicit-stack
78
- * descent. Used by articulation to keep a voice from revoicing a fragment
79
- * OF that voice. */
80
- export declare function contains(ctx: MindContext, ancestor: number, descendant: number): boolean;
81
- /** The best-scoring item by cosine against `query`, among items scoring at
82
- * or above `threshold` — the shared arg-max every Pattern-A "which of these
83
- * resonates best" decision reduces to. `strict` picks the tie-break a
84
- * caller needs: `true` keeps the first-seen leader on a tie (`>`), the
85
- * default lets a later equal score take it (`>=`). */
86
- export declare function argmaxBy<T>(items: Iterable<T>, scoreOf: (item: T) => number, threshold: number, strict?: boolean): {
87
- item: T;
88
- score: number;
89
- } | null;
90
- export declare function argmaxCosine<T>(query: Vec, items: Iterable<T>, vecOf: (item: T) => Vec | null | undefined, threshold: number, strict?: boolean): {
91
- item: T;
92
- score: number;
93
- } | null;
94
- /** The guided-or-first continuation of a node, as answer-shaped bytes source:
95
- * chooseNext under the response guide, falling back to the FIRST-inserted
96
- * edge — the one no-guide convention chooseNext, project() and the search's
97
- * formRules all share. undefined when the node has no continuation. */
98
- export declare function guidedFirst(ctx: MindContext, id: number): number | undefined;
99
- export declare function guidedNext(ctx: MindContext, node: number): number | undefined;
100
- /** Disambiguate among a node's learnt continuations by distributional
101
- * support. NOTE the `guide` contract: its VALUE is deliberately unused —
102
- * only its PRESENCE gates disambiguation (a null guide means no query is in
103
- * flight, so structural walkers keep plain first-edge behaviour). The
104
- * gist-cosine of short answer candidates against a query guide is dominated
105
- * by accidental byte-pattern correlations, not semantic relatedness, so the
106
- * evidence consulted is structural: each candidate's reverse-edge support
107
- * count (see below). Contrast {@link chooseAmong}, the REVERSE-direction
108
- * disambiguator, whose candidates are whole learnt contexts — long enough
109
- * that their perceived gists ARE semantically meaningful — and which
110
- * therefore scores by guide cosine. The two directions consult different
111
- * halves of the evidence on purpose. */
112
- export declare function chooseNext(ctx: MindContext, id: number, guide?: Vec | null): number | undefined;
113
- /** The perceived gist of a candidate node, through the session gist cache.
114
- * Re-gisting a candidate is a full river fold of its bytes — the measured
115
- * recall bottleneck (a hub context offers up to √N continuations, EACH
116
- * re-perceived per pick). A node's bytes are immutable and perception is
117
- * pure, so the cached gist is valid for the store's lifetime. Exported for
118
- * every "score node ids against a guide" decision (chooseAmong here, the
119
- * bridge's junction pick) so they share ONE cache and one convention. */
120
- export declare function candidateGist(ctx: MindContext, c: number): Vec | null;
121
- export declare function chooseAmong(ctx: MindContext, candidates: readonly number[], guide: Vec): {
122
- id: number;
123
- score: number;
124
- };