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

Method resolveReferencesBatched

src/index.ts:2282–2315  ·  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
  )

Source from the content-addressed store, hash-verified

2280 * Processes chunks of unresolved refs, persisting results after each batch.
2281 */
2282 async resolveReferencesBatched(
2283 onProgress?: (current: number, total: number) => void,
2284 onSynthesisProgress?: (done: number, total: number) => void,
2285 // The WAL valve's writer-side backstop, threaded into the batch loop's
2286 // pool-idle boundaries. Without it the valve's only lever during
2287 // resolution is timer-driven passive checkpoints, which the pool's
2288 // continuous reads keep perpetually partial — the WAL then accretes the
2289 // whole phase's write volume (22GB on a 4.6GB DB at kernel scale).
2290 backpressure?: () => Promise<void> | null,
2291 synthesize: boolean = true,
2292 // The caller has just re-detected the frameworks on this index, so the
2293 // resolver pool's workers needn't each read the project again to do it.
2294 frameworksCurrent: boolean = false
2295 ): Promise<ResolutionResult> {
2296 return this.resolver.resolveAndPersistBatched(onProgress, undefined, onSynthesisProgress, {
2297 dbPath: this.db.getPath(),
2298 shareFrameworks: frameworksCurrent,
2299 // Bulk-edge-load hooks: on big runs the resolver drops the non-unique
2300 // edge indexes for the batch loop and recreates them before synthesis
2301 // (which reads kind-keyed). Concurrent readers (a daemon serving this
2302 // project mid-index) stay CORRECT during the window — target/kind reads
2303 // just degrade to scans until the recreate.
2304 bulkEdgeLoad: {
2305 begin: () => this.db.beginBulkEdgeLoad(),
2306 end: () => this.db.endBulkEdgeLoad({ deferSynthesisSite: true }),
2307 deferred: () => this.db.createSynthesisSiteIndex(),
2308 },
2309 refIndexLoad: {
2310 begin: () => this.db.beginBulkRefLoad(),
2311 end: () => this.db.endBulkRefLoad(),
2312 },
2313 backpressure,
2314 }, synthesize);
2315 }
2316
2317 /**
2318 * 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