import type { DerivationContext, DerivationStrategy } from './types.js'; export interface RunResult { outputs: Record; failed: boolean; } /** * Per-output result of a strategy invocation. Discriminated by * `kind`: * * - `record` — the existing v1 shape: one value (or a "skipped" * marker if the output was optional and `derive` returned null). * - `array` — a list of `(key, value)` entries. * The caller diffs these against the previously-emitted key set * (loaded from the fanout sidecar) to compute deletes + upserts. */ export type OutputResult = RecordOutputResult | ArrayOutputResult | FailedOutputResult; export interface RecordOutputResult { kind: 'record'; value: Record; ok: true; /** * `true` when an optional output returned `null` / * `undefined`. The caller deletes any previously-emitted output at * the same id (mirrors "tombstone for derived data"); a never-emitted * output is a silent no-op. `ok: true` because skipping is a * successful outcome, not a failure. */ skipped?: boolean; } export interface ArrayOutputResult { kind: 'array'; ok: true; /** One `(key, value)` per derived row. Empty array means "all prior outputs for this source go." */ entries: ReadonlyArray<{ readonly key: string; readonly value: Record; }>; } export interface FailedOutputResult { kind: 'failed'; ok: false; error: Error; /** Always empty on failure; present so consumers don't have to narrow. */ value: Record; } /** * Stateless functions that execute a derivation strategy. Persistence * (encrypt + store.put) is the caller's job — typically * `DerivationRegistry.onSourceWrite` which iterates run() results and * writes each output via `Collection.put`. */ export declare const DerivationExecutor: { /** * Run `derive` once, validate output shape against the spec, stamp * `_derivedFrom` onto every output. Returns per-output success or * failure; throws only for shape mismatches (a contract violation). */ run, TOutputs extends Record | ReadonlyArray>>>(strategy: DerivationStrategy, source: TSource & { id: string; }, sourceVersion: number, strategyHash: string, ctx: DerivationContext): Promise; };