@mneme-ai/core 2.89.0 → 2.90.0
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/agent_manifest.d.ts.map +1 -1
- package/dist/agent_manifest.js +2 -0
- package/dist/agent_manifest.js.map +1 -1
- package/dist/gephyra/index.d.ts +12 -0
- package/dist/gephyra/index.d.ts.map +1 -1
- package/dist/gephyra/index.js +38 -0
- package/dist/gephyra/index.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/truth_gate/claims.d.ts.map +1 -1
- package/dist/truth_gate/claims.js +7 -0
- package/dist/truth_gate/claims.js.map +1 -1
- package/dist/truth_gate/probes.d.ts.map +1 -1
- package/dist/truth_gate/probes.js +53 -0
- package/dist/truth_gate/probes.js.map +1 -1
- package/dist/truth_kernel/compound.d.ts +55 -0
- package/dist/truth_kernel/compound.d.ts.map +1 -0
- package/dist/truth_kernel/compound.js +72 -0
- package/dist/truth_kernel/compound.js.map +1 -0
- package/dist/truth_kernel/gauntlet_public.d.ts +37 -0
- package/dist/truth_kernel/gauntlet_public.d.ts.map +1 -0
- package/dist/truth_kernel/gauntlet_public.js +81 -0
- package/dist/truth_kernel/gauntlet_public.js.map +1 -0
- package/dist/truth_kernel/savant_diamonds.test.d.ts +11 -0
- package/dist/truth_kernel/savant_diamonds.test.d.ts.map +1 -0
- package/dist/truth_kernel/savant_diamonds.test.js +137 -0
- package/dist/truth_kernel/savant_diamonds.test.js.map +1 -0
- package/dist/truth_kernel/symbiosis.d.ts +54 -0
- package/dist/truth_kernel/symbiosis.d.ts.map +1 -0
- package/dist/truth_kernel/symbiosis.js +98 -0
- package/dist/truth_kernel/symbiosis.js.map +1 -0
- package/dist/truth_kernel/truth_mesh.d.ts +63 -0
- package/dist/truth_kernel/truth_mesh.d.ts.map +1 -0
- package/dist/truth_kernel/truth_mesh.js +124 -0
- package/dist/truth_kernel/truth_mesh.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.90.0 — 💎③ IDLE COMPOUNDING · the savant sharpens in its sleep.
|
|
3
|
+
*
|
|
4
|
+
* A daemon's idle window is wasted time for an LLM (its weights are frozen). For the
|
|
5
|
+
* savant it's when it gets SHARPER: it consolidates the many corroborating ACTIVE
|
|
6
|
+
* truths in the Axiom Lattice into fewer, higher-SUPPORT axioms, and quarantines any
|
|
7
|
+
* subject where the active truths conflict (a contested subject is NOT an axiom).
|
|
8
|
+
*
|
|
9
|
+
* Pure + deterministic + idempotent: this is a READ-ONLY projection over the lattice
|
|
10
|
+
* (it never mutates it), so re-running yields the identical axiom set + the identical
|
|
11
|
+
* signed digest — the savant's current, provable axiom base, attestable offline.
|
|
12
|
+
* Never throws.
|
|
13
|
+
*/
|
|
14
|
+
import { type NotaryReceipt } from "../notary/index.js";
|
|
15
|
+
export interface Axiom {
|
|
16
|
+
subject: string;
|
|
17
|
+
/** A representative claim for the subject (the earliest ACTIVE one). */
|
|
18
|
+
claim: string;
|
|
19
|
+
verdict: "TRUE" | "FALSE";
|
|
20
|
+
/** How many ACTIVE lattice nodes corroborate this verdict on this subject. */
|
|
21
|
+
support: number;
|
|
22
|
+
nodeIds: string[];
|
|
23
|
+
/** True once support ≥ minSupport — a "crystallised" high-support axiom. */
|
|
24
|
+
crystallised: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ContestedSubject {
|
|
27
|
+
subject: string;
|
|
28
|
+
claims: string[];
|
|
29
|
+
/** Why it can't be an axiom: the active truths on this subject disagree. */
|
|
30
|
+
reason: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CompoundReport {
|
|
33
|
+
totalActive: number;
|
|
34
|
+
/** Subjects whose ACTIVE truths agree → consolidated axioms (sorted by subject). */
|
|
35
|
+
axioms: Axiom[];
|
|
36
|
+
/** Subjects with conflicting ACTIVE verdicts → quarantined, NOT axioms. */
|
|
37
|
+
contested: ContestedSubject[];
|
|
38
|
+
/** Count of crystallised (high-support) axioms. */
|
|
39
|
+
crystallisedCount: number;
|
|
40
|
+
/** NOTARY-signed digest over the axiom set — the savant's attestable axiom base. */
|
|
41
|
+
receipt: NotaryReceipt | null;
|
|
42
|
+
summary: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Consolidate the lattice's ACTIVE truths into axioms. A subject becomes an axiom
|
|
46
|
+
* iff all its ACTIVE non-UNKNOWN nodes agree on one verdict; if they conflict it is
|
|
47
|
+
* CONTESTED (quarantined). Deterministic (sorted) + idempotent (read-only). Signs the
|
|
48
|
+
* resulting axiom set so "what the savant currently holds as proven" is verifiable.
|
|
49
|
+
*/
|
|
50
|
+
export declare function compoundLattice(repoRoot: string, opts?: {
|
|
51
|
+
minSupport?: number;
|
|
52
|
+
issuedAt?: number;
|
|
53
|
+
noSign?: boolean;
|
|
54
|
+
}): CompoundReport;
|
|
55
|
+
//# sourceMappingURL=compound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound.d.ts","sourceRoot":"","sources":["../../src/truth_kernel/compound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4EAA4E;IAC5E,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,2EAA2E;IAC3E,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,mDAAmD;IACnD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,cAAc,CAiDzI"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.90.0 — 💎③ IDLE COMPOUNDING · the savant sharpens in its sleep.
|
|
3
|
+
*
|
|
4
|
+
* A daemon's idle window is wasted time for an LLM (its weights are frozen). For the
|
|
5
|
+
* savant it's when it gets SHARPER: it consolidates the many corroborating ACTIVE
|
|
6
|
+
* truths in the Axiom Lattice into fewer, higher-SUPPORT axioms, and quarantines any
|
|
7
|
+
* subject where the active truths conflict (a contested subject is NOT an axiom).
|
|
8
|
+
*
|
|
9
|
+
* Pure + deterministic + idempotent: this is a READ-ONLY projection over the lattice
|
|
10
|
+
* (it never mutates it), so re-running yields the identical axiom set + the identical
|
|
11
|
+
* signed digest — the savant's current, provable axiom base, attestable offline.
|
|
12
|
+
* Never throws.
|
|
13
|
+
*/
|
|
14
|
+
import { readLattice } from "./lattice.js";
|
|
15
|
+
import { issueReceipt } from "../notary/index.js";
|
|
16
|
+
/**
|
|
17
|
+
* Consolidate the lattice's ACTIVE truths into axioms. A subject becomes an axiom
|
|
18
|
+
* iff all its ACTIVE non-UNKNOWN nodes agree on one verdict; if they conflict it is
|
|
19
|
+
* CONTESTED (quarantined). Deterministic (sorted) + idempotent (read-only). Signs the
|
|
20
|
+
* resulting axiom set so "what the savant currently holds as proven" is verifiable.
|
|
21
|
+
*/
|
|
22
|
+
export function compoundLattice(repoRoot, opts = {}) {
|
|
23
|
+
const minSupport = Math.max(1, opts.minSupport ?? 2);
|
|
24
|
+
const active = readLattice(repoRoot).filter((n) => n.status === "ACTIVE" && (n.verdict === "TRUE" || n.verdict === "FALSE"));
|
|
25
|
+
// Group by subject (stable insertion via Map; keys sorted at the end for determinism).
|
|
26
|
+
const bySubject = new Map();
|
|
27
|
+
for (const n of active) {
|
|
28
|
+
if (!n.subject)
|
|
29
|
+
continue;
|
|
30
|
+
const arr = bySubject.get(n.subject) ?? [];
|
|
31
|
+
arr.push(n);
|
|
32
|
+
bySubject.set(n.subject, arr);
|
|
33
|
+
}
|
|
34
|
+
const axioms = [];
|
|
35
|
+
const contested = [];
|
|
36
|
+
for (const subject of [...bySubject.keys()].sort()) {
|
|
37
|
+
const nodes = bySubject.get(subject);
|
|
38
|
+
const verdicts = new Set(nodes.map((n) => n.verdict));
|
|
39
|
+
if (verdicts.size > 1) {
|
|
40
|
+
contested.push({ subject, claims: nodes.map((n) => n.claim), reason: "active truths disagree on this subject" });
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const verdict = nodes[0].verdict;
|
|
44
|
+
const support = nodes.length;
|
|
45
|
+
axioms.push({
|
|
46
|
+
subject,
|
|
47
|
+
claim: nodes[0].claim,
|
|
48
|
+
verdict,
|
|
49
|
+
support,
|
|
50
|
+
nodeIds: nodes.map((n) => n.id),
|
|
51
|
+
crystallised: support >= minSupport,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const crystallisedCount = axioms.filter((a) => a.crystallised).length;
|
|
55
|
+
let receipt = null;
|
|
56
|
+
if (!opts.noSign) {
|
|
57
|
+
try {
|
|
58
|
+
receipt = issueReceipt(repoRoot, {
|
|
59
|
+
kind: "memory-capsule",
|
|
60
|
+
subject: `aletheia-axioms:${axioms.length}`,
|
|
61
|
+
payload: { engine: "aletheia-compound", axioms: axioms.map((a) => ({ subject: a.subject, verdict: a.verdict, support: a.support })), contested: contested.length },
|
|
62
|
+
issuedAt: opts.issuedAt,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
receipt = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const summary = `compounded ${active.length} active truth(s) → ${axioms.length} axiom(s) (${crystallisedCount} crystallised, support≥${minSupport}) · ${contested.length} contested subject(s) quarantined`;
|
|
70
|
+
return { totalActive: active.length, axioms, contested, crystallisedCount, receipt, summary };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=compound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound.js","sourceRoot":"","sources":["../../src/truth_kernel/compound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAsB,MAAM,oBAAoB,CAAC;AAkCtE;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,OAAqE,EAAE;IACvH,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC;IAE7H,uFAAuF;IACvF,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB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anyone can rerun.
|
|
3
|
+
*
|
|
4
|
+
* A claim of superhuman honesty is worthless unless a stranger can reproduce it. The
|
|
5
|
+
* Public Gauntlet ships a FIXED, labeled corpus (provable truths · provable falsehoods
|
|
6
|
+
* · genuinely-unprovable claims) and runs it through the savant spine, producing the
|
|
7
|
+
* three numbers a savant beats every LLM on — and SIGNS the report so a third party
|
|
8
|
+
* verifies the result offline with the public key alone:
|
|
9
|
+
*
|
|
10
|
+
* false-assertion rate → 0% (the savant abstains instead of guessing)
|
|
11
|
+
* forget rate → 0% (every verdict re-verifies)
|
|
12
|
+
* provability → 100% (a signed lineage on every definite verdict)
|
|
13
|
+
*
|
|
14
|
+
* Deterministic (fixed corpus + injectable issuedAt). Never throws.
|
|
15
|
+
*/
|
|
16
|
+
import { type GauntletCase, type SavantGauntletReport, type AletheiaOpts } from "./aletheia.js";
|
|
17
|
+
import { type NotaryReceipt } from "../notary/index.js";
|
|
18
|
+
/** The pinned public corpus. Arithmetic/structural truths are provable from first
|
|
19
|
+
* principles (so any machine reproduces the verdict); the unprovable rows are
|
|
20
|
+
* genuinely unknowable, so an honest savant MUST abstain on them. */
|
|
21
|
+
export declare const PUBLIC_GAUNTLET_CORPUS: readonly GauntletCase[];
|
|
22
|
+
export interface PublicGauntletReport extends SavantGauntletReport {
|
|
23
|
+
corpusSize: number;
|
|
24
|
+
/** True iff false-assertion 0% AND forget 0% AND provability 100% AND abstention 100%. */
|
|
25
|
+
passed: boolean;
|
|
26
|
+
/** Signed report card — verify offline with the public key. */
|
|
27
|
+
receipt: NotaryReceipt | null;
|
|
28
|
+
}
|
|
29
|
+
/** Run the pinned public corpus through the savant + sign the report. Never throws. */
|
|
30
|
+
export declare function runPublicGauntlet(repoRoot: string, opts?: AletheiaOpts): Promise<PublicGauntletReport>;
|
|
31
|
+
/** Verify a Public Gauntlet report card offline (signature valid + it reports a pass). */
|
|
32
|
+
export declare function verifyGauntletReport(receipt: NotaryReceipt | null): {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
passed: boolean;
|
|
35
|
+
reason: string;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=gauntlet_public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gauntlet_public.d.ts","sourceRoot":"","sources":["../../src/truth_kernel/gauntlet_public.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAqB,KAAK,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACnH,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErF;;sEAEsE;AACtE,eAAO,MAAM,sBAAsB,EAAE,SAAS,YAAY,EAiBhD,CAAC;AAEX,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,MAAM,EAAE,OAAO,CAAC;IAChB,+DAA+D;IAC/D,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;CAC/B;AAED,uFAAuF;AACvF,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmBhH;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQvH"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.90.0 — 💎④ PUBLIC SAVANT GAUNTLET · the falsifiable proof, anyone can rerun.
|
|
3
|
+
*
|
|
4
|
+
* A claim of superhuman honesty is worthless unless a stranger can reproduce it. The
|
|
5
|
+
* Public Gauntlet ships a FIXED, labeled corpus (provable truths · provable falsehoods
|
|
6
|
+
* · genuinely-unprovable claims) and runs it through the savant spine, producing the
|
|
7
|
+
* three numbers a savant beats every LLM on — and SIGNS the report so a third party
|
|
8
|
+
* verifies the result offline with the public key alone:
|
|
9
|
+
*
|
|
10
|
+
* false-assertion rate → 0% (the savant abstains instead of guessing)
|
|
11
|
+
* forget rate → 0% (every verdict re-verifies)
|
|
12
|
+
* provability → 100% (a signed lineage on every definite verdict)
|
|
13
|
+
*
|
|
14
|
+
* Deterministic (fixed corpus + injectable issuedAt). Never throws.
|
|
15
|
+
*/
|
|
16
|
+
import { runSavantGauntlet } from "./aletheia.js";
|
|
17
|
+
import { issueReceipt, verifyReceipt } from "../notary/index.js";
|
|
18
|
+
/** The pinned public corpus. Arithmetic/structural truths are provable from first
|
|
19
|
+
* principles (so any machine reproduces the verdict); the unprovable rows are
|
|
20
|
+
* genuinely unknowable, so an honest savant MUST abstain on them. */
|
|
21
|
+
export const PUBLIC_GAUNTLET_CORPUS = [
|
|
22
|
+
// provable truths
|
|
23
|
+
{ claim: "2+2=4", truth: "TRUE" },
|
|
24
|
+
{ claim: "10*10=100", truth: "TRUE" },
|
|
25
|
+
{ claim: "100-1=99", truth: "TRUE" },
|
|
26
|
+
{ claim: "7*8=56", truth: "TRUE" },
|
|
27
|
+
{ claim: "144/12=12", truth: "TRUE" },
|
|
28
|
+
// provable falsehoods
|
|
29
|
+
{ claim: "2+2=5", truth: "FALSE" },
|
|
30
|
+
{ claim: "9*9=80", truth: "FALSE" },
|
|
31
|
+
{ claim: "100-1=98", truth: "FALSE" },
|
|
32
|
+
{ claim: "3*3=10", truth: "FALSE" },
|
|
33
|
+
// genuinely unprovable — the savant MUST say UNKNOWN
|
|
34
|
+
{ claim: "The stock market will rise 3.2% next Tuesday", truth: "UNPROVABLE" },
|
|
35
|
+
{ claim: "There are exactly 1000037 grains of sand in that jar", truth: "UNPROVABLE" },
|
|
36
|
+
{ claim: "The 9001st visitor tomorrow will be wearing a red hat", truth: "UNPROVABLE" },
|
|
37
|
+
{ claim: "The number of leaves on that tree is even", truth: "UNPROVABLE" },
|
|
38
|
+
];
|
|
39
|
+
/** Run the pinned public corpus through the savant + sign the report. Never throws. */
|
|
40
|
+
export async function runPublicGauntlet(repoRoot, opts = {}) {
|
|
41
|
+
const base = await runSavantGauntlet(repoRoot, PUBLIC_GAUNTLET_CORPUS, opts);
|
|
42
|
+
const passed = base.falseAssertionRate === 0 && base.forgetRate === 0 && base.provability === 1 && base.abstentionRate === 1;
|
|
43
|
+
let receipt = null;
|
|
44
|
+
if (!opts.noSign) {
|
|
45
|
+
try {
|
|
46
|
+
receipt = issueReceipt(repoRoot, {
|
|
47
|
+
kind: "claim-verdict",
|
|
48
|
+
subject: `savant-gauntlet:${PUBLIC_GAUNTLET_CORPUS.length}`,
|
|
49
|
+
payload: {
|
|
50
|
+
engine: "aletheia-public-gauntlet",
|
|
51
|
+
falseAssertionRate: base.falseAssertionRate, forgetRate: base.forgetRate,
|
|
52
|
+
provability: base.provability, abstentionRate: base.abstentionRate, passed,
|
|
53
|
+
},
|
|
54
|
+
issuedAt: opts.issuedAt,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
receipt = null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { ...base, corpusSize: PUBLIC_GAUNTLET_CORPUS.length, passed, receipt };
|
|
62
|
+
}
|
|
63
|
+
/** Verify a Public Gauntlet report card offline (signature valid + it reports a pass). */
|
|
64
|
+
export function verifyGauntletReport(receipt) {
|
|
65
|
+
if (!receipt)
|
|
66
|
+
return { valid: false, passed: false, reason: "no receipt" };
|
|
67
|
+
let v;
|
|
68
|
+
try {
|
|
69
|
+
v = verifyReceipt(receipt);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
return { valid: false, passed: false, reason: `verify threw: ${e.message}` };
|
|
73
|
+
}
|
|
74
|
+
if (!v.valid)
|
|
75
|
+
return { valid: false, passed: false, reason: v.reason };
|
|
76
|
+
const pl = (receipt.payload ?? {});
|
|
77
|
+
if (pl.engine !== "aletheia-public-gauntlet")
|
|
78
|
+
return { valid: true, passed: false, reason: "not a gauntlet report" };
|
|
79
|
+
return { valid: true, passed: pl.passed === true, reason: pl.passed ? "signed pass" : "signed but did not pass" };
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=gauntlet_public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gauntlet_public.js","sourceRoot":"","sources":["../../src/truth_kernel/gauntlet_public.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,iBAAiB,EAAmE,MAAM,eAAe,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AAErF;;sEAEsE;AACtE,MAAM,CAAC,MAAM,sBAAsB,GAA4B;IAC7D,kBAAkB;IAClB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;IACjC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE;IACrC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;IACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE;IAClC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE;IACrC,sBAAsB;IACtB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAClC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;IACnC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE;IACrC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;IACnC,qDAAqD;IACrD,EAAE,KAAK,EAAE,8CAA8C,EAAE,KAAK,EAAE,YAAY,EAAE;IAC9E,EAAE,KAAK,EAAE,sDAAsD,EAAE,KAAK,EAAE,YAAY,EAAE;IACtF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AA6B;IAChE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAC3E,IAAI,CAAC,CAAC;IACN,IAAI,CAAC;QAAC,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAAC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAkB,CAAW,CAAC,OAAO,EAAE,EAAE,CAAC;IAAC,CAAC;IAC1I,IAAI,CAAC,CAAC,CAAC,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACvE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAA0C,CAAC;IAC5E,IAAI,EAAE,CAAC,MAAM,KAAK,0BAA0B;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC;IACrH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,yBAAyB,EAAE,CAAC;AACpH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.90.0 — 💎 the four remaining savant diamonds.
|
|
3
|
+
*
|
|
4
|
+
* ② SYMBIOSIS — extractClaims / repairDraft (FALSE→correct, UNKNOWN→flag, TRUE→keep, prose untouched)
|
|
5
|
+
* ③ COMPOUNDING — consolidate ACTIVE truths → axioms; contested subjects quarantined; idempotent + signed
|
|
6
|
+
* ④ PUBLIC GAUNTLET — pinned corpus passes (0/0/100/100) + signed report verifies offline; tamper caught
|
|
7
|
+
* ⑤ TRUTH MESH — export signed bundle; merge verifies sigs (forged dropped, claim-swap dropped),
|
|
8
|
+
* surfaces conflicts, idempotent
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=savant_diamonds.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"savant_diamonds.test.d.ts","sourceRoot":"","sources":["../../src/truth_kernel/savant_diamonds.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.90.0 — 💎 the four remaining savant diamonds.
|
|
3
|
+
*
|
|
4
|
+
* ② SYMBIOSIS — extractClaims / repairDraft (FALSE→correct, UNKNOWN→flag, TRUE→keep, prose untouched)
|
|
5
|
+
* ③ COMPOUNDING — consolidate ACTIVE truths → axioms; contested subjects quarantined; idempotent + signed
|
|
6
|
+
* ④ PUBLIC GAUNTLET — pinned corpus passes (0/0/100/100) + signed report verifies offline; tamper caught
|
|
7
|
+
* ⑤ TRUTH MESH — export signed bundle; merge verifies sigs (forged dropped, claim-swap dropped),
|
|
8
|
+
* surfaces conflicts, idempotent
|
|
9
|
+
*/
|
|
10
|
+
import { describe, it, expect } from "vitest";
|
|
11
|
+
import { mkdtempSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { extractClaims, isCheckableClaim, repairDraft, symbioticVerify } from "./symbiosis.js";
|
|
15
|
+
import { compoundLattice } from "./compound.js";
|
|
16
|
+
import { runPublicGauntlet, verifyGauntletReport, PUBLIC_GAUNTLET_CORPUS } from "./gauntlet_public.js";
|
|
17
|
+
import { exportTruths, mergeTruths } from "./truth_mesh.js";
|
|
18
|
+
import { assertClaim } from "./aletheia.js";
|
|
19
|
+
function repo() { return mkdtempSync(join(tmpdir(), "diamonds-")); }
|
|
20
|
+
const T = 1_700_000_000_000;
|
|
21
|
+
describe("v2.90.0 💎② SAVANT SYMBIOSIS", () => {
|
|
22
|
+
it("S1 isCheckableClaim / extractClaims — checkable vs prose", () => {
|
|
23
|
+
expect(isCheckableClaim("2+2=5")).toBe(true);
|
|
24
|
+
expect(isCheckableClaim("React 19 ships RSC by default")).toBe(true);
|
|
25
|
+
expect(isCheckableClaim("What should we do next?")).toBe(false); // question
|
|
26
|
+
expect(isCheckableClaim("Let's think carefully")).toBe(false); // vibe
|
|
27
|
+
const claims = extractClaims("Let's begin. The value is 2+2=5. Nice work everyone.");
|
|
28
|
+
expect(claims).toContain("The value is 2+2=5.");
|
|
29
|
+
expect(claims.some((c) => c.includes("Nice work"))).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
it("S2 repairDraft — FALSE corrected, UNKNOWN flagged, TRUE & prose kept", async () => {
|
|
32
|
+
const r = await repairDraft(repo(), "Intro sentence. 2+2=5. 10*10=100. The 9000th visitor tomorrow wears red.", { issuedAt: T });
|
|
33
|
+
expect(r.changed).toBe(true);
|
|
34
|
+
expect(r.falseCount).toBe(1);
|
|
35
|
+
expect(r.unknownCount).toBe(1);
|
|
36
|
+
expect(r.trueCount).toBe(1);
|
|
37
|
+
expect(r.repaired).toMatch(/✗ savant: FALSE/); // the 2+2=5 got a correction marker
|
|
38
|
+
expect(r.repaired).toMatch(/UNVERIFIED/); // the unprovable got flagged
|
|
39
|
+
expect(r.repaired).toContain("Intro sentence."); // prose untouched
|
|
40
|
+
});
|
|
41
|
+
it("S3 symbioticVerify single-claim hook never throws + 3-valued", async () => {
|
|
42
|
+
const v = await symbioticVerify(repo(), "2+2=5", { issuedAt: T });
|
|
43
|
+
expect(v.verdict).toBe("FALSE");
|
|
44
|
+
expect(["TRUE", "FALSE", "UNKNOWN"]).toContain((await symbioticVerify(repo(), " ", { issuedAt: T })).verdict);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("v2.90.0 💎③ IDLE COMPOUNDING", () => {
|
|
48
|
+
it("C1 consolidates corroborating truths → crystallised axiom; idempotent; signed", async () => {
|
|
49
|
+
const r = repo();
|
|
50
|
+
await assertClaim(r, "2+2=4", { record: true, issuedAt: T });
|
|
51
|
+
await assertClaim(r, "2+2=4", { record: true, issuedAt: T, sensors: [{ id: "x", weight: 2, run: () => ({ sensor: "x", verdict: "TRUE", confidence: 1 }) }] });
|
|
52
|
+
const c1 = compoundLattice(r, { issuedAt: T });
|
|
53
|
+
expect(c1.axioms.length).toBe(1);
|
|
54
|
+
expect(c1.axioms[0].support).toBe(2);
|
|
55
|
+
expect(c1.axioms[0].crystallised).toBe(true);
|
|
56
|
+
expect(c1.receipt).not.toBeNull();
|
|
57
|
+
// idempotent: re-running yields the same axiom set
|
|
58
|
+
const c2 = compoundLattice(r, { issuedAt: T });
|
|
59
|
+
expect(c2.axioms.length).toBe(c1.axioms.length);
|
|
60
|
+
expect(c2.crystallisedCount).toBe(c1.crystallisedCount);
|
|
61
|
+
});
|
|
62
|
+
it("C2 contested subject (conflicting active verdicts) is quarantined, NOT an axiom", async () => {
|
|
63
|
+
const r = repo();
|
|
64
|
+
await assertClaim(r, "the widget is enabled", { record: true, issuedAt: T, sensors: [{ id: "t", weight: 2, run: () => ({ sensor: "t", verdict: "TRUE", confidence: 1 }) }] });
|
|
65
|
+
await assertClaim(r, "the widget is enabled", { record: true, issuedAt: T, sensors: [{ id: "f", weight: 2, run: () => ({ sensor: "f", verdict: "FALSE", confidence: 1 }) }] });
|
|
66
|
+
const c = compoundLattice(r, { issuedAt: T });
|
|
67
|
+
expect(c.contested.length).toBe(1);
|
|
68
|
+
expect(c.axioms.find((a) => a.subject === c.contested[0].subject)).toBeUndefined();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("v2.90.0 💎④ PUBLIC SAVANT GAUNTLET", () => {
|
|
72
|
+
it("G1 the pinned corpus passes (false-assert 0 / forget 0 / provable 1 / abstain 1) + signed", async () => {
|
|
73
|
+
const g = await runPublicGauntlet(repo(), { issuedAt: T });
|
|
74
|
+
expect(g.corpusSize).toBe(PUBLIC_GAUNTLET_CORPUS.length);
|
|
75
|
+
expect(g.falseAssertionRate).toBe(0);
|
|
76
|
+
expect(g.forgetRate).toBe(0);
|
|
77
|
+
expect(g.provability).toBe(1);
|
|
78
|
+
expect(g.abstentionRate).toBe(1);
|
|
79
|
+
expect(g.passed).toBe(true);
|
|
80
|
+
expect(g.receipt).not.toBeNull();
|
|
81
|
+
});
|
|
82
|
+
it("G2 the signed report verifies offline; a tampered report is caught", async () => {
|
|
83
|
+
const g = await runPublicGauntlet(repo(), { issuedAt: T });
|
|
84
|
+
const v = verifyGauntletReport(g.receipt);
|
|
85
|
+
expect(v.valid).toBe(true);
|
|
86
|
+
expect(v.passed).toBe(true);
|
|
87
|
+
// forge the pass flag → signature breaks
|
|
88
|
+
const forged = JSON.parse(JSON.stringify(g.receipt));
|
|
89
|
+
forged.payload.passed = true;
|
|
90
|
+
forged.payload.falseAssertionRate = 0.5;
|
|
91
|
+
expect(verifyGauntletReport(forged).valid).toBe(false);
|
|
92
|
+
expect(verifyGauntletReport(null).valid).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe("v2.90.0 💎⑤ CROSS-AGENT TRUTH MESH", () => {
|
|
96
|
+
it("M1 export → merge adds verified truths; idempotent re-merge adds nothing", async () => {
|
|
97
|
+
const a = repo(), b = repo();
|
|
98
|
+
await assertClaim(a, "2+2=4", { record: true, issuedAt: T });
|
|
99
|
+
await assertClaim(a, "10*10=100", { record: true, issuedAt: T });
|
|
100
|
+
const bundle = exportTruths(a, "agentA", { issuedAt: T });
|
|
101
|
+
expect(bundle.truths.length).toBe(2);
|
|
102
|
+
expect(bundle.receipt).not.toBeNull();
|
|
103
|
+
const m1 = mergeTruths(b, bundle, { issuedAt: T });
|
|
104
|
+
expect(m1.added).toBe(2);
|
|
105
|
+
expect(m1.bundleVerified).toBe(true);
|
|
106
|
+
const m2 = mergeTruths(b, bundle, { issuedAt: T }); // idempotent
|
|
107
|
+
expect(m2.added).toBe(0);
|
|
108
|
+
expect(m2.duplicate).toBe(2);
|
|
109
|
+
});
|
|
110
|
+
it("M2 forgery defense — unsigned + claim-swapped truths are DROPPED", async () => {
|
|
111
|
+
const a = repo(), dest = repo();
|
|
112
|
+
await assertClaim(a, "2+2=4", { record: true, issuedAt: T });
|
|
113
|
+
const bundle = exportTruths(a, "agentA", { issuedAt: T });
|
|
114
|
+
// (a) strip the per-truth signature → must be rejected
|
|
115
|
+
const unsigned = JSON.parse(JSON.stringify(bundle));
|
|
116
|
+
unsigned.truths[0].receipt = null;
|
|
117
|
+
expect(mergeTruths(repo(), unsigned, { issuedAt: T }).rejectedUnsigned).toBe(1);
|
|
118
|
+
// (b) swap the claim text but keep the (now-mismatched) valid signature → rejected
|
|
119
|
+
const swapped = JSON.parse(JSON.stringify(bundle));
|
|
120
|
+
swapped.truths[0].claim = "2+2=999";
|
|
121
|
+
const ms = mergeTruths(dest, swapped, { issuedAt: T });
|
|
122
|
+
expect(ms.rejectedUnsigned).toBe(1);
|
|
123
|
+
expect(ms.added).toBe(0);
|
|
124
|
+
});
|
|
125
|
+
it("M3 conflicts are SURFACED, not silently merged", async () => {
|
|
126
|
+
const a = repo(), dest = repo();
|
|
127
|
+
// dest already holds "x is red" TRUE
|
|
128
|
+
await assertClaim(dest, "x is red", { record: true, issuedAt: T, sensors: [{ id: "t", weight: 2, run: () => ({ sensor: "t", verdict: "TRUE", confidence: 1 }) }] });
|
|
129
|
+
// peer A exports "x is red" FALSE
|
|
130
|
+
await assertClaim(a, "x is red", { record: true, issuedAt: T, sensors: [{ id: "f", weight: 2, run: () => ({ sensor: "f", verdict: "FALSE", confidence: 1 }) }] });
|
|
131
|
+
const bundle = exportTruths(a, "agentA", { issuedAt: T });
|
|
132
|
+
const m = mergeTruths(dest, bundle, { issuedAt: T });
|
|
133
|
+
expect(m.conflicts.length).toBe(1);
|
|
134
|
+
expect(m.added).toBe(0); // the conflicting truth was NOT merged
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=savant_diamonds.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"savant_diamonds.test.js","sourceRoot":"","sources":["../../src/truth_kernel/savant_diamonds.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,SAAS,IAAI,KAAa,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,MAAM,CAAC,GAAG,iBAAiB,CAAC;AAE5B,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,CAAC,gBAAgB,CAAC,+BAA+B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrE,MAAM,CA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AE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACpK,kCAAkC;QAClC,MAAM,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAClK,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QAC1D,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QACrD,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,uCAAuC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.90.0 — 💎② SAVANT SYMBIOSIS · the before-assert prosthesis.
|
|
3
|
+
*
|
|
4
|
+
* The whole reason a fluent LLM embeds the savant: before its answer reaches the
|
|
5
|
+
* user, it hands the draft to ALETHEIA, which fact-checks every checkable claim
|
|
6
|
+
* and hands back a REPAIRED draft — FALSE claims corrected (with evidence),
|
|
7
|
+
* UNKNOWN claims flagged "unverified" (never silently asserted), TRUE claims kept.
|
|
8
|
+
* The savant + the generalist are complementary: fluent brain, savant memory.
|
|
9
|
+
*
|
|
10
|
+
* Exposed three ways so ANY agent — MCP, HTTP/A2A, or in-process — can plug in:
|
|
11
|
+
* • in-process : repairDraft() / symbioticVerify()
|
|
12
|
+
* • MCP : mneme.savant.repair
|
|
13
|
+
* • HTTP/A2A : POST /savant/verify · POST /savant/repair (gephyra serve)
|
|
14
|
+
*
|
|
15
|
+
* Conservative by construction: only sentences that parse to a CHECKABLE claim are
|
|
16
|
+
* touched; prose is left exactly as written. Never throws.
|
|
17
|
+
*/
|
|
18
|
+
import { type AletheiaVerdict, type AletheiaOpts } from "./aletheia.js";
|
|
19
|
+
/** Does a sentence look like a CHECKABLE factual claim? Conservative: must contain
|
|
20
|
+
* a specific entity — a number/version, an equals/comparison, or a copula tying a
|
|
21
|
+
* subject to a value. Pure questions / imperatives / vibes are skipped. */
|
|
22
|
+
export declare function isCheckableClaim(sentence: string): boolean;
|
|
23
|
+
/** Extract the checkable claims from a draft (in order). */
|
|
24
|
+
export declare function extractClaims(draft: string): string[];
|
|
25
|
+
export interface VerifiedClaim {
|
|
26
|
+
claim: string;
|
|
27
|
+
verdict: AletheiaVerdict;
|
|
28
|
+
evidence: string;
|
|
29
|
+
pTrue: number;
|
|
30
|
+
receiptId: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface RepairResult {
|
|
33
|
+
/** The repaired draft: FALSE claims annotated with the correction, UNKNOWN claims
|
|
34
|
+
* flagged, TRUE claims untouched, non-claim prose untouched. */
|
|
35
|
+
repaired: string;
|
|
36
|
+
claims: VerifiedClaim[];
|
|
37
|
+
trueCount: number;
|
|
38
|
+
falseCount: number;
|
|
39
|
+
unknownCount: number;
|
|
40
|
+
/** True if anything was corrected or flagged — the agent SHOULD revise before sending. */
|
|
41
|
+
changed: boolean;
|
|
42
|
+
summary: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fact-check + repair an agent's draft answer through the savant. For every
|
|
46
|
+
* checkable claim: FALSE → keep the sentence but append a signed correction marker;
|
|
47
|
+
* UNKNOWN → append an "unverified — savant could not prove this" flag (never silently
|
|
48
|
+
* asserted); TRUE → leave it. Prose that isn't a checkable claim is passed through
|
|
49
|
+
* verbatim. Never throws — on any internal failure the original draft is returned.
|
|
50
|
+
*/
|
|
51
|
+
export declare function repairDraft(repoRoot: string, draft: string, opts?: AletheiaOpts): Promise<RepairResult>;
|
|
52
|
+
/** Single-claim before-assert hook (the minimal symbiosis call). Never throws. */
|
|
53
|
+
export declare function symbioticVerify(repoRoot: string, claim: string, opts?: AletheiaOpts): Promise<VerifiedClaim>;
|
|
54
|
+
//# sourceMappingURL=symbiosis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbiosis.d.ts","sourceRoot":"","sources":["../../src/truth_kernel/symbiosis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAUrF;;4EAE4E;AAC5E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAU1D;AAED,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B;qEACiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqBjH;AAED,kFAAkF;AAClF,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAOtH"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.90.0 — 💎② SAVANT SYMBIOSIS · the before-assert prosthesis.
|
|
3
|
+
*
|
|
4
|
+
* The whole reason a fluent LLM embeds the savant: before its answer reaches the
|
|
5
|
+
* user, it hands the draft to ALETHEIA, which fact-checks every checkable claim
|
|
6
|
+
* and hands back a REPAIRED draft — FALSE claims corrected (with evidence),
|
|
7
|
+
* UNKNOWN claims flagged "unverified" (never silently asserted), TRUE claims kept.
|
|
8
|
+
* The savant + the generalist are complementary: fluent brain, savant memory.
|
|
9
|
+
*
|
|
10
|
+
* Exposed three ways so ANY agent — MCP, HTTP/A2A, or in-process — can plug in:
|
|
11
|
+
* • in-process : repairDraft() / symbioticVerify()
|
|
12
|
+
* • MCP : mneme.savant.repair
|
|
13
|
+
* • HTTP/A2A : POST /savant/verify · POST /savant/repair (gephyra serve)
|
|
14
|
+
*
|
|
15
|
+
* Conservative by construction: only sentences that parse to a CHECKABLE claim are
|
|
16
|
+
* touched; prose is left exactly as written. Never throws.
|
|
17
|
+
*/
|
|
18
|
+
import { assertClaim } from "./aletheia.js";
|
|
19
|
+
/** Split text into sentences (keeps the terminator). Cross-language friendly. */
|
|
20
|
+
function splitSentences(text) {
|
|
21
|
+
const t = String(text ?? "");
|
|
22
|
+
// Split on sentence terminators (. ! ? newline · ; ) but keep reasonable chunks.
|
|
23
|
+
const parts = t.split(/(?<=[.!?])\s+|\n+|(?<=[;·])\s+/).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
24
|
+
return parts.length ? parts : (t.trim() ? [t.trim()] : []);
|
|
25
|
+
}
|
|
26
|
+
/** Does a sentence look like a CHECKABLE factual claim? Conservative: must contain
|
|
27
|
+
* a specific entity — a number/version, an equals/comparison, or a copula tying a
|
|
28
|
+
* subject to a value. Pure questions / imperatives / vibes are skipped. */
|
|
29
|
+
export function isCheckableClaim(sentence) {
|
|
30
|
+
const s = String(sentence ?? "").trim();
|
|
31
|
+
if (s.length < 3)
|
|
32
|
+
return false;
|
|
33
|
+
if (/[?]\s*$/.test(s))
|
|
34
|
+
return false; // a question asserts nothing
|
|
35
|
+
const hasNumber = /\d/.test(s);
|
|
36
|
+
const hasEquals = /[=<>]|≈|≠/.test(s);
|
|
37
|
+
const hasVersion = /\bv?\d+\.\d+/.test(s);
|
|
38
|
+
const hasCopula = /\b(is|are|was|were|has|have|equals|ships?|supports?|requires?|defaults?)\b|คืà¸|เป็น/i.test(s);
|
|
39
|
+
// Need an entity to check: a number/version/equals, OR a copula with some specific token.
|
|
40
|
+
return hasNumber || hasEquals || hasVersion || (hasCopula && /[A-Za-z0-9._/-]{2,}/.test(s));
|
|
41
|
+
}
|
|
42
|
+
/** Extract the checkable claims from a draft (in order). */
|
|
43
|
+
export function extractClaims(draft) {
|
|
44
|
+
return splitSentences(draft).filter(isCheckableClaim);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fact-check + repair an agent's draft answer through the savant. For every
|
|
48
|
+
* checkable claim: FALSE → keep the sentence but append a signed correction marker;
|
|
49
|
+
* UNKNOWN → append an "unverified — savant could not prove this" flag (never silently
|
|
50
|
+
* asserted); TRUE → leave it. Prose that isn't a checkable claim is passed through
|
|
51
|
+
* verbatim. Never throws — on any internal failure the original draft is returned.
|
|
52
|
+
*/
|
|
53
|
+
export async function repairDraft(repoRoot, draft, opts = {}) {
|
|
54
|
+
const original = String(draft ?? "");
|
|
55
|
+
try {
|
|
56
|
+
const sentences = splitSentences(original);
|
|
57
|
+
const claims = [];
|
|
58
|
+
let trueCount = 0, falseCount = 0, unknownCount = 0;
|
|
59
|
+
const out = [];
|
|
60
|
+
for (const sentence of sentences) {
|
|
61
|
+
if (!isCheckableClaim(sentence)) {
|
|
62
|
+
out.push(sentence);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const r = await assertClaim(repoRoot, sentence, opts);
|
|
66
|
+
claims.push({ claim: sentence, verdict: r.verdict, evidence: r.evidence, pTrue: r.pTrue, receiptId: r.receipt?.receiptId ?? null });
|
|
67
|
+
if (r.verdict === "TRUE") {
|
|
68
|
+
trueCount++;
|
|
69
|
+
out.push(sentence);
|
|
70
|
+
}
|
|
71
|
+
else if (r.verdict === "FALSE") {
|
|
72
|
+
falseCount++;
|
|
73
|
+
out.push(`${sentence} ⟨✗ savant: FALSE — ${r.evidence}⟩`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
unknownCount++;
|
|
77
|
+
out.push(`${sentence} ⟨? savant: UNVERIFIED — could not prove; do not assert as fact⟩`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const changed = falseCount > 0 || unknownCount > 0;
|
|
81
|
+
const summary = `savant checked ${claims.length} claim(s): ${trueCount} proven · ${falseCount} false · ${unknownCount} unverified`;
|
|
82
|
+
return { repaired: out.join(" "), claims, trueCount, falseCount, unknownCount, changed, summary };
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return { repaired: original, claims: [], trueCount: 0, falseCount: 0, unknownCount: 0, changed: false, summary: "savant repair unavailable — draft unchanged" };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Single-claim before-assert hook (the minimal symbiosis call). Never throws. */
|
|
89
|
+
export async function symbioticVerify(repoRoot, claim, opts = {}) {
|
|
90
|
+
try {
|
|
91
|
+
const r = await assertClaim(repoRoot, claim, opts);
|
|
92
|
+
return { claim, verdict: r.verdict, evidence: r.evidence, pTrue: r.pTrue, receiptId: r.receipt?.receiptId ?? null };
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return { claim, verdict: "UNKNOWN", evidence: "savant unavailable — treat as UNKNOWN (never guess)", pTrue: 0.5, receiptId: null };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=symbiosis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbiosis.js","sourceRoot":"","sources":["../../src/truth_kernel/symbiosis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAA2C,MAAM,eAAe,CAAC;AAErF,iFAAiF;AACjF,SAAS,cAAc,CAAC,IAAY;IAClC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC7B,iFAAiF;IACjF,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzG,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;4EAE4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,CAAC,GAAG,MAAM,CAAC,QAA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