@hviana/sema 0.9.1 → 0.9.3
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/src/meter.d.ts +19 -0
- package/dist/src/meter.js +19 -0
- package/dist/src/mind/evidence.d.ts +30 -0
- package/dist/src/mind/evidence.js +102 -0
- package/dist/src/mind/mechanisms/cast.d.ts +1 -1
- package/dist/src/mind/mechanisms/cast.js +73 -12
- package/dist/src/mind/mechanisms/cover.js +25 -3
- package/dist/src/mind/mechanisms/recall.js +93 -9
- package/dist/src/mind/mechanisms/reference.js +25 -0
- package/dist/src/mind/mind.d.ts +7 -0
- package/dist/src/mind/mind.js +3 -0
- package/dist/src/mind/pipeline-mechanism.js +15 -1
- package/dist/src/mind/pipeline.js +51 -8
- package/dist/src/mind/reasoning.js +65 -18
- package/dist/src/mind/resonance.d.ts +3 -2
- package/dist/src/mind/resonance.js +3 -2
- package/dist/src/mind/traverse.d.ts +94 -2
- package/dist/src/mind/traverse.js +611 -7
- package/dist/src/mind/types.d.ts +12 -0
- package/docs/INDEX.md +18 -17
- package/docs/INVARIANTS.md +1 -0
- package/docs/architecture/evidence.md +256 -0
- package/docs/architecture/exact-vs-approximate.md +10 -9
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/meter.ts +19 -0
- package/src/mind/evidence.ts +125 -0
- package/src/mind/mechanisms/cast.ts +77 -3
- package/src/mind/mechanisms/cover.ts +42 -3
- package/src/mind/mechanisms/recall.ts +123 -11
- package/src/mind/mechanisms/reference.ts +24 -1
- package/src/mind/mind.ts +6 -0
- package/src/mind/pipeline-mechanism.ts +15 -1
- package/src/mind/pipeline.ts +64 -8
- package/src/mind/reasoning.ts +82 -17
- package/src/mind/resonance.ts +3 -2
- package/src/mind/traverse.ts +652 -7
- package/src/mind/types.ts +10 -0
- package/test/154-the-question-names-the-step.test.mjs +368 -0
- package/test/155-the-relation-read-off-another-instance.test.mjs +376 -0
- package/test/29-counterfactual.test.mjs +21 -11
- package/test/76-reference-binding.test.mjs +32 -0
package/dist/src/mind/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { MindConfig } from "../config.js";
|
|
|
7
7
|
import type { Meter } from "../meter.js";
|
|
8
8
|
import type { GraphSearch, Leaf, Seg, Site } from "./graph-search.js";
|
|
9
9
|
import type { Rationale } from "./rationale.js";
|
|
10
|
+
import type { WindowIndex } from "./evidence.js";
|
|
10
11
|
import type { ContentFold, Grid } from "../geometry.js";
|
|
11
12
|
/** One {@link MindContext._depositTrees} entry — see that field's doc.
|
|
12
13
|
*
|
|
@@ -370,6 +371,17 @@ export interface MindContext extends GraphSearchHost {
|
|
|
370
371
|
* ordinary respond() and for the first turn of a conversation. */
|
|
371
372
|
currentTurnStart: number;
|
|
372
373
|
_edgeGuide: Vec | null;
|
|
374
|
+
/** The question currently being answered, as the material `chooseNext`'s
|
|
375
|
+
* exact tier witnesses a continuation's establishing contexts against —
|
|
376
|
+
* its bytes (canonical when the response's canon preserves offsets) and
|
|
377
|
+
* their window index. Set and cleared with `_edgeGuide`. `points` are the
|
|
378
|
+
* anchors the response's consensus climb scored, once it has climbed —
|
|
379
|
+
* the proposals the exact tier reads co-instances from. */
|
|
380
|
+
_edgeAsked: {
|
|
381
|
+
bytes: Uint8Array;
|
|
382
|
+
index: WindowIndex;
|
|
383
|
+
points?: readonly number[];
|
|
384
|
+
} | null;
|
|
373
385
|
_edgeChoice: Map<number, number>;
|
|
374
386
|
_prevSeen: Set<number> | null;
|
|
375
387
|
/** Session cache of node-id → perceived gist, for candidate scoring
|
package/docs/INDEX.md
CHANGED
|
@@ -19,24 +19,25 @@ proof in `test/` (pins that fail when the law is broken).
|
|
|
19
19
|
| Change vector search | `docs/architecture/exact-vs-approximate.md` + `docs/architecture/bounded-reads.md` | Scores propose, bytes dispose; ANN is bounded by `hubBound` |
|
|
20
20
|
| Profile or bound work | `docs/architecture/meter.md` + `docs/architecture/bounded-reads.md` | `meter.ts` is write-only; counters are product, phases are hints |
|
|
21
21
|
|
|
22
|
-
## Architecture laws (
|
|
22
|
+
## Architecture laws (15)
|
|
23
23
|
|
|
24
|
-
| Law | File | Summary
|
|
25
|
-
| --- | ------------------------------------------- |
|
|
26
|
-
| 1 | `docs/architecture/determinism.md` | No `Math.random`/`Date.now` in behaviour; seed-derived randomness; corpus-determined tie-breaks
|
|
27
|
-
| 2 | `docs/architecture/thresholds.md` | Every decision cutoff derived in `geometry.ts` over D/W/N; no tunable knobs
|
|
28
|
-
| 3 | `docs/architecture/exact-vs-approximate.md` | Vector scores rank only; identity via content-addressed lookup;
|
|
29
|
-
| 4 | `docs/architecture/cost-model.md` | Single ladder `MICRO`/`STEP`/`CONCEPT`/`PASS`; weight `moves + PASS·unaccounted`; `STEP`-grade compare
|
|
30
|
-
| 5 | `docs/architecture/match-project.md` | Shared `match.ts` family (`locate`/`alignGraded`/`frameSlots`/`project`); voicing gates belong to consumers
|
|
31
|
-
| 6 | `docs/architecture/mechanism-market.md` | `PipelineMechanism` (`floor`/`run`/`parse`); admissible-floor pruning, investment discipline, run-ahead bounds
|
|
32
|
-
| 7 | `docs/architecture/commonality.md` | Three: global (`reachOf`+`dominates`), weave-local (`depth[]`), window rarity
|
|
33
|
-
| 8 | `docs/architecture/bounded-reads.md` | No per-query read grows with N; `hubBound=√N` enforced at store via LIMIT/probe/prefix caps
|
|
34
|
-
| 9 | `docs/architecture/store.md` | `AbstractStore` owns dedup/indexing/batch; `store-sqlite.ts` is thin wrappers; canon index optional
|
|
35
|
-
| 10 | `docs/architecture/fold-contract.md` | `perceiveDeposit` and `perceive` agree; the read side names a branch as `intern` does; `contentLevels` is single boundary rule; no W/offset dependence
|
|
36
|
-
| 11 | `docs/architecture/memoization.md` | `Precomputed` is per-response lazy cache (promise-cached async); `beginResponse`/`endResponse` lifecycle
|
|
37
|
-
| 12 | `docs/architecture/saturation.md` | Every walk names a deciding saturation beside its cap; cap is safety net, not decision
|
|
38
|
-
| 13 | `docs/architecture/meter.md` | `meter.ts` is write-only work accounting; counts are exact, phases nest
|
|
39
|
-
| 14 | `docs/architecture/closure.md` | A derivation is closed when its structure accounts for the question's remainder; every transition asks that law, one engine walks the layers
|
|
24
|
+
| Law | File | Summary | Pins |
|
|
25
|
+
| --- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
|
|
26
|
+
| 1 | `docs/architecture/determinism.md` | No `Math.random`/`Date.now` in behaviour; seed-derived randomness; corpus-determined tie-breaks | `test/20` |
|
|
27
|
+
| 2 | `docs/architecture/thresholds.md` | Every decision cutoff derived in `geometry.ts` over D/W/N; no tunable knobs | `test/40`, `test/64` |
|
|
28
|
+
| 3 | `docs/architecture/exact-vs-approximate.md` | Vector scores rank only; identity via content-addressed lookup; six graded ladders | `test/51` |
|
|
29
|
+
| 4 | `docs/architecture/cost-model.md` | Single ladder `MICRO`/`STEP`/`CONCEPT`/`PASS`; weight `moves + PASS·unaccounted`; `STEP`-grade compare | `test/04`, `test/55` |
|
|
30
|
+
| 5 | `docs/architecture/match-project.md` | Shared `match.ts` family (`locate`/`alignGraded`/`frameSlots`/`project`); voicing gates belong to consumers | `test/24`, `test/76` |
|
|
31
|
+
| 6 | `docs/architecture/mechanism-market.md` | `PipelineMechanism` (`floor`/`run`/`parse`); admissible-floor pruning, investment discipline, run-ahead bounds | `test/01`, `test/04`, `test/153` |
|
|
32
|
+
| 7 | `docs/architecture/commonality.md` | Three: global (`reachOf`+`dominates`), weave-local (`depth[]`), window rarity | `test/17`, `test/34` |
|
|
33
|
+
| 8 | `docs/architecture/bounded-reads.md` | No per-query read grows with N; `hubBound=√N` enforced at store via LIMIT/probe/prefix caps | `test/77`, `test/90` |
|
|
34
|
+
| 9 | `docs/architecture/store.md` | `AbstractStore` owns dedup/indexing/batch; `store-sqlite.ts` is thin wrappers; canon index optional | `test/08` |
|
|
35
|
+
| 10 | `docs/architecture/fold-contract.md` | `perceiveDeposit` and `perceive` agree; the read side names a branch as `intern` does; `contentLevels` is single boundary rule; no W/offset dependence | `test/59`, `test/63`, `test/148`, `test/152` |
|
|
36
|
+
| 11 | `docs/architecture/memoization.md` | `Precomputed` is per-response lazy cache (promise-cached async); `beginResponse`/`endResponse` lifecycle | `test/42` |
|
|
37
|
+
| 12 | `docs/architecture/saturation.md` | Every walk names a deciding saturation beside its cap; cap is safety net, not decision | `test/27`, `test/16` |
|
|
38
|
+
| 13 | `docs/architecture/meter.md` | `meter.ts` is write-only work accounting; counts are exact, phases nest | `test/55` |
|
|
39
|
+
| 14 | `docs/architecture/closure.md` | A derivation is closed when its structure accounts for the question's remainder; every transition asks that law, one engine walks the layers | `test/133`–`151` |
|
|
40
|
+
| 15 | `docs/architecture/evidence.md` | A stored form is identified when the material at hand (question ∪ the node a derivation stands on) witnesses every byte of it, order-free; the question NAMES a continuation through its establishing context, or through another instance of its frame (a co-instance, never voiced as the answer); a step it did not name pays from what is still owed | `test/154`, `test/155` |
|
|
40
41
|
|
|
41
42
|
## Mechanisms (8)
|
|
42
43
|
|
package/docs/INVARIANTS.md
CHANGED
|
@@ -16,3 +16,4 @@
|
|
|
16
16
|
| 12 | Meter contracts | `src/meter.ts:Meter,PhaseCost,time` `src/mind/pipeline-mechanism.ts:Precomputed.shared` | `test/55` | `meter.md` |
|
|
17
17
|
| 13 | Saturation | `traverse.ts:edgeAncestors,types.ts:SaturationReason` `src/mind/junction.ts:junctionContainersFrom` `src/mind/resonance.ts:pivotInto` | `test/27` `test/16` | `saturation.md` |
|
|
18
18
|
| 14 | Closure | `src/mind/derivation.ts:admissible,advance,closeOver` | `test/133`–`151` | `closure.md` |
|
|
19
|
+
| 15 | Witnessed evidence | `src/mind/evidence.ts:witness,windowIndex` `src/mind/traverse.ts:chooseNext,askedEvidence,namedContinuations,answersOtherQuestions,coInstanceFiller,scaffoldExtents` | `test/154`, `test/155` | `evidence.md` |
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Witnessed Evidence — The Question Names the Step
|
|
2
|
+
|
|
3
|
+
> **Law:** a stored form is identified by the material at hand when every one of
|
|
4
|
+
> its bytes lies in a W-window that material holds — in any order, at any place,
|
|
5
|
+
> and wherever each piece of the material came from. A form witnessed in every
|
|
6
|
+
> byte but one contiguous span of content is ANOTHER INSTANCE of the same
|
|
7
|
+
> question: it says what the question's relation is, never what it asks about. A
|
|
8
|
+
> step the question did not name has to be paid for by material the question
|
|
9
|
+
> still owes.
|
|
10
|
+
|
|
11
|
+
## The operation — `src/mind/evidence.ts`
|
|
12
|
+
|
|
13
|
+
`witness(form, indexes, W)` reads one form against a list of window indexes
|
|
14
|
+
(`windowIndex`). It is the order-free reading of correspondence, beside
|
|
15
|
+
`alignRuns` (which produces runs) and `junctionContainersFrom(…, unordered)`
|
|
16
|
+
(which finds containers). It is exact, deterministic and linear: one index per
|
|
17
|
+
source and one probe per window of the form. A window is credited to the LAST
|
|
18
|
+
source that holds it, so source 0 (the question) is credited only with what
|
|
19
|
+
nothing else at hand supplies. A form shorter than W is never witnessed. The
|
|
20
|
+
form's own unwitnessed bytes come back as its `residue`.
|
|
21
|
+
|
|
22
|
+
## Where the material comes from
|
|
23
|
+
|
|
24
|
+
The corpus records, for every continuation, the questions that establish it: its
|
|
25
|
+
predecessors. A 2Wiki fact `The father of Frederick II is Peter III of
|
|
26
|
+
Aragon.`
|
|
27
|
+
is established by `Frederick II` and by `Frederick II father`. The asker's
|
|
28
|
+
question rarely repeats either one byte for byte, but it often holds every byte
|
|
29
|
+
of one of them.
|
|
30
|
+
|
|
31
|
+
The derivation stands on more than the question. The node it is following is
|
|
32
|
+
material too. On the second hop of
|
|
33
|
+
`Where was the place of death of the
|
|
34
|
+
director of film Beat Girl?` the node is
|
|
35
|
+
`Edmond T. Gréville`, which the first hop reached and the asker never wrote. The
|
|
36
|
+
establishing question `Edmond T.
|
|
37
|
+
Gréville place of death` is held by neither the
|
|
38
|
+
question nor the first hop's fact, only by both. Measured over 5,236 held-out
|
|
39
|
+
2WikiMultihopQA compositional questions, such a context is wholly witnessed by
|
|
40
|
+
the question alone 69 times, and by the question plus the first hop 2,153 times.
|
|
41
|
+
|
|
42
|
+
An establishing context is a DEPOSITED context: a predecessor with structural
|
|
43
|
+
parents or containers is a span interned inside bigger forms, and it inherits
|
|
44
|
+
their edges. Witnessing such a fragment named every fact it is a piece of (the
|
|
45
|
+
fragment `born?` named nine strangers' birthplaces on the 2Wiki fixture with
|
|
46
|
+
one-hop questions), so it never counts — the same structural predicate
|
|
47
|
+
`pivotInto` reads.
|
|
48
|
+
|
|
49
|
+
## Another instance of the question — `coInstanceFiller`, `byCoInstance`
|
|
50
|
+
|
|
51
|
+
The question rarely spells the relation the way the corpus does.
|
|
52
|
+
`When was the
|
|
53
|
+
director of film Jinpa born?` reaches `Pema Tseden`, whose fact is
|
|
54
|
+
established by `Pema Tseden date of birth`: no window joins `born` to
|
|
55
|
+
`date of birth`, so nothing is witnessed. What joins them is another instance of
|
|
56
|
+
the question.
|
|
57
|
+
|
|
58
|
+
A **co-instance** is a stored context that shares the question's FRAME, its
|
|
59
|
+
opening and its close byte for byte under the response's equivalence, around ONE
|
|
60
|
+
different filler, and whose filler is a thing the corpus knows: a stored context
|
|
61
|
+
with continuations of its own. `Where was Peter Jackson born?`, read against
|
|
62
|
+
`Where was the director of film Beat Girl born?`, shares `Where was` and `born?`
|
|
63
|
+
and leaves `Peter Jackson`. Three conditions make the reading exact, and each
|
|
64
|
+
was measured necessary:
|
|
65
|
+
|
|
66
|
+
- **Order.** A frame is not a bag of windows. Read order-free,
|
|
67
|
+
`Lyon is a city in France` passes for an instance of
|
|
68
|
+
`what if the capital of France were Lyon?`, which NAMES Lyon, and a
|
|
69
|
+
coincidental window inside a filler splits it.
|
|
70
|
+
- **The filler is an entity.**
|
|
71
|
+
`Explain how photosynthesis converts sunlight
|
|
72
|
+
into chemical energy.` shares
|
|
73
|
+
a frame with `Explain how photosynthesis
|
|
74
|
+
works.`, but its slot holds a
|
|
75
|
+
description of the frame's own subject, and it answers the question. The
|
|
76
|
+
filler is the longest stored context opening where the slot opens (up to one
|
|
77
|
+
window earlier: the `T` of `Taika` can sit in the question's `as t`).
|
|
78
|
+
- **The frame is unsaid.** Every frame window must be held by the material, so
|
|
79
|
+
on the walk a frame a product already said cannot name a second step.
|
|
80
|
+
`Who is the father of …?` names the second hop of
|
|
81
|
+
`Who is the father of the director of film Beat Girl?` and not the
|
|
82
|
+
grandfather. Scaffolding windows are exempt, because they are nobody's
|
|
83
|
+
evidence (`is` in `Which country Leo Mittler is from?`).
|
|
84
|
+
|
|
85
|
+
The co-instance's continuation is established by other contexts too
|
|
86
|
+
(`Peter Jackson place of birth`), and the one holding the filler spells the
|
|
87
|
+
relation the corpus's way: a RELATION FRAME, `` · `place of birth`. A frame
|
|
88
|
+
counts only where two co-instances spell it alike. One alignment agrees with
|
|
89
|
+
nothing, which is the bar `reference` holds a frame to (`MIN_INSTANCES`). The
|
|
90
|
+
exact tier's second reading (`byCoInstance`, run only when no establishing
|
|
91
|
+
context is witnessed outright) puts the node the derivation stands on in each
|
|
92
|
+
frame and looks the result up by content: `Edmond T. Gréville place of birth`
|
|
93
|
+
exists, so its continuation is named. Neither the equivalence nor the frame is
|
|
94
|
+
stored as a unit, and nothing is approximate.
|
|
95
|
+
|
|
96
|
+
**The proposals are the consensus climb's.** The climb already scores the stored
|
|
97
|
+
forms the question's regions reach, and the co-instances are among its points.
|
|
98
|
+
Its scored anchors are published on the question when it runs, and the tier
|
|
99
|
+
reads the `chainReach(W)` most corroborated of them. It climbs nothing of its
|
|
100
|
+
own. A first version climbed every question window itself and cost the 116-query
|
|
101
|
+
battery +16% climb visits for zero namings. Two consequences follow, both
|
|
102
|
+
pinned:
|
|
103
|
+
|
|
104
|
+
- A pick made before the climb read less evidence than one made after, so the
|
|
105
|
+
response's pick memo is cleared when the points arrive. Traced and untraced
|
|
106
|
+
responses agree.
|
|
107
|
+
- Recall's argument binding, which runs before the climb, asks for it first when
|
|
108
|
+
the argument has several continuations and the question names none outright.
|
|
109
|
+
That is exactly where the choice would otherwise be blind.
|
|
110
|
+
|
|
111
|
+
A question the corpus holds verbatim is its own instance and reads no frames.
|
|
112
|
+
Frames are read once per question (and once per walk material), and every node
|
|
113
|
+
pays only the exact lookups.
|
|
114
|
+
|
|
115
|
+
The same reading refuses the co-instance as an ANSWER, because its own
|
|
116
|
+
continuation speaks of its own filler. Recall's consensus-anchor tier does not
|
|
117
|
+
ground it: `Where was the performer of song God (John Lennon Song) born?`
|
|
118
|
+
elected `Where was Nicki Minaj (Nicki Minaj Song) born?`. Fusion does not fuse
|
|
119
|
+
it as a further topic. A CAST comparison does not take it as its dominant: it
|
|
120
|
+
set `Where was Shakira (Shakira Song) born?` against `John Lennon` and voiced
|
|
121
|
+
Shakira's birthplace.
|
|
122
|
+
|
|
123
|
+
## Arguments the question holds under the response's equivalence
|
|
124
|
+
|
|
125
|
+
Recognition matches bytes and the query fold's own boundaries. 2Wiki title-cases
|
|
126
|
+
its questions (`… of film Man At Bath work at?` for the stored `Man at Bath`),
|
|
127
|
+
and a title inside a question lines up with none of the fold's cuts. When
|
|
128
|
+
recall's argument binding finds no recognised argument, the stored forms the
|
|
129
|
+
consensus climb reaches become candidates if the question holds them under the
|
|
130
|
+
response's equivalence (`canonHeldPoints`: canonical containment,
|
|
131
|
+
offset-preserving, so the span is the question's own). The approximate climb
|
|
132
|
+
proposes and exact containment decides. This is read after the clean-resonance
|
|
133
|
+
tier, so a near-identical question pays no climb for it. The canonical-form
|
|
134
|
+
index it relies on is the one the trainer builds after training
|
|
135
|
+
(`buildCanonIndex`, progress.ts).
|
|
136
|
+
|
|
137
|
+
A fragment that answers other questions is no argument and no independent piece
|
|
138
|
+
of the question either. It is set aside BEFORE the binding looks for one maximal
|
|
139
|
+
argument, so `director` no longer cancels `Man at Bath`. The same predicate
|
|
140
|
+
gates CAST's redirection: the substitute `ong)?`, the tail of every
|
|
141
|
+
`… (… Song)?` question, voiced a stranger's birthplace.
|
|
142
|
+
|
|
143
|
+
## Its consumers
|
|
144
|
+
|
|
145
|
+
| Where | What it decides |
|
|
146
|
+
| --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
147
|
+
| `chooseNext` (traverse.ts) | **The exact tier.** It names the continuation one of whose establishing contexts (other than the node) is witnessed by the question plus the node, with the question supplying at least one window the node does not. It ranks first among the readings; the distributional ladder decides only when nothing is named, or among continuations named equally. |
|
|
148
|
+
| `askedEvidence` (traverse.ts) | The question spans that named a pick. A mechanism projecting through the pick accounts for them, because evidence travels (mechanism-market.md). Recall's argument binding uses this. |
|
|
149
|
+
| `preConsumed` (pipeline.ts) | When a grounding does not declare `used`, what it spoke for is the forms inside its answer that the question already holds. The entity the answer added stays pivotable. |
|
|
150
|
+
| The walk (reasoning.ts) | A pivot is NAMED when one of its continuation's establishing contexts is witnessed by what of the question no product has said yet, plus the pivot. A named pivot MOVES. An unnamed one is offered only while the derivation still owes something, and the law then decides by carrying. No grounding owns the next step: a CAST grounding used to move through any term inside its answer, unasked (`Who is the director of The Jerk?` walked on to Carl Reiner's citizenship). |
|
|
151
|
+
| `answersOtherQuestions` (traverse.ts) — cover sites and recall's argument binding | A FRAGMENT is a form that sits inside other forms, has several continuations, and leaves at least one window of the question beyond it. It answers other questions, so it leads somewhere for this question only when the question names one of its continuations. Recall's binding read the same fragment (`director`) and voiced the most-poured stranger's fact. |
|
|
152
|
+
| `byCoInstance` (traverse.ts) | The exact tier's second reading: the relation read off another instance of the question, transferred to the node by an exact substitution. |
|
|
153
|
+
| Recall's consensus anchor, fusion roots | A co-instance of the question is never voiced as its answer, nor fused as a further topic. |
|
|
154
|
+
| CAST comparison (mechanisms/cast.ts) | A comparison voices two structures, so the question must evidence the analog with a window of its own: neither inside the dominant's runs nor scaffolding. `father of Frederick II?` evidenced `Peter III of Aragon father` only with `father` and `of`, and the comparison glued that bare question onto the answer. |
|
|
155
|
+
|
|
156
|
+
A cover span made of nothing but scaffolding (every window a hub,
|
|
157
|
+
`scaffoldSpans`) is not accounted. The form recognised there, such as the song
|
|
158
|
+
`What` in the trained store, is one of thousands the bytes could name. This is
|
|
159
|
+
measured only on the trained store (`What country is Jerry Bock a citizen of?`
|
|
160
|
+
was won by `The performer of What is Melinda Marx.` glued onto the right fact).
|
|
161
|
+
A synthetic fixture could not reproduce that regime, because content addressing
|
|
162
|
+
folds every filler's `What` into a handful of shared nodes, so no suite test
|
|
163
|
+
pins this rule.
|
|
164
|
+
|
|
165
|
+
## What the question owes
|
|
166
|
+
|
|
167
|
+
The derivation is born owing only its discriminative material. The bytes a
|
|
168
|
+
corpus-global scaffolding window reaches (`scaffoldExtents`, the same "hub"
|
|
169
|
+
reading as `allWindowsAreScaffolding` and the bridge's `explainedSpan`) are
|
|
170
|
+
nobody's debt. Otherwise a step could claim to pay `Who is the` by restating
|
|
171
|
+
`is`, which every fact holds. Pricing is untouched: the ladder still charges
|
|
172
|
+
every unexplained byte, because for a question made only of scaffolding,
|
|
173
|
+
covering those bytes is the evidence. Making scaffolding free in the market was
|
|
174
|
+
measured and refused, because it changed dialogue answers
|
|
175
|
+
(`How are you
|
|
176
|
+
today?`).
|
|
177
|
+
|
|
178
|
+
The hub reading behind `scaffoldExtents` is floored at `chainReach(W)`
|
|
179
|
+
containers. Inside one deposit's fold, a window is already contained by up to
|
|
180
|
+
that many chunks and branches, so on a store of a few facts the √N reading would
|
|
181
|
+
call every window frame. That count measures fold structure, not corpus
|
|
182
|
+
commonality (`test/22`'s two-fact chains are exactly that regime).
|
|
183
|
+
|
|
184
|
+
## Bounds
|
|
185
|
+
|
|
186
|
+
The exact tier reads at most √N establishing contexts per decision, floored at
|
|
187
|
+
`chainReach(W)`. It asks the cheapest candidates first and compares scores
|
|
188
|
+
afterwards in the continuations' own order. It abstains, metered as
|
|
189
|
+
`askedReadsSaturated`, in two cases: the continuation read came back at the √N
|
|
190
|
+
cap, or the question holds no window the node lacks. One short prefix read
|
|
191
|
+
refuses most predecessors before a whole form is reconstructed. Picks are
|
|
192
|
+
memoized per node per question.
|
|
193
|
+
|
|
194
|
+
## Measured
|
|
195
|
+
|
|
196
|
+
2Wiki held-out fixture: the evidence triples of 300 validation rows, deposited
|
|
197
|
+
as `wiki2.ts` does, with the canonical-form index built as the trainer builds
|
|
198
|
+
it, and asked the rows' own composed questions. Same evidence "plus instances":
|
|
199
|
+
261 one-hop questions about OTHER entities, built from other validation rows by
|
|
200
|
+
replacing the first hop's phrase with its referent
|
|
201
|
+
(`Where was the director of film X born?` → `Where was Óskar Jónasson born?`)
|
|
202
|
+
and answered with the second hop's fact. No test entity has one.
|
|
203
|
+
|
|
204
|
+
| Compositional correct (of 133) | Witnessing only (655b192) | Final |
|
|
205
|
+
| ------------------------------ | ------------------------- | ----- |
|
|
206
|
+
| Fixture | 52 | 56 |
|
|
207
|
+
| Plus instances | 41 | 89 |
|
|
208
|
+
|
|
209
|
+
The first hop is now right on 114 and 109 of the 133. Of the first hops still
|
|
210
|
+
wrong, most name the entity differently from the corpus (`Clara Novello` for
|
|
211
|
+
`Clara Anastasia Novello`). That is an alias, which no byte reading recovers.
|
|
212
|
+
|
|
213
|
+
Removing CAST's unasked step cost six right answers on the fixture without
|
|
214
|
+
instances: second hops that were right paraphrases taken without evidence
|
|
215
|
+
(`work at`, `is from`, `When was … born`). The same licence produced the Carl
|
|
216
|
+
Reiner extension on the trained store. Without an instance, nothing names those
|
|
217
|
+
relations, and the chain stops at the first hop. The answers gained plus
|
|
218
|
+
instances are those relations: `born` → place of birth, `Why did … die` → cause
|
|
219
|
+
of death, `study`/`graduate from` → educated at, `work at` → employer, `is from`
|
|
220
|
+
→ country of citizenship.
|
|
221
|
+
|
|
222
|
+
The inference count stays low. Two hops of `father` from a question that says
|
|
223
|
+
`father` once, as in `paternal grandfather`, are not composed: the store holds
|
|
224
|
+
no evidence that `grandfather` composes `father` twice.
|
|
225
|
+
|
|
226
|
+
On the 31.7M-node store's 116-query battery, two dialogue answers changed
|
|
227
|
+
(neither was correct before). The deterministic read counters rose about 4%
|
|
228
|
+
(`bytesRead`, `ancestorVisits`, `edgeProbes`), with ANN queries up 1%. CPU on
|
|
229
|
+
this workstation varies by ±15% between back-to-back runs of one build, and
|
|
230
|
+
paired runs read 163 s against 152 s and 171 s, then 223 s against 203 s under
|
|
231
|
+
outside load. The co-instance tier read 190 forms over the battery and named
|
|
232
|
+
nothing there: on that store a frame's windows are scaffolding, and the one-hop
|
|
233
|
+
questions it would need are not in the corpus.
|
|
234
|
+
|
|
235
|
+
## Pins
|
|
236
|
+
|
|
237
|
+
- `test/154` — witnessing semantics. The named continuation beats the
|
|
238
|
+
most-poured one. The second hop is named by the question plus the introduced
|
|
239
|
+
entity, whatever grounded the first hop. A question that names no further step
|
|
240
|
+
is not extended. A fragment voices none of its continuations unless the
|
|
241
|
+
question names one, in the cover and in recall's argument binding. A
|
|
242
|
+
comparison needs two things named. An argument held only under the response's
|
|
243
|
+
equivalence binds. Each assertion was verified by mutation.
|
|
244
|
+
- `test/155` — the relation read off another instance of the frame; absent
|
|
245
|
+
without two instances that agree; refused for a partly shared frame; never
|
|
246
|
+
voiced as the answer; a frame a product already said names no further step; a
|
|
247
|
+
description in the slot is no other instance; traced and untraced responses
|
|
248
|
+
agree; fusion does not fuse a co-instance, nor does a comparison take one as
|
|
249
|
+
its dominant. Verified by mutation.
|
|
250
|
+
- `test/76` — a fact the corpus files under an instance's filler is no carriage:
|
|
251
|
+
`reference` does not construct one for a new referent.
|
|
252
|
+
- `test/29` C3 — a further hop inside a comparison's seat waits to be asked.
|
|
253
|
+
- Unpinned, measured only at fixture scale. Excluding fragments from
|
|
254
|
+
establishing contexts is worth 16 answers on the fixture with one-hop
|
|
255
|
+
questions. Refusing a fragment as CAST's redirection substitute is worth four.
|
|
256
|
+
Fragments with inherited edges appear only at that scale.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Exact vs Approximate — The Law and Its
|
|
1
|
+
# Exact vs Approximate — The Law and Its Six Ladders
|
|
2
2
|
|
|
3
3
|
Vector scores (`resonate` / `resonateHalo`) are RaBitQ **estimates**. They rank
|
|
4
4
|
candidates and gate broad regions; they never decide identity. Identity is
|
|
@@ -15,17 +15,18 @@ thresholds gate breadth, not truth.
|
|
|
15
15
|
|
|
16
16
|
## Graded evidence ladders
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Six subsystems share one shape — **exact → distributional → geometric** — with
|
|
19
19
|
earlier tiers strictly preferred. Never reorder tiers; never let an approximate
|
|
20
20
|
tier override an exact one.
|
|
21
21
|
|
|
22
|
-
| # | Site | Ladder (strong → weak)
|
|
23
|
-
| - | ------------------ |
|
|
24
|
-
| 1 | `resolve` | exact content-addressed fold → `canonResolve` (equivalence class, hash-then-verify)
|
|
25
|
-
| 2 | `locate` | exact bytes → halo role → gist
|
|
26
|
-
| 3 | `alignGraded` | literal W-gram runs → halo-matched sites + climb proposals (weave)
|
|
27
|
-
| 4 | `bridge` | junction containers → edge → synonym → whole-gist
|
|
28
|
-
| 5 | `crossRegionVotes` | exact containers → single synonym → double → `structuralResonance` (synthetic gist, gated hardest — no byte containment)
|
|
22
|
+
| # | Site | Ladder (strong → weak) | File |
|
|
23
|
+
| - | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
24
|
+
| 1 | `resolve` | exact content-addressed fold → `canonResolve` (equivalence class, hash-then-verify) | `mind/primitives.ts` |
|
|
25
|
+
| 2 | `locate` | exact bytes → halo role → gist | `mind/match.ts` |
|
|
26
|
+
| 3 | `alignGraded` | literal W-gram runs → halo-matched sites + climb proposals (weave) | `mind/match.ts` / `pipeline-mechanism.ts` |
|
|
27
|
+
| 4 | `bridge` | junction containers → edge → synonym → whole-gist | `mind/resonance.ts` |
|
|
28
|
+
| 5 | `crossRegionVotes` | exact containers → single synonym → double → `structuralResonance` (synthetic gist, gated hardest — no byte containment) | `mind/attention.ts` |
|
|
29
|
+
| 6 | `chooseNext` | an establishing context witnessed by the question ∪ the node (evidence.md) → distributional support (prevCount, poured mass) → first-inserted | `mind/traverse.ts` |
|
|
29
30
|
|
|
30
31
|
## Asymmetries (attention)
|
|
31
32
|
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/src/meter.ts
CHANGED
|
@@ -265,6 +265,25 @@ export class Meter {
|
|
|
265
265
|
/** Times the reasoner pivoted on a span its answer contains and stepped
|
|
266
266
|
* across that fact. */
|
|
267
267
|
pivotSteps = 0;
|
|
268
|
+
/** `chooseNext` picks the question NAMED — a continuation one of whose own
|
|
269
|
+
* establishing contexts the question (plus the node) wholly witnesses
|
|
270
|
+
* (traverse.ts, the exact tier). */
|
|
271
|
+
askedContinuations = 0;
|
|
272
|
+
/** Predecessor rows that exact tier read, against its shared √N budget. */
|
|
273
|
+
askedPredecessorReads = 0;
|
|
274
|
+
/** Times the tier abstained on a read it could not trust: the continuations
|
|
275
|
+
* came back at the √N cap, or its predecessor budget ran out before every
|
|
276
|
+
* continuation was asked about — the distributional ladder decided. */
|
|
277
|
+
askedReadsSaturated = 0;
|
|
278
|
+
/** Picks named by a CO-INSTANCE of the question — another instance of its
|
|
279
|
+
* frame whose continuation carries the relation over to this node by an
|
|
280
|
+
* exact substitution (traverse.ts, `byCoInstance`). */
|
|
281
|
+
coInstanceNamings = 0;
|
|
282
|
+
/** Proposed co-instances that tier read and witnessed. */
|
|
283
|
+
coInstanceReads = 0;
|
|
284
|
+
/** Cover sites dropped as FRAGMENTS whose several continuations the question
|
|
285
|
+
* names none of (mechanisms/cover.ts). */
|
|
286
|
+
unaskedFragments = 0;
|
|
268
287
|
/** Canon probes REFUSED because the canon budget ran out — the one thing the
|
|
269
288
|
* budget does that nothing could see. The budget itself is derived
|
|
270
289
|
* (`bytes.length · chainReach(W)²`, recognition.ts), and the cheap exact route
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// evidence.ts — what of a stored form the material at hand WITNESSES.
|
|
2
|
+
//
|
|
3
|
+
// A stored form is WITNESSED by some material when every one of its bytes lies
|
|
4
|
+
// inside a W-window that occurs literally in that material — in any order, at
|
|
5
|
+
// any place. It is the order-free reading of correspondence (`alignRuns` is
|
|
6
|
+
// its run-producing sibling, `junctionContainersFrom(…, unordered)` its
|
|
7
|
+
// container-finding one): a learnt form is evidenced by bytes that hold all of
|
|
8
|
+
// its windows, whichever way the asker happened to arrange them.
|
|
9
|
+
//
|
|
10
|
+
// The material is a LIST of sources because what a derivation has at hand is
|
|
11
|
+
// more than the question: the node it stands on is material too. A trained
|
|
12
|
+
// question `Edmond T. Gréville place of death` is in neither the asker's
|
|
13
|
+
// `Where was the place of death of the director of film Beat Girl?` nor the
|
|
14
|
+
// fact `The director of Beat Girl is Edmond T. Gréville.` the first hop reached
|
|
15
|
+
// — and both together hold every byte of it. The witness records which source
|
|
16
|
+
// held each window, so a consumer can tell the question's share (what the asker
|
|
17
|
+
// SAID about the form) from what the derivation itself brought.
|
|
18
|
+
//
|
|
19
|
+
// Exact, deterministic and linear: one window index per source, one probe per
|
|
20
|
+
// window of the form. Below one window a byte agreement is chance (the floor
|
|
21
|
+
// identityBar, attestedQ and the site test all draw), so a form shorter than W
|
|
22
|
+
// is never witnessed.
|
|
23
|
+
//
|
|
24
|
+
// Layering: bytes only — importable from traverse.ts and everything above it.
|
|
25
|
+
|
|
26
|
+
import { latin1 } from "../bytes.js";
|
|
27
|
+
|
|
28
|
+
/** Where each W-window of one source first occurs. Built once per source and
|
|
29
|
+
* reused across every form asked against it. */
|
|
30
|
+
export type WindowIndex = Map<string, number>;
|
|
31
|
+
|
|
32
|
+
export function windowIndex(bytes: Uint8Array, W: number): WindowIndex {
|
|
33
|
+
const index: WindowIndex = new Map();
|
|
34
|
+
for (let o = 0; o + W <= bytes.length; o++) {
|
|
35
|
+
const key = latin1(bytes.subarray(o, o + W));
|
|
36
|
+
if (!index.has(key)) index.set(key, o);
|
|
37
|
+
}
|
|
38
|
+
return index;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The windows of `index` (over `bytes`) that `spoken` does not hold — what
|
|
42
|
+
* of the question no product of the derivation has restated yet. The keys
|
|
43
|
+
* keep their positions in `bytes`, so a witnessing span still names the
|
|
44
|
+
* asker's bytes. */
|
|
45
|
+
export function unspoken(
|
|
46
|
+
index: WindowIndex,
|
|
47
|
+
spoken: ReadonlyArray<WindowIndex>,
|
|
48
|
+
): WindowIndex {
|
|
49
|
+
const out: WindowIndex = new Map();
|
|
50
|
+
for (const [key, at] of index) {
|
|
51
|
+
if (!spoken.some((s) => s.has(key))) out.set(key, at);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** How a form is witnessed by a list of sources. */
|
|
57
|
+
export interface Witnessing {
|
|
58
|
+
/** Every byte of the form lies in a window some source holds. */
|
|
59
|
+
complete: boolean;
|
|
60
|
+
/** The windows SOURCE 0 alone supplied — windows no later source holds — as
|
|
61
|
+
* merged spans of source 0. With the question as source 0, this is what the
|
|
62
|
+
* asker said about the form that the derivation did not already have. */
|
|
63
|
+
spans: Array<[number, number]>;
|
|
64
|
+
/** Bytes of source 0 inside `spans`. */
|
|
65
|
+
bytes: number;
|
|
66
|
+
/** The form's own bytes no source witnesses, as merged spans of the FORM —
|
|
67
|
+
* empty exactly when `complete`. ONE residue span is the shape of a
|
|
68
|
+
* co-instance: the same frame around a different filler (`When was Peter
|
|
69
|
+
* Jackson born?` read against `When was the director of film Jinpa
|
|
70
|
+
* born?` leaves `Peter Jackson`). */
|
|
71
|
+
residue: Array<[number, number]>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Witness `form` against `sources` (their window indexes, same order). A
|
|
75
|
+
* window is credited to the LAST source holding it — so source 0 is credited
|
|
76
|
+
* only with what nothing else at hand supplies. */
|
|
77
|
+
export function witness(
|
|
78
|
+
form: Uint8Array,
|
|
79
|
+
indexes: ReadonlyArray<WindowIndex>,
|
|
80
|
+
W: number,
|
|
81
|
+
): Witnessing {
|
|
82
|
+
if (form.length < W || indexes.length === 0) {
|
|
83
|
+
return {
|
|
84
|
+
complete: false,
|
|
85
|
+
spans: [],
|
|
86
|
+
bytes: 0,
|
|
87
|
+
residue: form.length > 0 ? [[0, form.length]] : [],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const covered = new Uint8Array(form.length);
|
|
91
|
+
const own: Array<[number, number]> = [];
|
|
92
|
+
for (let o = 0; o + W <= form.length; o++) {
|
|
93
|
+
const key = latin1(form.subarray(o, o + W));
|
|
94
|
+
let at = -1;
|
|
95
|
+
let from = -1;
|
|
96
|
+
for (let s = indexes.length - 1; s >= 0; s--) {
|
|
97
|
+
const p = indexes[s].get(key);
|
|
98
|
+
if (p !== undefined) {
|
|
99
|
+
at = p;
|
|
100
|
+
from = s;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (from < 0) continue;
|
|
105
|
+
covered.fill(1, o, o + W);
|
|
106
|
+
if (from === 0) own.push([at, at + W]);
|
|
107
|
+
}
|
|
108
|
+
const residue: Array<[number, number]> = [];
|
|
109
|
+
for (let i = 0; i < form.length; i++) {
|
|
110
|
+
if (covered[i]) continue;
|
|
111
|
+
const last = residue[residue.length - 1];
|
|
112
|
+
if (last !== undefined && last[1] === i) last[1] = i + 1;
|
|
113
|
+
else residue.push([i, i + 1]);
|
|
114
|
+
}
|
|
115
|
+
own.sort((a, b) => a[0] - b[0]);
|
|
116
|
+
const spans: Array<[number, number]> = [];
|
|
117
|
+
for (const [s, e] of own) {
|
|
118
|
+
const last = spans[spans.length - 1];
|
|
119
|
+
if (last !== undefined && s <= last[1]) last[1] = Math.max(last[1], e);
|
|
120
|
+
else spans.push([s, e]);
|
|
121
|
+
}
|
|
122
|
+
let bytes = 0;
|
|
123
|
+
for (const [s, e] of spans) bytes += e - s;
|
|
124
|
+
return { complete: residue.length === 0, spans, bytes, residue };
|
|
125
|
+
}
|