Skip to content

feat: add ctx map — token-budgeted PageRank repo map#5

Merged
saldestechnology merged 4 commits into
mainfrom
feat/map
Jul 9, 2026
Merged

feat: add ctx map — token-budgeted PageRank repo map#5
saldestechnology merged 4 commits into
mainfrom
feat/map

Conversation

@saldestechnology

Copy link
Copy Markdown
Collaborator

Summary

PR 6 of 7 in the Quality Intelligence Suite. Stacked on #2 (feat/quality-foundation) — will be retargeted to main once #2 merges; review only the top 3 commits until then.

  • New ctx map command: 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.
  • Ranks cached in a new symbol_rank table (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.
  • Deviation worth reviewer attention: subcommand --format must reuse the global OutputFormat type (differing clap downcast types on the same arg id panic at runtime), so OutputFormat gains a Text variant — text becomes an alias for plain in other commands.

Test plan

  • 16 new tests: PageRank correctness/dangling/determinism on hand-built graphs; budget compliance across 7 budgets × 3 formats; hub-symbol-appears/leaf-absent on a 23-file indexed fixture; focus by glob and name; cache populate → reindex clears → repopulate; byte-identical repeats.
  • cargo test (196 green), clippy -D warnings, fmt --check, --no-default-features build — all clean.

🤖 Generated with Claude Code

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.
@saldestechnology
saldestechnology deleted the branch main July 9, 2026 15:38
@saldestechnology
saldestechnology changed the base branch from feat/quality-foundation to main July 9, 2026 15:41
# Conflicts:
#	CHANGELOG.md
#	docs/json-output.md
#	src/db/mod.rs
#	src/db/schema.rs
#	src/main.rs
@saldestechnology
saldestechnology merged commit ce658d0 into main Jul 9, 2026
5 checks passed
@saldestechnology
saldestechnology deleted the feat/map branch July 9, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant