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

Method resolveReferencesBatched

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

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