MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolveReferencesBatched

Method resolveReferencesBatched

src/index.ts:2356–2392  ·  view source on GitHub ↗

* Resolve references in batches to keep memory bounded on large codebases. * Processes chunks of unresolved refs, persisting results after each batch.

(
    onProgress?: (current: number, total: number) => void,
    onSynthesisProgress?: (done: number, total: number) => void,
    // The WAL valve's writer-side backstop, threaded into the batch loop's
    // pool-idle boundaries. Without it the valve's only lever during
    // resolution is timer-driven passive checkpoints, which the pool's
    // continuous reads keep perpetually partial — the WAL then accretes the
    // whole phase's write volume (22GB on a 4.6GB DB at kernel scale).
    backpressure?: () => Promise<void> | null,
    synthesize: boolean = true,
    // The caller has just re-detected the frameworks on this index, so the
    // resolver pool's workers needn't each read the project again to do it.
    frameworksCurrent: boolean = false,
    // Run right before the resolver pool starts (see resolveAndPersistBatched).
    beforePool?: () => void
  )

Source from the content-addressed store, hash-verified

2354 * Processes chunks of unresolved refs, persisting results after each batch.
2355 */
2356 async resolveReferencesBatched(
2357 onProgress?: (current: number, total: number) => void,
2358 onSynthesisProgress?: (done: number, total: number) => void,
2359 // The WAL valve's writer-side backstop, threaded into the batch loop's
2360 // pool-idle boundaries. Without it the valve's only lever during
2361 // resolution is timer-driven passive checkpoints, which the pool's
2362 // continuous reads keep perpetually partial — the WAL then accretes the
2363 // whole phase's write volume (22GB on a 4.6GB DB at kernel scale).
2364 backpressure?: () => Promise<void> | null,
2365 synthesize: boolean = true,
2366 // The caller has just re-detected the frameworks on this index, so the
2367 // resolver pool's workers needn't each read the project again to do it.
2368 frameworksCurrent: boolean = false,
2369 // Run right before the resolver pool starts (see resolveAndPersistBatched).
2370 beforePool?: () => void
2371 ): Promise<ResolutionResult> {
2372 return this.resolver.resolveAndPersistBatched(onProgress, undefined, onSynthesisProgress, {
2373 dbPath: this.db.getPath(),
2374 shareFrameworks: frameworksCurrent,
2375 beforePool,
2376 // Bulk-edge-load hooks: on big runs the resolver drops the non-unique
2377 // edge indexes for the batch loop and recreates them before synthesis
2378 // (which reads kind-keyed). Concurrent readers (a daemon serving this
2379 // project mid-index) stay CORRECT during the window — target/kind reads
2380 // just degrade to scans until the recreate.
2381 bulkEdgeLoad: {
2382 begin: () => this.db.beginBulkEdgeLoad(),
2383 end: () => this.db.endBulkEdgeLoad({ deferSynthesisSite: true }),
2384 deferred: () => this.db.createSynthesisSiteIndex(),
2385 },
2386 refIndexLoad: {
2387 begin: () => this.db.beginBulkRefLoad(),
2388 end: () => this.db.endBulkRefLoad(),
2389 },
2390 backpressure,
2391 }, synthesize);
2392 }
2393
2394 /**
2395 * References extracted but never attempted by a resolution pass. Zero on a

Callers 4

indexAllMethod · 0.95
syncMethod · 0.95
indexFunction · 0.80

Calls 7

getPathMethod · 0.80
beginBulkEdgeLoadMethod · 0.80
endBulkEdgeLoadMethod · 0.80
beginBulkRefLoadMethod · 0.80
endBulkRefLoadMethod · 0.80

Tested by 1

indexFunction · 0.64