You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-ups for the GraphRAG prompt compiler (#19, shipped in #219), capturing design extensions raised by @kehansama on #19. v1 ships a fixed --depth 2, INTERNAL-only neighbours, source snippet, and a lightweight <domain> block; the items below are the next rungs that are specific to the cgis context compiler.
Note: @kehansama's broader insights already have homes — #25 (Prompt-as-Memory / multi-dimensional change memory + negative examples), #16 (DuckDB analytical layer / centrality), #60 (hybrid vector-graph retrieval). This issue intentionally scopes ONLY the compiler-side work and points at those rather than duplicating them.
1. Adaptive depth (leaf vs hub)
Replace the fixed depth with a strategy keyed on the focal node's position in the graph: a bug-fix in a leaf wants depth 1 (immediate neighbours); a refactor of a core abstraction wants depth 3+. @kehansama's heuristic:
For hub nodes the subgraph can still explode. Rank subgraph nodes by betweenness/degree centrality and prune low-centrality branches when the estimated token count crosses a budget — keeping structurally-important context, dropping noise. The centrality computation is exactly what #16 (DuckDB layer) provides; this issue is just the budget-pruning consumer in the compiler. Blocked on #16.
3. Full L3 domain-graph in the <domain> block
v1 surfaces only the focal node's own domain tags. Extend <domain> to the domain-to-domain dependency sub-graph ("this function is part of the auth boundary; see also the permission model") so semantic tasks ("add authentication to this API") get why it matters, not just what connects to what. Builds on the quotient/#186 domain-graph + #47 ontology work.
4. Optional --format mermaid
Reuse MermaidCompiler for a human/visual rendering of the same subgraph, behind a flag — keeping the lean XML lists the default.
Credit: insights from @kehansama's review on #19. Meta-memory / RAG-eval (TruLens, context-effectiveness scoring, negative examples) tracked on #25, not here.
Note for the centrality-budgeting item: betweenness centrality lands here (reassigned from #231). Rationale: betweenness is all-pairs-shortest-paths, impractical as a whole-graph SQL query — but the pruning operates on the small ego-graph the PromptCompiler (#19) already builds, so a plain-Python Brandes' over that subgraph is cheap and exact. The DuckDB layer (#16/#233) provides whole-graph PageRank for the cheaper 'rank by importance' variant if a SQL-side approximation is preferred.
Absorbing #60 (hybrid vector-graph retrieval) as the semantic rung after the lexical one (#206), and the context-compression measurement from #36 (CGIS context bytes vs. naive file dump).
Prior art for "centrality budgeting", from colbymchenry/codegraph (MIT). Its codegraph_explore is the closest thing to what this issue describes (src/mcp/tools.ts):
Entry is free text, not an FQN. Seeds come from exact symbol names in the query, camelCase segments (damped ×0.6), stem-prefix matches and FTS5 bm25. File paths named in the query are pinned and funded first. Today cgis context needs a known FQN, so an agent has to find first.
Ranking is a random walk with restart over the candidate subgraph (calls, references, extends, imports…), with the restart mass spread over the seeds (computeGraphRelevance, ~L3998). A file with a text match but no graph mass is dropped. The 1–2 most central matching files get a bigger budget.
The budget scales with repo size (getExploreOutputBudget, L287–380): 13K chars below 150 files, up to 24K above 500 (kept under the host's ~25K inline tool-result limit). It is split across files in proportion to relevance, with at most 70% per file. Siblings off the main path are reduced to skeletons.
Output: line-numbered source grouped by file, the call path among the symbols the query names, a blast-radius footer (locations only), and "files not shown" pointers.
Suggested split: keep this issue for adaptive depth plus RWR-based budgeting, add an optional free-text query entry point, and measure with the agent A/B in #543 (their "sufficiency" metric shows whether the budget went to the right files).
Activity
feat(metrics): DuckDB analytical layer — cgis metrics (#16, slice 1)
feat(metrics): DuckDB analytical layer — `cgis metrics` (#16, slice 1) (
zaebee commentedon Jun 13, 2026
Note for the centrality-budgeting item: betweenness centrality lands here (reassigned from #231). Rationale: betweenness is all-pairs-shortest-paths, impractical as a whole-graph SQL query — but the pruning operates on the small ego-graph the PromptCompiler (#19) already builds, so a plain-Python Brandes' over that subgraph is cheap and exact. The DuckDB layer (#16/#233) provides whole-graph PageRank for the cheaper 'rank by importance' variant if a SQL-side approximation is preferred.
feat(metrics): vectorized PageRank — critical-nodes ranking (#231) (#233
zaebee commentedon Oct 2, 2026
Absorbing #60 (hybrid vector-graph retrieval) as the semantic rung after the lexical one (#206), and the context-compression measurement from #36 (CGIS context bytes vs. naive file dump).
Generated by Claude Code
zaebee commentedon Oct 2, 2026
Prior art for "centrality budgeting", from colbymchenry/codegraph (MIT). Its
codegraph_exploreis the closest thing to what this issue describes (src/mcp/tools.ts):cgis contextneeds a known FQN, so an agent has tofindfirst.computeGraphRelevance, ~L3998). A file with a text match but no graph mass is dropped. The 1–2 most central matching files get a bigger budget.getExploreOutputBudget, L287–380): 13K chars below 150 files, up to 24K above 500 (kept under the host's ~25K inline tool-result limit). It is split across files in proportion to relevance, with at most 70% per file. Siblings off the main path are reduced to skeletons.Suggested split: keep this issue for adaptive depth plus RWR-based budgeting, add an optional free-text
queryentry point, and measure with the agent A/B in #543 (their "sufficiency" metric shows whether the budget went to the right files).Notes:
research/competitor-codegraph.md(idea 1).Generated by Claude Code
feat(bench): agent A/B harness for cgis vs no cgis (#547)