{"version":311,"agent":"capacity","message":"Move detection reads the draft's own lines first and lays out no file for an edit with no move (abso 714, piece 3 of Christopher's base fix)\n\n- expressMoves, before a publish, used to lay out every file the draft touched twice: before the draft and after it. It then read each line's deleters, so its cost grew with the files' length, not the change. For a 1470-shaped publish that was worker/src/index.ts's 12k lines, twice.\n- Now it reads the draft's own deleted lines (deletedLines) and written lines (eachInsertedLine) first. A move needs a written line with real content whose text the draft also deleted. With none, as in any edit that only changes lines, it returns before laying out anything.\n- When there may be a move, the files are laid out as before. But a line counts as deleted by the draft from that set of the draft's deleted lines, not from a lookup of each line's deleters. Moves come out the same.\n- Test: worker/project/test/express-moves-early.test.ts, with a host whose views throw if laid out. A line edit and a brackets-only match lay out nothing; a real line written again goes on to the files.\n\nChecks: tsc clean; Biome clean on both files; core tests (worker/project and src): 762 passed, none failed; the 17 move tests pass.\nLab, on abso's Oct 14 tables with abso 1476's disk route, 1470-shaped publish, 38 changed lines: 9,408 statements and 1,438 writes in one transaction of 1.5 s, inside the budget test's 10,600 and 3,280. It was 24,209 statements after piece 2 (6.1 s) and 36,038 before it. Record is unchanged (piece 4).","time":1792200889849,"timeIso":"2026-10-17T01:34:49.849Z","changes":3,"change":5327,"files":["worker/project/express-moves.ts","worker/project/test/express-moves-early.test.ts"],"draft":null,"diff":[{"path":"worker/project/express-moves.ts","added":25,"removed":1,"diff":"--- a/worker/project/express-moves.ts\n+++ b/worker/project/express-moves.ts\n@@ -62,6 +62,29 @@\n \tconst g = host.graph;\n \tconst mine = new Set(draft);\n \tconst text = new MoveLineText(g);\n+\t// The draft's own lines first, before laying out any file (abso 714, piece 3): a move needs a written line with\n+\t// real content whose text the draft also deleted. An edit that only changes lines has none, and laying out its\n+\t// files (12k lines twice for one changed line of worker/src/index.ts) cost the whole publish.\n+\tconst goneIds = new Set<LineId>();\n+\tconst goneTexts = new Set<number>();\n+\tfor (const id of draft)\n+\t\tfor (const line of g.deletedLines(id)) {\n+\t\t\tgoneIds.add(line);\n+\t\t\tgoneTexts.add(text.intern(line));\n+\t\t}\n+\tif (goneTexts.size === 0) return;\n+\tlet moved = false;\n+\tfor (const id of draft) {\n+\t\tfor (const line of g.eachInsertedLine(id)) {\n+\t\t\tconst t = text.intern(line);\n+\t\t\tif (!text.plain[t] && goneTexts.has(t)) {\n+\t\t\t\tmoved = true;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t\tif (moved) break;\n+\t}\n+\tif (!moved) return;\n \tconst after = host.agentView(agent);\n \tconst before = host.beforeDraft\n \t\t? host.beforeDraft(agent, draft)\n@@ -81,7 +104,8 @@\n \tfor (const file of [...touched].toSorted()) {\n \t\tlet cur: Block | undefined;\n \t\tbefore.buildLines(file).forEach((l, i) => {\n-\t\t\tif (g.deletersOf(l.id).some((d) => mine.has(d))) {\n+\t\t\t// Deleted by the draft: one of its atoms' deleted lines, with no lookup of each line's deleters.\n+\t\t\tif (goneIds.has(l.id)) {\n \t\t\t\tif (!cur) gone.push((cur = { file, start: i, ids: [], texts: [] }));\n \t\t\t\tcur.ids.push(l.id);\n \t\t\t\tcur.texts.push(text.intern(l.id));"},{"path":"worker/project/test/express-moves-early.test.ts","added":55,"removed":0,"diff":"--- /dev/null\n+++ b/worker/project/test/express-moves-early.test.ts\n@@ -0,0 +1,55 @@\n+// Moves before laying out files (abso 714, piece 3): expressMoves looks at the draft's own written and deleted lines\n+// first, and lays out no file when none of its written lines with real content has a deleted line's text. moves.test.ts\n+// covers the moves themselves.\n+\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import type { Graph } from \"../../../src/engine/index.ts\";\n+import { type ExpressMovesHost, expressMoves } from \"../express-moves.ts\";\n+import type { AgentState } from \"../project-types.ts\";\n+\n+/** A draft of two atoms: \"del\" deletes one line, \"add\" writes the others. Any view laid out throws. */\n+function host(deleted: string, written: string[]): ExpressMovesHost {\n+\tconst texts = [deleted, ...written];\n+\tconst graph = {\n+\t\tdeletedLines: (id: string) => (id === \"del\" ? [\"line-0\"] : []),\n+\t\t*eachInsertedLine(id: string) {\n+\t\t\tif (id === \"add\") for (let k = 1; k < texts.length; k++) yield `line-${k}`;\n+\t\t},\n+\t\tlineN: (line: string) => Number(line.slice(\"line-\".length)),\n+\t\t*textChunks(n: number) {\n+\t\t\tyield texts[n]!;\n+\t\t},\n+\t\ttextOf: (n: number) => texts[n]!,\n+\t} as unknown as Graph;\n+\tconst laidOut = (): never => {\n+\t\tthrow new Error(\"laid out\");\n+\t};\n+\treturn {\n+\t\tgraph,\n+\t\tdraft: () => [\"del\", \"add\"],\n+\t\tagentView: laidOut,\n+\t\tbeforeDraft: laidOut,\n+\t\tview: laidOut,\n+\t\tapply: laidOut,\n+\t\taddDraft: laidOut,\n+\t\trecordFile: laidOut,\n+\t};\n+}\n+\n+const agent = { name: \"ann\" } as AgentState;\n+\n+test(\"an edit that only changes lines lays out no file\", () => {\n+\texpressMoves(host(\"  return pi * r * r;\", [\"  return Math.PI * r * r;\"]), agent, 1, []);\n+});\n+\n+test(\"a deleted text written again with only brackets or blanks in common lays out no file\", () => {\n+\texpressMoves(host(\"}\", [\"  const tree = parse(p);\", \"}\", \"\"]), agent, 1, []);\n+});\n+\n+test(\"a written line with real content that the draft also deleted goes on to the files\", () => {\n+\tassert.throws(\n+\t\t() => expressMoves(host(\"  return pi * r * r;\", [\"\", \"  return pi * r * r;\"]), agent, 1, []),\n+\t\t/laid out/,\n+\t);\n+});"}],"ci":null}