/** * Partition the canonical file set across shards by longest-matching root dir. * * Phase 1 of graph-sharded-exact-parity. The sharded engine used to RE-DERIVE * each shard's files from that package's own tsconfig — which excludes the * package's `__fixtures__` tree AND (for some packages) its test files — so it * silently dropped files the exact engine kept. The fix: enumerate the project * once (root discovery → {@link resolveCanonicalFileSet}), then ASSIGN each * canonical file to a shard here. Discovery now only supplies shard BOUNDARIES * (rootDir + configPath), never the file set. * * Assignment rule: each file goes to the unit whose `rootDir` is its LONGEST * matching path prefix (so a file under `packages/foo/src/...` lands in the * `foo` unit, not a shorter-prefix ancestor unit). Files under NO unit's * rootDir — root scripts, `.config`, files in packages without a tsconfig — * fall into a synthetic ROOT shard anchored at the project root + root tsconfig. * * Invariant (asserted by callers' tests): `union(shard.files) === canonicalFiles` * and every file lands in EXACTLY one shard — the partition is total and * disjoint, which is what makes the merged sharded catalog equal the exact one. */ import type { Shard } from './shard-model.js'; /** Stable id of the synthetic catch-all shard that owns files under no unit. */ export declare const ROOT_SHARD_ID = ":root"; /** A shard boundary derived from discovery: where a unit lives + its config anchor. */ export interface ShardBoundary { /** Stable unit id (e.g. `pkg:core`). MUST NOT be {@link ROOT_SHARD_ID}. */ readonly id: string; /** Absolute root dir the unit's files live under. */ readonly rootDir: string; /** Absolute config anchor (tsconfig.json) for the unit, if any. */ readonly configPathAbs?: string; } /** Inputs to {@link partitionFilesIntoShards}. */ export interface PartitionInput { /** The canonical (fixture-excluded) project-wide file set — absolute paths. */ readonly canonicalFiles: readonly string[]; /** Unit boundaries from discovery (rootDir + config anchor). */ readonly units: readonly ShardBoundary[]; /** Absolute project root — the synthetic root shard's rootDir. */ readonly projectRoot: string; /** Absolute root config anchor (root tsconfig.json), threaded onto the root shard. */ readonly rootConfigPathAbs?: string; } /** * Assign each canonical file to the unit whose rootDir is its longest matching * prefix; files under no unit go to a synthetic ROOT shard. Returns only * non-empty shards. Deterministic: shard order follows the input unit order * (root shard last); each shard's files preserve canonical input order. */ export declare function partitionFilesIntoShards(input: PartitionInput): Shard[]; //# sourceMappingURL=partition-files.d.ts.map