@mneme-ai/core 2.26.1 → 2.27.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.
@@ -0,0 +1,75 @@
1
+ // v2.27.0 — TRUTH GATE unit tests (discrete root tests covering every logic branch).
2
+ import { describe, it, expect, beforeEach } from "vitest";
3
+ import { CLAIM_CATALOG, ALL_PROBES, probeById } from "./index.js";
4
+ import { verifyMatrix, __resetTruthChainForTest } from "./engine.js";
5
+ describe("truth_gate — claim catalog", () => {
6
+ it("every claim has a probeId that exists", () => {
7
+ for (const claim of CLAIM_CATALOG) {
8
+ const probe = probeById(claim.probeId);
9
+ expect(probe, `no probe for claim ${claim.id} → ${claim.probeId}`).toBeDefined();
10
+ }
11
+ });
12
+ it("every claim has source + text + kind + severity", () => {
13
+ for (const c of CLAIM_CATALOG) {
14
+ expect(c.source.length).toBeGreaterThan(0);
15
+ expect(c.text.length).toBeGreaterThan(0);
16
+ expect(["numeric", "boolean", "string", "shape"]).toContain(c.kind);
17
+ expect(["info", "warn", "block"]).toContain(c.severity);
18
+ }
19
+ });
20
+ it("numeric claims declare asserted value + op", () => {
21
+ for (const c of CLAIM_CATALOG) {
22
+ if (c.kind === "numeric") {
23
+ expect(c.asserted).toBeDefined();
24
+ expect(typeof c.asserted.value).toBe("number");
25
+ expect(["<", "<=", ">", ">=", "=", "~="]).toContain(c.asserted.op);
26
+ }
27
+ }
28
+ });
29
+ it("boolean claims declare asserted value", () => {
30
+ for (const c of CLAIM_CATALOG) {
31
+ if (c.kind === "boolean") {
32
+ expect(c.asserted).toBeDefined();
33
+ expect([0, 1]).toContain(c.asserted.value);
34
+ }
35
+ }
36
+ });
37
+ it("at least 10 claims in the catalog", () => {
38
+ expect(CLAIM_CATALOG.length).toBeGreaterThanOrEqual(10);
39
+ });
40
+ });
41
+ describe("truth_gate — probes", () => {
42
+ it("each probe id is unique", () => {
43
+ const ids = new Set(ALL_PROBES.map((p) => p.id));
44
+ expect(ids.size).toBe(ALL_PROBES.length);
45
+ });
46
+ it("each probe has description + kind + run function", () => {
47
+ for (const p of ALL_PROBES) {
48
+ expect(p.description.length).toBeGreaterThan(0);
49
+ expect(typeof p.run).toBe("function");
50
+ expect(["numeric", "boolean", "string", "shape"]).toContain(p.kind);
51
+ }
52
+ });
53
+ });
54
+ describe("truth_gate — verifyMatrix", () => {
55
+ function badMatrix() {
56
+ return {
57
+ spec: { name: "MNEME-TRUTH-GATE", version: "1.0" },
58
+ scannedAt: "2026-05-22T00:00:00.000Z",
59
+ cwd: "tmp",
60
+ totalClaims: 0,
61
+ entries: [],
62
+ summary: { pass: 0, drift: 0, refuted: 0, unmeasured: 0, truthScore: 0 },
63
+ headline: "test",
64
+ trafficLight: "yellow",
65
+ hmac: "deadbeef".repeat(8),
66
+ seq: 1,
67
+ bodyDigest: "feedface".repeat(8),
68
+ };
69
+ }
70
+ beforeEach(() => __resetTruthChainForTest());
71
+ it("rejects a tampered matrix (bad bodyDigest)", () => {
72
+ expect(verifyMatrix(badMatrix()).ok).toBe(false);
73
+ });
74
+ });
75
+ //# sourceMappingURL=truth_gate.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"truth_gate.test.js","sourceRoot":"","sources":["../../src/truth_gate/truth_gate.test.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGrE,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,OAA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AAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,SAAS,SAAS;QAChB,OAAO;YACL,IAAI,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE;YAClD,SAAS,EAAE,0BAA0B;YACrC,GAAG,EAAE,KAAK;YACV,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;YACxE,QAAQ,EAAE,MAAM;YAChB,YAAY,EAAE,QAAQ;YACtB,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YAC1B,GAAG,EAAE,CAAC;YACN,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACjC,CAAC;IACJ,CAAC;IACD,UAAU,CAAC,GAAG,EAAE,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAE7C,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * v2.27.0 — MARKETING TRUTH GATE.
3
+ *
4
+ * Audit (2026-05-22, user-supplied matrix): 8 marketing claims that
5
+ * don't match measured reality, e.g.
6
+ *
7
+ * Marketing: "74.7% fewer tokens" Measured: 80K tokens / call
8
+ * Marketing: "9 verification agents" Measured: returns NEEDS-DATA
9
+ * Marketing: "SUPERNOVA self-heal" Measured: kill 5x → 0 respawn
10
+ * Marketing: "Phoenix Resurrection" Measured: not activated by default
11
+ * Marketing: "Ollama detected ★★★★" Measured: bundled ★★★ picked
12
+ *
13
+ * The world has plenty of "release notes" pages. None of them PROVE the
14
+ * claim every time the binary is built. The TRUTH GATE does:
15
+ *
16
+ * 1. SCAN — parse claim-shaped sentences out of README / CHANGELOG /
17
+ * docs (and from MCP tool descriptions).
18
+ * 2. PROBE — each claim has a measurable probe (live function that
19
+ * returns a number / boolean / string).
20
+ * 3. RECONCILE — compare claim's asserted value to probed value; emit
21
+ * verdict (pass / drift / refuted).
22
+ * 4. ATTEST — HMAC-sign the reconciliation matrix so receivers can
23
+ * verify offline that the binary's claims have been measured.
24
+ *
25
+ * Composable with the PEAK GAUNTLET (v2.26.x): N1-N12 are spec
26
+ * conformance; TRUTH GATE is marketing-vs-reality. Together they form
27
+ * the world's first measurable-truth release pipeline.
28
+ */
29
+ export type ClaimId = string;
30
+ export type ClaimKind = "numeric" | "boolean" | "string" | "shape";
31
+ export type ClaimVerdict = "pass" | "drift" | "refuted" | "unmeasured";
32
+ export interface Claim {
33
+ /** Stable id, e.g. "claim.tokens.capabilities". */
34
+ id: ClaimId;
35
+ /** Where the claim appears (file:line, README section title). */
36
+ source: string;
37
+ /** The marketing text verbatim (≤ 240 chars). */
38
+ text: string;
39
+ kind: ClaimKind;
40
+ /** For numeric claims: asserted value + comparison operator. */
41
+ asserted?: {
42
+ value: number;
43
+ op: "<" | "<=" | ">" | ">=" | "=" | "~=";
44
+ unit?: string;
45
+ tolerance?: number;
46
+ };
47
+ /** Probe id that measures the live value. */
48
+ probeId: string;
49
+ /** Severity if the claim drifts. */
50
+ severity: "info" | "warn" | "block";
51
+ }
52
+ export interface ProbeResult {
53
+ /** Measured value (kind-dependent). */
54
+ value: number | boolean | string | null;
55
+ /** Single-line summary of the measurement. */
56
+ evidence: string;
57
+ /** Wall-time of the probe. */
58
+ dtMs?: number;
59
+ /** Optional structured detail. */
60
+ detail?: Record<string, unknown>;
61
+ }
62
+ export interface Probe {
63
+ id: string;
64
+ /** What kind of claim this probe can answer. */
65
+ kind: ClaimKind;
66
+ /** Short description. */
67
+ description: string;
68
+ /** Run the probe. NEVER throws — returns { value: null } on error. */
69
+ run: (ctx: ProbeContext) => Promise<ProbeResult>;
70
+ }
71
+ export interface ProbeContext {
72
+ cwd: string;
73
+ }
74
+ export interface ReconciliationEntry {
75
+ claim: Claim;
76
+ probe: ProbeResult;
77
+ verdict: ClaimVerdict;
78
+ reason: string;
79
+ }
80
+ export interface TruthMatrix {
81
+ spec: {
82
+ name: "MNEME-TRUTH-GATE";
83
+ version: string;
84
+ };
85
+ scannedAt: string;
86
+ cwd: string;
87
+ totalClaims: number;
88
+ entries: ReconciliationEntry[];
89
+ summary: {
90
+ pass: number;
91
+ drift: number;
92
+ refuted: number;
93
+ unmeasured: number;
94
+ truthScore: number;
95
+ };
96
+ headline: string;
97
+ trafficLight: "green" | "yellow" | "red";
98
+ hmac: string;
99
+ seq: number;
100
+ bodyDigest: string;
101
+ }
102
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/truth_gate/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,SAAS,GACT,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,CAAC;AAEvE,MAAM,WAAW,KAAK;IACpB,mDAAmD;IACnD,EAAE,EAAE,OAAO,CAAC;IACZ,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,gEAAgE;IAChE,QAAQ,CAAC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AAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * v2.27.0 — MARKETING TRUTH GATE.
3
+ *
4
+ * Audit (2026-05-22, user-supplied matrix): 8 marketing claims that
5
+ * don't match measured reality, e.g.
6
+ *
7
+ * Marketing: "74.7% fewer tokens" Measured: 80K tokens / call
8
+ * Marketing: "9 verification agents" Measured: returns NEEDS-DATA
9
+ * Marketing: "SUPERNOVA self-heal" Measured: kill 5x → 0 respawn
10
+ * Marketing: "Phoenix Resurrection" Measured: not activated by default
11
+ * Marketing: "Ollama detected ★★★★" Measured: bundled ★★★ picked
12
+ *
13
+ * The world has plenty of "release notes" pages. None of them PROVE the
14
+ * claim every time the binary is built. The TRUTH GATE does:
15
+ *
16
+ * 1. SCAN — parse claim-shaped sentences out of README / CHANGELOG /
17
+ * docs (and from MCP tool descriptions).
18
+ * 2. PROBE — each claim has a measurable probe (live function that
19
+ * returns a number / boolean / string).
20
+ * 3. RECONCILE — compare claim's asserted value to probed value; emit
21
+ * verdict (pass / drift / refuted).
22
+ * 4. ATTEST — HMAC-sign the reconciliation matrix so receivers can
23
+ * verify offline that the binary's claims have been measured.
24
+ *
25
+ * Composable with the PEAK GAUNTLET (v2.26.x): N1-N12 are spec
26
+ * conformance; TRUTH GATE is marketing-vs-reality. Together they form
27
+ * the world's first measurable-truth release pipeline.
28
+ */
29
+ export {};
30
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/truth_gate/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mneme-ai/core",
3
- "version": "2.26.1",
3
+ "version": "2.27.0",
4
4
  "description": "Core indexing, retrieval, and graph engine for Mneme",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",