@mneme-ai/core 2.19.8 → 2.19.10
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/cosmic/aurelian_v1910.test.d.ts +2 -0
- package/dist/cosmic/aurelian_v1910.test.d.ts.map +1 -0
- package/dist/cosmic/aurelian_v1910.test.js +46 -0
- package/dist/cosmic/aurelian_v1910.test.js.map +1 -0
- package/dist/cosmic/aurelian_v199.test.d.ts +2 -0
- package/dist/cosmic/aurelian_v199.test.d.ts.map +1 -0
- package/dist/cosmic/aurelian_v199.test.js +33 -0
- package/dist/cosmic/aurelian_v199.test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/proof_carrying/index.d.ts +100 -0
- package/dist/proof_carrying/index.d.ts.map +1 -0
- package/dist/proof_carrying/index.js +184 -0
- package/dist/proof_carrying/index.js.map +1 -0
- package/dist/proof_carrying/proof_carrying.test.d.ts +2 -0
- package/dist/proof_carrying/proof_carrying.test.d.ts.map +1 -0
- package/dist/proof_carrying/proof_carrying.test.js +179 -0
- package/dist/proof_carrying/proof_carrying.test.js.map +1 -0
- package/dist/reverse_wrapper/index.d.ts +137 -0
- package/dist/reverse_wrapper/index.d.ts.map +1 -0
- package/dist/reverse_wrapper/index.js +245 -0
- package/dist/reverse_wrapper/index.js.map +1 -0
- package/dist/reverse_wrapper/reverse_wrapper.test.d.ts +2 -0
- package/dist/reverse_wrapper/reverse_wrapper.test.d.ts.map +1 -0
- package/dist/reverse_wrapper/reverse_wrapper.test.js +199 -0
- package/dist/reverse_wrapper/reverse_wrapper.test.js.map +1 -0
- package/dist/whats_new.d.ts.map +1 -1
- package/dist/whats_new.js +16 -0
- package/dist/whats_new.js.map +1 -1
- package/dist/wrapper_genesis/index.d.ts.map +1 -1
- package/dist/wrapper_genesis/index.js +11 -0
- package/dist/wrapper_genesis/index.js.map +1 -1
- package/dist/wrapper_genesplicing/index.d.ts +133 -0
- package/dist/wrapper_genesplicing/index.d.ts.map +1 -0
- package/dist/wrapper_genesplicing/index.js +301 -0
- package/dist/wrapper_genesplicing/index.js.map +1 -0
- package/dist/wrapper_genesplicing/wrapper_genesplicing.test.d.ts +2 -0
- package/dist/wrapper_genesplicing/wrapper_genesplicing.test.d.ts.map +1 -0
- package/dist/wrapper_genesplicing/wrapper_genesplicing.test.js +228 -0
- package/dist/wrapper_genesplicing/wrapper_genesplicing.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { attachProof, verifyProof, verifyChain, requireParentProof, fingerprintCaller, formatProofLine, } from "./index.js";
|
|
3
|
+
describe("v2.19.10 · PROOF-CARRYING WRAPPER", () => {
|
|
4
|
+
// ── attachProof ──────────────────────────────────────────────────
|
|
5
|
+
describe("attachProof", () => {
|
|
6
|
+
it("emits ProofedOutput with HMAC + sha256 + chainDepth=1 for root", () => {
|
|
7
|
+
const r = attachProof({
|
|
8
|
+
toolName: "mneme.test.t1",
|
|
9
|
+
input: { x: 1 },
|
|
10
|
+
output: { y: 2 },
|
|
11
|
+
callerKey: "ck-abc",
|
|
12
|
+
});
|
|
13
|
+
expect(r.proof.proofId).toMatch(/^p-[0-9a-f]{14}$/);
|
|
14
|
+
expect(r.proof.hmac).toMatch(/^[0-9a-f]{64}$/);
|
|
15
|
+
expect(r.proof.inputSha256).toMatch(/^[0-9a-f]{64}$/);
|
|
16
|
+
expect(r.proof.outputSha256).toMatch(/^[0-9a-f]{64}$/);
|
|
17
|
+
expect(r.proof.chainParent).toBeNull();
|
|
18
|
+
expect(r.proof.chainDepth).toBe(1);
|
|
19
|
+
expect(verifyProof(r).ok).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
it("chainDepth strictly increments per parent", () => {
|
|
22
|
+
const a = attachProof({ toolName: "T1", input: {}, output: { v: 1 }, callerKey: "ck" });
|
|
23
|
+
const b = attachProof({ toolName: "T2", input: { v: 1 }, output: { v: 2 }, callerKey: "ck", parentProof: a.proof });
|
|
24
|
+
const c = attachProof({ toolName: "T3", input: { v: 2 }, output: { v: 3 }, callerKey: "ck", parentProof: b.proof });
|
|
25
|
+
expect(a.proof.chainDepth).toBe(1);
|
|
26
|
+
expect(b.proof.chainDepth).toBe(2);
|
|
27
|
+
expect(c.proof.chainDepth).toBe(3);
|
|
28
|
+
});
|
|
29
|
+
it("rejects chains exceeding MAX_CHAIN_DEPTH=32 (loop guard)", () => {
|
|
30
|
+
let proof = attachProof({ toolName: "T", input: {}, output: {}, callerKey: "ck" }).proof;
|
|
31
|
+
for (let i = 0; i < 30; i++) {
|
|
32
|
+
proof = attachProof({ toolName: "T", input: {}, output: {}, callerKey: "ck", parentProof: proof }).proof;
|
|
33
|
+
}
|
|
34
|
+
// Depth is now 31; next attach takes us to 32; one more = 33 → throws
|
|
35
|
+
proof = attachProof({ toolName: "T", input: {}, output: {}, callerKey: "ck", parentProof: proof }).proof;
|
|
36
|
+
expect(() => attachProof({ toolName: "T", input: {}, output: {}, callerKey: "ck", parentProof: proof }))
|
|
37
|
+
.toThrow(/MAX_CHAIN_DEPTH/);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
// ── verifyProof ──────────────────────────────────────────────────
|
|
41
|
+
describe("verifyProof", () => {
|
|
42
|
+
it("returns ok=true on a clean ProofedOutput", () => {
|
|
43
|
+
const r = attachProof({ toolName: "T", input: { x: 1 }, output: { y: 2 }, callerKey: "ck" });
|
|
44
|
+
expect(verifyProof(r).ok).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
it("detects tampered output (sha mismatch)", () => {
|
|
47
|
+
const r = attachProof({ toolName: "T", input: { x: 1 }, output: { y: 2 }, callerKey: "ck" });
|
|
48
|
+
const tampered = { ...r, data: { y: 999 } };
|
|
49
|
+
const v = verifyProof(tampered);
|
|
50
|
+
expect(v.ok).toBe(false);
|
|
51
|
+
expect(v.reason).toContain("outputSha256 mismatch");
|
|
52
|
+
});
|
|
53
|
+
it("detects tampered proof metadata (HMAC mismatch)", () => {
|
|
54
|
+
const r = attachProof({ toolName: "T", input: {}, output: { z: 1 }, callerKey: "ck" });
|
|
55
|
+
const tampered = { ...r, proof: { ...r.proof, toolName: "EVIL.tool" } };
|
|
56
|
+
const v = verifyProof(tampered);
|
|
57
|
+
expect(v.ok).toBe(false);
|
|
58
|
+
expect(v.reason).toContain("HMAC mismatch");
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
// ── verifyChain ──────────────────────────────────────────────────
|
|
62
|
+
describe("verifyChain", () => {
|
|
63
|
+
it("returns ok=true on a properly-formed chain", () => {
|
|
64
|
+
const a = attachProof({ toolName: "T1", input: {}, output: { v: 1 }, callerKey: "ck" });
|
|
65
|
+
const b = attachProof({ toolName: "T2", input: { v: 1 }, output: { v: 2 }, callerKey: "ck", parentProof: a.proof });
|
|
66
|
+
const c = attachProof({ toolName: "T3", input: { v: 2 }, output: { v: 3 }, callerKey: "ck", parentProof: b.proof });
|
|
67
|
+
const r = verifyChain([a, b, c]);
|
|
68
|
+
expect(r.ok).toBe(true);
|
|
69
|
+
expect(r.dagDepth).toBe(3);
|
|
70
|
+
});
|
|
71
|
+
it("detects chain break (parent mismatch)", () => {
|
|
72
|
+
const a = attachProof({ toolName: "T1", input: {}, output: { v: 1 }, callerKey: "ck" });
|
|
73
|
+
const b = attachProof({ toolName: "T2", input: { v: 1 }, output: { v: 2 }, callerKey: "ck", parentProof: a.proof });
|
|
74
|
+
const stranger = attachProof({ toolName: "Tx", input: {}, output: { v: 99 }, callerKey: "ck" }); // root with no parent matching b
|
|
75
|
+
// Force a chain that pretends c follows b but c's chainParent is the stranger's id
|
|
76
|
+
const c = attachProof({ toolName: "T3", input: { v: 99 }, output: { v: 100 }, callerKey: "ck", parentProof: stranger.proof });
|
|
77
|
+
const r = verifyChain([a, b, c]);
|
|
78
|
+
expect(r.ok).toBe(false);
|
|
79
|
+
expect(r.reason).toContain("chain break");
|
|
80
|
+
});
|
|
81
|
+
it("detects loop (proofId reuse)", () => {
|
|
82
|
+
const a = attachProof({ toolName: "T1", input: {}, output: {}, callerKey: "ck" });
|
|
83
|
+
const b = attachProof({ toolName: "T2", input: {}, output: {}, callerKey: "ck", parentProof: a.proof });
|
|
84
|
+
const r = verifyChain([a, b, a]); // a reused
|
|
85
|
+
expect(r.ok).toBe(false);
|
|
86
|
+
expect(r.reason).toContain("loop detected");
|
|
87
|
+
});
|
|
88
|
+
it("root must have chainParent=null", () => {
|
|
89
|
+
const a = attachProof({ toolName: "T1", input: {}, output: {}, callerKey: "ck" });
|
|
90
|
+
const b = attachProof({ toolName: "T2", input: {}, output: {}, callerKey: "ck", parentProof: a.proof });
|
|
91
|
+
// Verify chain with b alone (as a fake root) — should fail because chainParent != null
|
|
92
|
+
const r = verifyChain([b]);
|
|
93
|
+
expect(r.ok).toBe(false);
|
|
94
|
+
expect(r.reason).toContain("root proof must have chainParent=null");
|
|
95
|
+
});
|
|
96
|
+
it("handles empty chain", () => {
|
|
97
|
+
expect(verifyChain([]).ok).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
// ── requireParentProof gate ─────────────────────────────────────
|
|
101
|
+
describe("requireParentProof gate", () => {
|
|
102
|
+
it("rejects calls without parentProof", async () => {
|
|
103
|
+
const gated = requireParentProof({
|
|
104
|
+
toolName: "T.gated",
|
|
105
|
+
callerKey: "ck",
|
|
106
|
+
inner: async () => ({ ok: true }),
|
|
107
|
+
});
|
|
108
|
+
await expect(gated({})).rejects.toThrow(/requires parentProof/);
|
|
109
|
+
});
|
|
110
|
+
it("rejects forged parentProof", async () => {
|
|
111
|
+
const gated = requireParentProof({
|
|
112
|
+
toolName: "T.gated",
|
|
113
|
+
callerKey: "ck",
|
|
114
|
+
inner: async () => ({ ok: true }),
|
|
115
|
+
});
|
|
116
|
+
const fake = {
|
|
117
|
+
v: 1, proofId: "p-fake", toolName: "x", inputSha256: "0".repeat(64),
|
|
118
|
+
outputSha256: "0".repeat(64), callerKey: "ck", chainParent: null, chainDepth: 1,
|
|
119
|
+
ts: "2026-01-01T00:00:00Z", hmac: "0".repeat(64),
|
|
120
|
+
};
|
|
121
|
+
await expect(gated({ parentProof: fake })).rejects.toThrow(/HMAC failed/);
|
|
122
|
+
});
|
|
123
|
+
it("accepts valid parentProof + chains the new proof", async () => {
|
|
124
|
+
const parent = attachProof({ toolName: "T.first", input: {}, output: { v: 1 }, callerKey: "ck" });
|
|
125
|
+
const gated = requireParentProof({
|
|
126
|
+
toolName: "T.second",
|
|
127
|
+
callerKey: "ck",
|
|
128
|
+
inner: async (args) => {
|
|
129
|
+
// parentProof should have been stripped
|
|
130
|
+
expect(args.parentProof).toBeUndefined();
|
|
131
|
+
return { v: 2 };
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
const r = await gated({ parentProof: parent.proof });
|
|
135
|
+
expect(r.proof.chainParent).toBe(parent.proof.proofId);
|
|
136
|
+
expect(r.proof.chainDepth).toBe(2);
|
|
137
|
+
expect(verifyProof(r).ok).toBe(true);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
// ── prompt-injection scenario ───────────────────────────────────
|
|
141
|
+
describe("prompt-injection rejection", () => {
|
|
142
|
+
it("forged tool output (fake proof attached) fails verifyProof", () => {
|
|
143
|
+
// Attacker tries to fake a TRUSTED proof and pass it to downstream tool
|
|
144
|
+
const fake = {
|
|
145
|
+
data: { evil: true },
|
|
146
|
+
proof: {
|
|
147
|
+
v: 1,
|
|
148
|
+
proofId: "p-malicious",
|
|
149
|
+
toolName: "mneme.confessional.audit",
|
|
150
|
+
inputSha256: "0".repeat(64),
|
|
151
|
+
outputSha256: "0".repeat(64),
|
|
152
|
+
callerKey: "ck-victim",
|
|
153
|
+
chainParent: null,
|
|
154
|
+
chainDepth: 1,
|
|
155
|
+
ts: new Date().toISOString(),
|
|
156
|
+
hmac: "0".repeat(64),
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
expect(verifyProof(fake).ok).toBe(false);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
// ── helpers ─────────────────────────────────────────────────────
|
|
163
|
+
describe("helpers", () => {
|
|
164
|
+
it("fingerprintCaller produces deterministic short key", () => {
|
|
165
|
+
const a = fingerprintCaller({ vendor: "claude", sessionId: "s1", repoPath: "/tmp/x" });
|
|
166
|
+
const b = fingerprintCaller({ vendor: "claude", sessionId: "s1", repoPath: "/tmp/x" });
|
|
167
|
+
const c = fingerprintCaller({ vendor: "claude", sessionId: "s2", repoPath: "/tmp/x" });
|
|
168
|
+
expect(a).toBe(b);
|
|
169
|
+
expect(a).not.toBe(c);
|
|
170
|
+
expect(a).toMatch(/^ck-[0-9a-f]{16}$/);
|
|
171
|
+
});
|
|
172
|
+
it("formatProofLine summarises", () => {
|
|
173
|
+
const p = attachProof({ toolName: "T", input: {}, output: {}, callerKey: "ck" });
|
|
174
|
+
expect(formatProofLine(p.proof)).toContain("PROOF");
|
|
175
|
+
expect(formatProofLine(p.proof)).toContain("(root)");
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=proof_carrying.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof_carrying.test.js","sourceRoot":"","sources":["../../src/proof_carrying/proof_carrying.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,EAC5E,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QAC3B,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;YACxE,MAAM,CAAC,GAAG,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PPER (tool suggests next tool)
|
|
3
|
+
*
|
|
4
|
+
* "MCP spec is pull-only — clients ask, servers answer. Mneme bends
|
|
5
|
+
* the contract (without breaking it): every wrapper response can
|
|
6
|
+
* attach an OPTIONAL `__suggested_next_call` field with the tool
|
|
7
|
+
* name + reasoning + confidence + cost estimate. The AI agent's
|
|
8
|
+
* planner sees the suggestion; if it's smart, it follows. If it
|
|
9
|
+
* isn't, nothing breaks. Pure additive layer over MCP.
|
|
10
|
+
*
|
|
11
|
+
* Bonus: telemetry. We log every suggestion + whether the AI
|
|
12
|
+
* followed within N calls. Follow-through rate measures BOTH:
|
|
13
|
+
* • the quality of the suggestion (high follow → good tool design)
|
|
14
|
+
* • the calibration of the AI (high follow → AI listens to hints)
|
|
15
|
+
* Loop detection: refuses to suggest a tool that was in the last K
|
|
16
|
+
* invocations of the current session."
|
|
17
|
+
*
|
|
18
|
+
* Honest scope:
|
|
19
|
+
* - The suggestion is ADVISORY. The AI agent's planner makes the
|
|
20
|
+
* final decision. We never auto-invoke anything.
|
|
21
|
+
* - Loop detection is per-session (caller supplies session id) and
|
|
22
|
+
* uses a sliding window (default last 8 invocations).
|
|
23
|
+
* - Suggestion rules can be hand-written OR mined from test corpus
|
|
24
|
+
* by AUTO-GENESIS (we expose the rule shape; the mining is left
|
|
25
|
+
* to the caller / future v2.20).
|
|
26
|
+
*
|
|
27
|
+
* Composes onto every MCP tool + v2.19.9 GENESPLICING (chimera's
|
|
28
|
+
* sequential mode follows the suggestion chain) + v2.19.10
|
|
29
|
+
* PROOF-CARRYING (the suggestion can carry a proof of where it came
|
|
30
|
+
* from). Pure additive layer.
|
|
31
|
+
*/
|
|
32
|
+
declare const PROTOCOL_VERSION: 1;
|
|
33
|
+
export interface SuggestedNext {
|
|
34
|
+
v: typeof PROTOCOL_VERSION;
|
|
35
|
+
suggestedNextId: string;
|
|
36
|
+
/** Recommended next tool name (e.g., "mneme.chronostasis.witness"). */
|
|
37
|
+
tool: string;
|
|
38
|
+
/** Human-readable rationale. */
|
|
39
|
+
why: string;
|
|
40
|
+
/** Confidence 0..1 the suggestion is right. */
|
|
41
|
+
confidence: number;
|
|
42
|
+
/** Optional USD cost estimate for the suggested call. */
|
|
43
|
+
costEstimateUsd?: number;
|
|
44
|
+
/** Optional pre-filled args (planner can adjust). */
|
|
45
|
+
suggestedArgs?: Record<string, unknown>;
|
|
46
|
+
/** Why this WASN'T suggested? (set when suppressed by loop detection). */
|
|
47
|
+
suppressedReason?: string;
|
|
48
|
+
ts: string;
|
|
49
|
+
sig: string;
|
|
50
|
+
}
|
|
51
|
+
/** Wrapper output with optional suggested-next attached. */
|
|
52
|
+
export interface OutputWithSuggestion<T = unknown> {
|
|
53
|
+
data: T;
|
|
54
|
+
__suggested_next?: SuggestedNext;
|
|
55
|
+
}
|
|
56
|
+
export interface SuggestionRule {
|
|
57
|
+
/** Name of the tool whose output triggers this rule. */
|
|
58
|
+
forTool: string;
|
|
59
|
+
/** Optional predicate over the output; if false, rule doesn't fire. */
|
|
60
|
+
predicate?: (output: unknown) => boolean;
|
|
61
|
+
/** Suggested next tool. */
|
|
62
|
+
suggestTool: string;
|
|
63
|
+
/** Why this suggestion. */
|
|
64
|
+
why: string;
|
|
65
|
+
/** Baseline confidence (0..1). */
|
|
66
|
+
confidence: number;
|
|
67
|
+
/** Optional cost estimate USD. */
|
|
68
|
+
costEstimateUsd?: number;
|
|
69
|
+
/** Optional args builder. */
|
|
70
|
+
buildArgs?: (output: unknown) => Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
export interface FollowThroughEvent {
|
|
73
|
+
/** Session this telemetry belongs to. */
|
|
74
|
+
sessionId: string;
|
|
75
|
+
/** The suggestion that was emitted. */
|
|
76
|
+
suggestion: SuggestedNext;
|
|
77
|
+
/** Was the next call to the suggested tool within window N? */
|
|
78
|
+
followed: boolean;
|
|
79
|
+
/** Number of invocations between suggestion + follow (or window expiry). */
|
|
80
|
+
invocationsBetween: number;
|
|
81
|
+
recordedAt: string;
|
|
82
|
+
}
|
|
83
|
+
export declare class ReverseWrapperSession {
|
|
84
|
+
private callHistory;
|
|
85
|
+
private pendingSuggestions;
|
|
86
|
+
private followEvents;
|
|
87
|
+
private secret;
|
|
88
|
+
readonly sessionId: string;
|
|
89
|
+
readonly loopWindow: number;
|
|
90
|
+
constructor(opts: {
|
|
91
|
+
sessionId: string;
|
|
92
|
+
loopWindow?: number;
|
|
93
|
+
secret?: string;
|
|
94
|
+
});
|
|
95
|
+
/** Record that a tool was just called. Updates loop-detection state + checks pending suggestions. */
|
|
96
|
+
recordCall(toolName: string, nowMs?: number): void;
|
|
97
|
+
/**
|
|
98
|
+
* Apply suggestion rules to a (currentTool, output) pair. Returns a
|
|
99
|
+
* SuggestedNext if any rule fires AND it doesn't trigger loop detection.
|
|
100
|
+
*/
|
|
101
|
+
suggestNext(input: {
|
|
102
|
+
currentTool: string;
|
|
103
|
+
output: unknown;
|
|
104
|
+
rules: SuggestionRule[];
|
|
105
|
+
nowMs?: number;
|
|
106
|
+
}): SuggestedNext | null;
|
|
107
|
+
/** Attach a suggestion to a wrapper output (mutation-free). */
|
|
108
|
+
attachSuggestion<T>(input: {
|
|
109
|
+
output: T;
|
|
110
|
+
currentTool: string;
|
|
111
|
+
rules: SuggestionRule[];
|
|
112
|
+
nowMs?: number;
|
|
113
|
+
}): OutputWithSuggestion<T>;
|
|
114
|
+
followThroughStats(): {
|
|
115
|
+
totalSuggestions: number;
|
|
116
|
+
followed: number;
|
|
117
|
+
expired: number;
|
|
118
|
+
followRate: number;
|
|
119
|
+
pendingNow: number;
|
|
120
|
+
perToolBreakdown: Array<{
|
|
121
|
+
tool: string;
|
|
122
|
+
suggested: number;
|
|
123
|
+
followed: number;
|
|
124
|
+
rate: number;
|
|
125
|
+
}>;
|
|
126
|
+
};
|
|
127
|
+
recentHistory(n?: number): Array<{
|
|
128
|
+
tool: string;
|
|
129
|
+
ts: number;
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
export declare function verifySuggestion(s: SuggestedNext, secret?: string): boolean;
|
|
133
|
+
export declare function formatSuggestionLine(s: SuggestedNext): string;
|
|
134
|
+
/** Built-in suggestion rules shipped with v2.19.10. Extensible. */
|
|
135
|
+
export declare const BUILTIN_RULES: SuggestionRule[];
|
|
136
|
+
export {};
|
|
137
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reverse_wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,QAAA,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAGpC,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,OAAO,gBAAgB,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC/C,IAAI,EAAE,CAAC,CAAC;IACR,gBAAgB,CAAC,EAAE,aAAa,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;IACzC,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB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M,EAAE,CAAC,CAAC;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,cAAc,EAAE,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,oBAAoB,CAAC,CAAC,CAAC;IAW3B,kBAAkB,IAAI;QACpB,gBAAgB,EAAE,MAAM,CAAC;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC9F;IAwBD,aAAa,CAAC,CAAC,GAAE,MAAU,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CAGlE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAG3E;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAG7D;AAED,mEAAmE;AACnE,eAAO,MAAM,aAAa,EAAE,cAAc,EA+CzC,CAAC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.19.10 — MNEME REVERSE-WRAPPER (tool suggests next tool)
|
|
3
|
+
*
|
|
4
|
+
* "MCP spec is pull-only — clients ask, servers answer. Mneme bends
|
|
5
|
+
* the contract (without breaking it): every wrapper response can
|
|
6
|
+
* attach an OPTIONAL `__suggested_next_call` field with the tool
|
|
7
|
+
* name + reasoning + confidence + cost estimate. The AI agent's
|
|
8
|
+
* planner sees the suggestion; if it's smart, it follows. If it
|
|
9
|
+
* isn't, nothing breaks. Pure additive layer over MCP.
|
|
10
|
+
*
|
|
11
|
+
* Bonus: telemetry. We log every suggestion + whether the AI
|
|
12
|
+
* followed within N calls. Follow-through rate measures BOTH:
|
|
13
|
+
* • the quality of the suggestion (high follow → good tool design)
|
|
14
|
+
* • the calibration of the AI (high follow → AI listens to hints)
|
|
15
|
+
* Loop detection: refuses to suggest a tool that was in the last K
|
|
16
|
+
* invocations of the current session."
|
|
17
|
+
*
|
|
18
|
+
* Honest scope:
|
|
19
|
+
* - The suggestion is ADVISORY. The AI agent's planner makes the
|
|
20
|
+
* final decision. We never auto-invoke anything.
|
|
21
|
+
* - Loop detection is per-session (caller supplies session id) and
|
|
22
|
+
* uses a sliding window (default last 8 invocations).
|
|
23
|
+
* - Suggestion rules can be hand-written OR mined from test corpus
|
|
24
|
+
* by AUTO-GENESIS (we expose the rule shape; the mining is left
|
|
25
|
+
* to the caller / future v2.20).
|
|
26
|
+
*
|
|
27
|
+
* Composes onto every MCP tool + v2.19.9 GENESPLICING (chimera's
|
|
28
|
+
* sequential mode follows the suggestion chain) + v2.19.10
|
|
29
|
+
* PROOF-CARRYING (the suggestion can carry a proof of where it came
|
|
30
|
+
* from). Pure additive layer.
|
|
31
|
+
*/
|
|
32
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
33
|
+
const PROTOCOL_VERSION = 1;
|
|
34
|
+
const DEFAULT_LOOP_WINDOW = 8;
|
|
35
|
+
function canon(v) {
|
|
36
|
+
if (v === null || typeof v !== "object")
|
|
37
|
+
return JSON.stringify(v);
|
|
38
|
+
if (Array.isArray(v))
|
|
39
|
+
return "[" + v.map(canon).join(",") + "]";
|
|
40
|
+
const keys = Object.keys(v).sort();
|
|
41
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canon(v[k])).join(",") + "}";
|
|
42
|
+
}
|
|
43
|
+
function defaultSecret() {
|
|
44
|
+
return process.env["MNEME_REVERSE_WRAPPER_SECRET"] || `mneme-reverse-wrapper-v${PROTOCOL_VERSION}`;
|
|
45
|
+
}
|
|
46
|
+
function hmac(body, secret) {
|
|
47
|
+
return createHmac("sha256", secret).update(canon(body)).digest("hex");
|
|
48
|
+
}
|
|
49
|
+
function safeEqHex(a, b) {
|
|
50
|
+
try {
|
|
51
|
+
return timingSafeEqual(Buffer.from(a, "hex"), Buffer.from(b, "hex"));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// ─── Session call history (for loop detection + follow-through) ─────────
|
|
58
|
+
export class ReverseWrapperSession {
|
|
59
|
+
callHistory = [];
|
|
60
|
+
pendingSuggestions = [];
|
|
61
|
+
followEvents = [];
|
|
62
|
+
secret;
|
|
63
|
+
sessionId;
|
|
64
|
+
loopWindow;
|
|
65
|
+
constructor(opts) {
|
|
66
|
+
this.sessionId = opts.sessionId;
|
|
67
|
+
this.loopWindow = opts.loopWindow ?? DEFAULT_LOOP_WINDOW;
|
|
68
|
+
this.secret = opts.secret ?? defaultSecret();
|
|
69
|
+
}
|
|
70
|
+
/** Record that a tool was just called. Updates loop-detection state + checks pending suggestions. */
|
|
71
|
+
recordCall(toolName, nowMs) {
|
|
72
|
+
const ts = nowMs ?? Date.now();
|
|
73
|
+
this.callHistory.push({ tool: toolName, ts });
|
|
74
|
+
// Check any pending suggestions: did this call satisfy them?
|
|
75
|
+
const currentIdx = this.callHistory.length - 1;
|
|
76
|
+
for (const ps of this.pendingSuggestions) {
|
|
77
|
+
const between = currentIdx - ps.emittedAtIdx;
|
|
78
|
+
if (between > this.loopWindow) {
|
|
79
|
+
// Expired without follow-through
|
|
80
|
+
this.followEvents.push({
|
|
81
|
+
sessionId: this.sessionId,
|
|
82
|
+
suggestion: ps.suggestion,
|
|
83
|
+
followed: false,
|
|
84
|
+
invocationsBetween: between,
|
|
85
|
+
recordedAt: new Date(ts).toISOString(),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else if (ps.suggestion.tool === toolName) {
|
|
89
|
+
// Followed!
|
|
90
|
+
this.followEvents.push({
|
|
91
|
+
sessionId: this.sessionId,
|
|
92
|
+
suggestion: ps.suggestion,
|
|
93
|
+
followed: true,
|
|
94
|
+
invocationsBetween: between,
|
|
95
|
+
recordedAt: new Date(ts).toISOString(),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Prune pending: keep only ones not yet resolved
|
|
100
|
+
this.pendingSuggestions = this.pendingSuggestions.filter((ps) => {
|
|
101
|
+
const between = currentIdx - ps.emittedAtIdx;
|
|
102
|
+
const expired = between > this.loopWindow;
|
|
103
|
+
const followed = ps.suggestion.tool === toolName;
|
|
104
|
+
return !expired && !followed;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Apply suggestion rules to a (currentTool, output) pair. Returns a
|
|
109
|
+
* SuggestedNext if any rule fires AND it doesn't trigger loop detection.
|
|
110
|
+
*/
|
|
111
|
+
suggestNext(input) {
|
|
112
|
+
const ts = input.nowMs ?? Date.now();
|
|
113
|
+
// Find first matching rule
|
|
114
|
+
const matched = input.rules.find((r) => r.forTool === input.currentTool && (!r.predicate || r.predicate(input.output)));
|
|
115
|
+
if (!matched)
|
|
116
|
+
return null;
|
|
117
|
+
// Build the suggestion
|
|
118
|
+
const buildId = () => "sn-" + createHmac("sha256", "mneme-reverse-sn-id")
|
|
119
|
+
.update(`${this.sessionId}|${matched.suggestTool}|${ts}`)
|
|
120
|
+
.digest("hex").slice(0, 14);
|
|
121
|
+
const suggestedNextId = buildId();
|
|
122
|
+
const baseBody = {
|
|
123
|
+
v: PROTOCOL_VERSION,
|
|
124
|
+
suggestedNextId,
|
|
125
|
+
tool: matched.suggestTool,
|
|
126
|
+
why: matched.why,
|
|
127
|
+
confidence: matched.confidence,
|
|
128
|
+
...(matched.costEstimateUsd !== undefined ? { costEstimateUsd: matched.costEstimateUsd } : {}),
|
|
129
|
+
...(matched.buildArgs ? { suggestedArgs: matched.buildArgs(input.output) } : {}),
|
|
130
|
+
ts: new Date(ts).toISOString(),
|
|
131
|
+
};
|
|
132
|
+
// Loop detection: is suggestTool in the recent window?
|
|
133
|
+
const recentTools = this.callHistory.slice(-this.loopWindow).map((c) => c.tool);
|
|
134
|
+
if (recentTools.includes(matched.suggestTool)) {
|
|
135
|
+
const suppressed = {
|
|
136
|
+
...baseBody,
|
|
137
|
+
suppressedReason: `loop guard: '${matched.suggestTool}' called within last ${this.loopWindow} invocations`,
|
|
138
|
+
};
|
|
139
|
+
const sig = hmac(suppressed, this.secret);
|
|
140
|
+
return { ...suppressed, sig };
|
|
141
|
+
}
|
|
142
|
+
const sig = hmac(baseBody, this.secret);
|
|
143
|
+
const suggestion = { ...baseBody, sig };
|
|
144
|
+
// Track as pending so we can measure follow-through
|
|
145
|
+
this.pendingSuggestions.push({ suggestion, emittedAtIdx: this.callHistory.length - 1 });
|
|
146
|
+
return suggestion;
|
|
147
|
+
}
|
|
148
|
+
/** Attach a suggestion to a wrapper output (mutation-free). */
|
|
149
|
+
attachSuggestion(input) {
|
|
150
|
+
const sn = this.suggestNext({
|
|
151
|
+
currentTool: input.currentTool,
|
|
152
|
+
output: input.output,
|
|
153
|
+
rules: input.rules,
|
|
154
|
+
...(input.nowMs !== undefined ? { nowMs: input.nowMs } : {}),
|
|
155
|
+
});
|
|
156
|
+
if (!sn)
|
|
157
|
+
return { data: input.output };
|
|
158
|
+
return { data: input.output, __suggested_next: sn };
|
|
159
|
+
}
|
|
160
|
+
followThroughStats() {
|
|
161
|
+
const totalSuggestions = this.followEvents.length + this.pendingSuggestions.length;
|
|
162
|
+
const followed = this.followEvents.filter((e) => e.followed).length;
|
|
163
|
+
const expired = this.followEvents.filter((e) => !e.followed).length;
|
|
164
|
+
const decided = followed + expired;
|
|
165
|
+
const followRate = decided === 0 ? 0 : Math.round((followed / decided) * 1000) / 1000;
|
|
166
|
+
const perToolMap = new Map();
|
|
167
|
+
for (const e of this.followEvents) {
|
|
168
|
+
const m = perToolMap.get(e.suggestion.tool) ?? { suggested: 0, followed: 0 };
|
|
169
|
+
m.suggested++;
|
|
170
|
+
if (e.followed)
|
|
171
|
+
m.followed++;
|
|
172
|
+
perToolMap.set(e.suggestion.tool, m);
|
|
173
|
+
}
|
|
174
|
+
const perToolBreakdown = Array.from(perToolMap.entries()).map(([tool, m]) => ({
|
|
175
|
+
tool, suggested: m.suggested, followed: m.followed,
|
|
176
|
+
rate: m.suggested === 0 ? 0 : Math.round((m.followed / m.suggested) * 1000) / 1000,
|
|
177
|
+
})).sort((a, b) => b.rate - a.rate);
|
|
178
|
+
return {
|
|
179
|
+
totalSuggestions, followed, expired, followRate,
|
|
180
|
+
pendingNow: this.pendingSuggestions.length,
|
|
181
|
+
perToolBreakdown,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
recentHistory(n = 8) {
|
|
185
|
+
return this.callHistory.slice(-n);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export function verifySuggestion(s, secret) {
|
|
189
|
+
const { sig, ...body } = s;
|
|
190
|
+
return safeEqHex(hmac(body, secret ?? defaultSecret()), sig);
|
|
191
|
+
}
|
|
192
|
+
export function formatSuggestionLine(s) {
|
|
193
|
+
const icon = s.suppressedReason ? "🔁" : "🪂";
|
|
194
|
+
return `${icon} SUGGEST · ${s.tool} · conf=${s.confidence}${s.costEstimateUsd ? ` · $${s.costEstimateUsd}` : ""}${s.suppressedReason ? " · SUPPRESSED" : ""}`;
|
|
195
|
+
}
|
|
196
|
+
/** Built-in suggestion rules shipped with v2.19.10. Extensible. */
|
|
197
|
+
export const BUILTIN_RULES = [
|
|
198
|
+
{
|
|
199
|
+
forTool: "mneme.inverse.audit",
|
|
200
|
+
predicate: (out) => {
|
|
201
|
+
const data = out ?? {};
|
|
202
|
+
const v = ("data" in data ? data.data?.verdict : data.verdict) ?? "";
|
|
203
|
+
return v === "rejected";
|
|
204
|
+
},
|
|
205
|
+
suggestTool: "mneme.chronostasis.tick",
|
|
206
|
+
why: "Rejected output should trigger CHRONOSTASIS witness pool to rewind dependents.",
|
|
207
|
+
confidence: 0.92,
|
|
208
|
+
costEstimateUsd: 0.003,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
forTool: "mneme.confessional.audit",
|
|
212
|
+
predicate: (out) => {
|
|
213
|
+
const data = out ?? {};
|
|
214
|
+
const v = ("data" in data ? data.data?.verdict : data.verdict) ?? "";
|
|
215
|
+
return v === "block" || v === "flag";
|
|
216
|
+
},
|
|
217
|
+
suggestTool: "mneme.inverse.audit",
|
|
218
|
+
why: "Flagged/blocked diff should be re-audited by the rarer output→input direction.",
|
|
219
|
+
confidence: 0.78,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
forTool: "mneme.chronostasis.propose",
|
|
223
|
+
suggestTool: "mneme.chronostasis.witness_prompt",
|
|
224
|
+
why: "Newly proposed claim should immediately get a witness panel summons.",
|
|
225
|
+
confidence: 0.85,
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
forTool: "mneme.agreement.compile",
|
|
229
|
+
suggestTool: "mneme.agreement.pre_commit_hook",
|
|
230
|
+
why: "Compiled agreement should be wired into the pre-commit gate.",
|
|
231
|
+
confidence: 0.88,
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
forTool: "mneme.dream.run",
|
|
235
|
+
predicate: (out) => {
|
|
236
|
+
const r = out;
|
|
237
|
+
const c = "data" in r ? r.data?.candidatesEmitted : r.candidatesEmitted;
|
|
238
|
+
return (c ?? 0) > 0;
|
|
239
|
+
},
|
|
240
|
+
suggestTool: "mneme.dream.review",
|
|
241
|
+
why: "Dream cycle emitted candidates — parent should review (confirm or refute).",
|
|
242
|
+
confidence: 0.90,
|
|
243
|
+
},
|
|
244
|
+
];
|
|
245
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reverse_wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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AC5F,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAE,CAAoC,CAAC,iBAAiB,CAAC;YAC5G,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QACD,WAAW,EAAE,oBAAoB;QACjC,GAAG,EAAE,4EAA4E;QACjF,UAAU,EAAE,IAAI;KACjB;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse_wrapper.test.d.ts","sourceRoot":"","sources":["../../src/reverse_wrapper/reverse_wrapper.test.ts"],"names":[],"mappings":""}
|