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

Method resolveReferencesBatched

src/index.ts:2355–2391  ·  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

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