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/path-rules.ts --json
JSON
/christopher/abso-core/blame/worker/project/path-rules.ts?format=json
69 linesFirst import 88% · engine 10% · infra-split 1%Last change infra-split in version 37,

69 lines from 3 changes in 3 versions.

init0Start the project1import { pathKey } from "./pathkey.ts";
2import { ProjectError } from "./project-error.ts";
3
4/**
5 * Why a path isn't canonical, or undefined when it is (#30). A canonical path
6 * is relative, uses forward slashes, and has no empty, "." or ".." segments,
7 * no control characters and no drive letter, so one file has one spelling.
8 * Otherwise "./harness/x" would slip past a filter on "harness/", and "../x"
9 * would escape the folder in every box that unpacks it. A ".git" segment would
10 * break the push to Artifacts.
11 */
12export function pathProblem(path: string): string | undefined {
13 if (typeof path !== "string" || path === "") return "a path must be a non-empty string";
14 if (/[\x00-\x1f\x7f]/.test(path)) return "a path may not hold control characters or line breaks";
15 if (path.includes("\\")) return "a path uses forward slashes, not backslashes";
16 if (path.startsWith("/")) return "a path is relative to the project, not absolute";
17 if (path.includes(":")) return "a path may not hold a colon (a drive letter, or a Windows stream like file::$DATA)";
18 // Every agent's disk must be able to hold it, Windows included, as the client screens (68f7a34).
19 if (/[<>"|?*]/.test(path)) return `a path may not hold < > " | ? or *, which Windows can't hold`;
20 for (const seg of path.split("/")) {
21 if (seg === "") return 'a path may not have empty segments (a leading, doubled or trailing "/")';
22 if (seg === "." || seg === "..") return `a path may not have "${seg}" segments`;
23 // By pathKey, so every spelling abso treats as one name counts (".GIT", ".gıt").
24 if (reservedKey(seg) === GIT_KEY) return "a path may not be under .git";
25 if (WINDOWS_DEVICE.test(seg.split(".")[0]!.trimEnd()))
26 return `"${seg}" is a Windows device name, which no Windows disk can hold as a file`;
27 // Windows drops a trailing dot or space, so ".git." is .git there.
28 if (/[. ]$/.test(seg)) return `"${seg}" ends in a dot or a space, which Windows drops`;
29 // A Windows short (8.3) name can be another file's second name: GIT~1 is .git (git's CVE-2019-1353).
30 if (/^[^.~ ]{1,6}~[0-9]{1,6}(\.[^. ]{1,3})?$/.test(seg))
31 return `"${seg}" looks like a Windows short name, which can be another file's second name`;
32 }
33 return undefined;
36/** Windows device names, with any extension, as the client refuses them (client/src/safety.ts). */
37const WINDOWS_DEVICE = /^(con|prn|aux|nul|com[0-9¹²³]|lpt[0-9¹²³]|conin\$|conout\$|clock\$)$/i;
38const GIT_KEY = pathKey(".git");
40/**
41 * A path part's key for comparing it against reserved names: pathKey, after
42 * dropping the characters HFS+ ignores in names, so ".g\u200Cit" is .git
43 * there (git's is_hfs_dotgit). Only for this comparison: U+200C and U+200D
infra-split37Comments and test names give each reason in plain words, without naming who raised it Notes like "(#37, Builder 5)" or "(AVCS - Security)" become "(#37)" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.Compare44 * are ordinary characters in Persian and Indic names.
init0Start the project45 */
46function reservedKey(seg: string): string {
47 return pathKey(seg.replace(/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g, ""));
engine25Read abso.json first, then avcs.json (abso 224, ask 238): one helper (projectFileIn) for the queue, files kept whole, reviewers and init; publish, init and git intake check both files the same way; when shared has both, abso.json counts and status says avcs.json is ignored (status answer projectFile, printed by abso status). .abso/ is kept out of projects like .avcs/. Old projects with only avcs.json work as before.Compare49/** The client's folder: .abso, and .avcs from before the rename (224). */
50const SETTINGS_KEYS = new Set([pathKey(".abso"), pathKey(".avcs")]);
init0Start the project51
engine25Read abso.json first, then avcs.json (abso 224, ask 238): one helper (projectFileIn) for the queue, files kept whole, reviewers and init; publish, init and git intake check both files the same way; when shared has both, abso.json counts and status says avcs.json is ignored (status answer projectFile, printed by abso status). .abso/ is kept out of projects like .avcs/. Old projects with only avcs.json work as before.Compare52/** For writes: the path must be canonical, and not under .abso/ or .avcs/ in any spelling, at any depth. */
init0Start the project53export function checkPath(path: string): void {
54 const problem = pathProblem(path);
55 if (problem) throw new ProjectError("bad-request", `bad file path ${JSON.stringify(path)}: ${problem}`);
56 // The client's settings stay in the agent's folder and are never published.
engine25Read abso.json first, then avcs.json (abso 224, ask 238): one helper (projectFileIn) for the queue, files kept whole, reviewers and init; publish, init and git intake check both files the same way; when shared has both, abso.json counts and status says avcs.json is ignored (status answer projectFile, printed by abso status). .abso/ is kept out of projects like .avcs/. Old projects with only avcs.json work as before.Compare57 const settings = path.split("/").find((seg) => SETTINGS_KEYS.has(reservedKey(seg)));
58 if (settings !== undefined) {
59 const folder = reservedKey(settings) === pathKey(".abso") ? ".abso" : ".avcs";
60 throw new ProjectError("bad-request", `${path} is under ${folder}/, which stays in the agent's folder`);
init0Start the project61 }
64/** For reads (history, restore): any path a log may hold, canonical or from before #30. */
65export function checkReadPath(path: string): void {
66 if (typeof path !== "string" || path === "" || /[\n\r]/.test(path)) {
67 throw new ProjectError("bad-request", `bad file path ${JSON.stringify(path)}`);
68 }