Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
blame on this site's /mcp
CLI
abso blame worker/project/test/express-moves-early.test.ts --version 311 --json
JSON
/christopher/abso-core/blame/worker/project/test/express-moves-early.test.ts?version=311&format=json
55 linescapacity 100%Last change capacity in version 311,

55 lines from 1 change in 1 version.

capacity311Move 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) - 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. - 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. - 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. - 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. Checks: tsc clean; Biome clean on both files; core tests (worker/project and src): 762 passed, none failed; the 17 move tests pass. Lab, 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).Compare1// Moves before laying out files (abso 714, piece 3): expressMoves looks at the draft's own written and deleted lines
2// first, and lays out no file when none of its written lines with real content has a deleted line's text. moves.test.ts
3// covers the moves themselves.
4
5import assert from "node:assert/strict";
6import { test } from "node:test";
7import type { Graph } from "../../../src/engine/index.ts";
8import { type ExpressMovesHost, expressMoves } from "../express-moves.ts";
9import type { AgentState } from "../project-types.ts";
11/** A draft of two atoms: "del" deletes one line, "add" writes the others. Any view laid out throws. */
12function host(deleted: string, written: string[]): ExpressMovesHost {
13 const texts = [deleted, ...written];
14 const graph = {
15 deletedLines: (id: string) => (id === "del" ? ["line-0"] : []),
16 *eachInsertedLine(id: string) {
17 if (id === "add") for (let k = 1; k < texts.length; k++) yield `line-${k}`;
18 },
19 lineN: (line: string) => Number(line.slice("line-".length)),
20 *textChunks(n: number) {
21 yield texts[n]!;
22 },
23 textOf: (n: number) => texts[n]!,
24 } as unknown as Graph;
25 const laidOut = (): never => {
26 throw new Error("laid out");
27 };
28 return {
29 graph,
30 draft: () => ["del", "add"],
31 agentView: laidOut,
32 beforeDraft: laidOut,
33 view: laidOut,
34 apply: laidOut,
35 addDraft: laidOut,
36 recordFile: laidOut,
37 };
40const agent = { name: "ann" } as AgentState;
42test("an edit that only changes lines lays out no file", () => {
43 expressMoves(host(" return pi * r * r;", [" return Math.PI * r * r;"]), agent, 1, []);
44});
46test("a deleted text written again with only brackets or blanks in common lays out no file", () => {
47 expressMoves(host("}", [" const tree = parse(p);", "}", ""]), agent, 1, []);
48});
50test("a written line with real content that the draft also deleted goes on to the files", () => {
51 assert.throws(
52 () => expressMoves(host(" return pi * r * r;", ["", " return pi * r * r;"]), agent, 1, []),
53 /laid out/,
54 );
55});