fix(cli): erase clears all builder-owned files (#349, #350)#364
Merged
Conversation
…mp) (#349, #350) erase left .graph_increment_in_progress and .graph_hashes.json.tmp on disk because _cmd_erase hardcoded only .graph_hashes.json. The surviving crash marker then forced the next increment into a silent full rebuild (explained only under --verbose); the .tmp was orphan cruft. Export the builder-owned filenames from build_ast_graph.BUILDER_OWNED_INDEX_FILES and have erase clear all of them from one list, so erase and the builder cannot drift. Co-Authored-By: Claude <noreply@anthropic.com>
The top-level `from build_ast_graph import BUILDER_OWNED_INDEX_FILES` pulled numpy/ladybug/pyarrow/tree_sitter on every CLI invocation (~54ms; measured via -X importtime: cli cumulative import went 44ms -> 98ms), including `--help` -- violating this file's own lazy-import invariant. The three filenames are only needed on the erase path, so move the import into _cmd_erase. After the move, build_ast_graph is no longer imported at cli import time and cumulative import is back to ~39ms. Co-Authored-By: Claude <noreply@anthropic.com>
Owner
Author
|
Addressed a finding from a multi-agent review pass: Top-level |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up to #346 / PR #348.
eraseremovedcode_graph.lbug,cocoindex.db, and.graph_hashes.jsonbut left the rest of the graph builder's bookkeeping on disk:eraseleaves.graph_increment_in_progress; nextincrementsilently does a full rebuild #349 —.graph_increment_in_progress(the incremental crash marker) survivederaseandinit. The nextincrementthen saw the stale marker and silently fell back to a full rebuild — a one-time perf hit explained only under--verbose.eraseleaves.graph_hashes.json.tmporphan after a crashed build #350 —.graph_hashes.json.tmp(the atomic-write temp fromFileHashTracker.save) was orphaned after a crashed save. Pure cruft, but it defeated the "clean slate"eraseadvertises and never appeared in theWill delete:preview.Fix
_cmd_erasehardcoded only.graph_hashes.json. Per both issues' suggestion, export the builder-owned filenames as a single source of truth:build_ast_graph.BUILDER_OWNED_INDEX_FILES= (GRAPH_HASHES_FILENAME,GRAPH_HASHES_TMP_FILENAME,GRAPH_INCREMENT_MARKER_FILENAME) — defined next to theFileHashTracker/ crash-marker code that owns them.FileHashTrackerandincremental_rebuildnow reference the constants instead of literals._cmd_erasederives its delete + preview list fromBUILDER_OWNED_INDEX_FILES, so erase and the builder cannot drift.Test
New
test_erase_removes_increment_marker_and_hash_store_tmpseeds the crash marker + the orphan temp and assertseraseremoves both. TDD: failed first (red on the marker assertion), then green after the fix.Notes
ontology_versionbump — pure lifecycle/CLI cleanup.build_ast_graphwas previously only run as a subprocess; this is the firstimport build_ast_graph. Verified import-safe:main()is__main__-guarded and there are no top-level side effects.Closes #349, closes #350.
🤖 Generated with Claude Code