/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * Read/write helpers over the layer-contract tables. The parsed {@link LayerManifest} is the * camelCase face of `layer_manifest`; validation happens at BOTH ends so a hand-built or * corrupted layer fails loudly at open time rather than misbehaving downstream. */ import { CoverageBasis, LayerFreshnessPolicy, LayerTier, type LayerContractHandle } from "./schema.ts"; /** * Which spine columns a layer carries. At least one key is required. */ export interface SpineKeys { h3?: { column: string; resolution: number; }; /** * Column name holding WOF ids, when present. */ wofID?: string; /** * Column name holding `@mailwoman/address-id` keys, when present. */ addressID?: string; /** * The normalized-street column a shard is probed by, for layers keyed by STREET rather than by cell or id. * * Added because the contract's first three keys describe the two layer shapes that existed when it was written — a * cellular one (`poi.db`, H3) and an id-joined one — and the situs shards are a third. `address_point` and * `street_segment` carry no H3 cell, no WOF id and no address-id; they are probed on `(postcode | locality, * street_norm, number)`. Declaring one of the other three for them would name a column that does not exist, in the * field a consumer uses to join. */ street?: { column: string; }; } /** * Parsed manifest — see {@link LayerManifestTable} for the storage form. */ export interface LayerManifest { name: string; version: string; schemaVersion: number; tier: LayerTier; license: string; attribution?: string; source: string; sourceVintage: string; buildCmd: string; buildSHA: string; freshnessPolicy: LayerFreshnessPolicy; spineKeys: SpineKeys; createdAt: string; } export interface CoverageCell { h3Cell: number; completeness: number; /** * What `completeness` rests on. A writer that omits it is declaring {@link CoverageBasis.SourcePresent} — the weakest * reading — because a builder that has not thought about basis is recording source presence whether or not it says * so. */ basis?: CoverageBasis; observedRows: number; } /** * Whether a coverage reading can support an EXCLUSION — a claim that the thing asked for is not there. * * Presence is supportable from any basis. Absence is not: `source_present` records that the source returned rows, which * says nothing about what it missed. Callers building negative evidence must gate on this rather than on `completeness` * alone, or an exclusion fires identically on a genuinely empty cell and on one we simply never surveyed. */ export declare function supportsExclusion(cell: Pick): boolean; /** * Insert the single manifest row. Call exactly once, from the layer's build script. */ export declare function writeLayerManifest(db: LayerContractHandle, manifest: LayerManifest): Promise; /** * Read + validate the manifest. Throws if the table is empty, multi-row, or invalid. */ export declare function readLayerManifest(db: LayerContractHandle): Promise; /** * Rows per INSERT statement (4 bound params/row = 16,000 params/statement), kept safely under SQLite's default 32,766 * bound-variable ceiling — a continental-scale build's res-6 coverage cell count blows past that limit in a single * `.values()` call (found 2026-07-19). */ export declare const COVERAGE_INSERT_BATCH = 5000; /** * Bulk-insert coverage cells (build-time; cold path, so Kysely inserts are fine), chunked to stay under SQLite's * bound-variable limit. */ export declare function writeLayerCoverage(db: LayerContractHandle, cells: CoverageCell[]): Promise; /** * Look up coverage for one short H3 cell. `undefined` = the cell was never surveyed (UNKNOWN) — callers must not * conflate this with `{completeness: 0}`. */ export declare function readLayerCoverage(db: LayerContractHandle, h3Cell: number): Promise; //# sourceMappingURL=manifest.d.ts.map