Skip to content

bug: config.include and config.exclude are silently ignored #981

@carlos-alm

Description

@carlos-alm

Found during dogfooding v3.9.4

Severity: High
Command: codegraph build

Top-level include and exclude keys in .codegraphrc.json are declared in DEFAULTS (src/infrastructure/config.ts:17-18) but never read anywhere in the codebase. Users who configure them get no warning, no error, and no effect.

Reproduction

mkdir cfg-test && cd cfg-test
cat > a.js <<'EOF'
export function foo() { return bar(); }
export function bar() { return 1; }
EOF
cat > test.test.js <<'EOF'
import { foo } from './a.js';
export function testFoo() { return foo(); }
EOF

# No config: 2 files, 3 functions
npx codegraph build .
# Native build orchestrator completed: 5 nodes, 6 edges, 2 files

# With exclude config: should drop test.test.js, should be 1 file
cat > .codegraphrc.json <<'EOF'
{
  "exclude": ["**/*.test.js"]
}
EOF
rm -rf .codegraph && npx codegraph build .
# Native build orchestrator completed: 5 nodes, 6 edges, 2 files   <-- identical

Result with and without exclude is bit-for-bit identical. The config key is accepted and preserved (loadConfig returns it), but no code path consumes it.

Expected behavior

Either:

  1. Honor the include / exclude glob patterns when collecting files (the obvious behavior), or
  2. If intentionally unsupported, reject the key during config validation with a clear error.

Actual behavior

Silent no-op.

Root cause

src/domain/graph/builder/helpers.ts:collectFiles() only reads config.ignoreDirs (line 90):

const extraIgnore = config.ignoreDirs ? new Set(config.ignoreDirs) : null;

Grepping the entire src/ for config.include, config.exclude, .include, or .exclude patterns returns zero references to these config keys other than their default declarations at src/infrastructure/config.ts:17-18. Neither collectFiles nor any upstream filter uses them.

Suggested fix

Add include and exclude glob matching to collectFiles — e.g., after the extension check, if config.include is non-empty require a match, and if config.exclude is non-empty reject a match. Use a simple glob library or minimatch-equivalent.

Related

ignoreDirs (directory-level) works correctly. The gap is specifically file-level glob filtering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions