/** * The exact bytes a version-2 run retains, written and read back whole. * * A source bundle's authoritative content lives in this database and nowhere * else. So writing it is one set of rows inside the creation transaction, and * reading it is a total re-derivation: every retained length, every source hash * and the bundle hash itself are recomputed from the BLOBs before anything is * handed back. A retained identity nobody can reproduce is not evidence of the * definition it claims. * * ## Missing and corrupt are different answers * * A manifest entry or a blob the store does not contain is absence: the run's * content is gone, and there is nothing here to repair. A path, a length, a * hash, a mapping or a bundle hash that disagrees is damage: what is retained * is there and no longer describes itself. Operators act on the two * differently, and neither is repaired by falling back to the original file, * the optional provenance, or the legacy Git reader. * * ## Hashing does not happen inside a transaction * * Recomputing a hash is an operation, and a lifecycle transaction body may not * suspend. So the rows are read synchronously inside the caller's transaction * and verified afterwards, still under the executor lock and still before any * lifecycle write. */ import type { DatabaseSync } from "node:sqlite"; import { type Operation, type Result } from "effection"; import type { GitRetainedDefinitionSourcesV1, RetainedDefinitionSources, SourceBundleRetainedDefinitionSourcesV2 } from "../lifecycle/source.js"; import { type GitWorkflowDefinitionV1 } from "../storage/definition.js"; import { type SourceBundleSnapshotEntryV2, type SourceBundleWorkflowDefinitionV2 } from "../storage/source-bundle.js"; /** * Retain the descriptor's complete manifest and its de-duplicated content. * * Synchronous and inside the caller's transaction, on a snapshot whose paths, * lengths and hashes have already been checked against the descriptor. Two * logical paths holding identical bytes reference one blob, because content is * keyed by its own hash and a second copy would be a second answer to the same * question. */ export declare function writeDefinitionSources(database: DatabaseSync, definition: SourceBundleWorkflowDefinitionV2, snapshot: readonly SourceBundleSnapshotEntryV2[]): void; /** One retained manifest row, as SQLite hands it back. */ interface ManifestRow { readonly path: string; readonly sourceHash: string; } /** One retained blob, as SQLite hands it back. */ interface BlobRow { readonly sourceHash: string; readonly byteLength: number; readonly content: Uint8Array; } /** Everything the source store holds, read inside the caller's transaction. */ export interface RetainedSourceRows { readonly manifest: readonly ManifestRow[]; readonly blobs: readonly BlobRow[]; } /** Read the whole source store, without deciding anything about it yet. */ export declare function readDefinitionSourceRows(database: DatabaseSync): RetainedSourceRows; /** * The retained source this descriptor names, re-derived from what is stored. * * Every check the issue settles, in the order an operator can act on: the * manifest must be exactly the descriptor's entries, every referenced blob must * exist, both retained lengths must equal the content's own, recomputing each * blob's hash must produce its key, no blob may be unreferenced, and the bundle * hash must be what the retained manifest and mapping produce. * * Nothing partial is ever returned. A closure with one source missing is not a * smaller closure, it is a different definition. */ export declare function verifyRetainedSources(definition: SourceBundleWorkflowDefinitionV2, rows: RetainedSourceRows): Operation>; /** * Hold a legacy reader's answer to the version-1 definition it was asked about. * * The adapter fetched it; this decides whether what came back is this run's. * Every term the descriptor pins is compared — the object format, the pinned * commit, the repository-relative path, the exact target, and the declared * component set with its paths and blob identities — because a reader that * returned another commit's bytes has not obtained this source, and none of * what it returned may execute. */ export declare function validateLegacySources(definition: GitWorkflowDefinitionV1, answered: RetainedDefinitionSources): Result; export {};