@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
package/package.json
CHANGED
package/src/geometry.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// identically regardless of what follows — pure structural stability.
|
|
8
8
|
// 3. The same rule recurses level after level until one root remains.
|
|
9
9
|
|
|
10
|
-
import { normalize, Vec } from "./vec.js";
|
|
10
|
+
import { addInto, copy, normalize, Vec, zeros } from "./vec.js";
|
|
11
11
|
import { Sema, sema, Space } from "./sema.js";
|
|
12
12
|
import { Alphabet } from "./alphabet.js";
|
|
13
13
|
|
|
@@ -461,8 +461,10 @@ function fold2(space: Space, a: Folded, b: Folded): Folded {
|
|
|
461
461
|
/** Plain river fold WITHOUT the final root normalize — the segment-level
|
|
462
462
|
* building block of {@link stablePrefixFold} (interiors must keep their
|
|
463
463
|
* byte-proportional magnitude; only the whole perception's root is ever
|
|
464
|
-
* normalized).
|
|
465
|
-
|
|
464
|
+
* normalized). Exported so callers that COMPOSE already-existing structural
|
|
465
|
+
* parts into a hypothetical synthetic root (see {@link composeStructuralGist})
|
|
466
|
+
* can feed the same raw primitive instead of duplicating its mathematics. */
|
|
467
|
+
export function riverFoldRaw(space: Space, row: Folded[]): Folded {
|
|
466
468
|
if (row.length === 0) {
|
|
467
469
|
const z = new Float32Array(space.D);
|
|
468
470
|
return { tree: sema(z, new Uint8Array(0), null), len: 0 };
|
|
@@ -477,6 +479,53 @@ function riverFoldRaw(space: Space, row: Folded[]): Folded {
|
|
|
477
479
|
return level[0];
|
|
478
480
|
}
|
|
479
481
|
|
|
482
|
+
// ---- structural composition (synthesize from EXISTING structural parts) ----
|
|
483
|
+
|
|
484
|
+
/** One already-existing structural vector to compose, paired with the byte
|
|
485
|
+
* span (query-slot) length it stands in for. `len`, not the vector's own
|
|
486
|
+
* magnitude, is what {@link composeStructuralGist} restores — the composed
|
|
487
|
+
* slot's NATURAL span, exactly as the linear river fold would carry it. */
|
|
488
|
+
export interface StructuralPart {
|
|
489
|
+
v: Vec;
|
|
490
|
+
len: number;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Synthesize a hypothetical internal structure from already-existing
|
|
494
|
+
* structural vectors — NOT from bytes. This is the raw positional
|
|
495
|
+
* composition the linear river fold already uses (see the folding header
|
|
496
|
+
* above): each part is positionally bound into its own seat, its natural
|
|
497
|
+
* span magnitude is preserved, the parts are linearly superposed, and only
|
|
498
|
+
* the final synthetic root is normalized. It never calls {@link gistOf}
|
|
499
|
+
* (there is no `gistOf` here — geometry.ts has no store), never perceives a
|
|
500
|
+
* concatenated byte string, and never interns or stores a new node: the
|
|
501
|
+
* result is an opaque, ungrounded Vec for an ANN probe only. */
|
|
502
|
+
export function composeStructuralGist(
|
|
503
|
+
space: Space,
|
|
504
|
+
parts: readonly StructuralPart[],
|
|
505
|
+
): Vec {
|
|
506
|
+
const foldedParts: Folded[] = [];
|
|
507
|
+
|
|
508
|
+
for (const part of parts) {
|
|
509
|
+
if (part.len <= 0) continue;
|
|
510
|
+
|
|
511
|
+
const direction = copy(part.v);
|
|
512
|
+
normalize(direction);
|
|
513
|
+
|
|
514
|
+
const scaled = zeros(space.D);
|
|
515
|
+
addInto(scaled, direction, Math.sqrt(part.len));
|
|
516
|
+
|
|
517
|
+
foldedParts.push({ tree: sema(scaled), len: part.len });
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (foldedParts.length === 0) return zeros(space.D);
|
|
521
|
+
|
|
522
|
+
const rawRoot = riverFoldRaw(space, foldedParts);
|
|
523
|
+
|
|
524
|
+
const result = copy(rawRoot.tree.v);
|
|
525
|
+
normalize(result);
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
|
|
480
529
|
// ---- pyramid fold (incremental plain perception) ----
|
|
481
530
|
|
|
482
531
|
/** The PLAIN fold's full level pyramid — every level's item list, bottom
|