Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
fix(finalizer): cover two rollback blind spots in the baseline patch (#753)
06FallingLight9008778069b85a
diff --git a/understand-anything-plugin/skills/understand/finalize-incremental.mjs b/understand-anything-plugin/skills/understand/finalize-incremental.mjsindex 5847c128..6e6d3f4b 100644--- a/understand-anything-plugin/skills/understand/finalize-incremental.mjs+++ b/understand-anything-plugin/skills/understand/finalize-incremental.mjs@@ -20,6 +20,7 @@ import {readFileSync,realpathSync,renameSync,+ rmSync,writeFileSync,} from 'node:fs';import { validateIncrementalSymbols, formatSymbolReport } from './validate-incremental-symbols.mjs';@@ -491,8 +492,12 @@ async function main() {// restore both the old graph and the old fingerprint baseline. Restoring// fingerprints matters as much as restoring the graph: a stale graph with// fresh fingerprints would make the next run misclassify every change.- const fingerprintBackup = readJson(fingerprintPath, null);+ // The snapshot read happens INSIDE the try: a corrupted store must also+ // roll the graph back instead of escaping with the new graph published.+ const fingerprintsExisted = existsSync(fingerprintPath);+ let fingerprintBackup = null;try {+ if (fingerprintsExisted) fingerprintBackup = readJson(fingerprintPath);patchFingerprints(uaDir, plan, patch);advanceMeta(uaDir, plan, scan.totalFiles);} catch (error) {@@ -500,8 +505,12 @@ async function main() {if (previousGraph && Array.isArray(previousGraph.nodes)) {atomicWriteJson(graphPath, previousGraph);}- if (fingerprintBackup && typeof fingerprintBackup === 'object' && !Array.isArray(fingerprintBackup)) {+ if (fingerprintsExisted && fingerprintBackup && typeof fingerprintBackup === 'object' && !Array.isArray(fingerprintBackup)) {atomicWriteJson(fingerprintPath, fingerprintBackup);+ } else if (!fingerprintsExisted && existsSync(fingerprintPath)) {+ // The patch created the store after the graph was written; a failed+ // run must not leave fresh fingerprints beside a rolled-back graph.+ rmSync(fingerprintPath);}process.stderr.write('Rolled back knowledge-graph.json and fingerprints.json to their previous state\n');}