fix(cli): include resolution + synthesizer edges in indexAll report (#413)
The orchestrator's per-file counter only sees extraction-phase edges, so the `X nodes, Y edges` line printed after `codegraph init -i` / `codegraph index` undercounts the graph — often by more than half on repos with heavy cross-file resolution (mall: 20 047 reported vs 45 629 actually in the DB). Snapshot (nodes, edges) before/after the full pipeline in `indexAll` and write the true delta back to the result. New lightweight `QueryBuilder.getNodeAndEdgeCount()` is one round-trip with no per-kind breakdowns. `indexFiles` (no resolution) and `sync` (uses `nodesUpdated`, not `nodesCreated`) are unaffected. Regression test added: `__tests__/integration/full-pipeline.test.ts > reports edgesCreated including resolution + synthesizer phases`.
This commit is contained in:
@@ -1445,6 +1445,19 @@ export class QueryBuilder {
|
||||
// Statistics
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* Lightweight (nodes, edges) count snapshot. Used around an index/sync
|
||||
* run to compute true additions across extraction + resolution +
|
||||
* synthesis — the per-phase counter in the orchestrator only sees
|
||||
* extraction's contribution, which is why the CLI summary under-reported
|
||||
* the edge count (resolution + synthesizer edges were invisible).
|
||||
*/
|
||||
getNodeAndEdgeCount(): { nodes: number; edges: number } {
|
||||
return this.db
|
||||
.prepare('SELECT (SELECT COUNT(*) FROM nodes) AS nodes, (SELECT COUNT(*) FROM edges) AS edges')
|
||||
.get() as { nodes: number; edges: number };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get graph statistics
|
||||
*/
|
||||
|
||||
@@ -325,6 +325,7 @@ export class CodeGraph {
|
||||
return { success: false, filesIndexed: 0, filesSkipped: 0, filesErrored: 0, nodesCreated: 0, edgesCreated: 0, errors: [{ message: 'Could not acquire file lock - another process may be indexing', severity: 'error' as const }], durationMs: 0 };
|
||||
}
|
||||
try {
|
||||
const before = this.queries.getNodeAndEdgeCount();
|
||||
const result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose);
|
||||
|
||||
// Re-detect frameworks now that the index is populated. The resolver
|
||||
@@ -367,6 +368,15 @@ export class CodeGraph {
|
||||
this.db.runMaintenance();
|
||||
}
|
||||
|
||||
// The orchestrator only sees extraction-phase counts; resolution and
|
||||
// synthesizer edges (often >50% of the graph on JVM repos) come later.
|
||||
// Recompute against the DB so the CLI summary reports the true totals.
|
||||
if (result.success && result.filesIndexed > 0) {
|
||||
const after = this.queries.getNodeAndEdgeCount();
|
||||
result.nodesCreated = after.nodes - before.nodes;
|
||||
result.edgesCreated = after.edges - before.edges;
|
||||
}
|
||||
|
||||
return result;
|
||||
} finally {
|
||||
this.fileLock.release();
|
||||
|
||||
Reference in New Issue
Block a user