@hviana/sema 0.9.1 → 0.9.3
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/dist/src/meter.d.ts +19 -0
- package/dist/src/meter.js +19 -0
- package/dist/src/mind/evidence.d.ts +30 -0
- package/dist/src/mind/evidence.js +102 -0
- package/dist/src/mind/mechanisms/cast.d.ts +1 -1
- package/dist/src/mind/mechanisms/cast.js +73 -12
- package/dist/src/mind/mechanisms/cover.js +25 -3
- package/dist/src/mind/mechanisms/recall.js +93 -9
- package/dist/src/mind/mechanisms/reference.js +25 -0
- package/dist/src/mind/mind.d.ts +7 -0
- package/dist/src/mind/mind.js +3 -0
- package/dist/src/mind/pipeline-mechanism.js +15 -1
- package/dist/src/mind/pipeline.js +51 -8
- package/dist/src/mind/reasoning.js +65 -18
- package/dist/src/mind/resonance.d.ts +3 -2
- package/dist/src/mind/resonance.js +3 -2
- package/dist/src/mind/traverse.d.ts +94 -2
- package/dist/src/mind/traverse.js +611 -7
- package/dist/src/mind/types.d.ts +12 -0
- package/docs/INDEX.md +18 -17
- package/docs/INVARIANTS.md +1 -0
- package/docs/architecture/evidence.md +256 -0
- package/docs/architecture/exact-vs-approximate.md +10 -9
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/meter.ts +19 -0
- package/src/mind/evidence.ts +125 -0
- package/src/mind/mechanisms/cast.ts +77 -3
- package/src/mind/mechanisms/cover.ts +42 -3
- package/src/mind/mechanisms/recall.ts +123 -11
- package/src/mind/mechanisms/reference.ts +24 -1
- package/src/mind/mind.ts +6 -0
- package/src/mind/pipeline-mechanism.ts +15 -1
- package/src/mind/pipeline.ts +64 -8
- package/src/mind/reasoning.ts +82 -17
- package/src/mind/resonance.ts +3 -2
- package/src/mind/traverse.ts +652 -7
- package/src/mind/types.ts +10 -0
- package/test/154-the-question-names-the-step.test.mjs +368 -0
- package/test/155-the-relation-read-off-another-instance.test.mjs +376 -0
- package/test/29-counterfactual.test.mjs +21 -11
- package/test/76-reference-binding.test.mjs +32 -0
package/src/mind/reasoning.ts
CHANGED
|
@@ -8,10 +8,18 @@ import { bytesEqual, indexOf, latin1 } from "../bytes.js";
|
|
|
8
8
|
import type { Attention, MindContext } from "./types.js";
|
|
9
9
|
import { read, resolve } from "./primitives.js";
|
|
10
10
|
import { countClusters } from "./attention.js";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
coInstanceFiller,
|
|
13
|
+
guidedFirst,
|
|
14
|
+
hubBound,
|
|
15
|
+
namedContinuations,
|
|
16
|
+
offsetCanon,
|
|
17
|
+
} from "./traverse.js";
|
|
18
|
+
import { unspoken, type WindowIndex, windowIndex } from "./evidence.js";
|
|
12
19
|
import { containsSpan, follow, haloSiblings, project } from "./match.js";
|
|
13
20
|
import { joinWithBridge, pivotInto } from "./resonance.js";
|
|
14
21
|
import {
|
|
22
|
+
closed,
|
|
15
23
|
closeOver,
|
|
16
24
|
type ClosureLayer,
|
|
17
25
|
type Continuation,
|
|
@@ -102,6 +110,12 @@ export function walkLayer(
|
|
|
102
110
|
// fire — the same visibility trade chooseNext documents.
|
|
103
111
|
const bound = hubBound(ctx);
|
|
104
112
|
const consumed = new Set<number>();
|
|
113
|
+
/** The windows each product of this derivation holds — what of the question
|
|
114
|
+
* the derivation has already restated, so a later step is NAMED only by
|
|
115
|
+
* question material none of them said. */
|
|
116
|
+
const spoken: WindowIndex[] = [];
|
|
117
|
+
const speak = (product: Uint8Array) =>
|
|
118
|
+
spoken.push(windowIndex(offsetCanon(ctx, product), ctx.space.maxGroup));
|
|
105
119
|
/** `prev` lets a caller hand in an already-read reverse-edge list — hop 0
|
|
106
120
|
* reuses the guard's, below, instead of re-reading it. */
|
|
107
121
|
const consumeNode = (
|
|
@@ -122,6 +136,7 @@ export function walkLayer(
|
|
|
122
136
|
const begin = async (d0: DerivationState): Promise<boolean> => {
|
|
123
137
|
const answer = d0.product;
|
|
124
138
|
startedFrom = answer;
|
|
139
|
+
speak(answer);
|
|
125
140
|
// Echo guard: a query that is ITSELF a learnt continuation (some context's
|
|
126
141
|
// answer) is being asked back at the system — hopping forward from it would
|
|
127
142
|
// chain through the very fact that produced it and echo the conversation
|
|
@@ -241,16 +256,12 @@ export function walkLayer(
|
|
|
241
256
|
// 30 s); and raising it from 12 to 200 changed neither the answer nor
|
|
242
257
|
// `pivotSteps` on the chain fixtures.
|
|
243
258
|
const qv = pre.guide; // the response-wide guide IS the query's gist
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
//
|
|
247
|
-
//
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
// voiced seat and leads on to a fact about neither analog), which the law
|
|
251
|
-
// expresses as the identity species of progress — `moves` — declared by the
|
|
252
|
-
// reporter and never inferred from the mechanism's name.
|
|
253
|
-
const producerOwnsShape = voiced.length > 0;
|
|
259
|
+
// NO PRODUCER OWNS THE NEXT STEP. A grounding that declared what it voiced
|
|
260
|
+
// (cast/join) used to MOVE through any further term inside its answer,
|
|
261
|
+
// unasked — `Who is the director of The Jerk?` grounded by CAST walked on to
|
|
262
|
+
// `The country of citizenship of Carl Reiner is American.` What it voiced
|
|
263
|
+
// still bounds what may be pivoted through (`voiced`, pivotInto); whether a
|
|
264
|
+
// step is taken is the naming rule below, the same for every mechanism.
|
|
254
265
|
let hop = 0;
|
|
255
266
|
let t: ReturnType<Rationale["enter"]> | undefined;
|
|
256
267
|
// WHAT THE OFFERED STEP WOULD BE. The law decides, so the accepted step is
|
|
@@ -402,16 +413,47 @@ export function walkLayer(
|
|
|
402
413
|
);
|
|
403
414
|
return null;
|
|
404
415
|
}
|
|
416
|
+
// THE STEP THE QUESTION ASKS FOR. The hop `follow` took is NAMED when one
|
|
417
|
+
// of its establishing contexts is witnessed by what of the question no
|
|
418
|
+
// product has restated yet, plus the pivot itself (traverse.ts,
|
|
419
|
+
// `namedContinuations`): `Where was the place of death of the director of
|
|
420
|
+
// film Beat Girl?` names `Edmond T. Gréville place of death` once the first
|
|
421
|
+
// hop has restated `director` and `Beat Girl` — and `Who is the father of
|
|
422
|
+
// Frederick II?` names nothing past `Peter III of Aragon`, because `father`
|
|
423
|
+
// was restated by the hop that reached him. A named step MOVES to structure
|
|
424
|
+
// the question asked for, so it is admitted on that ground; an unnamed one
|
|
425
|
+
// must carry the question's remainder as before, and from a CLOSED
|
|
426
|
+
// derivation — nothing left owed — it is not offered at all: the question
|
|
427
|
+
// asks for no further step, and the law would otherwise admit any.
|
|
428
|
+
const asked = ctx._edgeAsked;
|
|
429
|
+
let named = false;
|
|
430
|
+
if (asked !== null) {
|
|
431
|
+
const unsaid = {
|
|
432
|
+
bytes: asked.bytes,
|
|
433
|
+
index: unspoken(asked.index, spoken),
|
|
434
|
+
};
|
|
435
|
+
const names = namedContinuations(ctx, pivot, unsaid);
|
|
436
|
+
const hop = guidedFirst(ctx, pivot);
|
|
437
|
+
named = names !== null && hop !== undefined && names.includes(hop);
|
|
438
|
+
}
|
|
439
|
+
if (!named && closed(d)) {
|
|
440
|
+
ctx.trace?.step(
|
|
441
|
+
"pivotUnasked",
|
|
442
|
+
[rItem(cur, "answer"), rNode(ctx, pivot, "pivot")],
|
|
443
|
+
[rItem(fc, "withheld")],
|
|
444
|
+
"the derivation owes nothing and the question names no further step — not offered",
|
|
445
|
+
);
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
405
448
|
pending = { kind: "pivot", cur, pivot, fc };
|
|
406
|
-
// Offered with the identity species
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
//
|
|
410
|
-
// test.
|
|
449
|
+
// Offered with the identity species when the question names the step;
|
|
450
|
+
// otherwise the law requires this step to carry question material the grounding left
|
|
451
|
+
// unaccounted, which is the drift the extension tests pin — refused by the
|
|
452
|
+
// law's own measure, not by a private window test.
|
|
411
453
|
return {
|
|
412
454
|
product: fc,
|
|
413
455
|
contains: true,
|
|
414
|
-
reaches:
|
|
456
|
+
reaches: named,
|
|
415
457
|
cost: STEP,
|
|
416
458
|
};
|
|
417
459
|
};
|
|
@@ -422,6 +464,7 @@ export function walkLayer(
|
|
|
422
464
|
witnesses: ReadonlyArray<Witness>,
|
|
423
465
|
): void => {
|
|
424
466
|
meterTransition(ctx, before, after, witnesses);
|
|
467
|
+
speak(after.product);
|
|
425
468
|
const p = pending;
|
|
426
469
|
pending = null;
|
|
427
470
|
if (p === null) return;
|
|
@@ -786,6 +829,28 @@ export function fusionLayer(
|
|
|
786
829
|
// again would only restate it. Deliberately NOT a magnitude measure:
|
|
787
830
|
// it fires on exact content-addressed recurrence, not on how strongly
|
|
788
831
|
// the root resonates.
|
|
832
|
+
// ANOTHER INSTANCE IS NOT ANOTHER TOPIC. A root the question witnesses
|
|
833
|
+
// in every byte but one contiguous span is the question's own frame
|
|
834
|
+
// around a different filler (evidence.ts, `coInstanceFiller`): the climb
|
|
835
|
+
// committed `Where was Peter Jackson born?` as a second point of
|
|
836
|
+
// `Where was the director of film Beat Girl born?` on the frame windows
|
|
837
|
+
// alone, and fusing it voiced Peter Jackson's birthplace beside the
|
|
838
|
+
// answer. Such a root says what the question's relation IS (traverse.ts,
|
|
839
|
+
// `byCoInstance`), never what it asks about.
|
|
840
|
+
const asked = ctx._edgeAsked;
|
|
841
|
+
if (asked !== null) {
|
|
842
|
+
const form = read(ctx, root.anchor, 2 * query.length);
|
|
843
|
+
const co = coInstanceFiller(ctx, form, [asked.index], asked.bytes);
|
|
844
|
+
if (co !== null) {
|
|
845
|
+
ctx.trace?.step(
|
|
846
|
+
"coInstanceRoot",
|
|
847
|
+
[rNode(ctx, root.anchor, "point", root.vote)],
|
|
848
|
+
[rItem(form.subarray(co.span[0], co.span[1]), "filler")],
|
|
849
|
+
"the question witnesses this point in every byte but one filler of its own — another instance of the question's frame, not a further topic",
|
|
850
|
+
);
|
|
851
|
+
continue;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
789
854
|
const cont = await follow(ctx, root.anchor, qv);
|
|
790
855
|
if (
|
|
791
856
|
cont !== null && cont.length > 0 &&
|
package/src/mind/resonance.ts
CHANGED
|
@@ -307,8 +307,9 @@ export async function joinWithBridge(
|
|
|
307
307
|
* Shakespeare" (id 676) and the pivot hopped through "speare" (id 606, not
|
|
308
308
|
* in `consumed`) straight into that analog's own biography, which is exactly
|
|
309
309
|
* what the comparison had refused to voice. The rule is CONTAINMENT, not
|
|
310
|
-
* overlap, so C3's
|
|
311
|
-
*
|
|
310
|
+
* overlap, so C3's further term — "Mona Lisa", inside the seat sentence but
|
|
311
|
+
* part of NEITHER analog — stays a candidate; whether the walk steps through
|
|
312
|
+
* it is the naming rule's decision (reasoning.ts, evidence.md). */
|
|
312
313
|
export async function pivotInto(
|
|
313
314
|
ctx: MindContext,
|
|
314
315
|
answer: Uint8Array,
|