@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.
Files changed (46) hide show
  1. package/AGENTS.md +16 -7
  2. package/dist/src/mind/learning.js +11 -12
  3. package/dist/src/mind/mind.js +4 -4
  4. package/dist/src/mind/types.d.ts +10 -15
  5. package/dist/src/store.d.ts +10 -10
  6. package/dist/src/store.js +5 -5
  7. package/docs/INDEX.md +62 -59
  8. package/docs/INVARIANTS.md +36 -18
  9. package/docs/PHILOSOPHY.md +317 -0
  10. package/docs/architecture/bounded-reads.md +31 -71
  11. package/docs/architecture/caches.md +61 -81
  12. package/docs/architecture/closure.md +88 -107
  13. package/docs/architecture/commonality.md +47 -38
  14. package/docs/architecture/cost-model.md +57 -79
  15. package/docs/architecture/determinism.md +43 -55
  16. package/docs/architecture/evidence.md +158 -235
  17. package/docs/architecture/exact-vs-approximate.md +41 -35
  18. package/docs/architecture/factored-machinery.md +34 -20
  19. package/docs/architecture/fold-contract.md +110 -118
  20. package/docs/architecture/halo-sketch.md +105 -96
  21. package/docs/architecture/match-project.md +51 -42
  22. package/docs/architecture/mechanism-market.md +87 -91
  23. package/docs/architecture/memoization.md +60 -74
  24. package/docs/architecture/meter.md +37 -47
  25. package/docs/architecture/saturation.md +75 -101
  26. package/docs/architecture/store.md +118 -99
  27. package/docs/architecture/thresholds.md +66 -73
  28. package/docs/failures/tempting-but-wrong.md +139 -165
  29. package/docs/harness/gates.md +27 -32
  30. package/docs/mechanisms/alu.md +22 -69
  31. package/docs/mechanisms/cast.md +76 -71
  32. package/docs/mechanisms/confluence.md +22 -29
  33. package/docs/mechanisms/cover.md +58 -66
  34. package/docs/mechanisms/extraction.md +33 -37
  35. package/docs/mechanisms/prefix-completion.md +36 -39
  36. package/docs/mechanisms/recall.md +60 -53
  37. package/docs/mechanisms/reference.md +63 -49
  38. package/jsr.json +1 -1
  39. package/package.json +1 -1
  40. package/src/alu/README.md +90 -298
  41. package/src/derive/README.md +94 -256
  42. package/src/mind/learning.ts +11 -12
  43. package/src/mind/mind.ts +4 -4
  44. package/src/mind/types.ts +10 -15
  45. package/src/rabitq-ivf/README.md +11 -8
  46. package/src/store.ts +5 -5
@@ -1,80 +1,85 @@
1
- # CAST — Counterfactual Transfer via Weave
2
-
3
- Counterfactual transfer over the query's **weave**: when byte-string evidence
4
- from multiple independently-learnt structures aligns to genuinely different
5
- query spans, CAST transfers structure between them (substitution, redirection,
6
- analogical comparison). One `alignGraded` weave, multiple schemas; each firing
7
- schema yields its own candidate and `think`'s single weight comparison picks.
8
-
9
- ## Matcher
10
-
11
- `alignGraded` over the current query bytes: literal W-gram runs first, then
12
- halo-matched `pre.rec.sites`. The product is `pre.weave()` — `points[]` (each
13
- with graded `runs[]`) and a per-query-byte `depth[]` (how many structures cover
14
- that byte). CAST's single-vs-multi test is measured from those runs: a second
15
- point must add ≥ one perception quantum of coverage the widest does not.
16
-
17
- ## Gate — weave-local discriminative frame
18
-
19
- Two derived components, both from the weave itself (no tuned threshold):
20
-
21
- 1. **MIN_WEAVE = 2** — CAST needs ≥ 2 points to form a weave. Frame requires
22
- _more_ than the minimum: `depth[i] > MIN_WEAVE`, i.e. ≥ 3 structures agree on
23
- the byte. With only the minimum pair no byte is frame.
24
-
25
- 2. **Half-dominance** — `dominates(n, total)` (> half scaffolding no longer
26
- discriminates). Per byte:
27
- `frame(i) ⇔ depth[i] > MIN_WEAVE ∧ dominates(depth[i], aligned)`. Per run:
28
- `usable(r) ⇔ ¬dominates(framedCount(qs,qe), runLen)`.
29
-
30
- `depth` counts **distinct structures**, not accumulated weight — a byte covered
31
- by the same structure twice still has depth 1. Counting weight instead lets
32
- shared frame (" describe it", "the importance of") survive as content and makes
33
- substitution fire on reordered single-fact queries. The split is 29/42 vs 6/42
34
- when wrong.
35
-
36
- This frame gate is **weave-local** ("what the aligned structures share among
37
- themselves"), not corpus-local (`reachOf` + `dominates` IDF). A phrase common to
38
- the aligned exemplars is frame here even when it reaches a corpus minority. Do
39
- not replace it with the structural IDF — refuted on the `test/17` reorder probe.
40
- The gate does not use `frameSlots` and therefore **does not consume frame
41
- slots** — it is not the cohort-local `frameSlots` voice gate.
42
-
43
- Other admission gates (query ≥ 2 quanta, ≥ 2 ranked anchors, weave touches a
44
- committed attention root, genuinely woven — not every run restating a recognised
45
- site) are structural competence checks; see `cast.ts`.
1
+ # CAST — Carry Structure Between Woven Forms
2
+
3
+ When independently learnt structures align to genuinely different spans of the
4
+ question, CAST (counterfactual transfer) carries structure from one to another
5
+ (`src/mind/mechanisms/cast.ts`). One weave serves three schemas. Each schema
6
+ that fires yields its own candidate, and the market's single comparison picks.
7
+
8
+ ## Matcher — the weave
9
+
10
+ `pre.weave()` is `alignGraded` over the question: literal `W`-gram runs, then
11
+ halo-matched sites and the climb's proposals. It produces `points[]`, each with
12
+ graded `runs[]`, and `depth[]`, the number of distinct structures that cover
13
+ each byte. A second point counts only if it adds at least one perception quantum
14
+ of coverage that the widest point lacks.
15
+
16
+ ## Gate — the cohort's frame
17
+
18
+ Frame is what the cohort of aligned structures shares (`commonality.md`):
19
+
20
+ ```
21
+ frame(i) ⇔ depth[i] > MIN_WEAVE ∧ dominates(depth[i], aligned) MIN_WEAVE = 2
22
+ usable(r) ⇔ ¬dominates(framedCount(qs, qe), runLen)
23
+ ```
24
+
25
+ - **More than a pair must agree.** A pair is ambiguous when insertions are
26
+ possible, so with only two points no byte is frame.
27
+ - **`depth` counts distinct structures, never weight.** Counting weight lets a
28
+ shared frame such as `describe it` survive as content, and makes substitution
29
+ fire on reordered single-fact questions (the measured split was 29/42 against
30
+ 6/42).
31
+ - **The cohort reading cannot be replaced by corpus reach.** A phrase common to
32
+ the aligned exemplars is frame here even when it is rare in the corpus
33
+ (`test/17`).
34
+
35
+ Further competence checks:
36
+
37
+ - the question is at least two quanta long;
38
+ - there are at least two ranked anchors;
39
+ - the weave touches a committed point of attention;
40
+ - the weave is genuinely woven, not every run restating a recognised site.
41
+
42
+ ## Schemas
43
+
44
+ - **Substitution.** A subject the question supplies takes the seat of a
45
+ displaced structure. The filler is what the subject contributes before the
46
+ seat, clipped at the seat, so the result does not depend on the weave's
47
+ elimination order. The substitution must actually displace something.
48
+ - **Redirection.** The question names a substitute by quoting it from its own
49
+ opening bytes (`…were Lyon?` against `Lyon is a city in France`), and names it
50
+ after what it displaces. A substitute that is a fragment answering other
51
+ questions is refused: `ong)?`, the tail of every `… (… Song)?` question, once
52
+ voiced a stranger's birthplace.
53
+ - **Comparison.** The dominant is seated against one analog, reached through
54
+ `seatOfNode` and corroborated by `analogyStrength` (halo company). Two guards
55
+ apply:
56
+ - the question must evidence the analog with a window of its own, not inside
57
+ the dominant's runs and not scaffolding;
58
+ - the dominant must not be a co-instance of the question (`evidence.md`).
59
+
60
+ Without them, a bare question was glued onto the answer, and once Shakira's
61
+ birthplace was set against `John Lennon`.
46
62
 
47
63
  ## Cost
48
64
 
49
- **2·STEP** (`STEP + STEP`): one projection per transfer act that the taken
50
- branch performs (halo-mediated analogy adds `CONCEPT`). Weight is
51
- `moves + PASS·unaccountedBytes` as usual; `accounted` is schema-specific — only
52
- the two points that schema actually transferred between.
53
-
54
- ## Investment discipline
55
-
56
- Floor is `2·STEP`. Before touching the shared expensive analyses
57
- (`pre.attention()` climb, `pre.weave()`), check `worthRunning(2*STEP)` and
58
- return the uninvested bound when it already loses. Never compute a shared
59
- analysis just to discard it.
65
+ Each transfer act costs `STEP + STEP`, plus `CONCEPT` for a halo-mediated
66
+ analogy. `accounted` covers only the points that schema actually transferred
67
+ between. The floor is `2·STEP`. Before first touching the climb or the weave,
68
+ the floor asks `worthRunning(2·STEP)` and returns its uninvested bound if it
69
+ would lose (`mechanism-market.md`).
60
70
 
61
71
  ## Provenance
62
72
 
63
- `cast` — the answer came from counterfactual transfer (substitution,
64
- redirection, or analogical comparison), not from a literal continuation.
73
+ `cast`.
65
74
 
66
75
  ## Pins
67
76
 
68
- - **test/17 intelligence** — reordered single-fact must not trigger
69
- substitution; the weave-local frame (depth as distinct-structure count +
70
- half-dominance) is what suppresses it.
71
- - **test/29 counterfactual** — B/C families pin substitution / redirection /
72
- comparison and their seat displacements.
73
- - **test/43 seat** — `seatOfNode` direction (establishing reverse vs forward vs
74
- fallback) that the schemas displace through.
75
-
76
- ## Source
77
-
78
- `src/mind/mechanisms/cast.ts` (`counterfactualTransfer`, `seatOfNode`,
79
- `MIN_WEAVE`, `weave.depth`), `src/mind/match.ts` (`alignGraded`, `project`),
80
- `src/geometry.ts` (`dominates`), `src/mind/graph-search.ts` (`STEP`).
77
+ - `test/17` — a reordered single fact does not trigger substitution; it pins the
78
+ cohort frame.
79
+ - `test/29` — substitution, redirection and comparison, and the displacement of
80
+ their seats. C3: a further hop inside a comparison's seat waits to be asked.
81
+ - `test/43` — the direction of `seatOfNode`.
82
+ - `test/47`, `test/50` — comparison coverage, the analog consensus floor and the
83
+ shared guards.
84
+ - `test/154.7`, `test/155.9` — a comparison needs two named things, and never
85
+ takes a co-instance as its dominant.
@@ -1,43 +1,36 @@
1
- # Confluence — Multi-Condition Meeting Point
1
+ # Confluence — Where Independent Conditions Meet
2
2
 
3
- Conjunctive queries whose answer lives in no single fact, only where independent
4
- evidence streams intersect. Each condition reaches its own exemplar set; the
5
- entity satisfying all lives at their meeting point.
3
+ Some questions state several conditions, and their answer lives in no single
4
+ fact, only where the conditions intersect. Each condition reaches its own stored
5
+ contexts, and the thing that satisfies all of them sits at their meeting point
6
+ (`src/mind/mechanisms/confluence.ts`, `confluenceJoin`).
6
7
 
7
- Source: `src/mind/mechanisms/confluence.ts` (`confluenceJoin`,
8
- `confluenceMechanism`).
8
+ ## Matcher — streams from the climb
9
9
 
10
- ## Matcher
10
+ The streams are the consensus climb's ranked anchors (`pre.attention()`,
11
+ `crossRegionVotes`), each bound by identity to a discriminating span of the
12
+ question. Two streams are independent when their spans are disjoint. The meet is
13
+ a set intersection by content-addressed window identity (`windowsOf`): a window
14
+ present in both anchors and absent from the question.
11
15
 
12
- `crossRegionVotes` tiers over the consensus climb (`pre.attention()` ranked
13
- anchors). Streams are anchors bound by identity to disjoint discriminative query
14
- spans; two streams are independent when their `cover` spans are disjoint. The
15
- meet is set intersection by content-addressed identity (`windowsOf` /
16
- `findBranch` window ids): present in both anchors, absent from the query.
16
+ ## Gate — corpus-global commonality
17
17
 
18
- ## Gate
19
-
20
- Corpus-global IDF, not weave-local. A window's `reachOf(ctx, wid, N, memo)`
21
- (`edgeAncestors` contexts-reached via `sharedReachMemo`) is gated by
22
- `dominates(reach, N)` (`geometry.ts` half-dominance, `reach*2 > N`). Majority
23
- reach is scaffolding and never binds a constraint nor survives the meet;
24
- minority reach is filler/entity. Single-window meets and sub-`2W` spans are
25
- refused.
18
+ A window's `reachOf` is gated by `dominates(reach, N)` (`commonality.md`). A
19
+ window reached by a majority of contexts is scaffolding: it never binds a
20
+ condition and never survives the meet. A minority reach is a filler, an entity.
21
+ A meet on a single window, or a span shorter than `2W`, is refused.
26
22
 
27
23
  ## Cost
28
24
 
29
- One currency (`mind/graph-search.ts`): `STEP=1`, `CONCEPT=10`, `PASS=1000`/byte.
30
- `moves = STEP·slots + CONCEPT` (floor `3·STEP`: two constraints + meet). Weight
31
- `moves + PASS·unaccounted` compared at `STEP` grade (`pipeline.ts:think`).
25
+ `3·STEP`: two conditions and the meet. That is also its floor, so the climb is
26
+ never touched unless `worthRunning(3·STEP)` holds (`mechanism-market.md`).
32
27
 
33
28
  ## Provenance
34
29
 
35
- `join` — confluence is the mechanism that OWNS this provenance
36
- (`src/mind/mechanisms/confluence.ts` sets it when the independent evidence
37
- streams meet at one anchor). It is not cover's: cover reports `cover` for every
38
- derivation it wins (see `docs/mechanisms/cover.md`).
30
+ `join`, which belongs to this mechanism alone.
39
31
 
40
32
  ## Pins
41
33
 
42
- `test/32-confluence.test.mjs` — two-constraint intersection, order invariance,
43
- empty-intersection honesty, cross-domain relational joins.
34
+ - `test/32` — two-condition intersection, invariance to the order of the
35
+ conditions, honest silence on an empty intersection, and relational joins
36
+ across domains.
@@ -1,73 +1,65 @@
1
- # Cover — Lightest Derivation over the Query
2
-
3
- Cover is graph search. Its axioms are the query's own decomposition and its goal
4
- is the cheapest cover of the query's bytes. It runs first so a computed-backed
5
- cover becomes a near-zero-cost incumbent.
6
-
7
- ## Matcher — `locate` / recognition sites (`src/mind/recognition.ts`)
8
-
9
- Sites are spans of the query that name a node already in the store. Cover
10
- consumes them directly; any site whose bytes overlap a computed span is masked
11
- (computation always wins).
12
-
13
- ## Projection — edges + conceptHop (`src/mind/match.ts`, `src/mind/graph-search.ts`)
14
-
15
- - `formRules` follow continuation edges (`GraphSearch.formRules`): each hop
16
- costs `STEP` (1). Forks across all continuations up to the hub bound;
17
- disambiguation is distributional, not heuristic.
18
- - Edge-less forms may hop via a halo sibling (`conceptHop` / `offerConcepts`) at
19
- `CONCEPT` (10), borrowing a synonym's continuation.
20
- - A span's cheapest completion DOMINATES the rest (`buildSearch`): a form or
21
- completion of `[i, j)` whose cost has reached that of a completion of `[i, j)`
22
- already yielded fires no rule (`searchDominated`). Coverage is positional, so
23
- only the cheapest matters to the goal; the byte rules (fuse, splice, join)
24
- fire from the completion the search would stand on, never from every
25
- alternative it reached. It also makes the first hop's stop-here
26
- (`STEP + CONCEPT`) a real horizon for the chain.
27
-
28
- ## Gate — `leadsSomewhere` (`src/mind/traverse.ts`)
29
-
30
- A site participates only if it leads somewhere: it bears an edge (`hasNext`) or
31
- a halo (`hasHalo`). Forms that lead nowhere contribute nothing to any derivation
32
- and are filtered during recognition.
33
-
34
- ## Cost (`src/mind/graph-search.ts`)
35
-
36
- | Symbol | Value | Rule |
37
- | --------- | ----------- | ----------------------------------------------- |
38
- | `STEP` | 1 | per edge hop |
39
- | `CONCEPT` | 10 | abandoning a chain / synonym hop |
40
- | `PASS` | 1000 / byte | each unaccounted byte |
41
- | `MICRO` | 1e-3 | per-byte A* heuristic (`h = (len-right)*MICRO`) |
42
-
43
- The cover reports `moves` (its derivation's discrete work) and `accounted`; the
44
- ladder prices both.
45
-
46
- ## Licensed premises (`src/mind/mechanisms/cover.ts`, `Licence` in `graph-search.ts`)
47
-
48
- The synchronous search cannot run the async reads two of its rules need — a
49
- concept target (a halo lookup) and a learnt connector between two answers (a
50
- `bridge`). `offerConcepts` and `offerConnectors` OFFER the keys up front (cheap:
51
- `hasNext`, the touching-site pairs and the N-ary allowances); the search ASKS
52
- for an offered key only where it reaches it — a connector when its splice's two
53
- premises meet, a concept target when the hop's asking form (held at the hop's
54
- own cost) is popped. A cover that asked is provisional: `cover.run` grants the
55
- asked keys and covers again, until a cover asks nothing — which is then the
56
- cover every key resolved in advance would have made. The joins licensed by
57
- ask-free rounds are kept across the re-covers.
1
+ # Cover — Compose the Question From What It Contains
2
+
3
+ `cover` answers by graph search. Its axioms are the question's own recognised
4
+ sites, and its goal is the lightest derivation that covers the question's bytes
5
+ and follows their continuations (`src/mind/mechanisms/cover.ts`, `GraphSearch`).
6
+ It runs first: a cover backed by a computation becomes an incumbent near zero
7
+ cost, and prunes the rest of the market through the ordinary floor check
8
+ (`mechanism-market.md`).
9
+
10
+ ## Matcher — recognition sites
11
+
12
+ Sites are the spans of the question that name a stored form (`recognition.ts`).
13
+ Any site that overlaps a computed span is masked: computation always wins,
14
+ enforced by masking rather than by price (`cost-model.md`).
15
+
16
+ ## Gates
17
+
18
+ - **The site must lead somewhere.** It has a continuation or a halo
19
+ (`leadsSomewhere`).
20
+ - **A fragment needs to be asked.** A site that answers other questions
21
+ (`answersOtherQuestions`: inside other forms, several continuations, a window
22
+ of the question outside it) is dropped unless the question names one of its
23
+ continuations. Otherwise the cover accounted the fragment's bytes as explained
24
+ by a stranger's answer (`unaskedFragments`).
25
+ - **Scaffolding accounts for nothing.** A span made only of hub windows
26
+ (`scaffoldSpans`) is not accounted (`evidence.md`).
27
+
28
+ ## Projection
29
+
30
+ - **Continuation edges.** `formRules` follow continuation edges at `STEP` per
31
+ hop, forking over continuations up to the hub bound. The continuation chosen
32
+ is `guidedFirst`'s: first one the question names, then distributional support,
33
+ then the first inserted (`determinism.md`).
34
+ - **Concept hops.** A form with no edge of its own may borrow a halo sibling's
35
+ continuation, at `CONCEPT`.
36
+ - **Dominance.** A span's cheapest completion dominates the rest, so a hub's
37
+ degree generates no work in the chart (`cost-model.md`).
38
+
39
+ ## Premises resolved where the search reaches them
40
+
41
+ The synchronous search cannot run the async reads that two of its rules need: a
42
+ concept target, which is a halo lookup, and a learnt connector between two
43
+ answers, which is a `bridge`. So `offerConcepts` and `offerConnectors` offer the
44
+ keys up front, cheaply. The search then asks for a key only when it reaches it:
45
+ a connector when a splice's two premises meet, and a concept target when the
46
+ form asking for it is popped.
47
+
48
+ A cover that asked is provisional. `cover.run` grants the asked keys and covers
49
+ again, until a cover asks for nothing. That final cover is the one that
50
+ resolving every key in advance would have produced. Joins licensed by rounds
51
+ that asked for nothing are kept across re-covers.
58
52
 
59
53
  ## Provenance
60
54
 
61
- `cover` for every cover derivation — including the fusion/recomposition steps
62
- (`fuse`/`recompose`) that name a deeper learned form. (`join` is NOT cover's:
63
- that provenance belongs to the CONFLUENCE mechanism, which reports it when
64
- independent evidence streams meet at one anchor — see
65
- `docs/mechanisms/confluence.md`.)
55
+ `cover`, including fusion and recomposition steps that name a deeper learnt
56
+ form. `join` belongs to `confluence`, not to `cover`.
66
57
 
67
58
  ## Pins
68
59
 
69
- - `test/09-edges.test.mjs` — edge following and hop semantics
70
- - `test/19-nd.test.mjs` — form rules and multi-hop chains
60
+ - `test/09` — edge following and hop semantics.
61
+ - `test/19` — form rules and multi-hop chains.
71
62
  - `test/151` — connectors and concept hops resolved where the search reaches
72
- them; a span's cheapest completion dominates (a hub's degree generates no
73
- work)
63
+ them; dominance.
64
+ - `test/154` — a fragment voices none of its continuations unless the question
65
+ names one.
@@ -1,53 +1,49 @@
1
- # Extraction — Skill-Framed Span Read-out
1
+ # Extraction — Read a Span Between Located Frames
2
2
 
3
- Extraction transfers a learnt span-in-context skill to an unseen query. A skill
4
- exemplar is a stored fact whose answer is a span of its context (or of its
5
- pieces); extraction locates the exemplar's framing bytes in the query and reads
6
- what sits between them.
3
+ Extraction transfers a learnt skill of the form "the answer is a span of the
4
+ context" to a question it has never seen. A **skill exemplar** is a stored fact
5
+ whose answer appears inside its own context. Extraction finds the exemplar's
6
+ framing bytes in the question and reads what sits between them
7
+ (`src/mind/mechanisms/extraction.ts`).
7
8
 
8
- ## Matcher — `skillExemplar` / `isSpanShaped` / `containsSpan` (`src/mind/match.ts`)
9
+ ## Matcher — span-shaped exemplars
9
10
 
10
- An exemplar is span-shaped when its answer embeds in order. `isSpanShaped` is
11
- the open reading (sparse subsequence, any gaps) for acceptance; `containsSpan`
12
- is the strict reading (contiguous run, or a resolved node) that fusion gates on,
13
- extraction decomposes with `answerRunsInContext` (greedy longest runs).
14
- Candidates are ranked anchors from `climbAttentionAll`
15
- (`Precomputed.spanShapedOf`), tried up to `pre.k`; sub-quantum (`< W`) or
16
- unanchored results are skipped.
11
+ The candidates are the climb's ranked anchors, tried up to `pre.k`
12
+ (`Precomputed.spanShapedOf`, `skillExemplar`). An exemplar qualifies when its
13
+ answer embeds in its context in order:
17
14
 
18
- ## Projection — read between located frames (`src/mind/mechanisms/extraction.ts`)
15
+ - **`isSpanShaped`** is the open reading, a sparse subsequence. Extraction
16
+ accepts on it.
17
+ - **`answerRunsInContext`** decomposes the answer into its pieces within the
18
+ context, taking the longest runs greedily. Fusion gates on the strict reading,
19
+ `containsSpan`, instead.
19
20
 
20
- `answerRunsInContext` splits the exemplar answer into pieces within its context.
21
- For each piece, the `W`-bounded pre-frame (and post-frame or next-piece
22
- pre-frame) is `locate`d in the query at recognition sites. Located frames define
23
- `start`/`end`; the bytes `query[start:end]` are read out. Multi-piece skills
24
- concatenate reads in order.
21
+ ## Projection — locate the frames, read between them
25
22
 
26
- ## Gate — both borders located to account (`src/mind/mechanisms/extraction.ts`)
23
+ For each piece, the bytes just before it (and just after it, or before the next
24
+ piece), bounded at `W`, are located in the question (`locate`). The located
25
+ frames fix the read's start and end. Multi-piece skills concatenate their reads
26
+ in order. Results shorter than one quantum are skipped.
27
27
 
28
- Frames are evidence only when `locate` succeeds. An unanchored read (no frame
29
- located, `accounted === []`) is discarded — not an extraction. An open-ended
30
- read (only one border located) stays unaccounted.
28
+ ## Gate and accounting — both borders, or nothing
31
29
 
32
- ## Cost (`src/mind/graph-search.ts`)
30
+ - **No frame located** (`accounted = []`): the read is discarded. That is
31
+ silence, not extraction.
32
+ - **A located frame is always evidence.**
33
+ - **The span read between frames is accounted only when both of its borders were
34
+ located.** An open-ended read stays priced at `PASS` per byte, so a bounded
35
+ extraction outweighs an echo that merely sets things side by side.
33
36
 
34
- Mechanism weight is `moves + PASS * unaccounted_bytes` with
35
- `moves = CONCEPT + STEP * accounted.length`. Comparison is at `STEP` grade, then
36
- scaffolding, then list order.
37
+ ## Cost
37
38
 
38
- ## Selective accounting
39
-
40
- Frames are always accounted when located. The read span between them is
41
- accounted only when bounded on both sides (`preBounded && postBounded`);
42
- otherwise it is PASS-priced like uncovered bytes, so a correct bounded
43
- extraction can outweigh an echoing juxtaposition.
39
+ `moves = CONCEPT + STEP · accounted.length`, with a floor of `CONCEPT + STEP`.
40
+ The floor checks `worthRunning` before touching the climb.
44
41
 
45
42
  ## Provenance
46
43
 
47
- `extract` (single-piece) or synthesised multi-piece read.
44
+ `extract`.
48
45
 
49
46
  ## Pins
50
47
 
51
- - `test/00-extract.test.mjs` — skill transfer across values and relations
52
- - `test/68-extraction-unanchored.test.mjs` — unanchored gate (empty accounted is
53
- silence)
48
+ - `test/00` — skill transfer across values and relations.
49
+ - `test/68` — an unanchored read is silence.
@@ -1,54 +1,51 @@
1
- # Prefix Completion — Literal Opening of One Trained Form
1
+ # Prefix Completion — Complete a Known Beginning
2
2
 
3
- The query is a proper prefix of exactly one trained form. That form is voiced
4
- whole; nothing is invented.
3
+ When the question is a proper prefix of exactly one trained form, that form is
4
+ voiced whole and nothing is invented
5
+ (`src/mind/mechanisms/prefix-completion.ts`).
5
6
 
6
- ## Gate — exactly one opener
7
+ ## Supply — one union, decided once
7
8
 
8
- A candidate is a form whose bytes literally open with the query (every query
9
- byte matched in order from offset zero). Grounding requires **exactly one
10
- distinct continuation** over the candidate set:
9
+ Resonance cannot rank a proper prefix. On the trained store, the cosine between
10
+ a prefix and its form falls from 0.96 at one truncated byte to 0.62 at three,
11
+ against a reach bar of 0.875. So the candidates come from two supplies:
11
12
 
12
- - **Candidates** = `formsOpenedBy` (content-addressed window index) ∪ memoised
13
- `resonance` top-k — evaluated as one union so an exact-index ambiguity cannot
14
- be hidden by the approximate tier.
15
- - **Distinctness** is by continuation bytes, not form id.
16
- - **Zero or ≥2 distinct continuations → refuse** (the prefix trap).
13
+ - **`formsOpenedBy`** (`traverse.ts`) reads the write side's window index, which
14
+ is position-invariant, and climbs containment and then parents to the deposits
15
+ a prefix opens. It is bounded by `hubBound`.
16
+ - **The response's top-`k` resonance.**
17
17
 
18
- ## Cost (`src/mind/graph-search.ts`)
18
+ The two are concatenated, and the guards decide once over the union. A chain
19
+ that tried one supply and then the other would let the approximate tier override
20
+ an ambiguity the exact one found.
19
21
 
20
- | Symbol | Value | Rule |
21
- | ------ | ----- | ------------------------------------------------- |
22
- | `STEP` | 1 | maximal claim: every query byte literally matched |
22
+ ## Guards
23
23
 
24
- `floor` returns `STEP`; `run` returns one candidate with `moves = STEP`,
25
- `accounted = [[0, query.length]]`, `bytes = form`.
24
+ 1. **Literal opening.** Every byte of the question matches the form in order
25
+ from offset 0.
26
+ 2. **Exactly one distinct continuation**, compared by bytes, not by form id.
27
+ Zero or two or more means refusal: that is the prefix trap.
28
+ 3. **Readable.** If any candidate saturates its capped `bytesPrefix` read, none
29
+ is licensed.
30
+ 4. **At least one window.** A continuation shorter than `W` cannot be voiced,
31
+ and counts as disagreement.
26
32
 
27
- ## `complete` flag
33
+ ## Cost
28
34
 
29
- The result carries `complete` semantics: the grounded bytes are a trained form
30
- reached by identity. Post-grounding (`reason` → `fuse`) must not extend them.
35
+ `STEP`, with `accounted = [[0, query.length]]`, since every byte is literally
36
+ matched. The result is **not** `complete`: the form may carry more beyond the
37
+ remainder this step voiced. The floor checks `worthRunning(STEP)` before either
38
+ supply is touched, and returns `null` when the question leaves no room for a
39
+ continuation within the phrase cap.
31
40
 
32
- ## Guards (from `src/mind/mechanisms/prefix-completion.ts`)
41
+ The mechanism is registered after `recall`, so an exact self-match wins ties.
33
42
 
34
- 1. **Unreadable veto** — a saturating `bytesPrefix` read is a standing
35
- disagreement; if any candidate saturates, none is licensed.
36
- 2. **One grouping window** — continuation must be ≥ `W` (`maxGroup`);
37
- sub-quantum tails are unvoiceable and also count as disagreement.
38
- 3. **Uniqueness** — as above.
43
+ ## Provenance
39
44
 
40
- Structural pre-check (`floor`): `query.length * W < query.length + W` → `null`
41
- (no room for a perceivable continuation).
42
-
43
- ## Where it runs
44
-
45
- Last grounding mechanism in `defaultMechanisms` (`mind/pipeline.ts`); registered
46
- after recall so an exact self-match (`IDENTITY`) wins ties. Shares
47
- `formsOpenedBy` (`mind/traverse.ts`) and `Precomputed.resonance()`.
45
+ `prefix`.
48
46
 
49
47
  ## Pins
50
48
 
51
- - `test/70-prefix-completion.test.mjs` — literal prefix, ambiguity, sub-quantum,
52
- saturating-read veto, determinism.
53
- - `test/72-prefix-candidate-supply.test.mjs` — `formsOpenedBy` ∪ `resonance`
54
- union supply; resonance alone cannot rank a proper prefix.
49
+ - `test/70` — a literal prefix, ambiguity, a sub-quantum tail, the veto on a
50
+ saturating read, and determinism.
51
+ - `test/72` — the union supply; resonance alone cannot rank a proper prefix.