/** * @file The record a parallel build writes when one source's work is finished, and the check that admits it for reuse. * * A source is complete when its `SOURCE_COMPLETE.json` exists, was written under the settings and derivation this * build would use, and every file it lists is on disk with its recorded size and sha256. A store directory, a * per-source parquet manifest or a subset of finished parts never makes a source complete, because a worker can * die after writing any of them. The record is the last file a source's work writes. */ import { type RecordedFile } from "@mailwoman/core/crypto/hash"; import { PathBuilder, type PathBuilderLike } from "path-ts"; import type { AlignSettings } from "#build/checkpoint"; import type { RegionNames } from "#build/region/names"; import { type RegionCheckedRecord } from "#build/region/recount"; import { type DerivationInputs } from "#parquet/record"; import type { ParquetFileDescriptor } from "#parquet/writers"; import type { AdapterRunManifest } from "#runner"; import type { SplitName } from "#utils/split"; /** * The completion record's name in a source's state directory, `intermediate/sources//`. * * A `finish` worker writes it as the last file of the source's work. */ export declare const SOURCE_RECORD_FILE = "SOURCE_COMPLETE.json"; /** * Every setting outside the derivation that changes a source's files: * the align settings, the shuffle and the row cap. */ export interface SourceBuildSettings { align: AlignSettings; rowsPerFile: number; shuffleSeed: number; shuffleWindow: number; } /** * A finished source. */ export interface SourceCompletionRecord extends RegionCheckedRecord { settings: SourceBuildSettings; /** * The derivation every one of the source's parquet files was written under, * before the writer added each file's split and part. */ derivation: DerivationInputs; adapter: AdapterRunManifest; /** * The byte ranges of the canonical file the source was aligned in. * * The files do not depend on them. * They're recorded for a reader of the build. */ alignRanges: { start: number; end: number; }[]; /** * Every parquet file the source wrote, as the corpus manifest lists it. */ parts: ParquetFileDescriptor[]; /** * The coordinator merges each split's sorted source-id list into the split files. */ sourceIDs: Record; /** * The quarantine files of the source's align ranges, in range order. */ quarantine: RecordedFile[]; completed_at: string; /** * The earlier build's output directory the source's files were cloned from, * when `--reuse-from` imported it. */ reusedFrom?: string; } /** * The directory under `intermediate/` that holds one source's parallel-build state. */ export declare function sourceStateDirectory(intermediateDir: PathBuilderLike, source: string): PathBuilder; /** * The size and sha256 of a file as it stands. */ export declare function recordFile(path: PathBuilderLike): Promise; /** * What a build expects of a source it reuses. */ export interface ExpectedSource { settings: SourceBuildSettings; derivation: DerivationInputs; /** * The fingerprints of the region data this build reads, from `regionCheckFingerprints`. */ regionCheck: Record; /** * Reads this build's region data, for a record whose count was made under other data. */ readRegions: () => Promise; } /** * Why a source's completion record cannot be reused, or `null` with the record when it can. * * Every listed file is re-hashed, so a reused source is one whose bytes were read back in this build. * A record made under other region data comes back with its `region:unknown` count recounted. * * `acrossBuilds` compares a record from another build's output directory. * It leaves out the corpus version, because no row holds it. * * It also leaves out the builder version: that moves at each release, * and the code hash already covers the code. */ export declare function readReusableSource(sourceDir: PathBuilderLike, expected: ExpectedSource, opts?: { acrossBuilds?: boolean; }): Promise<{ record: SourceCompletionRecord; problem: null; } | { record: null; problem: string; }>; //# sourceMappingURL=source-record.d.ts.map