mneme-ai 2.146.0 → 2.148.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/commands/mycelium.d.ts +13 -0
- package/dist/commands/mycelium.d.ts.map +1 -0
- package/dist/commands/mycelium.js +116 -0
- package/dist/commands/mycelium.js.map +1 -0
- package/dist/commands/siege.d.ts +12 -0
- package/dist/commands/siege.d.ts.map +1 -0
- package/dist/commands/siege.js +92 -0
- package/dist/commands/siege.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme mycelium` (v2.147.0) — the Sovereign Data Flywheel. Share signed,
|
|
3
|
+
* content-free lesson digests across Mneme nodes so the whole network gets
|
|
4
|
+
* smarter — with NO central data store. Local data never leaves; only hashes +
|
|
5
|
+
* DP-noised counts do.
|
|
6
|
+
*
|
|
7
|
+
* mneme mycelium bundle --out lessons.bundle.json # signed, content-free, DP-noised
|
|
8
|
+
* mneme mycelium merge --bundle peer.bundle.json # CRDT-merge a peer's lessons
|
|
9
|
+
* mneme mycelium status # mesh size + worked/failed split
|
|
10
|
+
*/
|
|
11
|
+
import type { Command } from "commander";
|
|
12
|
+
export declare function registerMyceliumCommands(program: Command): void;
|
|
13
|
+
//# sourceMappingURL=mycelium.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mycelium.d.ts","sourceRoot":"","sources":["../../src/commands/mycelium.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBzC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2C/D"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme mycelium` (v2.147.0) — the Sovereign Data Flywheel. Share signed,
|
|
3
|
+
* content-free lesson digests across Mneme nodes so the whole network gets
|
|
4
|
+
* smarter — with NO central data store. Local data never leaves; only hashes +
|
|
5
|
+
* DP-noised counts do.
|
|
6
|
+
*
|
|
7
|
+
* mneme mycelium bundle --out lessons.bundle.json # signed, content-free, DP-noised
|
|
8
|
+
* mneme mycelium merge --bundle peer.bundle.json # CRDT-merge a peer's lessons
|
|
9
|
+
* mneme mycelium status # mesh size + worked/failed split
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
12
|
+
import { join, dirname } from "node:path";
|
|
13
|
+
import { mycelium as myc, notary } from "@mneme-ai/core";
|
|
14
|
+
function out(s) { process.stdout.write(s + "\n"); }
|
|
15
|
+
const MESH = ".mneme/mycelium/mesh.json";
|
|
16
|
+
/** Best-effort: harvest local outcomes from the regret + nkl ledgers (content stays local). */
|
|
17
|
+
function localOutcomes(cwd) {
|
|
18
|
+
const o = [];
|
|
19
|
+
try {
|
|
20
|
+
const rp = join(cwd, ".mneme", "regret", "outcomes.jsonl");
|
|
21
|
+
if (existsSync(rp))
|
|
22
|
+
for (const l of readFileSync(rp, "utf8").split("\n")) {
|
|
23
|
+
if (!l.trim())
|
|
24
|
+
continue;
|
|
25
|
+
try {
|
|
26
|
+
const j = JSON.parse(l);
|
|
27
|
+
o.push({ topic: (j.features || []).join(" "), approach: (j.features || []).join(","), kind: j.regretted ? "failed" : "worked" });
|
|
28
|
+
}
|
|
29
|
+
catch { /* */ }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch { /* */ }
|
|
33
|
+
return o;
|
|
34
|
+
}
|
|
35
|
+
function readMesh(cwd) { try {
|
|
36
|
+
const p = join(cwd, MESH);
|
|
37
|
+
if (existsSync(p)) {
|
|
38
|
+
const j = JSON.parse(readFileSync(p, "utf8"));
|
|
39
|
+
return Array.isArray(j.lessons) ? j.lessons : [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch { /* */ } return []; }
|
|
43
|
+
function writeMesh(cwd, lessons) { try {
|
|
44
|
+
const p = join(cwd, MESH);
|
|
45
|
+
if (!existsSync(dirname(p)))
|
|
46
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
47
|
+
writeFileSync(p, JSON.stringify({ v: 1, lessons }, null, 2));
|
|
48
|
+
}
|
|
49
|
+
catch { /* */ } }
|
|
50
|
+
export function registerMyceliumCommands(program) {
|
|
51
|
+
const m = program
|
|
52
|
+
.command("mycelium")
|
|
53
|
+
.description("🍄 MYCELIUM — the Sovereign Data Flywheel: share SIGNED, content-free lesson digests (hashes + DP-noised counts, never raw code/secrets) across Mneme nodes so the whole network gets smarter with NO central data store. Captures what WORKED and what FAILED (negative knowledge). The privacy-preserving flywheel only a local-first system can run.");
|
|
54
|
+
m.command("bundle")
|
|
55
|
+
.description("build a signed, content-free, DP-noised bundle of local lessons to share with peers.")
|
|
56
|
+
.option("--out <file>", "write the bundle JSON here (else stdout)")
|
|
57
|
+
.option("--epsilon <n>", "differential-privacy epsilon (default 1)", (v) => parseFloat(v))
|
|
58
|
+
.action((opts) => {
|
|
59
|
+
const cwd = process.cwd();
|
|
60
|
+
const lessons = myc.extractLessons(localOutcomes(cwd), "node");
|
|
61
|
+
const b = myc.buildBundle(lessons, { epsilon: opts.epsilon ?? 1, sample: () => 0 });
|
|
62
|
+
let receipt = null;
|
|
63
|
+
try {
|
|
64
|
+
receipt = notary.issueReceipt(cwd, { kind: "memory-capsule", subject: `mycelium.bundle:${b.lessons.length}`, payload: { count: b.lessons.length, epsilon: b.epsilon }, includePayload: true });
|
|
65
|
+
}
|
|
66
|
+
catch { /* */ }
|
|
67
|
+
const bundle = { ...b, signed: receipt };
|
|
68
|
+
if (opts.out) {
|
|
69
|
+
try {
|
|
70
|
+
writeFileSync(opts.out, JSON.stringify(bundle, null, 2));
|
|
71
|
+
out(`🍄 wrote ${b.lessons.length} content-free lessons → ${opts.out} (signed, DP ε=${b.epsilon})`);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
out("✗ write failed");
|
|
75
|
+
process.exitCode = 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
out(JSON.stringify(bundle, null, 2));
|
|
80
|
+
});
|
|
81
|
+
m.command("merge")
|
|
82
|
+
.description("CRDT-merge a peer's lesson bundle into the local mesh (signature-verified; forged dropped). Commutative + idempotent.")
|
|
83
|
+
.requiredOption("--bundle <file>", "peer bundle JSON")
|
|
84
|
+
.action((opts) => {
|
|
85
|
+
const cwd = process.cwd();
|
|
86
|
+
if (!existsSync(opts.bundle)) {
|
|
87
|
+
out("✗ bundle not found");
|
|
88
|
+
process.exitCode = 2;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let incoming = [];
|
|
92
|
+
try {
|
|
93
|
+
const j = JSON.parse(readFileSync(opts.bundle, "utf8"));
|
|
94
|
+
incoming = Array.isArray(j.lessons) ? j.lessons : [];
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
out("✗ bad bundle JSON");
|
|
98
|
+
process.exitCode = 2;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const r = myc.mergeBundles(readMesh(cwd), incoming);
|
|
102
|
+
writeMesh(cwd, r.merged);
|
|
103
|
+
out(`🍄 merged — +${r.added} new · ~${r.updated} updated · ${r.dropped} dropped · mesh now ${r.merged.length} lessons`);
|
|
104
|
+
});
|
|
105
|
+
m.command("status")
|
|
106
|
+
.description("mesh size + worked/failed split + topics covered.")
|
|
107
|
+
.action(() => {
|
|
108
|
+
const mesh = readMesh(process.cwd());
|
|
109
|
+
const worked = mesh.filter((l) => l.kind === "worked").length;
|
|
110
|
+
const failed = mesh.filter((l) => l.kind === "failed").length;
|
|
111
|
+
const topics = new Set(mesh.map((l) => l.topicHash)).size;
|
|
112
|
+
out(`🍄 MYCELIUM mesh — ${mesh.length} lessons · ✅ ${worked} worked · ❌ ${failed} failed (negative knowledge) · ${topics} topics`);
|
|
113
|
+
out(" content-free + signed; the network compounds without a central data store.");
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=mycelium.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mycelium.js","sourceRoot":"","sources":["../../src/commands/mycelium.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEzD,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACjE,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC,+FAA+F;AAC/F,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,CAAC,GAAuB,EAAE,CAAC;IACjC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC3D,IAAI,UAAU,CAAC,EAAE,CAAC;YAAE,KAAK,MAAM,CAAC,IAAI,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;oBAAE,SAAS;gBAAC,IAAI,CAAC;oBAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,C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kC,MAAM,SAAS,CAAC,CAAC;QACnI,GAAG,CAAC,+EAA+E,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme siege` (v2.148.0) — the Adversarial Self-Bounty. Fire Mneme's attack
|
|
3
|
+
* corpus at a command-gate and get a SIGNED, public, ever-rising bypass-resistance
|
|
4
|
+
* score (Wilson lower bound). Self mode benches Mneme's own gate (CERBERUS).
|
|
5
|
+
*
|
|
6
|
+
* mneme siege self # resistance of Mneme's own command gate
|
|
7
|
+
* mneme siege gate --cmd 'mygate {cmd}' # bench any external gate (parse ALLOW/BLOCK)
|
|
8
|
+
* mneme siege corpus # show the attack corpus
|
|
9
|
+
*/
|
|
10
|
+
import type { Command } from "commander";
|
|
11
|
+
export declare function registerSiegeCommands(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=siege.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siege.d.ts","sourceRoot":"","sources":["../../src/commands/siege.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqD5D"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme siege` (v2.148.0) — the Adversarial Self-Bounty. Fire Mneme's attack
|
|
3
|
+
* corpus at a command-gate and get a SIGNED, public, ever-rising bypass-resistance
|
|
4
|
+
* score (Wilson lower bound). Self mode benches Mneme's own gate (CERBERUS).
|
|
5
|
+
*
|
|
6
|
+
* mneme siege self # resistance of Mneme's own command gate
|
|
7
|
+
* mneme siege gate --cmd 'mygate {cmd}' # bench any external gate (parse ALLOW/BLOCK)
|
|
8
|
+
* mneme siege corpus # show the attack corpus
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, mkdirSync, appendFileSync } from "node:fs";
|
|
11
|
+
import { join, dirname } from "node:path";
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { siege as sg, hephaestus, notary } from "@mneme-ai/core";
|
|
14
|
+
function out(s) { process.stdout.write(s + "\n"); }
|
|
15
|
+
const LEDGER = ".mneme/siege/resistance.jsonl";
|
|
16
|
+
export function registerSiegeCommands(program) {
|
|
17
|
+
const s = program
|
|
18
|
+
.command("siege")
|
|
19
|
+
.description("🏰 SIEGE — the Adversarial Self-Bounty. Fire Mneme's attack corpus (rm -rf, pipe-to-shell, base64/hex-decode, find -delete, $IFS, var-indirection, fork-bomb, DROP TABLE, /dev/tcp exfil, …) at a command-gate → a SIGNED, public, EVER-RISING bypass-resistance score (Wilson LOWER bound = proven-at-least, never 'unbreakable'). Every new bypass found folds back into the corpus → the gate gets provably harder. The moat: a public resistance score competitors can't match + nobody else dares publish.");
|
|
20
|
+
s.command("self")
|
|
21
|
+
.description("siege Mneme's OWN command gate (CERBERUS) → its bypass-resistance, signed + appended to the resistance ledger.")
|
|
22
|
+
.option("--json", "JSON output (signed)")
|
|
23
|
+
.action((opts) => {
|
|
24
|
+
const cwd = process.cwd();
|
|
25
|
+
const gate = (cmd) => hephaestus.classifyCommandRisk(cmd).risk === "destructive" ? "COSIGN" : "ALLOW";
|
|
26
|
+
const score = sg.scoreSiege(sg.siege(gate));
|
|
27
|
+
let receipt = null;
|
|
28
|
+
try {
|
|
29
|
+
receipt = notary.issueReceipt(cwd, { kind: "claim-verdict", subject: `siege:${score.band}:${(score.resistanceLB * 100).toFixed(0)}`, payload: { band: score.band, resistanceLB: score.resistanceLB, withstood: score.withstood, total: score.total }, includePayload: true });
|
|
30
|
+
}
|
|
31
|
+
catch { /* */ }
|
|
32
|
+
try {
|
|
33
|
+
const p = join(cwd, LEDGER);
|
|
34
|
+
if (!existsSync(dirname(p)))
|
|
35
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
36
|
+
appendFileSync(p, JSON.stringify({ at: Date.now(), band: score.band, resistanceLB: score.resistanceLB, withstood: score.withstood, total: score.total }) + "\n");
|
|
37
|
+
}
|
|
38
|
+
catch { /* */ }
|
|
39
|
+
if (opts.json) {
|
|
40
|
+
out(JSON.stringify({ ...score, signed: receipt }, null, 2));
|
|
41
|
+
process.exitCode = score.bypassed === 0 ? 0 : 2;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const icon = score.band === "FORTRESS" ? "🏰" : score.band === "STRONG" ? "🛡" : score.band === "WEAK" ? "⚠" : "🛑";
|
|
45
|
+
out(`${icon} SIEGE — ${score.band} · bypass-resistance ≥ ${(score.resistanceLB * 100).toFixed(0)}% (Wilson LB)`);
|
|
46
|
+
out(` withstood ${score.withstood}/${score.total} attacks · bypassed ${score.bypassed}`);
|
|
47
|
+
for (const [cls, b] of Object.entries(score.byClass))
|
|
48
|
+
out(` ${cls.padEnd(12)} ${b.withstood}/${b.total}`);
|
|
49
|
+
for (const b of score.bypasses.slice(0, 8))
|
|
50
|
+
out(` 🛑 BYPASS ${b.id} (${b.class}) → gate said ${b.verdict}`);
|
|
51
|
+
out(` ${receipt ? "✓ signed + ledgered · " : ""}${score.note}`);
|
|
52
|
+
process.exitCode = score.bypassed === 0 ? 0 : 2;
|
|
53
|
+
});
|
|
54
|
+
s.command("gate")
|
|
55
|
+
.description("siege an EXTERNAL gate: a command template with {cmd}; non-zero exit OR stdout containing BLOCK/DENY/COSIGN = withstood, else bypassed.")
|
|
56
|
+
.requiredOption("--cmd <template>", "gate command, e.g. \"mygate check {cmd}\"")
|
|
57
|
+
.option("--json", "JSON output")
|
|
58
|
+
.action((opts) => {
|
|
59
|
+
const gate = (payload) => {
|
|
60
|
+
try {
|
|
61
|
+
const command = opts.cmd.replace(/\{cmd\}/g, payload);
|
|
62
|
+
const r = spawnSync(command, { encoding: "utf8", shell: true, timeout: 15000 });
|
|
63
|
+
const o = ((r.stdout ?? "") + (r.stderr ?? "")).toUpperCase();
|
|
64
|
+
if ((r.status ?? 0) !== 0 || /\b(BLOCK|DENY|DENIED|COSIGN|REFUSE|REJECT)\b/.test(o))
|
|
65
|
+
return "BLOCK";
|
|
66
|
+
return "ALLOW";
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return "BLOCK";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const score = sg.scoreSiege(sg.siege(gate));
|
|
73
|
+
if (opts.json) {
|
|
74
|
+
out(JSON.stringify(score, null, 2));
|
|
75
|
+
process.exitCode = score.bypassed === 0 ? 0 : 2;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const icon = score.band === "FORTRESS" ? "🏰" : score.band === "STRONG" ? "🛡" : score.band === "WEAK" ? "⚠" : "🛑";
|
|
79
|
+
out(`${icon} SIEGE (external) — ${score.band} · resistance ≥ ${(score.resistanceLB * 100).toFixed(0)}% · withstood ${score.withstood}/${score.total}`);
|
|
80
|
+
for (const b of score.bypasses.slice(0, 12))
|
|
81
|
+
out(` 🛑 BYPASS ${b.id} (${b.class})`);
|
|
82
|
+
process.exitCode = score.bypassed === 0 ? 0 : 2;
|
|
83
|
+
});
|
|
84
|
+
s.command("corpus").description("show the attack corpus (size + classes).").action(() => {
|
|
85
|
+
const byClass = {};
|
|
86
|
+
for (const c of sg.ATTACK_CORPUS)
|
|
87
|
+
byClass[c.class] = (byClass[c.class] ?? 0) + 1;
|
|
88
|
+
out(`🏰 SIEGE attack corpus — ${sg.ATTACK_CORPUS.length} payloads: ${Object.entries(byClass).map(([k, v]) => `${k}=${v}`).join(" · ")}`);
|
|
89
|
+
out(" self-hardening: every bypass found in a bounty folds back in → the gate gets provably harder.");
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=siege.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siege.js","sourceRoot":"","sources":["../../src/commands/siege.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO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GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzI,GAAG,CAAC,kGAAkG,CAAC,CAAC;IAC1G,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyKA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAykNvD"}
|
package/dist/index.js
CHANGED
|
@@ -99,6 +99,8 @@ import { registerCrucibleCommands } from "./commands/crucible.js";
|
|
|
99
99
|
import { registerDriftCommands } from "./commands/drift.js";
|
|
100
100
|
import { registerGovernCommands } from "./commands/govern.js";
|
|
101
101
|
import { registerGatewayCommands } from "./commands/gateway.js";
|
|
102
|
+
import { registerMyceliumCommands } from "./commands/mycelium.js";
|
|
103
|
+
import { registerSiegeCommands } from "./commands/siege.js";
|
|
102
104
|
import { attachRegretOracle } from "./commands/regret.js";
|
|
103
105
|
import { registerTrustCommands } from "./commands/trust.js";
|
|
104
106
|
import { registerNuclearCommands } from "./commands/nuclear-cli.js";
|
|
@@ -4751,6 +4753,8 @@ export async function run(argv) {
|
|
|
4751
4753
|
registerDriftCommands(program);
|
|
4752
4754
|
registerGovernCommands(program);
|
|
4753
4755
|
registerGatewayCommands(program);
|
|
4756
|
+
registerMyceliumCommands(program);
|
|
4757
|
+
registerSiegeCommands(program);
|
|
4754
4758
|
// ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
|
|
4755
4759
|
registerTrustCommands(program);
|
|
4756
4760
|
// ─── Wisdom reactor (v1.33.0) -- five nuclear-physics formulas as Mneme metrics
|