import { type LicenseDecision, type UsePurpose } from "@mailwoman/license/decision"; import { SourceOperation } from "@mailwoman/license/operations"; import { type LicenseRequest } from "@mailwoman/license/tree"; import { type PathBuilderLike } from "path-ts"; import type { AddressSourceRecord, AddressSourceRegister } from "#source-register/types"; /** * One register source whose data reaches a corpus source's rows. */ export interface CorpusSourceInput { /** * The register's `sourceID`. */ registerSource: string; /** * The `licenseID` that register source points at, repeated so a reviewer reads the decision key here. * * {@linkcode auditCorpusSourceInputs} refuses a value that disagrees with the register. */ license: string; /** * What the corpus source reads from it: the file, the fields and the component they fill. */ reads: string; } /** * Everything one corpus source's rows are built from. */ export interface CorpusSourceMapping { /** * Other spellings rows of this source are stored under, such as the retired `synth-*` spelling. */ aliases?: readonly string[]; /** * Every register source whose data reaches a row. */ inputs: readonly CorpusSourceInput[]; /** * Inputs written in this repository need no register row. * Examples include a hand-written word list and a template. */ authored?: readonly string[]; note?: string; /** * What the source read in corpora built before its producer changed inputs under the same id. * * `inputs` describes what a build reads today. * The build and training checks read it. * * A corpus already built keeps the rows it was built from, so the release audit reads the * entry naming that corpus: `spliced-sub-venue` kept its name when its GB skeletons moved from * Price Paid Data to OS OpenData, and the published model trained on the Price Paid Data rows. */ history?: readonly CorpusSourceHistory[]; } /** * The inputs one source read in the listed corpora. */ export interface CorpusSourceHistory { corpora: readonly string[]; inputs: readonly CorpusSourceInput[]; because: string; } /** * The committed table. */ export interface CorpusSourceInputsFile { sources: Readonly>; } /** * The table indexed for lookup under every spelling it records. */ export interface CorpusSourceInputs { readonly file: CorpusSourceInputsFile; /** * The mapping a spelling resolves to, with the id it is filed under. */ resolve(source: string): { id: string; mapping: CorpusSourceMapping; } | null; } /** * Resolves the committed table through the package's `./data/*` export. */ export declare function corpusSourceInputsPath(): string; /** * Indexes a table by id and alias. * * @throws When two entries claim one spelling, because a lookup would then answer for whichever came last. */ export declare function indexCorpusSourceInputs(file: CorpusSourceInputsFile): CorpusSourceInputs; /** * One message per structural problem in the table, read against the register. */ export declare function auditCorpusSourceInputs(file: CorpusSourceInputsFile, register: AddressSourceRegister): string[]; /** * The register inputs a source's rows were built from in `corpusVersion`. * * A `history` entry naming the corpus wins over `inputs`, which describes what a build reads today. * Without `corpusVersion` the function reads today's inputs. */ export declare function mappingInputsFor(mapping: CorpusSourceMapping, corpusVersion?: string): readonly CorpusSourceInput[]; /** * Reads the committed table and checks it against the register. * * @throws When the file doesn't parse or the audit reports a problem. */ export declare function readCorpusSourceInputs(register: AddressSourceRegister, path?: PathBuilderLike): Promise; /** * Why one corpus source lacks a permission the checked operations need, * those of the `train` action unless the caller passes others. */ export interface SourceRightsGap { /** * The corpus source id the caller supplied. */ source: string; /** * The register source lacking the permission, or `null` when the table has no entry for the corpus source. */ registerSource: string | null; licenseID: string | null; /** * The decision's review state, or `null` when there's no decision to read. */ state: LicenseDecision["state"] | null; /** * The operations the decision doesn't permit, then, for an elected decision, * the purposes it doesn't permit them for. */ missing: Array; because: string; /** * Present when the register source is reserved for evaluation. * * `--unshippable-reason` admits no reserved source, because a model trained on a local * experiment's output has seen the rows the reservation keeps unseen by every model. */ reserved?: true; } /** * Every reason a corpus source's rows may not be built into a corpus or trained on. * * An empty array is the only answer a caller may read as permission. * A source the table doesn't map answers one gap whose `registerSource` is `null`, * because no mapping identifies that source's publishers. * * `corpusVersion` names a corpus already built, so a source whose inputs changed under * the same id is read against what that corpus's rows were built from. * A build or training check omits it and reads today's inputs. * * `request` defaults to the `train` action with no offering. * A release check passes the model release and the license expression its package offers. */ export declare function sourceRightsGaps(source: string, inputs: CorpusSourceInputs, register: AddressSourceRegister, corpusVersion?: string, request?: Pick): SourceRightsGap[]; /** * The register fields a permission check reads: each row's license and reservation, * and each license's decision. */ export interface RegisterDecisions { sources: ReadonlyArray>; licenses: readonly LicenseDecision[]; } /** * Whether one register row holds a decision under which the decision tree * answers `go` for the `train` action. * * A row the register lacks, or whose license has no decision, doesn't. */ export declare function registerSourcePermitsTraining(register: RegisterDecisions, registerSource: string): boolean; /** * One line naming the corpus source, the register row and the missing permission. */ export declare function describeSourceRightsGap(gap: SourceRightsGap): string; /** * Raised when a build or training run would admit a source lacking the permission. */ export declare class SourceRightsError extends Error { readonly gaps: readonly SourceRightsGap[]; /** * @param overrideHint Follows the flag in the message, naming where else the caller * sets the override, as a training config's `data.unshippable_reason`. */ constructor(context: string, gaps: readonly SourceRightsGap[], overrideHint?: string); } /** * What a checked output records about the sources it admitted. * * Its field names use snake_case. * The record is written into corpus manifests and read by Python tools. */ export interface SourceRightsRecord { /** * False when an override admitted a source lacking the permission. */ shippable: boolean; unshippable_reason: string | null; /** * Every corpus source the check read, sorted. */ sources_checked: string[]; gaps: SourceRightsGap[]; /** * Inputs whose corpus sources couldn't be read, so the check couldn't judge them, * such as a base corpus whose files name no source and whose manifest has no record. */ unverified: string[]; } /** * Checks corpus sources one at a time as an output admits them. */ export interface SourceRightsAdmission { /** * Admits a source or throws {@linkcode SourceRightsError}. * * Under an override it logs each gap once and returns them instead. */ admit(source: string): readonly SourceRightsGap[]; /** * Admits several sources at once, so a refusal lists every one of them. */ admitAll(sources: Iterable): readonly SourceRightsGap[]; /** * Refuses an input whose sources cannot be read, or records it under an override. * * An input the check cannot read stays unverified rather than clear. */ admitUnverified(description: string): void; record(): SourceRightsRecord; } /** * Options for {@linkcode createSourceRightsAdmission}. */ export interface SourceRightsAdmissionOptions { /** * Names the output in a refusal, as `corpus build v0.7.7` or `recipe sub-venue`. */ context: string; /** * Why a local experiment admits sources lacking the permission. * * A caller that sets it marks the output unshippable rather than relaxing the rule. */ unshippableReason?: string | null; /** * The built corpus the output reads, so a source whose inputs changed under the same id is * judged by the inputs that built that corpus, as {@linkcode sourceRightsGaps} reads it. * * A build omits it and is judged by today's inputs. */ corpusVersion?: string; /** * Names where else the caller sets the override, in the refusal's message. */ overrideHint?: string; log?: (line: string) => void; } /** * Builds the admission check over an already-read register and table. * * @throws When `unshippableReason` is set and blank, because an override must say why. */ export declare function createSourceRightsAdmission(register: AddressSourceRegister, inputs: CorpusSourceInputs, options: SourceRightsAdmissionOptions): SourceRightsAdmission; /** * The file name of the record a corpus builder writes beside its output. */ export declare const SOURCE_RIGHTS_FILE_NAME = "SOURCE_RIGHTS.json"; /** * Writes `record` beside an output as {@linkcode SOURCE_RIGHTS_FILE_NAME}, * two-space indented with a trailing newline, the bytes the Python builders' * `write_rights_record` wrote for a record with no gaps. * * @returns The path written. */ export declare function writeSourceRightsRecord(record: SourceRightsRecord, outDir: PathBuilderLike): Promise; /** * Reads the committed register and table and builds the admission check over them. */ export declare function openSourceRightsAdmission(options: SourceRightsAdmissionOptions): Promise; //# sourceMappingURL=corpus-inputs.d.ts.map