@hviana/sema 0.9.4 → 0.9.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/AGENTS.md +16 -7
- package/dist/src/mind/learning.js +11 -12
- package/dist/src/mind/mind.js +4 -4
- package/dist/src/mind/types.d.ts +10 -15
- package/dist/src/store.d.ts +10 -10
- package/dist/src/store.js +5 -5
- package/docs/INDEX.md +62 -63
- package/docs/INVARIANTS.md +36 -18
- package/docs/architecture/bounded-reads.md +31 -71
- package/docs/architecture/caches.md +61 -81
- package/docs/architecture/closure.md +88 -107
- package/docs/architecture/commonality.md +47 -38
- package/docs/architecture/cost-model.md +57 -79
- package/docs/architecture/determinism.md +43 -55
- package/docs/architecture/evidence.md +158 -235
- package/docs/architecture/exact-vs-approximate.md +41 -35
- package/docs/architecture/factored-machinery.md +34 -20
- package/docs/architecture/fold-contract.md +110 -118
- package/docs/architecture/halo-sketch.md +105 -96
- package/docs/architecture/match-project.md +51 -42
- package/docs/architecture/mechanism-market.md +87 -91
- package/docs/architecture/memoization.md +60 -74
- package/docs/architecture/meter.md +37 -47
- package/docs/architecture/saturation.md +75 -101
- package/docs/architecture/store.md +118 -99
- package/docs/architecture/thresholds.md +66 -73
- package/docs/failures/tempting-but-wrong.md +139 -165
- package/docs/harness/gates.md +27 -32
- package/docs/mechanisms/alu.md +22 -69
- package/docs/mechanisms/cast.md +76 -71
- package/docs/mechanisms/confluence.md +22 -29
- package/docs/mechanisms/cover.md +58 -66
- package/docs/mechanisms/extraction.md +33 -37
- package/docs/mechanisms/prefix-completion.md +36 -39
- package/docs/mechanisms/recall.md +60 -53
- package/docs/mechanisms/reference.md +63 -49
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/alu/README.md +90 -298
- package/src/derive/README.md +94 -256
- package/src/mind/learning.ts +11 -12
- package/src/mind/mind.ts +4 -4
- package/src/mind/types.ts +10 -15
- package/src/rabitq-ivf/README.md +11 -8
- package/src/store.ts +5 -5
|
@@ -1,68 +1,75 @@
|
|
|
1
|
-
# Recall — Nearest Stored Form
|
|
1
|
+
# Recall — The Nearest Stored Form
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
`recall` answers with the continuation of the stored form nearest the question.
|
|
4
|
+
Resonance proposes, and bytes decide (`src/mind/mechanisms/recall.ts`). Its
|
|
5
|
+
tiers degrade in order, and each one is priced as what it is. A tier that only
|
|
6
|
+
resembles accounts for little, so anything that explains more beats it.
|
|
5
7
|
|
|
6
|
-
##
|
|
8
|
+
## Supply and budget
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
All tiers read the response's single top-`k` resonance (`pre.resonance()`,
|
|
11
|
+
`k = 2·recallQueryK`), guided by the query gist. The last tier re-folds the
|
|
12
|
+
hit's bytes instead of trusting its estimate.
|
|
11
13
|
|
|
12
|
-
## Tiers
|
|
14
|
+
## Tiers
|
|
13
15
|
|
|
14
|
-
| Tier | Name
|
|
15
|
-
| ---- |
|
|
16
|
-
| 0 |
|
|
17
|
-
| 0b |
|
|
18
|
-
| 1 |
|
|
19
|
-
|
|
|
20
|
-
|
|
|
16
|
+
| Tier | Name | Gate | Action |
|
|
17
|
+
| ---- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
18
|
+
| 0 | exact identity | the question resolves | reverse-recall to its best-resonating predecessor, at `STEP` |
|
|
19
|
+
| 0b | argument binding | one maximal recognised constituent of at least `2W` that is an edge source, with no substantial form outside it. Fragments that answer other questions are set aside first. When the pick would otherwise be blind, the climb is asked first | `follow` its continuation, guided by the whole question |
|
|
20
|
+
| 1 | clean resonance | per hit, `score ≥ identityBar(D, W, len)` | `project` the hit. A hit that restates the question goes only through reverse-recall |
|
|
21
|
+
| — | an argument held under the equivalence | no argument recognised, and a canonical index present | the climb's points that the question canonically contains bind as arguments (`evidence.md`) |
|
|
22
|
+
| 2 | scaffolding-dominated | resonance `≥ significanceBar`; the climb's anchor clears `consensusFloor(N)` (or is broad with a peak above `ln 2`); the question is not all scaffolding | `project` the anchor at `CONCEPT` |
|
|
23
|
+
| 3 | last resort | the share of the question the grounding explains, `max(0, cos − sig)·√(lenG/lenQ) ≥ reachThreshold(W)` | `project` the best grounded hit, at `STEP` |
|
|
24
|
+
| 3b | substitution bridge | only after every gist tier failed (below) | align and substitute |
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
**Tier 2 refuses three things.** Each would voice the anchor's own occupant as
|
|
27
|
+
the asker's:
|
|
28
|
+
|
|
29
|
+
- a continuation that voices the anchor's displaced filler
|
|
30
|
+
(`voicesDisplacedFiller`);
|
|
31
|
+
- a continuation that is a subspan of the question;
|
|
32
|
+
- an anchor that is a co-instance of the question (`evidence.md`).
|
|
33
|
+
|
|
34
|
+
Putting the asker's referent in that place is `reference`'s job, because it
|
|
35
|
+
needs the corpus's own evidence of carriage.
|
|
23
36
|
|
|
24
37
|
## Echo — the refusing tail
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
substituted byte — the double-charge that let `cast` outbid the bridge).
|
|
50
|
-
Zero-substitution identity bridges carry `complete: true` (the whole read-out);
|
|
51
|
-
substituted bridges do not.
|
|
52
|
-
|
|
53
|
-
Scaffolding-only queries abstain: when every window that could anchor is
|
|
54
|
-
saturated (corpus-global scaffolding, `allWindowsAreScaffolding`), the bridge
|
|
55
|
-
returns nothing — one substituted word cannot carry the load.
|
|
39
|
+
When no tier grounds, the top hit's exact cosine is recomputed from its bytes
|
|
40
|
+
and read with the same chance-corrected fraction. The outcome is one of two:
|
|
41
|
+
|
|
42
|
+
- **Silence,** when the fraction is below reach, or when the hit restates the
|
|
43
|
+
question.
|
|
44
|
+
- **An echo,** otherwise: the hit's own bytes, labelled `recall-echo` and
|
|
45
|
+
declaring `used: ∅`. It tells the asker that the answer is near, not derived.
|
|
46
|
+
|
|
47
|
+
## The substitution bridge — refusal path only (`src/mind/bridge.ts`)
|
|
48
|
+
|
|
49
|
+
The bridge aligns a candidate around the rarest stored windows. A mismatch
|
|
50
|
+
becomes a corroborated substitution only when all of these hold:
|
|
51
|
+
|
|
52
|
+
- the question's span is attested in the corpus;
|
|
53
|
+
- the geometry clears `conceptThreshold`, or the halo clears `significanceBar`;
|
|
54
|
+
- the frame is unanimous;
|
|
55
|
+
- the gap is balanced in length.
|
|
56
|
+
|
|
57
|
+
Coverage must dominate the question, and no dismissed gap may hide known content
|
|
58
|
+
(`dismissedKnownContent`). Each substitution costs `CONCEPT`, and the
|
|
59
|
+
substituted spans are accounted. A question made only of scaffolding abstains,
|
|
60
|
+
because one substituted word cannot carry it. A zero-substitution identity
|
|
61
|
+
bridge is `complete`.
|
|
56
62
|
|
|
57
63
|
## Cost
|
|
58
64
|
|
|
59
|
-
Tiers 0
|
|
60
|
-
substitution
|
|
61
|
-
`moves + PASS·unaccounted`.
|
|
65
|
+
Tiers 0, 0b, 1 and 3 cost `STEP`. Tier 2 and the bridge cost `CONCEPT` per
|
|
66
|
+
substitution or scaffolding step. The floor is `STEP`.
|
|
62
67
|
|
|
63
68
|
## Pins
|
|
64
69
|
|
|
65
|
-
- `test/03
|
|
66
|
-
- `test/16
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
- `test/03` — exact identity and reverse-recall.
|
|
71
|
+
- `test/16`, `test/56` — corroborated substitutions, and the bridge's admission
|
|
72
|
+
by identity.
|
|
73
|
+
- `test/73` — a question made only of scaffolding stays silent.
|
|
74
|
+
- `test/154.6`, `test/154.8` — a stranger fragment is not bound; an argument
|
|
75
|
+
held only under the equivalence binds.
|
|
@@ -1,58 +1,72 @@
|
|
|
1
|
-
# Reference —
|
|
2
|
-
|
|
3
|
-
Reference voices a slot of a learned frame with the bytes the asker supplied in
|
|
4
|
-
that position — asserting _position_, not equivalence. The bytes are the
|
|
5
|
-
asker's, so voicing them cannot fabricate corpus knowledge; the fabricable claim
|
|
6
|
-
is the _relation_ about them, which the licence withholds.
|
|
7
|
-
|
|
8
|
-
## Matcher — `frameSlots` inventory
|
|
9
|
-
|
|
10
|
-
The shared matcher is `frameSlots` (`src/mind/match.ts`) via
|
|
11
|
-
`Precomputed.frames()`.
|
|
12
|
-
|
|
13
|
-
- Seeded at origin `(0,0)`, `alignAround` finds common runs (seed `W`) then
|
|
14
|
-
sweeps both directions; each gap is contracted by `contractGap` to its varying
|
|
15
|
-
core (shared prefix/suffix stripped) and tagged
|
|
16
|
-
`substitution | insertion | deletion`.
|
|
17
|
-
- `frameSlots` **reports, never judges**: every gap (any kind, any size), sorted
|
|
18
|
-
by `qs`, plus `covered` (shared bytes) and `matched` spans. No gate is applied
|
|
19
|
-
there.
|
|
20
|
-
|
|
21
|
-
## Gate — reference elects and licences; matcher does not
|
|
22
|
-
|
|
23
|
-
All voicing gates belong to the **consumer**
|
|
24
|
-
(`src/mind/mechanisms/reference.ts`), not the matcher. A shared layer that
|
|
25
|
-
refused on their behalf would be reference-shaped and hide most real pairings.
|
|
26
|
-
|
|
27
|
-
- **Election:** `electFrame` groups inventory by full slot signature
|
|
28
|
-
(`qs:qe,...`) and keeps the modal group — one frame, not one slot.
|
|
29
|
-
- **Carriage licence:** `carriesFillers` —
|
|
30
|
-
`substituteAll(contA, fillersA→fillersB) == contB` byte-exact, all slots
|
|
31
|
-
simultaneously (longest needle first). Constant continuations pass vacuously;
|
|
32
|
-
filler-dependent content is refused.
|
|
33
|
-
- **Four voicing gates** (in `voiceable` + caller):
|
|
34
|
-
1. frame `dominates` query (`covered > |query|/2`);
|
|
35
|
-
2. every slot reaches one window `W` on _both_ sides;
|
|
36
|
-
3. no insertion/deletion (substitutions only);
|
|
37
|
-
4. fillers pairwise distinct. Additional: referents pairwise distinct and no
|
|
38
|
-
slot inside `answeredSpans`.
|
|
39
|
-
|
|
40
|
-
Matched frame + every slot is `accounted`; `complete: true`.
|
|
1
|
+
# Reference — Voice a Slot With the Asker's Bytes
|
|
41
2
|
|
|
42
|
-
|
|
3
|
+
`reference` learns a frame from worked examples and voices its slot with the
|
|
4
|
+
bytes the asker put in that position (`src/mind/mechanisms/reference.ts`). It
|
|
5
|
+
asserts _position_ ("this is the thing you named, where the corpus keeps one"),
|
|
6
|
+
not equivalence. The voiced bytes are the asker's, so they cannot fabricate
|
|
7
|
+
corpus knowledge. What can be fabricated is the relation claimed about them, and
|
|
8
|
+
the licence exists to withhold that.
|
|
9
|
+
|
|
10
|
+
The substitution bridge refuses this shape, and is right to. A substitution
|
|
11
|
+
asserts that two spans mean the same, which no corpus can corroborate for bytes
|
|
12
|
+
it has never seen.
|
|
13
|
+
|
|
14
|
+
## Matcher — the frame inventory
|
|
15
|
+
|
|
16
|
+
`Precomputed.frames()` reads the ranked candidates as instances of the
|
|
17
|
+
question's own frame, through `frameSlots`, which reports and elects nothing
|
|
18
|
+
(`match-project.md`).
|
|
19
|
+
|
|
20
|
+
Its supply is the shared top-`k` resonance, so a frame the corpus instantiates
|
|
21
|
+
only once within `k` is out of reach. Measured on the trained store,
|
|
22
|
+
`How do you say 'flurbish' in French?` finds one instance of its frame in the
|
|
23
|
+
top 24, so `reference` abstains. Widening the supply is not the fix: abstaining
|
|
24
|
+
on thin evidence is.
|
|
25
|
+
|
|
26
|
+
## Election and voicing gates
|
|
43
27
|
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
|
|
28
|
+
`electFrame` keeps the modal group of instances that place the question's slots
|
|
29
|
+
alike. It needs at least `MIN_INSTANCES = 2`, because one alignment agrees with
|
|
30
|
+
nothing. Each instance must also be voiceable:
|
|
31
|
+
|
|
32
|
+
1. the frame dominates the question, covering more than half of it;
|
|
33
|
+
2. every slot reaches one window `W` on both sides;
|
|
34
|
+
3. substitutions only, with no insertion or deletion;
|
|
35
|
+
4. the fillers are pairwise distinct, the referents are distinct, and no slot
|
|
36
|
+
lies inside an already answered span.
|
|
37
|
+
|
|
38
|
+
## The licence — what a new referent may inherit
|
|
39
|
+
|
|
40
|
+
Each instance's continuation is followed, one at a time, because refusal is the
|
|
41
|
+
common outcome and usually comes on the second instance. Two checks apply:
|
|
42
|
+
|
|
43
|
+
- **Co-variation.** `carriesFillers` requires
|
|
44
|
+
`substituteAll(contA, fillersA → fillersB) == contB`, byte for byte, for all
|
|
45
|
+
slots at once. Content that depends on which filler stands in the slot is
|
|
46
|
+
refused.
|
|
47
|
+
- **A fact filed under a filler is not a carriage.** A continuation that does
|
|
48
|
+
not vary passes co-variation vacuously, and coincidence lives there. If an
|
|
49
|
+
instance's answer is a continuation of its own filler, it is something the
|
|
50
|
+
corpus knows _about_ that filler. Two people born in Wellington once gave an
|
|
51
|
+
unknown `Zorblax` the same birthplace. `Run gcc hello.c` is filed under the
|
|
52
|
+
question alone, so it still carries.
|
|
53
|
+
|
|
54
|
+
## Cost
|
|
47
55
|
|
|
48
|
-
`
|
|
56
|
+
`moves = STEP · slots + STEP`: one binding per slot and one edge followed. It is
|
|
57
|
+
not `CONCEPT`, because the reading is byte identity, not halo. The matched frame
|
|
58
|
+
and every slot are `accounted`, the answer is `complete`, and no scaffolding is
|
|
59
|
+
reported. The floor is `2·STEP`, checked with `worthRunning` before `frames()`
|
|
60
|
+
is touched.
|
|
49
61
|
|
|
50
62
|
## Provenance
|
|
51
63
|
|
|
52
|
-
`
|
|
64
|
+
`reference`, with the trace steps `bindReferent` and `referenceLicence`.
|
|
53
65
|
|
|
54
66
|
## Pins
|
|
55
67
|
|
|
56
|
-
- `test/76-reference-binding` — inventory
|
|
57
|
-
refused
|
|
58
|
-
|
|
68
|
+
- `test/76-reference-binding` — the split between inventory and gate; carried,
|
|
69
|
+
absorbed and refused frames; the multi-slot licence; `complete`; the guard on
|
|
70
|
+
answered spans; a fact filed under its filler is no carriage.
|
|
71
|
+
- `test/76-type-level-company` — the halo company by type that the inventory's
|
|
72
|
+
supply relies on.
|
package/jsr.json
CHANGED