mneme-ai 3.118.0 → 3.120.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/hpe.d.ts.map +1 -1
- package/dist/commands/hpe.js +53 -1
- package/dist/commands/hpe.js.map +1 -1
- package/dist/commands/vericert.d.ts +12 -0
- package/dist/commands/vericert.d.ts.map +1 -0
- package/dist/commands/vericert.js +96 -0
- package/dist/commands/vericert.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hpe.d.ts","sourceRoot":"","sources":["../../src/commands/hpe.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"hpe.d.ts","sourceRoot":"","sources":["../../src/commands/hpe.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBzC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqD1D"}
|
package/dist/commands/hpe.js
CHANGED
|
@@ -5,8 +5,28 @@
|
|
|
5
5
|
* mneme protect "p > 0.05 so the drug has no effect"
|
|
6
6
|
* mneme protect bench
|
|
7
7
|
*/
|
|
8
|
+
import { existsSync, readFileSync, appendFileSync, mkdirSync } from "node:fs";
|
|
9
|
+
import { join, dirname } from "node:path";
|
|
8
10
|
import { hpe, notary } from "@mneme-ai/core";
|
|
9
11
|
function out(s) { process.stdout.write(s + "\n"); }
|
|
12
|
+
const LEDGER = () => join(process.cwd(), ".mneme", "hpe-learned.jsonl");
|
|
13
|
+
/** Load confirmed learned faults from the local ledger (auto-applied on every scan). */
|
|
14
|
+
function loadLearned() {
|
|
15
|
+
try {
|
|
16
|
+
const p = LEDGER();
|
|
17
|
+
if (!existsSync(p))
|
|
18
|
+
return [];
|
|
19
|
+
return readFileSync(p, "utf8").split("\n").filter((l) => l.trim()).map((l) => { try {
|
|
20
|
+
return JSON.parse(l);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
} }).filter((x) => !!x && Array.isArray(x.signature));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
10
30
|
export function registerHpeCommands(program) {
|
|
11
31
|
const g = program
|
|
12
32
|
.command("protect")
|
|
@@ -21,7 +41,8 @@ export function registerHpeCommands(program) {
|
|
|
21
41
|
process.exitCode = 2;
|
|
22
42
|
return;
|
|
23
43
|
}
|
|
24
|
-
const
|
|
44
|
+
const learned = loadLearned();
|
|
45
|
+
const r = hpe.protect(q, undefined, { learned });
|
|
25
46
|
let receipt = null;
|
|
26
47
|
try {
|
|
27
48
|
receipt = notary.issueReceipt(process.cwd(), { kind: "claim-verdict", subject: `hpe:${r.verdict}`, payload: { verdict: r.verdict, trust: r.trust, fired: r.fired.map((f) => f.nerve) }, includePayload: true });
|
|
@@ -42,6 +63,37 @@ export function registerHpeCommands(program) {
|
|
|
42
63
|
out(` no nerve fired — no known fault (not a proof of truth).`);
|
|
43
64
|
process.exitCode = r.verdict === "BLOCK" ? 2 : 0;
|
|
44
65
|
});
|
|
66
|
+
g.command("learn")
|
|
67
|
+
.argument("<claim...>", "the CONFIRMED hallucination to learn")
|
|
68
|
+
.description("teach HPE a confirmed real hallucination it missed → it auto-catches that kind on every future scan. Consent-gated (only learn a confirmed fault); precision-guarded (a too-broad pattern is rejected). Appends to .mneme/hpe-learned.jsonl.")
|
|
69
|
+
.option("--why <s>", "why it's a fault", "a previously-confirmed hallucination case")
|
|
70
|
+
.option("--fix <s>", "the correct handling", "verify against the source before relaying")
|
|
71
|
+
.option("--hard", "block (default: soft = review)", false)
|
|
72
|
+
.action((claim, opts) => {
|
|
73
|
+
const q = claim.join(" ");
|
|
74
|
+
// guard against false-flagging the engine's own known-safe corpus
|
|
75
|
+
const safe = hpe.HPE_CORPUS.filter((c) => c.expectSafe).map((c) => c.text);
|
|
76
|
+
const res = hpe.learnFault(q, { why: opts.why, fix: opts.fix, severity: opts.hard ? "hard" : "soft" }, safe);
|
|
77
|
+
if (!res.ok || !res.learned) {
|
|
78
|
+
out(`🛑 not learned — ${res.reason}`);
|
|
79
|
+
process.exitCode = 2;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const p = LEDGER();
|
|
84
|
+
if (!existsSync(dirname(p)))
|
|
85
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
86
|
+
appendFileSync(p, JSON.stringify(res.learned) + "\n", "utf8");
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
out(`✗ could not write ledger: ${e.message}`);
|
|
90
|
+
process.exitCode = 2;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
out(`✓ learned [${res.learned.severity}] ${res.learned.id}`);
|
|
94
|
+
out(` signature: ${res.learned.signature.join(" · ")}`);
|
|
95
|
+
out(` HPE will now ${res.learned.severity === "hard" ? "BLOCK" : "REVIEW"} this kind on every future scan (auto-loaded from the ledger).`);
|
|
96
|
+
});
|
|
45
97
|
g.command("bench")
|
|
46
98
|
.description("the signed A/B: precision-when-TRUSTED (no hallucination passes) + per-class containment, on a labeled corpus.")
|
|
47
99
|
.option("--json", "JSON output")
|
package/dist/commands/hpe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hpe.js","sourceRoot":"","sources":["../../src/commands/hpe.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAA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,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,mCAAmC,CAAC,CAAC;QACvI,GAAG,CAAC,gCAAgC,CAAC,CAAC,+BAA+B,IAAI,CAAC,CAAC,KAAK,oBAAoB,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAChL,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,2HAA2H,CAAC,CAAC;IACrK,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme certify` (v3.120.0) — VERICERT: stamp an AI-worker deliverable with a
|
|
3
|
+
* signed, offline-verifiable "Verified-by-Mneme" certificate (CERTIFIED /
|
|
4
|
+
* CONDITIONAL / REJECTED) — the trust layer for the AI-worker economy.
|
|
5
|
+
*
|
|
6
|
+
* mneme certify "the build always works and never fails"
|
|
7
|
+
* cat report.md | mneme certify - # certify a file/stdin
|
|
8
|
+
* mneme certify verify --cert cert.json [--deliverable report.md]
|
|
9
|
+
*/
|
|
10
|
+
import type { Command } from "commander";
|
|
11
|
+
export declare function registerVericertCommands(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=vericert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vericert.d.ts","sourceRoot":"","sources":["../../src/commands/vericert.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0C/D"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme certify` (v3.120.0) — VERICERT: stamp an AI-worker deliverable with a
|
|
3
|
+
* signed, offline-verifiable "Verified-by-Mneme" certificate (CERTIFIED /
|
|
4
|
+
* CONDITIONAL / REJECTED) — the trust layer for the AI-worker economy.
|
|
5
|
+
*
|
|
6
|
+
* mneme certify "the build always works and never fails"
|
|
7
|
+
* cat report.md | mneme certify - # certify a file/stdin
|
|
8
|
+
* mneme certify verify --cert cert.json [--deliverable report.md]
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { vericert, notary } from "@mneme-ai/core";
|
|
12
|
+
function out(s) { process.stdout.write(s + "\n"); }
|
|
13
|
+
export function registerVericertCommands(program) {
|
|
14
|
+
const c = program
|
|
15
|
+
.command("certify")
|
|
16
|
+
.alias("vericert")
|
|
17
|
+
.argument("[deliverable...]", "the AI-produced deliverable ('-' = stdin)")
|
|
18
|
+
.description("🎗️ VERICERT — stamp an AI-worker deliverable (report / code / answer) with a signed, offline-verifiable certificate: CERTIFIED / CONDITIONAL / REJECTED. Runs every claim through the HPE verification stack; CERTIFIED only if NO known fault (CERTIFIED-precision 1.0 — never certifies a hallucinated deliverable). The trust layer the AI-worker gold rush is missing.")
|
|
19
|
+
.option("--json", "JSON output (the full signed certificate)")
|
|
20
|
+
.action((deliverable, opts) => {
|
|
21
|
+
let d = Array.isArray(deliverable) ? deliverable.join(" ") : String(deliverable ?? "");
|
|
22
|
+
if (d === "-") {
|
|
23
|
+
try {
|
|
24
|
+
d = readFileSync(0, "utf8");
|
|
25
|
+
}
|
|
26
|
+
catch { /* */ }
|
|
27
|
+
}
|
|
28
|
+
if (!d.trim()) {
|
|
29
|
+
out("usage: mneme certify \"<deliverable>\" (or pipe a file: cat report.md | mneme certify -)");
|
|
30
|
+
process.exitCode = 2;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const cert = vericert.certify(d, { ts: Date.now() });
|
|
34
|
+
let receipt = null;
|
|
35
|
+
try {
|
|
36
|
+
receipt = notary.issueReceipt(process.cwd(), { kind: "claim-verdict", subject: `vericert:${cert.verdict}:${cert.certId.slice(0, 12)}`, payload: { certId: cert.certId }, includePayload: true });
|
|
37
|
+
}
|
|
38
|
+
catch { /* */ }
|
|
39
|
+
const signed = { ...cert, signed: receipt };
|
|
40
|
+
if (opts.json) {
|
|
41
|
+
out(JSON.stringify(signed, null, 2));
|
|
42
|
+
process.exitCode = cert.verdict === "REJECTED" ? 2 : 0;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const icon = cert.verdict === "CERTIFIED" ? "🎗️ ✓" : cert.verdict === "CONDITIONAL" ? "🎗️ ❔" : "🎗️ 🛑";
|
|
46
|
+
out(`${icon} ${cert.verdict} (score ${(cert.score * 100).toFixed(0)}% · ${cert.trusted}/${cert.claimsChecked} claims clean)`);
|
|
47
|
+
out(` certId: ${cert.certId.slice(0, 24)}… ${receipt ? "· Ed25519-signed (verify offline)" : ""}`);
|
|
48
|
+
for (const f of cert.faults)
|
|
49
|
+
out(` ${f.verdict === "BLOCK" ? "🛑" : "❔"} ${f.nerves.join(",")}: ${f.claim.slice(0, 70)}`);
|
|
50
|
+
if (cert.verdict === "CERTIFIED")
|
|
51
|
+
out(` ✓ no known fault — safe to relay (CERTIFIED = no KNOWN fault, not a proof of truth).`);
|
|
52
|
+
process.exitCode = cert.verdict === "REJECTED" ? 2 : 0;
|
|
53
|
+
});
|
|
54
|
+
c.command("verify")
|
|
55
|
+
.description("verify a VERICERT certificate OFFLINE: tamper-evidence + (optionally) that it matches the deliverable + the Ed25519 signature.")
|
|
56
|
+
.requiredOption("--cert <file>", "the certificate JSON ('-' for stdin)")
|
|
57
|
+
.option("--deliverable <file>", "the original deliverable to re-check against")
|
|
58
|
+
.option("--json", "JSON output")
|
|
59
|
+
.action((o) => {
|
|
60
|
+
let cert;
|
|
61
|
+
try {
|
|
62
|
+
cert = JSON.parse(o.cert === "-" ? readFileSync(0, "utf8") : readFileSync(o.cert, "utf8"));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
out("✗ could not read/parse cert");
|
|
66
|
+
process.exitCode = 2;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let deliverable;
|
|
70
|
+
if (o.deliverable) {
|
|
71
|
+
try {
|
|
72
|
+
deliverable = readFileSync(o.deliverable, "utf8");
|
|
73
|
+
}
|
|
74
|
+
catch { /* */ }
|
|
75
|
+
}
|
|
76
|
+
const body = vericert.verifyCertBody(cert, deliverable);
|
|
77
|
+
let sigOk = null;
|
|
78
|
+
try {
|
|
79
|
+
if (cert.signed)
|
|
80
|
+
sigOk = notary.verifyReceipt(cert.signed).valid;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
sigOk = false;
|
|
84
|
+
}
|
|
85
|
+
if (o.json) {
|
|
86
|
+
out(JSON.stringify({ ...body, signatureValid: sigOk }, null, 2));
|
|
87
|
+
process.exitCode = body.ok ? 0 : 2;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
out(`${body.ok ? "✓ VALID" : "🛑 INVALID"} — ${body.reason}`);
|
|
91
|
+
if (sigOk !== null)
|
|
92
|
+
out(` Ed25519 signature: ${sigOk ? "✓ valid (offline)" : "🛑 invalid"}`);
|
|
93
|
+
process.exitCode = body.ok ? 0 : 2;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=vericert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vericert.js","sourceRoot":"","sources":["../../src/commands/vericert.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElD,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAEjE,MAAM,UAAU,wBAAwB,CAAC,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AAC,CAAC;QACxD,IAAI,KAAK,GAAmB,IAAI,CAAC;QACjC,IAAI,CAAC;YAAC,IAAI,IAAI,CAAC,MAAM;gBAAE,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,KAAK,GAAG,KAAK,CAAC;QAAC,CAAC;QAClG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO;QAAC,CAAC;QAC7H,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9D,IAAI,KAAK,KAAK,IAAI;YAAE,GAAG,CAAC,yBAAyB,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;QAC/F,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,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":"AAyMA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4mNvD"}
|
package/dist/index.js
CHANGED
|
@@ -131,6 +131,7 @@ import { registerCanonCommands } from "./commands/canon.js";
|
|
|
131
131
|
import { registerSdcCommands } from "./commands/sdc.js";
|
|
132
132
|
import { registerStatguardCommands } from "./commands/statguard.js";
|
|
133
133
|
import { registerHpeCommands } from "./commands/hpe.js";
|
|
134
|
+
import { registerVericertCommands } from "./commands/vericert.js";
|
|
134
135
|
import { registerMoatCommands } from "./commands/moat.js";
|
|
135
136
|
import { attachRegretOracle } from "./commands/regret.js";
|
|
136
137
|
import { registerTrustCommands } from "./commands/trust.js";
|
|
@@ -4819,6 +4820,7 @@ export async function run(argv) {
|
|
|
4819
4820
|
registerSdcCommands(program);
|
|
4820
4821
|
registerStatguardCommands(program);
|
|
4821
4822
|
registerHpeCommands(program);
|
|
4823
|
+
registerVericertCommands(program);
|
|
4822
4824
|
registerMoatCommands(program);
|
|
4823
4825
|
// ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
|
|
4824
4826
|
registerTrustCommands(program);
|