Skip to content

abso-core

Public
Check passed
MCP
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/src/engine/test/graph-move-write-membership.test.ts?format=json
41 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 162, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { buildBase, Graph } from "../index.ts";
4import { gapKey, posKey } from "../keys.ts";
5import type { Atom } from "../types.ts";
6import { SqlState } from "./storage-helper.ts";
7
8test("move validation uses indexed write membership without rescanning the write list", () => {
9 const storage = new SqlState();
10 try {
11 const graph = new Graph({ storage });
12 graph.add(buildBase({ "a.txt": "one\ntwo" }, { author: "fixture", message: "base", time: 0 }));
13 const writes = [posKey("a0.1"), gapKey("a0.0")];
14 writes.includes = () => {
15 throw Error("whole write list scan forbidden");
16 };
17 const atom: Atom = {
18 id: "a1",
19 seq: 1,
20 author: "fixture",
21 message: "move",
22 time: 1,
23 inserts: [],
24 deletes: [],
25 writes,
26 reads: [],
27 holds: [],
28 needs: [],
29 resolves: [],
30 reasons: [],
31 deps: ["a0"],
32 moves: [{ line: "a0.1", parent: "a0.0" }],
33 };
34 graph.add(atom);
35 assert.equal(new Graph({ storage }).size, 2);
36 assert.throws(() => graph.add({ ...atom, id: "a2", seq: 2, writes: [posKey("a0.1")] }), /without writing/);
37 assert.equal(graph.size, 2);
38 } finally {
39 storage.db.close();
40 }
41});