@mneme-ai/core 2.89.0 โ†’ 2.91.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.
Files changed (46) hide show
  1. package/dist/agent_manifest.d.ts.map +1 -1
  2. package/dist/agent_manifest.js +4 -0
  3. package/dist/agent_manifest.js.map +1 -1
  4. package/dist/gephyra/index.d.ts +12 -0
  5. package/dist/gephyra/index.d.ts.map +1 -1
  6. package/dist/gephyra/index.js +38 -0
  7. package/dist/gephyra/index.js.map +1 -1
  8. package/dist/index.d.ts +5 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +21 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/truth_gate/claims.d.ts.map +1 -1
  13. package/dist/truth_gate/claims.js +14 -0
  14. package/dist/truth_gate/claims.js.map +1 -1
  15. package/dist/truth_gate/probes.d.ts.map +1 -1
  16. package/dist/truth_gate/probes.js +94 -0
  17. package/dist/truth_gate/probes.js.map +1 -1
  18. package/dist/truth_kernel/anamnesis.d.ts +172 -0
  19. package/dist/truth_kernel/anamnesis.d.ts.map +1 -0
  20. package/dist/truth_kernel/anamnesis.js +335 -0
  21. package/dist/truth_kernel/anamnesis.js.map +1 -0
  22. package/dist/truth_kernel/anamnesis.test.d.ts +15 -0
  23. package/dist/truth_kernel/anamnesis.test.d.ts.map +1 -0
  24. package/dist/truth_kernel/anamnesis.test.js +136 -0
  25. package/dist/truth_kernel/anamnesis.test.js.map +1 -0
  26. package/dist/truth_kernel/compound.d.ts +55 -0
  27. package/dist/truth_kernel/compound.d.ts.map +1 -0
  28. package/dist/truth_kernel/compound.js +72 -0
  29. package/dist/truth_kernel/compound.js.map +1 -0
  30. package/dist/truth_kernel/gauntlet_public.d.ts +37 -0
  31. package/dist/truth_kernel/gauntlet_public.d.ts.map +1 -0
  32. package/dist/truth_kernel/gauntlet_public.js +81 -0
  33. package/dist/truth_kernel/gauntlet_public.js.map +1 -0
  34. package/dist/truth_kernel/savant_diamonds.test.d.ts +11 -0
  35. package/dist/truth_kernel/savant_diamonds.test.d.ts.map +1 -0
  36. package/dist/truth_kernel/savant_diamonds.test.js +137 -0
  37. package/dist/truth_kernel/savant_diamonds.test.js.map +1 -0
  38. package/dist/truth_kernel/symbiosis.d.ts +54 -0
  39. package/dist/truth_kernel/symbiosis.d.ts.map +1 -0
  40. package/dist/truth_kernel/symbiosis.js +98 -0
  41. package/dist/truth_kernel/symbiosis.js.map +1 -0
  42. package/dist/truth_kernel/truth_mesh.d.ts +63 -0
  43. package/dist/truth_kernel/truth_mesh.d.ts.map +1 -0
  44. package/dist/truth_kernel/truth_mesh.js +124 -0
  45. package/dist/truth_kernel/truth_mesh.js.map +1 -0
  46. package/package.json +1 -1
@@ -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,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/B,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,6BAA6B;IAClE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,SA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B,EAAE,KAAa,EAAE,OAAqB,EAAE;IAC5F,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,CAAC;IACtH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,qDAAqD,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACrI,CAAC;AACH,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * v2.90.0 โ€” ๐Ÿ’Žโ‘ค CROSS-AGENT TRUTH MESH ยท the multiverse truth substrate.
3
+ *
4
+ * One savant's Axiom Lattice is a private brain. The Truth Mesh lets MANY savants
5
+ * (across vendors, machines, agents) share PROVEN truths without a central server:
6
+ * each exports a SIGNED bundle of its ACTIVE truths; a peer MERGES it after
7
+ * verifying every signature offline โ€” adding non-conflicting truths, DROPPING
8
+ * forged/invalid ones, and SURFACING (never silently resolving) any truth that
9
+ * CONTRADICTS what the peer already holds. CRDT-style: commutative + idempotent
10
+ * (re-merging the same bundle changes nothing). Never throws.
11
+ *
12
+ * This is how the savant becomes the backbone of the AI multiverse: a tamper-evident,
13
+ * vendor-neutral, offline-verifiable fabric of facts that compounds as more agents join.
14
+ */
15
+ import { type NotaryReceipt } from "../notary/index.js";
16
+ import type { AletheiaVerdict } from "./aletheia.js";
17
+ export interface MeshTruth {
18
+ claim: string;
19
+ subject: string;
20
+ verdict: AletheiaVerdict;
21
+ pTrue: number;
22
+ /** Per-truth signature (so a single truth is verifiable in isolation). */
23
+ receipt: NotaryReceipt | null;
24
+ }
25
+ export interface TruthBundle {
26
+ v: 1;
27
+ /** Who exported it (opaque agent id). */
28
+ agent: string;
29
+ truths: MeshTruth[];
30
+ /** Signature over the whole bundle. */
31
+ receipt: NotaryReceipt | null;
32
+ }
33
+ /** Export this savant's ACTIVE truths as a signed, portable bundle. Never throws. */
34
+ export declare function exportTruths(repoRoot: string, agent: string, opts?: {
35
+ issuedAt?: number;
36
+ }): TruthBundle;
37
+ export interface MergeResult {
38
+ /** Truths added to the local lattice. */
39
+ added: number;
40
+ /** Truths skipped because already present (idempotence). */
41
+ duplicate: number;
42
+ /** Truths dropped because their signature was missing/invalid (forgery defense). */
43
+ rejectedUnsigned: number;
44
+ /** Truths that CONTRADICT a local ACTIVE truth โ€” surfaced, NOT merged. */
45
+ conflicts: Array<{
46
+ claim: string;
47
+ verdict: AletheiaVerdict;
48
+ against: string;
49
+ }>;
50
+ /** True iff the incoming bundle's own signature verified. */
51
+ bundleVerified: boolean;
52
+ summary: string;
53
+ }
54
+ /**
55
+ * Merge an incoming signed bundle into the local lattice. Verifies the bundle's
56
+ * signature + every per-truth signature OFFLINE; an unsigned/forged truth is DROPPED.
57
+ * A truth that contradicts a local ACTIVE truth is SURFACED (the savant doesn't
58
+ * silently pick a winner). Duplicates are skipped โ†’ idempotent + commutative. Never throws.
59
+ */
60
+ export declare function mergeTruths(repoRoot: string, bundle: TruthBundle, opts?: {
61
+ issuedAt?: number;
62
+ }): MergeResult;
63
+ //# sourceMappingURL=truth_mesh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"truth_mesh.d.ts","sourceRoot":"","sources":["../../src/truth_kernel/truth_mesh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,C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esh lets MANY savants
5
+ * (across vendors, machines, agents) share PROVEN truths without a central server:
6
+ * each exports a SIGNED bundle of its ACTIVE truths; a peer MERGES it after
7
+ * verifying every signature offline โ€” adding non-conflicting truths, DROPPING
8
+ * forged/invalid ones, and SURFACING (never silently resolving) any truth that
9
+ * CONTRADICTS what the peer already holds. CRDT-style: commutative + idempotent
10
+ * (re-merging the same bundle changes nothing). Never throws.
11
+ *
12
+ * This is how the savant becomes the backbone of the AI multiverse: a tamper-evident,
13
+ * vendor-neutral, offline-verifiable fabric of facts that compounds as more agents join.
14
+ */
15
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
16
+ import { join } from "node:path";
17
+ import { issueReceipt, verifyReceipt } from "../notary/index.js";
18
+ import { readLattice, recordAssertion, detectContradictions } from "./lattice.js";
19
+ /** Export this savant's ACTIVE truths as a signed, portable bundle. Never throws. */
20
+ export function exportTruths(repoRoot, agent, opts = {}) {
21
+ const active = readLattice(repoRoot).filter((n) => n.status === "ACTIVE" && (n.verdict === "TRUE" || n.verdict === "FALSE"));
22
+ const truths = active.map((n) => ({ claim: n.claim, subject: n.subject, verdict: n.verdict, pTrue: n.pTrue, receipt: n.receipt }));
23
+ let receipt = null;
24
+ try {
25
+ receipt = issueReceipt(repoRoot, {
26
+ kind: "memory-capsule",
27
+ subject: `truth-bundle:${String(agent ?? "anon")}:${truths.length}`,
28
+ payload: { engine: "aletheia-mesh", agent, truths: truths.map((t) => ({ claim: t.claim, verdict: t.verdict })) },
29
+ issuedAt: opts.issuedAt,
30
+ });
31
+ }
32
+ catch {
33
+ receipt = null;
34
+ }
35
+ return { v: 1, agent: String(agent ?? "anon"), truths, receipt };
36
+ }
37
+ function meshSeenPath(repoRoot) { return join(repoRoot, ".mneme", "aletheia", "mesh-seen.json"); }
38
+ function loadSeen(repoRoot) {
39
+ try {
40
+ const p = meshSeenPath(repoRoot);
41
+ if (!existsSync(p))
42
+ return new Set();
43
+ const arr = JSON.parse(readFileSync(p, "utf8"));
44
+ return new Set(Array.isArray(arr) ? arr : []);
45
+ }
46
+ catch {
47
+ return new Set();
48
+ }
49
+ }
50
+ function saveSeen(repoRoot, seen) {
51
+ try {
52
+ mkdirSync(join(repoRoot, ".mneme", "aletheia"), { recursive: true });
53
+ writeFileSync(meshSeenPath(repoRoot), JSON.stringify([...seen]), "utf8");
54
+ }
55
+ catch { /* best-effort */ }
56
+ }
57
+ function truthKey(t) { return `${t.verdict}::${t.claim}`; }
58
+ /**
59
+ * Merge an incoming signed bundle into the local lattice. Verifies the bundle's
60
+ * signature + every per-truth signature OFFLINE; an unsigned/forged truth is DROPPED.
61
+ * A truth that contradicts a local ACTIVE truth is SURFACED (the savant doesn't
62
+ * silently pick a winner). Duplicates are skipped โ†’ idempotent + commutative. Never throws.
63
+ */
64
+ export function mergeTruths(repoRoot, bundle, opts = {}) {
65
+ let bundleVerified = false;
66
+ try {
67
+ bundleVerified = bundle.receipt ? verifyReceipt(bundle.receipt).valid : false;
68
+ }
69
+ catch {
70
+ bundleVerified = false;
71
+ }
72
+ const seen = loadSeen(repoRoot);
73
+ let added = 0, duplicate = 0, rejectedUnsigned = 0;
74
+ const conflicts = [];
75
+ const truths = Array.isArray(bundle?.truths) ? bundle.truths : [];
76
+ for (const t of truths) {
77
+ if (!t || typeof t.claim !== "string" || (t.verdict !== "TRUE" && t.verdict !== "FALSE"))
78
+ continue;
79
+ // (1) forgery defense โ€” the per-truth signature must be valid AND the truth's
80
+ // claim/verdict must MATCH the signed payload. (Catches swapping the claim
81
+ // text while keeping a valid-but-unrelated signature.)
82
+ let sigOk = false;
83
+ try {
84
+ if (t.receipt && verifyReceipt(t.receipt).valid) {
85
+ const pl = (t.receipt.payload ?? {});
86
+ sigOk = pl.claim === t.claim && pl.verdict === t.verdict;
87
+ }
88
+ }
89
+ catch {
90
+ sigOk = false;
91
+ }
92
+ if (!sigOk) {
93
+ rejectedUnsigned++;
94
+ continue;
95
+ }
96
+ const key = truthKey(t);
97
+ if (seen.has(key)) {
98
+ duplicate++;
99
+ continue;
100
+ }
101
+ // (2) conflict โ€” surfaced, never silently merged.
102
+ const contra = detectContradictions(repoRoot, t.claim, t.verdict);
103
+ if (contra.length > 0) {
104
+ conflicts.push({ claim: t.claim, verdict: t.verdict, against: contra[0].existing });
105
+ seen.add(key);
106
+ continue;
107
+ }
108
+ // (3) duplicate-by-content already in the local lattice?
109
+ const already = readLattice(repoRoot).some((n) => n.status === "ACTIVE" && n.claim === t.claim && n.verdict === t.verdict);
110
+ if (already) {
111
+ duplicate++;
112
+ seen.add(key);
113
+ continue;
114
+ }
115
+ // (4) accept โ€” record into the local lattice as a corroborated truth.
116
+ recordAssertion(repoRoot, { claim: t.claim, verdict: t.verdict, pTrue: t.pTrue, lineageSummary: ["mesh"] }, { issuedAt: opts.issuedAt });
117
+ added++;
118
+ seen.add(key);
119
+ }
120
+ saveSeen(repoRoot, seen);
121
+ const summary = `mesh merge from "${bundle?.agent ?? "?"}": +${added} added ยท ${duplicate} dup ยท ${rejectedUnsigned} forged-dropped ยท ${conflicts.length} conflict(s) surfaced ยท bundle ${bundleVerified ? "VERIFIED" : "UNVERIFIED"}`;
122
+ return { added, duplicate, rejectedUnsigned, conflicts, bundleVerified, summary };
123
+ }
124
+ //# sourceMappingURL=truth_mesh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"truth_mesh.js","sourceRoot":"","sources":["../../src/truth_kernel/truth_mesh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAqBlF,qFAAqF;AACrF,MAAM,UAAU,YAAY,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EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzI,KAAK,EAAE,CAAC;QAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAEzB,MAAM,OAAO,GAAG,oBAAoB,MAAM,EAAE,KAAK,IAAI,GAAG,OAAO,KAAK,YAAY,SAAS,UAAU,gBAAgB,qBAAqB,SAAS,CAAC,MAAM,kCAAkC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IACvO,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AACpF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mneme-ai/core",
3
- "version": "2.89.0",
3
+ "version": "2.91.0",
4
4
  "description": "Core indexing, retrieval, and graph engine for Mneme",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",