@polycode-projects/the-mechanical-code-talker 6.0.18 → 6.0.20
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/README.md +20 -23
- package/bin/tmct.mjs +16 -33
- package/corpus/LICENSES.json +0 -21
- package/corpus/README.md +10 -13
- package/corpus/reference/manifest.json +19 -19
- package/corpus/reference/shards/ref-01.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-04.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-08.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-10.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-11.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-17.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-20.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-25.jsonl.gz +0 -0
- package/corpus/reference/shards/ref-2c.jsonl.gz +0 -0
- package/corpus/tier2/generate.mjs +6 -142
- package/corpus/tier2/manifest.json +0 -42
- package/package.json +6 -4
- package/src/adapters/corpus/child-seed.mjs +74 -0
- package/src/adapters/corpus/conceptnet.mjs +45 -26
- package/src/adapters/corpus/research-source.mjs +6 -2
- package/src/adapters/corpus/wikidata-live.mjs +92 -51
- package/src/adapters/memory/blocks.mjs +7 -1
- package/src/adapters/memory/core.mjs +505 -107
- package/src/adapters/memory/corpus-bands.mjs +27 -10
- package/src/adapters/memory/inspect.mjs +24 -5
- package/src/adapters/memory/rows.mjs +359 -30
- package/src/adapters/memory/shacl.mjs +10 -3
- package/src/domain/ask.mjs +27 -10
- package/src/domain/cli-verbs.mjs +3 -4
- package/src/domain/completions/group.mjs +8 -3
- package/src/domain/completions/infer.mjs +7 -2
- package/src/domain/completions/prune.mjs +5 -1
- package/src/domain/completions/rank.mjs +7 -2
- package/src/domain/digest/compose.mjs +5 -1
- package/src/domain/digest/select.mjs +12 -6
- package/src/domain/domain.mjs +15 -8
- package/src/domain/el-classify.mjs +11 -2
- package/src/domain/fact-phrase.mjs +86 -4
- package/src/domain/hash.mjs +9 -0
- package/src/domain/memory/bias.mjs +8 -4
- package/src/domain/memory/capability.mjs +12 -6
- package/src/domain/memory/fact-order.mjs +29 -0
- package/src/domain/memory/resolution.mjs +3 -0
- package/src/domain/news-feed.mjs +862 -92
- package/src/domain/reference-pack.mjs +5 -0
- package/src/domain/sense-gate.mjs +220 -0
- package/src/domain/sense-scope.mjs +116 -0
- package/src/domain/sense-split.mjs +1 -1
- package/src/domain/syllogise.mjs +60 -21
- package/src/domain/tableau.mjs +23 -14
- package/src/domain/term-ledger.mjs +16 -1
- package/src/domain/worlds-pack.mjs +5 -1
- package/src/services/adventure-autoplay.mjs +6 -1
- package/src/services/adventure-editor.mjs +43 -21
- package/src/services/adventure-viz.mjs +26 -9
- package/src/services/adventure.mjs +40 -10
- package/src/services/chat.mjs +270 -125
- package/src/services/extensions.mjs +51 -58
- package/src/services/extract-facts.mjs +906 -66
- package/src/services/init.mjs +4 -4
- package/src/services/ledger-viz.mjs +9 -4
- package/src/services/memory-panel-viz.mjs +4 -5
- package/src/services/mud-editor.mjs +40 -16
- package/src/services/mud-viz.mjs +8 -2
- package/src/services/mudiii-turn.mjs +5 -3
- package/src/services/mudiii-viz.mjs +8 -2
- package/src/services/news.mjs +306 -21
- package/src/services/research-viz.mjs +1 -1
- package/src/services/sprite-catalog-viz.mjs +10 -5
- package/src/surfaces/web/adventure-browser-entry.mjs +6 -12
- package/src/surfaces/web/memory-ask-browser.bundle.js +152 -151
- package/src/surfaces/web/mud-browser-entry.mjs +7 -11
- package/src/surfaces/web/research-browser-entry.mjs +5 -2
- package/corpus/tier2/aws.jsonl +0 -39
- package/corpus/tier2/java.jsonl +0 -31
- package/corpus/tier2/python.jsonl +0 -30
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
// Pure and import-free of core.mjs, exactly like trust.mjs beside it.
|
|
20
20
|
|
|
21
21
|
import { findIsaChain, buildSubClassSuccessors, SUBCLASS_PREDICATE, TYPE_PREDICATE } from "../syllogise.mjs";
|
|
22
|
+
import { compareFactsByContent } from "./fact-order.mjs";
|
|
22
23
|
|
|
23
24
|
/** The negative-polarity CURIE prefix. A separate prefix, never an
|
|
24
25
|
* "mgx:not-<lemma>" mint: fact-phrase.mjs's predicatePhrase reads "mgx:not-fly" as
|
|
@@ -74,7 +75,7 @@ export const NEG_CAPABLE_OF_PREDICATE = negatedPredicate(CAPABLE_OF_PREDICATE);
|
|
|
74
75
|
* order it lists them in. One constant each, in one place, so the verbosity of
|
|
75
76
|
* every case-4 answer is tuned by editing two lines. */
|
|
76
77
|
export const CAPABILITY_REPORT_CAP = 6;
|
|
77
|
-
const byTrustThenName = (a, b) => (b.trust || 0) - (a.trust || 0) ||
|
|
78
|
+
const byTrustThenName = (a, b) => (b.trust || 0) - (a.trust || 0) || compareFactsByContent(a, b);
|
|
78
79
|
|
|
79
80
|
const asSet = (v) => (v instanceof Set ? v : new Set(Array.isArray(v) ? v : [v]));
|
|
80
81
|
|
|
@@ -155,7 +156,9 @@ export function resolveCapabilityPolarity(subject, object, facts, { maxHops = 3
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
// hop count first, trust only within a rank — the whole point of the design
|
|
158
|
-
candidates.sort((a, b) => a.hops - b.hops
|
|
159
|
+
candidates.sort((a, b) => a.hops - b.hops
|
|
160
|
+
|| (b.fact.trust || 0) - (a.fact.trust || 0)
|
|
161
|
+
|| compareFactsByContent(a.fact, b.fact));
|
|
159
162
|
const hops = candidates[0].hops;
|
|
160
163
|
const winning = candidates.filter((c) => c.hops === hops);
|
|
161
164
|
const positive = winning.filter((c) => c.polarity === "positive").map((c) => c.fact);
|
|
@@ -198,19 +201,22 @@ export function capabilityBaseRate(subject, object, facts, { maxHops = 3 } = {})
|
|
|
198
201
|
const rows = Array.isArray(facts) ? facts : [];
|
|
199
202
|
const isaRows = rows.filter((f) => f.predicate === SUBCLASS_PREDICATE || f.predicate === TYPE_PREDICATE);
|
|
200
203
|
|
|
201
|
-
|
|
204
|
+
// The class the whole report is about, so it cannot come from whichever
|
|
205
|
+
// parent row happened to be stored first.
|
|
206
|
+
const parents = isaRows.filter((f) => subjects.has(f.subject)).sort(compareFactsByContent).map((f) => f.object);
|
|
202
207
|
if (!parents.length) return null;
|
|
203
208
|
const klass = parents[0];
|
|
204
209
|
|
|
205
210
|
const siblings = [...new Set(
|
|
206
|
-
isaRows.filter((f) => f.object === klass && !subjects.has(f.subject))
|
|
211
|
+
isaRows.filter((f) => f.object === klass && !subjects.has(f.subject))
|
|
212
|
+
.sort(compareFactsByContent).map((f) => f.subject),
|
|
207
213
|
)];
|
|
208
214
|
|
|
209
215
|
const capabilityOf = (name) => {
|
|
210
|
-
const hit = rows.
|
|
216
|
+
const hit = rows.filter(
|
|
211
217
|
(f) => f.subject === name && objects.has(f.object)
|
|
212
218
|
&& (f.predicate === CAPABLE_OF_PREDICATE || f.predicate === NEG_CAPABLE_OF_PREDICATE),
|
|
213
|
-
);
|
|
219
|
+
).sort(compareFactsByContent)[0];
|
|
214
220
|
if (!hit) return { name, polarity: "unknown", fact: null };
|
|
215
221
|
return { name, polarity: hit.predicate === NEG_CAPABLE_OF_PREDICATE ? "negative" : "positive", fact: hit };
|
|
216
222
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// memory/fact-order.mjs — the order a fact listing falls back to once ranking
|
|
2
|
+
// runs out of things to say. Every rank over fact rows (bias, trust, relevance)
|
|
3
|
+
// ends in ties, and a stable sort settles a tie by array index, which is
|
|
4
|
+
// arrival order: two peers holding one fact set then render the same facts on
|
|
5
|
+
// different lines.
|
|
6
|
+
//
|
|
7
|
+
// The tiebreak here is a pure function of the fact's own content — the same
|
|
8
|
+
// (subject, predicate, object) triple hash.mjs content-addresses a Fact by,
|
|
9
|
+
// plus the provenance that separates two sources asserting one triple. NUL
|
|
10
|
+
// delimits the parts for hash.mjs's reason: it never occurs inside a
|
|
11
|
+
// normalized term or predicate, so "a b|c" and "a|b c" cannot collide on one
|
|
12
|
+
// key. Codepoint order throughout, never localeCompare — two locales have to
|
|
13
|
+
// land on the same order.
|
|
14
|
+
//
|
|
15
|
+
// The store's own precedent is p2p-room.mjs's sortFactIndividualsById, which
|
|
16
|
+
// sorts Fact individuals by content-addressed id after every merge for exactly
|
|
17
|
+
// this reason. This is that discipline carried through to the read side.
|
|
18
|
+
|
|
19
|
+
/** A fact row's content-derived sort key. */
|
|
20
|
+
export const factOrderKey = (f) => [
|
|
21
|
+
f?.subject ?? "", f?.predicate ?? "", f?.object ?? "", f?.provenance ?? "",
|
|
22
|
+
].join("\0");
|
|
23
|
+
|
|
24
|
+
/** Order two fact rows by content. The last comparison in any fact ranking. */
|
|
25
|
+
export function compareFactsByContent(a, b) {
|
|
26
|
+
const ka = factOrderKey(a);
|
|
27
|
+
const kb = factOrderKey(b);
|
|
28
|
+
return ka < kb ? -1 : ka > kb ? 1 : 0;
|
|
29
|
+
}
|
|
@@ -44,6 +44,9 @@ const MERGE_PREDICATE_STEMS = [
|
|
|
44
44
|
"mgx:createdBy",
|
|
45
45
|
"mgx:mannerOf", "mgx:relatedTo", "mgx:synonym", "mgx:antonym", "mgx:similarTo", "mgx:symbolOf",
|
|
46
46
|
"mgx:knows-about",
|
|
47
|
+
// One claim can be attributed to many speakers at once. Two outlets naming two
|
|
48
|
+
// different people corroborate the claim; they do not disagree about it.
|
|
49
|
+
"mgx:attributedTo",
|
|
47
50
|
];
|
|
48
51
|
|
|
49
52
|
export const MERGE_PREDICATES = new Set(
|