Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 188 to 189

Compare

+108 −0 in 1 place
new file, 108 lines
1+// Score Jev against how agents really settled past holds (#19).
2+//
3+// node scripts/autosettle/score.ts <cases.json> [--out <report.json>] [--model jev-latest]
4+//
5+// A case is one settled collision: base, yours, theirsLines, context, both
6+// pushes' messages, and `kept` from the server's settled record (yours, theirs,
7+// both, or rewrote, which counts as "agent": a hand edit). Needs JEV_API_KEY.
8+
9+import { readFileSync, writeFileSync } from "node:fs";
10+import { ask, dollars, type Hold, PICKS, type Pick, type Verdict } from "./jev.ts";
12+interface Case {
13+ id: string;
14+ file: string;
15+ kind?: string;
16+ settler: { agent: string; heldMessage?: string; settleMessage?: string };
17+ theirs: { agent: string; version: number; message?: string };
18+ base: string[] | null;
19+ yours: string[] | null;
20+ theirsLines: string[] | null;
21+ context?: { before?: string[]; after?: string[] };
22+ kept: "yours" | "theirs" | "both" | "rewrote";
23+ issue?: string | null;
24+}
26+const truth = (kept: Case["kept"]): Pick => (kept === "rewrote" ? "agent" : kept);
28+function holdOf(c: Case): Hold {
29+ return {
30+ file: c.file,
31+ base: c.base ?? [],
32+ yours: c.yours ?? [],
33+ theirs: c.theirsLines ?? [],
34+ before: c.context?.before ?? [],
35+ after: c.context?.after ?? [],
36+ yourAgent: c.settler.agent,
37+ ...(c.settler.heldMessage ? { yourMessage: c.settler.heldMessage } : {}),
38+ theirAgent: c.theirs.agent,
39+ ...(c.theirs.message ? { theirMessage: c.theirs.message } : {}),
40+ ...(c.issue ? { issue: c.issue } : {}),
41+ };
42+}
44+function flag(args: string[], name: string): string | undefined {
45+ const i = args.indexOf(name);
46+ return i === -1 ? undefined : args[i + 1];
47+}
49+const args = process.argv.slice(2);
50+const cases = (JSON.parse(readFileSync(args[0]!, "utf8")) as Case[]).filter(
51+ (c) => c.yours !== null && c.theirsLines !== null,
52+);
53+const rows: { id: string; truth: Pick; verdict: Verdict; right: boolean }[] = [];
54+for (const c of cases) {
55+ try {
56+ const verdict = await ask(holdOf(c), { ...(flag(args, "--model") ? { model: flag(args, "--model") } : {}) });
57+ const t = truth(c.kept);
58+ rows.push({ id: c.id, truth: t, verdict, right: verdict.pick === t });
59+ console.log(
60+ `${verdict.pick === t ? "agree" : "DIFFER"} ${c.id}: agent ${t}, Jev ${verdict.pick} ${verdict.confidence.toFixed(2)} (${verdict.ms.toFixed(0)} ms)`,
61+ );
62+ } catch (e) {
63+ console.log(`error ${c.id}: ${(e as Error).message}`);
64+ }
65+}
67+const mean = (xs: number[]) => (xs.length === 0 ? Number.NaN : xs.reduce((a, b) => a + b, 0) / xs.length);
68+const right = rows.filter((r) => r.right);
69+const wrong = rows.filter((r) => !r.right);
70+const ms = rows.map((r) => r.verdict.ms).sort((a, b) => a - b);
71+const tokens = rows.map((r) => r.verdict.inputTokens);
72+const at = (threshold: number) => {
73+ const sure = rows.filter((r) => r.verdict.confidence >= threshold);
74+ return { threshold, settled: sure.length, agreed: sure.filter((r) => r.right).length };
75+};
76+const report = {
77+ model: rows[0]?.verdict.model,
78+ cases: rows.length,
79+ skipped: cases.length - rows.length,
80+ agreed: right.length,
81+ confidenceWhenRight: mean(right.map((r) => r.verdict.confidence)),
82+ confidenceWhenWrong: mean(wrong.map((r) => r.verdict.confidence)),
83+ thresholds: [0.3, 0.5, 0.6, 0.7, 0.8, 0.9].map(at),
84+ confusion: Object.fromEntries(
85+ PICKS.map((t) => [
86+ t,
87+ Object.fromEntries(PICKS.map((p) => [p, rows.filter((r) => r.truth === t && r.verdict.pick === p).length])),
88+ ]),
89+ ),
90+ ordersDisagreed: rows.filter((r) => r.verdict.orders[0]!.pick !== r.verdict.orders[1]!.pick).length,
91+ latencyMs: { median: ms[Math.floor(ms.length / 2)], max: ms[ms.length - 1], mean: mean(ms) },
92+ inputTokensMean: mean(tokens),
93+ dollarsPerCall: dollars(mean(tokens)),
94+ rows: rows.map((r) => ({
95+ id: r.id,
96+ agent: r.truth,
97+ jev: r.verdict.pick,
98+ confidence: r.verdict.confidence,
99+ probabilities: r.verdict.probabilities,
100+ orders: r.verdict.orders.map((o) => o.pick),
101+ signs: r.verdict.signs,
102+ ms: Math.round(r.verdict.ms),
103+ })),
104+};
105+const out = flag(args, "--out");
106+if (out) writeFileSync(out, JSON.stringify(report, null, "\t"));
107+const { rows: _, ...summary } = report;
108+console.log(JSON.stringify(summary, null, "\t"));
MCP
compare on this site's /mcp
CLI
abso diff 188 189 scripts/autosettle/score.ts --json
JSON
/christopher/abso-core/compare/188..189?file=scripts%2Fautosettle%2Fscore.ts&format=json