@hviana/sema 0.8.2 → 0.8.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 (126) hide show
  1. package/AGENTS.md +38 -37
  2. package/README.md +17 -38
  3. package/TRADEMARKS.md +0 -1
  4. package/dist/example/demo.js +85 -34
  5. package/dist/src/config.d.ts +11 -0
  6. package/dist/src/config.js +2 -0
  7. package/dist/src/geometry.d.ts +21 -10
  8. package/dist/src/geometry.js +21 -12
  9. package/dist/src/meter.d.ts +62 -0
  10. package/dist/src/meter.js +62 -0
  11. package/dist/src/mind/articulation.js +1 -1
  12. package/dist/src/mind/attention.d.ts +4 -0
  13. package/dist/src/mind/attention.js +167 -17
  14. package/dist/src/mind/canonical.d.ts +16 -0
  15. package/dist/src/mind/canonical.js +41 -0
  16. package/dist/src/mind/derivation.d.ts +201 -0
  17. package/dist/src/mind/derivation.js +327 -0
  18. package/dist/src/mind/graph-search.d.ts +2 -1
  19. package/dist/src/mind/graph-search.js +70 -29
  20. package/dist/src/mind/match.d.ts +3 -1
  21. package/dist/src/mind/match.js +7 -3
  22. package/dist/src/mind/mechanisms/alu.js +0 -2
  23. package/dist/src/mind/mechanisms/cast.d.ts +1 -5
  24. package/dist/src/mind/mechanisms/cast.js +16 -19
  25. package/dist/src/mind/mechanisms/confluence.d.ts +0 -3
  26. package/dist/src/mind/mechanisms/confluence.js +27 -9
  27. package/dist/src/mind/mechanisms/cover.js +17 -20
  28. package/dist/src/mind/mechanisms/extraction.d.ts +0 -1
  29. package/dist/src/mind/mechanisms/extraction.js +13 -8
  30. package/dist/src/mind/mechanisms/prefix-completion.js +0 -1
  31. package/dist/src/mind/mechanisms/recall.d.ts +0 -1
  32. package/dist/src/mind/mechanisms/recall.js +40 -13
  33. package/dist/src/mind/mechanisms/reference.js +3 -4
  34. package/dist/src/mind/mind.d.ts +4 -2
  35. package/dist/src/mind/mind.js +5 -4
  36. package/dist/src/mind/pipeline-mechanism.d.ts +7 -3
  37. package/dist/src/mind/pipeline.js +136 -44
  38. package/dist/src/mind/primitives.js +9 -1
  39. package/dist/src/mind/rationale.d.ts +21 -5
  40. package/dist/src/mind/rationale.js +16 -21
  41. package/dist/src/mind/reasoning.d.ts +12 -20
  42. package/dist/src/mind/reasoning.js +190 -106
  43. package/dist/src/mind/recognition.js +4 -8
  44. package/dist/src/mind/resonance.js +20 -1
  45. package/dist/src/mind/trace.js +1 -0
  46. package/dist/src/mind/traverse.js +6 -2
  47. package/dist/src/mind/types.d.ts +36 -13
  48. package/dist/src/mind/types.js +6 -3
  49. package/docs/INDEX.md +23 -24
  50. package/docs/INVARIANTS.md +16 -17
  51. package/docs/architecture/bounded-reads.md +5 -5
  52. package/docs/architecture/closure.md +65 -0
  53. package/docs/architecture/commonality.md +29 -20
  54. package/docs/architecture/cost-model.md +7 -7
  55. package/docs/architecture/determinism.md +7 -7
  56. package/docs/architecture/exact-vs-approximate.md +4 -4
  57. package/docs/architecture/factored-machinery.md +14 -14
  58. package/docs/architecture/match-project.md +2 -3
  59. package/docs/architecture/mechanism-market.md +16 -16
  60. package/docs/architecture/meter.md +10 -11
  61. package/docs/architecture/store.md +4 -4
  62. package/docs/architecture/thresholds.md +1 -1
  63. package/docs/failures/tempting-but-wrong.md +14 -5
  64. package/docs/harness/gates.md +7 -7
  65. package/docs/mechanisms/cast.md +2 -2
  66. package/docs/mechanisms/cover.md +4 -5
  67. package/docs/mechanisms/extraction.md +7 -7
  68. package/docs/mechanisms/recall.md +8 -9
  69. package/example/demo.ts +90 -37
  70. package/jsr.json +1 -1
  71. package/package.json +1 -1
  72. package/src/alu/README.md +11 -12
  73. package/src/config.ts +13 -0
  74. package/src/geometry.ts +21 -13
  75. package/src/meter.ts +62 -0
  76. package/src/mind/articulation.ts +0 -1
  77. package/src/mind/attention.ts +169 -17
  78. package/src/mind/canonical.ts +43 -0
  79. package/src/mind/derivation.ts +473 -0
  80. package/src/mind/graph-search.ts +76 -34
  81. package/src/mind/match.ts +7 -3
  82. package/src/mind/mechanisms/alu.ts +0 -2
  83. package/src/mind/mechanisms/cast.ts +20 -22
  84. package/src/mind/mechanisms/confluence.ts +27 -13
  85. package/src/mind/mechanisms/cover.ts +17 -20
  86. package/src/mind/mechanisms/extraction.ts +13 -9
  87. package/src/mind/mechanisms/prefix-completion.ts +0 -1
  88. package/src/mind/mechanisms/recall.ts +39 -13
  89. package/src/mind/mechanisms/reference.ts +2 -3
  90. package/src/mind/mind.ts +6 -4
  91. package/src/mind/pipeline-mechanism.ts +7 -3
  92. package/src/mind/pipeline.ts +160 -52
  93. package/src/mind/primitives.ts +9 -1
  94. package/src/mind/rationale.ts +27 -23
  95. package/src/mind/reasoning.ts +227 -120
  96. package/src/mind/recognition.ts +4 -8
  97. package/src/mind/resonance.ts +19 -1
  98. package/src/mind/trace.ts +1 -0
  99. package/src/mind/traverse.ts +7 -5
  100. package/src/mind/types.ts +41 -15
  101. package/test/105-derive-through-reports-its-refusal.test.mjs +24 -0
  102. package/test/118-the-join-reaches-a-key-off-the-cut.test.mjs +74 -0
  103. package/test/119-the-work-does-not-grow-with-the-corpus.test.mjs +122 -0
  104. package/test/120-composition-is-consequence.test.mjs +132 -0
  105. package/test/121-the-extension-does-not-grow-with-the-corpus.test.mjs +128 -0
  106. package/test/122-the-climb-search-does-not-grow-with-the-corpus.test.mjs +117 -0
  107. package/test/123-the-paired-formulas-agree.test.mjs +90 -0
  108. package/test/125-the-post-grounding-branch-publishes-its-operand.test.mjs +51 -0
  109. package/test/126-the-pipeline-does-not-name-mechanisms.test.mjs +42 -0
  110. package/test/128-the-leads-somewhere-pair-agrees.test.mjs +83 -0
  111. package/test/129-the-trace-payload-shape.test.mjs +164 -0
  112. package/test/133-the-decision-point-renders-the-state.test.mjs +204 -0
  113. package/test/134-the-law-explains-the-engines-own-refusal.test.mjs +237 -0
  114. package/test/135-one-law-any-producer.test.mjs +289 -0
  115. package/test/136-the-two-named-limits.test.mjs +205 -0
  116. package/test/137-the-law-lives-once-and-below.test.mjs +400 -0
  117. package/test/138-the-remainder-drains-only-what-a-move-declares.test.mjs +62 -0
  118. package/test/139-the-witness-is-engagement-not-explanation.test.mjs +51 -0
  119. package/test/140-irrelevant-supply-does-not-change-an-answer.test.mjs +48 -0
  120. package/test/141-the-question-is-paid-at-construction.test.mjs +98 -0
  121. package/test/32-confluence.test.mjs +68 -0
  122. package/test/36-already-answered-fusion.test.mjs +20 -2
  123. package/test/37-cluster-dispersion-fusion.test.mjs +30 -3
  124. package/test/38-reason-restate-guard.test.mjs +28 -2
  125. package/test/43-cast-analog-seat.test.mjs +10 -0
  126. package/test/55-cost-meter.test.mjs +862 -0
package/docs/INDEX.md CHANGED
@@ -8,10 +8,10 @@ proof in `test/` (pins that fail when the law is broken).
8
8
 
9
9
  | Task | Read | Why |
10
10
  | --------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
11
- | Add a mechanism | `docs/architecture/mechanism-market.md` + `docs/mechanisms/*.md` | Market contract: decoupled, declared competence, visible budget, evidence travels |
12
- | Add a threshold | `docs/architecture/thresholds.md` | All cutoffs are formulas over D/W/N in `geometry.ts`; `config.ts` holds only budgets |
13
- | Debug an answer | `docs/architecture/cost-model.md` + `src/meter.ts` | One cost ladder (`MICRO`/`STEP`/`CONCEPT`/`PASS`) decides every grounding choice |
14
- | Understand the fold | `docs/architecture/fold-contract.md` | Deposit and inference must compute the same tree; boundaries are not turn metadata |
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
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
16
  | Add an ALU operation | `src/alu/README.md` | One `registry.derive` per op composing existing ops; no new `derive` needed |
17
17
  | Add a matcher or projection | `docs/architecture/match-project.md` | Mechanisms are `(matcher, direction, gate)` configs over the shared `match.ts` family |
@@ -19,23 +19,24 @@ 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 (13)
22
+ ## Architecture laws (14)
23
23
 
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; five 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 and investment discipline | `test/01`, `test/04` |
32
- | 7 | `docs/architecture/commonality.md` | Two populations: corpus-global (`reachOf`+`dominates`) vs weave-local (`depth[]`) | `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; `contentLevels` is single boundary rule; no W/offset dependence | `test/59`, `test/63` |
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 deterministic, phases nest | `test/55` |
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; five 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 and investment discipline | `test/01`, `test/04` |
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; `contentLevels` is single boundary rule; no W/offset dependence | `test/59`, `test/63` |
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 | `test/133`–`140` |
39
40
 
40
41
  ## Mechanisms (8)
41
42
 
@@ -63,9 +64,7 @@ proof in `test/` (pins that fail when the law is broken).
63
64
  - `docs/INVARIANTS.md` — the five invariants (determinism, derived thresholds,
64
65
  exact-decides, one cost currency, bounded reads) with file-level routing.
65
66
  - `docs/failures/tempting-but-wrong.md` — refuted simplifications that passed
66
- review but failed pins (e.g. reordering ladders, flattening attention
67
- asymmetries, one-cone-exhausted stop).
67
+ review but failed pins.
68
68
  - `docs/harness/gates.md` — how `AGENTS.md` recipes,
69
69
  `bench/profile-inference.mjs`, and `test/*.test.mjs` enforce the laws.
70
- - `docs/architecture/` — full per-law derivation (each file states why the law
71
- is this way; no separate HOW).
70
+ - `docs/architecture/` — per-law derivation: each file says why, not how.
@@ -1,19 +1,18 @@
1
1
  # INVARIANTS — Laws, Proofs, Derivations
2
2
 
3
- > Law in `docs/architecture/*.md`, proof in `test/*.test.mjs`.
4
-
5
- | # | Law | Where defined (src symbol) | Pins (test/N) | Doc (docs/architecture/*.md) |
6
- | -- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ---------------------------- |
7
- | 1 | Determinism | `src/config.ts:seed` `src/alphabet.ts:Alphabet` `src/mind/traverse.ts:guidedFirst` | `test/20` `test/42` | `determinism.md` |
8
- | 2 | Derived thresholds | `src/geometry.ts:mergeThreshold,identityBar,reachThreshold,significanceBar,consensusFloor,dominates` | `test/64` `test/40` | `thresholds.md` |
9
- | 3 | Exact decides / approximate proposes | `src/mind/primitives.ts:resolve` `src/mind/match.ts:locate,alignGraded` `src/mind/resonance.ts:bridge` | `test/51` | `exact-vs-approximate.md` |
10
- | 4 | One cost currency | `src/mind/graph-search.ts:MICRO,STEP,CONCEPT,PASS` `src/derive:lightestDerivation` (min,+) `src/mind/attention.ts:poolVotes` (+,+) | `test/55` `test/04` | `cost-model.md` |
11
- | 5 | Bounded reads | `src/store.ts:AbstractStore:nextFirst,parentsFirst,containersSlice,hasNext,bytesPrefix` `src/mind/traverse.ts:hubBound,hubCap` | `test/90` `test/14` | `bounded-reads.md` |
12
- | 6 | Fold contract | `src/geometry.ts:contentLevels` `src/mind/canonical.ts:canonicalWindows,chainReach` `src/canon.ts:canonicalizer` | `test/59` `test/63` | `fold-contract.md` |
13
- | 7 | Mechanism market | `src/mind/pipeline-mechanism.ts:PipelineMechanism,Precomputed` `src/mind/pipeline.ts:think,worthRunning` | `test/01` `test/04` | `mechanism-market.md` |
14
- | 8 | Two commonality measures | `src/mind/traverse.ts:reachOf,dominates,corpusN` (global) `src/mind/match.ts:depth[],MIN_WEAVE` (weave-local) | `test/17` `test/34` | `commonality.md` |
15
- | 9 | Memoization idempotence | `src/mind/pipeline-mechanism.ts:Precomputed` `src/mind/mind.ts:beginResponse,endResponse,_resolvedSubtrees` | `test/42` | `memoization.md` |
16
- | 10 | Caches as budgets | `src/store.ts:BoundedMap` `src/config.ts:StoreConfig:bytesCacheMax,recCacheBytes,haloCacheBytes` | `test/96` `test/91` | `caches.md` |
17
- | 11 | Honest degradation | `src/mind/pipeline.ts:weight=moves+PASS*unaccounted` `src/store.ts:BoundedMap:miss→re-derive` | `test/28` `test/84` | `store.md`+`caches.md` |
18
- | 12 | Meter contracts | `src/meter.ts:Meter,PhaseCost,time` `src/mind/pipeline-mechanism.ts:Precomputed.shared` | `test/55` | `meter.md` |
19
- | 13 | Saturation | `src/mind/traverse.ts:edgeAncestors:SaturationReason` `src/mind/junction.ts:junctionContainersFrom` `src/mind/resonance.ts:pivotInto` | `test/27` `test/16` | `saturation.md` |
3
+ | # | Law | Defined in | Pins | Doc |
4
+ | -- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------------------------- |
5
+ | 1 | Determinism | `src/config.ts:seed` `src/alphabet.ts:Alphabet` `src/mind/traverse.ts:guidedFirst` | `test/20` `test/42` | `determinism.md` |
6
+ | 2 | Derived thresholds | `src/geometry.ts:mergeThreshold,identityBar,reachThreshold,significanceBar,consensusFloor,dominates` | `test/64` `test/40` | `thresholds.md` |
7
+ | 3 | Exact decides / approximate proposes | `src/mind/primitives.ts:resolve` `src/mind/match.ts:locate,alignGraded` `src/mind/resonance.ts:bridge` | `test/51` | `exact-vs-approximate.md` |
8
+ | 4 | One cost currency | `src/mind/graph-search.ts:MICRO,STEP,CONCEPT,PASS` `src/derive:lightestDerivation` (min,+) `src/mind/attention.ts:poolVotes` (+,+) | `test/55` `test/04` | `cost-model.md` |
9
+ | 5 | Bounded reads | `src/store.ts:AbstractStore:nextFirst,parentsFirst,containersSlice,hasNext,bytesPrefix` `src/mind/traverse.ts:hubBound,hubCap` | `test/90` `test/14` | `bounded-reads.md` |
10
+ | 6 | Fold contract | `src/geometry.ts:contentLevels` `src/mind/canonical.ts:canonicalWindows,chainReach` `src/canon.ts:canonicalizer` | `test/59` `test/63` | `fold-contract.md` |
11
+ | 7 | Mechanism market | `src/mind/pipeline-mechanism.ts:PipelineMechanism,Precomputed` `src/mind/pipeline.ts:think,worthRunning` | `test/01` `test/04` | `mechanism-market.md` |
12
+ | 8 | Two commonality measures | `src/mind/traverse.ts:reachOf,dominates,corpusN` (global) `cast.ts:depth[],MIN_WEAVE` (weave-local) | `test/17` `test/34` | `commonality.md` |
13
+ | 9 | Memoization idempotence | `src/mind/pipeline-mechanism.ts:Precomputed` `src/mind/mind.ts:beginResponse,endResponse,_resolvedSubtrees` | `test/42` | `memoization.md` |
14
+ | 10 | Caches as budgets | `src/store.ts:BoundedMap` `src/config.ts:StoreConfig:bytesCacheMax,recCacheBytes,haloCacheBytes` | `test/96` `test/91` | `caches.md` |
15
+ | 11 | Honest degradation | `src/mind/pipeline.ts:weight=moves+PASS*unaccounted` `src/store.ts:BoundedMap:miss→re-derive` | `test/28` `test/84` | `store.md`+`caches.md` |
16
+ | 12 | Meter contracts | `src/meter.ts:Meter,PhaseCost,time` `src/mind/pipeline-mechanism.ts:Precomputed.shared` | `test/55` | `meter.md` |
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
+ | 14 | Closure | `src/mind/derivation.ts:closed,admissible,advance` | `test/133`–`140` | `closure.md` |
@@ -3,10 +3,10 @@
3
3
  > **Law:** the cost of one query is proportional to the query, not to how much
4
4
  > was learned. No per-query read may grow with corpus size N.
5
5
 
6
- Every fan-out, walk, and disambiguation is capped at `hubBound` —
7
- `ceil(sqrt(N))` — derived once from `corpusN` and floored at 2 so `sqrt` and
8
- `ln` stay meaningful on a near-empty store. There is no second convention; do
9
- not invent one.
6
+ Every fan-out, walk, and disambiguation reads at most the OLDEST `hubBound` —
7
+ `ceil(sqrt(N))`, floored at 2 for a near-empty store. A better-supported
8
+ candidate beyond that prefix is invisible: a trade, and there is no second
9
+ convention.
10
10
 
11
11
  ## Scale
12
12
 
@@ -18,7 +18,7 @@ boundFor(n) = ceil(sqrt(max(2, n))) // ctx-free reading
18
18
  ```
19
19
 
20
20
  Defined once in `mind/traverse.ts` (`corpusN`, `hubBound`, `hubCap`,
21
- `boundFor`). Every consumer imports them; never spell `Math.sqrt` inline.
21
+ `boundFor`). Every consumer imports them; never re-derive them inline.
22
22
 
23
23
  ## Enforcement at the store level
24
24
 
@@ -0,0 +1,65 @@
1
+ # Closure — One Law, One Unit, Every Transition
2
+
3
+ > **Law:** a step is admitted only when it CLOSES the derivation, or MOVES to
4
+ > structure it has not consumed, or CARRIES material the asker left unaccounted.
5
+
6
+ One unit and one law, asked by every tier that decides whether to continue: the
7
+ chart's frontier, the market's candidates, the post-grounding walk, fusion, and
8
+ the mechanisms' own gates. None re-spells a condition the law owns.
9
+
10
+ ## The unit — `src/mind/derivation.ts`
11
+
12
+ | Field | What it is |
13
+ | ----------- | ----------------------------------------------------- |
14
+ | `product` | the answer bytes so far |
15
+ | `accounted` | the spans of the asker's bytes it explains |
16
+ | `remainder` | what the asker still owes, per span, at the `W` floor |
17
+ | `cost` | the currency's total for the steps taken |
18
+ | `fixed` | a declared fixpoint: no transition is offered |
19
+ | `used` | the anchors the producer speaks for |
20
+
21
+ No identity field (`resolve(product)` is one), no structure field, no frontier
22
+ field, no producer field, and no count of any kind. The witnesses `contains` and
23
+ `moves` are the LAYER's: it holds the structure and hands them in, so the law
24
+ never probes the store.
25
+
26
+ ## The transition
27
+
28
+ `admissible(state, continuation, query, W)` returns the witnesses the step pays
29
+ in, or `null`; `advance(state, continuation, witnesses)` is the only transition.
30
+ The remainder is consumed only by a declared move, and only by the material that
31
+ move CARRIES: `carries` admits by ENGAGEMENT and consumes nothing, a move
32
+ consumes what its window proves. Whole-span draining was refuted by `test/110`,
33
+ the window alone by `test/138`. The state is BORN owing what its product does
34
+ not carry.
35
+
36
+ ## One cost home
37
+
38
+ `moves + PASS · unaccountedBytes` is computed in ONE place (`pipeline.ts`,
39
+ `weigh`). A mechanism reports `moves` and `accounted` — what it did — and never
40
+ a price; `cover` reports its chart derivation's work.
41
+
42
+ ## Two limits, proved and left out
43
+
44
+ 1. **The chart cannot evaluate accounting** — its interface has no parameter for
45
+ it, and carrying it per item was measured and rejected. The chart reads the
46
+ same law off an item: identity is its `key`, continuation the rule's
47
+ existence, progress the frontier advancing, closure the goal test, `fix` is
48
+ `fixed`.
49
+ 2. **Closure by the query's position in the graph is not a term of the unit** —
50
+ `reason`'s echo guards stop with the remainder non-empty, and recall's
51
+ reverse tiers close with an empty accounting. That is a fact about the
52
+ asker's material in the store, available only to the layer holding it.
53
+
54
+ ## Layering
55
+
56
+ Imports `../bytes.js` only, and sits below `graph-search.ts`, `match.ts`,
57
+ `rationale.ts` and `pipeline.ts`. The span algebra lives here too — the law's
58
+ vocabulary, not the tracer's.
59
+
60
+ ## Pins
61
+
62
+ - `test/133`–`137` — the law's home, readings, refusal, limits.
63
+ - `test/138` — a cycle cannot close it; a carried move can.
64
+ - `test/139` — carrying is ENGAGEMENT, not explanation.
65
+ - `test/140` — irrelevant supply changes no answer.
@@ -1,9 +1,9 @@
1
- # Two Measures of Commonality
1
+ # Three Measures of Commonality
2
2
 
3
- Sema needs "what is shared" in two different populations. One is corpus-global
4
- (how widely a structure is reused), the other is weave-local (what a local
5
- cohort of overlapping forms agrees on). They use different data and different
6
- formulas and must not be conflated.
3
+ Sema needs "what is shared" in three populations: corpus-global (how widely a
4
+ structure is reused), weave-local (what a local cohort of overlapping forms
5
+ agrees on), and container-local (how many containers hold a byte window).
6
+ Different data, different formulas, never conflated.
7
7
 
8
8
  ## Corpus-global — `reachOf` + `dominates`
9
9
 
@@ -11,32 +11,41 @@ _Defined in `src/mind/traverse.ts` + `src/geometry.ts`; used by climb,
11
11
  containment, IDF pooling._
12
12
 
13
13
  For a node id, `reachOf(id, N)` counts how many learnt contexts contain it
14
- (ancestor reach via capped graph walks, memoised per response in
15
- `sharedReachMemo`). `dominates(reach, N)` then asks whether that reach is above
16
- the corpus-determined majority threshold (derived in `geometry.ts` over `N`).
17
- Intuition: minority reach discriminates (a filler), majority reach is
18
- scaffolding. Powers the consensus climb, edge following, and vote pooling.
14
+ (capped graph walks, memoised per response in `sharedReachMemo`).
15
+ `dominates(reach, N)` asks whether that reach is above the corpus-determined
16
+ majority threshold (`geometry.ts`, over `N`). Minority reach discriminates (a
17
+ filler), majority reach is scaffolding. Powers the climb, edge following and
18
+ vote pooling.
19
19
 
20
20
  ## Weave-local — `depth[]` + `MIN_WEAVE` + `dominates`
21
21
 
22
- _Defined in `src/mind/match.ts` (`depth[]`, `MIN_WEAVE`, `frame`) and gated in
23
- `src/mind/match.ts:frame`; used by CAST._
22
+ _Defined and gated in `src/mind/mechanisms/cast.ts` (`depth[]` from the shared
23
+ weave, `MIN_WEAVE`); used by CAST._
24
24
 
25
25
  For an alignment weave, `depth[i]` counts how many aligned structures cover byte
26
- `i` of the query. `MIN_WEAVE = 2` requires agreement beyond a pair (pair columns
27
- are ambiguous with insertions/deletions), and `dominates(depth[i], aligned)`
28
- requires agreement by a majority of the aligned cohort:
26
+ `i` of the query; `MIN_WEAVE = 2` requires agreement beyond a pair (pairs are
27
+ ambiguous with insertions), and `dominates(depth[i], aligned)` a majority of the
28
+ cohort:
29
29
 
30
30
  ```
31
31
  frame(i) ⇔ depth[i] > MIN_WEAVE ∧ dominates(depth[i], aligned)
32
32
  ```
33
33
 
34
- This powers CAST's frame gate: what the local cohort shares vs what
35
- differentiates one member. It never consults corpus reach.
34
+ This powers CAST's frame gate — what the cohort shares vs what differentiates
35
+ one member — and never consults corpus reach.
36
36
 
37
- The two measures answer different questions over different populations; CAST's
38
- frame must not be replaced by a reach check and the climb must not be driven by
39
- weave depth.
37
+ The three answer different questions over different populations; CAST's frame
38
+ must not be replaced by a reach check, and the climb must not be driven by weave
39
+ depth.
40
+
41
+ ## Container-local — the window's rarity
42
+
43
+ _Defined in `src/mind/bridge.ts` (`containersSlice(id, 0, bound + 1).length`);
44
+ used by the bridge, and by attention's anchoring._
45
+
46
+ `rarity` counts how many containers hold a byte window: zero anchors nothing,
47
+ two or more marks it REUSED (`winReused`), and the bridge sorts its anchors by
48
+ it, so the rarest leads. Purpose: choosing what to anchor on.
40
49
 
41
50
  ## Pins
42
51
 
@@ -19,17 +19,17 @@ with that order give the same derivations.
19
19
 
20
20
  ## Pipeline weighing (`src/mind/pipeline.ts:think`)
21
21
 
22
- Mechanism candidates are weighed in the same ladder:
22
+ Candidates are weighed in ONE place — a mechanism reports `moves` and
23
+ `accounted`, never a price:
23
24
 
24
25
  ```
25
26
  weight = moves + PASS * unaccounted_bytes
26
27
  grade = floor(weight / STEP)
27
28
  ```
28
29
 
29
- `unaccounted` is the query bytes no `accounted` span covers. Comparison is at
30
- `STEP` resolution: lowest `grade` wins. At equal grade the candidate with fewer
31
- `scaffolding` bytes (answer bytes lifted from unrecognised spans) wins; only
32
- then does mechanism list order decide.
30
+ `unaccounted` is what no `accounted` span covers. Comparison is at `STEP`
31
+ resolution: lowest `grade` wins; at equal grade fewer `scaffolding` bytes
32
+ (answer bytes lifted from unrecognised spans) wins; then list order.
33
33
 
34
34
  ## Two semirings
35
35
 
@@ -59,8 +59,8 @@ exceeds the true remaining cost.
59
59
  ## Policy is not cost
60
60
 
61
61
  "Computation always wins" is **not** priced into the ladder (a computed result
62
- costs `STEP`, same as a learned edge). It is enforced by masking: `pipeline.ts`
63
- removes recognised sites overlapped by a `ComputedResult` so the computation is
62
+ costs `STEP`, same as a learned edge). It is enforced by masking: `cover.ts`
63
+ removes recognised sites overlapped by a `ComputedResult`, so the computation is
64
64
  the sole completion there. Keep policy in callers; keep the engine neutral.
65
65
 
66
66
  ## Pins
@@ -20,7 +20,7 @@ flaky, the contract was broken, not the test.
20
20
  entropy root. Subsystems derive deterministically:
21
21
 
22
22
  - **Alphabet** — `Alphabet` (`src/alphabet.ts`) via `rng` (`src/vec.ts:rng`)
23
- seeded as `seed ^ seedMask`; builds 16→64→256 vectors by refinement.
23
+ seeded as `seed ^ seedMask`; builds 16→64→256 vectors.
24
24
  - **Keyring / Space** — `Space.seats` (`src/sema.ts:Space`) via `makeKeyring`
25
25
  (`src/vec.ts:makeKeyring`) and `rng` seeded from `seed` in `Mind`
26
26
  (`src/mind/mind.ts`); `fold`/`twoEndedSeat`/`companySignature` are pure over
@@ -34,8 +34,8 @@ derived from `D`/`W`/`N`, not sampled.
34
34
 
35
35
  ## Tie-breaks are corpus-determined
36
36
 
37
- Every choice among equals bottoms out in a fixed ordering — insertion order or
38
- lowest node id. The universal no-evidence fallback is **first-inserted**:
37
+ Every choice bottoms out in a fixed ordering — insertion order or lowest node id
38
+ — not interchangeable (`test/34`). The fallback is **first-inserted**:
39
39
 
40
40
  - `guidedFirst` (`src/mind/traverse.ts:guidedFirst`) — guided pick via
41
41
  `chooseNext` else first-inserted edge (`nextFirst` LIMIT 1).
@@ -46,7 +46,7 @@ lowest node id. The universal no-evidence fallback is **first-inserted**:
46
46
  - `companySignature` (`src/sema.ts:companySignature`) — `rng(id ^ 0x9e3779b9)`,
47
47
  i.e. seeded by node id, not observation order.
48
48
 
49
- Last-inserted was once used in one place; it was a bug. Never reintroduce it.
49
+ Never use last-inserted.
50
50
 
51
51
  ## Memoization and trace must not break identity
52
52
 
@@ -56,7 +56,7 @@ Per-response memos (`Precomputed`, `perceiveMemo`, `recogniseMemo`, `climbMemo`,
56
56
  `src/mind/primitives.ts`) are sound because asking never writes. Only
57
57
  `guidedNext`/`sharedReachMemo` are trace-bypassed;
58
58
  `perceiveMemo`/`recogniseMemo`/`climbMemo` are always consulted — `foldTree`'s
59
- subtree fast path skips `visit` (and thus site emission) for cached subtrees, so
59
+ subtree fast path skips `visit` (and site emission) for cached subtrees, so
60
60
  bypassing makes `recognise` non-idempotent.
61
61
 
62
62
  ## Follow it
@@ -69,5 +69,5 @@ call `Math.random`/`Date.now` on a behavioural path.
69
69
 
70
70
  - `test/42` pins recognition idempotence under trace — traced and untraced
71
71
  `recognise` must return the same cached object and site count.
72
- - Determinism suites — `test/03`, `test/04`, `test/08`, `test/20` and others
73
- assert same seed + same training ⇒ byte-identical answers and stores.
72
+ - Determinism suites — `test/03`, `test/04`, `test/08`, `test/20` — assert same
73
+ seed + same training ⇒ byte-identical answers and stores.
@@ -2,16 +2,16 @@
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
5
- decided only by content-addressed lookup — `resolve` / `findLeaf` / `findBranch`
6
- / `canonResolve` — and by re-folding bytes to verify.
5
+ content-addressed lookup — `resolve` / `findLeaf` / `findBranch` /
6
+ `canonResolve` — with ONE exception: the store's near-merge (`store.ts`).
7
7
 
8
8
  ## The law
9
9
 
10
10
  > Scores propose, bytes dispose.
11
11
 
12
12
  Even recall's echo decision re-folds the top hit's bytes rather than trusting
13
- the estimate it already has. No `score >= threshold` path may mint an identity
14
- claim; thresholds derived in `geometry.ts` gate search breadth, not truth.
13
+ the estimate. No OTHER `score >= threshold` path may mint an identity;
14
+ thresholds gate breadth, not truth.
15
15
 
16
16
  ## Graded evidence ladders
17
17
 
@@ -3,23 +3,23 @@
3
3
  Every shared operation is defined once and imported many times. Duplicating it
4
4
  forks the corpus contract; moving it hides who owns the gate.
5
5
 
6
- For the match → project → gate family see `match-project.md`; for the two
7
- commonality measures see `commonality.md`; for work accounting see `meter.md`.
6
+ Siblings: `match-project.md`, `commonality.md`, `meter.md`.
8
7
 
9
8
  ## Single-definition contracts
10
9
 
11
- | Symbol | Defined in | One fact |
12
- | ------------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
13
- | `contentLevels` | `src/geometry.ts` | Single boundary rule: cuts + levels from one rolling hash pass; every segmentation reads it. |
14
- | `canonicalWindows` / `chainReach` / `leafIdRun` / `windowIds` | `src/mind/canonical.ts` | Write/read contract: training interns `W-1,W` windows, reading chains to `W²` and probes `W`-windows — drift silences recognition. |
15
- | `junction.ts` + `WalkCache` | `src/mind/junction.ts` | Shared junction ascent (parents + containers) with bounded `√N·W` walk; `WalkCache` memoizes capped reads/parents/containers per response; bridge and attention share it. |
16
- | `joinWithBridge` | `src/mind/resonance.ts` | One out-of-search assembly: `bridge(left,right)` or bare concat with `bridgeMiss` trace. |
17
- | `dismissedKnownContent` | `src/mind/bridge.ts` | Pure attestation: any unaccounted `W`-window that resolves as known content — shared gap guard for substitution and CAST. |
18
- | `sharedReachMemo` | `src/mind/traverse.ts` | One response-scoped `AncestorReach` memo (cleared on write and for traces); every `reachOf`/`edgeAncestors` consumer shares it. |
19
- | `guidedFirst` | `src/mind/traverse.ts` | Guided-or-first answer bytes: `guidedNext` else first-inserted edge (`LIMIT 1`). |
20
- | `leadsSomewhere` | `src/mind/traverse.ts` | Admission predicate: `hasNext` (cached) or `hasHalo`; sites that lead nowhere contribute no derivation. |
21
- | `isChunk` | `src/sema.ts` | `kids !== null && kids.every(k=>k.kids===null)` — smallest grouped unit; governs regions, seams, indexing. |
22
- | `twoEndedSeat` | `src/sema.ts` | One seat algebra: first half low seats, second half high seats; shared by perception, `fold`, and canonical folds. |
10
+ | Symbol | Defined in | One fact |
11
+ | ------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12
+ | `contentLevels` | `src/geometry.ts` | Single boundary rule: cuts + levels from one rolling hash pass; every segmentation reads it. |
13
+ | `canonicalWindows` / `chainReach` / `leafIdRun` / `windowIds` | `src/mind/canonical.ts` | Write/read contract: training interns `W-1,W` windows, reading chains to `W²` and probes `W`-windows — drift silences recognition. |
14
+ | `junction.ts` + `WalkCache` | `src/mind/junction.ts` | Shared junction ascent (parents + containers) with bounded `√N·W` walk; `WalkCache` memoizes capped reads/parents/containers per response; bridge and attention share it. |
15
+ | `joinWithBridge` | `src/mind/resonance.ts` | One out-of-search assembly: `bridge(left,right)` or bare concat with `bridgeMiss` trace. |
16
+ | `dismissedKnownContent` | `src/mind/bridge.ts` | Pure attestation: any unaccounted `W`-window that resolves as known content — shared gap guard for substitution and CAST. |
17
+ | `sharedReachMemo` | `src/mind/traverse.ts` | One response-scoped `AncestorReach` memo (cleared on write and for traces); every `reachOf`/`edgeAncestors` consumer shares it. |
18
+ | `guidedFirst` | `src/mind/traverse.ts` | Guided-or-first answer bytes: `guidedNext` else first-inserted edge (`LIMIT 1`). |
19
+ | `leadsSomewhere` | `src/mind/traverse.ts` | Admission predicate: `hasNext` (cached) or `hasHalo`; sites that lead nowhere contribute no derivation. |
20
+ | `isChunk` | `src/sema.ts` | `kids !== null && kids.every(k=>k.kids===null)` — smallest grouped unit; governs regions, seams, indexing. |
21
+ | `twoEndedSeat` | `src/sema.ts` | One seat algebra: first half low seats, second half high seats; shared by perception, `fold`, and canonical folds. |
22
+ | `closed`/`admissible`/`advance` | `src/mind/derivation.ts` | One admission for every derivation step and the readings every tier asks. |
23
23
 
24
24
  ## Pins
25
25
 
@@ -16,7 +16,7 @@ functions over bytes and the store — no mechanism owns a private copy.
16
16
  | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
17
17
  | **Match** (locate structure) | `locate` (exact → halo → gist ladder), `alignRuns` (literal W-gram weave), `alignGraded` (literal + halo gaps), `alignAround` / `frameSlots` (seeded frame with contracted gaps), `bestHaloMate` (in-list halo), `analogyStrength` / `sharedFrameStrength` (distributional + structural analogy) | Finds where a query sits in a learnt form. |
18
18
  | **Project** (direction) | `follow` (forward to fixpoint, first hop may `conceptHop`), `reverseContext` (reverse to context), `project` (forward else reverse), `conceptHop` (halo sibling with edge) | Moves along the store from the match — forward toward answers, reverse toward contexts. |
19
- | **Gate** (structural licence) | `isSpanShaped` (sparse subsequence — open reading), `carriesFillers` (substitution carriage — strict voicing licence) | Decides whether the shape licences voicing. |
19
+ | **Gate** (structural licence) | `isSpanShaped` (OPEN reading — sparse subsequence), `containsSpan` (STRICT reading — contiguous run or resolved node), `skillExemplar` (anchor → context + answer), `carriesFillers` (substitution carriage — strict voicing licence) | Two readings; not interchangeable. |
20
20
 
21
21
  Mechanisms declare only `(matcher, direction, gate)`. Thresholds behind gates
22
22
  live in `src/geometry.ts` — the match layer never invents a cutoff.
@@ -52,8 +52,7 @@ The shared layer never refuses on a consumer's behalf. Reference owns its four
52
52
  gates: frame dominates the query, each slot reaches `W` on both sides, no
53
53
  insertion/deletion, fillers pairwise distinct — plus `carriesFillers` on the
54
54
  chosen pair. CAST, recall, and cover each apply their own gate over the same
55
- shared inventory. Moving a consumer's gate into `match.ts` would hide who is
56
- responsible for the refusal.
55
+ shared inventory. Moving a gate into `match.ts` would hide who owns the refusal.
57
56
 
58
57
  ## Pins
59
58
 
@@ -14,10 +14,11 @@ interface PipelineMechanism {
14
14
  }
15
15
  interface MechanismResult {
16
16
  bytes: Uint8Array;
17
- accounted: [number, number][];
17
+ accounted: Array<[number, number]>;
18
18
  moves: number;
19
- unexplained: string;
19
+ used?: ReadonlySet<number>;
20
20
  scaffolding?: number;
21
+ provenance?: string;
21
22
  complete?: boolean;
22
23
  }
23
24
  ```
@@ -30,7 +31,7 @@ interface MechanismResult {
30
31
 
31
32
  ## Decider
32
33
 
33
- `think` in `mind/pipeline.ts` iterates `defaultMechanisms` in list order:
34
+ `think` iterates `defaultMechanisms` in list order:
34
35
 
35
36
  ```
36
37
  defaultMechanisms = [cover, cast, confluence, extraction, reference, recall,
@@ -39,8 +40,7 @@ defaultMechanisms = [cover, cast, confluence, extraction, reference, recall,
39
40
 
40
41
  Weight is one currency: `weight = moves + PASS · unaccountedBytes` where
41
42
  `unaccountedBytes = unexplainedSpans(query.length, accounted)`. Comparison is at
42
- `STEP` grade (`grade = floor(weight/STEP)`); equal grade prefers fewer
43
- `scaffolding` bytes, then list order.
43
+ `STEP` grade ; equal grade prefers fewer `scaffolding` bytes, then list order.
44
44
 
45
45
  ## Four constraints
46
46
 
@@ -48,16 +48,16 @@ Weight is one currency: `weight = moves + PASS · unaccountedBytes` where
48
48
  never touches another; no mechanism asks what already decided.
49
49
  2. **Declared competence** — binary structural gates inside `floor`/`run` (query
50
50
  length, anchor shape, weave existence). Never a learned score; rationale
51
- states exactly why a mechanism abstained.
51
+ states why a mechanism abstained.
52
52
  3. **Visible budget** — every corpus-scale loop is capped at a named constant:
53
53
  `√N` via `hubBound`/`hubCap` and `k = 2·recallQueryK` (`Precomputed.k`).
54
- Enforced at the store level.
54
+ Enforced at the store.
55
55
  4. **Evidence travels** — every candidate carries `accounted` (query spans
56
- explained), `moves` (priced on `MICRO/STEP/CONCEPT/PASS`), `unexplained`
57
- (diagnostic label); optionally `scaffolding` (answer bytes from unrecognised
58
- spans — equal-grade tie-break) and `complete` (trained-form continuation
59
- reached via identity; post-grounding must not extend). The decider honours
60
- both without knowing who set them.
56
+ explained) and `moves` (priced on `MICRO/STEP/CONCEPT/PASS`); optionally
57
+ `scaffolding` (answer bytes from unrecognised spans — equal-grade tie-break),
58
+ `complete` (trained-form continuation reached via identity; post-grounding
59
+ must not extend) and `provenance`. The decider honours them without knowing
60
+ who set them.
61
61
 
62
62
  ## Two disciplines
63
63
 
@@ -70,8 +70,8 @@ Weight is one currency: `weight = moves + PASS · unaccountedBytes` where
70
70
  - **Investment discipline.** `worthRunning` is passed _into_ `floor`. A floor
71
71
  that would first-touch an expensive shared analysis (`pre.attention()` climb,
72
72
  `pre.weave()`, `pre.resonance()`) checks `worthRunning(cheapestBound)` first
73
- and returns the uninvested bound when it already loses. Never compute a shared
74
- analysis just to discard it. `cast.ts`/`extraction.ts` are the references.
73
+ and returns the uninvested bound if it loses. Never compute a shared analysis
74
+ just to discard it. `cast.ts`/`extraction.ts` are the references.
75
75
 
76
76
  ## Accounting
77
77
 
@@ -86,8 +86,8 @@ Weight is one currency: `weight = moves + PASS · unaccountedBytes` where
86
86
  same act is charged twice (`PASS`/byte dominates).
87
87
 
88
88
  `accounted` is a cost-ladder quantity; `cover.ts` leaves masked computed spans
89
- out of it so `PASS`-bridged bytes are still charged. `unexplained`,
90
- `narrowDecision`, `thinGrounding` are observational only.
89
+ out so `PASS`-bridged bytes are still charged. `narrowDecision` and
90
+ `thinGrounding` are observational only.
91
91
 
92
92
  ## Pins
93
93
 
@@ -11,17 +11,16 @@ it. Harness: `bench/profile-inference.mjs`.
11
11
  an ordering. Determinism survives only because the meter is observed, never
12
12
  consulted. Every call site is `meter?.x++` on a nullable field.
13
13
 
14
- 2. **Counters vs hints.** Counters are deterministic and diffable between runs;
15
- the same query on the same store meters identically, so a regression is
16
- visible in a diff. Millisecond fields (`elapsedMs`, per-phase `ms`) are
17
- non-deterministic hints reported separately — never use them to gate
18
- behaviour.
19
-
20
- 3. **Phases nest, they do not partition.** `think` contains every mechanism
21
- phase; a mechanism's `floor` contains whatever shared analysis it
22
- first-touched; `recall.run` contains `substitutionBridge`. Read a phase as
23
- inclusive wall-clock — never sum phases and expect the total.
24
- `CostReport.elapsedMs` is the only whole.
14
+ 2. **Counters vs hints.** Counters are exact and diffable: a regression shows in
15
+ a diff of two COLD runs; a repeated query meters less, as memos warm.
16
+ Millisecond fields (`elapsedMs`, per-phase `ms`) are non-deterministic hints
17
+ reported separately — never use them to gate behaviour.
18
+
19
+ 3. **Phases nest, they do not partition.** Each phase is charged by the layer
20
+ doing the work (`recognise`, the climb's two, the bridge), and a mechanism's
21
+ `floor` contains whatever shared analysis it first-touched. Read a phase as
22
+ inclusive wall-clock; never sum phases. `CostReport.elapsedMs` is the only
23
+ whole.
25
24
 
26
25
  4. **Count once.** Off by default and free when off
27
26
  (`new Mind({ profile:
@@ -36,9 +36,9 @@ root never costs a full walk.
36
36
 
37
37
  ## Gist, halo, dedup
38
38
 
39
- On `put*`, content dedup (`hashOf`→probe→mint) gates first. `DedupKey` caches
40
- short keys (`DEDUP_KEY_MAX` bypass). Near-dedup merges by `mergeThreshold(D)` on
41
- unit gist cosine. Gists sit in `_pendingGist` (byte-budgeted `BoundedMap`);
39
+ On `put*`, content dedup (`hashOf`→probe→mint) gates first. Short keys are
40
+ cached (`DEDUP_KEY_MAX` bypass). Near-dedup: `identityBar(D, W, len)`, one
41
+ window apart. Gists sit in `_pendingGist` (byte-budgeted `BoundedMap`);
42
42
  `indexSubtree` & `pourHalo` promote via `_vecContentUpsert`/`_vecHaloUpsert` in
43
43
  `batchSize` batches. Buffers flush on cadence, `commit()`, and close. Halo mass
44
44
  re-indexes geometrically (`mass<=4 || powerOfTwo`) and encodes 2-bit quantized.
@@ -55,7 +55,7 @@ deferred transaction.
55
55
  Every in-memory cache is a `BoundedMap` with byte accounting and eviction (`lru`
56
56
  vs `smallest` + `clock`/`reorder` recency). ANN reads
57
57
  (`resonate`/`resonateHalo`) are content-addressed (`vecKey`) and dropped on any
58
- index mutation; `RESonate_CACHE_MAX=4096`.
58
+ index mutation; `RESONATE_CACHE_MAX=4096`.
59
59
 
60
60
  ## Maintenance (incremental)
61
61
 
@@ -17,7 +17,7 @@ perception window), or `N` (corpus size). No threshold is tuned or added to
17
17
 
18
18
  | Symbol | Definition | Formula |
19
19
  | ----------------------- | ---------------------------------------------------------------------------- | ----------------------------------- |
20
- | `mergeThreshold(D)` | Store identity bar — cosine at which `intern` treats two gists as same node | `1 - 1/√D` |
20
+ | `mergeThreshold(D)` | Cosine below which two gists are near enough to consider merging | `1 - 1/√D` |
21
21
  | `identityBar(D,W,len)` | Scale-aware whole-span identity claim | `max(mergeThreshold(D), 1 - W/len)` |
22
22
  | `reachThreshold(W)` | Recall confidence floor — half a river quantum | `1 - 1/(2·W)` |
23
23
  | `estimatorNoise(D)` | RaBitQ noise floor — 1σ of random cosine | `1/√D` |