@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
package/CONTRIBUTING.md CHANGED
@@ -1,15 +1,97 @@
1
- # Contributing
1
+ # Contributing to Sema
2
2
 
3
- By contributing to Sema, you agree that:
3
+ Thank you for your interest in contributing to Sema.
4
4
 
5
- - you have the legal right to submit your contribution;
6
- - your contribution does not violate third-party rights;
7
- - your contribution will be licensed under the PolyForm Noncommercial License
8
- 1.0.0;
9
- - this project is source-available, not formally open source;
10
- - commercial use requires a separate paid license;
11
- - you will not submit secrets, credentials, private keys, or confidential data.
5
+ Sema is source-available software distributed publicly under the PolyForm
6
+ Noncommercial License 1.0.0. Commercial use requires a separate commercial
7
+ license from the Sema licensor.
12
8
 
13
- All commits should be signed off:
9
+ ## Contributor representations
14
10
 
11
+ By submitting a contribution to Sema, you represent that:
12
+
13
+ - you created the contribution or otherwise have the legal right to submit it
14
+ under these terms;
15
+ - the contribution does not knowingly violate any copyright, patent, trade
16
+ secret, contractual obligation, or other third-party right;
17
+ - you have obtained any authorization required from your employer or another
18
+ rights holder;
19
+ - you have clearly identified any third-party material included in the
20
+ contribution and provided its applicable license and copyright notices;
21
+ - the contribution does not contain secrets, credentials, private keys,
22
+ confidential information, or unlawfully obtained material;
23
+ - if the contribution was created with the assistance of an artificial
24
+ intelligence system, you have reviewed it and remain responsible for its
25
+ origin, legality, correctness, and compliance with these terms.
26
+
27
+ ## Contribution license grant
28
+
29
+ You retain ownership of the copyright in your contribution.
30
+
31
+ By intentionally submitting a contribution for inclusion in Sema, you grant
32
+ Henrique Viana, as the author, copyright holder, and licensor of Sema, and his
33
+ successors and assigns, a worldwide, perpetual, irrevocable, non-exclusive,
34
+ royalty-free, transferable, and sublicensable license to:
35
+
36
+ - use, reproduce, modify, adapt, and prepare derivative works from the
37
+ contribution;
38
+ - combine the contribution with Sema or other materials;
39
+ - publicly display, publicly perform, distribute, make available, host, and
40
+ otherwise exploit the contribution;
41
+ - offer, license, and sublicense the contribution as part of Sema under the
42
+ PolyForm Noncommercial License 1.0.0;
43
+ - offer, license, and sublicense the contribution as part of commercial,
44
+ proprietary, source-available, or other versions of Sema;
45
+ - relicense the contribution as part of Sema under current or future licensing
46
+ terms.
47
+
48
+ This license grant does not transfer ownership of your contribution to Henrique
49
+ Viana. You remain free to use and license your original contribution
50
+ independently, provided that doing so does not violate rights belonging to Sema
51
+ or to third parties.
52
+
53
+ ## Patent license
54
+
55
+ To the extent that you own or control patent claims necessarily infringed by
56
+ your contribution, you grant Henrique Viana, his successors and assigns, and
57
+ recipients of Sema a worldwide, perpetual, irrevocable, non-exclusive,
58
+ royalty-free, transferable, and sublicensable patent license to make, use, sell,
59
+ offer for sale, import, and otherwise exploit your contribution as part of Sema.
60
+
61
+ This patent license terminates for any party that initiates patent litigation
62
+ alleging that Sema or a contribution incorporated into Sema infringes a patent.
63
+
64
+ ## No obligation to accept contributions
65
+
66
+ Submitting a contribution does not guarantee that it will be accepted, merged,
67
+ published, maintained, or included in any public or commercial version of Sema.
68
+
69
+ The project maintainer may modify, reject, remove, or replace an accepted
70
+ contribution.
71
+
72
+ ## Developer Certificate of Origin
73
+
74
+ All commits must include a Developer Certificate of Origin sign-off:
75
+
76
+ ```bash
15
77
  git commit -s
78
+ ```
79
+
80
+ The sign-off must use your real name and an email address you are authorized to
81
+ use:
82
+
83
+ ```text
84
+ Signed-off-by: Your Name <your.email@example.com>
85
+ ```
86
+
87
+ The sign-off certifies the origin and authorization of each commit. It does not
88
+ replace the contribution license grant described in this document.
89
+
90
+ ## Acceptance
91
+
92
+ By opening or submitting a pull request, patch, or other contribution intended
93
+ for inclusion in Sema, you confirm that you have read and agree to these
94
+ contribution terms.
95
+
96
+ Contributions submitted on behalf of a company or another organization must be
97
+ authorized by the applicable rights holder.
package/LICENSE.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
4
 
5
- > Required Notice: Copyright Sema Authors — Henrique Viana, Marcelo Oliveira dos
6
- > Reis, Rogerio Nascimento (hv5088@gmail.com)
5
+ > Required Notice: Copyright © Henrique Viana (author). Marcelo Oliveira dos
6
+ > Reis and Rogerio Nascimento (supporters).
7
7
 
8
8
  ## Acceptance
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hviana/sema",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Sema: a non-parametric, instance-based reasoning system.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -42,6 +42,8 @@ import { bindSeat, companySignature, type Sema } from "./sema.js";
42
42
  import type { Input } from "./mind/index.js";
43
43
  import { BoundedMap } from "./store.js";
44
44
  import type { Vec } from "./vec.js";
45
+ import { invalidateStructuralCaches } from "./mind/traverse.js";
46
+ import { invalidateJunctionCache } from "./mind/junction.js";
45
47
 
46
48
  /** The interned result of perceiving + interning ONE input.
47
49
  *
@@ -122,6 +124,8 @@ export class CachedIngest {
122
124
  input: Input | (Input | [Input, Input])[],
123
125
  second?: Input,
124
126
  ): Promise<(Sema & { id: number }) | undefined> {
127
+ invalidateStructuralCaches(this.mind);
128
+ invalidateJunctionCache(this.mind);
125
129
  // One shape-reading for both ingest paths — see {@link dispatchIngest}.
126
130
  return dispatchIngest(
127
131
  input,
package/src/meter.ts CHANGED
@@ -176,6 +176,11 @@ export class Meter {
176
176
  /** Nodes popped by those ascents, against their √N·W budget — the counter
177
177
  * that shows whether the walks are deciding early or burning the budget. */
178
178
  junctionPops = 0;
179
+ /** Arbitrary byte spans whose distributional company was VSA-bundled from
180
+ * existing episode halos. */
181
+ spanHalos = 0;
182
+ /** Canonical W-windows examined while composing those span halos. */
183
+ spanHaloWindows = 0;
179
184
 
180
185
  /** `lightestDerivation` searches started. */
181
186
  searches = 0;
@@ -2275,6 +2275,16 @@ async function crossRegionVotes(
2275
2275
  // the same container (or a sub-container of it) twice.
2276
2276
  const consumed = new Set<number>();
2277
2277
  let probes = 0;
2278
+ // Once atoms themselves are hubs (N > W²), the cross-region analysis gets
2279
+ // one k·W walk allowance per evidence tier. Without a shared allowance,
2280
+ // each of k candidate pairs spends the full corpus-derived budget and a
2281
+ // cumulative dialogue multiplies bounded work into tens of seconds. Small
2282
+ // corpora retain exhaustive exact traversal: below this same scale the
2283
+ // budget would be smaller than the structures the tests deliberately build.
2284
+ const marketScale = k * ctx.space.maxGroup;
2285
+ const corpusScale = N > marketScale ** 3;
2286
+ const exactBudget = corpusScale ? { n: k * ctx.space.maxGroup } : undefined;
2287
+ const synonymBudget = corpusScale ? { n: k * ctx.space.maxGroup } : undefined;
2278
2288
 
2279
2289
  for (let a = 0; a < cand.length && probes < k; a++) {
2280
2290
  if (consumed.has(cand[a])) continue;
@@ -2284,6 +2294,12 @@ async function crossRegionVotes(
2284
2294
  const rb = regions[cand[b]];
2285
2295
  if (!strong.has(cand[a]) && !strong.has(cand[b])) continue;
2286
2296
  if (ra.end >= rb.start) continue; // overlap or adjacent — nothing between
2297
+ // In a cumulative conversation, an old↔old interaction cannot explain
2298
+ // the user turn currently being answered; it was already available
2299
+ // before that turn existed. Keep old↔current pairs (the current turn may
2300
+ // refer to a prior answer), but do not repeatedly spend the junction
2301
+ // budget recomposing two regions wholly before the current boundary.
2302
+ if (ctx.currentTurnStart > 0 && rb.end <= ctx.currentTurnStart) continue;
2287
2303
  // Candidates strictly BETWEEN ra and rb (cand is sorted by start, so
2288
2304
  // that is exactly cand[a+1 .. b-1]) that already cast their OWN vote —
2289
2305
  // genuine, individually-corroborated evidence about what fills the gap
@@ -2364,7 +2380,7 @@ async function crossRegionVotes(
2364
2380
  cap,
2365
2381
  seedsOf(cand[a]),
2366
2382
  seedsOf(cand[b]),
2367
- undefined,
2383
+ exactBudget,
2368
2384
  true,
2369
2385
  );
2370
2386
  if (probe) {
@@ -2384,6 +2400,7 @@ async function crossRegionVotes(
2384
2400
  maxInterior,
2385
2401
  true,
2386
2402
  sides,
2403
+ synonymBudget,
2387
2404
  );
2388
2405
  if (probe) {
2389
2406
  const singleAttempted = sides.leftSiblings.length > 0 ||