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
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/src/engine/test/attribute-projection.test.ts?format=json
57 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 140, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { Graph } from "../graph.ts";
4import { CachedStateStorage, StableOverlaySet } from "../state-source.ts";
5import { View } from "../view.ts";
6import { Repo } from "./helpers.ts";
7import { SqlState } from "./storage-helper.ts";
8
9test("attribute queries and explicit file existence do not traverse line history", (t) => {
10 const repo = Repo.init({ "file.txt": "one\ntwo\n" });
11 const base = new Set(repo.shared);
12 repo.edit({
13 attrs: [
14 { file: "file.txt", name: "exec", value: "1" },
15 { file: "empty.txt", name: "exists", value: "1" },
16 { file: "link.txt", name: "link", value: "target" },
17 ],
18 });
19 const first = new Set(repo.shared);
20 repo.edit({
21 attrs: [
22 { file: "file.txt", name: "exec", value: null },
23 { file: "empty.txt", name: "exists", value: null },
24 { file: "link.txt", name: "link", value: null },
25 ],
26 });
27 const source = new SqlState();
28 try {
29 const disk = new Graph({ storage: new CachedStateStorage(source) });
30 for (const id of repo.shared) disk.add(repo.graph.atom(id));
31 for (const graph of [repo.graph, new Graph({ storage: new CachedStateStorage(source) })]) {
32 for (const set of [base, first, repo.shared]) {
33 const view = new View(graph, new StableOverlaySet(set));
34 const before = view.weight();
35 const guard = t.mock.method(graph, "startCodeOf", () => {
36 throw new Error("line traversal forbidden");
37 });
38 assert.equal(view.attrs("file.txt").exec, set === first);
39 assert.equal(view.attrs("empty.txt").exists, set === first);
40 assert.equal(view.attrs("link.txt").link, set === first ? "target" : null);
41 assert.deepEqual(view.attrs("missing.txt"), { exists: false, exec: false, link: null, blob: null });
42 if (set === first) {
43 assert.equal(view.hasFile("empty.txt"), true);
44 assert.equal(view.hasFile("link.txt"), true);
45 }
46 assert.equal(view.weight(), before);
47 guard.mock.restore();
48 assert.equal(view.hasFile("file.txt"), true, "text-only files retain line fallback");
49 assert.equal(view.hasFile("missing.txt"), false);
50 assert.equal(view.hasFile("empty.txt"), set === first);
51 assert.equal(view.text("file.txt"), "one\ntwo\n");
52 }
53 }
54 } finally {
55 source.db.close();
56 }
57});