import { type ApplyResult } from '../config/harness-feedback-applier.js'; import { type FlywheelEvaluationReceipt } from './flywheel-receipt.js'; declare const STATE_VERSION: 1; export interface ReceiptState { receiptId: string; status: 'evaluated' | 'consumed' | 'expired' | 'revoked'; registeredAt: number; promotedAt: number | null; promotionTransactionId: string | null; } export interface PromotionCommit { commitId: string; transactionId: string; receiptId: string; lineageId: string; sequence: number; previousLedgerHead: string; baselineRef: string; candidateId: string; servingEpoch: number; proposer: string; proposerSubstitution?: string; promotedAt: number; } export interface FlywheelTransactionState { version: typeof STATE_VERSION; activeChampionRef: string | null; activePolicy: Record | null; activeGateVersion: string | null; activePolicySchemaVersion: string | null; activeSafetyEnvelopeRef: string | null; ledgerHead: string; servingEpoch: number; materializedServingEpoch: number; servedChampionRef: string | null; receiptStates: Record; commits: PromotionCommit[]; /** * Sequential-evidence alpha ledger (ADR-381): receiptId → 1-based test * index in this ledger's promotion-test stream for the CURRENT evidence * epoch. The stream is scoped to the transaction state itself (one ledger, * one champion chain, one stream) — NOT to receipt lineageIds, which * default to a fresh UUID per run and would void the control. An index is * allocated the first time a receipt is presented to the promotion gate * and persists whether or not the candidate promoted — looking spends * alpha, and retrying the same receipt reuses its index (no double spend, * no index shopping). Absent in pre-upgrade state files; readers treat * missing as empty. */ sequentialTests?: Record; /** Current evidence epoch (ADR-381 §2). Incremented only by an explicit governed reset. */ evidenceEpoch?: number; /** * Wall-clock boundary (ms) of the current evidence epoch — the `now` an * explicit reset ran at. A receipt whose OWN evidence (payload.issuedAt) * predates this boundary belongs to a prior epoch even if it happens to be * registered/promoted after the reset — the exact "index shopping" ADR-381 * §2 requires the epoch mechanism to prevent. Undefined for the genesis * epoch (no lower bound) and for state files written before this field * existed. */ evidenceEpochStartedAt?: number; /** Append-only audit trail of evidence resets. Nothing is ever deleted from it. */ sequentialResets?: SequentialResetRecord[]; } export interface SequentialResetRecord { /** The epoch that was CLOSED by this reset. */ epoch: number; at: number; reason: string; /** Alpha spend archived from the closed epoch (receiptId → test index). */ testsSpent: Record; /** Outstanding 'evaluated' receipts expired by the reset (fresh-data enforcement). */ expiredReceipts: string[]; } export interface EvidenceResetResult { success: boolean; reason: string; closedEpoch?: number; newEpoch?: number; testsArchived?: number; receiptsExpired?: number; } export interface PromotionResult { success: boolean; idempotent: boolean; reason: string; transactionId?: string; receiptId?: string; championRef?: string; ledgerHead?: string; servingEpoch?: number; materialized?: boolean; materializeReason?: string; } export interface PromoteOptions { confirm: boolean; now?: number; trustedPublicKeys?: Set; approvedAttestors?: Set; allowedProposerSubstitutions?: Set; applyFn?: (root: string, policy: Record, championRef: string, previous: string | null, now: number) => ApplyResult; /** * Strict promotion evidence (default true): the receipt must carry * task-level pairedOutcomes AND clear the sequential-evidence e-process at * this test's allocated share of the family-wise alpha budget. Set false * ONLY as an explicit migration escape hatch for pre-upgrade receipts — * aggregate-only evidence is otherwise refused, never silently accepted. */ requirePairedEvidence?: boolean; /** Family-wise type-I budget across the whole candidate stream (default 0.05). */ sequentialAlphaTotal?: number; /** e-process betting fraction in (0,1) (default 0.5). */ sequentialLambda?: number; /** Test-only crash hook; production callers leave unset. */ faultAt?: 'before-commit' | 'after-commit-before-materialize'; } export declare function readFlywheelTransactionState(root: string): FlywheelTransactionState; export declare function readFlywheelReceipt(root: string, receiptId: string): FlywheelEvaluationReceipt | null; /** * Start a new evidence epoch (ADR-381 §2): archive the current alpha spend * into the append-only reset audit trail, EXPIRE every outstanding * 'evaluated' receipt (the new epoch may only promote evidence produced * after the reset — structurally enforcing fresh data), clear the spend * ledger, and increment the epoch. Requires explicit confirmation and a * non-empty human reason; the CLI/MCP surfaces additionally gate this * through the same policy engine as promotion. */ export declare function resetSequentialEvidence(root: string, options: { confirm: boolean; reason: string; now?: number; }): Promise; export declare function registerFlywheelReceipt(root: string, receipt: FlywheelEvaluationReceipt, now?: number): Promise; export declare function recoverFlywheelMaterialization(root: string, opts?: Pick): Promise; export declare function promoteFlywheelCandidate(root: string, receiptId: string, options: PromoteOptions): Promise; export declare function listFlywheelReceipts(root: string): Array<{ receipt: FlywheelEvaluationReceipt; state: ReceiptState | null; }>; export declare function verifyFlywheelLedger(root: string): { valid: boolean; errors: string[]; commits: number; head: string; }; export {}; //# sourceMappingURL=flywheel-transaction.d.ts.map