{"version":204,"agent":"autosettle","message":"Auto-settle switch (abso 19): on advises, act also has the client settle\n\nAUTOSETTLE=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).","time":1792028481422,"timeIso":"2026-10-15T01:41:21.422Z","changes":6,"change":3450,"files":["client/src/api-answers.ts","client/src/publish-commands.ts","server/src/env.ts","server/src/router.ts","worker/project/autosettle.ts","worker/project/test/autosettle.test.ts"],"draft":null,"diff":[{"path":"client/src/api-answers.ts","added":8,"removed":1,"diff":"--- a/client/src/api-answers.ts\n+++ b/client/src/api-answers.ts\n@@ -88,7 +88,14 @@\n \t  }\n \t/** With the merge queue on (#39): queued, not landed yet; `ahead` publishes wait in front of it. */\n \t| { ok: true; queued: number; position: number; ahead: number; changes: number; settled?: readonly Settled[] }\n-\t| { ok: false; collisions: readonly Collision[]; reason?: string; advice?: readonly (Advice | null)[] };\n+\t| {\n+\t\t\tok: false;\n+\t\t\tcollisions: readonly Collision[];\n+\t\t\treason?: string;\n+\t\t\tadvice?: readonly (Advice | null)[];\n+\t\t\t/** The server runs AUTOSETTLE=act: settle the collisions it advised a side of, and push again (#19). */\n+\t\t\tsettle?: boolean;\n+\t  };\n /**\n  * A server's first opinion on one collision of a held push (#19), when it runs AUTOSETTLE: which settle fits,\n  * how sure, and why. `by`: rule (code decided), model (Workers AI), turned down (the model's pick would break"},{"path":"client/src/publish-commands.ts","added":3,"removed":2,"diff":"--- a/client/src/publish-commands.ts\n+++ b/client/src/publish-commands.ts\n@@ -461,8 +461,9 @@\n \tconst newer = real.filter((c) => c.kind !== \"duplicate\");\n \t// The server's first opinion on each collision (#19), when it runs AUTOSETTLE.\n \tconst advice = answer.advice ?? [];\n-\t// When it says to keep a side of every collision, settle them here and push again (ABSO_AUTOSETTLE=off stops it).\n-\tconst plan = autoSettled ? null : autoPlan(collisions, advice, env);\n+\t// When the server says to settle (its AUTOSETTLE=act) and to keep a side of every collision, settle them here and\n+\t// push again (ABSO_AUTOSETTLE=off stops it).\n+\tconst plan = autoSettled || answer.settle !== true ? null : autoPlan(collisions, advice, env);\n \tif (plan) {\n \t\tconst pulled = await runSync({ positionals: [], flags: new Map() }, env);\n \t\tconst done: string[] = [];"},{"path":"server/src/env.ts","added":1,"removed":1,"diff":"--- a/server/src/env.ts\n+++ b/server/src/env.ts\n@@ -24,7 +24,7 @@\n \t/** Per-agent keys: \"on\" with KEY_HMAC_SECRET set. */\n \tAGENT_KEYS?: string;\n \tKEY_HMAC_SECRET?: string;\n-\t/** \"on\" gives a held push a first opinion on each collision from Workers AI (#19); needs the AI binding. */\n+\t/** \"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. */\n \tAUTOSETTLE?: string;\n \t/** Which model advises: clef (the default), clef-flash, or a Workers AI text model's id. */\n \tAUTOSETTLE_MODEL?: string;"},{"path":"server/src/router.ts","added":2,"removed":18,"diff":"--- a/server/src/router.ts\n+++ b/server/src/router.ts\n@@ -18,7 +18,7 @@\n // ABSO_TOKEN set, the server refuses every call.\n \n import { type Answer, validName } from \"../../worker/project/http.ts\";\n-import { adviseHeld } from \"./autosettle.ts\";\n+import { withAdvice } from \"./autosettle.ts\";\n import { artifactsOf, type Env, secret } from \"./env.ts\";\n import type { IssuesAuth, issuesFetch } from \"./issues-entry.ts\";\n import { isAgentKey, type KeyRole, keyAllows, keysEnabled, timingSame } from \"./keys.ts\";\n@@ -270,23 +270,7 @@\n \t\t\trequest.headers.get(\"Idempotency-Key\") ?? undefined,\n \t\t)) as unknown as Answer;\n \t\t// A held push gets a first opinion on each collision (#19), when the server is set up for it.\n-\t\tif (op === \"publish\" && env.AUTOSETTLE === \"on\" && env.AI && agent) {\n-\t\t\tconst held = a.body as { ok?: boolean; collisions?: Parameters<typeof adviseHeld>[1] };\n-\t\t\tif (held.ok === false && held.collisions && held.collisions.length > 0) {\n-\t\t\t\tconst message = String((body as { message?: unknown } | undefined)?.message ?? \"\");\n-\t\t\t\tconst advice = await adviseHeld(\n-\t\t\t\t\tenv.AI,\n-\t\t\t\t\theld.collisions,\n-\t\t\t\t\t{ agent, message },\n-\t\t\t\t\t{\n-\t\t\t\t\t\t...(env.AUTOSETTLE_MODEL ? { model: env.AUTOSETTLE_MODEL } : {}),\n-\t\t\t\t\t\t...(Number(env.AUTOSETTLE_AT) > 0 ? { at: Number(env.AUTOSETTLE_AT) } : {}),\n-\t\t\t\t\t},\n-\t\t\t\t);\n-\t\t\t\tif (advice.some((x) => x !== null)) return json(a.status, { ...held, advice });\n-\t\t\t}\n-\t\t}\n-\t\treturn json(a.status, a.body);\n+\t\treturn json(a.status, await withAdvice(env, op, agent, body, a.body));\n \t} catch (e) {\n \t\tconst error = `the project object failed: ${e instanceof Error ? e.message : String(e)}`;\n \t\tconsole.error(`${project} ${op ?? top}: ${error}`);"},{"path":"worker/project/autosettle.ts","added":40,"removed":1,"diff":"--- a/worker/project/autosettle.ts\n+++ b/worker/project/autosettle.ts\n@@ -1,6 +1,6 @@\n // A first opinion on a held push (#19), shared by the open server and the platform: for each collision, which of abso's\n // settle choices fits, from Workers AI, with checks in code before and after.\n-// Off unless AUTOSETTLE is \"on\" and the Worker has an AI binding. The model\n+// Off unless AUTOSETTLE is \"on\" (advice) or \"act\" (the client settles) and the Worker has an AI binding. The model\n // picks one of four words; it never writes code.\n \n /** abso's settle choices, plus a hand edit by an agent. */\n@@ -357,3 +357,42 @@\n \t\t}),\n \t);\n }\n+\n+/** The switch as a Worker's env carries it: AUTOSETTLE \"on\" advises, \"act\" also has the client settle; else off. */\n+export interface AutosettleEnv {\n+\treadonly AUTOSETTLE?: string;\n+\treadonly AUTOSETTLE_MODEL?: string;\n+\treadonly AUTOSETTLE_AT?: string | number;\n+\treadonly AI?: Ai;\n+}\n+\n+/**\n+ * The one hook for a server (#19): a publish answer with the first opinion added when the push was held and the\n+ * switch is on, or the answer as it was. Under \"act\" it also says `settle: true`, and the client settles the\n+ * collisions advised to a side and pushes again; under \"on\" the client only shows the advice.\n+ */\n+export async function withAdvice(\n+\tenv: AutosettleEnv,\n+\top: string | undefined,\n+\tagent: string | undefined,\n+\trequest: unknown,\n+\tanswer: unknown,\n+): Promise<unknown> {\n+\tconst mode = env.AUTOSETTLE;\n+\tif (op !== \"publish\" || (mode !== \"on\" && mode !== \"act\") || !env.AI || !agent) return answer;\n+\tconst held = answer as { ok?: boolean; collisions?: readonly HeldCollision[] } | null;\n+\tif (held?.ok !== false || !held.collisions || held.collisions.length === 0) return answer;\n+\tconst message = String((request as { message?: unknown } | null | undefined)?.message ?? \"\");\n+\tconst at = Number(env.AUTOSETTLE_AT);\n+\tconst advice = await adviseHeld(\n+\t\tenv.AI,\n+\t\theld.collisions,\n+\t\t{ agent, message },\n+\t\t{\n+\t\t\t...(env.AUTOSETTLE_MODEL ? { model: env.AUTOSETTLE_MODEL } : {}),\n+\t\t\t...(at > 0 ? { at } : {}),\n+\t\t},\n+\t);\n+\tif (!advice.some((x) => x !== null)) return answer;\n+\treturn { ...held, advice, ...(mode === \"act\" ? { settle: true } : {}) };\n+}"},{"path":"worker/project/test/autosettle.test.ts","added":20,"removed":1,"diff":"--- a/worker/project/test/autosettle.test.ts\n+++ b/worker/project/test/autosettle.test.ts\n@@ -1,6 +1,6 @@\n import assert from \"node:assert/strict\";\n import { test } from \"node:test\";\n-import { type Ai, adviseHeld, refused, ruled } from \"../autosettle.ts\";\n+import { type Ai, adviseHeld, refused, ruled, withAdvice } from \"../autosettle.ts\";\n \n /**\n  * A stand-in for Workers AI that always leans to `pick`: a System One answer for Clef (`top` on `pick`, the rest\n@@ -93,3 +93,22 @@\n \tconst [a] = await adviseHeld(ai, [held(\"a = 1\", \"b = 2\")], me);\n \tassert.equal(a, null);\n });\n+\n+test(\"the switch: off leaves the answer alone, on adds advice, act also tells the client to settle\", async () => {\n+\tconst answer = { ok: false, collisions: [routes] };\n+\tconst request = { message: \"my reason\" };\n+\tassert.equal(await withAdvice({ AI: fakeAi(\"both\") }, \"publish\", \"me\", request, answer), answer);\n+\tassert.equal(await withAdvice({ AUTOSETTLE: \"on\", AI: fakeAi(\"both\") }, \"draft\", \"me\", request, answer), answer);\n+\tconst on = (await withAdvice({ AUTOSETTLE: \"on\", AI: fakeAi(\"both\") }, \"publish\", \"me\", request, answer)) as {\n+\t\tadvice?: unknown[];\n+\t\tsettle?: boolean;\n+\t};\n+\tassert.equal(on.advice?.length, 1);\n+\tassert.equal(on.settle, undefined);\n+\tconst act = (await withAdvice({ AUTOSETTLE: \"act\", AI: fakeAi(\"both\") }, \"publish\", \"me\", request, answer)) as {\n+\t\tsettle?: boolean;\n+\t};\n+\tassert.equal(act.settle, true);\n+\tconst ok = { ok: true, version: 4 };\n+\tassert.equal(await withAdvice({ AUTOSETTLE: \"act\", AI: fakeAi(\"both\") }, \"publish\", \"me\", request, ok), ok);\n+});"}],"ci":null}