@hviana/sema 0.9.3 → 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 -59
- package/docs/INVARIANTS.md +36 -18
- package/docs/PHILOSOPHY.md +317 -0
- 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
|
@@ -22,171 +22,145 @@ discovering bugs:**
|
|
|
22
22
|
breaker; it can cause truncation and is not necessarily a budget-related
|
|
23
23
|
measure. Therefore, it must be used wisely.
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- **
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- **
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
`test/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- **
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
`
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
`
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
- **
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- **
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- **
|
|
129
|
-
`
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
`
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
- **
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- **
|
|
147
|
-
|
|
148
|
-
`test/34-cross-region.test.mjs` and
|
|
149
|
-
`test/52-climb-consensus-instrumentation.test.mjs`.
|
|
150
|
-
|
|
151
|
-
### 12. Imposing turn boundaries on `fold`
|
|
152
|
-
|
|
153
|
-
- **WRONG:** Cut the byte stream at conversation turn edges before folding, so
|
|
154
|
-
deposits and queries fold differently.
|
|
155
|
-
- **WHY:** Perception is a pure function of the bytes; deposit and inference
|
|
156
|
-
must compute the same tree for the same input (`AGENTS §1` Orientation — Hard
|
|
157
|
-
facts).
|
|
158
|
-
- **CORRECT:** Fold content-defined cuts (`contentLevels` in `geometry.ts` +
|
|
159
|
-
`twoEndedSeat`); turns are API state in `mind/mind.ts`, not segmentation.
|
|
160
|
-
Pinned by `test/59-fold-invariance.test.mjs` and
|
|
161
|
-
`test/63-fold-invariants.test.mjs`.
|
|
25
|
+
Each trap below was tried, looked like an improvement, and was measured wrong.
|
|
26
|
+
The laws themselves live in `docs/architecture/`; this file keeps only the
|
|
27
|
+
shortcuts that pass review and fail the evidence.
|
|
28
|
+
|
|
29
|
+
### 1. Telling the fold where the boundaries are
|
|
30
|
+
|
|
31
|
+
- **Tempting:** cut a conversation at its turns before folding, or stamp a
|
|
32
|
+
deposit as "the next turn" so its prefix is reused.
|
|
33
|
+
- **Refuted:** a cut the question cannot reproduce from its own bytes splits one
|
|
34
|
+
identity in two. Alignment went quadratic (5.2M cells against 0), and turns
|
|
35
|
+
asked verbatim stopped resolving. Reusing a `prev` that was not a
|
|
36
|
+
byte-identical prefix gave a wrong tree on 336 of 400 streams.
|
|
37
|
+
- **Instead:** the content decides every cut, and reuse is keyed by the prefix
|
|
38
|
+
bytes (`fold-contract.md`; `test/59`, `test/63`, `test/152`).
|
|
39
|
+
|
|
40
|
+
### 2. Asking the vector index whether two branches are the same
|
|
41
|
+
|
|
42
|
+
- **Tempting:** at intern, probe the ANN index for a near-duplicate to merge.
|
|
43
|
+
- **Refuted:** it was the dominant training cost, and the 1-bit code ranked a
|
|
44
|
+
byte-distinct branch as nearest, so two different subtrees collapsed onto one
|
|
45
|
+
id.
|
|
46
|
+
- **Instead:** exact dedup, then same-bytes reuse, then a near merge against the
|
|
47
|
+
write buffer only, decided by bytes (`store.md`; `test/02`).
|
|
48
|
+
|
|
49
|
+
### 3. Reading one population's cut with another population's measure
|
|
50
|
+
|
|
51
|
+
- **Tempting:** "common" is common, so corpus reach can decide CAST's frame,
|
|
52
|
+
weight can stand for distinct structures, and a window's containers can stand
|
|
53
|
+
for the contexts it reaches.
|
|
54
|
+
- **Refuted:**
|
|
55
|
+
- corpus reach for the cohort's frame failed the reorder probe (`test/17`);
|
|
56
|
+
- counting weight instead of distinct structures gave 29/42 against 6/42;
|
|
57
|
+
- container fan-out read as a hub called `fran` saturated, though it sits in 4
|
|
58
|
+
containers and reaches only 2 contexts (`test/49`).
|
|
59
|
+
- **Instead:** name the population; three measures, never substituted
|
|
60
|
+
(`commonality.md`, `saturation.md`).
|
|
61
|
+
|
|
62
|
+
### 4. Inventing a bar, or reusing one for a different quantity
|
|
63
|
+
|
|
64
|
+
- **Tempting:** a new number fitted to the case at hand, or a derived bar reused
|
|
65
|
+
elsewhere because it is derived.
|
|
66
|
+
- **Refuted:** `consensusFloor` is priced for pooled votes, and gating a single
|
|
67
|
+
fact's support with it refused clear corroboration at N≈325K. A fixed identity
|
|
68
|
+
cosine tolerates four foreign windows on a long span.
|
|
69
|
+
- **Instead:** a bar is never a new number. Derive it from `D`, `W` and `N` for
|
|
70
|
+
the quantity it gates (`thresholds.md`; `test/40`, `test/64`).
|
|
71
|
+
|
|
72
|
+
### 5. Stopping a junction walk early
|
|
73
|
+
|
|
74
|
+
- **Tempting:** stop when one side's upward cone is exhausted, or borrow
|
|
75
|
+
`edgeAncestors`' lateral-cone limit.
|
|
76
|
+
- **Refuted:** a junction can be reachable from one side only (`cold or hot`
|
|
77
|
+
from `cold`, while the cone of `hot` is empty), and the lateral limit
|
|
78
|
+
discarded half of the successful junctions.
|
|
79
|
+
- **Instead:** per-node hub guards, plus the shared `bound·W` net
|
|
80
|
+
(`saturation.md`; `test/16`, `test/34`).
|
|
81
|
+
|
|
82
|
+
### 6. Reading company by token
|
|
83
|
+
|
|
84
|
+
- **Tempting:** a halo of whole-partner signatures; or a sketch of depth 1; or
|
|
85
|
+
one that stops at the first unit seen twice; or one that includes byte atoms.
|
|
86
|
+
- **Refuted:** in turn, these gave synonyms at 0.146 against a 0.516 bar; no
|
|
87
|
+
signal (0.0319 against a 0.0416 control); pairs that never met (0.0165 against
|
|
88
|
+
0.0375); and CAST's analogy gate silenced (0.3636 to 0.2004).
|
|
89
|
+
- **Instead:** a bottom-k sketch of constituents at every depth, keyed by
|
|
90
|
+
identity, with hubs and atoms excluded (`halo-sketch.md`;
|
|
91
|
+
`test/76-type-level-company`).
|
|
92
|
+
|
|
93
|
+
### 7. Letting a fragment speak
|
|
94
|
+
|
|
95
|
+
- **Tempting:** a recognised form with continuations is evidence wherever it
|
|
96
|
+
appears.
|
|
97
|
+
- **Refuted:** a fragment inherits the edges of every whole it sits in.
|
|
98
|
+
Witnessing `born?` named nine strangers' birthplaces, the fragment `director`
|
|
99
|
+
cancelled the argument `Man at Bath`, and `ong)?` voiced a stranger's
|
|
100
|
+
birthplace.
|
|
101
|
+
- **Instead:** only deposited contexts establish anything, and a fragment that
|
|
102
|
+
answers other questions leads somewhere only when the question names one of
|
|
103
|
+
its continuations (`evidence.md`; `test/154`).
|
|
104
|
+
|
|
105
|
+
### 8. Making scaffolding free
|
|
106
|
+
|
|
107
|
+
- **Tempting:** scaffolding is nobody's evidence, so charge nothing for it in
|
|
108
|
+
the market.
|
|
109
|
+
- **Refuted:** dialogue answers changed (`How are you today?`), because for a
|
|
110
|
+
question made only of scaffolding, covering those bytes is the evidence.
|
|
111
|
+
- **Instead:** scaffolding is nobody's debt in the derivation, while the price
|
|
112
|
+
still charges every unexplained byte (`evidence.md`).
|
|
113
|
+
|
|
114
|
+
### 9. Giving a new reading its own analysis
|
|
115
|
+
|
|
116
|
+
- **Tempting:** a new tier climbs, resonates or aligns for itself.
|
|
117
|
+
- **Refuted:** the co-instance tier's private climb added 16% climb visits and
|
|
118
|
+
named nothing. Reading the shared climb's points named the same things for
|
|
119
|
+
free.
|
|
120
|
+
- **Instead:** read `Precomputed`, and add an analysis there only if none exists
|
|
121
|
+
(`memoization.md`).
|
|
122
|
+
|
|
123
|
+
### 10. Putting a consumer's gate in the shared matcher
|
|
124
|
+
|
|
125
|
+
- **Tempting:** `frameSlots` refuses what `reference` would refuse anyway.
|
|
126
|
+
- **Refuted:** the shared reading became shaped like `reference` and hid three
|
|
127
|
+
of four real pairings from every other consumer.
|
|
128
|
+
- **Instead:** the matcher reports, the consumer judges (`match-project.md`;
|
|
129
|
+
`test/47`).
|
|
130
|
+
|
|
131
|
+
### 11. Dropping weak evidence, or crediting it as strong
|
|
132
|
+
|
|
133
|
+
- **Tempting:** remove regions shorter than one window from the climb, or count
|
|
134
|
+
them as exact because their bytes resolve.
|
|
135
|
+
- **Refuted:** dropping them took the suite from 441 to 406. Crediting them as
|
|
136
|
+
exact let the 3-byte `of` lift a junk root past `consensusFloor`.
|
|
137
|
+
- **Instead:** they vote on their gist and pay the margin that approximate
|
|
138
|
+
evidence pays, scaled by how much of them is not stored (`attention.ts`).
|
|
139
|
+
|
|
140
|
+
### 12. Trying the exact supply first, then the approximate
|
|
141
|
+
|
|
142
|
+
- **Tempting:** a chain of `exact ?? approximate` supplies.
|
|
143
|
+
- **Refuted:** the approximate tier then overrides an ambiguity the exact one
|
|
144
|
+
found. For prefix completion, two forms opened by the index must refuse,
|
|
145
|
+
whatever resonance ranks first.
|
|
146
|
+
- **Instead:** one union, decided once by the guards (`prefix-completion.md`;
|
|
147
|
+
`test/72`).
|
|
162
148
|
|
|
163
149
|
### 13. Capping a combinatorial explosion instead of budgeting it
|
|
164
150
|
|
|
165
|
-
- **
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
is given, not a smaller cap.
|
|
182
|
-
- **THE IDEAL:** a universal **closure engine** — one law of closure, stated in
|
|
183
|
-
the quantities the machine already has (`leadsSomewhere`, the
|
|
184
|
-
exact-then-canonical identity, `accounted` bytes, the ladder, `hubBound`),
|
|
185
|
-
from which the reach of a gap, the offer of a hop, the depth of a join and the
|
|
186
|
-
scope of a substitution are CONSEQUENCES, not four separate decisions. Where
|
|
187
|
-
the repository stands against it — the engine (`closeOver`), which of the four
|
|
188
|
-
follow from the law, and the one that does not, with the reason — is stated in
|
|
189
|
-
`docs/architecture/closure.md`, and nowhere else.
|
|
190
|
-
- **THE STANDARD A CHANGE MUST MEET:** state which consequence it is, and show
|
|
191
|
-
it following from the law. A change that cannot be stated that way is not
|
|
192
|
-
ready.
|
|
151
|
+
- **Tempting:** answer an explosion with a derived limit: a cap on the pairs a
|
|
152
|
+
sweep enumerates, the continuations a hop offers, the candidates a scan
|
|
153
|
+
probes.
|
|
154
|
+
- **Refuted:** a cap stops the computation silently. Reach is lost, the
|
|
155
|
+
capability that depended on it goes with it, and no test fails, because the
|
|
156
|
+
tests were written against the capped behaviour. Capping truncates; removing
|
|
157
|
+
the cap lets the cost run; each failure hides the other.
|
|
158
|
+
- **Instead:** budget it. Charge the work in the one currency, make it visible
|
|
159
|
+
in the meter and the rationale, and let the search decide whether it is worth
|
|
160
|
+
paying (`cost-model.md`). Where the work is mechanical (enumeration, scans,
|
|
161
|
+
sweeps), the answer is an algorithm whose cost is structural in its input, not
|
|
162
|
+
a smaller cap. The ideal is one closure law from which the reach of a gap, the
|
|
163
|
+
offer of a hop, the depth of a join and the scope of a substitution follow as
|
|
164
|
+
consequences. Where the repository stands against that ideal is stated in
|
|
165
|
+
`closure.md`, and nowhere else. A change must state which consequence it is,
|
|
166
|
+
and show that it follows from the law.
|
package/docs/harness/gates.md
CHANGED
|
@@ -1,58 +1,53 @@
|
|
|
1
1
|
# Gates
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
There are four executable gates. The laws in `docs/architecture/` are enforced
|
|
4
|
+
by these and by the pins each law lists.
|
|
5
5
|
|
|
6
|
-
## 1 —
|
|
6
|
+
## 1. Correctness — every suite
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
-
npm test
|
|
9
|
+
npm test # tsc, then node --test over test/**/*.test.mjs against dist/
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
unrelated queries ground to nothing (`test/28`, `50`, `56`, `67`, `76`, `84`).
|
|
14
|
-
Determinism: same seed + deposit order + query gives byte-identical answer
|
|
15
|
-
(`test/20`). Every invariant is pinned, the closure law included
|
|
16
|
-
(`test/133`–`151`). §14–25 (pipeline), §64 (derived thresholds), AGENTS.md §2
|
|
17
|
-
invariants 1–5.
|
|
12
|
+
This gate guards every pinned contract, and two in particular:
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
- **Honest silence.** An unrelated question grounds to nothing (`test/28`,
|
|
15
|
+
`test/50`, `test/56`, `test/67`, `test/76`, `test/84`).
|
|
16
|
+
- **Determinism.** The same seed, deposit order and question give a
|
|
17
|
+
byte-identical answer (`test/20`).
|
|
18
|
+
|
|
19
|
+
The closure law is pinned in `test/133`–`151`, and the docs themselves are read
|
|
20
|
+
by `test/137`: an export that only the docs describe counts as documented.
|
|
21
|
+
|
|
22
|
+
## 2. Work accounting — the profiler
|
|
20
23
|
|
|
21
24
|
```js
|
|
22
|
-
const mind = new Mind({ profile: true });
|
|
23
|
-
await mind.respondText(q);
|
|
25
|
+
const mind = new Mind({ profile: true });
|
|
26
|
+
await mind.respondText(q);
|
|
24
27
|
console.log(formatReport(mind.lastCost)); // sumReports() over several
|
|
25
28
|
```
|
|
26
29
|
|
|
27
|
-
The public path is the harness
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
analyses charged to themselves, not to the first toucher; millisecond fields are
|
|
31
|
-
non-deterministic hints only. With an `inspectRationale` callback attached,
|
|
32
|
-
recognition idempotence still holds (`test/42`). `src/meter.ts`,
|
|
33
|
-
`docs/architecture/meter.md`, §55, `AGENTS.md` §6.
|
|
30
|
+
The public path is the harness: there is no separate bench script (`AGENTS.md`
|
|
31
|
+
§6, `meter.md`). Compare cold runs by their counters. Attaching an
|
|
32
|
+
`inspectRationale` callback must not change the answer (`test/42`).
|
|
34
33
|
|
|
35
|
-
## 3
|
|
34
|
+
## 3. Dependency footprint
|
|
36
35
|
|
|
37
36
|
```bash
|
|
38
37
|
node --test test/88-dependency-footprint.test.mjs
|
|
39
38
|
```
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
declares no `dependencies` (
|
|
43
|
-
near-zero footprint is a product feature. AGENTS.md §7, §3 (store has one
|
|
44
|
-
runtime dep: `node:sqlite`).
|
|
40
|
+
`dist/src` may import only `node:` builtins and relative paths, and
|
|
41
|
+
`package.json` declares no `dependencies` (`AGENTS.md` §7).
|
|
45
42
|
|
|
46
|
-
## 4
|
|
43
|
+
## 4. Fold invariance and sublinear scaling
|
|
47
44
|
|
|
48
45
|
```bash
|
|
49
46
|
node --test test/59-fold-invariance.test.mjs test/63-fold-invariants.test.mjs
|
|
50
47
|
node --test test/14-scaling.test.mjs
|
|
51
48
|
```
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
is sublinear in corpus size
|
|
56
|
-
|
|
57
|
-
`src/geometry.ts` (`contentLevels`), `docs/architecture/fold-contract.md` +
|
|
58
|
-
`bounded-reads.md`, §59, §63.
|
|
50
|
+
- `test/59` and `test/63`: segmentation is content-defined, so the grid's 14.3%
|
|
51
|
+
shift survival cannot pass (`fold-contract.md`).
|
|
52
|
+
- `test/14`: inference is sublinear in corpus size, measured as a log–log slope
|
|
53
|
+
over independent corpora, and linear in input length (`bounded-reads.md`).
|
package/docs/mechanisms/alu.md
CHANGED
|
@@ -1,81 +1,34 @@
|
|
|
1
1
|
# ALU — Computation as an Extension
|
|
2
2
|
|
|
3
|
-
The ALU is a self-contained sublibrary (`src/alu
|
|
4
|
-
pipeline. `aluToMechanism` (`src/mind/mechanisms/alu.ts`)
|
|
5
|
-
ordinary `PipelineMechanism
|
|
3
|
+
The ALU is a self-contained sublibrary (`src/alu/`, its own README) that knows
|
|
4
|
+
nothing about the pipeline. `aluToMechanism` (`src/mind/mechanisms/alu.ts`)
|
|
5
|
+
wraps it as an ordinary `PipelineMechanism`. It is the one way Sema produces
|
|
6
|
+
bytes that no deposit or asker supplied, and those bytes are authoritative.
|
|
6
7
|
|
|
7
|
-
## How it joins
|
|
8
|
+
## How it joins the market
|
|
8
9
|
|
|
9
|
-
Every mechanism may implement `parse(query) → ComputedSpan[]
|
|
10
|
-
`
|
|
11
|
-
`
|
|
12
|
-
|
|
10
|
+
Every mechanism may implement `parse(query) → ComputedSpan[]`. `think` collects
|
|
11
|
+
every parse into `pre.computed` before any `floor` runs. Each computed span is a
|
|
12
|
+
candidate at `STEP`, with `accounted = [[i, j]]`. The floor is `0` when there
|
|
13
|
+
are computed spans, and `null` otherwise.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
// src/mind/mechanisms/alu.ts — run()
|
|
16
|
-
{ bytes: u.bytes, accounted: [[u.i, u.j]], moves: STEP }
|
|
17
|
-
```
|
|
15
|
+
## Computation always wins — by masking, not by price
|
|
18
16
|
|
|
19
|
-
`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`
|
|
24
|
-
overlap a computed span. A learned `2+2 → 5` is dropped; the computed `4` is the
|
|
25
|
-
sole cover there. Masking is the only precedence — a computed span and a learned
|
|
26
|
-
edge both cost `STEP`.
|
|
27
|
-
|
|
28
|
-
A computed span and an unrelated rewrite still compose (`"ice 2+2" → "cold 4"`).
|
|
29
|
-
|
|
30
|
-
## Registry — `derive` composes ops
|
|
31
|
-
|
|
32
|
-
`OperationRegistry` (`src/alu/src/operation.ts`) holds every op indexed by
|
|
33
|
-
canonical name and surface form. `prim` registers irreducible roots; `derive`
|
|
34
|
-
registers a rewrite over existing ops via `ctx.apply`:
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
registry.derive(
|
|
38
|
-
"hypot",
|
|
39
|
-
2,
|
|
40
|
-
["hypot"],
|
|
41
|
-
(args, ctx) =>
|
|
42
|
-
ctx.apply("sqrt", [ctx.apply("add", [
|
|
43
|
-
ctx.apply("multiply", [args[0], args[0]]),
|
|
44
|
-
ctx.apply("multiply", [args[1], args[1]]),
|
|
45
|
-
])]),
|
|
46
|
-
);
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
`derive(name, arity, surfaceForms, body)` — name it, list forms, write the body
|
|
50
|
-
in terms of existing ops. No kernel or graph-search edit.
|
|
51
|
-
|
|
52
|
-
## Broadcast — scalar ops over n-d
|
|
53
|
-
|
|
54
|
-
One place (`OperationRegistry.context`): a non-structural op applied to `nd`
|
|
55
|
-
lists lifts element-wise, recursing into nested `nd`. Structural ops (`nd`,
|
|
56
|
-
`length`, `at`, `reduce`, …) are broadcast-exempt — they consume the list whole.
|
|
57
|
-
So `add([1,2,3], 10) = [11,12,13]` without matrix code.
|
|
58
|
-
|
|
59
|
-
## Resonance — meaning pre-resolved
|
|
60
|
-
|
|
61
|
-
Operand meanings are pre-resolved before the synchronous kernel runs
|
|
62
|
-
(`AluResonance` / `prefetchResonance` in `src/alu/src/resonance.ts`):
|
|
63
|
-
`recogniseOp` maps a span to its operation concept, `opposite` finds the
|
|
64
|
-
resonant inverse of a symbol for the polymorphic `inverse`. Literal surface
|
|
65
|
-
forms need no host; meaning-based paths do.
|
|
17
|
+
`cover` masks any recognised site that overlaps a computed span, so a learnt
|
|
18
|
+
`2+2 → 5` is dropped and the computed `4` is the only cover there. A computed
|
|
19
|
+
span and a learnt edge both cost `STEP`: precedence is policy, enforced by
|
|
20
|
+
masking (`cost-model.md`). A computed span still composes with an unrelated
|
|
21
|
+
rewrite: `ice 2+2` → `cold 4`.
|
|
66
22
|
|
|
67
23
|
## Provenance
|
|
68
24
|
|
|
69
|
-
`cover`.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`
|
|
74
|
-
vocabulary, because post-grounding gates on it (see `pipeline-mechanism.ts`).
|
|
75
|
-
The ALU's own act is named in the TRACE (`evalComputation`/`computeExtensions`),
|
|
76
|
-
not in the provenance.
|
|
25
|
+
`cover`. Cover's derivation carries the computed answer out: 9 of 9 computed
|
|
26
|
+
probes, such as `137*24` and `1000 - 421`, report `cover`. A mechanism may not
|
|
27
|
+
invent a label outside the pipeline's `Provenance` vocabulary, because
|
|
28
|
+
post-grounding gates on it. The ALU's own act is named in the trace
|
|
29
|
+
(`evalComputation`, `computeExtensions`).
|
|
77
30
|
|
|
78
31
|
## Pins
|
|
79
32
|
|
|
80
|
-
- `test/18
|
|
81
|
-
- `test/19
|
|
33
|
+
- `test/18` — arithmetic, masking, and operations gated by resonance.
|
|
34
|
+
- `test/19` — `nd` lists, broadcast, and higher-order operations.
|