mneme-ai 3.113.0 → 3.114.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,10 @@
1
+ /**
2
+ * `mneme sdc` (v3.114.0) — Syndrome-Decoded Consensus: error-correct a multi-agent
3
+ * trust mesh. Detect + locate + recover poisoned/wrong attestations, or abstain.
4
+ *
5
+ * echo '[{"fact":"x","attestations":[{"agent":"a","value":"T"},{"agent":"b","value":"T"},{"agent":"evil","value":"X"}]}]' | mneme sdc decode -
6
+ * mneme sdc bench # the signed A/B: SDC vs plain majority-vote
7
+ */
8
+ import type { Command } from "commander";
9
+ export declare function registerSdcCommands(program: Command): void;
10
+ //# sourceMappingURL=sdc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdc.d.ts","sourceRoot":"","sources":["../../src/commands/sdc.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsC1D"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `mneme sdc` (v3.114.0) — Syndrome-Decoded Consensus: error-correct a multi-agent
3
+ * trust mesh. Detect + locate + recover poisoned/wrong attestations, or abstain.
4
+ *
5
+ * echo '[{"fact":"x","attestations":[{"agent":"a","value":"T"},{"agent":"b","value":"T"},{"agent":"evil","value":"X"}]}]' | mneme sdc decode -
6
+ * mneme sdc bench # the signed A/B: SDC vs plain majority-vote
7
+ */
8
+ import { readFileSync } from "node:fs";
9
+ import { sdc, notary } from "@mneme-ai/core";
10
+ function out(s) { process.stdout.write(s + "\n"); }
11
+ export function registerSdcCommands(program) {
12
+ const s = program
13
+ .command("sdc")
14
+ .description("🧬 SDC — Syndrome-Decoded Consensus: treat a multi-agent trust mesh like a QEC codeword. Detects + LOCATES poisoned/wrong attestations from the syndrome, recovers the consensus truth while errors stay under tolerance, or returns UNRECOVERABLE (abstains, never guesses). Beats plain majority-vote when liars are dense per-fact but a minority across the mesh (measured). The error-correction layer for a fleet of AI agents.");
15
+ s.command("decode")
16
+ .description("decode a mesh of facts+attestations (JSON array, '-' for stdin) → per-fact verdict + located bad agents + earned reliability.")
17
+ .argument("[file]", "JSON file ('-' or omitted = stdin)")
18
+ .option("--json", "JSON output")
19
+ .action((file, opts) => {
20
+ let facts;
21
+ try {
22
+ const raw = !file || file === "-" ? readFileSync(0, "utf8") : readFileSync(file, "utf8");
23
+ facts = JSON.parse(raw);
24
+ }
25
+ catch {
26
+ out("✗ could not read/parse JSON (expected: [{fact, attestations:[{agent,value}]}])");
27
+ process.exitCode = 2;
28
+ return;
29
+ }
30
+ const m = sdc.decodeMesh(facts);
31
+ let receipt = null;
32
+ try {
33
+ receipt = notary.issueReceipt(process.cwd(), { kind: "claim-verdict", subject: `sdc:decode:${m.decoded.length}`, payload: { corrupted: m.corruptedAgents, facts: m.decoded.length }, includePayload: true });
34
+ }
35
+ catch { /* */ }
36
+ if (opts.json) {
37
+ out(JSON.stringify({ ...m, signed: receipt }, null, 2));
38
+ return;
39
+ }
40
+ out(`🧬 SDC — ${m.decoded.length} fact(s), ${m.iterations} decode iteration(s)`);
41
+ for (const d of m.decoded)
42
+ out(` ${d.verdict === "UNRECOVERABLE" ? "🛑" : d.verdict === "CORRECTED" ? "🔧" : "✓"} ${d.fact}: ${d.verdict}${d.value !== null ? ` → ${d.value}` : ""}${d.dissenters.length ? ` (dissent: ${d.dissenters.join(",")})` : ""}`);
43
+ if (m.corruptedAgents.length)
44
+ out(` ⚠ located bad agents: ${m.corruptedAgents.join(", ")}`);
45
+ out(` reliability: ${Object.entries(m.reliability).map(([a, r]) => `${a}=${r}`).join(" · ")}`);
46
+ });
47
+ s.command("bench")
48
+ .description("the signed A/B: Syndrome-Decoded Consensus vs plain majority-vote on a labeled mesh (sustained-liar regime).")
49
+ .option("--json", "JSON output")
50
+ .option("--seed <n>", "scenario seed", "7")
51
+ .action((opts) => {
52
+ const b = sdc.sdcBench(parseInt(opts.seed ?? "7", 10) || 7);
53
+ let receipt = null;
54
+ try {
55
+ receipt = notary.issueReceipt(process.cwd(), { kind: "reasoning-trace", subject: `sdc.bench:${(b.sdcAcc * 100).toFixed(0)}vs${(b.majorityAcc * 100).toFixed(0)}`, payload: { sdcAcc: b.sdcAcc, majorityAcc: b.majorityAcc }, includePayload: true });
56
+ }
57
+ catch { /* */ }
58
+ if (opts.json) {
59
+ out(JSON.stringify({ ...b, signed: receipt }, null, 2));
60
+ return;
61
+ }
62
+ out(`🧬 SDC A/B — ${b.facts} labeled facts (sustained-liar regime):`);
63
+ out(` plain majority-vote: ${b.majorityCorrect}/${b.facts} = ${(b.majorityAcc * 100).toFixed(0)}%`);
64
+ out(` Syndrome-Decoded: ${b.sdcCorrect}/${b.facts} = ${(b.sdcAcc * 100).toFixed(0)}% (+${((b.sdcAcc - b.majorityAcc) * 100).toFixed(0)} pts)`);
65
+ out(` byzantine located: precision ${b.byzantinePrecision} · recall ${b.byzantineRecall}`);
66
+ out(` ${receipt ? "✓ signed · " : ""}HONEST: corrects sustained liars who are a global minority; a colluding majority everywhere → UNRECOVERABLE (abstain, never guess).`);
67
+ });
68
+ }
69
+ //# sourceMappingURL=sdc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdc.js","sourceRoot":"","sources":["../../src/commands/sdc.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAEjE,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,MAAM,CAAC,GAAG,OAAO;SACd,OAAO,CAAC,KAA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AAC,CAAC;QACtG,GAAG,CAAC,2BAA2B,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACtJ,GAAG,CAAC,qCAAqC,CAAC,CAAC,kBAAkB,aAAa,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;QAC/F,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,qIAAqI,CAAC,CAAC;IAC/K,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqMA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwmNvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsMA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAymNvD"}
package/dist/index.js CHANGED
@@ -128,6 +128,7 @@ import { registerMorphCommands } from "./commands/morph.js";
128
128
  import { registerMyceliumCommands } from "./commands/mycelium.js";
129
129
  import { registerSiegeCommands } from "./commands/siege.js";
130
130
  import { registerCanonCommands } from "./commands/canon.js";
131
+ import { registerSdcCommands } from "./commands/sdc.js";
131
132
  import { registerMoatCommands } from "./commands/moat.js";
132
133
  import { attachRegretOracle } from "./commands/regret.js";
133
134
  import { registerTrustCommands } from "./commands/trust.js";
@@ -4813,6 +4814,7 @@ export async function run(argv) {
4813
4814
  registerMyceliumCommands(program);
4814
4815
  registerSiegeCommands(program);
4815
4816
  registerCanonCommands(program);
4817
+ registerSdcCommands(program);
4816
4818
  registerMoatCommands(program);
4817
4819
  // ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
4818
4820
  registerTrustCommands(program);