feat: add ctx map — token-budgeted PageRank repo map#5
Merged
Conversation
Compute PageRank (damping 0.85, L1 convergence 1e-6, dangling-node mass redistribution) over resolved calls/imports/extends/implements edges. Scores are cached in a new symbol_rank table (created lazily via CREATE TABLE IF NOT EXISTS, so existing indexes self-heal without a schema version bump) and invalidated whenever the indexer changes the graph: full/parallel/single-file reindex, cleanup of deleted files, and watch-mode deletions. All floating-point accumulation happens in fixed node order, so identical index state yields bit-identical ranks.
ctx map [--budget N] [--focus PATH|SYMBOL] [--format text|markdown|json] emits the highest-ranked symbols (file path, signature, kind, line) grouped by file until the token budget (estimated as ceil(chars / 4)) is exhausted. Roughly the first 10% of the budget is a compact project tree (top two directory levels, deeper paths collapsed) reusing the existing tree renderer. --focus boosts a path glob or symbol name and its 1-hop neighbors 10x in memory. Output is byte-identical for identical index state; the global --json flag forces JSON format. Intended for SessionStart hooks that prime AI assistants with a stable overview.
# Conflicts: # CHANGELOG.md # docs/json-output.md # src/db/mod.rs # src/db/schema.rs # src/main.rs
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
PR 6 of 7 in the Quality Intelligence Suite. Stacked on #2 (
feat/quality-foundation) — will be retargeted tomainonce #2 merges; review only the top 3 commits until then.ctx mapcommand: a token-budgeted orientation summary ranked by PageRank over the symbol graph (calls/imports/extends/implements edges; damping 0.85, bit-deterministic power iteration), intended for Claude Code SessionStart hooks.symbol_ranktable (FK-cascaded, no schema-version bump — old DBs self-heal), invalidated by incremental indexing and recomputed lazily.--budget 2000(chars/4 token heuristic, documented), first ~10% reserved for a 2-level project tree reusing the existing renderer; consecutive same-file symbols grouped under one header.--focus <path-glob|symbol>: 10× boost of the focus set + 1-hop neighbors, renormalized in memory.--format text|markdown|json; deterministic (byte-identical) output for identical index state.--formatmust reuse the globalOutputFormattype (differing clap downcast types on the same arg id panic at runtime), soOutputFormatgains aTextvariant —textbecomes an alias forplainin other commands.Test plan
cargo test(196 green),clippy -D warnings,fmt --check,--no-default-featuresbuild — all clean.🤖 Generated with Claude Code