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. Version 202 of shared· autosettle· Oct 15 (2026-10-15 01:31 UTC) · Not checked
Version 201 · Files at version 202
1 file, 90 lines added, 1 removed.
--- a/client/src/publish-commands.ts
+++ b/client/src/publish-commands.ts
@@ -293,6 +293,7 @@
293 293 waitSeconds: number, 294 294 skippedCheck: boolean, 295 295 leftOut: LeftOut[], 296 + autoSettled = false, 296 297 ): Promise<Output> { 297 298 const recorded = await recordFolder(root, api, false, meantBinary(args)); 298 299 leftOut.push(...recorded.leftOut); @@ -458,8 +459,73 @@
458 459 const real = collisions.filter((c) => !isLocalOnly(c.file)); 459 460 const twice = real.filter((c) => c.kind === "duplicate"); 460 461 const newer = real.filter((c) => c.kind !== "duplicate"); 461 − // The server's first opinion on each collision (#19), when it runs AUTOSETTLE. Advice only: the agent settles.
462 + // The server's first opinion on each collision (#19), when it runs AUTOSETTLE. 462 463 const advice = answer.advice ?? []; 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); 467 + const pulled = await runSync({ positionals: [], flags: new Map() }, env); 468 + const done: string[] = []; 469 + for (const [file, a] of plan) { 470 + const path = absolute(root, file); 471 + const text = readText(path); 473 + text === null || text === undefined ? null : settleText(text, a.pick as "yours" | "theirs" | "both"); 474 + if (!settled) continue; 475 + if (settled.blocks > 0) { 476 + writeFileAtomic(path, settled.text); 480 + // No marker block: the pull merged the lines itself. That counts when the file already holds the 481 + // advised side's lines (keep both: both sides'). 482 + const lines = new Set(text!.split(/\r?\n/).map((l) => l.trim())); 483 + const sides = collisions 484 + .filter((c) => c.file === file) 486 + ...(a.pick !== "theirs" ? [c.yours.text] : []), 487 + ...(a.pick !== "yours" ? [c.theirs.text] : []), 489 + const wanted = sides.flatMap((t) => t.split(/\r?\n/).map((l) => l.trim())).filter((l) => l !== ""); 490 + if (wanted.length > 0 && wanted.every((l) => lines.has(l))) done.push(file); 492 + const left = [...plan.keys()].filter((f) => !done.includes(f)); 493 + if (left.length > 0) 499 + `Not pushed: the server advised settling ${left.join(", ")}, but the pull left no marker block there. Settle as the pull says, then push again.`, 501 + json: { collisions, advice, autosettle: { pulled: true, settled: done, left } }, 503 + const why = [...plan].map(([file, a]) => `${file}: kept ${a.pick} (${a.reason})`).join("; "); 504 + const again = await publishSteps( 510 + `${message}\n\nSettled automatically (abso 19): ${why}`, 521 + `Held: ${plural(collisions.length, "collision")} with work pushed since your last pull. Settled automatically, as the server advised:`, 522 + ...[...plan].map(([file, a]) => ` ${file}: ${adviceWords(a)}`), 524 + "Check what was kept with abso show <version>:<file>; to change it, edit the file and push. ABSO_AUTOSETTLE=off settles nothing by itself.", 526 + json: { ...(again.json as object), autosettled: Object.fromEntries(plan) }, 464 530 exit: EXIT.refused, @@ -511,6 +577,29 @@
511 577 return `${what} (${how}): ${a.reason}`; 581 + * What to settle by itself (#19), file by file, or null to leave it to the agent: every collision a lines collision 582 + * the server advised keeping a side of (it advises a side only at or above its threshold), each file's advice the 583 + * same, nothing still queued or local-only, and ABSO_AUTOSETTLE not "off". 586 + collisions: readonly Collision[], 587 + advice: readonly (Advice | null)[], 589 + ): Map<string, Advice> | null { 590 + if (fromEnv(env.env, "AUTOSETTLE") === "off" || collisions.length === 0) return null; 591 + const plan = new Map<string, Advice>(); 592 + for (const [i, c] of collisions.entries()) { 593 + const a = advice[i]; 594 + if ((c.kind ?? "lines") !== "lines" || c.untouched || c.marked || c.theirs.queued !== undefined) return null; 595 + if (isLocalOnly(c.file) || !a || a.pick === "agent") return null; 596 + const before = plan.get(c.file); 597 + if (before && before.pick !== a.pick) return null; 598 + if (!before || a.confidence < before.confidence) plan.set(c.file, a); 514 603 export async function runSync(args: Parsed, env: Env): Promise<Output> { 515 604 const { root, api } = open(env); 516 605 const recorded = await recordFolder(root, api);