/** * Sequence materialization. * * `buildSequences` consumes the ordered list of sequence specs declared * in the DSL `` and produces a registry mapping each sequence name * to its materialized per-cell values. Parent-constrained sequences are * computed only over the subset of rows where the parent produced the * declared value; remaining rows get `undefined`. Percentages inside * child `` are evaluated over the constrained subset, not the * total `count` — this is the core of the "ierarchical probabilistic * dependencies" moat (docs/vision/02-sequences.md). * * The registry is also seeded with the built-in `_count` sequence * (1-based iteration index, one entry per row) for interpolation. * * Ordering: specs are processed in declaration order. A child sequence * whose `parent` references a later-declared sequence throws at the * dependency-lookup step — cycles and forward references are not * supported in this phase. */ import type { GeneratorBody } from '../data-pack/generator.js'; import type { PackRegistry } from '../data-pack/index.js'; import { type DataSourceOptions } from '../data-source/index.js'; export { patternGenForGen } from './pattern-source.js'; export { pickSequential, sequentialIndex, sequentialList, walkedValueAt } from './sequential.js'; import type { AttrMap } from '../processor/attrs.js'; import type { GenSpec, SequenceRegistry, SequenceSpec } from './types.js'; import type { SequenceBuildContext } from './context.js'; import { type PoolTables } from './pool.js'; /** * A uniq group's arrangement, as it travels: row index (as a string, so it * survives a structured clone) to the members' values for that row. Only the * rows that moved are in it, which is a few thousand out of a hundred million. */ export type UniqArrangement = Readonly>; /** Every env-level `` group's arrangement, keyed by its members joined by ' × '. */ export type UniqPlan = Readonly>; export interface SequenceBuildOptions { /** * This build is ONE ROW of a bigger one — a pack generator's body, built for * a single row of the column that names it. Carried through so the body's own * sequences know it too: a one-row build has no column to plan over, and * without this they would each start planning one. */ readonly perRow?: boolean | undefined; /** * Arrangements worked out elsewhere, so this build does not work them out * again. * * Deciding which rows move where is the expensive half of a uniq run — a * full pass over every row, twice — and it depends only on the config and the * seed. So it is worth doing once and telling everyone else. That is what * lets several threads each render a different range of rows of the same uniq * config: without it each thread would repeat the whole analysis, which is * slower than not splitting at all. */ readonly uniqPlan?: UniqPlan | undefined; /** Called with each group's arrangement as it is worked out, so it can be passed on. */ readonly onUniqPlan?: ((group: string, arrangement: UniqArrangement) => void) | undefined; /** * Build the members of an env-level `` group but do NOT make them * unique. * * For the threads that compute the scan. Their whole job is to report what * each row drew BEFORE any rearrangement — that is the input the analysis * works on — so applying the analysis to get it would be circular. */ readonly skipEnvUniq?: true; /** Throw the uniq-repair refusal instead of the in-memory fallback — see `RenderOptions`. */ readonly refuseUniqFallback?: true; /** Colliding rows already found elsewhere, per uniq group. See `DuplicateScanOptions.knownExcess`. */ readonly uniqExcess?: Readonly> | undefined; /** Fingerprint piles for the hunt — Engine 5. See `DuplicateScanOptions.fingerprintBuckets`. */ readonly uniqFingerprintBuckets?: number | undefined; /** Sorted fingerprint files computed elsewhere, per uniq group — the parallel coordinator's. */ readonly uniqFingerprintFiles?: Readonly> | undefined; /** * Called as the uniq machinery advances. The phases and shape are * `RenderProgress` — declared render-side because that is where the render * phase reports from; the uniq phases join through here. */ readonly onProgress?: ((progress: { phase: 'uniq-scan' | 'uniq-sort' | 'uniq-repair' | 'render'; done: number; total: number; }) => void) | undefined; /** * Rows are computed strictly in order, so `prev()` has a previous row to read. * * Set from ``. Not to be confused with * `order="sequential"` on a list-backed generator, which is about the order * values are DRAWN in and has nothing to do with this. */ readonly sequential?: true; readonly regexMaxLength?: number | undefined; /** * A column's value at an absolute row, for a `` written inside a * ``. The streaming engines fill it with a read of their own lazy * registry; the in-memory engine passes the same shape on its context. */ readonly valueAt?: ((name: string, row: number) => string | undefined) | undefined; /** The document's `${{…}}` marker, for a `` written inside a ``. */ readonly inject?: string | undefined; /** Is this name a column? See `SequenceBuildContext.hasColumn`. */ readonly hasColumn?: ((name: string) => boolean) | undefined; /** * Pools already computed for this run, by name — see `pool-build.ts`. A * `` reads a member out of one of these instead of drawing a * value of its own. */ readonly pools?: PoolTables | undefined; /** * The run's seed, needed only to pick a member per row. A reference draws * from its own derived stream, so the pick must be reproducible from the seed * rather than from wherever the main generator happens to have got to. */ readonly seed?: string | undefined; readonly dataSources?: DataSourceOptions | undefined; readonly packs?: PackRegistry | undefined; /** * Config-level `` groups: each inner array holds the names of * scalar sequences that must produce different values from each other * within one row. Enforced after all sequences materialise. */ readonly envDistinctGroups?: readonly (readonly string[])[] | undefined; /** * Config-level `` groups: each inner array holds the names of scalar * sequences whose combined TUPLE must be unique across all rows. Enforced * after all sequences materialise. */ readonly envUniqGroups?: readonly (readonly string[])[] | undefined; /** * Parameter overrides for a pack generator body: a local `` whose * name matches a key is materialized as that constant value for every row, * instead of running its own spec. This is how a calling * `` passes `p="v"` into the generator — * the pack author declares `…default…` and the * caller value wins. Only set by `runGenerator`; top-level configs never pass * it, so their sequences are unaffected. */ readonly overrides?: Readonly> | undefined; /** * Set by the async render path. Lets a `type="http"` generator produce a * placeholder column to be filled by an async post-pass; absent, it refuses to * render synchronously. See {@link SequenceBuildContext.httpDeferred}. */ readonly httpDeferred?: boolean | undefined; } /** * Execute a data-pack generator body and return `count` values. * * - `single` → run the one primitive `` spec. * - `composed` → materialise the local sequences over `count` (so exact * percentages, shuffle and determinism apply), then interpolate the * `` output template per row. * * Deterministic on the shared prng. Used from both the inline (render) * path and the sequence path. */ /** * Control attributes on a `` that steer the call itself * rather than parameterize the pack generator. Everything else is a parameter * that may override a same-named local sequence (spec §4.1). */ /** * What the ENGINE reads off a `` before the pack runs. * * This set is the authority on which names a pack may claim: anything NOT here * is handed to the pack as a parameter override by `paramOverrides` below, so a * pack is free to declare a `` and have the caller pin it. * The validator imports it for exactly that reason — it used to keep its own * idea of which names belong to which generator type, and refused `base=` on * `usa.finance.aba_routing`, `common.payment.card.pan` and 37 other packs that * declare it, with `TDC015: does not read "base"`. The engine had been * reading it all along. */ export declare const RESERVED_TEMPLATE_ATTRS: Set; /** Extract caller parameters (non-reserved attrs) as sequence overrides. */ export declare function paramOverrides(attrs: AttrMap): Record; export declare function runGenerator(body: GeneratorBody, count: number, prng: () => number, locale: string, now: number, options?: SequenceBuildOptions): string[]; export declare function buildSequences(specs: readonly SequenceSpec[], count: number, prng: () => number, locale: string, now: number, options?: SequenceBuildOptions): SequenceRegistry; export declare function streamCtx(options: SequenceBuildOptions): SequenceBuildContext; /** * Produce `count` values for a gen, then apply `anomaly` and `missing` (MCAR) * if set — one extra PRNG draw per row, so it's deterministic. This is the * in-memory (Engine 1) path; independent gens in streaming reach it via * `resolveGenValueAt`, while the inline-built streaming types (text, counters, * timeseries, pattern) apply the same two modifiers seekably in stream-build.ts * (`missingAnomalyMod`). */ export declare function buildGenValues(gen: GenSpec, count: number, prng: () => number, locale: string, now: number, ctx: SequenceBuildContext, flagTextOut?: string[], instantsOut?: (number | undefined)[]): string[]; //# sourceMappingURL=build.d.ts.map