AUTOSETTLE=on now only adds advice to a held push; AUTOSETTLE=act adds settle: true, and the client settles the collisions advised a side only then (ABSO_AUTOSETTLE=off still stops it). The whole server hook is one function, withAdvice(env, op, agent, request, answer), so a Worker calls it in one line: return json(a.status, await withAdvice(env, op, agent, body, a.body)). Tested: the switch test, held-push tests, and the local demo under on (held with advice) and act (settled and pushed).
- MCP
- show on this site's /mcp
- CLI
- abso show 204 --json
- JSON
- /christopher/abso-core/versions/204?format=json
Auto-settle switch (abso 19): on advises, act also has the client settle
of shared·autosettle··Not checked
Version 203 · Files at version 204
6 files, 74 lines added, 24 removed.
--- a/client/src/api-answers.ts
+++ b/client/src/api-answers.ts
@@ -88,7 +88,14 @@
8989 /** With the merge queue on (#39): queued, not landed yet; `ahead` publishes wait in front of it. */
9090 | { ok: true; queued: number; position: number; ahead: number; changes: number; settled?: readonly Settled[] }
91− | { ok: false; collisions: readonly Collision[]; reason?: string; advice?: readonly (Advice | null)[] };
96+ /** The server runs AUTOSETTLE=act: settle the collisions it advised a side of, and push again (#19). */
93100 * A server's first opinion on one collision of a held push (#19), when it runs AUTOSETTLE: which settle fits,
94101 * how sure, and why. `by`: rule (code decided), model (Workers AI), turned down (the model's pick would break
--- a/client/src/publish-commands.ts
+++ b/client/src/publish-commands.ts
@@ -461,8 +461,9 @@
464− // When it says to keep a side of every collision, settle them here and push again (ABSO_AUTOSETTLE=off stops it).
465− const plan = autoSettled ? null : autoPlan(collisions, advice, env);
464+ // When the server says to settle (its AUTOSETTLE=act) and to keep a side of every collision, settle them here and
--- a/server/src/env.ts
+++ b/server/src/env.ts
@@ -24,7 +24,7 @@
27− /** "on" gives a held push a first opinion on each collision from Workers AI (#19); needs the AI binding. */
27+ /** "on" gives a held push a first opinion on each collision from Workers AI (#19); "act" also has the client settle the ones advised a side. Needs the AI binding. */
--- a/server/src/router.ts
+++ b/server/src/router.ts
@@ -18,7 +18,7 @@
1919
21−import { adviseHeld } from "./autosettle.ts";
@@ -270,23 +270,7 @@
272272 // A held push gets a first opinion on each collision (#19), when the server is set up for it.
273− if (op === "publish" && env.AUTOSETTLE === "on" && env.AI && agent) {
274− const held = a.body as { ok?: boolean; collisions?: Parameters<typeof adviseHeld>[1] };
275− if (held.ok === false && held.collisions && held.collisions.length > 0) {
276− const message = String((body as { message?: unknown } | undefined)?.message ?? "");
277− const advice = await adviseHeld(
278− env.AI,
279− held.collisions,
280− { agent, message },
281− {
282− ...(env.AUTOSETTLE_MODEL ? { model: env.AUTOSETTLE_MODEL } : {}),
283− ...(Number(env.AUTOSETTLE_AT) > 0 ? { at: Number(env.AUTOSETTLE_AT) } : {}),
284− },
285− );
286− if (advice.some((x) => x !== null)) return json(a.status, { ...held, advice });
287− }
288− }
289− return json(a.status, a.body);
--- a/worker/project/autosettle.ts
+++ b/worker/project/autosettle.ts
@@ -1,6 +1,6 @@
11// A first opinion on a held push (#19), shared by the open server and the platform: for each collision, which of abso's
3−// Off unless AUTOSETTLE is "on" and the Worker has an AI binding. The model
3+// Off unless AUTOSETTLE is "on" (advice) or "act" (the client settles) and the Worker has an AI binding. The model
55
@@ -357,3 +357,42 @@
360+
361+/** The switch as a Worker's env carries it: AUTOSETTLE "on" advises, "act" also has the client settle; else off. */
368+
370+ * The one hook for a server (#19): a publish answer with the first opinion added when the push was held and the
371+ * switch is on, or the answer as it was. Under "act" it also says `settle: true`, and the client settles the
--- a/worker/project/test/autosettle.test.ts
+++ b/worker/project/test/autosettle.test.ts
@@ -1,6 +1,6 @@
3−import { type Ai, adviseHeld, refused, ruled } from "../autosettle.ts";
44
66 * A stand-in for Workers AI that always leans to `pick`: a System One answer for Clef (`top` on `pick`, the rest
@@ -93,3 +93,22 @@
96+
97+test("the switch: off leaves the answer alone, on adds advice, act also tells the client to settle", async () => {
100+ assert.equal(await withAdvice({ AI: fakeAi("both") }, "publish", "me", request, answer), answer);
101+ assert.equal(await withAdvice({ AUTOSETTLE: "on", AI: fakeAi("both") }, "draft", "me", request, answer), answer);
102+ const on = (await withAdvice({ AUTOSETTLE: "on", AI: fakeAi("both") }, "publish", "me", request, answer)) as {
108+ const act = (await withAdvice({ AUTOSETTLE: "act", AI: fakeAi("both") }, "publish", "me", request, answer)) as {
113+ assert.equal(await withAdvice({ AUTOSETTLE: "act", AI: fakeAi("both") }, "publish", "me", request, ok), ok);