/** * Shard runner — drives N shard workers in parallel and collects their * serializable `ShardBuildResult` fragments. * * Each shard is built in its own child process (`graph-shard-worker`), so * heap is isolated per shard: N shards × per-shard budget ≈ total budget, * the same memory-scaling property the legacy `--workspace` runner has. * Concurrency is capped at `cpus()-1` by default. A worker that exits * non-zero is surfaced as a `ShardFailure` attributable to its shard id * rather than aborting the whole build. * * The spec is handed to the worker via a temp FILE (not argv) because a * shard can enumerate thousands of files, well past the OS argv limit. */ import type { Shard, ShardBuildResult } from './shard-model.js'; import type { GraphLanguageAdapter } from '../../lang-adapter/types.js'; import type { CatalogRepo } from '../../persistence/catalog-repo.js'; import type { ResolutionMode } from '../../types.js'; export interface RunShardsInput { readonly shards: readonly Shard[]; /** Common project root — every fragment's filePaths resolve against it. */ readonly projectRoot: string; /** CLI entry script (`process.argv[1]`); children run `node graph-shard-worker `. */ readonly cliScript: string; readonly resolutionMode: ResolutionMode; /** Concurrency cap. Default: `max(1, cpus()-1)`. */ readonly concurrency?: number; } /** A shard whose worker exited non-zero — attributable, non-fatal. */ export interface ShardFailure { readonly shardId: string; readonly exitCode: number; readonly stderr: string; } export interface RunShardsOutput { readonly fragments: readonly ShardBuildResult[]; readonly failures: readonly ShardFailure[]; } /** * Build every shard in a bounded parallel pool. Always resolves; per-shard * failures are collected in `failures` (never thrown) so one bad shard * doesn't sink the build. */ export declare function runShardsInParallel(input: RunShardsInput): Promise; /** Partition of a build's shards into reusable-from-cache vs needs-rebuild. */ export interface ShardWorkPlan { /** Fragments loaded verbatim from the per-shard cache — no worker runs. */ readonly cached: readonly ShardBuildResult[]; /** Shards whose files (or config/mode) changed — a worker must rebuild them. */ readonly toBuild: readonly Shard[]; } /** * Decide, per shard, whether its cached fragment is still valid (config * key + files fingerprint match) and can be reused without a worker, or * whether the shard must be rebuilt. This is the incremental-parse fix: * unchanged shards skip parse entirely. With `useCache=false` (or no * repo) every shard is rebuilt. * * Cheap by design — it stats each shard's files (fingerprint) and reads * each shard's config (cacheKey); no parsing, no worker spawn. */ export declare function planShardWork(shards: readonly Shard[], repo: CatalogRepo | null, adapter: GraphLanguageAdapter, resolutionMode: ResolutionMode, useCache: boolean): ShardWorkPlan; //# sourceMappingURL=shard-runner.d.ts.map