{"file":"worker/project/path-rules.ts","version":318,"total":69,"from":1,"to":69,"lines":[{"n":1,"text":"import { pathKey } from \"./pathkey.ts\";","atom":"a0","author":"init","version":0},{"n":2,"text":"import { ProjectError } from \"./project-error.ts\";","atom":"a0","author":"init","version":0},{"n":3,"text":"","atom":"a0","author":"init","version":0},{"n":4,"text":"/**","atom":"a0","author":"init","version":0},{"n":5,"text":" * Why a path isn't canonical, or undefined when it is (#30). A canonical path","atom":"a0","author":"init","version":0},{"n":6,"text":" * is relative, uses forward slashes, and has no empty, \".\" or \"..\" segments,","atom":"a0","author":"init","version":0},{"n":7,"text":" * no control characters and no drive letter, so one file has one spelling.","atom":"a0","author":"init","version":0},{"n":8,"text":" * Otherwise \"./harness/x\" would slip past a filter on \"harness/\", and \"../x\"","atom":"a0","author":"init","version":0},{"n":9,"text":" * would escape the folder in every box that unpacks it. A \".git\" segment would","atom":"a0","author":"init","version":0},{"n":10,"text":" * break the push to Artifacts.","atom":"a0","author":"init","version":0},{"n":11,"text":" */","atom":"a0","author":"init","version":0},{"n":12,"text":"export function pathProblem(path: string): string | undefined {","atom":"a0","author":"init","version":0},{"n":13,"text":"\tif (typeof path !== \"string\" || path === \"\") return \"a path must be a non-empty string\";","atom":"a0","author":"init","version":0},{"n":14,"text":"\tif (/[\\x00-\\x1f\\x7f]/.test(path)) return \"a path may not hold control characters or line breaks\";","atom":"a0","author":"init","version":0},{"n":15,"text":"\tif (path.includes(\"\\\\\")) return \"a path uses forward slashes, not backslashes\";","atom":"a0","author":"init","version":0},{"n":16,"text":"\tif (path.startsWith(\"/\")) return \"a path is relative to the project, not absolute\";","atom":"a0","author":"init","version":0},{"n":17,"text":"\tif (path.includes(\":\")) return \"a path may not hold a colon (a drive letter, or a Windows stream like file::$DATA)\";","atom":"a0","author":"init","version":0},{"n":18,"text":"\t// Every agent's disk must be able to hold it, Windows included, as the client screens (68f7a34).","atom":"a0","author":"init","version":0},{"n":19,"text":"\tif (/[<>\"|?*]/.test(path)) return `a path may not hold < > \" | ? or *, which Windows can't hold`;","atom":"a0","author":"init","version":0},{"n":20,"text":"\tfor (const seg of path.split(\"/\")) {","atom":"a0","author":"init","version":0},{"n":21,"text":"\t\tif (seg === \"\") return 'a path may not have empty segments (a leading, doubled or trailing \"/\")';","atom":"a0","author":"init","version":0},{"n":22,"text":"\t\tif (seg === \".\" || seg === \"..\") return `a path may not have \"${seg}\" segments`;","atom":"a0","author":"init","version":0},{"n":23,"text":"\t\t// By pathKey, so every spelling abso treats as one name counts (\".GIT\", \".gıt\").","atom":"a0","author":"init","version":0},{"n":24,"text":"\t\tif (reservedKey(seg) === GIT_KEY) return \"a path may not be under .git\";","atom":"a0","author":"init","version":0},{"n":25,"text":"\t\tif (WINDOWS_DEVICE.test(seg.split(\".\")[0]!.trimEnd()))","atom":"a0","author":"init","version":0},{"n":26,"text":"\t\t\treturn `\"${seg}\" is a Windows device name, which no Windows disk can hold as a file`;","atom":"a0","author":"init","version":0},{"n":27,"text":"\t\t// Windows drops a trailing dot or space, so \".git.\" is .git there.","atom":"a0","author":"init","version":0},{"n":28,"text":"\t\tif (/[. ]$/.test(seg)) return `\"${seg}\" ends in a dot or a space, which Windows drops`;","atom":"a0","author":"init","version":0},{"n":29,"text":"\t\t// A Windows short (8.3) name can be another file's second name: GIT~1 is .git (git's CVE-2019-1353).","atom":"a0","author":"init","version":0},{"n":30,"text":"\t\tif (/^[^.~ ]{1,6}~[0-9]{1,6}(\\.[^. ]{1,3})?$/.test(seg))","atom":"a0","author":"init","version":0},{"n":31,"text":"\t\t\treturn `\"${seg}\" looks like a Windows short name, which can be another file's second name`;","atom":"a0","author":"init","version":0},{"n":32,"text":"\t}","atom":"a0","author":"init","version":0},{"n":33,"text":"\treturn undefined;","atom":"a0","author":"init","version":0},{"n":34,"text":"}","atom":"a0","author":"init","version":0},{"n":35,"text":"","atom":"a0","author":"init","version":0},{"n":36,"text":"/** Windows device names, with any extension, as the client refuses them (client/src/safety.ts). */","atom":"a0","author":"init","version":0},{"n":37,"text":"const WINDOWS_DEVICE = /^(con|prn|aux|nul|com[0-9¹²³]|lpt[0-9¹²³]|conin\\$|conout\\$|clock\\$)$/i;","atom":"a0","author":"init","version":0},{"n":38,"text":"const GIT_KEY = pathKey(\".git\");","atom":"a0","author":"init","version":0},{"n":39,"text":"","atom":"a0","author":"init","version":0},{"n":40,"text":"/**","atom":"a0","author":"init","version":0},{"n":41,"text":" * A path part's key for comparing it against reserved names: pathKey, after","atom":"a0","author":"init","version":0},{"n":42,"text":" * dropping the characters HFS+ ignores in names, so \".g\\u200Cit\" is .git","atom":"a0","author":"init","version":0},{"n":43,"text":" * there (git's is_hfs_dotgit). Only for this comparison: U+200C and U+200D","atom":"a0","author":"init","version":0},{"n":44,"text":" * are ordinary characters in Persian and Indic names.","atom":"a329","author":"infra-split","version":37},{"n":45,"text":" */","atom":"a0","author":"init","version":0},{"n":46,"text":"function reservedKey(seg: string): string {","atom":"a0","author":"init","version":0},{"n":47,"text":"\treturn pathKey(seg.replace(/[\\u200C-\\u200F\\u202A-\\u202E\\u206A-\\u206F\\uFEFF]/g, \"\"));","atom":"a0","author":"init","version":0},{"n":48,"text":"}","atom":"a0","author":"init","version":0},{"n":49,"text":"/** The client's folder: .abso, and .avcs from before the rename (224). */","atom":"a179","author":"engine","version":25},{"n":50,"text":"const SETTINGS_KEYS = new Set([pathKey(\".abso\"), pathKey(\".avcs\")]);","atom":"a179","author":"engine","version":25},{"n":51,"text":"","atom":"a0","author":"init","version":0},{"n":52,"text":"/** For writes: the path must be canonical, and not under .abso/ or .avcs/ in any spelling, at any depth. */","atom":"a179","author":"engine","version":25},{"n":53,"text":"export function checkPath(path: string): void {","atom":"a0","author":"init","version":0},{"n":54,"text":"\tconst problem = pathProblem(path);","atom":"a0","author":"init","version":0},{"n":55,"text":"\tif (problem) throw new ProjectError(\"bad-request\", `bad file path ${JSON.stringify(path)}: ${problem}`);","atom":"a0","author":"init","version":0},{"n":56,"text":"\t// The client's settings stay in the agent's folder and are never published.","atom":"a0","author":"init","version":0},{"n":57,"text":"\tconst settings = path.split(\"/\").find((seg) => SETTINGS_KEYS.has(reservedKey(seg)));","atom":"a179","author":"engine","version":25},{"n":58,"text":"\tif (settings !== undefined) {","atom":"a179","author":"engine","version":25},{"n":59,"text":"\t\tconst folder = reservedKey(settings) === pathKey(\".abso\") ? \".abso\" : \".avcs\";","atom":"a179","author":"engine","version":25},{"n":60,"text":"\t\tthrow new ProjectError(\"bad-request\", `${path} is under ${folder}/, which stays in the agent's folder`);","atom":"a179","author":"engine","version":25},{"n":61,"text":"\t}","atom":"a0","author":"init","version":0},{"n":62,"text":"}","atom":"a0","author":"init","version":0},{"n":63,"text":"","atom":"a0","author":"init","version":0},{"n":64,"text":"/** For reads (history, restore): any path a log may hold, canonical or from before #30. */","atom":"a0","author":"init","version":0},{"n":65,"text":"export function checkReadPath(path: string): void {","atom":"a0","author":"init","version":0},{"n":66,"text":"\tif (typeof path !== \"string\" || path === \"\" || /[\\n\\r]/.test(path)) {","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\tthrow new ProjectError(\"bad-request\", `bad file path ${JSON.stringify(path)}`);","atom":"a0","author":"init","version":0},{"n":68,"text":"\t}","atom":"a0","author":"init","version":0},{"n":69,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a179","author":"engine","message":"","time":1791531853932,"timeIso":"2026-10-09T07:44:13.932Z","publish":{"draft":null,"version":25,"agent":"engine","message":"Read 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.","time":1791531874263,"timeIso":"2026-10-09T07:44:34.263Z"}},{"atom":"a329","author":"infra-split","message":"","time":1791546813593,"timeIso":"2026-10-09T11:53:33.593Z","publish":{"draft":null,"version":37,"agent":"infra-split","message":"Comments and test names give each reason in plain words, without naming who raised it\n\nNotes 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.","time":1791547035956,"timeIso":"2026-10-09T11:57:15.956Z"}}]}