- MCP
- blame on this site's /mcp
- CLI
- abso blame scripts/autosettle/score.ts --json
- JSON
- /christopher/abso-core/blame/scripts/autosettle/score.ts?format=json
133 linesautosettle 100%Last change autosettle in version 198,
133 lines from 4 changes in 3 versions.
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare1// Score a model against how agents really settled past holds (#19).
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare2//
autosettle198Auto-settle (#19): Clef, Cloudflare's decision model on Workers AI, as a settler. Clef takes Jev's System One request, so clef.ts sends jev.ts's own questions through the local Worker's new /system-one route, with the same code checks before and after. score.ts and settle-one.ts take --via clef (--model clef or clef-flash). Six local holds: 6 of 6 right, 0.4 to 0.6 s each.Compare3// node scripts/autosettle/score.ts <cases.json> [--via workers-ai|clef|jev] [--model <id>] [--out <report.json>]
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare4//
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare5// --via workers-ai (the default) needs the Worker in workers-ai/ running under wrangler dev.
6//
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare7// A case is one settled collision: base, yours, theirsLines, context, both
8// pushes' messages, and `kept` from the server's settled record (yours, theirs,
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare9// both, or rewrote, which counts as "agent": a hand edit). --via jev needs JEV_API_KEY.
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare10
11import { readFileSync, writeFileSync } from "node:fs";
autosettle198Auto-settle (#19): Clef, Cloudflare's decision model on Workers AI, as a settler. Clef takes Jev's System One request, so clef.ts sends jev.ts's own questions through the local Worker's new /system-one route, with the same code checks before and after. score.ts and settle-one.ts take --via clef (--model clef or clef-flash). Six local holds: 6 of 6 right, 0.4 to 0.6 s each.Compare12import { askClef } from "./clef.ts";
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare13import { ask, dollars, type Hold, PICKS, type Pick } from "./jev.ts";
14import { askWorkersAi } from "./workers-ai.ts";
16/** What score needs from either model. */
17interface Verdict {
18 pick: Pick;
19 confidence: number;
20 model: string;
21 ms: number;
22 inputTokens: number;
23 reason?: string;
24 probabilities?: Record<Pick, number>;
25 orders?: readonly { pick: Pick }[];
26}
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare27
28interface Case {
29 id: string;
30 file: string;
31 kind?: string;
32 settler: { agent: string; heldMessage?: string; settleMessage?: string };
33 theirs: { agent: string; version: number; message?: string };
34 base: string[] | null;
35 yours: string[] | null;
36 theirsLines: string[] | null;
37 context?: { before?: string[]; after?: string[] };
38 kept: "yours" | "theirs" | "both" | "rewrote";
39 issue?: string | null;
40}
42const truth = (kept: Case["kept"]): Pick => (kept === "rewrote" ? "agent" : kept);
44function holdOf(c: Case): Hold {
45 return {
46 file: c.file,
47 base: c.base ?? [],
48 yours: c.yours ?? [],
49 theirs: c.theirsLines ?? [],
50 before: c.context?.before ?? [],
51 after: c.context?.after ?? [],
52 yourAgent: c.settler.agent,
53 ...(c.settler.heldMessage ? { yourMessage: c.settler.heldMessage } : {}),
54 theirAgent: c.theirs.agent,
55 ...(c.theirs.message ? { theirMessage: c.theirs.message } : {}),
56 ...(c.issue ? { issue: c.issue } : {}),
57 };
58}
60function flag(args: string[], name: string): string | undefined {
61 const i = args.indexOf(name);
62 return i === -1 ? undefined : args[i + 1];
63}
65const args = process.argv.slice(2);
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare66const via = flag(args, "--via") ?? "workers-ai";
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare67const cases = (JSON.parse(readFileSync(args[0]!, "utf8")) as Case[]).filter(
68 (c) => c.yours !== null && c.theirsLines !== null,
69);
70const rows: { id: string; truth: Pick; verdict: Verdict; right: boolean }[] = [];
71for (const c of cases) {
72 try {
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare73 const model = flag(args, "--model") ? { model: flag(args, "--model")! } : {};
autosettle198Auto-settle (#19): Clef, Cloudflare's decision model on Workers AI, as a settler. Clef takes Jev's System One request, so clef.ts sends jev.ts's own questions through the local Worker's new /system-one route, with the same code checks before and after. score.ts and settle-one.ts take --via clef (--model clef or clef-flash). Six local holds: 6 of 6 right, 0.4 to 0.6 s each.Compare74 const verdict: Verdict =
75 via === "jev"
76 ? await ask(holdOf(c), model)
77 : via === "clef"
78 ? await askClef(holdOf(c), { model: (model.model as "clef" | "clef-flash") ?? "clef" })
79 : await askWorkersAi(holdOf(c), model);
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare80 const t = truth(c.kept);
81 rows.push({ id: c.id, truth: t, verdict, right: verdict.pick === t });
82 console.log(
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare83 `${verdict.pick === t ? "agree" : "DIFFER"} ${c.id}: agent ${t}, model ${verdict.pick} ${verdict.confidence.toFixed(2)} (${verdict.ms.toFixed(0)} ms)`,
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare84 );
85 } catch (e) {
86 console.log(`error ${c.id}: ${(e as Error).message}`);
87 }
88}
90const mean = (xs: number[]) => (xs.length === 0 ? Number.NaN : xs.reduce((a, b) => a + b, 0) / xs.length);
91const right = rows.filter((r) => r.right);
92const wrong = rows.filter((r) => !r.right);
93const ms = rows.map((r) => r.verdict.ms).sort((a, b) => a - b);
94const tokens = rows.map((r) => r.verdict.inputTokens);
95const at = (threshold: number) => {
96 const sure = rows.filter((r) => r.verdict.confidence >= threshold);
97 return { threshold, settled: sure.length, agreed: sure.filter((r) => r.right).length };
98};
99const report = {
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare100 via,
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare101 model: rows[0]?.verdict.model,
102 cases: rows.length,
103 skipped: cases.length - rows.length,
104 agreed: right.length,
105 confidenceWhenRight: mean(right.map((r) => r.verdict.confidence)),
106 confidenceWhenWrong: mean(wrong.map((r) => r.verdict.confidence)),
107 thresholds: [0.3, 0.5, 0.6, 0.7, 0.8, 0.9].map(at),
108 confusion: Object.fromEntries(
109 PICKS.map((t) => [
110 t,
111 Object.fromEntries(PICKS.map((p) => [p, rows.filter((r) => r.truth === t && r.verdict.pick === p).length])),
112 ]),
113 ),
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare114 ordersDisagreed: rows.filter((r) => r.verdict.orders && r.verdict.orders[0]!.pick !== r.verdict.orders[1]!.pick)
115 .length,
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare116 latencyMs: { median: ms[Math.floor(ms.length / 2)], max: ms[ms.length - 1], mean: mean(ms) },
117 inputTokensMean: mean(tokens),
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare118 ...(via === "jev" ? { dollarsPerCall: dollars(mean(tokens)) } : {}),
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare119 rows: rows.map((r) => ({
120 id: r.id,
121 agent: r.truth,
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare122 model: r.verdict.pick,
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare123 confidence: r.verdict.confidence,
124 probabilities: r.verdict.probabilities,
autosettle191Auto-settle (#19): a Workers AI settler. scripts/autosettle/workers-ai is a Worker (wrangler dev --port 8845) that asks Llama 3.3 70B, in JSON mode, for one of keep yours, keep theirs, keep both or needs an agent, plus a confidence and a one-line reason. settle-one and score use it by default (--via jev for Jev). On the commonmark hold (nesting 64 vs 1000) it picks needs an agent, 0.90, in 2.5 s.Compare125 orders: r.verdict.orders?.map((o) => o.pick),
126 reason: r.verdict.reason,
autosettle189Jev auto-settle prototype, step 1 (#19): scripts/autosettle asks Jev to pick keep yours, theirs, both, or needs an agent for each marker block, and scores it against past settles. Local scripts only; reads JEV_API_KEY, never prints it.Compare127 ms: Math.round(r.verdict.ms),
128 })),
129};
130const out = flag(args, "--out");
131if (out) writeFileSync(out, JSON.stringify(report, null, "\t"));
132const { rows: _, ...summary } = report;
133console.log(JSON.stringify(summary, null, "\t"));