/**
 * RL dataset packaging + datasheet — the publishable, sellable bundle.
 *
 * The format exporters (`toGrpoRows` / `toSftRows` / `toDpoRows`) already
 * produce trainer-ready shapes (prime-rl GRPO, TRL DPO, conversational SFT).
 * What turns that into a dataset someone can PUBLISH or BUY is the provenance
 * + a datasheet: which models produced it, which prompt/agent versions, how the
 * reward was derived (deterministic verifiable vs probabilistic judge — the
 * credibility axis a buyer checks first), the split discipline, the reward
 * distribution, the quality gates, the license, and the intended/out-of-scope
 * uses. This module computes those facts from the `RunRecord[]` and renders a
 * "Datasheet for Datasets" (Gebru et al. 2018) card alongside the format files.
 *
 * It composes the existing `rl/exporters` — it does not reimplement any trainer
 * format. The renderers token-identity step (DeepSeek/Kimi/Qwen tokenization
 * with per-token loss masks) is a downstream Python stage that consumes the
 * `messages`/`completions` this bundle emits.
 */
import type { RunRecord, RunSplitTag } from '../run-record';
import { type DpoLookups, type GrpoLookups, type SftLookups } from './exporters';
import type { PreferenceTriple } from './preferences';
export type RewardKind = 'deterministic' | 'probabilistic' | 'mixed';
export type DatasetFormat = 'grpo' | 'sft' | 'dpo';
/** Caller-declared context — the qualitative half of the datasheet that can't
 *  be computed from records. */
export interface RlDatasetConfig {
    name: string;
    version: string;
    /** Product/task domain, e.g. 'legal-m&a', 'tax-1040'. */
    domain: string;
    /** SPDX id or a named commercial license. Required — an unlicensed dataset
     *  cannot be published or sold. */
    license: string;
    /** How the reward was produced. `kind: 'deterministic'` (a test/schema/XPath
     *  decided it) is the credibility signal; 'probabilistic' = LLM-judge. */
    reward: {
        kind: RewardKind;
        source: string;
        description: string;
    };
    intendedUse: string;
    outOfScope: string;
    limitations: string;
    /** ISO timestamp — passed in (the substrate forbids Date.now()). */
    createdAtIso: string;
    /** Default: ['grpo', 'sft']. */
    formats?: DatasetFormat[];
    /** Quality gates already run, recorded on the card for the buyer. */
    qualityGates?: {
        contaminationProbe?: 'passed' | 'failed' | 'not-run';
        dedup?: boolean;
        verifiableRewardFilter?: boolean;
    };
}
export interface RewardStats {
    n: number;
    mean: number;
    median: number;
    min: number;
    max: number;
    std: number;
}
export interface RlDatasetStats {
    records: number;
    /** Record count per split — a publishable dataset must declare its holdout. */
    splits: Record<RunSplitTag, number>;
    reward: RewardStats;
    /** Distinct snapshot-pinned models that produced the trajectories. */
    models: string[];
    /** Distinct effective-prompt hashes (the agent profile/prompt versions). */
    promptHashes: string[];
    commitShas: string[];
    totalTokens: {
        input: number;
        output: number;
    };
    totalCostUsd: number;
}
export interface RlDatasetManifest extends RlDatasetConfig {
    formats: DatasetFormat[];
    rowCounts: Partial<Record<DatasetFormat, number>>;
    stats: RlDatasetStats;
}
export interface RlDatasetBundle {
    manifest: RlDatasetManifest;
    /** Relative filename -> contents. Write these to a directory to publish. */
    files: Record<string, string>;
}
/**
 * Package graded `RunRecord[]` into a publishable RL dataset bundle: the
 * trainer-format JSONL files + a manifest + a datasheet. DPO requires
 * pre-extracted preference triples (pass `preferences`); GRPO/SFT derive from
 * the records directly via the supplied lookups. Throws on an empty corpus —
 * an empty dataset must never be published.
 */
export declare function buildRlDataset(records: RunRecord[], lookups: GrpoLookups & SftLookups, config: RlDatasetConfig, preferences?: {
    triples: PreferenceTriple[];
    lookups: DpoLookups;
}): Promise<RlDatasetBundle>;
/** Render the "Datasheet for Datasets" card — the artifact a buyer reads. */
export declare function datasheetToMarkdown(m: RlDatasetManifest): string;
//# sourceMappingURL=dataset.d.ts.map