Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(ingest): symbol table version 2, so a journal-unaware CLI ignores it
KageBinary482e0ace622e
diff --git a/ix-cli/src/cli/__tests__/ingest-symbols.test.ts b/ix-cli/src/cli/__tests__/ingest-symbols.test.tsindex d2905357..01a0f6ab 100644--- a/ix-cli/src/cli/__tests__/ingest-symbols.test.ts+++ b/ix-cli/src/cli/__tests__/ingest-symbols.test.ts@@ -33,16 +33,24 @@ describe("ingest symbol table", () => {it("is empty for another extractor or another root", () => {saveIngestSymbols(root, "tree-sitter/1.29", new Map([["a.py", entry("a.py")]]));expect(loadIngestSymbols(root, "tree-sitter/1.30").size).toBe(0);- writeFileSync(ingestSymbolsPath("/other"), JSON.stringify({ version: 1, root, extractor: "tree-sitter/1.29", files: {} }));+ writeFileSync(ingestSymbolsPath("/other"), JSON.stringify({ version: 2, root, extractor: "tree-sitter/1.29", files: {} }));expect(loadIngestSymbols("/other", "tree-sitter/1.29").size).toBe(0);});+ it("ignores a version-1 table, which a journal-unaware CLI would have read alone", () => {+ writeFileSync(+ ingestSymbolsPath(root),+ JSON.stringify({ version: 1, root, extractor: "tree-sitter/1.29", files: { "a.py": entry("a.py") } }),+ );+ expect(loadIngestSymbols(root, "tree-sitter/1.29").size).toBe(0);+ });+it("is empty when missing or unreadable, and drops malformed entries", () => {expect(loadIngestSymbols(root, "x").size).toBe(0);writeFileSync(ingestSymbolsPath(root), "{not json");expect(loadIngestSymbols(root, "x").size).toBe(0);writeFileSync(ingestSymbolsPath(root), JSON.stringify({- version: 1, root, extractor: "x", files: { "a.py": entry("a.py"), "b.py": { hash: 3 }, "c.py": { hash: "h", summary: {} } },+ version: 2, root, extractor: "x", files: { "a.py": entry("a.py"), "b.py": { hash: 3 }, "c.py": { hash: "h", summary: {} } },}));expect([...loadIngestSymbols(root, "x").keys()]).toEqual(["a.py"]);expect(existsSync(ingestSymbolsPath(root))).toBe(true);@@ -101,7 +109,7 @@ describe("ingest symbol table", () => {it("keeps the table readable without the journal: version 1, every field it had", () => {seed(3);const data = JSON.parse(readFileSync(tablePath(), "utf8")) as Record<string, unknown>;- expect(data).toMatchObject({ version: 1, root, extractor: "x" });+ expect(data).toMatchObject({ version: 2, root, extractor: "x" });expect(Object.keys(data.files as object)).toEqual(["f0.py", "f1.py", "f2.py"]);});@@ -139,7 +147,7 @@ describe("ingest symbol table", () => {t.set("f1.py", { ...entry("f1.py"), hash: "h2" });saveIngestSymbols(root, "x", t, new Set(["f1.py"]));// A CLI that does not know the journal rewrites the table without a generation.- writeFileSync(tablePath(), JSON.stringify({ version: 1, root, extractor: "x", files: { "f1.py": entry("f1.py") } }));+ writeFileSync(tablePath(), JSON.stringify({ version: 2, root, extractor: "x", files: { "f1.py": entry("f1.py") } }));const loaded = loadIngestSymbols(root, "x");expect(loaded.get("f1.py")?.hash).toBe("h1");// And the save after that replaces it rather than appending to it.diff --git a/ix-cli/src/cli/ingest-symbols.ts b/ix-cli/src/cli/ingest-symbols.tsindex ab399751..fb623dbe 100644--- a/ix-cli/src/cli/ingest-symbols.ts+++ b/ix-cli/src/cli/ingest-symbols.ts@@ -22,8 +22,13 @@ import { ingestSymbolsJournalPath, ingestSymbolsPath } from "./config.js";* wrote it.*/-/** Bump when the stored shape changes; an older table is ignored, not migrated. */-const TABLE_VERSION = 1;+/**+ * Bump when the stored shape or meaning changes; an older table is ignored,+ * not migrated. 2: the table may be extended by a journal (below), so a CLI+ * that reads the table alone would see a stale "before" for the run's+ * dependents step.+ */+const TABLE_VERSION = 2;/** What core-ingestion's `FileSummary` looks like from here: opaque except for the path. */export interface StoredSummary {@@ -89,10 +94,12 @@ interface SerializedSymbolTable {/*** The table is written in full only now and then. In between, a run that* changed a few entries appends them to a journal beside it, one JSON record- * per line, and the next load applies the journal over the table. The table- * keeps its version-1 shape, so a CLI that does not know about the journal- * still reads it; the entries it lacks are then merely older, and an older- * entry is checked against its file's hash and mtime before it is used.+ * per line, and the next load applies the journal over the table. A table+ * read without its journal is not merely older: the dependents step diffs the+ * names a file exported before this run against after it, and a "before"+ * several journaled runs behind the backend misses renames that already+ * landed. So the table is version 2, which a CLI that does not know about the+ * journal ignores (it re-parses) rather than reading alone.** Line 1 is a header naming the table it extends; each line after it is* `{"k": path, "e": entry}` (set) or `{"k": path, "d": 1}` (removed).