Skip to content

fix(cli): erase clears all builder-owned files (#349, #350)#364

Merged
HumanBean17 merged 2 commits into
masterfrom
fix/erase-cleanup
Jul 4, 2026
Merged

fix(cli): erase clears all builder-owned files (#349, #350)#364
HumanBean17 merged 2 commits into
masterfrom
fix/erase-cleanup

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

What

Follow-up to #346 / PR #348. erase removed code_graph.lbug, cocoindex.db, and .graph_hashes.json but left the rest of the graph builder's bookkeeping on disk:

Fix

_cmd_erase hardcoded 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 the FileHashTracker / crash-marker code that owns them.
  • FileHashTracker and incremental_rebuild now reference the constants instead of literals.
  • _cmd_erase derives its delete + preview list from BUILDER_OWNED_INDEX_FILES, so erase and the builder cannot drift.

Test

New test_erase_removes_increment_marker_and_hash_store_tmp seeds the crash marker + the orphan temp and asserts erase removes both. TDD: failed first (red on the marker assertion), then green after the fix.

.venv/bin/python -m pytest tests/test_java_codebase_rag_cli.py -q
# 62 passed

Notes

  • No re-index required, no env-var change, no ontology_version bump — pure lifecycle/CLI cleanup.
  • build_ast_graph was previously only run as a subprocess; this is the first import 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

HumanBean17 and others added 2 commits July 3, 2026 23:11
…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>
@HumanBean17

Copy link
Copy Markdown
Owner Author

Addressed a finding from a multi-agent review pass:

Top-level build_ast_graph import cost (low)from build_ast_graph import BUILDER_OWNED_INDEX_FILES at module top pulled numpy/ladybug/pyarrow/tree_sitter on every CLI invocation (~54ms; -X importtime: cli cumulative 44ms → 98ms), including --help, violating cli.py's own lazy-import header. Moved the import into _cmd_erase (the only user). After the move build_ast_graph is not imported at cli import time and cumulative is back to ~39ms. test_java_codebase_rag_cli.py 62 passed.

@HumanBean17 HumanBean17 merged commit 533909c into master Jul 4, 2026
1 check passed
@HumanBean17 HumanBean17 deleted the fix/erase-cleanup branch July 4, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant