import { type ContextPlanFailureReason, type ContextProviderProfile } from './context-plan.js'; import { type ContextQualification } from './context-qualification.js'; import { type ContextLiveApproval, type ContextLiveCorpus, type ContextLiveHost, type ContextLiveRecord } from './context-live-qualification.js'; /** The reviewer's signed choice. It must equal the preregistered rule's output, not a free choice. */ export interface ContextMarginReview { schemaVersion: 'context-margin-review/v1'; approved: true; reviewer: string; approvalReference: string; runId: string; recordsDigest: string; selectedMarginBps: number; qualifiedProfile: { id: string; version: string; }; } export interface ContextQualificationRecord { schemaVersion: 'context-qualification-record/v1'; runId: string; sourceCommit: string; model: string; region: string; corpusDigest: string; preregistrationDigest: string; approvalDigest: string; recordsDigest: string; collectionProfileDigest: string; marginRule: ContextLiveApproval['marginRule']; selection: { worstUndercountBps: number; extraReserveBps: number; candidateMarginBps: number; maximumMarginBps: number; }; review: ContextMarginReview; profile: ContextProviderProfile; profileDigest: string; qualification: ContextQualification; } export declare const contextLiveRecordsDigest: (records: readonly ContextLiveRecord[]) => `sha256:${string}`; /** * Applies the preregistered rule (worst observed undercount plus the frozen reserve, capped by the frozen * maximum) and records the reviewer's matching approval. Synthetic, partial or unbound evidence throws. */ export declare function recordContextQualification(options: { approval: ContextLiveApproval; corpus: ContextLiveCorpus; records: readonly ContextLiveRecord[]; review: ContextMarginReview; }): Promise; /** Enforcement gate for a stored record. Any profile change, including only its version, invalidates it. */ export declare function verifyContextQualificationRecord(record: ContextQualificationRecord, profile?: ContextProviderProfile): void; /** Frozen before collection; the later canary approval embeds it unchanged. */ export interface ContextCanaryPlan { schemaVersion: 'context-canary-plan/v1'; caseIds: string[]; rollback: 'observe-only'; budget: ContextLiveApproval['budget']; /** * Reviewer-approved per-call ceilings. Jev exposes no request-level output cap, so the * output ceiling is enforced after dispatch: unknown or over-bound reported output fails * the canary. The output ceiling is a sub-ceiling of the total bound. */ perRequestBound: { totalTokens: number; outputTokens: number; usd: number; approvalReference: string; }; } export interface ContextCanaryApproval { schemaVersion: 'context-canary-approval/v1'; approved: true; reviewer: string; stagingWorkspace: string; runId: string; sourceCommit: string; exactHeadCi: string; model: string; apiRevision: 'v1'; region: string; secretServiceReference: string; credentialResolverDigest: string; corpusDigest: string; qualificationRecordDigest: string; canaryPlanDigest: string; plan: ContextCanaryPlan; } export interface ContextCanaryCase { caseId: string; phase: 'enforce' | 'rollback'; expectedDispatches: number; dispatches: number; rejectedBeforeDispatch: boolean; planDigest: string | null; profileDigest: string | null; requestIds: string[]; partitions: Array<{ partitionId: string; questions: number; estimatedInputTokens: number; actualInputTokens: number; withinEffectiveLimits: boolean; withinDocumentedLimits: boolean; }>; oversizedDispatches: number; nativeDispatches: number; pass: boolean; /** Provider requests with unknown or over-bound reported output; any nonzero value fails the case. */ outputOversizedDispatches: number; } /** * The evaluator preflights the worst-case completion envelope before dispatch (#2797): every * evaluation carries every usage entry with the binding's full retry attempts, so the 24-question * `many-short` case rejects with `invalid-input` before any provider work instead of exceeding * the default entry limits (`property-count`) after dispatch. The canary covers that shape as a * rejected-before-dispatch case with zero dispatches in both phases. */ export declare function validateContextCanaryApproval(approval: ContextCanaryApproval, corpus: ContextLiveCorpus, record: ContextQualificationRecord): void; /** Expected dispatches per canary phase; a rejected phase needs none and names its reason. */ export interface ContextCanaryDispatchExpectation { caseId: string; enforce: number; rollback: number; enforceRejection: ContextPlanFailureReason | null; rollbackRejection: ContextPlanFailureReason | null; } /** Dispatches each phase would need, derived from the qualified plan; rejected phases need none. */ export declare function contextCanaryDispatches(caseIds: readonly string[], corpus: ContextLiveCorpus, record: ContextQualificationRecord): Promise; /** * Enforce-mode canary. Each case runs once with the recorded qualification (native batching split by the * qualified plan), then once rolled back to `observe-only`, which evaluates every question singly. All * dispatches of a phase are reserved against the approved bound before it starts; the first failure stops. */ export declare function runContextEnforceCanary(options: { approval: ContextCanaryApproval; corpus: ContextLiveCorpus; record: ContextQualificationRecord; sourceRoot: string; artifactRoot: string; host: ContextLiveHost; offlineTransport?: typeof fetch; }): Promise<{ schemaVersion: string; source: string; runId: string; sourceCommit: string; qualificationRecordDigest: string; canaryPlanDigest: string; profile: { id: string; version: string; digest: string; }; canaryPassed: boolean; stopped: string | null; oversizedDispatches: number; outputOversizedDispatches: number; enforceDispatches: number; rollbackExercised: boolean; rollbackNativeDispatches: number; cases: number; reserved: { requests: number; tokens: number; usd: number; }; issueSpend: { capUsd: number; priorUsd: number; runUsdCeiling: number; }; requestCapacityAtStop: number; elapsedMs: number; }>; //# sourceMappingURL=context-live-promotion.d.ts.map