- MCP
- show on this site's /mcp
- CLI
- abso show 195 --json
- JSON
- /christopher/abso-core/versions/195?format=json
Auto-settle (#19): score it on project abso's own past settles. extract.ts now finds each collided region with git's line diff (before theirs, theirs, the settle's result) instead of one span over the whole file. rules.ts turns down a keep-both that holds one statement in two versions (an import from the same module with different names): on abso's history the model picked keep both there at 1.00, which wouldn't have compiled.
of shared·autosettle··Not checked
Version 194 · Files at version 195
2 files, 133 lines added, 65 removed.
--- a/scripts/autosettle/extract.ts
+++ b/scripts/autosettle/extract.ts
@@ -3,13 +3,16 @@
6−// Each settled collision gives: the file before theirs (their version - 1, the
7−// best guess at what both started from), theirs, and the settle's result.
8−// The held agent's own lines are only recoverable from the result when it kept
9−// yours or both; otherwise "yours" is null and score.ts skips the case.
1011
12−import { writeFileSync } from "node:fs";
1316
@@ -35,15 +38,14 @@
38−const review = JSON.parse(abso("review", "--since", since, "--json")) as {
39− changes: {
40− agent?: string;
41− author?: string;
42− message?: string;
43− settled: Settled[];
44− versions?: { version: number; message: string }[];
45− }[];
46−};
4850for (const c of review.changes) for (const v of c.versions ?? []) messages.set(v.version, v.message);
@@ -58,59 +60,115 @@
6062
61−/** The span where `a` and `b` differ, by common prefix and suffix. */
62−function hunk(a: string[], b: string[]): { start: number; aEnd: number; bEnd: number } {
63− let start = 0;
64− while (start < a.length && start < b.length && a[start] === b[start]) start++;
65− let tail = 0;
66− while (tail < a.length - start && tail < b.length - start && a[a.length - 1 - tail] === b[b.length - 1 - tail])
67− tail++;
68− return { start, aEnd: a.length - tail, bEnd: b.length - tail };
64+ /** 0-based start and length on each side; a length of 0 is an insertion before (or deletion at) start. */
7070
71−/** The lines of `r` between the context above and below a hunk of `t`, found by a few anchor lines. */
72−function regionIn(r: string[], t: string[], start: number, end: number): string[] | null {
73− const above = t.slice(Math.max(0, start - 3), start);
74− const below = t.slice(end, end + 3);
75− const find = (needle: string[], from: number) => {
76− if (needle.length === 0) return -1;
77− for (let i = from; i + needle.length <= r.length; i++) if (needle.every((l, j) => r[i + j] === l)) return i;
78− return -2;
79− };
80− const a = find(above, 0);
81− const from = above.length === 0 ? 0 : a < 0 ? -1 : a + above.length;
82− if (from < 0) return null;
83− const b = find(below, from);
84− const to = below.length === 0 ? r.length : b < 0 ? -1 : b;
85− return to < 0 ? null : r.slice(from, to);
78+ text = execFileSync("git", ["diff", "--no-index", "-U0", "--no-color", join(dir, "a"), join(dir, "b")], {
87100
106+
108+ * The collisions a settle went through in one file: each of their hunks (before to theirs) that the
114+ const touches = (h: Hunk, g: Hunk) => g.aStart <= h.bStart + h.bLen && h.bStart <= g.aStart + g.aLen;
131+ context: { before: theirs.slice(Math.max(0, tStart - 15), tStart), after: theirs.slice(tEnd, tEnd + 15) },
136+
89−for (const c of review.changes) {
91− const before = fileAt(s.theirs.version - 1, s.file);
92− const theirs = fileAt(s.theirs.version, s.file);
93− const result = fileAt(s.version, s.file);
152+ // Marker blocks the settler changed, in file order; a block where it kept theirs left no trace to find.
95− let base: string[] | null = null;
96− let theirsLines: string[] | null = null;
97− let region: string[] | null = null;
98− let context = { before: [] as string[], after: [] as string[] };
99− if (before && theirs && result) {
100− const h = hunk(before, theirs);
101− base = before.slice(h.start, h.aEnd);
102− theirsLines = theirs.slice(h.start, h.bEnd);
103− context = { before: theirs.slice(Math.max(0, h.start - 15), h.start), after: theirs.slice(h.bEnd, h.bEnd + 15) };
104− region = regionIn(result, theirs, h.start, h.bEnd);
105− if (region === null) notes.push("couldn't find the region in the settled file");
106− if (theirsLines.length > 80) notes.push(`their change spans ${theirsLines.length} lines`);
107− } else notes.push("a version of the file couldn't be read");
160+ else if (!r) notes.push(`found ${found.length} changed regions for ${changed.length} settled blocks`);
162+ notes.push(`found ${found.length} changed regions for ${changed.length} settled blocks: the pairing may be off`);
109− if (region && s.kept === "yours") yours = region;
110− else if (region && theirsLines && s.kept === "both") yours = region.slice(0, region.length - theirsLines.length);
111− else notes.push(`yours isn't recoverable from the result when the agent kept ${s.kept}`);
167+ if (tail.join("\n") === r.theirs.join("\n")) yours = r.result.slice(0, r.result.length - r.theirs.length);
169+ } else if (r) notes.push(`yours isn't recoverable from the result when the agent kept ${s.kept}`);
113− id: `${s.version}-${s.file}`,
@@ -120,16 +178,16 @@
122180 theirs: { agent: s.theirs.agent, version: s.theirs.version, message: messageOf(s.theirs.version) },
123− base,
125− theirsLines,
126− context,
127− result: region,
131− });
132− }
--- a/scripts/autosettle/rules.ts
+++ b/scripts/autosettle/rules.ts
@@ -31,5 +31,15 @@
34− return clash ? `keeping both would set ${clash} twice` : undefined;
35+ // Two versions of one statement, such as an import from the same module with a different list of names:
37+ const names = (lines: readonly string[]) => new Set(lines.join(" ").match(/[A-Za-z_$][\w$]{2,}/g) ?? []);