export { C as CampaignStorage, D as DefaultProductionGateOptions, E as EvolutionaryDriverOptions, G as GepaDriverConstraints, a as GepaDriverOptions, H as HeldOutGateOptions, O as OpenAutoPrOptions, b as OpenAutoPrResult, R as RunCampaignOptions, c as RunEvalOptions, d as RunImprovementLoopOptions, e as RunImprovementLoopResult, f as RunOptimizationOptions, g as RunOptimizationResult, h as composeGate, i as countSentenceEdits, j as defaultProductionGate, k as evolutionaryDriver, l as extractH2Sections, m as fsCampaignStorage, n as gepaDriver, o as heldOutGate, p as inMemoryCampaignStorage, q as openAutoPr, r as runCampaign, s as runEval, t as runImprovementLoop, u as runOptimization, v as surfaceHash } from '../run-improvement-loop-BhfdjrMY.js';
import { L as LabeledScenarioStore, c as LabeledScenarioWrite, d as LabeledScenarioSampleArgs, e as LabeledScenarioRecord, f as LabelTrust, C as CodeSurface } from '../types-BgrxOJSf.js';
export { g as CampaignAggregates, h as CampaignArtifactWriter, i as CampaignCellResult, j as CampaignCostMeter, k as CampaignResult, l as CampaignTraceWriter, b as DispatchContext, D as DispatchFn, G as Gate, m as GateContext, n as GateDecision, o as GateResult, p as GenerationCandidate, q as GenerationRecord, I as ImprovementDriver, r as JudgeAggregate, a as JudgeConfig, s as JudgeDimension, J as JudgeScore, t as LabeledScenarioSource, M as MutableSurface, u as Mutator, O as OptimizerConfig, P as ProposeContext, R as RedactionStatus, S as Scenario, v as ScenarioAggregate, w as SessionScript, T as TraceSpan, x as labelTrustRank } from '../types-BgrxOJSf.js';
import '../llm-client-BXVRUZyX.js';
import '../errors-mje_cKOs.js';
import '../raw-provider-sink-C46HDghv.js';
import '../red-team-CrC5MZYd.js';
import '../dataset-BlwAtYYf.js';
import '../store-CKUAgsJz.js';
import '../schema-m0gsnbt3.js';
import '../run-record-etiCMsUq.js';

/**
 * @experimental
 *
 * Filesystem `LabeledScenarioStore` adapter. The default capture sink for
 * traces + eval artifacts. Production deployments typically swap for a
 * Turso/SQLite adapter (same interface).
 *
 * Records land as one JSONL file per source under `<root>/<source>.jsonl`.
 * Each line is a `LabeledScenarioRecord`. Append-only — no in-place edits.
 *
 * Safety properties enforced at write-time:
 *
 *   - **Provenance required**: writes without `source`, `sourceVersionHash`,
 *     `capturedAt`, `redactionStatus` are rejected. Closes the alignment
 *     reviewer's data-poisoning gap.
 *   - **Per-source rate limits**: optional `rateLimitBucket` + `maxWritesPerMinute`
 *     stops a single tenant/source from flooding the store.
 *
 * Safety properties enforced at sample-time:
 *
 *   - **Required split + capturedBefore**: substrate refuses to sample without
 *     an explicit `split` ('train' | 'test') AND a temporal cutoff. Eliminates
 *     accidental train/test contamination.
 *   - **Default training-source filter**: when the store is sampled with
 *     `split: 'train'`, production-trace records are EXCLUDED unless the
 *     caller passes `filter.source: 'production-trace'` explicitly. Closes
 *     the contamination-by-default gap flagged by the senior eval engineer.
 */

interface FsLabeledScenarioStoreOptions {
    /** Root directory for JSONL files. Created if missing. */
    root: string;
    /** Per-source rate limit. When set, writes exceeding the cap are rejected
     *  with a typed error. Default: no limit. */
    maxWritesPerMinutePerBucket?: number;
    /** Test seam — override `Date.now()` for deterministic tests. */
    now?: () => number;
}
declare class LabeledScenarioStoreError extends Error {
    readonly code: string;
    constructor(code: string, message: string);
}
declare class FsLabeledScenarioStore implements LabeledScenarioStore {
    private readonly options;
    private readonly now;
    private readonly rateLimits;
    constructor(options: FsLabeledScenarioStoreOptions);
    observe(write: LabeledScenarioWrite): Promise<void>;
    sample(args: LabeledScenarioSampleArgs): Promise<LabeledScenarioRecord[]>;
    size(): Promise<{
        train: number;
        test: number;
        bySource: Record<string, number>;
        byTrust: Record<LabelTrust, number>;
    }>;
    private assertProvenance;
    private assertRateLimit;
    private toRecord;
    private pathForSource;
}

/**
 * @experimental
 *
 * VCS-pluggable worktree adapter. One improvement = one worktree, PR-like
 * (multiple commits allowed). A code-tier driver's `propose()` creates a
 * worktree, an agent commits the change into it, and `finalize()` returns a
 * `CodeSurface{ worktreeRef }` the measurement checks out to run the worker
 * against the changed code. On promotion the worktree becomes the PR branch.
 *
 * The interface is VCS-agnostic so a future `jj` ([jj-vcs](https://github.com/jj-vcs/jj))
 * adapter can slot in without touching driver code. Only the git adapter
 * ships today. See `docs/design/self-improvement-engine.md`.
 */

interface Worktree {
    /** Absolute path to the checked-out worktree directory. */
    path: string;
    /** The branch the worktree is on (becomes the PR branch on promotion). */
    branch: string;
    /** The ref the worktree was forked from. */
    baseRef: string;
}
interface WorktreeAdapter {
    /** Create an isolated worktree on a fresh branch off `baseRef`. */
    create(opts: {
        baseRef: string;
        label: string;
    }): Promise<Worktree>;
    /** Commit any pending changes in the worktree, then return a CodeSurface
     *  pointing at it. The agent has already written its change into
     *  `worktree.path` by the time this is called. */
    finalize(worktree: Worktree, summary: string): Promise<CodeSurface>;
    /** Remove the worktree (and its branch) — called for losing candidates. */
    discard(worktree: Worktree): Promise<void>;
}
declare class WorktreeAdapterError extends Error {
    readonly cause?: unknown | undefined;
    constructor(message: string, cause?: unknown | undefined);
}
interface GitWorktreeAdapterOptions {
    /** Repo root the worktrees fork from. */
    repoRoot: string;
    /** Directory worktrees are created under. Default: `<repoRoot>/.worktrees`. */
    worktreeDir?: string;
    /** Branch-name prefix. Default: `improve`. */
    branchPrefix?: string;
    /** Test seam — defaults to a real `git` runner. */
    git?: (args: string[], cwd: string) => string;
}
declare function gitWorktreeAdapter(opts: GitWorktreeAdapterOptions): WorktreeAdapter;
/** Resolve a `CodeSurface`'s worktreeRef to a directory the measurement can
 *  run the worker in. A path ref is returned as-is; anything else is treated
 *  as a ref under the adapter's worktree dir. */
declare function resolveWorktreePath(surface: CodeSurface, worktreeDir?: string): string;

export { CodeSurface, FsLabeledScenarioStore, type FsLabeledScenarioStoreOptions, type GitWorktreeAdapterOptions, LabelTrust, LabeledScenarioRecord, LabeledScenarioSampleArgs, LabeledScenarioStore, LabeledScenarioStoreError, LabeledScenarioWrite, type Worktree, type WorktreeAdapter, WorktreeAdapterError, gitWorktreeAdapter, resolveWorktreePath };
