From 303cee166569a925e9ea55876bcbd65064a0ed5a Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:31:18 -0700 Subject: [PATCH 1/7] fix: bump native engine version to 3.0.0 (#305) Cargo.toml was still at 2.6.0 after the v3.0.0 release, causing codegraph info to report a stale native version and potentially triggering unnecessary full rebuilds from version mismatch detection. --- crates/codegraph-core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/codegraph-core/Cargo.toml b/crates/codegraph-core/Cargo.toml index 36aab6b2..64c042f0 100644 --- a/crates/codegraph-core/Cargo.toml +++ b/crates/codegraph-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "codegraph-core" -version = "2.6.0" +version = "3.0.0" edition = "2021" license = "Apache-2.0" From 930c2c4a6a681dffeb88d8f46dcf55a3a38fc4ad Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:39:46 -0700 Subject: [PATCH 2/7] feat: enable --cfg and --dataflow by default on builds CFG and dataflow analyses now run by default during `codegraph build`. Users who want faster builds can skip them with `--no-cfg` / `--no-dataflow`, following the same Commander --no-* convention as --no-incremental. - Replace opt-in --cfg/--dataflow with opt-out --no-cfg/--no-dataflow - Add dataflowMs to build return object (was tracked but not returned) - Update MCP tool descriptions to remove stale "Requires build --cfg" notes - Update fallback warnings in cfg.js and dataflow.js for legacy DBs Impact: 5 functions changed, 19 affected --- src/builder.js | 5 +++-- src/cfg.js | 2 +- src/cli.js | 4 ++-- src/dataflow.js | 6 +++--- src/mcp.js | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/builder.js b/src/builder.js index b11813e6..001fa0ac 100644 --- a/src/builder.js +++ b/src/builder.js @@ -1271,7 +1271,7 @@ export async function buildGraph(rootDir, opts = {}) { } _t.complexityMs = performance.now() - _t.complexity0; - // Opt-in CFG analysis (--cfg) + // CFG analysis (skip with --no-cfg) if (opts.cfg) { _t.cfg0 = performance.now(); try { @@ -1283,7 +1283,7 @@ export async function buildGraph(rootDir, opts = {}) { _t.cfgMs = performance.now() - _t.cfg0; } - // Opt-in dataflow analysis (--dataflow) + // Dataflow analysis (skip with --no-dataflow) if (opts.dataflow) { _t.dataflow0 = performance.now(); try { @@ -1387,6 +1387,7 @@ export async function buildGraph(rootDir, opts = {}) { rolesMs: +_t.rolesMs.toFixed(1), complexityMs: +_t.complexityMs.toFixed(1), ...(_t.cfgMs != null && { cfgMs: +_t.cfgMs.toFixed(1) }), + ...(_t.dataflowMs != null && { dataflowMs: +_t.dataflowMs.toFixed(1) }), }, }; } diff --git a/src/cfg.js b/src/cfg.js index 82493024..74a2c4d4 100644 --- a/src/cfg.js +++ b/src/cfg.js @@ -1241,7 +1241,7 @@ export function cfgData(name, customDbPath, opts = {}) { return { name, results: [], - warning: 'No CFG data found. Run `codegraph build --cfg` first.', + warning: 'No CFG data found. Rebuild with `codegraph build` (CFG is now included by default).', }; } diff --git a/src/cli.js b/src/cli.js index 48e8d29a..df564b92 100644 --- a/src/cli.js +++ b/src/cli.js @@ -105,8 +105,8 @@ program .command('build [dir]') .description('Parse repo and build graph in .codegraph/graph.db') .option('--no-incremental', 'Force full rebuild (ignore file hashes)') - .option('--dataflow', 'Extract data flow edges (flows_to, returns, mutates)') - .option('--cfg', 'Build intraprocedural control flow graphs') + .option('--no-dataflow', 'Skip data flow edge extraction') + .option('--no-cfg', 'Skip control flow graph building') .action(async (dir, opts) => { const root = path.resolve(dir || '.'); const engine = program.opts().engine; diff --git a/src/dataflow.js b/src/dataflow.js index bdc95dc9..6592801a 100644 --- a/src/dataflow.js +++ b/src/dataflow.js @@ -734,7 +734,7 @@ export function dataflowData(name, customDbPath, opts = {}) { return { name, results: [], - warning: 'No dataflow data found. Run `codegraph build --dataflow` first.', + warning: 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', }; } @@ -876,7 +876,7 @@ export function dataflowPathData(from, to, customDbPath, opts = {}) { from, to, found: false, - warning: 'No dataflow data found. Run `codegraph build --dataflow` first.', + warning: 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', }; } @@ -1005,7 +1005,7 @@ export function dataflowImpactData(name, customDbPath, opts = {}) { return { name, results: [], - warning: 'No dataflow data found. Run `codegraph build --dataflow` first.', + warning: 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', }; } diff --git a/src/mcp.js b/src/mcp.js index eb8d1f0d..a63ff873 100644 --- a/src/mcp.js +++ b/src/mcp.js @@ -638,7 +638,7 @@ const BASE_TOOLS = [ }, { name: 'cfg', - description: 'Show intraprocedural control flow graph for a function. Requires build --cfg.', + description: 'Show intraprocedural control flow graph for a function.', inputSchema: { type: 'object', properties: { @@ -658,7 +658,7 @@ const BASE_TOOLS = [ }, { name: 'dataflow', - description: 'Show data flow edges or data-dependent blast radius. Requires build --dataflow.', + description: 'Show data flow edges or data-dependent blast radius.', inputSchema: { type: 'object', properties: { From 2a410999400858c9c87b2cb2cbaaf6fff1f8bf16 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:40:13 -0700 Subject: [PATCH 3/7] style: fix Biome line-length formatting for warning strings Impact: 4 functions changed, 7 affected --- src/cfg.js | 3 ++- src/dataflow.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cfg.js b/src/cfg.js index 74a2c4d4..67dd3338 100644 --- a/src/cfg.js +++ b/src/cfg.js @@ -1241,7 +1241,8 @@ export function cfgData(name, customDbPath, opts = {}) { return { name, results: [], - warning: 'No CFG data found. Rebuild with `codegraph build` (CFG is now included by default).', + warning: + 'No CFG data found. Rebuild with `codegraph build` (CFG is now included by default).', }; } diff --git a/src/dataflow.js b/src/dataflow.js index 6592801a..ba64a96a 100644 --- a/src/dataflow.js +++ b/src/dataflow.js @@ -734,7 +734,8 @@ export function dataflowData(name, customDbPath, opts = {}) { return { name, results: [], - warning: 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', + warning: + 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', }; } @@ -876,7 +877,8 @@ export function dataflowPathData(from, to, customDbPath, opts = {}) { from, to, found: false, - warning: 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', + warning: + 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', }; } @@ -1005,7 +1007,8 @@ export function dataflowImpactData(name, customDbPath, opts = {}) { return { name, results: [], - warning: 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', + warning: + 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).', }; } From b20b7eb1ca6da0e493a3268ff6d8d0ace6563ae2 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:47:24 -0700 Subject: [PATCH 4/7] docs: update README to reflect default-on cfg/dataflow --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f0cba4f5..aa32b8c9 100644 --- a/README.md +++ b/README.md @@ -208,8 +208,8 @@ Full agent setup: [AI Agent Guide](docs/guides/ai-agent-guide.md) · [CLAU | 📋 | **Composite audit** | Single `audit` command combining explain + impact + health metrics per function — one call instead of 3-4 | | 🚦 | **Triage queue** | `triage` merges connectivity, hotspots, roles, and complexity into a ranked audit priority queue | | 📦 | **Batch querying** | Accept a list of targets and return all results in one JSON payload — enables multi-agent parallel dispatch | -| 🔬 | **Dataflow analysis** | Track how data moves through functions with `flows_to`, `returns`, and `mutates` edges — opt-in via `build --dataflow` (JS/TS) | -| 🧩 | **Control flow graph** | Intraprocedural CFG construction for all 11 languages — `cfg` command with text/DOT/Mermaid output, opt-in via `build --cfg` | +| 🔬 | **Dataflow analysis** | Track how data moves through functions with `flows_to`, `returns`, and `mutates` edges — included by default (JS/TS), skip with `--no-dataflow` | +| 🧩 | **Control flow graph** | Intraprocedural CFG construction for all 11 languages — `cfg` command with text/DOT/Mermaid output, included by default, skip with `--no-cfg` | | 🔎 | **AST node querying** | Stored queryable AST nodes (calls, `new`, string, regex, throw, await) — `ast` command with SQL GLOB pattern matching | | 🧬 | **Expanded node/edge types** | `parameter`, `property`, `constant` node kinds with `parent_id` for sub-declaration queries; `contains`, `parameter_of`, `receiver` edge kinds | | 📊 | **Exports analysis** | `exports ` shows all exported symbols with per-symbol consumers, re-export detection, and counts | @@ -327,7 +327,7 @@ codegraph ast -k call # Filter by kind: call, new, string, regex codegraph ast -k throw --file src/ # Combine kind and file filters ``` -> **Note:** Dataflow requires `codegraph build --dataflow` (JS/TS only). CFG requires `codegraph build --cfg`. Both are opt-in to keep default builds fast. +> **Note:** Dataflow (JS/TS only) and CFG are included by default. Use `--no-dataflow` / `--no-cfg` for faster builds. ### Audit, Triage & Batch From 909bc8a4c364c04ae8d7b889108a0b395984525d Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:53:54 -0700 Subject: [PATCH 5/7] fix: default cfg/dataflow to true for programmatic API calls Impact: 1 functions changed, 0 affected --- src/builder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builder.js b/src/builder.js index 001fa0ac..dba24641 100644 --- a/src/builder.js +++ b/src/builder.js @@ -1272,7 +1272,7 @@ export async function buildGraph(rootDir, opts = {}) { _t.complexityMs = performance.now() - _t.complexity0; // CFG analysis (skip with --no-cfg) - if (opts.cfg) { + if (opts.cfg !== false) { _t.cfg0 = performance.now(); try { const { buildCFGData } = await import('./cfg.js'); @@ -1284,7 +1284,7 @@ export async function buildGraph(rootDir, opts = {}) { } // Dataflow analysis (skip with --no-dataflow) - if (opts.dataflow) { + if (opts.dataflow !== false) { _t.dataflow0 = performance.now(); try { const { buildDataflowEdges } = await import('./dataflow.js'); From aa5b9891fa34cf25b347953112f88e15b0ffe15e Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Tue, 3 Mar 2026 20:11:40 -0700 Subject: [PATCH 6/7] fix: apply opts !== false pattern to incremental build checks Impact: 1 functions changed, 0 affected --- src/builder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/builder.js b/src/builder.js index dba24641..8a1862c4 100644 --- a/src/builder.js +++ b/src/builder.js @@ -522,9 +522,9 @@ export async function buildGraph(rootDir, opts = {}) { } if (!isFullBuild && parseChanges.length === 0 && removed.length === 0) { - // Check if optional analysis was requested but never computed + // Check if default analyses were never computed (e.g. legacy DB) const needsCfg = - opts.cfg && + opts.cfg !== false && (() => { try { return db.prepare('SELECT COUNT(*) as c FROM cfg_blocks').get().c === 0; @@ -533,7 +533,7 @@ export async function buildGraph(rootDir, opts = {}) { } })(); const needsDataflow = - opts.dataflow && + opts.dataflow !== false && (() => { try { return ( From 7b912620d5083cb0c4a56169ce2d1fc9dd63530f Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Tue, 3 Mar 2026 20:25:31 -0700 Subject: [PATCH 7/7] fix: needsDataflow check was querying wrong table (edges vs dataflow) Impact: 1 functions changed, 0 affected --- src/builder.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/builder.js b/src/builder.js index 8a1862c4..afe47307 100644 --- a/src/builder.js +++ b/src/builder.js @@ -536,13 +536,7 @@ export async function buildGraph(rootDir, opts = {}) { opts.dataflow !== false && (() => { try { - return ( - db - .prepare( - "SELECT COUNT(*) as c FROM edges WHERE kind IN ('flows_to','returns','mutates')", - ) - .get().c === 0 - ); + return db.prepare('SELECT COUNT(*) as c FROM dataflow').get().c === 0; } catch { return true; }