{"version":202,"agent":"autosettle","message":"Auto-settle (#19): the client settles a held push by itself when the server advises keeping a side of every collision (Clef at 0.5 or more, or a check in code). It pulls, settles each file as advised (or takes the pull's own word-by-word merge when the file already holds the advised side), pushes again with what was kept and why in the message, and says how to check or change it. ABSO_AUTOSETTLE=off settles nothing by itself. Tried on a local open server: a timeout where theirs had yours settled to theirs by a code check; a typo both fixed settled to yours by Clef at 0.81 and pushed; a nesting limit set two ways stayed held for an agent.","time":1792027876716,"timeIso":"2026-10-15T01:31:16.716Z","changes":5,"change":3424,"files":["client/src/publish-commands.ts"],"draft":null,"diff":[{"path":"client/src/publish-commands.ts","added":90,"removed":1,"diff":"--- a/client/src/publish-commands.ts\n+++ b/client/src/publish-commands.ts\n@@ -293,6 +293,7 @@\n \twaitSeconds: number,\n \tskippedCheck: boolean,\n \tleftOut: LeftOut[],\n+\tautoSettled = false,\n ): Promise<Output> {\n \tconst recorded = await recordFolder(root, api, false, meantBinary(args));\n \tleftOut.push(...recorded.leftOut);\n@@ -458,8 +459,73 @@\n \tconst real = collisions.filter((c) => !isLocalOnly(c.file));\n \tconst twice = real.filter((c) => c.kind === \"duplicate\");\n \tconst newer = real.filter((c) => c.kind !== \"duplicate\");\n-\t// The server's first opinion on each collision (#19), when it runs AUTOSETTLE. Advice only: the agent settles.\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+\tif (plan) {\n+\t\tconst pulled = await runSync({ positionals: [], flags: new Map() }, env);\n+\t\tconst done: string[] = [];\n+\t\tfor (const [file, a] of plan) {\n+\t\t\tconst path = absolute(root, file);\n+\t\t\tconst text = readText(path);\n+\t\t\tconst settled =\n+\t\t\t\ttext === null || text === undefined ? null : settleText(text, a.pick as \"yours\" | \"theirs\" | \"both\");\n+\t\t\tif (!settled) continue;\n+\t\t\tif (settled.blocks > 0) {\n+\t\t\t\twriteFileAtomic(path, settled.text);\n+\t\t\t\tdone.push(file);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\t// No marker block: the pull merged the lines itself. That counts when the file already holds the\n+\t\t\t// advised side's lines (keep both: both sides').\n+\t\t\tconst lines = new Set(text!.split(/\\r?\\n/).map((l) => l.trim()));\n+\t\t\tconst sides = collisions\n+\t\t\t\t.filter((c) => c.file === file)\n+\t\t\t\t.flatMap((c) => [\n+\t\t\t\t\t...(a.pick !== \"theirs\" ? [c.yours.text] : []),\n+\t\t\t\t\t...(a.pick !== \"yours\" ? [c.theirs.text] : []),\n+\t\t\t\t]);\n+\t\t\tconst wanted = sides.flatMap((t) => t.split(/\\r?\\n/).map((l) => l.trim())).filter((l) => l !== \"\");\n+\t\t\tif (wanted.length > 0 && wanted.every((l) => lines.has(l))) done.push(file);\n+\t\t}\n+\t\tconst left = [...plan.keys()].filter((f) => !done.includes(f));\n+\t\tif (left.length > 0)\n+\t\t\treturn {\n+\t\t\t\texit: EXIT.refused,\n+\t\t\t\ttext: [\n+\t\t\t\t\t...pre,\n+\t\t\t\t\tpulled.text,\n+\t\t\t\t\t`Not pushed: the server advised settling ${left.join(\", \")}, but the pull left no marker block there. Settle as the pull says, then push again.`,\n+\t\t\t\t].join(\"\\n\"),\n+\t\t\t\tjson: { collisions, advice, autosettle: { pulled: true, settled: done, left } },\n+\t\t\t};\n+\t\tconst why = [...plan].map(([file, a]) => `${file}: kept ${a.pick} (${a.reason})`).join(\"; \");\n+\t\tconst again = await publishSteps(\n+\t\t\targs,\n+\t\t\tenv,\n+\t\t\troot,\n+\t\t\tconfig,\n+\t\t\tapi,\n+\t\t\t`${message}\\n\\nSettled automatically (abso 19): ${why}`,\n+\t\t\tchecked,\n+\t\t\twaitSeconds,\n+\t\t\tskippedCheck,\n+\t\t\tleftOut,\n+\t\t\ttrue,\n+\t\t);\n+\t\treturn {\n+\t\t\t...again,\n+\t\t\ttext: [\n+\t\t\t\t...pre,\n+\t\t\t\t`Held: ${plural(collisions.length, \"collision\")} with work pushed since your last pull. Settled automatically, as the server advised:`,\n+\t\t\t\t...[...plan].map(([file, a]) => `  ${file}: ${adviceWords(a)}`),\n+\t\t\t\tagain.text,\n+\t\t\t\t\"Check what was kept with abso show <version>:<file>; to change it, edit the file and push. ABSO_AUTOSETTLE=off settles nothing by itself.\",\n+\t\t\t].join(\"\\n\"),\n+\t\t\tjson: { ...(again.json as object), autosettled: Object.fromEntries(plan) },\n+\t\t};\n+\t}\n \treturn {\n \t\texit: EXIT.refused,\n \t\ttext: [\n@@ -511,6 +577,29 @@\n \treturn `${what} (${how}): ${a.reason}`;\n }\n \n+/**\n+ * What to settle by itself (#19), file by file, or null to leave it to the agent: every collision a lines collision\n+ * the server advised keeping a side of (it advises a side only at or above its threshold), each file's advice the\n+ * same, nothing still queued or local-only, and ABSO_AUTOSETTLE not \"off\".\n+ */\n+function autoPlan(\n+\tcollisions: readonly Collision[],\n+\tadvice: readonly (Advice | null)[],\n+\tenv: Env,\n+): Map<string, Advice> | null {\n+\tif (fromEnv(env.env, \"AUTOSETTLE\") === \"off\" || collisions.length === 0) return null;\n+\tconst plan = new Map<string, Advice>();\n+\tfor (const [i, c] of collisions.entries()) {\n+\t\tconst a = advice[i];\n+\t\tif ((c.kind ?? \"lines\") !== \"lines\" || c.untouched || c.marked || c.theirs.queued !== undefined) return null;\n+\t\tif (isLocalOnly(c.file) || !a || a.pick === \"agent\") return null;\n+\t\tconst before = plan.get(c.file);\n+\t\tif (before && before.pick !== a.pick) return null;\n+\t\tif (!before || a.confidence < before.confidence) plan.set(c.file, a);\n+\t}\n+\treturn plan;\n+}\n+\n export async function runSync(args: Parsed, env: Env): Promise<Output> {\n \tconst { root, api } = open(env);\n \tconst recorded = await recordFolder(root, api);"}],"ci":null}