@mneme-ai/core 2.103.0 → 2.105.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/agent_manifest.d.ts.map +1 -1
- package/dist/agent_manifest.js +9 -3
- package/dist/agent_manifest.js.map +1 -1
- package/dist/cortex/cortex.test.d.ts +2 -0
- package/dist/cortex/cortex.test.d.ts.map +1 -0
- package/dist/cortex/cortex.test.js +102 -0
- package/dist/cortex/cortex.test.js.map +1 -0
- package/dist/cortex/index.d.ts +159 -0
- package/dist/cortex/index.d.ts.map +1 -0
- package/dist/cortex/index.js +263 -0
- package/dist/cortex/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/notary/keys.d.ts.map +1 -1
- package/dist/notary/keys.js +6 -1
- package/dist/notary/keys.js.map +1 -1
- package/dist/truth_gate/probes.d.ts.map +1 -1
- package/dist/truth_gate/probes.js +22 -0
- package/dist/truth_gate/probes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { emptyStore, contribute, recall, verifyEntry, handoff, activeView, cortexGauntlet, reconcile, reconcileGauntlet } from "./index.js";
|
|
3
|
+
const R = process.cwd();
|
|
4
|
+
describe("v2.104 THE COGNITIVE CORTEX — Sovereign Memory Bus", () => {
|
|
5
|
+
it("contribute → recall round-trips (any agent can read what another wrote)", () => {
|
|
6
|
+
let s = emptyStore();
|
|
7
|
+
s = contribute(R, s, { agent: "claude", key: "build.cmd", value: "npm run build", kind: "fact" }, 1).store;
|
|
8
|
+
const hits = recall(s, "build command");
|
|
9
|
+
expect(hits.length).toBeGreaterThan(0);
|
|
10
|
+
expect(hits[0].entry.value).toBe("npm run build");
|
|
11
|
+
});
|
|
12
|
+
it("identical fact from a different agent is a DUPLICATE (agents agree)", () => {
|
|
13
|
+
let s = emptyStore();
|
|
14
|
+
s = contribute(R, s, { agent: "claude", key: "k", value: "v" }, 1).store;
|
|
15
|
+
const r = contribute(R, s, { agent: "gpt", key: "k", value: "v" }, 2);
|
|
16
|
+
expect(r.result.verdict).toBe("DUPLICATE");
|
|
17
|
+
});
|
|
18
|
+
it("THE GATEKEEPER — a conflicting value is QUARANTINED, not silently overwritten", () => {
|
|
19
|
+
let s = emptyStore();
|
|
20
|
+
s = contribute(R, s, { agent: "claude", key: "db.url", value: "postgres://prod" }, 1).store;
|
|
21
|
+
const conf = contribute(R, s, { agent: "grok", key: "db.url", value: "postgres://EVIL" }, 2);
|
|
22
|
+
expect(conf.result.verdict).toBe("QUARANTINED");
|
|
23
|
+
expect(conf.result.conflictsWith).toBeTruthy();
|
|
24
|
+
// established memory is unchanged — the mesh was not poisoned
|
|
25
|
+
expect(activeView(conf.store).get("db.url")?.value).toBe("postgres://prod");
|
|
26
|
+
});
|
|
27
|
+
it("a DECLARED update supersedes (opts.update) — drift only by consent", () => {
|
|
28
|
+
let s = emptyStore();
|
|
29
|
+
s = contribute(R, s, { agent: "claude", key: "db.url", value: "v1" }, 1).store;
|
|
30
|
+
const upd = contribute(R, s, { agent: "claude", key: "db.url", value: "v2" }, 2, { update: true });
|
|
31
|
+
expect(upd.result.verdict).toBe("UPDATED");
|
|
32
|
+
expect(activeView(upd.store).get("db.url")?.value).toBe("v2");
|
|
33
|
+
});
|
|
34
|
+
it("every entry is Ed25519-signed + offline-verifiable; tampering ANY signed field is caught", () => {
|
|
35
|
+
let s = emptyStore();
|
|
36
|
+
s = contribute(R, s, { agent: "claude", key: "k", value: "v", kind: "fact" }, 1).store;
|
|
37
|
+
const e = activeView(s).get("k");
|
|
38
|
+
expect(verifyEntry(e).bound).toBe(true);
|
|
39
|
+
// every signed field must be bound (regression: v2.104 review found kind+at unbound)
|
|
40
|
+
for (const mut of [
|
|
41
|
+
(x) => { x.value = "HACKED"; },
|
|
42
|
+
(x) => { x.agent = "evil"; },
|
|
43
|
+
(x) => { x.key = "other"; },
|
|
44
|
+
(x) => { x.kind = "warning"; },
|
|
45
|
+
(x) => { x.at = 999999; },
|
|
46
|
+
(x) => { x.supersedes = "fake"; },
|
|
47
|
+
]) {
|
|
48
|
+
const t = JSON.parse(JSON.stringify(e));
|
|
49
|
+
mut(t);
|
|
50
|
+
expect(verifyEntry(t).bound).toBe(false);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
it("TOTAL — issueReceipt-backed functions never throw on a null repoRoot (v2.104 review)", () => {
|
|
54
|
+
expect(() => handoff(null, emptyStore(), "x", 1)).not.toThrow();
|
|
55
|
+
expect(() => contribute(null, emptyStore(), { agent: "a", key: "k", value: "v" }, 1)).not.toThrow();
|
|
56
|
+
});
|
|
57
|
+
it("handoff builds a SIGNED context capsule of the live shared memory", () => {
|
|
58
|
+
let s = emptyStore();
|
|
59
|
+
s = contribute(R, s, { agent: "claude", key: "a", value: "1" }, 1).store;
|
|
60
|
+
s = contribute(R, s, { agent: "gpt", key: "b", value: "2" }, 2).store;
|
|
61
|
+
const cap = handoff(R, s, "gemini", 3);
|
|
62
|
+
expect(cap.facts.length).toBe(2);
|
|
63
|
+
expect(cap.toAgent).toBe("gemini");
|
|
64
|
+
expect(typeof cap.receipt.sig).toBe("string");
|
|
65
|
+
});
|
|
66
|
+
it("cortex gauntlet scores 100 (round-trip ∧ quarantine ∧ signed ∧ tamper ∧ deterministic ∧ stable)", () => {
|
|
67
|
+
const g = cortexGauntlet(R, 1700000000000);
|
|
68
|
+
expect(g.roundTrip).toBe(true);
|
|
69
|
+
expect(g.quarantinesConflict).toBe(true);
|
|
70
|
+
expect(g.signed).toBe(true);
|
|
71
|
+
expect(g.tamperCaught).toBe(true);
|
|
72
|
+
expect(g.deterministic).toBe(true);
|
|
73
|
+
expect(g.stable).toBe(true);
|
|
74
|
+
expect(g.score).toBe(100);
|
|
75
|
+
});
|
|
76
|
+
it("RECONCILIATION (the magical power) — resolves a verifiably-false conflict BY PROOF", async () => {
|
|
77
|
+
const r = await reconcile(R, { agent: "claude", value: "2+2=4" }, { agent: "grok", value: "2+2=5" }, 1700000000000);
|
|
78
|
+
expect(r.resolution).toBe("proof");
|
|
79
|
+
expect(r.winner?.value).toBe("2+2=4");
|
|
80
|
+
expect(r.loser?.value).toBe("2+2=5");
|
|
81
|
+
});
|
|
82
|
+
it("RECONCILIATION — two unprovable opinions stay UNRESOLVED (no auto-decide; Padgett)", async () => {
|
|
83
|
+
const r = await reconcile(R, { agent: "claude", value: "fly.io is the target" }, { agent: "grok", value: "vercel is the target" }, 1700000000000);
|
|
84
|
+
expect(r.resolution).toBe("unresolved");
|
|
85
|
+
expect(r.winner).toBeNull();
|
|
86
|
+
});
|
|
87
|
+
it("reconcile gauntlet scores 100 (proof-resolves ∧ opinion-unresolved ∧ signed ∧ stable)", async () => {
|
|
88
|
+
const g = await reconcileGauntlet(R, 1700000000000);
|
|
89
|
+
expect(g.proofResolves).toBe(true);
|
|
90
|
+
expect(g.opinionUnresolved).toBe(true);
|
|
91
|
+
expect(g.signed).toBe(true);
|
|
92
|
+
expect(g.score).toBe(100);
|
|
93
|
+
});
|
|
94
|
+
it("STABILITY — total on garbage", () => {
|
|
95
|
+
expect(() => contribute(R, null, null, 0)).not.toThrow();
|
|
96
|
+
expect(contribute(R, null, null, 0).result.verdict).toBe("QUARANTINED");
|
|
97
|
+
expect(recall(null, null)).toEqual([]);
|
|
98
|
+
expect(verifyEntry(null).bound).toBe(false);
|
|
99
|
+
expect(cortexGauntlet(R, 0).score).toBe(100); // gauntlet builds its own data
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=cortex.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cortex.test.js","sourceRoot":"","sources":["../../src/cortex/cortex.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO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AC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAa,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAC3E,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,IAAa,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1F,MAAM,CAAC,MAAM,CAAC,IAAa,EAAE,IAAa,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzD,MAAM,CAAC,WAAW,CAAC,IAAa,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAG,+BAA+B;IACjF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.104.0 — THE COGNITIVE CORTEX (Sovereign Memory Bus).
|
|
3
|
+
*
|
|
4
|
+
* The honest, buildable heart of the "Universal Memory Bus / Cognitive Mesh"
|
|
5
|
+
* vision: a LOCAL, vendor-neutral, SIGNED, drift-guarded shared memory that
|
|
6
|
+
* ANY AI agent — Grok / GPT / Gemini / Claude / Codex / a local model —
|
|
7
|
+
* contributes to and recalls from. Mneme is the LOGIC GATEKEEPER: every
|
|
8
|
+
* contribution is Ed25519-signed (provenance) and, critically, a value that
|
|
9
|
+
* CONTRADICTS established shared memory is QUARANTINED, not silently
|
|
10
|
+
* overwritten — so the mesh cannot be poisoned or drift out from under the
|
|
11
|
+
* agents sharing it.
|
|
12
|
+
*
|
|
13
|
+
* DIAKRISIS — what this deliberately is NOT: it is not a kernel driver and
|
|
14
|
+
* not process/VRAM injection (that is malware-class and, for a cloud agent,
|
|
15
|
+
* fantasy). It is a clean, safe, cross-vendor protocol surface (MCP / the
|
|
16
|
+
* existing HTTP bridge). We ship the part that empowers every agent and is
|
|
17
|
+
* measurable, and refuse the part that is dangerous theatre.
|
|
18
|
+
*
|
|
19
|
+
* Four booleans that cannot lie: round-trip (contribute→recall) ∧
|
|
20
|
+
* quarantines-conflict ∧ signed (offline-verifiable, tamper-evident) ∧
|
|
21
|
+
* deterministic. Every function is total (108-error rule): garbage in → the
|
|
22
|
+
* safest result, never a throw. The shared brain of all agents must never
|
|
23
|
+
* crash the host.
|
|
24
|
+
*/
|
|
25
|
+
import { type NotaryReceipt } from "../notary/receipt.js";
|
|
26
|
+
export type CortexKind = "fact" | "decision" | "context" | "warning";
|
|
27
|
+
export interface Contribution {
|
|
28
|
+
agent: string;
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
kind?: CortexKind;
|
|
32
|
+
}
|
|
33
|
+
export interface CortexEntry {
|
|
34
|
+
id: string;
|
|
35
|
+
agent: string;
|
|
36
|
+
key: string;
|
|
37
|
+
value: string;
|
|
38
|
+
kind: CortexKind;
|
|
39
|
+
/** id of the entry this one supersedes (declared update), or null. */
|
|
40
|
+
supersedes: string | null;
|
|
41
|
+
at: number;
|
|
42
|
+
receipt: NotaryReceipt;
|
|
43
|
+
}
|
|
44
|
+
export interface CortexStore {
|
|
45
|
+
v: 1;
|
|
46
|
+
entries: CortexEntry[];
|
|
47
|
+
}
|
|
48
|
+
export declare function emptyStore(): CortexStore;
|
|
49
|
+
/** The latest non-superseded entry for each key (the live shared memory). */
|
|
50
|
+
export declare function activeView(store: CortexStore): Map<string, CortexEntry>;
|
|
51
|
+
export type ContributeVerdict = "ACCEPTED" | "DUPLICATE" | "UPDATED" | "QUARANTINED";
|
|
52
|
+
export interface ContributeResult {
|
|
53
|
+
verdict: ContributeVerdict;
|
|
54
|
+
entry: CortexEntry | null;
|
|
55
|
+
/** id of the established entry a QUARANTINED contribution conflicts with. */
|
|
56
|
+
conflictsWith: string | null;
|
|
57
|
+
reason: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* THE GATEKEEPER. Contribute a fact to the shared cortex:
|
|
61
|
+
* - identical key+value already present → DUPLICATE (agents agree; no-op)
|
|
62
|
+
* - same key, NEW value, opts.update → UPDATED (declared supersede)
|
|
63
|
+
* - same key, NEW value, no update → QUARANTINED (drift! refused —
|
|
64
|
+
* established memory is not
|
|
65
|
+
* silently overwritten)
|
|
66
|
+
* - new key → ACCEPTED
|
|
67
|
+
* The accepted/updated entry is Ed25519-signed. Total; never throws.
|
|
68
|
+
*/
|
|
69
|
+
export declare function contribute(repoRoot: string, store: CortexStore, c: Contribution, at: number, opts?: {
|
|
70
|
+
update?: boolean;
|
|
71
|
+
}): {
|
|
72
|
+
store: CortexStore;
|
|
73
|
+
result: ContributeResult;
|
|
74
|
+
};
|
|
75
|
+
export interface RecallHit {
|
|
76
|
+
entry: CortexEntry;
|
|
77
|
+
score: number;
|
|
78
|
+
}
|
|
79
|
+
/** Recall shared memory relevant to a query (deterministic token overlap on
|
|
80
|
+
* key+value), most-relevant + most-recent first. Total. */
|
|
81
|
+
export declare function recall(store: CortexStore, query: string, limit?: number): RecallHit[];
|
|
82
|
+
export interface VerifyEntryResult {
|
|
83
|
+
valid: boolean;
|
|
84
|
+
bound: boolean;
|
|
85
|
+
reason: string;
|
|
86
|
+
}
|
|
87
|
+
/** Verify a cortex entry OFFLINE: signature valid AND the receipt binds this
|
|
88
|
+
* exact (agent,key,value,id). Catches tampering. Total. */
|
|
89
|
+
export declare function verifyEntry(entry: CortexEntry): VerifyEntryResult;
|
|
90
|
+
export interface HandoffCapsule {
|
|
91
|
+
kind: "cortex/handoff";
|
|
92
|
+
toAgent: string;
|
|
93
|
+
facts: Array<{
|
|
94
|
+
key: string;
|
|
95
|
+
value: string;
|
|
96
|
+
agent: string;
|
|
97
|
+
kind: CortexKind;
|
|
98
|
+
}>;
|
|
99
|
+
at: number;
|
|
100
|
+
receipt: NotaryReceipt;
|
|
101
|
+
}
|
|
102
|
+
/** Build a SIGNED context capsule (the live shared memory) for a receiving
|
|
103
|
+
* agent — "feed clean, verified context to the next agent". Total. */
|
|
104
|
+
export declare function handoff(repoRoot: string, store: CortexStore, toAgent: string, at: number): HandoffCapsule;
|
|
105
|
+
export type ReconcileResolution = "proof" | "unresolved";
|
|
106
|
+
export interface ReconcileResult {
|
|
107
|
+
resolution: ReconcileResolution;
|
|
108
|
+
winner: {
|
|
109
|
+
agent: string;
|
|
110
|
+
value: string;
|
|
111
|
+
} | null;
|
|
112
|
+
loser: {
|
|
113
|
+
agent: string;
|
|
114
|
+
value: string;
|
|
115
|
+
} | null;
|
|
116
|
+
verdicts: {
|
|
117
|
+
a: string;
|
|
118
|
+
b: string;
|
|
119
|
+
};
|
|
120
|
+
reason: string;
|
|
121
|
+
receipt: NotaryReceipt;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Reconcile two conflicting contributions by PROOF. Async (consults the
|
|
125
|
+
* truth kernel). Total: any failure → an honest "unresolved" verdict, never
|
|
126
|
+
* a throw.
|
|
127
|
+
*/
|
|
128
|
+
export declare function reconcile(repoRoot: string, a: {
|
|
129
|
+
agent: string;
|
|
130
|
+
value: string;
|
|
131
|
+
}, b: {
|
|
132
|
+
agent: string;
|
|
133
|
+
value: string;
|
|
134
|
+
}, at: number): Promise<ReconcileResult>;
|
|
135
|
+
export interface ReconcileGauntlet {
|
|
136
|
+
/** a verifiably-false claim loses to a true one (resolution=proof). */
|
|
137
|
+
proofResolves: boolean;
|
|
138
|
+
/** two unprovable opinions stay unresolved (no auto-decide; Padgett). */
|
|
139
|
+
opinionUnresolved: boolean;
|
|
140
|
+
/** the reconciliation verdict is signed + offline-verifiable. */
|
|
141
|
+
signed: boolean;
|
|
142
|
+
/** total on garbage. */
|
|
143
|
+
stable: boolean;
|
|
144
|
+
score: number;
|
|
145
|
+
}
|
|
146
|
+
/** Prove the reconciliation power. Async + total. */
|
|
147
|
+
export declare function reconcileGauntlet(repoRoot: string, at: number): Promise<ReconcileGauntlet>;
|
|
148
|
+
export interface CortexGauntlet {
|
|
149
|
+
roundTrip: boolean;
|
|
150
|
+
quarantinesConflict: boolean;
|
|
151
|
+
signed: boolean;
|
|
152
|
+
tamperCaught: boolean;
|
|
153
|
+
deterministic: boolean;
|
|
154
|
+
stable: boolean;
|
|
155
|
+
score: number;
|
|
156
|
+
}
|
|
157
|
+
/** Prove the cortex invariants. Total. */
|
|
158
|
+
export declare function cortexGauntlet(repoRoot: string, at: number): CortexGauntlet;
|
|
159
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cortex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAErE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,sEAAsE;IACtE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAA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AAO,CAAC,eAAe,CAAC,CA0BhK;AAED,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,aAAa,EAAE,OAAO,CAAC;IACvB,yEAAyE;IACzE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iEAAiE;IACjE,MAAM,EAAE,OAAO,CAAC;IAChB,wBAAwB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qDAAqD;AACrD,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAYhG;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0CAA0C;AAC1C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,cAAc,CA4B3E"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.104.0 — THE COGNITIVE CORTEX (Sovereign Memory Bus).
|
|
3
|
+
*
|
|
4
|
+
* The honest, buildable heart of the "Universal Memory Bus / Cognitive Mesh"
|
|
5
|
+
* vision: a LOCAL, vendor-neutral, SIGNED, drift-guarded shared memory that
|
|
6
|
+
* ANY AI agent — Grok / GPT / Gemini / Claude / Codex / a local model —
|
|
7
|
+
* contributes to and recalls from. Mneme is the LOGIC GATEKEEPER: every
|
|
8
|
+
* contribution is Ed25519-signed (provenance) and, critically, a value that
|
|
9
|
+
* CONTRADICTS established shared memory is QUARANTINED, not silently
|
|
10
|
+
* overwritten — so the mesh cannot be poisoned or drift out from under the
|
|
11
|
+
* agents sharing it.
|
|
12
|
+
*
|
|
13
|
+
* DIAKRISIS — what this deliberately is NOT: it is not a kernel driver and
|
|
14
|
+
* not process/VRAM injection (that is malware-class and, for a cloud agent,
|
|
15
|
+
* fantasy). It is a clean, safe, cross-vendor protocol surface (MCP / the
|
|
16
|
+
* existing HTTP bridge). We ship the part that empowers every agent and is
|
|
17
|
+
* measurable, and refuse the part that is dangerous theatre.
|
|
18
|
+
*
|
|
19
|
+
* Four booleans that cannot lie: round-trip (contribute→recall) ∧
|
|
20
|
+
* quarantines-conflict ∧ signed (offline-verifiable, tamper-evident) ∧
|
|
21
|
+
* deterministic. Every function is total (108-error rule): garbage in → the
|
|
22
|
+
* safest result, never a throw. The shared brain of all agents must never
|
|
23
|
+
* crash the host.
|
|
24
|
+
*/
|
|
25
|
+
import { createHash } from "node:crypto";
|
|
26
|
+
import { issueReceipt, verifyReceipt } from "../notary/receipt.js";
|
|
27
|
+
export function emptyStore() { return { v: 1, entries: [] }; }
|
|
28
|
+
function sha256(s) { return createHash("sha256").update(s, "utf8").digest("hex"); }
|
|
29
|
+
function str(x, max = 4000) { return (typeof x === "string" ? x : "").slice(0, max); }
|
|
30
|
+
function entryPayload(c) {
|
|
31
|
+
return { agent: c.agent, key: c.key, value: c.value, kind: c.kind, supersedes: c.supersedes, at: c.at };
|
|
32
|
+
}
|
|
33
|
+
/** The latest non-superseded entry for each key (the live shared memory). */
|
|
34
|
+
export function activeView(store) {
|
|
35
|
+
const superseded = new Set();
|
|
36
|
+
const byId = new Map();
|
|
37
|
+
const entries = store && Array.isArray(store.entries) ? store.entries : [];
|
|
38
|
+
for (const e of entries) {
|
|
39
|
+
if (e) {
|
|
40
|
+
byId.set(e.id, e);
|
|
41
|
+
if (e.supersedes)
|
|
42
|
+
superseded.add(e.supersedes);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const latest = new Map();
|
|
46
|
+
for (const e of entries) {
|
|
47
|
+
if (!e || superseded.has(e.id))
|
|
48
|
+
continue;
|
|
49
|
+
const prev = latest.get(e.key);
|
|
50
|
+
if (!prev || e.at >= prev.at)
|
|
51
|
+
latest.set(e.key, e);
|
|
52
|
+
}
|
|
53
|
+
return latest;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* THE GATEKEEPER. Contribute a fact to the shared cortex:
|
|
57
|
+
* - identical key+value already present → DUPLICATE (agents agree; no-op)
|
|
58
|
+
* - same key, NEW value, opts.update → UPDATED (declared supersede)
|
|
59
|
+
* - same key, NEW value, no update → QUARANTINED (drift! refused —
|
|
60
|
+
* established memory is not
|
|
61
|
+
* silently overwritten)
|
|
62
|
+
* - new key → ACCEPTED
|
|
63
|
+
* The accepted/updated entry is Ed25519-signed. Total; never throws.
|
|
64
|
+
*/
|
|
65
|
+
export function contribute(repoRoot, store, c, at, opts) {
|
|
66
|
+
try {
|
|
67
|
+
const safe = store && Array.isArray(store.entries) ? store : emptyStore();
|
|
68
|
+
const agent = str(c?.agent, 120) || "unknown";
|
|
69
|
+
const key = str(c?.key, 400);
|
|
70
|
+
const value = str(c?.value);
|
|
71
|
+
const kind = ["fact", "decision", "context", "warning"].includes(c?.kind) ? c.kind : "fact";
|
|
72
|
+
if (!key || !value)
|
|
73
|
+
return { store: safe, result: { verdict: "QUARANTINED", entry: null, conflictsWith: null, reason: "empty key or value" } };
|
|
74
|
+
const active = activeView(safe);
|
|
75
|
+
const existing = active.get(key);
|
|
76
|
+
if (existing) {
|
|
77
|
+
if (existing.value === value)
|
|
78
|
+
return { store: safe, result: { verdict: "DUPLICATE", entry: existing, conflictsWith: null, reason: "identical fact already in the cortex (agents agree)" } };
|
|
79
|
+
if (!opts?.update)
|
|
80
|
+
return { store: safe, result: { verdict: "QUARANTINED", entry: null, conflictsWith: existing.id, reason: `conflicts with established memory for key (set update=true to declare a supersede)` } };
|
|
81
|
+
}
|
|
82
|
+
const supersedes = existing && opts?.update ? existing.id : null;
|
|
83
|
+
const base = { agent, key, value, kind, supersedes, at };
|
|
84
|
+
const id = sha256(JSON.stringify(entryPayload(base)));
|
|
85
|
+
const receipt = issueReceipt(repoRoot, { kind: "memory-capsule", subject: `cortex:${key.slice(0, 40)}`, payload: { ...entryPayload(base), id }, includePayload: true, issuedAt: at });
|
|
86
|
+
const entry = { id, ...base, receipt };
|
|
87
|
+
return { store: { v: 1, entries: [...safe.entries, entry] }, result: { verdict: supersedes ? "UPDATED" : "ACCEPTED", entry, conflictsWith: null, reason: supersedes ? "superseded prior value (declared update)" : "new fact accepted into the cortex" } };
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
return { store: store ?? emptyStore(), result: { verdict: "QUARANTINED", entry: null, conflictsWith: null, reason: `threw: ${e.message}` } };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Recall shared memory relevant to a query (deterministic token overlap on
|
|
94
|
+
* key+value), most-relevant + most-recent first. Total. */
|
|
95
|
+
export function recall(store, query, limit = 10) {
|
|
96
|
+
try {
|
|
97
|
+
const q = str(query, 400).toLowerCase().split(/\W+/).filter((t) => t.length > 1);
|
|
98
|
+
if (q.length === 0)
|
|
99
|
+
return [];
|
|
100
|
+
const active = [...activeView(store).values()];
|
|
101
|
+
const hits = [];
|
|
102
|
+
for (const e of active) {
|
|
103
|
+
const hay = (e.key + " " + e.value).toLowerCase();
|
|
104
|
+
let score = 0;
|
|
105
|
+
for (const t of q)
|
|
106
|
+
if (hay.includes(t))
|
|
107
|
+
score++;
|
|
108
|
+
if (score > 0)
|
|
109
|
+
hits.push({ entry: e, score });
|
|
110
|
+
}
|
|
111
|
+
hits.sort((a, b) => b.score - a.score || b.entry.at - a.entry.at);
|
|
112
|
+
return hits.slice(0, Math.max(0, limit));
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** Verify a cortex entry OFFLINE: signature valid AND the receipt binds this
|
|
119
|
+
* exact (agent,key,value,id). Catches tampering. Total. */
|
|
120
|
+
export function verifyEntry(entry) {
|
|
121
|
+
try {
|
|
122
|
+
if (!entry || !entry.receipt)
|
|
123
|
+
return { valid: false, bound: false, reason: "no entry/receipt" };
|
|
124
|
+
const v = verifyReceipt(entry.receipt);
|
|
125
|
+
if (!v.valid)
|
|
126
|
+
return { valid: false, bound: false, reason: v.reason ?? "bad signature" };
|
|
127
|
+
const p = entry.receipt.payload;
|
|
128
|
+
// Bind EVERY signed field. The id is derived from the full payload
|
|
129
|
+
// (agent,key,value,kind,supersedes,at), so recomputing it from the
|
|
130
|
+
// entry's current fields and matching it to the signed id catches a
|
|
131
|
+
// tamper of ANY field — including kind and at (which feed activeView +
|
|
132
|
+
// handoff). We also check each field explicitly, belt-and-suspenders.
|
|
133
|
+
const recomputedId = sha256(JSON.stringify(entryPayload(entry)));
|
|
134
|
+
const bound = !!p
|
|
135
|
+
&& p.id === entry.id && recomputedId === entry.id
|
|
136
|
+
&& p.agent === entry.agent && p.key === entry.key && p.value === entry.value
|
|
137
|
+
&& p.kind === entry.kind && p.supersedes === entry.supersedes && p.at === entry.at;
|
|
138
|
+
return { valid: true, bound, reason: bound ? "signed + bound to this entry" : "signature valid but entry does not match receipt (tampered)" };
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
return { valid: false, bound: false, reason: `threw: ${e.message}` };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Build a SIGNED context capsule (the live shared memory) for a receiving
|
|
145
|
+
* agent — "feed clean, verified context to the next agent". Total. */
|
|
146
|
+
export function handoff(repoRoot, store, toAgent, at) {
|
|
147
|
+
const facts = [...activeView(store).values()].sort((a, b) => (a.key < b.key ? -1 : 1)).map((e) => ({ key: e.key, value: e.value, agent: e.agent, kind: e.kind }));
|
|
148
|
+
// Canonical digest: sort each fact's keys so the hash is stable regardless
|
|
149
|
+
// of object key insertion order (consistent with notary's canonicalJson).
|
|
150
|
+
const canonFacts = facts.map((f) => Object.keys(f).sort().map((k) => [k, f[k]]));
|
|
151
|
+
const digest = sha256(JSON.stringify(canonFacts));
|
|
152
|
+
const receipt = issueReceipt(repoRoot, { kind: "memory-capsule", subject: `cortex-handoff:${str(toAgent, 80) || "agent"}`, payload: { toAgent: str(toAgent, 80), digest, count: facts.length }, includePayload: true, issuedAt: at });
|
|
153
|
+
return { kind: "cortex/handoff", toAgent: str(toAgent, 80) || "agent", facts, at, receipt };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Reconcile two conflicting contributions by PROOF. Async (consults the
|
|
157
|
+
* truth kernel). Total: any failure → an honest "unresolved" verdict, never
|
|
158
|
+
* a throw.
|
|
159
|
+
*/
|
|
160
|
+
export async function reconcile(repoRoot, a, b, at) {
|
|
161
|
+
let va = "UNKNOWN", vb = "UNKNOWN";
|
|
162
|
+
try {
|
|
163
|
+
const aletheia = await import("../truth_kernel/aletheia.js");
|
|
164
|
+
const ra = await aletheia.assertClaim(repoRoot, str(a?.value), {});
|
|
165
|
+
const rb = await aletheia.assertClaim(repoRoot, str(b?.value), {});
|
|
166
|
+
va = ra?.verdict ?? "UNKNOWN";
|
|
167
|
+
vb = rb?.verdict ?? "UNKNOWN";
|
|
168
|
+
}
|
|
169
|
+
catch { /* truth kernel unavailable → stays unresolved */ }
|
|
170
|
+
let resolution = "unresolved";
|
|
171
|
+
let winner = null;
|
|
172
|
+
let loser = null;
|
|
173
|
+
let reason;
|
|
174
|
+
// Auto-resolve ONLY when exactly one side is verifiably FALSE (proven).
|
|
175
|
+
if (va === "FALSE" && vb !== "FALSE") {
|
|
176
|
+
resolution = "proof";
|
|
177
|
+
winner = { agent: str(b?.agent, 120), value: str(b?.value) };
|
|
178
|
+
loser = { agent: str(a?.agent, 120), value: str(a?.value) };
|
|
179
|
+
reason = `claim A is verifiably FALSE — B wins by proof`;
|
|
180
|
+
}
|
|
181
|
+
else if (vb === "FALSE" && va !== "FALSE") {
|
|
182
|
+
resolution = "proof";
|
|
183
|
+
winner = { agent: str(a?.agent, 120), value: str(a?.value) };
|
|
184
|
+
loser = { agent: str(b?.agent, 120), value: str(b?.value) };
|
|
185
|
+
reason = `claim B is verifiably FALSE — A wins by proof`;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
reason = `neither claim is provably false (verdicts ${va}/${vb}) — quarantine holds; signed belief-diff for human/trusted-agent resolution`;
|
|
189
|
+
}
|
|
190
|
+
const receipt = issueReceipt(repoRoot, {
|
|
191
|
+
kind: "claim-verdict",
|
|
192
|
+
subject: `cortex-reconcile:${sha256(str(a?.value) + "|" + str(b?.value)).slice(0, 16)}`,
|
|
193
|
+
payload: { resolution, winnerValue: winner?.value ?? null, loserValue: loser?.value ?? null, verdicts: { a: va, b: vb }, a: { agent: str(a?.agent, 120), value: str(a?.value) }, b: { agent: str(b?.agent, 120), value: str(b?.value) } },
|
|
194
|
+
includePayload: true,
|
|
195
|
+
issuedAt: at,
|
|
196
|
+
});
|
|
197
|
+
return { resolution, winner, loser, verdicts: { a: va, b: vb }, reason, receipt };
|
|
198
|
+
}
|
|
199
|
+
/** Prove the reconciliation power. Async + total. */
|
|
200
|
+
export async function reconcileGauntlet(repoRoot, at) {
|
|
201
|
+
try {
|
|
202
|
+
const proof = await reconcile(repoRoot, { agent: "claude", value: "2+2=4" }, { agent: "grok", value: "2+2=5" }, at);
|
|
203
|
+
const proofResolves = proof.resolution === "proof" && proof.winner?.value === "2+2=4" && proof.loser?.value === "2+2=5";
|
|
204
|
+
const opinion = await reconcile(repoRoot, { agent: "claude", value: "fly.io is the deploy target" }, { agent: "grok", value: "vercel is the deploy target" }, at);
|
|
205
|
+
const opinionUnresolved = opinion.resolution === "unresolved" && opinion.winner === null;
|
|
206
|
+
const signed = verifyReceipt(proof.receipt).valid;
|
|
207
|
+
let stable = true;
|
|
208
|
+
try {
|
|
209
|
+
await reconcile(repoRoot, null, null, at);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
stable = false;
|
|
213
|
+
}
|
|
214
|
+
const perfect = proofResolves && opinionUnresolved && signed && stable;
|
|
215
|
+
return { proofResolves, opinionUnresolved, signed, stable, score: perfect ? 100 : 0 };
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return { proofResolves: false, opinionUnresolved: false, signed: false, stable: false, score: 0 };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/** Prove the cortex invariants. Total. */
|
|
222
|
+
export function cortexGauntlet(repoRoot, at) {
|
|
223
|
+
try {
|
|
224
|
+
let s = emptyStore();
|
|
225
|
+
// 1) accept + recall round-trip
|
|
226
|
+
s = contribute(repoRoot, s, { agent: "claude", key: "db.url", value: "postgres://prod", kind: "fact" }, at).store;
|
|
227
|
+
const found = recall(s, "db url").some((h) => h.entry.value === "postgres://prod");
|
|
228
|
+
// 2) duplicate from another agent → DUPLICATE (agree)
|
|
229
|
+
const dup = contribute(repoRoot, s, { agent: "gpt", key: "db.url", value: "postgres://prod" }, at + 1).result.verdict === "DUPLICATE";
|
|
230
|
+
// 3) conflict → QUARANTINED, active value unchanged
|
|
231
|
+
const conf = contribute(repoRoot, s, { agent: "grok", key: "db.url", value: "postgres://EVIL" }, at + 2);
|
|
232
|
+
const quarantinesConflict = conf.result.verdict === "QUARANTINED" && activeView(conf.store).get("db.url")?.value === "postgres://prod";
|
|
233
|
+
// 4) declared update → supersede
|
|
234
|
+
const upd = contribute(repoRoot, s, { agent: "claude", key: "db.url", value: "postgres://prod2" }, at + 3, { update: true });
|
|
235
|
+
const updated = upd.result.verdict === "UPDATED" && activeView(upd.store).get("db.url")?.value === "postgres://prod2";
|
|
236
|
+
// signed + tamper
|
|
237
|
+
const entry = activeView(s).get("db.url");
|
|
238
|
+
const signed = verifyEntry(entry).bound;
|
|
239
|
+
const tampered = JSON.parse(JSON.stringify(entry));
|
|
240
|
+
tampered.value = "postgres://HACKED";
|
|
241
|
+
const tamperCaught = verifyEntry(tampered).bound === false;
|
|
242
|
+
// deterministic handoff digest
|
|
243
|
+
const h1 = handoff(repoRoot, s, "x", at).receipt.payloadHash;
|
|
244
|
+
const h2 = handoff(repoRoot, s, "x", at).receipt.payloadHash;
|
|
245
|
+
const deterministic = h1 === h2;
|
|
246
|
+
let stable = true;
|
|
247
|
+
try {
|
|
248
|
+
contribute(repoRoot, null, null, at);
|
|
249
|
+
recall(null, null);
|
|
250
|
+
verifyEntry(null);
|
|
251
|
+
handoff(repoRoot, null, null, at);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
stable = false;
|
|
255
|
+
}
|
|
256
|
+
const perfect = found && dup && quarantinesConflict && updated && signed && tamperCaught && deterministic && stable;
|
|
257
|
+
return { roundTrip: found, quarantinesConflict, signed, tamperCaught, deterministic, stable, score: perfect ? 100 : 0 };
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return { roundTrip: false, quarantinesConflict: false, signed: false, tamperCaught: false, deterministic: false, stable: false, score: 0 };
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cortex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAsB,MAAM,sBAAsB,CAAC;AA4BvF,MAAM,UAAU,UAAU,KAAkB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAE3E,SAAS,MAAM,CAAC,CAAS,IAAY,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnG,SAAS,GAAG,CAAC,CAAU,EAAE,GAAG,GAAG,IAAI,IAAY,OAAO,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CA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AAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7D,MAAM,aAAa,GAAG,EAAE,KAAK,EAAE,CAAC;QAChC,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC;YAAC,UAAU,CAAC,QAAQ,EAAE,IAAa,EAAE,IAAa,EAAE,EAAE,CAAC,CAAC;YAAC,MAAM,CAAC,IAAa,EAAE,IAAa,CAAC,CAAC;YAAC,WAAW,CAAC,IAAa,CAAC,CAAC;YAAC,OAAO,CAAC,QAAQ,EAAE,IAAa,EAAE,IAAa,EAAE,EAAE,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,MAAM,GAAG,KAAK,CAAC;QAAC,CAAC;QAChN,MAAM,OAAO,GAAG,KAAK,IAAI,GAAG,IAAI,mBAAmB,IAAI,OAAO,IAAI,MAAM,IAAI,YAAY,IAAI,aAAa,IAAI,MAAM,CAAC;QACpH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1H,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,CAAC;AACzJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -117,6 +117,7 @@ export * as lexicon from "./lexicon/index.js";
|
|
|
117
117
|
export * as hydra from "./hydra/index.js";
|
|
118
118
|
export * as cognitiveGate from "./cognitive_gate/index.js";
|
|
119
119
|
export * as branchOracle from "./branch_oracle/index.js";
|
|
120
|
+
export * as cortex from "./cortex/index.js";
|
|
120
121
|
export * as symbiosis from "./symbiosis/index.js";
|
|
121
122
|
export * as truthKernel from "./truth_kernel/index.js";
|
|
122
123
|
export * as aletheiaSpine from "./truth_kernel/aletheia.js";
|