- MCP
- show on this site's /mcp
- CLI
- abso show 191 --json
- JSON
- /christopher/abso-core/versions/191?format=json
Auto-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.
of shared·autosettle··Not checked
Version 190 · Files at version 191
6 files, 203 lines added, 17 removed.
--- a/scripts/autosettle/extract.ts
+++ b/scripts/autosettle/extract.ts
@@ -85,7 +85,7 @@
8787
88−const cases = [];
--- a/scripts/autosettle/score.ts
+++ b/scripts/autosettle/score.ts
@@ -1,14 +1,29 @@
1−// Score Jev against how agents really settled past holds (#19).
3−// node scripts/autosettle/score.ts <cases.json> [--out <report.json>] [--model jev-latest]
3+// node scripts/autosettle/score.ts <cases.json> [--via workers-ai|jev] [--model <id>] [--out <report.json>]
7−// both, or rewrote, which counts as "agent": a hand edit). Needs JEV_API_KEY.
810
10−import { ask, dollars, type Hold, PICKS, type Pick, type Verdict } from "./jev.ts";
1114
26+
@@ -47,17 +62,19 @@
4863
56− const verdict = await ask(holdOf(c), { ...(flag(args, "--model") ? { model: flag(args, "--model") } : {}) });
73+ const verdict: Verdict = via === "jev" ? await ask(holdOf(c), model) : await askWorkersAi(holdOf(c), model);
60− `${verdict.pick === t ? "agree" : "DIFFER"} ${c.id}: agent ${t}, Jev ${verdict.pick} ${verdict.confidence.toFixed(2)} (${verdict.ms.toFixed(0)} ms)`,
77+ `${verdict.pick === t ? "agree" : "DIFFER"} ${c.id}: agent ${t}, model ${verdict.pick} ${verdict.confidence.toFixed(2)} (${verdict.ms.toFixed(0)} ms)`,
@@ -74,6 +91,7 @@
@@ -87,18 +105,19 @@
87105 Object.fromEntries(PICKS.map((p) => [p, rows.filter((r) => r.truth === t && r.verdict.pick === p).length])),
90− ordersDisagreed: rows.filter((r) => r.verdict.orders[0]!.pick !== r.verdict.orders[1]!.pick).length,
108+ ordersDisagreed: rows.filter((r) => r.verdict.orders && r.verdict.orders[0]!.pick !== r.verdict.orders[1]!.pick)
93− dollarsPerCall: dollars(mean(tokens)),
97− jev: r.verdict.pick,
100− orders: r.verdict.orders.map((o) => o.pick),
101− signs: r.verdict.signs,
--- a/scripts/autosettle/settle-one.ts
+++ b/scripts/autosettle/settle-one.ts
@@ -1,13 +1,14 @@
1−// Ask Jev how to settle each marker block in one file (#19), the way abso pull
2−// leaves a held push's file. Prints Jev's pick and its probabilities; changes nothing.
4−// node scripts/autosettle/settle-one.ts <file> [--message "<your held push's message>"] [--issue "..."] [--name <path in the project>] [--json]
4+// node scripts/autosettle/settle-one.ts <file> [--via workers-ai|jev] [--model <id>] [--message "<your held push's message>"] [--issue "..."] [--name <path in the project>] [--json]
6−// Needs JEV_API_KEY in the environment.
6+// --via workers-ai (the default) needs workers-ai/ running under wrangler dev; --via jev needs JEV_API_KEY.
77
1112
@@ -57,8 +58,18 @@
61− const v = await ask(h);
68+ `Block ${i + 1} of ${holds.length} in ${h.file}: ${w.pick}, confidence ${w.confidence.toFixed(2)}\n ${w.reason}\n ${w.model}, ${w.ms.toFixed(0)} ms (model ${w.modelMs} ms), ${w.inputTokens} input tokens`,
--- /dev/null
+++ b/scripts/autosettle/workers-ai.ts
@@ -0,0 +1,45 @@
1+// Ask the local auto-settle Worker (workers-ai/, run with wrangler dev) how a hold should be settled (#19).
2+
4+
6+
18+
19+export async function askWorkersAi(h: Hold, opts: { model?: string; url?: string } = {}): Promise<ModelVerdict> {
35+ if (!res.ok || out.error || !out.pick) throw new Error(`Workers AI: ${out.error ?? res.status}`);
--- /dev/null
+++ b/scripts/autosettle/workers-ai/index.ts
@@ -0,0 +1,101 @@
5+// cd scripts/autosettle/workers-ai && npx wrangler dev --port 8845 (the AI binding always runs on Cloudflare)
7+
11+
25+
28+
30+Two agents changed the same lines of one file. Both started from BEFORE. YOURS is what the held agent wrote, for the reason in its push message; THEIRS was pushed first, for the reason in its push message.
32+- "yours": keep YOURS only. YOURS already does what THEIRS meant, or THEIRS is wrong or out of date.
33+- "theirs": keep THEIRS only. THEIRS already does what YOURS meant, or YOURS is wrong or out of date.
34+- "both": keep both unchanged, YOURS then THEIRS. They add separate things that work side by side, with nothing duplicated or contradictory.
35+- "agent": none of those is correct. The sides change the same thing in different ways (such as two different values for one setting), or keeping both would duplicate or contradict, so a correct result needs a hand edit.
36+Give "confidence" from 0 to 1: how likely your pick is the correct settle. Give "reason" as one plain sentence. Do not write code.`;
37+
38+const block = (lines: readonly string[]) => (lines.length === 0 ? "(no lines)" : lines.join("\n"));
39+
63+
73+
77+ const { hold, model = DEFAULT_MODEL } = (await request.json()) as { hold: Hold; model?: string };
89+ const answer = (typeof out.response === "string" ? JSON.parse(out.response) : out.response) as {
98+ return Response.json({ error: (e as Error).message, model, ms: Date.now() - started }, { status: 502 });
--- /dev/null
+++ b/scripts/autosettle/workers-ai/wrangler.jsonc
@@ -0,0 +1,10 @@
1+// The auto-settle prototype's Workers AI caller (#19). Local only: npx wrangler dev from this folder.