@hviana/sema 0.8.3 → 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.
- package/AGENTS.md +11 -10
- package/README.md +17 -38
- package/dist/example/demo.js +85 -34
- package/dist/src/geometry.d.ts +0 -10
- package/dist/src/geometry.js +0 -12
- package/dist/src/meter.d.ts +11 -0
- package/dist/src/meter.js +11 -0
- package/dist/src/mind/articulation.js +1 -1
- package/dist/src/mind/attention.js +2 -1
- package/dist/src/mind/derivation.d.ts +201 -0
- package/dist/src/mind/derivation.js +327 -0
- package/dist/src/mind/graph-search.d.ts +2 -1
- package/dist/src/mind/graph-search.js +37 -15
- package/dist/src/mind/match.d.ts +2 -0
- package/dist/src/mind/match.js +2 -0
- package/dist/src/mind/mechanisms/alu.js +0 -2
- package/dist/src/mind/mechanisms/cast.d.ts +1 -5
- package/dist/src/mind/mechanisms/cast.js +15 -18
- package/dist/src/mind/mechanisms/confluence.d.ts +0 -3
- package/dist/src/mind/mechanisms/confluence.js +3 -9
- package/dist/src/mind/mechanisms/cover.js +17 -20
- package/dist/src/mind/mechanisms/extraction.d.ts +0 -1
- package/dist/src/mind/mechanisms/extraction.js +13 -8
- package/dist/src/mind/mechanisms/prefix-completion.js +0 -1
- package/dist/src/mind/mechanisms/recall.d.ts +0 -1
- package/dist/src/mind/mechanisms/recall.js +8 -9
- package/dist/src/mind/mechanisms/reference.js +3 -4
- package/dist/src/mind/pipeline-mechanism.d.ts +1 -4
- package/dist/src/mind/pipeline.js +106 -41
- package/dist/src/mind/rationale.d.ts +0 -11
- package/dist/src/mind/rationale.js +6 -32
- package/dist/src/mind/reasoning.d.ts +4 -30
- package/dist/src/mind/reasoning.js +183 -151
- package/dist/src/mind/types.js +6 -3
- package/docs/INDEX.md +23 -24
- package/docs/INVARIANTS.md +16 -17
- package/docs/architecture/bounded-reads.md +4 -4
- package/docs/architecture/closure.md +65 -0
- package/docs/architecture/commonality.md +27 -18
- package/docs/architecture/cost-model.md +5 -5
- package/docs/architecture/exact-vs-approximate.md +4 -4
- package/docs/architecture/factored-machinery.md +14 -14
- package/docs/architecture/mechanism-market.md +9 -9
- package/docs/architecture/meter.md +4 -5
- package/docs/architecture/store.md +2 -2
- package/docs/architecture/thresholds.md +1 -1
- package/docs/failures/tempting-but-wrong.md +11 -1
- package/docs/harness/gates.md +6 -6
- package/docs/mechanisms/cover.md +2 -2
- package/example/demo.ts +90 -37
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/geometry.ts +0 -13
- package/src/meter.ts +11 -0
- package/src/mind/articulation.ts +0 -1
- package/src/mind/attention.ts +2 -1
- package/src/mind/derivation.ts +473 -0
- package/src/mind/graph-search.ts +37 -20
- package/src/mind/match.ts +2 -0
- package/src/mind/mechanisms/alu.ts +0 -2
- package/src/mind/mechanisms/cast.ts +17 -21
- package/src/mind/mechanisms/confluence.ts +3 -13
- package/src/mind/mechanisms/cover.ts +17 -20
- package/src/mind/mechanisms/extraction.ts +13 -9
- package/src/mind/mechanisms/prefix-completion.ts +0 -1
- package/src/mind/mechanisms/recall.ts +7 -9
- package/src/mind/mechanisms/reference.ts +2 -3
- package/src/mind/pipeline-mechanism.ts +1 -4
- package/src/mind/pipeline.ts +121 -46
- package/src/mind/rationale.ts +6 -36
- package/src/mind/reasoning.ts +208 -178
- package/src/mind/types.ts +5 -2
- package/test/133-the-decision-point-renders-the-state.test.mjs +204 -0
- package/test/134-the-law-explains-the-engines-own-refusal.test.mjs +237 -0
- package/test/135-one-law-any-producer.test.mjs +289 -0
- package/test/136-the-two-named-limits.test.mjs +205 -0
- package/test/137-the-law-lives-once-and-below.test.mjs +400 -0
- package/test/138-the-remainder-drains-only-what-a-move-declares.test.mjs +62 -0
- package/test/139-the-witness-is-engagement-not-explanation.test.mjs +51 -0
- package/test/140-irrelevant-supply-does-not-change-an-answer.test.mjs +48 -0
- package/test/141-the-question-is-paid-at-construction.test.mjs +98 -0
- package/test/36-already-answered-fusion.test.mjs +20 -2
- package/test/37-cluster-dispersion-fusion.test.mjs +30 -3
- package/test/38-reason-restate-guard.test.mjs +22 -2
- package/test/55-cost-meter.test.mjs +4 -1
|
@@ -94,7 +94,16 @@ test("fuseAttention: a root whose continuation is already answered in the query
|
|
|
94
94
|
}),
|
|
95
95
|
guide,
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
// fusion consumes and returns the derivation STATE; these cases exercise the
|
|
98
|
+
// mechanism's own gates, so the state is the minimum one for them.
|
|
99
|
+
const out = dec(
|
|
100
|
+
(await fuseAttention(m, q, {
|
|
101
|
+
product: primary,
|
|
102
|
+
accounted: [],
|
|
103
|
+
remainder: [],
|
|
104
|
+
cost: 0,
|
|
105
|
+
}, pre)).product,
|
|
106
|
+
);
|
|
98
107
|
assert.ok(
|
|
99
108
|
!out.includes("reply-greet"),
|
|
100
109
|
`a root whose continuation is already answered in the query must not fuse in, got "${out}"`,
|
|
@@ -126,7 +135,16 @@ test("fuseAttention: ordinary multi-topic fusion (no embedded answers) is comple
|
|
|
126
135
|
}),
|
|
127
136
|
guide,
|
|
128
137
|
};
|
|
129
|
-
|
|
138
|
+
// fusion consumes and returns the derivation STATE; these cases exercise the
|
|
139
|
+
// mechanism's own gates, so the state is the minimum one for them.
|
|
140
|
+
const out = dec(
|
|
141
|
+
(await fuseAttention(m, q, {
|
|
142
|
+
product: primary,
|
|
143
|
+
accounted: [],
|
|
144
|
+
remainder: [],
|
|
145
|
+
cost: 0,
|
|
146
|
+
}, pre)).product,
|
|
147
|
+
);
|
|
130
148
|
assert.ok(
|
|
131
149
|
out.includes("answer alpha"),
|
|
132
150
|
`an ordinary further topic must still fuse in, got "${out}"`,
|
|
@@ -127,7 +127,16 @@ test("fuseAttention: 2 clusters, low breadth — dispersion alone is enough (gap
|
|
|
127
127
|
}),
|
|
128
128
|
guide,
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
// fusion consumes and returns the derivation STATE; these cases exercise the
|
|
131
|
+
// mechanism's own gates, so the state is the minimum one for them.
|
|
132
|
+
const out = dec(
|
|
133
|
+
(await fuseAttention(m, q, {
|
|
134
|
+
product: primary,
|
|
135
|
+
accounted: [],
|
|
136
|
+
remainder: [],
|
|
137
|
+
cost: 0,
|
|
138
|
+
}, pre)).product,
|
|
139
|
+
);
|
|
131
140
|
assert.equal(
|
|
132
141
|
out,
|
|
133
142
|
"answer alpha" + dec(primary),
|
|
@@ -154,7 +163,16 @@ test("fuseAttention: 1 cluster, dominant breadth — dominance alone is enough (
|
|
|
154
163
|
}),
|
|
155
164
|
guide,
|
|
156
165
|
};
|
|
157
|
-
|
|
166
|
+
// fusion consumes and returns the derivation STATE; these cases exercise the
|
|
167
|
+
// mechanism's own gates, so the state is the minimum one for them.
|
|
168
|
+
const out = dec(
|
|
169
|
+
(await fuseAttention(m, q, {
|
|
170
|
+
product: primary,
|
|
171
|
+
accounted: [],
|
|
172
|
+
remainder: [],
|
|
173
|
+
cost: 0,
|
|
174
|
+
}, pre)).product,
|
|
175
|
+
);
|
|
158
176
|
assert.equal(
|
|
159
177
|
out,
|
|
160
178
|
"answer alpha" + dec(primary),
|
|
@@ -180,7 +198,16 @@ test("fuseAttention: 1 cluster, low breadth — neither measure saves it (the li
|
|
|
180
198
|
}),
|
|
181
199
|
guide,
|
|
182
200
|
};
|
|
183
|
-
|
|
201
|
+
// fusion consumes and returns the derivation STATE; these cases exercise the
|
|
202
|
+
// mechanism's own gates, so the state is the minimum one for them.
|
|
203
|
+
const out = dec(
|
|
204
|
+
(await fuseAttention(m, q, {
|
|
205
|
+
product: primary,
|
|
206
|
+
accounted: [],
|
|
207
|
+
remainder: [],
|
|
208
|
+
cost: 0,
|
|
209
|
+
}, pre)).product,
|
|
210
|
+
);
|
|
184
211
|
assert.equal(
|
|
185
212
|
out,
|
|
186
213
|
dec(primary),
|
|
@@ -60,7 +60,17 @@ test("reason(): a forward hop landing on bytes already present in the query is r
|
|
|
60
60
|
// `reason()` reports the WHOLE extension (bytes + what it carried + how many
|
|
61
61
|
// steps) so a caller can price it; these assertions measure the bytes, and
|
|
62
62
|
// that is all this change touches — the law they pin is untouched.
|
|
63
|
-
|
|
63
|
+
// `reason()` now consumes and returns the derivation STATE; with no remainder
|
|
64
|
+
// the derivation is CLOSED, so the law admits any contained continuation —
|
|
65
|
+
// which is exactly what these two cases exercise. The assertions below are
|
|
66
|
+
// untouched.
|
|
67
|
+
const state = {
|
|
68
|
+
product: answer,
|
|
69
|
+
accounted: [],
|
|
70
|
+
remainder: [],
|
|
71
|
+
cost: 0,
|
|
72
|
+
};
|
|
73
|
+
const out = (await reason(m, query, state, new Set(), pre)).product;
|
|
64
74
|
assert.equal(
|
|
65
75
|
dec(out),
|
|
66
76
|
"bridge context",
|
|
@@ -88,7 +98,17 @@ test("reason(): an ordinary forward hop onto genuinely new content is unaffected
|
|
|
88
98
|
// `reason()` reports the WHOLE extension (bytes + what it carried + how many
|
|
89
99
|
// steps) so a caller can price it; these assertions measure the bytes, and
|
|
90
100
|
// that is all this change touches — the law they pin is untouched.
|
|
91
|
-
|
|
101
|
+
// `reason()` now consumes and returns the derivation STATE; with no remainder
|
|
102
|
+
// the derivation is CLOSED, so the law admits any contained continuation —
|
|
103
|
+
// which is exactly what these two cases exercise. The assertions below are
|
|
104
|
+
// untouched.
|
|
105
|
+
const state = {
|
|
106
|
+
product: answer,
|
|
107
|
+
accounted: [],
|
|
108
|
+
remainder: [],
|
|
109
|
+
cost: 0,
|
|
110
|
+
};
|
|
111
|
+
const out = (await reason(m, query, state, new Set(), pre)).product;
|
|
92
112
|
assert.equal(
|
|
93
113
|
dec(out),
|
|
94
114
|
"a wholly new fact never mentioned in any query",
|
|
@@ -949,8 +949,11 @@ test("21. the price's second term has one definition, and it is the complement",
|
|
|
949
949
|
// Since the value did NOT change, the lot is only pinned if something would
|
|
950
950
|
// fail when the helper sums the wrong thing — so this test uses an input where
|
|
951
951
|
// the two candidate readings DIFFER.
|
|
952
|
+
// PATH ONLY: the span algebra moved to the closure law's home
|
|
953
|
+
// (src/mind/derivation.ts) when the law was extracted; the assertions below
|
|
954
|
+
// are untouched and still pin the same contract.
|
|
952
955
|
const { unexplainedSpans, unaccountedBytes } = await import(
|
|
953
|
-
"../dist/src/mind/
|
|
956
|
+
"../dist/src/mind/derivation.js"
|
|
954
957
|
);
|
|
955
958
|
// Empty accounted ⇒ the whole query is unaccounted.
|
|
956
959
|
assert.equal(unaccountedBytes(unexplainedSpans(10, [])), 10);
|