Skip to content

Incremental sync misses cross-file relations after a new export is added #1240

Description

@loadcosmos

Summary

On CodeGraph v1.3.1, incremental sync can leave the graph semantically stale when a changed file introduces an export that satisfies an existing import/call in an unchanged file.

The index reports a clean state (pendingChanges = 0, pendingRefs = 0, state = "complete", reindexRecommended = false), but a full index of the exact same source snapshot adds missing edges.

Minimal TypeScript reproduction

Initial a.ts:

import { greet } from './b';

export function run(): number {
  return greet();
}

Initial b.ts:

export function other(): number {
  return 1;
}
  1. Run a full initial index:
codegraph init --force .
  1. Replace b.ts with:
export function greet(): number {
  return 42;
}
  1. Run incremental sync and inspect the graph:
codegraph sync --quiet .
codegraph status --json .

Actual result after sync

  • fileCount: 2
  • nodeCount: 5
  • edgeCount: 4
  • edge kinds: contains: 3, imports: 1
  • pendingChanges: { added: 0, modified: 0, removed: 0 }
  • pendingRefs: 0

Then run a full index without changing any source file:

codegraph index --force --quiet .
codegraph status --json .

Result after full index

  • fileCount: 2
  • nodeCount: 5
  • edgeCount: 6
  • edge kinds: calls: 1, contains: 3, imports: 2
  • pendingChanges: { added: 0, modified: 0, removed: 0 }
  • pendingRefs: 0

Expected result

For an unchanged source snapshot, sync should produce the same resolved cross-file graph as a full index. In this case, the import/call in unchanged a.ts should be resolved after b.ts adds greet.

Impact

The MCP file watcher uses incremental sync, so impact, caller/callee, and flow results can silently omit cross-file relationships after a normal edit. Status does not indicate that a full re-index is needed.

This appears consistent with reference resolution being scoped to changed files: the unresolved reference in unchanged a.ts is not revisited after b.ts gains the matching export.

Environment

  • CodeGraph: 1.3.1
  • Linux x64
  • TypeScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions