Skip to content

codegraph exports does not credit instanceof ClassName checks as consumers #1784

Description

@carlos-alm

Context

Discovered during Titan audit (phase: gauntlet, date: 2026-07-02).

Description

codegraph exports does not credit instanceof ClassName checks (or other bare-reference, no-call-site usages) as consumers, distinct root cause from #1724 (import-type not credited). CodegraphError (src/shared/errors.ts:15) shows consumerCount:0 via codegraph exports src/shared/errors.ts --json despite two real production (non-test) usages: src/cli.ts:5,29 (import { CodegraphError } + if (err instanceof CodegraphError)) and src/mcp/server.ts:17,190,192 (import { CodegraphError, ConfigError } + two instanceof CodegraphError checks).

By contrast, subclasses of CodegraphError that are consumed via new SubClass(...) constructor calls (e.g. ConfigError, consumerCount:23) ARE correctly credited. So the exports consumer-counter appears to only recognize call-expression sites (new X()), not instanceof/bare-reference usages — meaning any base/parent class whose primary cross-file use is instanceof narrowing will falsely present as a dead/unused export.

Additional Context

Repro:

codegraph exports src/shared/errors.ts -T --json
grep -n 'instanceof CodegraphError' src/cli.ts src/mcp/server.ts

Source

  • Titan phase: gauntlet
  • Severity: bug
  • Category: codegraph

Metadata

Metadata

Assignees

No one assigned

    Labels

    titan-auditIssues discovered during Titan audit

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions