/**
 * Verifiable reward channel.
 *
 * For RL on coding / math / theorem-proving / structured-output tasks, the
 * reward signal is *decidable* — a test passes or fails, a proof checks or
 * doesn't, an output validates against a schema or doesn't. These rewards
 * are dramatically more useful for RL training than LLM-judge scores
 * because they don't drift, can't be Goodhart-gamed by the policy in the
 * same way, and don't require a separate calibration loop.
 *
 * The `MultiLayerVerifier` already produces this signal — it just doesn't
 * surface it in a shape that's clean enough for RL training. This module
 * wraps the verifier output so consumers can:
 *
 *   1. Extract a clean `VerifiableReward` from a `VerificationReport`
 *   2. Distinguish *deterministic* rewards (compile, test, schema) from
 *      *probabilistic* rewards (judge) so they can be weighted differently
 *      in the RL training step
 *   3. Filter `RunRecord[]` to only those with a verifiable reward,
 *      producing the clean training set that DeepSeek-R1-style GRPO and
 *      AlphaProof-style search both depend on
 *
 * Why this matters: every credible 2025-2026 frontier RL result on coding
 * agents leans on verifiable reward (DeepSeek-R1 GRPO on test pass-rate,
 * o-series RL on math/code, AlphaProof on Lean kernel checking). Mixing
 * judge scores into the reward signal poisons the gradient. This module
 * is the seam.
 */
import type { VerificationReport } from '../multi-layer-verifier';
import type { RunRecord } from '../run-record';
export type VerifiableRewardSource = 'compile' | 'test' | 'schema' | 'sandbox' | 'judge' | 'composite';
export interface VerifiableReward {
    /** Scalar in [0, 1]. The RL training signal. */
    value: number;
    /** What produced the reward — different sources have different determinism. */
    source: VerifiableRewardSource;
    /**
     * Determinism class. `'deterministic'` rewards are repeatable byte-for-byte
     * given the same inputs (compile, test, schema validation, sandbox exit code).
     * `'probabilistic'` rewards depend on a stochastic component (LLM judge).
     * Mixing these in the same training batch without separation is a known
     * footgun in production RLHF pipelines.
     */
    determinism: 'deterministic' | 'probabilistic';
    /**
     * Confidence in the reward value. For deterministic sources this is 1.0
     * (the bit either flipped or didn't). For judge sources this is the
     * judge-reported confidence or — when missing — a calibrated prior.
     */
    confidence: number;
    /** The layer / judge id that produced the signal, for provenance. */
    origin: string;
    /**
     * Per-source contribution to `value`, keyed by layer/judge id. Single-source
     * rewards carry one entry (`{ [origin]: value }`); composite rewards carry
     * every contributing layer's score — the anti-scalar-collapse surface RL
     * consumers weight per-source instead of trusting one blended number.
     */
    components: Record<string, number>;
    /**
     * @deprecated Read `components` for per-source reward values. Kept for
     * published-API compatibility: single-source rewards carry the layer's
     * diagnostics here (e.g. `{ tests_passed: 7 }`); composite rewards carry
     * the same per-layer scores `components` now holds.
     */
    breakdown?: Record<string, number>;
}
export interface VerifiableRewardExtractionOptions {
    /**
     * Which layers count as deterministic-reward sources. The verifier doesn't
     * tag layers as "this is verifiable"; the caller declares it via this list
     * (or via the layer name → source mapping). Default treats common names
     * (`install`, `typecheck`, `build`, `lint`, `test`, `compile`, `schema`,
     * `sandbox`) as deterministic.
     */
    deterministicLayers?: string[];
    /**
     * Map layer name → reward source. Defaults to a sensible string-match.
     */
    sourceFor?: (layerName: string) => VerifiableRewardSource;
    /**
     * Whether to fall back to a probabilistic (judge) reward when no
     * deterministic layer produced a numeric score. Default `true`. Set to
     * `false` for "deterministic-only" training pipelines that should
     * discard runs without a verifiable signal.
     */
    fallbackToJudge?: boolean;
    /**
     * Default confidence for probabilistic (judge) rewards when the judge
     * doesn't report one. Default `0.7`.
     */
    judgeConfidenceFloor?: number;
}
/**
 * Extract a `VerifiableReward` from a `VerificationReport`.
 *
 * Strategy: prefer the deterministic layers (in order: test → compile →
 * schema → sandbox), fall back to the judge layer if `fallbackToJudge` is
 * true, return `null` if no signal qualifies. When multiple deterministic
 * layers contribute, return a `'composite'` source with a weighted blend.
 */
export declare function extractVerifiableReward(report: VerificationReport, opts?: VerifiableRewardExtractionOptions): VerifiableReward | null;
/**
 * Extract verifiable rewards from `RunRecord[]` produced via the
 * `verificationReportToRunRecord` adapter (which encodes per-layer scores
 * in `outcome.raw['layer.<name>']`). For records that don't carry layer
 * scores, returns `null` for that record.
 *
 * This is the canonical bridge from "campaign-shaped artifacts" to
 * "RL-training-ready reward signals": every record that has a clean
 * verifiable reward becomes a training datum, every record that doesn't
 * gets filtered out (or kept with `'probabilistic'` determinism for
 * separate downstream handling).
 */
export declare function extractVerifiableRewardsFromRecords(runs: RunRecord[], opts?: VerifiableRewardExtractionOptions): Array<{
    runId: string;
    reward: VerifiableReward | null;
}>;
/** Filter `RunRecord[]` to those with deterministic verifiable rewards. */
export declare function filterDeterministicallyRewarded(runs: RunRecord[], opts?: VerifiableRewardExtractionOptions): Array<{
    run: RunRecord;
    reward: VerifiableReward;
}>;
//# sourceMappingURL=verifiable-reward.d.ts.map