import { LicenseReviewState, type LicenseDecision } from "@mailwoman/license/decision"; import { SourceOperation } from "@mailwoman/license/operations"; import { type CorpusSourceInputs } from "#source-register/corpus-inputs"; /** * The license label recorded for a source whose rows have no label. * * A recipe in a corpus built before #2741 could write rows with an empty `license` column. * A current writer stamps the register's id and refuses a source that has none, * so only an older file reaches this label. * * An empty string in the record would read as a source with no terms, and `summarizeLicense` * would find no identifier in it and report no obligation. * * This label is unrecognized by design, so every reader reports the source's * terms as unknown rather than as none. */ export declare const NO_LICENSE_RECORDED = "none-recorded-on-rows"; /** * What one source contributed to a build. * * Also records what the build had established about its terms. */ export interface TrainingSourceRecord { /** * The adapter id stamped into every row's `source`, and the join key to the register's `sourceID`. */ source: string; /** * Rows this source contributed after license exclusion and eligibility but before augmentation. * A synthetic row counts under the source it was fanned from. */ rows: number; /** * The license label assigned to the source's rows. * * When the rows have more than one label, this is the label assigned to most of them * and {@linkcode licenseValues} lists every label with its rows. */ license: string; /** * Every license label assigned to the source's rows, with a row count for each label * when there's more than one. * * A recipe stamps a description of its own output into the column, and one recipe can stamp * several, so a synthetic source reads several labels where an adapter's source reads one. * The record keeps the whole set because a reader that saw only {@linkcode license} * would take the majority label for the terms of every row. */ licenseValues?: Record; /** * The register's decisions for the source's register inputs when the build ran, * combined by {@linkcode combineSourceDecisions}, or `null` when they couldn't all be found. * * The inputs are the ones `corpus-source-inputs.json` maps the source to, so the * decision is found through the mapping rather than through {@linkcode license}. */ decision: TrainingSourceDecision | null; /** * Why {@linkcode decision} is `null`. * * A record frozen before the decision was resolved through the mapping has a `null` decision and no * gap, and reads as a decision the freeze never looked up rather than as one the register lacked. */ decisionGap?: TrainingDecisionGap; } /** * What one register decision said at build time. */ export interface TrainingInputDecision { licenseID: string; state: LicenseReviewState; electedTerms: string | null; /** * The operations the elected grant permitted at build time, spelled as the freeze wrote them. * * An operation absent here was `unreviewed` or `refused`, which the decision records separately. * A manifest frozen before the operations were renamed records the names in * {@linkcode FROZEN_OPERATION_NAMES}, and {@linkcode frozenPermittedOperations} reads them. */ permitted: string[]; } /** * The operation each name a manifest frozen before 2026-11-23 records means today, * or `null` for a name no operation means. * * A frozen manifest's digest covers its names, so the record keeps them and the reader maps them. * `commercial-sublicense` was the act the `sale` purpose now reads, and a freeze records no purpose. */ export declare const FROZEN_OPERATION_NAMES: Readonly>; /** * The operations a frozen decision records as permitted, read under today's names. */ export declare function frozenPermittedOperations(decision: Pick): SourceOperation[]; /** * The decisions over one source's register inputs, combined. */ export interface TrainingSourceDecision extends TrainingInputDecision { /** * Each decision the combination read, in `licenseID` order, when there's more than one. * * A combined `state` names one state where the inputs can hold several, * such as an elected grant beside an unchecked one, and the record is frozen * so a reader cannot look the others up as they stood at build time. */ inputs?: TrainingInputDecision[]; } /** * Why a source's decision couldn't be found. */ export declare const TrainingDecisionGapReason: { /** * `corpus-source-inputs.json` doesn't map the source. */ readonly Unmapped: "unmapped"; /** * The mapping lists only authored inputs, so no register decision covers the rows. */ readonly NoRegisterInput: "no-register-input"; /** * The mapping points at a `licenseID` the register doesn't declare. */ readonly MissingDecision: "missing-decision"; }; export type TrainingDecisionGapReason = (typeof TrainingDecisionGapReason)[keyof typeof TrainingDecisionGapReason]; export type TrainingDecisionGap = { reason: typeof TrainingDecisionGapReason.Unmapped | typeof TrainingDecisionGapReason.NoRegisterInput; } | { reason: typeof TrainingDecisionGapReason.MissingDecision; /** * Each `licenseID` the mapping names and the register lacks. */ licenseIDs: string[]; }; /** * The register decisions and the source table a freeze resolves each source's decision through. */ export interface SourceDecisionTable { /** * The register's license decisions keyed by `licenseID`. */ decisions: ReadonlyMap>; inputs: CorpusSourceInputs; } /** * Combines the decisions over one source's register inputs into one record. * * The combination is elected only when every decision is elected. * Otherwise it reads `refused` when any decision is refused, and the first other * state in `licenseID` order when none is. * * `permitted` is the intersection of every decision's permitted operations, * so an operation counts only when every input's grant permits it. * `licenseID` and `electedTerms` list every decision's value joined by ` AND `, * the SPDX expression for terms that all apply. * `electedTerms` is `null` unless every decision is elected. * * @throws When `decisions` is empty, because a combination needs at least one decision to state. */ export declare function combineSourceDecisions(decisions: readonly LicenseDecision[]): TrainingSourceDecision; /** * The decision one source's record holds, or the gap that stopped it from being found. * * `corpusVersion` selects a mapping's `history` entry when one lists the corpus, as the release audit does. */ export declare function resolveSourceDecision(source: string, table: SourceDecisionTable, corpusVersion?: string): { decision: TrainingSourceDecision; } | { decision: null; decisionGap: TrainingDecisionGap; }; /** * One corpus build's frozen source record. */ export interface TrainingManifest { manifestID: "corpus-training-manifest"; schemaVersion: 1; corpusVersion: string; builtAt: string; /** * The build profile, so a reader can tell a corpus whose sources were checked * from one whose sources weren't. */ profile: string; /** * Sources in descending row order. */ sources: TrainingSourceRecord[]; /** * Sources the build refused, with the reasons, so the record shows what was * left out as well as what went in. * * Each key is `:`, the pair that addresses one register source, * because one adapter can emit several jurisdictions and each has its own license decision. */ refused: Record; totalRows: number; /** * Sha256 over this manifest with `contentDigest` emptied. */ contentDigest: string; } /** * The digest a manifest should include, computed over the manifest with its digest field emptied. */ export declare function trainingManifestDigest(manifest: TrainingManifest): string; /** * Freeze one build's source observations into a manifest. * * Each source's decision is resolved through its register inputs in `decisionTable.inputs` * by {@linkcode resolveSourceDecision}. * A source whose decision cannot be found records `decision: null` with the * {@linkcode TrainingDecisionGap} that stopped it rather than being omitted, so a build * that read an unmapped source stays distinguishable from one that read no source. */ export declare function freezeTrainingManifest(input: { corpusVersion: string; builtAt: string; profile: string; rowsBySource: ReadonlyMap; }>; decisionTable: SourceDecisionTable; refused: ReadonlyMap; }): TrainingManifest; /** * Everything wrong with a training manifest, one message per problem. * * The digest check is what makes the record frozen rather than merely written. */ export declare function auditTrainingManifest(manifest: TrainingManifest): string[]; /** * The sources in a manifest whose terms didn't permit an operation when the build ran, * with the reason for each. * * A source recorded with a {@linkcode TrainingDecisionGapReason.NoRegisterInput} gap * isn't listed: every input reaching its rows was written in this repository, so no third * party's terms apply, and `sourceRightsGaps` admits it into a build on the same reading. */ export declare function sourcesNotPermitting(manifest: TrainingManifest, operation: SourceOperation): Array<{ source: string; because: string; }>; //# sourceMappingURL=training-manifest.d.ts.map