Repository navigation
Add self-scan DB tool for token-efficient LLM orientation - #901
Merged
Merged
Conversation
…icient orientation GitGalaxy already knows how to extract Structural Signatures about any repo it scans -- including its own. An LLM coding session working in this repo often re-derives basic structural facts (how big is this file, how many functions does it have, which files already exist for language X) via grep or an Explore subagent at the start of a task, both of which cost real tokens for exactly the kind of question this engine already answers about itself. This wraps `galaxyscope . --db-only` to regenerate docs/self_scan/gitgalaxy_master.db (gitignored, disposable, ~6-8s to rebuild) so that orientation questions can be answered with a near-zero-token `sqlite3` query instead. It does not replace reading actual file content -- the DB has no line numbers and doesn't parse dict-literal internals (e.g. it can't locate a specific language's entry inside language_standards.py's LANGUAGE_DEFINITIONS dict) -- it's for orientation and prioritization (file/function/class inventories, LOC, complexity, dependency-network scores), not symbol lookup. Deletes the DB before each regeneration rather than relying on the recorder's own DELETE-then-INSERT (keyed on repo_name+commit_hash) -- that only replaces rows from a run at the same commit, so rows from a previous commit would otherwise silently accumulate as HEAD moves. Also merges (rather than replaces) the subprocess environment when shelling out, since galaxyscope needs PATH/HOME to resolve git's commit hash -- a replaced env degrades commit_hash to "Unknown" instead of erroring, which is what caused the row-accumulation bug in the first place during manual testing. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
7 tasks done
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.
Summary
tests/tools/self_scan.py, a thin wrapper aroundgalaxyscope . --db-onlythat regeneratesdocs/self_scan/gitgalaxy_master.db— a SQLite database of this repo's own structural facts (per-file LOC/complexity/function-class counts, per-function complexity/args/calls_out_to, dependency-network scores).LANGUAGE_DEFINITIONS["scala"]starts insidelanguage_standards.py, for example) — it's for orientation/prioritization, not symbol lookup.*.db) and lives atdocs/self_scan/(sibling todocs/gitgalaxy_architecture_brief.md, outsidedocs/wiki/so it can't interfere with the mkdocs build — confirmed viamkdocs.yml'sdocs_dir: "docs/wiki"). Disposable, regenerated in ~6-8s.Bug found and fixed during manual testing
The native SQLite recorder DELETEs-then-INSERTs keyed on
(repo_name, commit_hash), so re-running it only replaces rows from a prior run at the same commit. My first draft of this script passed a replacement (not merged)env=to thegalaxyscopesubprocess call, which strippedPATH/HOMEand silently degraded git's commit-hash resolution to"Unknown"instead of erroring — so the second run's rows never matched the first run's key and just accumulated (179 files → 357, every file duplicated). Fixed by merging the parent env ({**os.environ, ...}) and, as defense in depth, having the script just delete the DB file before every regeneration rather than relying on the keyed replace at all (this DB is meant to reflect current state only, not history).Test plan
ruff check/ruff format --check/mypy— all cleanfile_pathrows, singlecommit_hashvalue) after the fixdocs/self_scan/gitgalaxy_master.dbdoes not show up ingit status(already covered by the existing*.dbgitignore rule)🤖 Generated with Claude Code