@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
package/AGENTS.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# AGENTS.md — the Sema development manual
|
|
2
2
|
|
|
3
|
-
The working manual for anyone (human or AI agent) changing Sema.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
The working manual for anyone (human or AI agent) changing Sema. Read
|
|
4
|
+
`docs/PHILOSOPHY.md` first: it follows information from deposit to answer and
|
|
5
|
+
says why the parts fit. Then `docs/INDEX.md` routes each task to the law it
|
|
6
|
+
touches in `docs/architecture/`. You should be able to develop against this
|
|
7
|
+
document and `docs/` alone.
|
|
7
8
|
|
|
8
9
|
## 1. Orientation
|
|
9
10
|
|
|
@@ -32,7 +33,7 @@ Mental model, top to bottom:
|
|
|
32
33
|
```
|
|
33
34
|
mind/pipeline.ts grounding decider: mechanisms compete on one cost scale
|
|
34
35
|
mind/mechanisms/* cover · cast · confluence · extraction · reference · recall · prefix-completion · alu
|
|
35
|
-
mind/*
|
|
36
|
+
mind/* recognition, attention, match/project, evidence, closure, graph search, learning, rationale
|
|
36
37
|
store.ts AbstractStore: ALL DAG store domain logic
|
|
37
38
|
store-sqlite.ts the one concrete backend (thin SQL wrappers)
|
|
38
39
|
geometry.ts + vec/alphabet/sema/canon vectors, fold, every derived threshold, canonicalizer
|
|
@@ -82,6 +83,10 @@ corpus-determined, not interchangeable (`determinism.md`).
|
|
|
82
83
|
| Weighted deduction + cost ladder | `src/mind/graph-search.ts` (engine in `src/derive/`) |
|
|
83
84
|
| Match/project family | `src/mind/match.ts` |
|
|
84
85
|
| Graph traversal, corpus scale | `src/mind/traverse.ts` |
|
|
86
|
+
| Witnessed evidence (`witness`) | `src/mind/evidence.ts` |
|
|
87
|
+
| Closure law and engine (`closeOver`) | `src/mind/derivation.ts` |
|
|
88
|
+
| Post-grounding walk and fusion | `src/mind/reasoning.ts` |
|
|
89
|
+
| Canonical windows | `src/mind/canonical.ts` |
|
|
85
90
|
| Consensus climb + attention | `src/mind/attention.ts` |
|
|
86
91
|
| Substitution bridge (recall tier) | `src/mind/bridge.ts` |
|
|
87
92
|
| Recognition / junction / resonance | `src/mind/recognition.ts`, `src/mind/junction.ts`, `src/mind/resonance.ts` |
|
|
@@ -132,8 +137,12 @@ against built `dist/` (`npm test`; one suite:
|
|
|
132
137
|
numbered suite. Many tests pin contracts that look like implementation details
|
|
133
138
|
(ladder order, span-shape readings, `MechanismResult.complete`, fold invariance,
|
|
134
139
|
recognition idempotence, honest silence). A simplification that fails an
|
|
135
|
-
existing test is wrong until the test is proven wrong
|
|
136
|
-
|
|
140
|
+
existing test is wrong until the test is proven wrong; read
|
|
141
|
+
`docs/failures/tempting-but-wrong.md` before trying one. `src/alu/` and
|
|
142
|
+
`src/derive/` test themselves in their own `test/` with zero Sema dependency;
|
|
143
|
+
`rabitq-ivf` is pinned by `test/35-ivf`. `test/137` also reads `docs/`: an
|
|
144
|
+
export only the docs describe counts as documented, so deleting its mention can
|
|
145
|
+
fail the dead-export guard.
|
|
137
146
|
|
|
138
147
|
## 6. Instrumentation — the meter and the rationale ARE the dev surface
|
|
139
148
|
|
|
@@ -109,18 +109,17 @@ export async function indexSubSpans(ctx, tree, ids) {
|
|
|
109
109
|
* root id, id map, and the changed (new) subtrees for halo reinforcement. */
|
|
110
110
|
export async function deposit(ctx, input, track, conversational = false) {
|
|
111
111
|
const bytes = inputBytes(ctx, input);
|
|
112
|
-
// Deposit-shaped perception:
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
// (
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
// would stop sharing structure with each other.
|
|
112
|
+
// Deposit-shaped perception (perceiveDeposit): the plain content fold, the
|
|
113
|
+
// same tree inference computes for these bytes. An accumulated context
|
|
114
|
+
// reuses the already-folded segments of its cached prefix
|
|
115
|
+
// (contentFoldIncremental), so it re-folds only its new suffix — O(turn)
|
|
116
|
+
// instead of O(context) per conversation turn. The reuse is transparent:
|
|
117
|
+
// a hit saves time and never changes the tree. Cache-only here (no
|
|
118
|
+
// store-probe fallback): conversation replays are always warm, because
|
|
119
|
+
// re-deposition replays from the first turn and rebuilds the cache as it
|
|
120
|
+
// goes. `conversational` only decides which deposits WRITE the cache —
|
|
121
|
+
// ingestPair's growing context, not every unrelated fact — a budget
|
|
122
|
+
// choice, not a correctness one (fold-contract.md).
|
|
124
123
|
const tree = perceiveDeposit(ctx, bytes, conversational);
|
|
125
124
|
const ids = new Map();
|
|
126
125
|
const rootId = await internTreeIds(ctx, tree, ids);
|
package/dist/src/mind/mind.js
CHANGED
|
@@ -685,10 +685,10 @@ export class Mind {
|
|
|
685
685
|
// No recognise-memo pre-seeding here: that used to be necessary because
|
|
686
686
|
// the flat/positional fold lost visibility into an earlier turn's own
|
|
687
687
|
// structure once later bytes shifted its position (foldTree no longer
|
|
688
|
-
// visited the turn's root node). The
|
|
689
|
-
// ConversationData})
|
|
690
|
-
// follows it
|
|
691
|
-
// own, first-touch, exactly once per turn.
|
|
688
|
+
// visited the turn's root node). The content-defined fold (see {@link
|
|
689
|
+
// ConversationData}) cuts by the bytes, never by position, so an earlier
|
|
690
|
+
// turn's structure is the same whatever follows it, and recognise() finds
|
|
691
|
+
// it on its own, first-touch, exactly once per turn.
|
|
692
692
|
this.beginResponse(inspectRationale, this._canonFor(typeof turn === "string" ? textCanon : null), data);
|
|
693
693
|
try {
|
|
694
694
|
const response = await this._groundAndVoice(newContext, "respondTurn");
|
package/dist/src/mind/types.d.ts
CHANGED
|
@@ -356,9 +356,8 @@ export interface MindContext extends GraphSearchHost {
|
|
|
356
356
|
* with `bytesToTree` on every turn, so every key was fresh and this cache
|
|
357
357
|
* could not hit even once — the O(suffix) claim above described an
|
|
358
358
|
* intention rather than the code. It now grows the context through
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
* turn 3 (26 new ≈ the new turn's own size). */
|
|
359
|
+
* contentFoldIncremental, which reuses each already-folded segment as the
|
|
360
|
+
* same object (~92% of nodes reused by identity across turns). */
|
|
362
361
|
_resolvedSubtrees: WeakMap<Sema, {
|
|
363
362
|
id: number;
|
|
364
363
|
len: number;
|
|
@@ -396,18 +395,14 @@ export interface MindContext extends GraphSearchHost {
|
|
|
396
395
|
* never a correctness risk. */
|
|
397
396
|
_gistCache: BoundedMap<number, Vec>;
|
|
398
397
|
/** DEPOSIT-path perception cache: content key (latin1) of a deposited
|
|
399
|
-
* input → its
|
|
400
|
-
* deposit whose
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
* so a later turn of the same conversation reuses them. Purely a
|
|
408
|
-
* performance cache for the FOLD STATE; the boundaries are semantic but
|
|
409
|
-
* derived only from the deposit sequence itself (an evicted chain falls
|
|
410
|
-
* back to plain-fold behavior, exactly the pre-boundary shape). */
|
|
398
|
+
* input → its reusable content-fold state ({@link DepositCacheEntry}). A
|
|
399
|
+
* deposit whose bytes extend a cached entry reuses that entry's
|
|
400
|
+
* already-folded segments (contentFoldIncremental) — O(turn) per deposit
|
|
401
|
+
* instead of O(context) — and gets exactly the tree a cold fold would
|
|
402
|
+
* give, the same one query-time perception computes. It holds no turn
|
|
403
|
+
* boundaries: the fold imposes none (fold-contract.md). Written only by
|
|
404
|
+
* conversational deposits, so the 8-entry budget keeps the live chains;
|
|
405
|
+
* an evicted chain costs a re-fold, never a different tree. */
|
|
411
406
|
_depositTrees: BoundedMap<string, DepositCacheEntry>;
|
|
412
407
|
/** The byte lengths present in {@link _depositTrees} — the candidate
|
|
413
408
|
* prefix lengths probed (longest first). Drifts on eviction (a stale
|
package/dist/src/store.d.ts
CHANGED
|
@@ -44,11 +44,11 @@ export declare class BoundedMap<K, V> {
|
|
|
44
44
|
/** How a HIT records recency.
|
|
45
45
|
*
|
|
46
46
|
* `"reorder"` (default) promotes the entry to most-recent by
|
|
47
|
-
* `m.delete(k); m.set(k, v)` — exact LRU,
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
47
|
+
* `m.delete(k); m.set(k, v)` — exact LRU, the policy for any cache whose
|
|
48
|
+
* choice of victim must follow use exactly. `_depositTrees` (8 entries,
|
|
49
|
+
* feeds contentFoldIncremental) keeps it so the live conversation chains
|
|
50
|
+
* stay warm; its reuse is transparent, so a wrong victim costs a re-fold,
|
|
51
|
+
* never a different tree (fold-contract.md).
|
|
52
52
|
*
|
|
53
53
|
* `"clock"` records recency as a BIT instead of as position, spent by
|
|
54
54
|
* the eviction sweep (see `nextOldest`). Correct only for a TRANSPARENT
|
|
@@ -64,11 +64,11 @@ export declare class BoundedMap<K, V> {
|
|
|
64
64
|
/** How a HIT records recency.
|
|
65
65
|
*
|
|
66
66
|
* `"reorder"` (default) promotes the entry to most-recent by
|
|
67
|
-
* `m.delete(k); m.set(k, v)` — exact LRU,
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
67
|
+
* `m.delete(k); m.set(k, v)` — exact LRU, the policy for any cache whose
|
|
68
|
+
* choice of victim must follow use exactly. `_depositTrees` (8 entries,
|
|
69
|
+
* feeds contentFoldIncremental) keeps it so the live conversation chains
|
|
70
|
+
* stay warm; its reuse is transparent, so a wrong victim costs a re-fold,
|
|
71
|
+
* never a different tree (fold-contract.md).
|
|
72
72
|
*
|
|
73
73
|
* `"clock"` records recency as a BIT instead of as position, spent by
|
|
74
74
|
* the eviction sweep (see `nextOldest`). Correct only for a TRANSPARENT
|
package/dist/src/store.js
CHANGED
|
@@ -95,11 +95,11 @@ export class BoundedMap {
|
|
|
95
95
|
/** How a HIT records recency.
|
|
96
96
|
*
|
|
97
97
|
* `"reorder"` (default) promotes the entry to most-recent by
|
|
98
|
-
* `m.delete(k); m.set(k, v)` — exact LRU,
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
98
|
+
* `m.delete(k); m.set(k, v)` — exact LRU, the policy for any cache whose
|
|
99
|
+
* choice of victim must follow use exactly. `_depositTrees` (8 entries,
|
|
100
|
+
* feeds contentFoldIncremental) keeps it so the live conversation chains
|
|
101
|
+
* stay warm; its reuse is transparent, so a wrong victim costs a re-fold,
|
|
102
|
+
* never a different tree (fold-contract.md).
|
|
103
103
|
*
|
|
104
104
|
* `"clock"` records recency as a BIT instead of as position, spent by
|
|
105
105
|
* the eviction sweep (see `nextOldest`). Correct only for a TRANSPARENT
|
package/docs/INDEX.md
CHANGED
|
@@ -1,71 +1,74 @@
|
|
|
1
1
|
# Sema Documentation Index
|
|
2
2
|
|
|
3
|
-
Sema is
|
|
4
|
-
(what holds), the prescription in `AGENTS.md` (what to do and where), and the
|
|
5
|
-
proof in `test/` (pins that fail when the law is broken).
|
|
3
|
+
Sema is one system, stated four ways:
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
| Where | It says |
|
|
6
|
+
| -------------------- | ----------------------------------------------------------------------------------------- |
|
|
7
|
+
| `docs/PHILOSOPHY.md` | the path of information from deposit to answer, and why it holds together. Read it first. |
|
|
8
|
+
| `docs/architecture/` | the laws: what holds and why, measured |
|
|
9
|
+
| `AGENTS.md` | the prescription: what to do, and where |
|
|
10
|
+
| `test/` | the proof: pins that fail when a law is broken |
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
| --------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
11
|
-
| Add a mechanism | `docs/architecture/mechanism-market.md` + `docs/mechanisms/*.md` | Market contract: the four constraints |
|
|
12
|
-
| Add a threshold | `docs/architecture/thresholds.md` | All cutoffs are formulas over D/W/N; `config.ts` holds budgets only |
|
|
13
|
-
| Debug an answer | `docs/architecture/cost-model.md` + `src/meter.ts` | One ladder decides every grounding choice |
|
|
14
|
-
| Understand the fold | `docs/architecture/fold-contract.md` | Deposit and inference compute the same tree |
|
|
15
|
-
| Add a store backend | `docs/architecture/store.md` + `docs/architecture/bounded-reads.md` | `AbstractStore` owns domain logic; backends are thin wrappers with capped reads |
|
|
16
|
-
| Add an ALU operation | `src/alu/README.md` | One `registry.derive` per op composing existing ops; no new `derive` needed |
|
|
17
|
-
| Add a matcher or projection | `docs/architecture/match-project.md` | Mechanisms are `(matcher, direction, gate)` configs over the shared `match.ts` family |
|
|
18
|
-
| Add a deduction rule | `docs/architecture/cost-model.md` + `docs/architecture/determinism.md` | Place cost on the ladder, keep heuristic admissible, extend `classifyMove` |
|
|
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
|
-
| Profile or bound work | `docs/architecture/meter.md` + `docs/architecture/bounded-reads.md` | `meter.ts` is write-only; counters are product, phases are hints |
|
|
12
|
+
`docs/INVARIANTS.md` routes every law to its code and its pins.
|
|
21
13
|
|
|
22
|
-
##
|
|
14
|
+
## What to read for each task
|
|
23
15
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
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` |
|
|
16
|
+
| Task | Read |
|
|
17
|
+
| ------------------------------ | --------------------------------------------------------------- |
|
|
18
|
+
| Understand the whole | `PHILOSOPHY.md` |
|
|
19
|
+
| Change perception or identity | `fold-contract.md`, `store.md`, `exact-vs-approximate.md` |
|
|
20
|
+
| Add a store backend | `store.md`, `bounded-reads.md` |
|
|
21
|
+
| Add or change a threshold | `thresholds.md` |
|
|
22
|
+
| Add a mechanism | `mechanism-market.md`, `match-project.md`, `docs/mechanisms/` |
|
|
23
|
+
| Add a deduction rule | `cost-model.md`, `closure.md`, `determinism.md` |
|
|
24
|
+
| Change what counts as evidence | `evidence.md`, `commonality.md` |
|
|
25
|
+
| Change vector search | `exact-vs-approximate.md`, `halo-sketch.md`, `bounded-reads.md` |
|
|
26
|
+
| Add a walk or a fan-out | `bounded-reads.md`, `saturation.md` |
|
|
27
|
+
| Profile or bound work | `meter.md`, `memoization.md`, `caches.md` |
|
|
28
|
+
| Add an ALU operation | `src/alu/README.md` |
|
|
29
|
+
| Simplify something | `docs/failures/tempting-but-wrong.md` first |
|
|
41
30
|
|
|
42
|
-
##
|
|
31
|
+
## The laws (`docs/architecture/`)
|
|
43
32
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
33
|
+
| # | Doc | Law |
|
|
34
|
+
| -- | ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
35
|
+
| 1 | `determinism.md` | the same seed, deposits and question give the same bytes; ties are broken by the corpus, never by chance |
|
|
36
|
+
| 2 | `thresholds.md` | every cutoff is a formula over `D`, `W`, `N`; `config.ts` holds budgets only |
|
|
37
|
+
| 3 | `exact-vs-approximate.md` | scores propose, bytes dispose; every graded ladder is exact first |
|
|
38
|
+
| 4 | `cost-model.md` | one currency: `MICRO < STEP < CONCEPT < PASS`, and the price is the unexplained question |
|
|
39
|
+
| 5 | `match-project.md` | a mechanism is `(matcher, direction, gate)` over one family; the gate belongs to the consumer |
|
|
40
|
+
| 6 | `mechanism-market.md` | one interface, one price; never compute what cannot change the decision |
|
|
41
|
+
| 7 | `commonality.md` | frame against filler is read over a named population: corpus, cohort or places, never substituted |
|
|
42
|
+
| 8 | `bounded-reads.md` | no per-query read grows with `N`; the store enforces `hubBound = ⌈√N⌉` |
|
|
43
|
+
| 9 | `store.md` | a node is named by its content; `AbstractStore` owns every domain decision |
|
|
44
|
+
| 10 | `fold-contract.md` | deposit and question fold the same bytes into the same tree and the same node; nothing outside the bytes shapes it |
|
|
45
|
+
| 11 | `memoization.md` | asking never writes; shared analyses are computed once per response, and tracing changes no answer |
|
|
46
|
+
| 12 | `saturation.md` | every walk names the stop that decides it; the cap is only a net |
|
|
47
|
+
| 13 | `meter.md` | the meter is write-only; counters are exact, milliseconds are hints |
|
|
48
|
+
| 14 | `closure.md` | a step is admitted only when it closes, moves to unconsumed structure, or carries what is owed |
|
|
49
|
+
| 15 | `evidence.md` | the question names the step; another instance of its frame says what the relation is, never what it asks about |
|
|
54
50
|
|
|
55
|
-
|
|
51
|
+
Supporting docs: `halo-sketch.md` (distributional memory), `caches.md` (every
|
|
52
|
+
acceleration is a budget), `factored-machinery.md` (one definition, many
|
|
53
|
+
consumers).
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
| ----------------------------------------- | ------------------------------------------------------------------------------- |
|
|
59
|
-
| `docs/architecture/caches.md` | Every acceleration is a `BoundedMap`; miss re-derives; budgets in `StoreConfig` |
|
|
60
|
-
| `docs/architecture/halo-sketch.md` | Halo & sketch — distributional memory, quantization, bottom-k profiles |
|
|
61
|
-
| `docs/architecture/factored-machinery.md` | Single-definition contracts table — one owner per shared symbol |
|
|
55
|
+
## Mechanisms (`docs/mechanisms/`)
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
| Mechanism | Answers by |
|
|
58
|
+
| ------------------- | ----------------------------------------------------------------------------- |
|
|
59
|
+
| `cover` | composing the question from its recognised sites, by graph search |
|
|
60
|
+
| `cast` | carrying structure between woven forms: substitution, redirection, comparison |
|
|
61
|
+
| `confluence` | intersecting what independent conditions reach |
|
|
62
|
+
| `extraction` | reading a span between frames located in the question |
|
|
63
|
+
| `reference` | voicing a learnt frame's slot with the asker's own bytes |
|
|
64
|
+
| `recall` | the nearest stored form, or honest silence |
|
|
65
|
+
| `prefix-completion` | completing a known beginning of exactly one form |
|
|
66
|
+
| `alu` | computation, which is authoritative |
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- `docs/failures/tempting-but-wrong.md` —
|
|
68
|
-
|
|
69
|
-
- `docs/harness/gates.md` —
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
## Elsewhere
|
|
69
|
+
|
|
70
|
+
- `docs/failures/tempting-but-wrong.md` — shortcuts that passed review and
|
|
71
|
+
failed the evidence.
|
|
72
|
+
- `docs/harness/gates.md` — the four executable gates.
|
|
73
|
+
- `src/derive/`, `src/alu/`, `src/rabitq-ivf/` — firewalled sublibraries, each
|
|
74
|
+
with its own README and tests.
|
package/docs/INVARIANTS.md
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
|
-
# INVARIANTS —
|
|
1
|
+
# INVARIANTS — Where Each Law Lives and What Pins It
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
3
|
+
`AGENTS.md` §2 names the five invariants that every change must keep. This table
|
|
4
|
+
routes all fifteen laws (numbered as in `INDEX.md`) to the code that defines
|
|
5
|
+
them and the tests that fail when they break.
|
|
6
|
+
|
|
7
|
+
| # | Law | Defined in | Pins |
|
|
8
|
+
| -- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------- |
|
|
9
|
+
| 1 | Determinism | `config.ts` (`seed`), `alphabet.ts`, `traverse.ts` (`guidedFirst`, `chooseNext`) | `test/20`, `test/42` |
|
|
10
|
+
| 2 | Derived thresholds | `geometry.ts`, `traverse.ts` (`corpusN`, `hubBound`, `atomReach`), `canonical.ts` (`chainReach`) | `test/40`, `test/64`, `test/78` |
|
|
11
|
+
| 3 | Exact decides | `mind/primitives.ts` (`resolve`, `exactNode`), `match.ts` (`locate`, `alignGraded`), `resonance.ts` (`bridge`), `attention.ts` | `test/51`, `test/56` |
|
|
12
|
+
| 4 | One cost currency | `graph-search.ts` (`MICRO`, `STEP`, `CONCEPT`, `PASS`), `src/derive` (min, +), `attention.ts` (`poolVotes`, +, +), `pipeline.ts` (`weigh`) | `test/04`, `test/55`, `test/151` |
|
|
13
|
+
| 5 | Match → project → gate | `match.ts` | `test/24`, `test/47`, `test/76` |
|
|
14
|
+
| 6 | Mechanism market | `pipeline-mechanism.ts` (`PipelineMechanism`, `Precomputed`), `pipeline.ts` (`think`, `worthRunning`) | `test/01`, `test/04`, `test/153` |
|
|
15
|
+
| 7 | Commonality | `traverse.ts` (`reachOf`, `dominates`, `hubWindows`), `cast.ts` (`depth[]`, `MIN_WEAVE`), `bridge.ts` (rarity) | `test/17`, `test/34`, `test/73` |
|
|
16
|
+
| 8 | Bounded reads | `store.ts` (`*First`, `containersSlice`, `has*`, `bytesPrefix`, `chainRun`), `traverse.ts` (`hubBound`, `hubCap`) | `test/14`, `test/89`, `test/90`, `test/119` |
|
|
17
|
+
| 9 | Store | `store.ts` (`AbstractStore`, `intern`), `store-sqlite.ts` | `test/02`, `test/08`, `test/36-bloom` |
|
|
18
|
+
| 10 | Fold contract | `geometry.ts` (`contentLevels`, `contentIdentity`), `primitives.ts` (`branchNaming`), `canonical.ts`, `canon.ts` | `test/59`, `test/63`, `test/148`, `test/152` |
|
|
19
|
+
| 11 | Memoization | `pipeline-mechanism.ts` (`Precomputed`), `mind.ts` (`beginResponse`, `endResponse`) | `test/42`, `test/155.4` |
|
|
20
|
+
| 12 | Saturation | `traverse.ts` (`edgeAncestors`), `junction.ts` (`junctionContainersFrom`), `resonance.ts` (`pivotInto`), `types.ts` (`SaturationStop`) | `test/16`, `test/27`, `test/34`, `test/49` |
|
|
21
|
+
| 13 | Meter | `meter.ts`, `Precomputed.shared` | `test/55` |
|
|
22
|
+
| 14 | Closure | `derivation.ts` (`admissible`, `advance`, `closeOver`) | `test/133`–`151` |
|
|
23
|
+
| 15 | Witnessed evidence | `evidence.ts` (`witness`, `windowIndex`), `traverse.ts` (`chooseNext`, `answersOtherQuestions`, `coInstanceFiller`, `scaffoldExtents`) | `test/154`, `test/155`, `test/76` |
|
|
24
|
+
|
|
25
|
+
Caches (`caches.md`: every acceleration is a `BoundedMap`, and a miss
|
|
26
|
+
re-derives) are pinned by `test/91` and `test/96`.
|
|
27
|
+
|
|
28
|
+
## Honest silence
|
|
29
|
+
|
|
30
|
+
Every law above serves one contract the code cites by this file's name: **when
|
|
31
|
+
the evidence does not decide, say less, never something invented.** A budget
|
|
32
|
+
that runs out abstains and is counted (`junctionBudgetExhausted`). A cache miss
|
|
33
|
+
re-derives, never approximates. A question whose every window is scaffolding is
|
|
34
|
+
not bridged. When nothing accounts for the question, the price makes silence the
|
|
35
|
+
lightest answer, and an answer that is only near says so. A gap is honest; an
|
|
36
|
+
assembly carrying content the evidence did not license is a fabrication. Pinned
|
|
37
|
+
by `test/28`, `test/73` and `test/84`.
|