@polycode-projects/the-mechanical-code-talker 5.0.30 → 5.0.32
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 +15 -3
- package/package.json +7 -3
- package/src/adapters/toml-config.mjs +2 -1
- package/src/adapters/uuid.mjs +19 -4
- package/src/domain/choice-question.mjs +128 -0
- package/src/domain/news-feed.mjs +20 -2
- package/src/domain/reasoning-config.mjs +27 -0
- package/src/domain/tableau.mjs +226 -29
- package/src/domain/term-ledger.mjs +1 -1
- package/src/services/chat.mjs +434 -33
- package/src/services/extract-facts.mjs +19 -10
- package/src/services/mudiii-viz.mjs +103 -29
- package/src/services/news-viz.mjs +36 -11
- package/src/services/news.mjs +3 -2
- package/src/surfaces/web/memory-ask-browser.bundle.js +130 -130
- package/src/surfaces/web/mudiii-browser-entry.mjs +45 -13
- package/src/surfaces/web/news-browser-entry.mjs +25 -3
- package/test-benchmarks/agentbench/README.md +196 -0
- package/test-benchmarks/agentbench/envelope-reader.mjs +13 -0
- package/test-benchmarks/agentbench/envelope.json +120 -0
package/src/services/chat.mjs
CHANGED
|
@@ -70,7 +70,7 @@ import { newsTurn, resolveNewsConfig, NEWS_DEFAULTS, createNewsState } from "./n
|
|
|
70
70
|
import { CHILD_PACK_NAME, childProvenanceTag } from "../domain/child-pack.mjs";
|
|
71
71
|
import { getChildPackProvider } from "../adapters/corpus/child-pack.mjs";
|
|
72
72
|
import { dialogueActForLane } from "../domain/dialogue-acts.mjs";
|
|
73
|
-
import { splitChoiceQuestion } from "../domain/choice-question.mjs";
|
|
73
|
+
import { splitChoiceQuestion, routeChoiceRelation, lemmaFoldVariants, headNounOf } from "../domain/choice-question.mjs";
|
|
74
74
|
import { subClassParents, subClassChildren, descendantSet, ancestryChain, clusterSenses } from "../domain/sense-split.mjs";
|
|
75
75
|
import { ANSWER_STOP_SET } from "../domain/hub-terms.mjs";
|
|
76
76
|
import { relatedForTerm } from "../domain/skos-view.mjs";
|
|
@@ -2848,6 +2848,10 @@ const SUBCLASS_PREDICATE = "rdfs:subClassOf";
|
|
|
2848
2848
|
// direct-write teach paths below stay in that family without re-typing the
|
|
2849
2849
|
// CURIE string at each call site.
|
|
2850
2850
|
const TYPE_PREDICATE = "rdf:type";
|
|
2851
|
+
// Role-hierarchy declaration — ACE pattern 19's own emitted predicate
|
|
2852
|
+
// (grammar/ace.mjs's parseSubProperty), named here for the same reason
|
|
2853
|
+
// SUBCLASS_PREDICATE and TYPE_PREDICATE are.
|
|
2854
|
+
const SUB_PROPERTY_OF_PREDICATE = "rdfs:subPropertyOf";
|
|
2851
2855
|
// HAS_A_PREDICATE (imported from memory/core.mjs, the canonical home) keeps
|
|
2852
2856
|
// generalVerbTeach's "has"/"have" special case in the same family ConceptNet's
|
|
2853
2857
|
// /r/HasA corpus facts already use, rather than minting a redundant mgx:has.
|
|
@@ -3699,9 +3703,96 @@ export { isAnchorableTerm };
|
|
|
3699
3703
|
* graph from the question's own distractors would ground every option for
|
|
3700
3704
|
* free, which is a slow way to guess rather than an honest probe.
|
|
3701
3705
|
*
|
|
3702
|
-
*
|
|
3703
|
-
*
|
|
3704
|
-
*
|
|
3706
|
+
* ROUTING (rung 2): `routeChoiceRelation` (choice-question.mjs) reads the
|
|
3707
|
+
* relation family the STEM itself names — "where" cues AtLocation, "part of"
|
|
3708
|
+
* cues PartOf/HasA/MadeOf, and so on, a closed cue table ordered by measured
|
|
3709
|
+
* yield on the committed fixture. When a route fires, an edge only grounds
|
|
3710
|
+
* an option if its predicate is IN that family — an edge under some other
|
|
3711
|
+
* predicate is no longer "a stated relation", it is the WRONG stated
|
|
3712
|
+
* relation, and the whole point of routing is to stop counting that as
|
|
3713
|
+
* evidence. A stem naming no relation at all (routeChoiceRelation returns
|
|
3714
|
+
* null) falls back to the unrouted any-predicate probe, unchanged.
|
|
3715
|
+
*
|
|
3716
|
+
* CHAIN FALLBACK (rung 3): an option with no direct edge gets one more
|
|
3717
|
+
* chance — findIsaChain (syllogise.mjs), the SAME bounded rooted proof
|
|
3718
|
+
* search the isa lanes already cite, chases from every spelling of
|
|
3719
|
+
* sourceTerm toward the option over the store's own rdf:type/rdfs:subClassOf
|
|
3720
|
+
* edges, maxHops:2 (its usual live-chase bound). `chain`, when non-null, is
|
|
3721
|
+
* the ORDERED ARRAY OF FACT ROWS the chase proved, every one of them a real
|
|
3722
|
+
* stored row so the citation never names a step nothing backs — the same
|
|
3723
|
+
* `premises.every(Boolean)` discipline the isa lanes use before returning a
|
|
3724
|
+
* chain answer. The routing filter above does not apply to the chain: a
|
|
3725
|
+
* relation family cues a DIRECT edge's predicate, and findIsaChain only ever
|
|
3726
|
+
* walks the isa family, a different axis entirely.
|
|
3727
|
+
*
|
|
3728
|
+
* WORDING (rung 4): an option's variant set is TAGGED, not just widened —
|
|
3729
|
+
* `choiceTermTags` maps every spelling the option could be read as back to
|
|
3730
|
+
* the mechanism that produced it ("exact" for factTermVariants' own plural
|
|
3731
|
+
* fold, "lemma" for lemmaFoldVariants' regular -ing/-ed reversal), so a
|
|
3732
|
+
* grounded fact's `matchedBy` says HOW it matched, not just THAT it did.
|
|
3733
|
+
* HEAD-NOUN BACKOFF is a second, separate pass: only when the full phrase
|
|
3734
|
+
* (exact + lemma) finds NOTHING does a multi-word option retry under its
|
|
3735
|
+
* head noun alone (`headNounOf`, choice-question.mjs) — "fast food
|
|
3736
|
+
* restaurant" retries as "restaurant". Bounded to the head only, never
|
|
3737
|
+
* every sub-phrase, and never tried when the full phrase already grounded.
|
|
3738
|
+
* WORDNET EXPANSION is the third and widest pass, tried only when the first
|
|
3739
|
+
* two find nothing: a fixed-depth (one hop) lookup into
|
|
3740
|
+
* corpus/wordnet/wordnet-full.jsonl's own `/r/Synonym` edges, the same
|
|
3741
|
+
* ConceptNet-shape corpus the `wordnet-xl` band already ships from, loaded
|
|
3742
|
+
* and indexed once per process and cached (loadWordnetSynonymIndex, below)
|
|
3743
|
+
* — a 28 MB file is not re-parsed per turn. */
|
|
3744
|
+
function choiceTermTags(text) {
|
|
3745
|
+
const tags = new Map();
|
|
3746
|
+
const addAll = (values, tag) => { for (const v of values) if (!tags.has(v)) tags.set(v, tag); };
|
|
3747
|
+
addAll(factTermVariants(normFactTermStatic, text), "exact");
|
|
3748
|
+
for (const folded of lemmaFoldVariants(text)) addAll(factTermVariants(normFactTermStatic, folded), "lemma");
|
|
3749
|
+
return tags;
|
|
3750
|
+
}
|
|
3751
|
+
function choiceHeadNounTags(text) {
|
|
3752
|
+
const head = headNounOf(text);
|
|
3753
|
+
if (!head) return new Map();
|
|
3754
|
+
const tags = new Map();
|
|
3755
|
+
for (const v of factTermVariants(normFactTermStatic, head)) tags.set(v, "head-noun");
|
|
3756
|
+
return tags;
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
/** subject|object -> Set(synonym) built once from wordnet-full.jsonl's own
|
|
3760
|
+
* `/r/Synonym` rows, both directions (a chained synonym pair is stored one
|
|
3761
|
+
* way in the source file, and a lookup needs to reach it from either
|
|
3762
|
+
* member). Cached at module scope: the file is 28 MB / ~206,000 rows, and a
|
|
3763
|
+
* choice question that never needs this pass never pays to load it — the
|
|
3764
|
+
* cache only fills on the first ungrounded option that reaches it. */
|
|
3765
|
+
let choiceWordnetSynonymIndex = null;
|
|
3766
|
+
async function loadChoiceWordnetSynonymIndex() {
|
|
3767
|
+
if (choiceWordnetSynonymIndex) return choiceWordnetSynonymIndex;
|
|
3768
|
+
const index = new Map();
|
|
3769
|
+
try {
|
|
3770
|
+
const { loadSlice, termText, WORDNET_DIR } = await import("../adapters/corpus/conceptnet.mjs");
|
|
3771
|
+
const assertions = await loadSlice(join(WORDNET_DIR, "wordnet-full.jsonl"));
|
|
3772
|
+
const add = (a, b) => {
|
|
3773
|
+
if (!a || !b || a === b) return;
|
|
3774
|
+
if (!index.has(a)) index.set(a, new Set());
|
|
3775
|
+
index.get(a).add(b);
|
|
3776
|
+
};
|
|
3777
|
+
for (const row of assertions) {
|
|
3778
|
+
if (row.rel !== "/r/Synonym") continue;
|
|
3779
|
+
const a = termText(row.start);
|
|
3780
|
+
const b = termText(row.end);
|
|
3781
|
+
add(a, b);
|
|
3782
|
+
add(b, a);
|
|
3783
|
+
}
|
|
3784
|
+
} catch { /* the corpus is optional; an empty index just skips this pass */ }
|
|
3785
|
+
choiceWordnetSynonymIndex = index;
|
|
3786
|
+
return choiceWordnetSynonymIndex;
|
|
3787
|
+
}
|
|
3788
|
+
async function choiceWordnetTags(text) {
|
|
3789
|
+
const index = await loadChoiceWordnetSynonymIndex();
|
|
3790
|
+
const synonyms = index.get(String(text ?? "").toLowerCase().trim());
|
|
3791
|
+
if (!synonyms) return new Map();
|
|
3792
|
+
const tags = new Map();
|
|
3793
|
+
for (const syn of synonyms) for (const v of factTermVariants(normFactTermStatic, syn)) tags.set(v, "wordnet");
|
|
3794
|
+
return tags;
|
|
3795
|
+
}
|
|
3705
3796
|
async function probeChoiceOptions(parsed, { memoryDir, env, cache, graph, synthesisBudget = AUTO_SYNTHESIS_BUDGET }) {
|
|
3706
3797
|
const sourceVariants = factTermVariants(normFactTermStatic, parsed.sourceTerm);
|
|
3707
3798
|
let rows = await factRows(memoryDir, cache);
|
|
@@ -3710,12 +3801,58 @@ async function probeChoiceOptions(parsed, { memoryDir, env, cache, graph, synthe
|
|
|
3710
3801
|
const learned = await childPackFactsForKey(parsed.sourceTerm, { memoryDir, env, cache, synthesisBudget });
|
|
3711
3802
|
if (learned) rows = await factRows(memoryDir, cache);
|
|
3712
3803
|
}
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3804
|
+
const route = routeChoiceRelation(parsed.stem);
|
|
3805
|
+
const {
|
|
3806
|
+
findIsaChain: chaseChoiceIsa, buildSubClassSuccessors: buildChoiceSubClassSucc,
|
|
3807
|
+
TYPE_PREDICATE: CHOICE_TYPE_PREDICATE, SUBCLASS_PREDICATE: CHOICE_SUBCLASS_PREDICATE,
|
|
3808
|
+
} = await import("../domain/syllogise.mjs");
|
|
3809
|
+
const choiceTypeRows = rows.filter((f) => f.predicate === CHOICE_TYPE_PREDICATE);
|
|
3810
|
+
const choiceSubClassRows = rows.filter((f) => f.predicate === CHOICE_SUBCLASS_PREDICATE);
|
|
3811
|
+
const choiceTypeEdges = choiceTypeRows.map((f) => [f.subject, f.object]);
|
|
3812
|
+
const choiceSubClassSucc = buildChoiceSubClassSucc(choiceSubClassRows.map((f) => [f.subject, f.object]));
|
|
3813
|
+
const factForChoiceChainStep = (step) => (step.predicate === CHOICE_SUBCLASS_PREDICATE ? choiceSubClassRows : choiceTypeRows)
|
|
3814
|
+
.find((f) => f.subject === step.subject && f.object === step.object);
|
|
3815
|
+
const matchFacts = (variantsSet) => {
|
|
3816
|
+
let matched = rows.filter((f) => (sourceVariants.has(f.subject) && variantsSet.has(f.object))
|
|
3817
|
+
|| (sourceVariants.has(f.object) && variantsSet.has(f.subject)));
|
|
3818
|
+
if (route) matched = matched.filter((f) => route.predicates.includes(f.predicate));
|
|
3819
|
+
return matched;
|
|
3820
|
+
};
|
|
3821
|
+
|
|
3822
|
+
return Promise.all(parsed.options.map(async (option) => {
|
|
3823
|
+
const primaryTags = choiceTermTags(option.text);
|
|
3824
|
+
const primaryVariants = new Set(primaryTags.keys());
|
|
3825
|
+
let facts = matchFacts(primaryVariants);
|
|
3826
|
+
let activeTags = primaryTags;
|
|
3827
|
+
if (facts.length === 0) {
|
|
3828
|
+
const headTags = choiceHeadNounTags(option.text);
|
|
3829
|
+
if (headTags.size) {
|
|
3830
|
+
const headFacts = matchFacts(new Set(headTags.keys()));
|
|
3831
|
+
if (headFacts.length) { facts = headFacts; activeTags = headTags; }
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
if (facts.length === 0) {
|
|
3835
|
+
const wordnetTags = await choiceWordnetTags(option.text);
|
|
3836
|
+
if (wordnetTags.size) {
|
|
3837
|
+
const wordnetFacts = matchFacts(new Set(wordnetTags.keys()));
|
|
3838
|
+
if (wordnetFacts.length) { facts = wordnetFacts; activeTags = wordnetTags; }
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3841
|
+
facts = facts.map((f) => {
|
|
3842
|
+
const optionSideTerm = sourceVariants.has(f.subject) ? f.object : f.subject;
|
|
3843
|
+
return { ...f, matchedBy: activeTags.get(optionSideTerm) ?? "exact" };
|
|
3844
|
+
});
|
|
3845
|
+
let chain = null;
|
|
3846
|
+
if (facts.length === 0) {
|
|
3847
|
+
for (const subj of sourceVariants) {
|
|
3848
|
+
const path = chaseChoiceIsa(subj, primaryVariants, choiceTypeEdges, choiceSubClassSucc, { maxHops: 2 });
|
|
3849
|
+
if (!path) continue;
|
|
3850
|
+
const premises = path.map(factForChoiceChainStep);
|
|
3851
|
+
if (premises.every(Boolean)) { chain = premises; break; }
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
return { label: option.label, text: option.text, grounds: facts.length > 0 || chain !== null, facts, chain };
|
|
3855
|
+
}));
|
|
3719
3856
|
}
|
|
3720
3857
|
|
|
3721
3858
|
/** The "both sides ungrounded" grounding NUDGE: reuses teachSuggestion's own
|
|
@@ -7664,14 +7801,25 @@ const WORLD_INTERNAL_PREDICATES = new Set([
|
|
|
7664
7801
|
"mgx:is-container", "mgx:is-open",
|
|
7665
7802
|
]);
|
|
7666
7803
|
|
|
7667
|
-
/** A `<role> rdf:type owl:TransitiveProperty`
|
|
7668
|
-
*
|
|
7669
|
-
*
|
|
7670
|
-
*
|
|
7671
|
-
* out of
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7804
|
+
/** A role-axiom declaration — `<role> rdf:type owl:TransitiveProperty` or
|
|
7805
|
+
* `<role> rdfs:subPropertyOf <role>` — is role scaffolding, not a fact about
|
|
7806
|
+
* the role a reader wants listed back in English. Neither ever renders as a
|
|
7807
|
+
* plain fact line, the same discipline that keeps the restriction scaffolding
|
|
7808
|
+
* predicates (RESTRICTION_SCAFFOLDING_PREDICATES, below) out of the describe
|
|
7809
|
+
* lane. */
|
|
7810
|
+
function isRoleScaffoldingDeclaration(f) {
|
|
7811
|
+
return (f.predicate === TYPE_PREDICATE && f.object === "transitiveproperty")
|
|
7812
|
+
|| f.predicate === SUB_PROPERTY_OF_PREDICATE;
|
|
7813
|
+
}
|
|
7814
|
+
|
|
7815
|
+
/** A restriction node's own internal edges — which property it restricts
|
|
7816
|
+
* (owl:onProperty) and which filler it restricts to (owl:someValuesFrom,
|
|
7817
|
+
* owl:allValuesFrom) — name the restriction's SHAPE, not a fact about the
|
|
7818
|
+
* role or the filler a reader wants listed back. Neither ever renders as a
|
|
7819
|
+
* plain fact line in the describe lane. */
|
|
7820
|
+
const RESTRICTION_SCAFFOLDING_PREDICATES = new Set([
|
|
7821
|
+
"owl:onProperty", "owl:someValuesFrom", "owl:allValuesFrom",
|
|
7822
|
+
]);
|
|
7675
7823
|
|
|
7676
7824
|
/** The world PLACEMENT predicates carry curated phrases above so they render as
|
|
7677
7825
|
* English, but they must stay OUT of the query-marker families derived from
|
|
@@ -7716,6 +7864,15 @@ function baseVerbSurface(verb) {
|
|
|
7716
7864
|
if (/(?:s|x|z|ch|sh|o)es$/i.test(w)) return w.slice(0, -2);
|
|
7717
7865
|
return w.replace(/s$/i, "");
|
|
7718
7866
|
}
|
|
7867
|
+
/** The gerund surface of a 3sg-minted role predicate — "contains" -> "containing",
|
|
7868
|
+
* "touches" -> "touching" — the naive INVERSE of the "-ing"-stripping fold
|
|
7869
|
+
* verbPredicateFromSurface (ace.mjs) already accepts alongside a 3sg surface
|
|
7870
|
+
* when parsing patterns 16, 17 and 19. Same accepted naive-morphology trade
|
|
7871
|
+
* thirdPersonSingularSurface/baseVerbSurface already make. */
|
|
7872
|
+
function gerundVerbSurface(verb) {
|
|
7873
|
+
const base = baseVerbSurface(verb);
|
|
7874
|
+
return /[^aeiou]e$/i.test(base) && base.length > 2 ? `${base.slice(0, -1)}ing` : `${base}ing`;
|
|
7875
|
+
}
|
|
7719
7876
|
function predicatePhrase(predicate) {
|
|
7720
7877
|
if (FACT_PREDICATE_PHRASES[predicate]) return FACT_PREDICATE_PHRASES[predicate];
|
|
7721
7878
|
const p = String(predicate || "");
|
|
@@ -7824,6 +7981,14 @@ function citationProvenance(provenance) {
|
|
|
7824
7981
|
* applies here instead. Provenance stays VERBATIM in every case. */
|
|
7825
7982
|
function renderFactLine(f) {
|
|
7826
7983
|
const cite = f.provenance ? ` (source: ${citationProvenance(f.provenance)})` : "";
|
|
7984
|
+
// A rdfs:subPropertyOf row relates two PREDICATES, not two things — factPhrase
|
|
7985
|
+
// would compose the raw CURIE ("contains rdfs:subPropertyOf touches"), so this
|
|
7986
|
+
// shape gets its own dedicated line ahead of the provenance-keyed framing below,
|
|
7987
|
+
// the same way renderUnionLine/renderEnumerationLine read as a definition
|
|
7988
|
+
// rather than a first-person claim regardless of who taught it.
|
|
7989
|
+
if (f.predicate === SUB_PROPERTY_OF_PREDICATE) {
|
|
7990
|
+
return `${gerundVerbSurface(f.subject)} implies ${gerundVerbSurface(f.object)}${cite}`;
|
|
7991
|
+
}
|
|
7827
7992
|
// ace:chat = the ACE-parsed operator assert; teach:chat = the teach lane's
|
|
7828
7993
|
// natural frames — both are things the operator SAID, so both read first-person.
|
|
7829
7994
|
if (f.provenance.includes("ace:chat") || f.provenance.includes("teach:chat")) return `you told me: ${factPhrase(f)}${cite}`;
|
|
@@ -7872,7 +8037,23 @@ function renderEnumerationLine(cls, members) {
|
|
|
7872
8037
|
const plural = thirdPersonSingularSurface(String(cls || "").replace(/-/g, " "));
|
|
7873
8038
|
return `the ${plural} are exactly ${list}${cite}`;
|
|
7874
8039
|
}
|
|
7875
|
-
|
|
8040
|
+
|
|
8041
|
+
/** A universal restriction's stored triples read back as ONE sentence rather
|
|
8042
|
+
* than the restriction node's raw scaffolding rows: "every heart contains
|
|
8043
|
+
* only valves (source: …)". `node` is the `<parent> rdfs:subClassOf
|
|
8044
|
+
* <restriction>` fact row (the parent and the citation both come from it);
|
|
8045
|
+
* `rows` are the restriction node's own rows, from which its owl:onProperty
|
|
8046
|
+
* role and owl:allValuesFrom filler are read — order-independent, the same
|
|
8047
|
+
* way renderUnionLine/renderEnumerationLine are. Pure — takes the fact rows,
|
|
8048
|
+
* returns one line. */
|
|
8049
|
+
function renderUniversalRestrictionLine(node, rows) {
|
|
8050
|
+
const onProperty = rows.find((r) => r.predicate === "owl:onProperty");
|
|
8051
|
+
const allValuesFrom = rows.find((r) => r.predicate === "owl:allValuesFrom");
|
|
8052
|
+
const cite = node.provenance ? ` (source: ${citationProvenance(node.provenance)})` : "";
|
|
8053
|
+
const filler = thirdPersonSingularSurface(String(allValuesFrom?.object || "").replace(/-/g, " "));
|
|
8054
|
+
return `every ${node.subject} ${onProperty?.object || ""} only ${filler}${cite}`;
|
|
8055
|
+
}
|
|
8056
|
+
export { renderUnionLine, renderEnumerationLine, renderUniversalRestrictionLine };
|
|
7876
8057
|
|
|
7877
8058
|
const SENSE_CITE_RE = / \(source: [^)]*\)$/;
|
|
7878
8059
|
|
|
@@ -9007,6 +9188,166 @@ async function findWiderConsistencyClash(rows, variants, reasoning) {
|
|
|
9007
9188
|
}
|
|
9008
9189
|
export { findWiderConsistencyClash };
|
|
9009
9190
|
|
|
9191
|
+
/** TRACK B1: a plain isa-shaped miss falls through to a bounded, automatic
|
|
9192
|
+
* tableau proof before the isa reader's own recovery text renders. Called
|
|
9193
|
+
* from the isa branch immediately after `deeperChainExists` is computed and
|
|
9194
|
+
* immediately before `knownSubjectIsa.length` is checked — the one point
|
|
9195
|
+
* that dominates every exit the branch takes, whichever of the three
|
|
9196
|
+
* reasons (a subject with an `rdf:type` row, a subject with only an
|
|
9197
|
+
* `owl:disjointWith` row, or a subject the store has never seen) sent it
|
|
9198
|
+
* there.
|
|
9199
|
+
*
|
|
9200
|
+
* Three things gate the prover, and none of them runs it: the question
|
|
9201
|
+
* already parsed through ISA_ASK_RE (true by construction — every caller
|
|
9202
|
+
* matched it to reach here); every live chase above already missed (true
|
|
9203
|
+
* by construction — this runs immediately before the isa branch's own
|
|
9204
|
+
* recovery text); and the extracted module holds a DL-only axiom shape
|
|
9205
|
+
* (`moduleHasDlShape`) — without one the tableau can only redo the
|
|
9206
|
+
* subclass walk the chases just finished, so running it would spend a
|
|
9207
|
+
* budget to reach the identical miss they already reached.
|
|
9208
|
+
*
|
|
9209
|
+
* Two-sided, PROVED ONLY. Proves `subject : class`; `proved` renders yes.
|
|
9210
|
+
* A `disproved` first pass tries the NEGATION (`subject : ¬class`);
|
|
9211
|
+
* `proved` there renders no — a store-entailed negation, never the
|
|
9212
|
+
* counter-model `/prove` itself renders as "no", since a counter-model
|
|
9213
|
+
* under the open-world rule means "not entailed", not "entailed false",
|
|
9214
|
+
* and converting that into a denial on a plain question would turn
|
|
9215
|
+
* abstention into a guess. Anything else (both passes disproved, either
|
|
9216
|
+
* exhausted, or the ex-falso guard below firing) returns null, so the
|
|
9217
|
+
* isa branch's own miss text renders byte-identical.
|
|
9218
|
+
*
|
|
9219
|
+
* The ex-falso guard runs before either proof pass: an individual whose
|
|
9220
|
+
* own premises already clash proves anything asked of it (the shipped
|
|
9221
|
+
* `inference.dl.cardinality-clash` corpus row shows the shape doing this
|
|
9222
|
+
* under an explicit `/prove`), and an automatic fallback must never turn
|
|
9223
|
+
* that into a confident yes — it renders the clash instead, through the
|
|
9224
|
+
* same premise-quoting text `findWiderConsistencyClash` above already
|
|
9225
|
+
* uses.
|
|
9226
|
+
*
|
|
9227
|
+
* Returns `{ text, replace: true }` on a proved verdict or a clash,
|
|
9228
|
+
* `{ budgetExhausted: true }` when a pass exhausted its budget (the caller
|
|
9229
|
+
* reads this flag to stamp the turn record the same way `/prove`'s own
|
|
9230
|
+
* budget wall does, and renders nothing else — the existing miss stands),
|
|
9231
|
+
* or `null` when nothing here changes the answer. */
|
|
9232
|
+
// A cheap, LITERAL duplicate of tableau.mjs's own moduleHasDlShape
|
|
9233
|
+
// vocabulary (DL_SHAPE_PREDICATES there) — checked here, inline, before
|
|
9234
|
+
// this file's own dynamic `import("../domain/tableau.mjs")`, so the
|
|
9235
|
+
// overwhelming majority of ordinary isa misses (nothing DL-shaped in the
|
|
9236
|
+
// store at all) never pay that module's first-load parse cost on the hot
|
|
9237
|
+
// path. Keep in sync with tableau.mjs's DL_SHAPE_PREDICATES by hand; a
|
|
9238
|
+
// drift here only ever makes this pre-check MISS a real DL shape (falling
|
|
9239
|
+
// through to the authoritative, imported moduleHasDlShape below, which
|
|
9240
|
+
// still runs whenever this pre-check can't rule the store out), never
|
|
9241
|
+
// falsely certify one.
|
|
9242
|
+
const CHAT_DL_SHAPE_PREDICATES = new Set([
|
|
9243
|
+
"owl:unionof", "owl:complementof", "owl:oneof", "owl:allvaluesfrom",
|
|
9244
|
+
"owl:mincardinality", "owl:maxcardinality", "owl:cardinality",
|
|
9245
|
+
"rdfs:subpropertyof", "owl:inverseof",
|
|
9246
|
+
]);
|
|
9247
|
+
function storeMightHaveDlShape(rows) {
|
|
9248
|
+
return rows.some((r) => {
|
|
9249
|
+
const p = String(r?.predicate || "").trim().toLowerCase();
|
|
9250
|
+
if (CHAT_DL_SHAPE_PREDICATES.has(p)) return true;
|
|
9251
|
+
return p === "rdf:type" && String(r?.object || "").toLowerCase() === "transitiveproperty";
|
|
9252
|
+
});
|
|
9253
|
+
}
|
|
9254
|
+
|
|
9255
|
+
/** TRACK B2: the English phrase naming a proved case-split's own disjuncts
|
|
9256
|
+
* — "a cat or a dog" — from tableau.mjs's own `cases` (a proved result's
|
|
9257
|
+
* distinct owl:unionOf/owl:oneOf disjuncts, deduped, sorted, capped at
|
|
9258
|
+
* MAX_PROVEN_CASES) and `casesTotal` (the real count before the cap). Once
|
|
9259
|
+
* the real count outruns the cap, names the count instead of listing
|
|
9260
|
+
* beyond it, rather than silently truncating the sentence. Each case is a
|
|
9261
|
+
* concept-expression atom or nominal (tableau.mjs's own shape), so its
|
|
9262
|
+
* display term is `.name` or `.ind` respectively. */
|
|
9263
|
+
function renderCasesPhrase(cases, casesTotal) {
|
|
9264
|
+
if (casesTotal > cases.length) return `one of ${casesTotal} possibilities`;
|
|
9265
|
+
return cases
|
|
9266
|
+
.map((c) => (c.t === "nom" ? c.ind : c.name))
|
|
9267
|
+
.map((term) => `${indefiniteArticleFor(term)} ${term}`)
|
|
9268
|
+
.join(" or ");
|
|
9269
|
+
}
|
|
9270
|
+
|
|
9271
|
+
/** The proved-verdict conclusion clause both `/prove` and the automatic
|
|
9272
|
+
* fallback render: "so X is a Y." for a single deduction, or "in every
|
|
9273
|
+
* case — <cases> — X is a Y." once `result.cases` names a genuine
|
|
9274
|
+
* case analysis the proof actually reasoned through — never the ⊑-rule's
|
|
9275
|
+
* own routine TBox-internalization disjunction, which every proof passes
|
|
9276
|
+
* through regardless of a union/oneOf premise and which tableau.mjs's own
|
|
9277
|
+
* `isGenuineDisjunction` already excludes from `cases`. `negate` renders
|
|
9278
|
+
* the negative form the store-entailed-negation path needs. */
|
|
9279
|
+
function renderProvedConclusion(result, subjectWord, classWord, { negate = false } = {}) {
|
|
9280
|
+
const predicate = negate ? `is not a ${classWord}` : `is a ${classWord}`;
|
|
9281
|
+
if (!result.cases || !result.cases.length) return `so ${subjectWord} ${predicate}.`;
|
|
9282
|
+
return `in every case — ${renderCasesPhrase(result.cases, result.casesTotal)} — ${subjectWord} ${predicate}.`;
|
|
9283
|
+
}
|
|
9284
|
+
async function autoProveFallback(memoryDir, cache, allRows, subjectWord, subjCandidates, objVariants, classWord) {
|
|
9285
|
+
// storeMightHaveDlShape already ruled out "nothing DL-shaped anywhere in
|
|
9286
|
+
// the store" without paying tableau.mjs's own first-load parse cost — see
|
|
9287
|
+
// its own docblock. Only a store that passes it ever reaches the import.
|
|
9288
|
+
if (!storeMightHaveDlShape(allRows)) return null;
|
|
9289
|
+
const {
|
|
9290
|
+
extractTableauModule, buildTableauKb, proveEntailment, proveSubsumption, proveSubsumptionOfNegation,
|
|
9291
|
+
findTableauViolations, moduleHasDlShape,
|
|
9292
|
+
} = await import("../domain/tableau.mjs");
|
|
9293
|
+
const { normFactTerm } = await import("../adapters/memory/core.mjs");
|
|
9294
|
+
const subjectTerm = resolveProveTerm(subjCandidates, allRows, normFactTerm(subjectWord));
|
|
9295
|
+
const classTerm = resolveProveTerm(objVariants, allRows, normFactTerm(classWord));
|
|
9296
|
+
// The subject's own stored TYPES seed the module too, not just its name —
|
|
9297
|
+
// extractTableauModule's structural walk starts from class/role
|
|
9298
|
+
// vocabulary, so an individual reached only through its own `rdf:type`
|
|
9299
|
+
// edge never pulls in that class's own restrictions or union membership
|
|
9300
|
+
// unless the class is seeded directly. Same discipline
|
|
9301
|
+
// findWiderConsistencyClash already applies above.
|
|
9302
|
+
const typeSeeds = allRows.filter((r) => r.predicate === "rdf:type" && subjCandidates.has(r.subject)).map((r) => r.object);
|
|
9303
|
+
const moduleRows = extractTableauModule(allRows, [subjectTerm, classTerm, ...typeSeeds]);
|
|
9304
|
+
// Both cheap, in-memory, no I/O — the gate that keeps the ordinary miss
|
|
9305
|
+
// off the hot-path cost of reading tmct.toml at all. Only a DL-shaped
|
|
9306
|
+
// module ever reaches resolveReasoningConfigForRepo below.
|
|
9307
|
+
if (!moduleHasDlShape(moduleRows)) return null;
|
|
9308
|
+
const reasoning = await resolveReasoningConfigForRepo(memoryDir);
|
|
9309
|
+
if (!reasoning.askProveFallback) return null;
|
|
9310
|
+
const kb = buildTableauKb(moduleRows);
|
|
9311
|
+
const proveOpts = { maxSteps: reasoning.askProveSteps, maxBranches: reasoning.askProveBranches, maxNodes: reasoning.askProveNodes };
|
|
9312
|
+
const isIndividual = kb.namedIndividuals.has(subjectTerm);
|
|
9313
|
+
const byId = new Map(moduleRows.map((r) => [r.id, r]));
|
|
9314
|
+
|
|
9315
|
+
if (isIndividual) {
|
|
9316
|
+
const violation = findTableauViolations(kb, [subjectTerm], proveOpts)[0];
|
|
9317
|
+
if (violation) {
|
|
9318
|
+
const cited = violation.premises.map((id) => byId.get(id)).filter(Boolean).map(renderFactLine).join("; ");
|
|
9319
|
+
return {
|
|
9320
|
+
text: `I can't answer that — what I've been told about ${violation.subject} is inconsistent: `
|
|
9321
|
+
+ `${cited || "the facts I hold about it clash"}. I'd need one of those retracted before I can answer honestly.`,
|
|
9322
|
+
replace: true,
|
|
9323
|
+
};
|
|
9324
|
+
}
|
|
9325
|
+
}
|
|
9326
|
+
|
|
9327
|
+
const renderProvedCite = (result) => result.premises.map((id) => byId.get(id)).filter(Boolean).map(renderFactLine).join("; ");
|
|
9328
|
+
|
|
9329
|
+
const positive = isIndividual
|
|
9330
|
+
? proveEntailment(kb, subjectTerm, { t: "atom", name: classTerm }, proveOpts)
|
|
9331
|
+
: proveSubsumption(kb, subjectTerm, classTerm, proveOpts);
|
|
9332
|
+
if (positive.status === "proved") {
|
|
9333
|
+
const cited = renderProvedCite(positive);
|
|
9334
|
+
const conclusion = renderProvedConclusion(positive, subjectWord, classWord);
|
|
9335
|
+
return { text: `yes — ${cited}; ${conclusion}`, replace: true };
|
|
9336
|
+
}
|
|
9337
|
+
if (positive.status === "exhausted") return { budgetExhausted: true };
|
|
9338
|
+
|
|
9339
|
+
// Step 1 disproved: a counter-model, never rendered on this path. Step 2
|
|
9340
|
+
// asks the negation — a store-entailed negation is a grounded no.
|
|
9341
|
+
const negative = isIndividual
|
|
9342
|
+
? proveEntailment(kb, subjectTerm, { t: "not", c: { t: "atom", name: classTerm } }, proveOpts)
|
|
9343
|
+
: proveSubsumptionOfNegation(kb, subjectTerm, classTerm, proveOpts);
|
|
9344
|
+
if (negative.status === "exhausted") return { budgetExhausted: true };
|
|
9345
|
+
if (negative.status !== "proved") return null;
|
|
9346
|
+
const cited = renderProvedCite(negative);
|
|
9347
|
+
const conclusion = renderProvedConclusion(negative, subjectWord, classWord, { negate: true });
|
|
9348
|
+
return { text: `no — ${cited}; ${conclusion}`, replace: true };
|
|
9349
|
+
}
|
|
9350
|
+
|
|
9010
9351
|
async function factAnswerReaders(memoryDir, query, envelope, miss, biasByBundle = {}, cache = null, focusLabel = null) {
|
|
9011
9352
|
let normFactTerm; let normFactPredicate;
|
|
9012
9353
|
try { ({ normFactTerm, normFactPredicate } = await import("../adapters/memory/core.mjs")); } catch { return null; }
|
|
@@ -9346,7 +9687,8 @@ async function factAnswerReaders(memoryDir, query, envelope, miss, biasByBundle
|
|
|
9346
9687
|
// and mechanics predicates are dropped so "what is the letter" never reads
|
|
9347
9688
|
// back where it's hidden or that it's the objective (WORLD_INTERNAL_PREDICATES).
|
|
9348
9689
|
const subjectHits = (await factRows(memoryDir, cache))
|
|
9349
|
-
.filter((f) => variants.has(f.subject) && !WORLD_INTERNAL_PREDICATES.has(f.predicate)
|
|
9690
|
+
.filter((f) => variants.has(f.subject) && !WORLD_INTERNAL_PREDICATES.has(f.predicate)
|
|
9691
|
+
&& !isRoleScaffoldingDeclaration(f) && !RESTRICTION_SCAFFOLDING_PREDICATES.has(f.predicate));
|
|
9350
9692
|
// Matched through normFactPredicate, so a fact stored under a minted
|
|
9351
9693
|
// spelling of the same relation ("mgx:used-for", from the participle
|
|
9352
9694
|
// teach frame, in a store written before the spellings converged) is
|
|
@@ -9981,7 +10323,8 @@ async function factAnswerReaders(memoryDir, query, envelope, miss, biasByBundle
|
|
|
9981
10323
|
// objective, and those datatype internals render as garbled non-English
|
|
9982
10324
|
// besides. The adventure's own where/openness readers answer the legitimate
|
|
9983
10325
|
// in-game questions from the world fold.
|
|
9984
|
-
hits = hits.filter((f) => !WORLD_INTERNAL_PREDICATES.has(f.predicate)
|
|
10326
|
+
hits = hits.filter((f) => !WORLD_INTERNAL_PREDICATES.has(f.predicate)
|
|
10327
|
+
&& !isRoleScaffoldingDeclaration(f) && !RESTRICTION_SCAFFOLDING_PREDICATES.has(f.predicate));
|
|
9985
10328
|
// A corpus-weak-only result set (every hit resolved ONLY through
|
|
9986
10329
|
// ConceptNet's /r/RelatedTo tier) still composes its hedged "possibly"
|
|
9987
10330
|
// lines below exactly as before — this reader's whole job is showing
|
|
@@ -11340,6 +11683,16 @@ async function factReadBackReaders(memoryDir, query, envelope, miss, graph = nul
|
|
|
11340
11683
|
const deeperChainExists = [...subjCandidates].some(
|
|
11341
11684
|
(subj) => findIsaChain(subj, objVariants, chainTypeEdges, chainSubClassSucc, { maxHops: DEEP_CHAIN_PROBE_HOPS }),
|
|
11342
11685
|
);
|
|
11686
|
+
// TRACK B1 — the automatic /prove fallback: every live chase above has
|
|
11687
|
+
// already missed, so this is the one point upstream of every exit the
|
|
11688
|
+
// isa branch takes (see autoProveFallback's own docblock). A proved
|
|
11689
|
+
// verdict or an ex-falso clash replaces the miss outright; an exhausted
|
|
11690
|
+
// budget merges onto whichever of the three recovery texts below still
|
|
11691
|
+
// renders, so the miss itself stays byte-identical and only gains the
|
|
11692
|
+
// marker chatbench/infbench read apart from a parse miss.
|
|
11693
|
+
const autoProve = await autoProveFallback(memoryDir, cache, rows, subjectWord, subjCandidates, objVariants, kindWord);
|
|
11694
|
+
if (autoProve?.text) return autoProve;
|
|
11695
|
+
const askProveBudgetExhausted = !!autoProve?.budgetExhausted;
|
|
11343
11696
|
if (knownSubjectIsa.length) {
|
|
11344
11697
|
const shown = knownSubjectIsa.slice(0, 3).map(renderFactLine).join("; ");
|
|
11345
11698
|
// A someValuesFrom restriction node among the subject's own remembered
|
|
@@ -11369,6 +11722,7 @@ async function factReadBackReaders(memoryDir, query, envelope, miss, graph = nul
|
|
|
11369
11722
|
text: `I can't confirm that — nothing I remember says ${subjectWord} is a ${kindWord}. I do know: ${shown}. ${recovery}`,
|
|
11370
11723
|
replace: true,
|
|
11371
11724
|
miss: true, // still a MISS in the turn record — honest wording, not an answer
|
|
11725
|
+
...(askProveBudgetExhausted ? { budgetExhausted: true } : {}),
|
|
11372
11726
|
};
|
|
11373
11727
|
}
|
|
11374
11728
|
// A stored CONVERSE ("every dog is a mammal" asked as "is a mammal a
|
|
@@ -11383,6 +11737,7 @@ async function factReadBackReaders(memoryDir, query, envelope, miss, graph = nul
|
|
|
11383
11737
|
text: `I can't confirm that — what I know runs the other way: ${renderFactLine(converseHit)}. A kind doesn't reverse. If it's true, teach me: "every ${subjectWord} is a ${kindWord}". If it isn't, teach me: "no ${subjectWord} is a ${kindWord}".`,
|
|
11384
11738
|
replace: true,
|
|
11385
11739
|
miss: true,
|
|
11740
|
+
...(askProveBudgetExhausted ? { budgetExhausted: true } : {}),
|
|
11386
11741
|
};
|
|
11387
11742
|
}
|
|
11388
11743
|
// Subject with NO isa facts: only divert when it's mentioned NOWHERE at
|
|
@@ -11395,6 +11750,7 @@ async function factReadBackReaders(memoryDir, query, envelope, miss, graph = nul
|
|
|
11395
11750
|
text: `I can't confirm that — I don't know "${subjectWord}" at all yet. If it's true, teach me: "${subjectWord} is a kind of ${kindWord}". If it isn't, teach me: "no ${subjectWord} is a ${kindWord}".`,
|
|
11396
11751
|
replace: true,
|
|
11397
11752
|
miss: true,
|
|
11753
|
+
...(askProveBudgetExhausted ? { budgetExhausted: true } : {}),
|
|
11398
11754
|
};
|
|
11399
11755
|
}
|
|
11400
11756
|
return null; // the honest miss stands (never a guessed "no")
|
|
@@ -13270,16 +13626,35 @@ async function entityOfKindInText(graph, expectedClass, answerText) {
|
|
|
13270
13626
|
return null;
|
|
13271
13627
|
}
|
|
13272
13628
|
|
|
13629
|
+
// The one taught action this lane derives a constraint for without being
|
|
13630
|
+
// asked: the river-crossing world pack and data/games/river.txt's own
|
|
13631
|
+
// taught lesson both name their crossing action "ferry onto", so a
|
|
13632
|
+
// mgx:consumes/mgx:guards pair only ever widens or narrows THAT action's
|
|
13633
|
+
// legal moves, never a different taught world's. A world that never teaches
|
|
13634
|
+
// "ferry onto" gets no constraint rows at all — constraintsFromDrives runs
|
|
13635
|
+
// over every fact row, but compileDomain groups action-constraint rows by
|
|
13636
|
+
// name, so the derived rows simply have nowhere to attach.
|
|
13637
|
+
const DRIVE_DERIVED_CONSTRAINT_ACTION = "ferry onto";
|
|
13638
|
+
|
|
13273
13639
|
/** Load the taught domain for the plan lane: fact rows + rule rows compiled
|
|
13274
|
-
* through src/domain.mjs
|
|
13275
|
-
*
|
|
13640
|
+
* through src/domain.mjs, with the fox may not be with the goat family of
|
|
13641
|
+
* constraints added wherever the rows state a consumes/guards pair
|
|
13642
|
+
* (agent-traits.mjs's constraintsFromDrives) — the same bridge
|
|
13643
|
+
* mudiii-turn.mjs's own puzzle plan runs, so a world taught here and a
|
|
13644
|
+
* world played on the square solve the same puzzle the same way. A world
|
|
13645
|
+
* with no such pair compiles exactly as it did before this ran. Fresh-loads
|
|
13646
|
+
* memory (never the turn cache) because the caller may have just written
|
|
13647
|
+
* snapshot rows this same turn. */
|
|
13276
13648
|
async function loadPlanContext(memoryDir) {
|
|
13277
13649
|
const { loadMemory, readFactRows, readRuleRows } = await import("../adapters/memory/core.mjs");
|
|
13278
13650
|
const { compileDomain, stateFromFacts } = await import("../domain/domain.mjs");
|
|
13651
|
+
const { constraintsFromDrives } = await import("../domain/agent-traits.mjs");
|
|
13279
13652
|
const payload = await loadMemory(memoryDir);
|
|
13280
13653
|
const factRows = readFactRows(payload);
|
|
13281
13654
|
const ruleRows = readRuleRows(payload);
|
|
13282
|
-
const
|
|
13655
|
+
const derivedConstraints = constraintsFromDrives(factRows)
|
|
13656
|
+
.map((slots) => ({ name: DRIVE_DERIVED_CONSTRAINT_ACTION, kind: "action-constraint", slots }));
|
|
13657
|
+
const domain = compileDomain(factRows, [...ruleRows, ...derivedConstraints]);
|
|
13283
13658
|
const state = stateFromFacts(factRows, domain);
|
|
13284
13659
|
return { factRows, ruleRows, domain, state };
|
|
13285
13660
|
}
|
|
@@ -15171,6 +15546,10 @@ async function runAsk(query, { config, source, graph, focus, last, templates, me
|
|
|
15171
15546
|
if (liveGameOwnWord) bareMetaHit = null;
|
|
15172
15547
|
const coldPronounDecline = focus?.label ? null : coldPronounDeclineText(query);
|
|
15173
15548
|
let selfContainedMiss = false;
|
|
15549
|
+
// TRACK B1: the automatic /prove fallback's own budget-exhaustion marker,
|
|
15550
|
+
// read off a fact-lane hit the same way selfContainedMiss is — merged onto
|
|
15551
|
+
// the turn record below, the same field /prove's own budget wall stamps.
|
|
15552
|
+
let budgetExhausted = false;
|
|
15174
15553
|
if (bareMetaHit?.reference) {
|
|
15175
15554
|
// The bare-form reference hit mirrors (4h): the cited answer replaces the
|
|
15176
15555
|
// miss, the turn is no longer recorded as one, and the article's grounded
|
|
@@ -15326,6 +15705,7 @@ async function runAsk(query, { config, source, graph, focus, last, templates, me
|
|
|
15326
15705
|
// the empty-graph orientation pointer below stays off it — a pronoun
|
|
15327
15706
|
// decline with an index pointer under it is two answers to one turn.
|
|
15328
15707
|
if (fact.selfContainedMiss) selfContainedMiss = true;
|
|
15708
|
+
if (fact.budgetExhausted) budgetExhausted = true;
|
|
15329
15709
|
// A `weakOnly` hit (the "what do you know about X" reader's
|
|
15330
15710
|
// corpus-weak-only hedge) is shown as `answer` above like any other
|
|
15331
15711
|
// fact-lane hit, but doesn't count as REAL grounding — via/recordMiss
|
|
@@ -15911,6 +16291,10 @@ async function runAsk(query, { config, source, graph, focus, last, templates, me
|
|
|
15911
16291
|
// Premise-derived trust for a LIVE-CHASE-ONLY entailment answer; omitted
|
|
15912
16292
|
// entirely when this turn didn't answer via one of those.
|
|
15913
16293
|
...(entailedTrust !== null ? { entailedTrust } : {}),
|
|
16294
|
+
// The automatic /prove fallback's own budget wall — the same marker
|
|
16295
|
+
// /prove's own explicit budget wall stamps, so chatbench/infbench can
|
|
16296
|
+
// count a budget miss apart from a parse miss.
|
|
16297
|
+
...(budgetExhausted ? { budgetExhausted: true } : {}),
|
|
15914
16298
|
};
|
|
15915
16299
|
const logLines = [ts, `> ${query}`, answer, ""];
|
|
15916
16300
|
// `detail` feeds why/say-more's verbose re-render: the traversal receipt + the
|
|
@@ -16419,9 +16803,10 @@ async function runCommand(line, { config, source, graph, focus, memoryDir, trace
|
|
|
16419
16803
|
// A case-split conclusion (the ⊔-rule fired on a genuine owl:unionOf
|
|
16420
16804
|
// or owl:oneOf premise, not just the ⊑-rule's own routine
|
|
16421
16805
|
// TBox-internalization disjunction, which every proof passes
|
|
16422
|
-
// through) reads as reasoning by cases, not a single deduction
|
|
16423
|
-
|
|
16424
|
-
|
|
16806
|
+
// through) reads as reasoning by cases, not a single deduction, and
|
|
16807
|
+
// names the cases it split on (result.cases, tableau.mjs's own
|
|
16808
|
+
// isGenuineDisjunction filter).
|
|
16809
|
+
const conclusion = renderProvedConclusion(result, subjectWord, classWord);
|
|
16425
16810
|
return mk(`yes — ${cited}; ${conclusion}`);
|
|
16426
16811
|
}
|
|
16427
16812
|
if (result.status === "disproved") {
|
|
@@ -18078,20 +18463,36 @@ async function dispatchTurn(input, { config, source = defaultSource, graph = nul
|
|
|
18078
18463
|
turn.lane = "ask-choice";
|
|
18079
18464
|
turn.detail = {
|
|
18080
18465
|
traversal: `${grounded.length} of ${probed.length} options grounded against "${parsed.sourceTerm}"`,
|
|
18081
|
-
matches: grounded.flatMap((o) => o.facts),
|
|
18466
|
+
matches: grounded.flatMap((o) => (o.facts.length ? o.facts : o.chain || [])),
|
|
18082
18467
|
};
|
|
18083
18468
|
return withLast(turn, choiceGoal);
|
|
18084
18469
|
}
|
|
18085
18470
|
const winner = grounded[0];
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18471
|
+
// Direct edge first; a chain (rung 3) only ever fires when NO direct
|
|
18472
|
+
// edge exists for the winning option — probeChoiceOptions' own guard.
|
|
18473
|
+
let text; let matches; let hop; let traversalNote; let matchedBy;
|
|
18474
|
+
if (winner.facts.length > 0) {
|
|
18475
|
+
const fact = winner.facts.slice().sort((a, b) => b.trust - a.trust)[0];
|
|
18476
|
+
text = `${winner.text} — ${factPhrase(fact)} (source: ${citationProvenance(fact.provenance)}).`;
|
|
18477
|
+
matches = winner.facts;
|
|
18478
|
+
hop = 1;
|
|
18479
|
+
matchedBy = fact.matchedBy;
|
|
18480
|
+
traversalNote = `option "${winner.label}" grounded against "${parsed.sourceTerm}" via ${fact.predicate}`;
|
|
18481
|
+
} else {
|
|
18482
|
+
text = `${winner.text} — ${renderIsaChain(winner.chain)}.`;
|
|
18483
|
+
matches = winner.chain;
|
|
18484
|
+
hop = winner.chain.length;
|
|
18485
|
+
traversalNote = `option "${winner.label}" grounded against "${parsed.sourceTerm}" via a ${winner.chain.length}-hop isa chain`;
|
|
18486
|
+
}
|
|
18487
|
+
note(trace, `lane: splitChoiceQuestion — exactly one option ("${winner.label}") grounds against "${parsed.sourceTerm}"; cited the deciding ${winner.facts.length > 0 ? "fact" : "chain"}`);
|
|
18089
18488
|
const turn = plainTurn(workingLine, text, { via: "composed", miss: false, focus, goal: choiceGoal });
|
|
18090
18489
|
turn.lane = "ask-choice";
|
|
18091
18490
|
turn.detail = {
|
|
18092
|
-
traversal:
|
|
18093
|
-
matches
|
|
18491
|
+
traversal: traversalNote,
|
|
18492
|
+
matches,
|
|
18094
18493
|
selectedLabel: winner.label,
|
|
18494
|
+
hop,
|
|
18495
|
+
...(matchedBy ? { matchedBy } : {}),
|
|
18095
18496
|
};
|
|
18096
18497
|
return withLast(turn, choiceGoal);
|
|
18097
18498
|
}
|