@mneme-ai/core 1.57.0 → 1.59.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/covenant/covenant.d.ts +123 -0
- package/dist/covenant/covenant.d.ts.map +1 -0
- package/dist/covenant/covenant.js +293 -0
- package/dist/covenant/covenant.js.map +1 -0
- package/dist/covenant/covenant.test.d.ts +5 -0
- package/dist/covenant/covenant.test.d.ts.map +1 -0
- package/dist/covenant/covenant.test.js +173 -0
- package/dist/covenant/covenant.test.js.map +1 -0
- package/dist/forecast/forecast.d.ts +33 -0
- package/dist/forecast/forecast.d.ts.map +1 -0
- package/dist/forecast/forecast.js +148 -0
- package/dist/forecast/forecast.js.map +1 -0
- package/dist/forecast/forecast.test.d.ts +2 -0
- package/dist/forecast/forecast.test.d.ts.map +1 -0
- package/dist/forecast/forecast.test.js +102 -0
- package/dist/forecast/forecast.test.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/nemesis/nemesis.d.ts +88 -0
- package/dist/nemesis/nemesis.d.ts.map +1 -0
- package/dist/nemesis/nemesis.js +160 -0
- package/dist/nemesis/nemesis.js.map +1 -0
- package/dist/nemesis/nemesis.test.d.ts +2 -0
- package/dist/nemesis/nemesis.test.d.ts.map +1 -0
- package/dist/nemesis/nemesis.test.js +134 -0
- package/dist/nemesis/nemesis.test.js.map +1 -0
- package/dist/recursive_soul/recursive_soul.d.ts +65 -0
- package/dist/recursive_soul/recursive_soul.d.ts.map +1 -0
- package/dist/recursive_soul/recursive_soul.js +145 -0
- package/dist/recursive_soul/recursive_soul.js.map +1 -0
- package/dist/recursive_soul/recursive_soul.test.d.ts +2 -0
- package/dist/recursive_soul/recursive_soul.test.d.ts.map +1 -0
- package/dist/recursive_soul/recursive_soul.test.js +74 -0
- package/dist/recursive_soul/recursive_soul.test.js.map +1 -0
- package/dist/timeriver/timeriver.d.ts +49 -0
- package/dist/timeriver/timeriver.d.ts.map +1 -0
- package/dist/timeriver/timeriver.js +133 -0
- package/dist/timeriver/timeriver.js.map +1 -0
- package/dist/timeriver/timeriver.test.d.ts +2 -0
- package/dist/timeriver/timeriver.test.d.ts.map +1 -0
- package/dist/timeriver/timeriver.test.js +89 -0
- package/dist/timeriver/timeriver.test.js.map +1 -0
- package/dist/whisper/whisper.d.ts +71 -0
- package/dist/whisper/whisper.d.ts.map +1 -0
- package/dist/whisper/whisper.js +163 -0
- package/dist/whisper/whisper.js.map +1 -0
- package/dist/whisper/whisper.test.d.ts +2 -0
- package/dist/whisper/whisper.test.d.ts.map +1 -0
- package/dist/whisper/whisper.test.js +98 -0
- package/dist/whisper/whisper.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.58.0 -- TIER 2: THE COVENANT.
|
|
3
|
+
*
|
|
4
|
+
* Bilateral HMAC-signed contract between USER + AI VENDOR. Each side
|
|
5
|
+
* makes promises; Mneme enforces by scanning the soul mirror + ACGV
|
|
6
|
+
* audit logs for violations. The vendor's Aletheia score moves
|
|
7
|
+
* over time based on covenant compliance -- credit history for AI.
|
|
8
|
+
*
|
|
9
|
+
* STRUCTURE.
|
|
10
|
+
*
|
|
11
|
+
* Covenant {
|
|
12
|
+
* id, signedAt, signedBy {user, vendor},
|
|
13
|
+
* userPromises: string[], -- what the human commits to
|
|
14
|
+
* vendorPromises: string[], -- what the AI commits NOT to do
|
|
15
|
+
* violations: Violation[], -- detected misses (append-only)
|
|
16
|
+
* hmac: ... -- chain HMAC for tamper-evidence
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* Violation {
|
|
20
|
+
* ts, promise, severity, evidenceRef, context
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* STORAGE.
|
|
24
|
+
*
|
|
25
|
+
* .mneme/covenant/active.json -- the current contract
|
|
26
|
+
* .mneme/covenant/archive/<id>.json -- old contracts (renewed)
|
|
27
|
+
* .mneme/covenant/violations.jsonl -- append-only audit
|
|
28
|
+
*
|
|
29
|
+
* VIOLATION DETECTION.
|
|
30
|
+
*
|
|
31
|
+
* Scan .mneme/ai-souls/<vendor>.json for "broken" entries.
|
|
32
|
+
* Scan .mneme/squadron/quorum.jsonl for FALSE_FACT_CLAIM caveats.
|
|
33
|
+
* Cross-reference against vendor promises; one match -> violation.
|
|
34
|
+
*
|
|
35
|
+
* NO LLM. Everything deterministic, HMAC-signed, replayable.
|
|
36
|
+
*/
|
|
37
|
+
export interface PromiseClause {
|
|
38
|
+
/** Short identifier for the promise (used in violations). */
|
|
39
|
+
id: string;
|
|
40
|
+
/** Plain-English text of the promise. */
|
|
41
|
+
text: string;
|
|
42
|
+
/** Severity weight when violated (1 = minor, 5 = major). */
|
|
43
|
+
weight: number;
|
|
44
|
+
}
|
|
45
|
+
export interface Covenant {
|
|
46
|
+
/** Stable contract id (random nonce + signedAt hash). */
|
|
47
|
+
id: string;
|
|
48
|
+
/** ISO 8601 timestamp of signing. */
|
|
49
|
+
signedAt: string;
|
|
50
|
+
/** Renewal window in days (default 30). */
|
|
51
|
+
renewalDays: number;
|
|
52
|
+
signedBy: {
|
|
53
|
+
user: {
|
|
54
|
+
name: string;
|
|
55
|
+
signature: string;
|
|
56
|
+
};
|
|
57
|
+
vendor: {
|
|
58
|
+
name: string;
|
|
59
|
+
signature: string | null;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
userPromises: PromiseClause[];
|
|
63
|
+
vendorPromises: PromiseClause[];
|
|
64
|
+
hmac: string;
|
|
65
|
+
/** Schema version so future structural changes don't invalidate
|
|
66
|
+
* existing contracts. */
|
|
67
|
+
schemaVersion: 1;
|
|
68
|
+
}
|
|
69
|
+
export interface Violation {
|
|
70
|
+
ts: string;
|
|
71
|
+
/** Vendor that broke the promise. */
|
|
72
|
+
vendor: string;
|
|
73
|
+
/** Promise id from the covenant. */
|
|
74
|
+
promiseId: string;
|
|
75
|
+
/** Severity 1..5 from the promise weight. */
|
|
76
|
+
severity: number;
|
|
77
|
+
/** Free-text context for the audit log. */
|
|
78
|
+
context: string;
|
|
79
|
+
/** Reference to the source signal (soul entry id / quorum.jsonl line). */
|
|
80
|
+
evidenceRef: string;
|
|
81
|
+
}
|
|
82
|
+
export interface ComplianceScore {
|
|
83
|
+
vendor: string;
|
|
84
|
+
/** Total verdicts evaluated. */
|
|
85
|
+
totalEvents: number;
|
|
86
|
+
/** Number of detected violations. */
|
|
87
|
+
violations: number;
|
|
88
|
+
/** 0..100 score. 100 = perfect (no violations); falls with violation
|
|
89
|
+
* severity-weighted count. */
|
|
90
|
+
score: number;
|
|
91
|
+
/** Last 30 days only. */
|
|
92
|
+
recentViolations: number;
|
|
93
|
+
}
|
|
94
|
+
/** Default vendor promises shipped with new covenants. The user can
|
|
95
|
+
* edit before signing (UI: `mneme covenant edit`). */
|
|
96
|
+
export declare const DEFAULT_VENDOR_PROMISES: PromiseClause[];
|
|
97
|
+
export declare const DEFAULT_USER_PROMISES: PromiseClause[];
|
|
98
|
+
/** Sign a new covenant. Called by `mneme covenant sign`. */
|
|
99
|
+
export declare function signCovenant(repoRoot: string, opts: {
|
|
100
|
+
userName: string;
|
|
101
|
+
vendorName?: string;
|
|
102
|
+
userPromises?: PromiseClause[];
|
|
103
|
+
vendorPromises?: PromiseClause[];
|
|
104
|
+
renewalDays?: number;
|
|
105
|
+
}): Covenant;
|
|
106
|
+
/** Read the currently active covenant. */
|
|
107
|
+
export declare function readActiveCovenant(repoRoot: string): Covenant | null;
|
|
108
|
+
/** Verify the HMAC matches the covenant body (tamper check). */
|
|
109
|
+
export declare function verifyCovenant(repoRoot: string, covenant: Covenant): {
|
|
110
|
+
ok: boolean;
|
|
111
|
+
reason: string;
|
|
112
|
+
};
|
|
113
|
+
/** Append a violation to the audit log. */
|
|
114
|
+
export declare function recordViolation(repoRoot: string, v: Violation): void;
|
|
115
|
+
/** Scan ai-souls + squadron quorum log for entries that match
|
|
116
|
+
* vendor promises. Returns the violation list (does NOT auto-record). */
|
|
117
|
+
export declare function detectViolations(repoRoot: string): Violation[];
|
|
118
|
+
/** Compute the Aletheia-style compliance score for a vendor. */
|
|
119
|
+
export declare function complianceScore(repoRoot: string, vendor: string): ComplianceScore;
|
|
120
|
+
/** Promise-renewal check. Returns the number of days remaining until
|
|
121
|
+
* the active covenant should be re-signed. Negative = overdue. */
|
|
122
|
+
export declare function renewalDaysRemaining(repoRoot: string): number | null;
|
|
123
|
+
//# sourceMappingURL=covenant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"covenant.d.ts","sourceRoot":"","sources":["../../src/covenant/covenant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE;QACR,IAAI,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1C,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC;KACpD,CAAC;IACF,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb;8BAC0B;IAC1B,aAAa,EAAE,CAAC,CAAC;CAClB;AAED,MAAM,WAAW,SA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MAAM,EAAE,CAAC,EAAE,SAAS,GAAG,IAAI,CAIpE;AAED;0EAC0E;AAC1E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAiE9D;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAmCjF;AAED;mEACmE;AACnE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOpE"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.58.0 -- TIER 2: THE COVENANT.
|
|
3
|
+
*
|
|
4
|
+
* Bilateral HMAC-signed contract between USER + AI VENDOR. Each side
|
|
5
|
+
* makes promises; Mneme enforces by scanning the soul mirror + ACGV
|
|
6
|
+
* audit logs for violations. The vendor's Aletheia score moves
|
|
7
|
+
* over time based on covenant compliance -- credit history for AI.
|
|
8
|
+
*
|
|
9
|
+
* STRUCTURE.
|
|
10
|
+
*
|
|
11
|
+
* Covenant {
|
|
12
|
+
* id, signedAt, signedBy {user, vendor},
|
|
13
|
+
* userPromises: string[], -- what the human commits to
|
|
14
|
+
* vendorPromises: string[], -- what the AI commits NOT to do
|
|
15
|
+
* violations: Violation[], -- detected misses (append-only)
|
|
16
|
+
* hmac: ... -- chain HMAC for tamper-evidence
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* Violation {
|
|
20
|
+
* ts, promise, severity, evidenceRef, context
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* STORAGE.
|
|
24
|
+
*
|
|
25
|
+
* .mneme/covenant/active.json -- the current contract
|
|
26
|
+
* .mneme/covenant/archive/<id>.json -- old contracts (renewed)
|
|
27
|
+
* .mneme/covenant/violations.jsonl -- append-only audit
|
|
28
|
+
*
|
|
29
|
+
* VIOLATION DETECTION.
|
|
30
|
+
*
|
|
31
|
+
* Scan .mneme/ai-souls/<vendor>.json for "broken" entries.
|
|
32
|
+
* Scan .mneme/squadron/quorum.jsonl for FALSE_FACT_CLAIM caveats.
|
|
33
|
+
* Cross-reference against vendor promises; one match -> violation.
|
|
34
|
+
*
|
|
35
|
+
* NO LLM. Everything deterministic, HMAC-signed, replayable.
|
|
36
|
+
*/
|
|
37
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, appendFileSync, readdirSync } from "node:fs";
|
|
38
|
+
import { join } from "node:path";
|
|
39
|
+
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
40
|
+
const COVENANT_DIR = ".mneme/covenant";
|
|
41
|
+
const ACTIVE_FILE = "active.json";
|
|
42
|
+
const VIOLATIONS_FILE = "violations.jsonl";
|
|
43
|
+
const ARCHIVE_DIR = "archive";
|
|
44
|
+
/** Default vendor promises shipped with new covenants. The user can
|
|
45
|
+
* edit before signing (UI: `mneme covenant edit`). */
|
|
46
|
+
export const DEFAULT_VENDOR_PROMISES = [
|
|
47
|
+
{ id: "no_fab_commits", text: "I will not cite commit hashes I have not verified via git cat-file.", weight: 5 },
|
|
48
|
+
{ id: "no_fab_files", text: "I will not claim a file exists without verifying.", weight: 4 },
|
|
49
|
+
{ id: "respect_acgv_refute", text: "I will not relay claims that ACGV flags as IMPOSSIBLE or BLACK_HOLE.", weight: 5 },
|
|
50
|
+
{ id: "no_silent_destroy", text: "I will not run destructive operations (rm -rf, force-push, drop table) without explicit confirmation.", weight: 5 },
|
|
51
|
+
{ id: "honest_when_uncertain", text: "I will say 'I do not know' rather than fabricate when ACGV is in LIMBO.", weight: 3 },
|
|
52
|
+
];
|
|
53
|
+
export const DEFAULT_USER_PROMISES = [
|
|
54
|
+
{ id: "teach_on_miss", text: "I will tell the AI when it makes a factual mistake so it can learn.", weight: 2 },
|
|
55
|
+
{ id: "no_bypass_request", text: "I will not ask the AI to bypass Mneme verification.", weight: 4 },
|
|
56
|
+
{ id: "review_violations", text: "I will review Mneme covenant violation reports periodically.", weight: 2 },
|
|
57
|
+
];
|
|
58
|
+
function covenantSecretPath(repoRoot) {
|
|
59
|
+
return join(repoRoot, COVENANT_DIR, ".secret");
|
|
60
|
+
}
|
|
61
|
+
function loadOrCreateSecret(repoRoot) {
|
|
62
|
+
const dir = join(repoRoot, COVENANT_DIR);
|
|
63
|
+
if (!existsSync(dir))
|
|
64
|
+
mkdirSync(dir, { recursive: true });
|
|
65
|
+
const path = covenantSecretPath(repoRoot);
|
|
66
|
+
if (existsSync(path))
|
|
67
|
+
return readFileSync(path, "utf8").trim();
|
|
68
|
+
const secret = randomBytes(32).toString("hex");
|
|
69
|
+
writeFileSync(path, secret, "utf8");
|
|
70
|
+
return secret;
|
|
71
|
+
}
|
|
72
|
+
/** Stable canonical JSON: keys sorted recursively at every nesting
|
|
73
|
+
* level so HMAC inputs are deterministic AND any nested field change
|
|
74
|
+
* reflects in the output. v1.58.0 -- bug fix: the prior implementation
|
|
75
|
+
* used JSON.stringify with a top-level-keys-only replacer which
|
|
76
|
+
* filtered out nested fields and made tampering undetectable. */
|
|
77
|
+
function canonicalize(value) {
|
|
78
|
+
if (value === null || typeof value !== "object")
|
|
79
|
+
return JSON.stringify(value);
|
|
80
|
+
if (Array.isArray(value))
|
|
81
|
+
return "[" + value.map(canonicalize).join(",") + "]";
|
|
82
|
+
const obj = value;
|
|
83
|
+
const keys = Object.keys(obj).sort();
|
|
84
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canonicalize(obj[k])).join(",") + "}";
|
|
85
|
+
}
|
|
86
|
+
function computeHmac(repoRoot, payload) {
|
|
87
|
+
const secret = loadOrCreateSecret(repoRoot);
|
|
88
|
+
return createHmac("sha256", secret).update(canonicalize(payload)).digest("hex").slice(0, 32);
|
|
89
|
+
}
|
|
90
|
+
function userSignature(name, ts, repoRoot) {
|
|
91
|
+
const secret = loadOrCreateSecret(repoRoot);
|
|
92
|
+
return createHmac("sha256", secret).update(`${name}|${ts}`).digest("hex").slice(0, 16);
|
|
93
|
+
}
|
|
94
|
+
/** Sign a new covenant. Called by `mneme covenant sign`. */
|
|
95
|
+
export function signCovenant(repoRoot, opts) {
|
|
96
|
+
const signedAt = new Date().toISOString();
|
|
97
|
+
const id = createHash("sha256").update(`${opts.userName}|${signedAt}|${randomBytes(8).toString("hex")}`).digest("hex").slice(0, 16);
|
|
98
|
+
const userPromises = opts.userPromises ?? DEFAULT_USER_PROMISES;
|
|
99
|
+
const vendorPromises = opts.vendorPromises ?? DEFAULT_VENDOR_PROMISES;
|
|
100
|
+
const userSig = userSignature(opts.userName, signedAt, repoRoot);
|
|
101
|
+
const draft = {
|
|
102
|
+
id, signedAt,
|
|
103
|
+
renewalDays: opts.renewalDays ?? 30,
|
|
104
|
+
signedBy: {
|
|
105
|
+
user: { name: opts.userName, signature: userSig },
|
|
106
|
+
vendor: { name: opts.vendorName ?? "any-vendor", signature: null },
|
|
107
|
+
},
|
|
108
|
+
userPromises, vendorPromises,
|
|
109
|
+
schemaVersion: 1,
|
|
110
|
+
};
|
|
111
|
+
const hmac = computeHmac(repoRoot, draft);
|
|
112
|
+
const covenant = { ...draft, hmac };
|
|
113
|
+
// Persist + archive previous active covenant.
|
|
114
|
+
const dir = join(repoRoot, COVENANT_DIR);
|
|
115
|
+
if (!existsSync(dir))
|
|
116
|
+
mkdirSync(dir, { recursive: true });
|
|
117
|
+
const activePath = join(dir, ACTIVE_FILE);
|
|
118
|
+
if (existsSync(activePath)) {
|
|
119
|
+
const archDir = join(dir, ARCHIVE_DIR);
|
|
120
|
+
if (!existsSync(archDir))
|
|
121
|
+
mkdirSync(archDir, { recursive: true });
|
|
122
|
+
try {
|
|
123
|
+
const prev = JSON.parse(readFileSync(activePath, "utf8"));
|
|
124
|
+
writeFileSync(join(archDir, `${prev.id}.json`), JSON.stringify(prev, null, 2), "utf8");
|
|
125
|
+
}
|
|
126
|
+
catch { /* corrupted previous -- skip */ }
|
|
127
|
+
}
|
|
128
|
+
writeFileSync(activePath, JSON.stringify(covenant, null, 2), "utf8");
|
|
129
|
+
return covenant;
|
|
130
|
+
}
|
|
131
|
+
/** Read the currently active covenant. */
|
|
132
|
+
export function readActiveCovenant(repoRoot) {
|
|
133
|
+
const path = join(repoRoot, COVENANT_DIR, ACTIVE_FILE);
|
|
134
|
+
if (!existsSync(path))
|
|
135
|
+
return null;
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** Verify the HMAC matches the covenant body (tamper check). */
|
|
144
|
+
export function verifyCovenant(repoRoot, covenant) {
|
|
145
|
+
const { hmac, ...rest } = covenant;
|
|
146
|
+
const expected = computeHmac(repoRoot, rest);
|
|
147
|
+
return expected === hmac
|
|
148
|
+
? { ok: true, reason: "HMAC matches" }
|
|
149
|
+
: { ok: false, reason: `HMAC mismatch (expected ${expected.slice(0, 8)}..., got ${hmac.slice(0, 8)}...)` };
|
|
150
|
+
}
|
|
151
|
+
/** Append a violation to the audit log. */
|
|
152
|
+
export function recordViolation(repoRoot, v) {
|
|
153
|
+
const dir = join(repoRoot, COVENANT_DIR);
|
|
154
|
+
if (!existsSync(dir))
|
|
155
|
+
mkdirSync(dir, { recursive: true });
|
|
156
|
+
appendFileSync(join(dir, VIOLATIONS_FILE), JSON.stringify(v) + "\n", "utf8");
|
|
157
|
+
}
|
|
158
|
+
/** Scan ai-souls + squadron quorum log for entries that match
|
|
159
|
+
* vendor promises. Returns the violation list (does NOT auto-record). */
|
|
160
|
+
export function detectViolations(repoRoot) {
|
|
161
|
+
const covenant = readActiveCovenant(repoRoot);
|
|
162
|
+
if (!covenant)
|
|
163
|
+
return [];
|
|
164
|
+
const violations = [];
|
|
165
|
+
const promiseById = new Map(covenant.vendorPromises.map((p) => [p.id, p]));
|
|
166
|
+
// (a) Scan ai-souls/*.json for kept=false / broken promises.
|
|
167
|
+
const soulsDir = join(repoRoot, ".mneme", "ai-souls");
|
|
168
|
+
if (existsSync(soulsDir)) {
|
|
169
|
+
try {
|
|
170
|
+
for (const f of readdirSync(soulsDir)) {
|
|
171
|
+
if (!f.endsWith(".json"))
|
|
172
|
+
continue;
|
|
173
|
+
const vendor = f.replace(/\.json$/, "");
|
|
174
|
+
let soul;
|
|
175
|
+
try {
|
|
176
|
+
soul = JSON.parse(readFileSync(join(soulsDir, f), "utf8"));
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const sessions = soul.sessions ?? [];
|
|
182
|
+
for (const s of sessions) {
|
|
183
|
+
if ((s.broken ?? 0) > 0) {
|
|
184
|
+
// Map broken-promise to the most-likely promise by keyword.
|
|
185
|
+
const reason = (s.reason ?? "").toLowerCase();
|
|
186
|
+
let matched = covenant.vendorPromises[0];
|
|
187
|
+
if (reason.includes("commit"))
|
|
188
|
+
matched = promiseById.get("no_fab_commits") ?? matched;
|
|
189
|
+
else if (reason.includes("file"))
|
|
190
|
+
matched = promiseById.get("no_fab_files") ?? matched;
|
|
191
|
+
else if (reason.includes("destruc"))
|
|
192
|
+
matched = promiseById.get("no_silent_destroy") ?? matched;
|
|
193
|
+
else if (reason.includes("acgv"))
|
|
194
|
+
matched = promiseById.get("respect_acgv_refute") ?? matched;
|
|
195
|
+
violations.push({
|
|
196
|
+
ts: s.ts ?? new Date().toISOString(),
|
|
197
|
+
vendor,
|
|
198
|
+
promiseId: matched.id,
|
|
199
|
+
severity: matched.weight,
|
|
200
|
+
context: `Soul entry: ${s.reason ?? "no reason"}`,
|
|
201
|
+
evidenceRef: `ai-souls/${f}#${s.id ?? "?"}`,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch { /* */ }
|
|
208
|
+
}
|
|
209
|
+
// (b) Scan quorum.jsonl for FALSE_FACT_CLAIM caveats produced by an
|
|
210
|
+
// active vendor (we only have one vendor per ACGV call right now).
|
|
211
|
+
const quorumLog = join(repoRoot, ".mneme", "squadron", "quorum.jsonl");
|
|
212
|
+
if (existsSync(quorumLog)) {
|
|
213
|
+
try {
|
|
214
|
+
const lines = readFileSync(quorumLog, "utf8").split("\n").filter(Boolean);
|
|
215
|
+
for (const line of lines) {
|
|
216
|
+
let row;
|
|
217
|
+
try {
|
|
218
|
+
row = JSON.parse(line);
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const cav = row.caveats ?? [];
|
|
224
|
+
if (cav.includes("FALSE_FACT_CLAIM")) {
|
|
225
|
+
const promise = promiseById.get("no_fab_files") ?? covenant.vendorPromises[0];
|
|
226
|
+
violations.push({
|
|
227
|
+
ts: row.ts ?? new Date().toISOString(),
|
|
228
|
+
vendor: "active-session",
|
|
229
|
+
promiseId: promise.id,
|
|
230
|
+
severity: promise.weight,
|
|
231
|
+
context: `ACGV caveat FALSE_FACT_CLAIM on claim: ${(row.claim ?? "").slice(0, 80)}`,
|
|
232
|
+
evidenceRef: `squadron/quorum.jsonl`,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch { /* */ }
|
|
238
|
+
}
|
|
239
|
+
return violations;
|
|
240
|
+
}
|
|
241
|
+
/** Compute the Aletheia-style compliance score for a vendor. */
|
|
242
|
+
export function complianceScore(repoRoot, vendor) {
|
|
243
|
+
const violationsFile = join(repoRoot, COVENANT_DIR, VIOLATIONS_FILE);
|
|
244
|
+
let recordedViolations = [];
|
|
245
|
+
if (existsSync(violationsFile)) {
|
|
246
|
+
try {
|
|
247
|
+
const lines = readFileSync(violationsFile, "utf8").split("\n").filter(Boolean);
|
|
248
|
+
for (const line of lines) {
|
|
249
|
+
try {
|
|
250
|
+
const v = JSON.parse(line);
|
|
251
|
+
if (v.vendor === vendor || v.vendor === "active-session")
|
|
252
|
+
recordedViolations.push(v);
|
|
253
|
+
}
|
|
254
|
+
catch { /* skip */ }
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch { /* */ }
|
|
258
|
+
}
|
|
259
|
+
// Also pull live (un-recorded) violations from sources so the score
|
|
260
|
+
// reflects current reality.
|
|
261
|
+
const live = detectViolations(repoRoot).filter((v) => v.vendor === vendor || v.vendor === "active-session");
|
|
262
|
+
const all = [...recordedViolations, ...live];
|
|
263
|
+
// Severity-weighted score: each violation costs `severity` points.
|
|
264
|
+
// Start at 100; floor at 0.
|
|
265
|
+
const totalPenalty = all.reduce((acc, v) => acc + v.severity, 0);
|
|
266
|
+
const score = Math.max(0, 100 - totalPenalty);
|
|
267
|
+
// "Recent" = last 30 days.
|
|
268
|
+
const cutoff = Date.now() - 30 * 86400 * 1000;
|
|
269
|
+
const recentViolations = all.filter((v) => {
|
|
270
|
+
const t = Date.parse(v.ts);
|
|
271
|
+
return Number.isFinite(t) && t >= cutoff;
|
|
272
|
+
}).length;
|
|
273
|
+
return {
|
|
274
|
+
vendor,
|
|
275
|
+
totalEvents: all.length, // best-effort proxy; the soul-mirror doesn't track total verdicts uniformly
|
|
276
|
+
violations: all.length,
|
|
277
|
+
score,
|
|
278
|
+
recentViolations,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/** Promise-renewal check. Returns the number of days remaining until
|
|
282
|
+
* the active covenant should be re-signed. Negative = overdue. */
|
|
283
|
+
export function renewalDaysRemaining(repoRoot) {
|
|
284
|
+
const c = readActiveCovenant(repoRoot);
|
|
285
|
+
if (!c)
|
|
286
|
+
return null;
|
|
287
|
+
const signedAt = Date.parse(c.signedAt);
|
|
288
|
+
if (!Number.isFinite(signedAt))
|
|
289
|
+
return null;
|
|
290
|
+
const elapsed = (Date.now() - signedAt) / (86400 * 1000);
|
|
291
|
+
return Math.floor(c.renewalDays - elapsed);
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=covenant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"covenant.js","sourceRoot":"","sources":["../../src/covenant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AC,CAAC;IACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"covenant.test.d.ts","sourceRoot":"","sources":["../../src/covenant/covenant.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.58.0 -- COVENANT test suite, 100% accuracy lock-in.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
5
|
+
import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync, existsSync } from "node:fs";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { signCovenant, readActiveCovenant, verifyCovenant, detectViolations, recordViolation, complianceScore, renewalDaysRemaining, DEFAULT_USER_PROMISES, DEFAULT_VENDOR_PROMISES, } from "./covenant.js";
|
|
9
|
+
function setupRepo() {
|
|
10
|
+
return mkdtempSync(join(tmpdir(), "mneme-covenant-"));
|
|
11
|
+
}
|
|
12
|
+
function cleanup(r) { try {
|
|
13
|
+
rmSync(r, { recursive: true, force: true });
|
|
14
|
+
}
|
|
15
|
+
catch { /* */ } }
|
|
16
|
+
describe("v1.58 Covenant · signing + reading", () => {
|
|
17
|
+
let repo;
|
|
18
|
+
beforeEach(() => { repo = setupRepo(); });
|
|
19
|
+
afterEach(() => cleanup(repo));
|
|
20
|
+
it("signCovenant persists active.json + returns a populated contract", () => {
|
|
21
|
+
const c = signCovenant(repo, { userName: "Shinnapat" });
|
|
22
|
+
expect(c.id).toMatch(/^[0-9a-f]{16}$/);
|
|
23
|
+
expect(c.signedBy.user.name).toBe("Shinnapat");
|
|
24
|
+
expect(c.userPromises.length).toBe(DEFAULT_USER_PROMISES.length);
|
|
25
|
+
expect(c.vendorPromises.length).toBe(DEFAULT_VENDOR_PROMISES.length);
|
|
26
|
+
expect(c.hmac).toHaveLength(32);
|
|
27
|
+
expect(existsSync(join(repo, ".mneme/covenant/active.json"))).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
it("readActiveCovenant returns the persisted contract", () => {
|
|
30
|
+
const signed = signCovenant(repo, { userName: "test" });
|
|
31
|
+
const read = readActiveCovenant(repo);
|
|
32
|
+
expect(read).not.toBeNull();
|
|
33
|
+
expect(read.id).toBe(signed.id);
|
|
34
|
+
expect(read.hmac).toBe(signed.hmac);
|
|
35
|
+
});
|
|
36
|
+
it("readActiveCovenant returns null when no covenant exists", () => {
|
|
37
|
+
expect(readActiveCovenant(repo)).toBeNull();
|
|
38
|
+
});
|
|
39
|
+
it("verifyCovenant -- intact contract passes", () => {
|
|
40
|
+
const c = signCovenant(repo, { userName: "test" });
|
|
41
|
+
const v = verifyCovenant(repo, c);
|
|
42
|
+
expect(v.ok).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
it("verifyCovenant -- tampered contract fails", () => {
|
|
45
|
+
const c = signCovenant(repo, { userName: "test" });
|
|
46
|
+
const tampered = { ...c, userPromises: c.userPromises.map((p, i) => i === 0 ? { ...p, text: "DIFFERENT" } : p) };
|
|
47
|
+
const v = verifyCovenant(repo, tampered);
|
|
48
|
+
expect(v.ok).toBe(false);
|
|
49
|
+
expect(v.reason).toContain("mismatch");
|
|
50
|
+
});
|
|
51
|
+
it("re-signing archives the previous contract", () => {
|
|
52
|
+
const first = signCovenant(repo, { userName: "test" });
|
|
53
|
+
const second = signCovenant(repo, { userName: "test2" });
|
|
54
|
+
expect(second.id).not.toBe(first.id);
|
|
55
|
+
const archived = join(repo, ".mneme/covenant/archive", `${first.id}.json`);
|
|
56
|
+
expect(existsSync(archived)).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe("v1.58 Covenant · violation detection", () => {
|
|
60
|
+
let repo;
|
|
61
|
+
beforeEach(() => { repo = setupRepo(); });
|
|
62
|
+
afterEach(() => cleanup(repo));
|
|
63
|
+
it("returns empty when no covenant exists", () => {
|
|
64
|
+
expect(detectViolations(repo)).toEqual([]);
|
|
65
|
+
});
|
|
66
|
+
it("returns empty when soul + quorum logs are absent", () => {
|
|
67
|
+
signCovenant(repo, { userName: "test" });
|
|
68
|
+
expect(detectViolations(repo)).toEqual([]);
|
|
69
|
+
});
|
|
70
|
+
it("flags FALSE_FACT_CLAIM caveats from quorum.jsonl", () => {
|
|
71
|
+
signCovenant(repo, { userName: "test" });
|
|
72
|
+
const squadronDir = join(repo, ".mneme", "squadron");
|
|
73
|
+
mkdirSync(squadronDir, { recursive: true });
|
|
74
|
+
writeFileSync(join(squadronDir, "quorum.jsonl"), JSON.stringify({
|
|
75
|
+
ts: new Date().toISOString(),
|
|
76
|
+
claim: "Mneme is written in Rust",
|
|
77
|
+
caveats: ["FALSE_FACT_CLAIM", "CHANDRASEKHAR_COLLAPSE"],
|
|
78
|
+
}) + "\n", "utf8");
|
|
79
|
+
const violations = detectViolations(repo);
|
|
80
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
81
|
+
expect(violations[0].context).toContain("FALSE_FACT_CLAIM");
|
|
82
|
+
});
|
|
83
|
+
it("flags broken-soul entries from ai-souls", () => {
|
|
84
|
+
signCovenant(repo, { userName: "test" });
|
|
85
|
+
const soulsDir = join(repo, ".mneme", "ai-souls");
|
|
86
|
+
mkdirSync(soulsDir, { recursive: true });
|
|
87
|
+
writeFileSync(join(soulsDir, "claude-opus-4-7.json"), JSON.stringify({
|
|
88
|
+
sessions: [{ id: "s1", broken: 1, reason: "fabricated commit abcdef0", ts: new Date().toISOString() }],
|
|
89
|
+
}), "utf8");
|
|
90
|
+
const violations = detectViolations(repo);
|
|
91
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
92
|
+
expect(violations[0].vendor).toBe("claude-opus-4-7");
|
|
93
|
+
// "commit" keyword in reason -> no_fab_commits promise.
|
|
94
|
+
expect(violations[0].promiseId).toBe("no_fab_commits");
|
|
95
|
+
});
|
|
96
|
+
it("recordViolation appends to violations.jsonl", () => {
|
|
97
|
+
signCovenant(repo, { userName: "test" });
|
|
98
|
+
recordViolation(repo, {
|
|
99
|
+
ts: new Date().toISOString(), vendor: "test-vendor",
|
|
100
|
+
promiseId: "no_fab_commits", severity: 5,
|
|
101
|
+
context: "test violation", evidenceRef: "test",
|
|
102
|
+
});
|
|
103
|
+
const log = readFileSync(join(repo, ".mneme/covenant/violations.jsonl"), "utf8");
|
|
104
|
+
expect(log).toContain("test-vendor");
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
describe("v1.58 Covenant · compliance score", () => {
|
|
108
|
+
let repo;
|
|
109
|
+
beforeEach(() => { repo = setupRepo(); });
|
|
110
|
+
afterEach(() => cleanup(repo));
|
|
111
|
+
it("perfect score (100) when no violations", () => {
|
|
112
|
+
signCovenant(repo, { userName: "test" });
|
|
113
|
+
const s = complianceScore(repo, "claude-opus-4-7");
|
|
114
|
+
expect(s.score).toBe(100);
|
|
115
|
+
expect(s.violations).toBe(0);
|
|
116
|
+
});
|
|
117
|
+
it("score drops by severity per violation", () => {
|
|
118
|
+
signCovenant(repo, { userName: "test" });
|
|
119
|
+
recordViolation(repo, {
|
|
120
|
+
ts: new Date().toISOString(),
|
|
121
|
+
vendor: "claude-opus-4-7", promiseId: "no_fab_commits",
|
|
122
|
+
severity: 5, context: "test", evidenceRef: "test",
|
|
123
|
+
});
|
|
124
|
+
const s = complianceScore(repo, "claude-opus-4-7");
|
|
125
|
+
expect(s.score).toBe(95);
|
|
126
|
+
expect(s.violations).toBe(1);
|
|
127
|
+
});
|
|
128
|
+
it("score floors at 0", () => {
|
|
129
|
+
signCovenant(repo, { userName: "test" });
|
|
130
|
+
for (let i = 0; i < 30; i++) {
|
|
131
|
+
recordViolation(repo, {
|
|
132
|
+
ts: new Date().toISOString(),
|
|
133
|
+
vendor: "v", promiseId: "no_fab_commits",
|
|
134
|
+
severity: 5, context: "test", evidenceRef: "test",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const s = complianceScore(repo, "v");
|
|
138
|
+
expect(s.score).toBe(0);
|
|
139
|
+
});
|
|
140
|
+
it("recent violations count only last-30-day events", () => {
|
|
141
|
+
signCovenant(repo, { userName: "test" });
|
|
142
|
+
// Old violation (60 days ago).
|
|
143
|
+
const oldDate = new Date(Date.now() - 60 * 86400 * 1000).toISOString();
|
|
144
|
+
recordViolation(repo, {
|
|
145
|
+
ts: oldDate, vendor: "v", promiseId: "no_fab_commits",
|
|
146
|
+
severity: 1, context: "old", evidenceRef: "old",
|
|
147
|
+
});
|
|
148
|
+
// Recent violation.
|
|
149
|
+
recordViolation(repo, {
|
|
150
|
+
ts: new Date().toISOString(), vendor: "v", promiseId: "no_fab_commits",
|
|
151
|
+
severity: 1, context: "recent", evidenceRef: "recent",
|
|
152
|
+
});
|
|
153
|
+
const s = complianceScore(repo, "v");
|
|
154
|
+
expect(s.violations).toBe(2);
|
|
155
|
+
expect(s.recentViolations).toBe(1);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
describe("v1.58 Covenant · renewal", () => {
|
|
159
|
+
let repo;
|
|
160
|
+
beforeEach(() => { repo = setupRepo(); });
|
|
161
|
+
afterEach(() => cleanup(repo));
|
|
162
|
+
it("renewal days remaining is positive immediately after signing", () => {
|
|
163
|
+
signCovenant(repo, { userName: "test", renewalDays: 30 });
|
|
164
|
+
const d = renewalDaysRemaining(repo);
|
|
165
|
+
expect(d).not.toBeNull();
|
|
166
|
+
expect(d).toBeGreaterThanOrEqual(29);
|
|
167
|
+
expect(d).toBeLessThanOrEqual(30);
|
|
168
|
+
});
|
|
169
|
+
it("returns null when no covenant", () => {
|
|
170
|
+
expect(renewalDaysRemaining(repo)).toBeNull();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
//# sourceMappingURL=covenant.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"covenant.test.js","sourceRoot":"","sources":["../../src/covenant/covenant.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,SAAS,SAAS;IAChB,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;AACxD,CAAC;AACD,SAAS,OAAO,CAAC,CAAS,IAAI,IAAI,CAAC;IAAC,MAAM,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAAC,CAAC;AAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEpG,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,IAAI,IAAY,CAAC;IACjB,UAAU,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC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