{"version":6,"agent":"engine","message":"A big publish spends less on the changed-definition rule (abso issue 158, under 157).\n\nMeasured 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:\n1. 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).\n2. 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).\nThe 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.\n\nTests: 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.","time":1791510401672,"timeIso":"2026-10-09T01:46:41.672Z","changes":4,"change":54,"files":["worker/project/definition-rule.ts","worker/project/definitions.ts","worker/project/names.ts","worker/project/test/definitions.test.ts"],"draft":null,"diff":[{"path":"worker/project/definition-rule.ts","added":19,"removed":12,"diff":"--- a/worker/project/definition-rule.ts\n+++ b/worker/project/definition-rule.ts\n@@ -7,7 +7,7 @@\n import { type AtomId, type Graph, joinLines, type LineId, type View } from \"../../src/engine/index.ts\";\n import { type Origin, touchedFiles } from \"./collisions.ts\";\n import { type Definition, definitionsIn, importsOf, usedNames } from \"./definitions.ts\";\n-import { codeOfLines, declaredIn, isProse } from \"./names.ts\";\n+import { codeOfLines, declaredIn, holdsNoCode } from \"./names.ts\";\n import { definitionText } from \"./news.ts\";\n import type { Collision } from \"./project.ts\";\n \n@@ -30,6 +30,12 @@\n \n const EMPTY_NAMES: ReadonlySet<string> = new Set();\n \n+/** Where one of an atom's inserted runs ends (its lines' k), and the node it hangs off. */\n+interface RunEnd {\n+\treadonly end: number;\n+\treadonly parent: string;\n+}\n+\n export class DefinitionRule {\n \treadonly #graph: Graph;\n \treadonly #origin: (atom: AtomId, spaceName: string) => Origin;\n@@ -46,20 +52,20 @@\n \t * replaced the block of lines the atom deleted just before it in `base`.\n \t * A pure insertion replaced nothing.\n \t */\n-\t#replacedNames(line: LineId, base: View): ReadonlySet<string> {\n+\t#replacedNames(line: LineId, base: View, runsOf: Map<AtomId, readonly RunEnd[]>): ReadonlySet<string> {\n \t\tconst g = this.#graph;\n \t\tconst info = g.line(line);\n \t\tif (!info) return EMPTY_NAMES;\n \t\tconst atom = g.atom(info.atom);\n-\t\tlet k = 0;\n-\t\tlet parent: string | undefined;\n-\t\tfor (const run of atom.inserts) {\n-\t\t\tif (info.k < k + run.lines.length) {\n-\t\t\t\tparent = run.parent;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tk += run.lines.length;\n+\t\t// Where each of the atom's runs ends, worked out once per check (abso issue 158): reading a run's\n+\t\t// lines can mean reading its text back from the log, so not once per line of a big change.\n+\t\tlet runs = runsOf.get(atom.id);\n+\t\tif (!runs) {\n+\t\t\tlet k = 0;\n+\t\t\truns = atom.inserts.map((run) => ({ end: (k += run.lines.length), parent: run.parent }));\n+\t\t\trunsOf.set(atom.id, runs);\n \t\t}\n+\t\tconst parent = runs.find((r) => info.k < r.end)?.parent;\n \t\tif (parent === undefined || parent.startsWith(\"^\") || !g.deletersOf(parent).includes(atom.id)) return EMPTY_NAMES;\n \t\tconst key = `${atom.id} ${parent}`;\n \t\tlet names = this.#replacedCache.get(key);\n@@ -100,10 +106,11 @@\n \t\tif (draft.size === 0 || newer.size === 0) return [];\n \t\tconst uses = new Map<string, { file: string; index: number }[]>();\n \t\tconst declared = new Set<string>();\n+\t\tconst runsOf = new Map<AtomId, readonly RunEnd[]>();\n \t\t// Only files the draft wrote lines in can hold its lines.\n \t\tconst draftFiles = touchedFiles(this.#graph, draft, [view]);\n \t\tfor (const file of [...draftFiles].sort()) {\n-\t\t\tif (isProse(file) || !view.hasFile(file)) continue;\n+\t\t\tif (holdsNoCode(file) || !view.hasFile(file)) continue;\n \t\t\tconst visible = view.lines(file);\n \t\t\tif (!visible.some((l) => draft.has(l.atom))) continue;\n \t\t\tconst code = codeOfLines(visible.map((l) => l.text));\n@@ -111,7 +118,7 @@\n \t\t\t\tif (!draft.has(line.atom)) return;\n \t\t\t\tfor (const name of declaredIn(code[i]!)) declared.add(name);\n \t\t\t\t// Only names the change added: a use already on the lines it replaced is not the draft's to answer for.\n-\t\t\t\tconst before = this.#replacedNames(line.id, baseView);\n+\t\t\t\tconst before = this.#replacedNames(line.id, baseView, runsOf);\n \t\t\t\tfor (const name of usedNames(code[i]!)) {\n \t\t\t\t\tif (before.has(name)) continue;\n \t\t\t\t\tconst list = uses.get(name);"},{"path":"worker/project/definitions.ts","added":2,"removed":2,"diff":"--- a/worker/project/definitions.ts\n+++ b/worker/project/definitions.ts\n@@ -20,7 +20,7 @@\n // that defines it (project.ts, #definitionCore).\n \n import type { LineId, View } from \"../../src/engine/index.ts\";\n-import { codeOfLines, isCommonName, isProse } from \"./names.ts\";\n+import { codeOfLines, holdsNoCode, isCommonName } from \"./names.ts\";\n \n export interface Definition {\n \treadonly name: string;\n@@ -119,7 +119,7 @@\n }\n \n function definitionsInFile(view: View, file: string, keepCommon = false): Definition[] {\n-\tif (isProse(file) || !view.hasFile(file)) return [];\n+\tif (holdsNoCode(file) || !view.hasFile(file)) return [];\n \tconst out: Definition[] = [];\n \tconst visible = view.lines(file);\n \tconst code = codeOfLines(visible.map((l) => l.text));"},{"path":"worker/project/names.ts","added":15,"removed":0,"diff":"--- a/worker/project/names.ts\n+++ b/worker/project/names.ts\n@@ -64,6 +64,21 @@\n ]);\n \n /** Files of prose, whose words are not code: Markdown, plain text, READMEs and the like. */\n+/** Data files: no code defines or uses a name in them, however big they are (abso issue 158). */\n+const DATA_EXTENSIONS = new Set([\"json\", \"jsonc\", \"json5\", \"jsonl\", \"ndjson\", \"geojson\", \"csv\", \"tsv\", \"lock\", \"svg\"]);\n+\n+/**\n+ * Whether the definition rule passes over a file: prose, or data. Scanning a\n+ * 23,000-line JSON fixture for definitions it can't hold cost a big publish\n+ * hundreds of milliseconds, and its keys could pass for uses of code names.\n+ */\n+export function holdsNoCode(path: string): boolean {\n+\tif (isProse(path)) return true;\n+\tconst base = path.slice(path.lastIndexOf(\"/\") + 1).toLowerCase();\n+\tconst dot = base.lastIndexOf(\".\");\n+\treturn dot > 0 && DATA_EXTENSIONS.has(base.slice(dot + 1));\n+}\n+\n export function isProse(path: string): boolean {\n \tconst base = path.slice(path.lastIndexOf(\"/\") + 1).toLowerCase();\n \tconst dot = base.lastIndexOf(\".\");"},{"path":"worker/project/test/definitions.test.ts","added":6,"removed":0,"diff":"--- a/worker/project/test/definitions.test.ts\n+++ b/worker/project/test/definitions.test.ts\n@@ -62,3 +62,9 @@\n \t\tSpan: [\"pub struct Span {\\n    start: usize,\\n}\"],\n \t});\n });\n+\n+test(\"data files hold no definitions: JSON, CSV and lock files are passed over, however code-like a line looks (abso issue 158)\", () => {\n+\tconst codeLike = \"export function parsePattern(text: string): Node {\\n  return compileNode(text);\\n}\\n\";\n+\tassert.deepEqual(defs({ \"fixtures/a.json\": codeLike, \"data/b.csv\": codeLike, \"c.lock\": codeLike }), {});\n+\tassert.deepEqual(Object.keys(defs({ \"src/a.ts\": codeLike })), [\"parsePattern\"]);\n+});"}],"ci":null}