@mneme-ai/core 2.14.1 → 2.15.1
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 +1 -1
- package/dist/agent_manifest.d.ts.map +1 -1
- package/dist/agent_manifest.js +18 -1
- package/dist/agent_manifest.js.map +1 -1
- package/dist/arbitrage/arbitrage.test.d.ts +2 -0
- package/dist/arbitrage/arbitrage.test.d.ts.map +1 -0
- package/dist/arbitrage/arbitrage.test.js +131 -0
- package/dist/arbitrage/arbitrage.test.js.map +1 -0
- package/dist/arbitrage/index.d.ts +140 -0
- package/dist/arbitrage/index.d.ts.map +1 -0
- package/dist/arbitrage/index.js +242 -0
- package/dist/arbitrage/index.js.map +1 -0
- package/dist/bug_prophet/bug_prophet.test.d.ts +2 -0
- package/dist/bug_prophet/bug_prophet.test.d.ts.map +1 -0
- package/dist/bug_prophet/bug_prophet.test.js +110 -0
- package/dist/bug_prophet/bug_prophet.test.js.map +1 -0
- package/dist/bug_prophet/index.d.ts +85 -0
- package/dist/bug_prophet/index.d.ts.map +1 -0
- package/dist/bug_prophet/index.js +219 -0
- package/dist/bug_prophet/index.js.map +1 -0
- package/dist/cosmic/aurelian_bug_prophet.test.d.ts +5 -0
- package/dist/cosmic/aurelian_bug_prophet.test.d.ts.map +1 -0
- package/dist/cosmic/aurelian_bug_prophet.test.js +31 -0
- package/dist/cosmic/aurelian_bug_prophet.test.js.map +1 -0
- package/dist/cosmic/aurelian_v215.test.d.ts +9 -0
- package/dist/cosmic/aurelian_v215.test.d.ts.map +1 -0
- package/dist/cosmic/aurelian_v215.test.js +75 -0
- package/dist/cosmic/aurelian_v215.test.js.map +1 -0
- package/dist/genesis/genesis.test.d.ts +2 -0
- package/dist/genesis/genesis.test.d.ts.map +1 -0
- package/dist/genesis/genesis.test.js +159 -0
- package/dist/genesis/genesis.test.js.map +1 -0
- package/dist/genesis/index.d.ts +94 -0
- package/dist/genesis/index.d.ts.map +1 -0
- package/dist/genesis/index.js +452 -0
- package/dist/genesis/index.js.map +1 -0
- package/dist/hive/hive.test.d.ts +2 -0
- package/dist/hive/hive.test.d.ts.map +1 -0
- package/dist/hive/hive.test.js +162 -0
- package/dist/hive/hive.test.js.map +1 -0
- package/dist/hive/index.d.ts +151 -0
- package/dist/hive/index.d.ts.map +1 -0
- package/dist/hive/index.js +246 -0
- package/dist/hive/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/vibe/index.d.ts +89 -0
- package/dist/vibe/index.d.ts.map +1 -0
- package/dist/vibe/index.js +243 -0
- package/dist/vibe/index.js.map +1 -0
- package/dist/vibe/vibe.test.d.ts +2 -0
- package/dist/vibe/vibe.test.d.ts.map +1 -0
- package/dist/vibe/vibe.test.js +97 -0
- package/dist/vibe/vibe.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/package.json +1 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.15.0 — MNEME ARBITRAGE
|
|
3
|
+
*
|
|
4
|
+
* "For every AI prompt, route to the cheapest vendor with acceptable
|
|
5
|
+
* quality. Quality measured by BOUNTY's per-vendor falseRate AND
|
|
6
|
+
* HIVE's per-pattern outcome history. Cost measured per token from
|
|
7
|
+
* a maintained price table. Outcome feeds back into BOUNTY → router
|
|
8
|
+
* learns over time."
|
|
9
|
+
*
|
|
10
|
+
* The hypercar feature: meta-AI router that gets BETTER as you use
|
|
11
|
+
* Mneme. After ~50 prompts, the router beats hand-picking — because it
|
|
12
|
+
* knows YOUR distribution of tasks + each vendor's measured trustability
|
|
13
|
+
* for that task class.
|
|
14
|
+
*
|
|
15
|
+
* Pure-function design (no network) — `chooseVendor` returns the
|
|
16
|
+
* recommended vendor + rationale. The caller routes the prompt.
|
|
17
|
+
* Optional `recordOutcome` feeds results back into BOUNTY.
|
|
18
|
+
*
|
|
19
|
+
* Wisdom: composes BOUNTY (vendor falseRate) + REPLICA (your historical
|
|
20
|
+
* decisions) + a price table. Never re-implements anything; pure
|
|
21
|
+
* orchestrator.
|
|
22
|
+
*/
|
|
23
|
+
import { createHmac } from "node:crypto";
|
|
24
|
+
const PROTOCOL_VERSION = 1;
|
|
25
|
+
/**
|
|
26
|
+
* Default vendor capability table. ORDER OF MAGNITUDE estimates only —
|
|
27
|
+
* actual values shift weekly. Real signal comes from your BOUNTY ledger
|
|
28
|
+
* once you have ≥50 samples per vendor.
|
|
29
|
+
*/
|
|
30
|
+
export const DEFAULT_VENDORS = [
|
|
31
|
+
{
|
|
32
|
+
vendor: "claude",
|
|
33
|
+
pricePer1kInput: 0.015, pricePer1kOutput: 0.075,
|
|
34
|
+
strengthByTask: {
|
|
35
|
+
code_generation: 0.92, code_review: 0.95, debugging: 0.93,
|
|
36
|
+
refactoring: 0.94, explanation: 0.95, structured_output: 0.93,
|
|
37
|
+
function_calling: 0.94, agentic_workflow: 0.95,
|
|
38
|
+
test_writing: 0.90, documentation: 0.93,
|
|
39
|
+
},
|
|
40
|
+
hasFree: false, fastPath: true, functionCalls: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
vendor: "chatgpt",
|
|
44
|
+
pricePer1kInput: 0.01, pricePer1kOutput: 0.03,
|
|
45
|
+
strengthByTask: {
|
|
46
|
+
code_generation: 0.88, debugging: 0.85, refactoring: 0.84,
|
|
47
|
+
explanation: 0.92, summarization: 0.91, translation: 0.93,
|
|
48
|
+
creative_writing: 0.93, data_analysis: 0.88,
|
|
49
|
+
research: 0.86, structured_output: 0.90, function_calling: 0.92,
|
|
50
|
+
},
|
|
51
|
+
hasFree: true, fastPath: true, functionCalls: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
vendor: "gemini",
|
|
55
|
+
pricePer1kInput: 0.0035, pricePer1kOutput: 0.0105,
|
|
56
|
+
strengthByTask: {
|
|
57
|
+
code_generation: 0.85, summarization: 0.93, translation: 0.92,
|
|
58
|
+
research: 0.95, data_analysis: 0.93, explanation: 0.88,
|
|
59
|
+
structured_output: 0.89, function_calling: 0.90,
|
|
60
|
+
},
|
|
61
|
+
hasFree: true, fastPath: true, functionCalls: true,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
vendor: "deepseek",
|
|
65
|
+
pricePer1kInput: 0.00027, pricePer1kOutput: 0.0011,
|
|
66
|
+
strengthByTask: {
|
|
67
|
+
code_generation: 0.86, debugging: 0.85, refactoring: 0.83,
|
|
68
|
+
structured_output: 0.85, function_calling: 0.84,
|
|
69
|
+
test_writing: 0.83,
|
|
70
|
+
},
|
|
71
|
+
hasFree: false, fastPath: true, functionCalls: true,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
vendor: "qwen",
|
|
75
|
+
pricePer1kInput: 0.0004, pricePer1kOutput: 0.0012,
|
|
76
|
+
strengthByTask: {
|
|
77
|
+
code_generation: 0.82, summarization: 0.86, translation: 0.91,
|
|
78
|
+
structured_output: 0.83,
|
|
79
|
+
},
|
|
80
|
+
hasFree: true, fastPath: true, functionCalls: true,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
vendor: "llama",
|
|
84
|
+
pricePer1kInput: 0, pricePer1kOutput: 0,
|
|
85
|
+
strengthByTask: {
|
|
86
|
+
code_generation: 0.78, summarization: 0.84, translation: 0.85,
|
|
87
|
+
explanation: 0.83,
|
|
88
|
+
},
|
|
89
|
+
hasFree: true, fastPath: false, functionCalls: false,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
vendor: "perplexity",
|
|
93
|
+
pricePer1kInput: 0.001, pricePer1kOutput: 0.001,
|
|
94
|
+
strengthByTask: {
|
|
95
|
+
research: 0.96, summarization: 0.92, explanation: 0.88,
|
|
96
|
+
data_analysis: 0.85,
|
|
97
|
+
},
|
|
98
|
+
hasFree: true, fastPath: true, functionCalls: false,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
const QUALITY_THRESHOLD = {
|
|
102
|
+
ultra: 0.92, high: 0.85, balanced: 0.78, cheap: 0.70, free_only: 0.0,
|
|
103
|
+
};
|
|
104
|
+
function canon(v) {
|
|
105
|
+
if (v === null || typeof v !== "object")
|
|
106
|
+
return JSON.stringify(v);
|
|
107
|
+
if (Array.isArray(v))
|
|
108
|
+
return "[" + v.map(canon).join(",") + "]";
|
|
109
|
+
const keys = Object.keys(v).sort();
|
|
110
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canon(v[k])).join(",") + "}";
|
|
111
|
+
}
|
|
112
|
+
function defaultSecret() {
|
|
113
|
+
return process.env["MNEME_ARBITRAGE_SECRET"] || `mneme-arbitrage-v${PROTOCOL_VERSION}`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Recommend a vendor for a task. Pure function — does NOT call any AI.
|
|
117
|
+
*
|
|
118
|
+
* Algorithm:
|
|
119
|
+
* 1. For each candidate, compute qualityScore = strengthByTask[task]
|
|
120
|
+
* (default 0.7 if unknown). If measured BOUNTY data exists for the
|
|
121
|
+
* vendor, blend it in (qualityScore *= (1 - falseRateLB)).
|
|
122
|
+
* 2. Filter by qualityScore >= threshold[budget].
|
|
123
|
+
* 3. Compute estCost = (estTokens.input * pricePer1kInput + estTokens.
|
|
124
|
+
* output * pricePer1kOutput) / 1000.
|
|
125
|
+
* 4. Score = qualityScore / max(estCost, 0.0001) — best quality per $.
|
|
126
|
+
* 5. Pick top scorer; provide ordered fallback.
|
|
127
|
+
*/
|
|
128
|
+
export function chooseVendor(input) {
|
|
129
|
+
const vendors = input.vendors ?? DEFAULT_VENDORS;
|
|
130
|
+
const budget = input.budget ?? "balanced";
|
|
131
|
+
const threshold = QUALITY_THRESHOLD[budget];
|
|
132
|
+
const tokens = input.estTokens ?? { input: 1000, output: 500 };
|
|
133
|
+
const candidates = vendors.filter((v) => !input.candidates || input.candidates.includes(v.vendor));
|
|
134
|
+
const considered = candidates.map((v) => {
|
|
135
|
+
const baseStrength = v.strengthByTask[input.task] ?? 0.7;
|
|
136
|
+
let qualityScore = baseStrength;
|
|
137
|
+
let scoreReason = `default strength ${baseStrength.toFixed(2)} on ${input.task}`;
|
|
138
|
+
const measured = input.measured?.[v.vendor];
|
|
139
|
+
if (measured && measured.samples >= 5) {
|
|
140
|
+
// Blend: measured trustworthiness penalty.
|
|
141
|
+
const adjustment = 1 - measured.falseRateLB;
|
|
142
|
+
qualityScore = baseStrength * adjustment;
|
|
143
|
+
scoreReason = `measured ${measured.samples} samples · falseRateLB ${measured.falseRateLB.toFixed(3)}`;
|
|
144
|
+
}
|
|
145
|
+
const estCostUsd = (tokens.input * v.pricePer1kInput + tokens.output * v.pricePer1kOutput) / 1000;
|
|
146
|
+
// Free tier respected when budget = free_only
|
|
147
|
+
const eligible = budget === "free_only"
|
|
148
|
+
? v.hasFree
|
|
149
|
+
: qualityScore >= threshold;
|
|
150
|
+
const score = eligible
|
|
151
|
+
? qualityScore / Math.max(estCostUsd, 0.0001)
|
|
152
|
+
: 0;
|
|
153
|
+
return {
|
|
154
|
+
vendor: v.vendor,
|
|
155
|
+
score: Math.round(score * 100) / 100,
|
|
156
|
+
qualityScore: Math.round(qualityScore * 1000) / 1000,
|
|
157
|
+
estCostUsd: Math.round(estCostUsd * 100000) / 100000,
|
|
158
|
+
eligible,
|
|
159
|
+
reason: scoreReason,
|
|
160
|
+
};
|
|
161
|
+
}).sort((a, b) => b.score - a.score);
|
|
162
|
+
const eligibleSorted = considered.filter((c) => c.eligible);
|
|
163
|
+
const top = eligibleSorted[0];
|
|
164
|
+
let decision = null;
|
|
165
|
+
let reason = "no candidate met the quality threshold";
|
|
166
|
+
if (top) {
|
|
167
|
+
const maxCost = Math.max(...eligibleSorted.map((c) => c.estCostUsd));
|
|
168
|
+
decision = {
|
|
169
|
+
vendor: top.vendor,
|
|
170
|
+
qualityScore: top.qualityScore,
|
|
171
|
+
estCostUsd: top.estCostUsd,
|
|
172
|
+
savingsVsTopUsd: Math.round((maxCost - top.estCostUsd) * 100000) / 100000,
|
|
173
|
+
fallback: eligibleSorted.slice(1, 4).map((c) => c.vendor),
|
|
174
|
+
};
|
|
175
|
+
reason = `${top.vendor} wins: quality ${top.qualityScore}, cost $${top.estCostUsd}, fallback=${decision.fallback.join(",") || "none"}`;
|
|
176
|
+
}
|
|
177
|
+
const generatedAt = new Date().toISOString();
|
|
178
|
+
const body = {
|
|
179
|
+
v: PROTOCOL_VERSION,
|
|
180
|
+
decision, reason, considered, generatedAt,
|
|
181
|
+
};
|
|
182
|
+
const sig = createHmac("sha256", input.secret ?? defaultSecret()).update(canon(body)).digest("hex");
|
|
183
|
+
return { ...body, sig };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Estimate token count from text length. Cheap heuristic — ~4 chars/
|
|
187
|
+
* token English; ~6 chars/token for code; ~2 chars/token for CJK.
|
|
188
|
+
*/
|
|
189
|
+
export function estimateTokens(text, opts = {}) {
|
|
190
|
+
const kind = opts.kind ?? "english";
|
|
191
|
+
const charsPerToken = kind === "code" ? 6 : kind === "cjk" ? 2 : 4;
|
|
192
|
+
return Math.ceil(text.length / charsPerToken);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* After a routed request returns, record the outcome to feed back into
|
|
196
|
+
* BOUNTY for next-time routing. Composes onto the existing v2.14
|
|
197
|
+
* BOUNTY module — does not duplicate.
|
|
198
|
+
*/
|
|
199
|
+
export async function recordRoutingOutcome(input) {
|
|
200
|
+
try {
|
|
201
|
+
const bounty = await import("../bounty/index.js");
|
|
202
|
+
const claim = bounty.recordClaim({
|
|
203
|
+
vendor: input.vendor,
|
|
204
|
+
text: `[arbitrage] task=${input.task}`,
|
|
205
|
+
session: "arbitrage",
|
|
206
|
+
...(input.repoDir ? { repoDir: input.repoDir } : {}),
|
|
207
|
+
});
|
|
208
|
+
bounty.recordVerdict({
|
|
209
|
+
claimId: claim.id,
|
|
210
|
+
vendor: input.vendor,
|
|
211
|
+
verdict: input.outcome === "correct" ? "true" : input.outcome === "wrong" ? "false" : "partial",
|
|
212
|
+
reason: input.detail.slice(0, 400),
|
|
213
|
+
...(input.repoDir ? { repoDir: input.repoDir } : {}),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch { /* bounty unavailable; non-fatal */ }
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Read measured falseRateLB per vendor from BOUNTY for richer routing.
|
|
220
|
+
* Returns the input shape that chooseVendor accepts as `measured`.
|
|
221
|
+
*/
|
|
222
|
+
export async function snapshotMeasured(opts = {}) {
|
|
223
|
+
const out = {};
|
|
224
|
+
try {
|
|
225
|
+
const bounty = await import("../bounty/index.js");
|
|
226
|
+
const board = bounty.leaderboard({ ...(opts.repoDir ? { repoDir: opts.repoDir } : {}) });
|
|
227
|
+
for (const card of board) {
|
|
228
|
+
out[card.vendor] = { falseRateLB: card.falseRateLB, samples: card.totalVerdicts };
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch { /* bounty unavailable */ }
|
|
232
|
+
return out;
|
|
233
|
+
}
|
|
234
|
+
/** One-line pulse summary. */
|
|
235
|
+
export function formatArbitrageLine(result) {
|
|
236
|
+
if (!result)
|
|
237
|
+
return "ARBITRAGE · idle";
|
|
238
|
+
if (!result.decision)
|
|
239
|
+
return `ARBITRAGE · NO MATCH (${result.considered.length} considered)`;
|
|
240
|
+
return `ARBITRAGE · ${result.decision.vendor} · q=${result.decision.qualityScore} · $${result.decision.estCostUsd} · save $${result.decision.savingsVsTopUsd}`;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/arbitrage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,g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O,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACzF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,CAAC,MAAgB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;QAC9F,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAC,wBAAwB,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,mBAAmB,CAAC,MAAiC;IACnE,IAAI,CAAC,MAAM;QAAE,OAAO,kBAAkB,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,OAAO,yBAAyB,MAAM,CAAC,UAAU,CAAC,MAAM,cAAc,CAAC;IAC7F,OAAO,eAAe,MAAM,CAAC,QAAQ,CAAC,MAAM,QAAQ,MAAM,CAAC,QAAQ,CAAC,YAAY,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,YAAY,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;AACjK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bug_prophet.test.d.ts","sourceRoot":"","sources":["../../src/bug_prophet/bug_prophet.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { prophesy, formatBugProphetLine } from "./index.js";
|
|
3
|
+
describe("v2.15.1 · MNEME BUG PROPHET — pre-bug detection", () => {
|
|
4
|
+
it("baseline empty corpora → low_risk verdict", async () => {
|
|
5
|
+
const r = await prophesy({ change: { description: "add a getter" }, stubs: {} });
|
|
6
|
+
expect(r.verdict).toBe("low_risk");
|
|
7
|
+
expect(r.regressionRisk).toBeLessThan(0.25);
|
|
8
|
+
expect(r.sig).toMatch(/^[0-9a-f]{64}$/);
|
|
9
|
+
});
|
|
10
|
+
it("SOUL scar match → high_risk", async () => {
|
|
11
|
+
const r = await prophesy({
|
|
12
|
+
change: { description: "deploy on Friday afternoon" },
|
|
13
|
+
stubs: {
|
|
14
|
+
soulFindings: { findings: [{ category: "scars", ruleId: "no-friday-deploys", severity: "block" }] },
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
expect(["high_risk", "very_high_risk"]).toContain(r.verdict);
|
|
18
|
+
expect(r.evidence.some((e) => e.source === "soul_scar")).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
it("HIVE pattern with 80% bad outcomes → very_high_risk", async () => {
|
|
21
|
+
const r = await prophesy({
|
|
22
|
+
change: { description: "refactor auth flow" },
|
|
23
|
+
stubs: {
|
|
24
|
+
hiveLookup: {
|
|
25
|
+
totalObservations: 20,
|
|
26
|
+
byOutcome: { good: 4, bad: 12, regression: 4, unknown: 0 },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
expect(["high_risk", "very_high_risk"]).toContain(r.verdict);
|
|
31
|
+
expect(r.evidence.some((e) => e.source === "hive_regression")).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
it("BOUNTY high vendor falseRateLB → adds evidence + bumps risk", async () => {
|
|
34
|
+
const a = await prophesy({
|
|
35
|
+
change: { description: "small typo fix", proposedBy: "claude" },
|
|
36
|
+
stubs: { bountyFalseRateLB: 0.6 },
|
|
37
|
+
});
|
|
38
|
+
const b = await prophesy({
|
|
39
|
+
change: { description: "small typo fix", proposedBy: "claude" },
|
|
40
|
+
stubs: { bountyFalseRateLB: 0.0 },
|
|
41
|
+
});
|
|
42
|
+
expect(a.regressionRisk).toBeGreaterThan(b.regressionRisk);
|
|
43
|
+
expect(a.evidence.some((e) => e.source === "bounty_trust")).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
it("compounding evidence: scar + replica bad + hive bad → very_high_risk", async () => {
|
|
46
|
+
const r = await prophesy({
|
|
47
|
+
change: { description: "deploy on Friday", proposedBy: "claude" },
|
|
48
|
+
stubs: {
|
|
49
|
+
soulFindings: { findings: [{ category: "scars", ruleId: "friday-deploy-incident", severity: "block" }] },
|
|
50
|
+
replicaSimilarBad: [{ question: "Friday afternoon deploy?", action: "shipped anyway" }],
|
|
51
|
+
hiveLookup: { totalObservations: 10, byOutcome: { good: 2, bad: 6, regression: 2, unknown: 0 } },
|
|
52
|
+
bountyFalseRateLB: 0.4,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
expect(r.verdict).toBe("very_high_risk");
|
|
56
|
+
expect(r.regressionRisk).toBeGreaterThan(0.7);
|
|
57
|
+
});
|
|
58
|
+
it("mitigations include scar-specific advice when scar evidence present", async () => {
|
|
59
|
+
const r = await prophesy({
|
|
60
|
+
change: { description: "Friday deploy" },
|
|
61
|
+
stubs: { soulFindings: { findings: [{ category: "scars", ruleId: "x", severity: "block" }] } },
|
|
62
|
+
});
|
|
63
|
+
expect(r.mitigations.some((m) => /scar|past self/i.test(m))).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
it("complexity heuristic surfaces evidence at score > 0.5", async () => {
|
|
66
|
+
const lots = Array.from({ length: 250 }, (_, i) => `function f${i}() { if (x) { for (let j = 0; j < 10; j++) try { call(); } catch (e) {} } }`).join("\n");
|
|
67
|
+
const r = await prophesy({
|
|
68
|
+
change: { description: "big refactor", content: lots, files: Array.from({ length: 10 }, (_, i) => `src/${i}.ts`) },
|
|
69
|
+
stubs: { complexityScore: 0.8 },
|
|
70
|
+
});
|
|
71
|
+
expect(r.evidence.some((e) => e.source === "complexity")).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
it("low confidence on empty corpora (≤0.55)", async () => {
|
|
74
|
+
const r = await prophesy({ change: { description: "x" }, stubs: {} });
|
|
75
|
+
expect(r.confidence).toBeLessThanOrEqual(0.55);
|
|
76
|
+
});
|
|
77
|
+
it("confidence rises with richer corpora", async () => {
|
|
78
|
+
const r = await prophesy({
|
|
79
|
+
change: { description: "x" },
|
|
80
|
+
stubs: {
|
|
81
|
+
soulFindings: { findings: [] },
|
|
82
|
+
replicaBadCount: 50,
|
|
83
|
+
hiveLookup: { totalObservations: 100, byOutcome: { good: 80, bad: 10, regression: 10, unknown: 0 } },
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
expect(r.confidence).toBeGreaterThan(0.55);
|
|
87
|
+
});
|
|
88
|
+
it("HMAC sig on full report", async () => {
|
|
89
|
+
const r = await prophesy({ change: { description: "x" }, stubs: {} });
|
|
90
|
+
expect(r.sig).toMatch(/^[0-9a-f]{64}$/);
|
|
91
|
+
});
|
|
92
|
+
it("formatBugProphetLine summarises", async () => {
|
|
93
|
+
const r = await prophesy({ change: { description: "x" }, stubs: {} });
|
|
94
|
+
expect(formatBugProphetLine(r)).toContain("BUG PROPHET");
|
|
95
|
+
expect(formatBugProphetLine(r)).toContain("%");
|
|
96
|
+
});
|
|
97
|
+
it("verdict buckets are monotonic with risk", async () => {
|
|
98
|
+
const lo = await prophesy({ change: { description: "noop" }, stubs: {} });
|
|
99
|
+
const hi = await prophesy({
|
|
100
|
+
change: { description: "deploy on Friday", proposedBy: "claude" },
|
|
101
|
+
stubs: {
|
|
102
|
+
soulFindings: { findings: [{ category: "scars", ruleId: "x", severity: "block" }] },
|
|
103
|
+
hiveLookup: { totalObservations: 20, byOutcome: { good: 1, bad: 15, regression: 4, unknown: 0 } },
|
|
104
|
+
bountyFalseRateLB: 0.6,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
expect(hi.regressionRisk).toBeGreaterThan(lo.regressionRisk);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=bug_prophet.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bug_prophet.test.js","sourceRoot":"","sources":["../../src/bug_prophet/bug_prophet.test.ts"],"names":[],"mappings":"AAAA,OAAO,E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AAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACvD,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1E,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC;YACxB,MAAM,EAAE,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,QAAQ,EAAE;YACjE,KAAK,EAAE;gBACL,YAAY,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE;gBACnF,UAAU,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;gBACjG,iBAAiB,EAAE,GAAG;aACvB;SACF,CAAC,CAAC;QACH,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.15.1 — MNEME BUG PROPHET
|
|
3
|
+
*
|
|
4
|
+
* "Predict bugs before they happen. The signal is already in your
|
|
5
|
+
* Mneme data: PROJECT SOUL scars name the patterns you've paid for,
|
|
6
|
+
* REPLICA decisions hold the outcomes, HIVE knows what patterns
|
|
7
|
+
* fail elsewhere, BOUNTY tracks which vendor lied last. BUG PROPHET
|
|
8
|
+
* fuses these four into a 0..1 regression risk for any proposed
|
|
9
|
+
* change — BEFORE you ship it."
|
|
10
|
+
*
|
|
11
|
+
* The Nobel move: BUG PROPHET doesn't run any LLM. Pure inference over
|
|
12
|
+
* existing Mneme data + the proposed change. Returns:
|
|
13
|
+
* - regressionRisk (0..1)
|
|
14
|
+
* - aggregated evidence from SOUL / REPLICA / HIVE / BOUNTY
|
|
15
|
+
* - mitigations tailored to the evidence
|
|
16
|
+
*
|
|
17
|
+
* Composes orthogonally with the existing v2.1 `prophet/` (which
|
|
18
|
+
* pre-fetches next-query topics) — different concern, different dir.
|
|
19
|
+
*
|
|
20
|
+
* Wisdom: BUG PROPHET gets stronger over time. Day 1 = conservative
|
|
21
|
+
* heuristic baseline. Day 90 with rich SOUL+REPLICA+HIVE+BOUNTY = real
|
|
22
|
+
* predictive power.
|
|
23
|
+
*/
|
|
24
|
+
declare const PROTOCOL_VERSION: 1;
|
|
25
|
+
export interface ProposedChange {
|
|
26
|
+
description: string;
|
|
27
|
+
files?: string[];
|
|
28
|
+
addsDeps?: string[];
|
|
29
|
+
content?: string;
|
|
30
|
+
/** Which AI vendor proposed it — used for BOUNTY trust weighting. */
|
|
31
|
+
proposedBy?: string;
|
|
32
|
+
/** Task class for routing context. */
|
|
33
|
+
taskClass?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface PropheticEvidence {
|
|
36
|
+
source: "soul_scar" | "replica_bad" | "hive_regression" | "bounty_trust" | "complexity" | "soul_block";
|
|
37
|
+
weight: number;
|
|
38
|
+
detail: string;
|
|
39
|
+
ref?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface PropheticReport {
|
|
42
|
+
v: typeof PROTOCOL_VERSION;
|
|
43
|
+
regressionRisk: number;
|
|
44
|
+
confidence: number;
|
|
45
|
+
verdict: "low_risk" | "medium_risk" | "high_risk" | "very_high_risk";
|
|
46
|
+
headline: string;
|
|
47
|
+
evidence: PropheticEvidence[];
|
|
48
|
+
mitigations: string[];
|
|
49
|
+
signedAt: string;
|
|
50
|
+
sig: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ProphesyInput {
|
|
53
|
+
change: ProposedChange;
|
|
54
|
+
repoDir?: string;
|
|
55
|
+
stubs?: {
|
|
56
|
+
soulFindings?: {
|
|
57
|
+
findings: Array<{
|
|
58
|
+
category: string;
|
|
59
|
+
ruleId: string;
|
|
60
|
+
severity: "warn" | "block";
|
|
61
|
+
}>;
|
|
62
|
+
};
|
|
63
|
+
replicaBadCount?: number;
|
|
64
|
+
replicaSimilarBad?: Array<{
|
|
65
|
+
question: string;
|
|
66
|
+
action: string;
|
|
67
|
+
}>;
|
|
68
|
+
hiveLookup?: {
|
|
69
|
+
totalObservations: number;
|
|
70
|
+
byOutcome: {
|
|
71
|
+
good: number;
|
|
72
|
+
bad: number;
|
|
73
|
+
regression: number;
|
|
74
|
+
unknown: number;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
bountyFalseRateLB?: number;
|
|
78
|
+
complexityScore?: number;
|
|
79
|
+
};
|
|
80
|
+
secret?: string;
|
|
81
|
+
}
|
|
82
|
+
export declare function prophesy(input: ProphesyInput): Promise<PropheticReport>;
|
|
83
|
+
export declare function formatBugProphetLine(r: PropheticReport): string;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bug_prophet/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,QAAA,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,E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