Skip to content

Commit ce25da7

Browse files
authored
Merge pull request #75 from optave/docs/backlog-and-roadmap-reorg
docs: integrate LLM features from planning doc into roadmap
2 parents 73f869a + 343f015 commit ce25da7

1 file changed

Lines changed: 126 additions & 12 deletions

File tree

roadmap/ROADMAP.md

Lines changed: 126 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ Codegraph is a strong local-first code graph CLI. This roadmap describes planned
1414
|-------|-------|-----------------|--------|
1515
| [**1**](#phase-1--rust-core) | Rust Core | Rust parsing engine via napi-rs, parallel parsing, incremental tree-sitter, JS orchestration layer | **Complete** (v1.3.0) |
1616
| [**2**](#phase-2--foundation-hardening) | Foundation Hardening | Parser registry, complete MCP, test coverage, enhanced config, multi-repo MCP | **Complete** (v1.4.0) |
17-
| [**3**](#phase-3--intelligent-embeddings) | Intelligent Embeddings | LLM-generated descriptions, hybrid search | Planned |
18-
| [**4**](#phase-4--natural-language-queries) | Natural Language Queries | `ask` command, conversational sessions | Planned |
17+
| [**3**](#phase-3--intelligent-embeddings) | Intelligent Embeddings | LLM-generated descriptions, hybrid search, build-time semantic metadata, module summaries | Planned |
18+
| [**4**](#phase-4--natural-language-queries) | Natural Language Queries | `ask` command, conversational sessions, LLM-narrated graph queries, onboarding tools | Planned |
1919
| [**5**](#phase-5--expanded-language-support) | Expanded Language Support | 8 new languages (12 → 20), parser utilities | Planned |
20-
| [**6**](#phase-6--github-integration--ci) | GitHub Integration & CI | Reusable GitHub Action, PR review, SARIF output | Planned |
21-
| [**7**](#phase-7--interactive-visualization--advanced-features) | Visualization & Advanced | Web UI, dead code detection, monorepo, agentic search | Planned |
20+
| [**6**](#phase-6--github-integration--ci) | GitHub Integration & CI | Reusable GitHub Action, LLM-enhanced PR review, visual impact graphs, SARIF output | Planned |
21+
| [**7**](#phase-7--interactive-visualization--advanced-features) | Visualization & Advanced | Web UI, dead code detection, monorepo, agentic search, refactoring analysis | Planned |
2222

2323
### Dependency graph
2424

2525
```
2626
Phase 1 (Rust Core)
2727
└──→ Phase 2 (Foundation Hardening)
28-
├──→ Phase 3 (Embeddings) ──→ Phase 4 (NL Queries)
28+
├──→ Phase 3 (Embeddings + Metadata) ──→ Phase 4 (NL Queries + Narration)
2929
├──→ Phase 5 (Languages)
30-
└──→ Phase 6 (GitHub/CI)
31-
Phases 1-4 ──→ Phase 7 (Visualization & Advanced)
30+
└──→ Phase 6 (GitHub/CI) ←── Phase 3 (risk_score, side_effects)
31+
Phases 1-4 ──→ Phase 7 (Visualization + Refactoring Analysis)
3232
```
3333

3434
---
@@ -243,6 +243,33 @@ Combine vector similarity with keyword matching.
243243

244244
**Affected files:** `src/embedder.js`, `src/db.js`
245245

246+
### 3.4 — Build-time Semantic Metadata
247+
248+
Enrich nodes with LLM-generated metadata beyond descriptions. Computed incrementally at build time (only for changed nodes), stored as columns on the `nodes` table.
249+
250+
| Column | Content | Example |
251+
|--------|---------|---------|
252+
| `side_effects` | Mutation/IO tags | `"writes DB"`, `"sends email"`, `"mutates state"` |
253+
| `complexity_notes` | Responsibility count, cohesion rating | `"3 responsibilities, low cohesion — consider splitting"` |
254+
| `risk_score` | Fragility metric from graph centrality + LLM assessment | `0.82` (high fan-in + complex logic) |
255+
256+
- MCP tool: `assess <name>` — returns complexity rating + specific concerns
257+
- Cascade invalidation: when a node changes, mark dependents for re-enrichment
258+
259+
**Depends on:** 3.1 (LLM provider abstraction)
260+
261+
### 3.5 — Module Summaries
262+
263+
Aggregate function descriptions + dependency direction into file-level narratives.
264+
265+
- `module_summaries` table — one entry per file, re-rolled when any contained node changes
266+
- MCP tool: `explain_module <file>` — returns module purpose, key exports, role in the system
267+
- `naming_conventions` metadata per module — detected patterns (camelCase, snake_case, verb-first), flag outliers
268+
269+
**Depends on:** 3.1 (function-level descriptions must exist first)
270+
271+
> **Full spec:** See [llm-integration.md](./llm-integration.md) for detailed architecture, infrastructure table, and prompt design.
272+
246273
---
247274

248275
## Phase 4 — Natural Language Queries
@@ -297,6 +324,32 @@ Enables AI coding agents (Claude Code, Cursor, etc.) to ask codegraph questions
297324

298325
**Affected files:** `src/mcp.js`
299326

327+
### 4.4 — LLM-Narrated Graph Queries
328+
329+
Graph traversal + LLM narration for questions that require both structural data and natural-language explanation. Each query walks the graph first, then sends the structural result to the LLM for narration.
330+
331+
| Query | Graph operation | LLM adds |
332+
|-------|----------------|----------|
333+
| `trace_flow <entry>` | BFS from entry point to leaves | Sequential narrative: "1. handler validates → 2. calls createOrder → 3. writes DB" |
334+
| `trace_upstream <name>` | Recursive caller walk | Ranked suspects: "most likely cause is X because it modifies the same state" |
335+
| `effect_analysis <name>` | Full callee tree walk, aggregate `side_effects` | "Calling X will: write to DB (via Y), send email (via Z)" |
336+
| `dependency_path <A> <B>` | Shortest path(s) between two symbols | Narrates each hop: "A imports X from B because A needs to validate tokens" |
337+
338+
Pre-computed `flow_narratives` table caches results for key entry points at build time, invalidated when any node in the chain changes.
339+
340+
**Depends on:** 3.4 (`side_effects` metadata), 3.1 (descriptions for narration context)
341+
342+
### 4.5 — Onboarding & Navigation Tools
343+
344+
Help new contributors and AI agents orient in an unfamiliar codebase.
345+
346+
- `entry_points` query — graph finds roots (high fan-out, low fan-in) + LLM ranks by importance
347+
- `onboarding_guide` command — generates a reading order based on dependency layers
348+
- MCP tool: `get_started` — returns ordered list: "start here, then read this, then this"
349+
- `change_plan <description>` — LLM reads description, graph identifies relevant modules, returns touch points and test coverage gaps
350+
351+
**Depends on:** 3.5 (module summaries for context), 4.1 (query engine)
352+
300353
---
301354

302355
## Phase 5 — Expanded Language Support
@@ -377,9 +430,39 @@ Requires `gh` CLI. For each changed function:
377430
4. Generate review summary (optionally LLM-enhanced)
378431
5. Post as PR comment via `gh pr comment`
379432

433+
**LLM-enhanced mode** (when LLM provider configured):
434+
435+
- **Risk labels per node**: `low` (cosmetic / internal), `medium` (behavior change), `high` (breaking / public API)
436+
- **Review focus ranking**: rank affected files by risk × blast radius — "review this file first"
437+
- **Critical path highlighting**: shortest path from a changed function to a high-fan-in entry point
438+
- **Test coverage gaps**: cross-reference affected code with test file graph edges
439+
380440
**New file:** `src/github.js`
381441

382-
### 6.3 — SARIF Output
442+
### 6.3 — Visual Impact Graphs for PRs
443+
444+
Extend the existing `diff-impact --format mermaid` foundation with CI automation and LLM annotations.
445+
446+
**CI automation** (GitHub Action):
447+
1. `codegraph build .` (incremental, fast on CI cache)
448+
2. `codegraph diff-impact $BASE_REF --format mermaid -T` to generate the graph
449+
3. Post as PR comment — GitHub renders Mermaid natively in markdown
450+
4. Update on new pushes (edit the existing comment)
451+
452+
**LLM-enriched annotations** (when provider configured):
453+
- For each changed function: one-line summary of WHAT changed (from diff hunks)
454+
- For each affected caller: WHY it's affected — what behavior might change downstream
455+
- Node colors shift from green → yellow → red based on risk labels
456+
- Overall PR risk score (aggregate of node risks weighted by centrality)
457+
458+
**Historical context overlay:**
459+
- Annotate nodes with churn data: "this function changed 12 times in the last 30 days"
460+
- Highlight fragile nodes: high churn + high fan-in = high breakage risk
461+
- Track blast radius trends: "this PR's blast radius is 2× larger than your average"
462+
463+
**Depends on:** 6.1 (GitHub Action), 3.4 (`risk_score`, `side_effects`)
464+
465+
### 6.4 — SARIF Output
383466

384467
Add SARIF output format for cycle detection. SARIF integrates with GitHub Code Scanning, showing issues inline in the PR.
385468

@@ -452,6 +535,34 @@ codegraph agent-search "payment processing"
452535

453536
**New file:** `src/agentic-search.js`
454537

538+
### 7.5 — Refactoring Analysis
539+
540+
LLM-powered structural analysis that identifies refactoring opportunities. The graph provides the structural data; the LLM interprets it.
541+
542+
| Command | Graph operation | LLM adds |
543+
|---------|----------------|----------|
544+
| `split_analysis <file>` | Cluster tightly-coupled functions within a file | Proposed split, cross-boundary edges, circular import risk |
545+
| `extraction_candidates` | Find high fan-in, low internal coupling functions | Rank by utility: "pure helper" vs "has side effects, risky to move" |
546+
| `signature_impact <name>` | All call sites from graph edges | Suggested new signature, adapter pattern if needed, call sites to update |
547+
| `lint-names` | Detect naming patterns per module | Flag outliers against detected conventions (camelCase, snake_case, verb-first) |
548+
| `hotspots` | High fan-in + high fan-out + on many paths | Ranked fragility report with explanations, `risk_score` per node |
549+
| `boundary_analysis` | Graph clustering (tightly-coupled groups spanning modules) | Reorganization suggestions: "these 4 functions in 3 files all deal with auth" |
550+
551+
**Depends on:** 3.4 (`risk_score`, `complexity_notes`), 3.5 (module summaries)
552+
553+
### 7.6 — Auto-generated Docstrings
554+
555+
```bash
556+
codegraph annotate
557+
codegraph annotate --changed-only
558+
```
559+
560+
LLM-generated docstrings aware of callers, callees, and types. Diff-aware: only regenerate for functions whose code or dependencies changed. Stores in `docstrings` column on nodes table — does not modify source files unless explicitly requested.
561+
562+
**Depends on:** 3.1 (LLM provider abstraction), 3.4 (side effects context)
563+
564+
> **Full spec:** See [llm-integration.md](./llm-integration.md) for detailed architecture, infrastructure tables, and prompt design for all LLM-powered features.
565+
455566
---
456567

457568
## Verification Strategy
@@ -462,11 +573,11 @@ Each phase includes targeted verification:
462573
|-------|-------------|
463574
| **1** | Benchmark native vs WASM parsing on a large repo, verify identical output from both engines |
464575
| **2** | `npm test`, manual MCP client test for all tools, config loading tests |
465-
| **3** | Compare `codegraph search` quality before/after descriptions on a real repo |
466-
| **4** | `codegraph ask "How does import resolution work?"` against codegraph itself |
576+
| **3** | Compare `codegraph search` quality before/after descriptions; verify `side_effects` and `risk_score` populated for LLM-enriched builds |
577+
| **4** | `codegraph ask "How does import resolution work?"` against codegraph itself; verify `trace_flow` and `get_started` produce coherent narration |
467578
| **5** | Parse sample files for each new language, verify definitions/calls/imports |
468-
| **6** | Test PR in a fork, verify GitHub Action comment is posted |
469-
| **7** | `codegraph viz` loads, nodes are interactive, search works |
579+
| **6** | Test PR in a fork, verify GitHub Action comment with Mermaid graph and risk labels is posted |
580+
| **7** | `codegraph viz` loads; `hotspots` returns ranked list; `split_analysis` produces actionable output |
470581

471582
**Full integration test** after all phases:
472583

@@ -475,7 +586,10 @@ codegraph build .
475586
codegraph embed --describe # LLM-enhanced descriptions
476587
codegraph search "middleware error handling"
477588
codegraph ask "How does routing work?"
589+
codegraph trace_flow handleRequest # LLM-narrated execution flow
590+
codegraph hotspots # Fragility report with risk scores
478591
codegraph diff-impact HEAD~5
592+
codegraph review --pr 42 # LLM-enhanced PR review
479593
codegraph viz
480594
```
481595

0 commit comments

Comments
 (0)