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/definitions.test.ts --json
JSON
/christopher/abso-core/blame/worker/project/test/definitions.test.ts?format=json
80 linesFirst import 80% · codex-capacity-chair 13% · engine 8%Last change codex-capacity-chair in version 175,

80 lines from 3 changes in 3 versions.

init0Start the project1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { buildBase, Graph, View } from "../../../src/engine/index.ts";
4import { definitionsIn } from "../definitions.ts";
5
6function defs(files: Record<string, string>): Record<string, string[]> {
7 const graph = new Graph();
8 const a0 = buildBase(files, { author: "t", message: "t" });
9 graph.add(a0);
10 const out: Record<string, string[]> = {};
11 for (const [name, list] of definitionsIn(new View(graph, [a0.id]))) out[name] = list.map((d) => d.text);
12 return out;
15test("function headers stop at the body; blocks of types are whole", () => {
16 const found = defs({
17 "a.ts": [
18 "export function parsePattern(text: string,",
19 " flags: string): Node {",
20 " return compileNode(text);",
21 "}",
22 "export const matchAll = (re: Node, s: string) => {",
23 " return [];",
24 "};",
25 "const MAX_DEPTH = 10;",
26 "export interface Node {",
27 " kind: string;",
28 " kids: Node[];",
29 "}",
30 'type Flag = "g" | "i";',
31 "class Engine {",
32 " async runOnce(input: string): Promise<void> {",
33 " helperCall(input);",
34 " }",
35 "}",
36 ].join("\n"),
37 });
38 assert.deepEqual(found, {
39 parsePattern: ["export function parsePattern(text: string,\n flags: string): Node {"],
40 matchAll: ["export const matchAll = (re: Node, s: string) => {"],
41 MAX_DEPTH: ["const MAX_DEPTH = 10;"],
42 Node: ["export interface Node {\n kind: string;\n kids: Node[];\n}"],
43 Flag: ['type Flag = "g" | "i";'],
44 // Only top-level declarations: the method runOnce is reached through a dot, never imported.
45 Engine: ["class Engine {"],
46 });
47});
49test("Python, Go and Rust shapes; calls are not definitions", () => {
50 const found = defs({
51 "a.py": "def compile_pattern(text,\n flags=0):\n return run_it(text)\nMAX_STEPS = 100\n",
52 "b.go": "func (m *Matcher) MatchString(s string) bool {\n\treturn false\n}\n",
53 "c.rs":
54 "pub fn find_at(hay: &str, at: usize) -> Option<usize> {\n None\n}\npub struct Span {\n start: usize,\n}\n",
55 "d.md": "function notCode(x) {\n",
56 });
57 assert.deepEqual(found, {
58 compile_pattern: ["def compile_pattern(text,\n flags=0):"],
59 MAX_STEPS: ["MAX_STEPS = 100"],
60 MatchString: ["func (m *Matcher) MatchString(s string) bool {"],
61 find_at: ["pub fn find_at(hay: &str, at: usize) -> Option<usize> {"],
62 Span: ["pub struct Span {\n start: usize,\n}"],
63 });
64});
engine6A big publish spends less on the changed-definition rule (abso issue 158, under 157). Measured on gig-replay-2's a3 PR 309 publish, five versions behind shared, through the Worker's project layer with text read back from the log, as live runs it. Cloud measured 9 s of CPU on staging. Two costs in the definition rule: 1. For every line a draft wrote, it walked the atom's runs to find the run holding the line, and each run's length meant reading its text back from the log. Each atom's run ends are now worked out once per check (definition-rule.ts). 2. It scanned data files for definitions. A 23,000-line JSON fixture was read line by line for names it can't define, and its keys could pass for uses of code names. JSON, CSV, lock and SVG files now count as holding no code, like prose (names.ts holdsNoCode). The publish through EngineProject takes about 0.84-1.1 s locally (was 1.9 s); what's left is mostly expressing moves within the layout budget. Tests: a new definitions test (data files hold no definitions); the changed-definition tests pass. Check passes (695), and the project tests also pass with AVCS_TEXT_FROM_LOG=1 (217). The replay gate passed on 33 live projects (ef9edb7) with these same three files in abso's folder.Compare65
66test("data files hold no definitions: JSON, CSV and lock files are passed over, however code-like a line looks (abso issue 158)", () => {
67 const codeLike = "export function parsePattern(text: string): Node {\n return compileNode(text);\n}\n";
68 assert.deepEqual(defs({ "fixtures/a.json": codeLike, "data/b.csv": codeLike, "c.lock": codeLike }), {});
69 assert.deepEqual(Object.keys(defs({ "src/a.ts": codeLike })), ["parsePattern"]);
70});
codex-capacity-chair175Reduce disk-backed record and publish allocations; reviewed in core ask 52 with parsed-code budget and exact aligned-line follow-ups. Keep disk-first activation off.Compare71
72test("definition scanning does not retain the original file line array", (t) => {
73 const graph = new Graph();
74 graph.add(buildBase({ "a.ts": "export function parseThing() { return 1; }\n" }, { author: "t", message: "t" }));
75 const view = new View(graph, ["a0"]);
76 t.mock.method(view, "lines", () => {
77 throw Error("original file line array forbidden");
78 });
79 assert.deepEqual([...definitionsIn(view).keys()], ["parseThing"]);
80});