import { type ContextPlanInput, type ContextProviderProfile } from './context-plan.js'; import { type DecisionProjectionPolicy } from './projection.js'; import type { DecisionDefinition, DecisionRuleset, DecisionBinding } from './types.js'; export declare const contextLiveDigest: (value: unknown) => `sha256:${string}`; export interface ContextLiveApproval { schemaVersion: 'context-live-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; preregistrationDigest: string; budget: { requests: number; tokens: number; usd: number; wallClockMs: number; }; /** Reviewer-approved upper bound, not a claimed provider price. All requests reserve the full bound. */ perRequestBound: { totalTokens: number; usd: number; approvalReference: string; }; marginRule: { extraReserveBps: number; maximumMarginBps: number; }; } export interface ContextLiveCase { id: string; input: { payload: unknown; }; definitions: DecisionDefinition[]; dimension: string; } export interface ContextLiveCorpus { schemaVersion: 'context-live-corpus/v1'; syntheticOnly: true; profile: ContextProviderProfile; cases: ContextLiveCase[]; } export interface ContextLiveHost { /** Approved secret service integration; receives only the logical reference. */ resolveCredential(reference: string): Promise; /** Metadata-only durable sink called before the next partition. */ record?(record: ContextLiveRecord): Promise; recordFailure?(failure: ContextLiveProviderFailure): Promise; /** Zeroes host-held credential material; called once when a run ends, however it ends. */ dispose?(): void; } /** Mirrors the DecisionBinding `credentialRef` pattern, so a reference that binding validation refuses is rejected at approval. */ export declare const CREDENTIAL_REF: RegExp; /** #2681 hard cap on all TV-12 provider spend: every collection and canary run, reserved amounts. */ export declare const TV12_ISSUE_USD_CAP = 2; /** Fixed ledger location beneath the canonical artifact root; every run directory lives here. */ export declare const contextLiveRunsRoot: (artifactRoot: string) => string; /** * Sums earlier #2681 spend in the ledger: a run's charged reservation when its summary exists, otherwise * (a crash or an unfinished run) its full approved budget. Unrecognized or unreadable entries fail closed. */ export declare function contextLivePriorSpendUsd(runsRoot: string): Promise; /** * Holds the ledger lock while `run` executes. The run's USD ceiling is the smaller of its approval and * the issue cap minus all prior spend; no remaining budget refuses before any write or credential use. */ export declare function withContextLiveSpendLedger(artifactRoot: string, approvedUsd: number, run: (runsRoot: string, issueSpend: { capUsd: number; priorUsd: number; runUsdCeiling: number; }) => Promise): Promise; /** Collection-only ruleset: one alias per compiled question, review outcome, no action execution. */ export declare function contextLiveRuleset(itemId: string, aliases: string[], definitions: DecisionDefinition[]): DecisionRuleset; /** Pinned Jev target: approved model and logical credential reference, no retries or fallbacks. */ export declare function contextLiveTarget(approval: Pick, adapterVersion: string, timeoutMs: number): { adapter: "jev"; adapterVersion: string; model: string; credentialRef: string; requiredCapabilities: string[]; acceptance: { mode: "typed-value"; }; timeoutMs: number; retry: { maxRetries: number; initialDelayMs: number; maxDelayMs: number; }; }; export declare function contextLiveBinding(ruleset: DecisionRuleset, aliases: string[], target: ReturnType, timeoutMs: number): DecisionBinding; /** Exposes the exact D10-projected planning input used by collection, for record binding and the canary. */ export declare function compileContextLiveCase(item: ContextLiveCase, model: string, region: string): Promise<{ input: ContextPlanInput; projected: { state: Record; evidence: import("./projection.js").DecisionProjectionEvidence; }; policy: DecisionProjectionPolicy; }>; /** Builds targets from actual compiled question and trust-partitioned provider state shapes. */ export declare function generateContextLiveCorpus(profile: ContextProviderProfile): Promise; export declare const TV12_MAX_RETRIES = 1; export declare const TV12_MIN_MEASURED_CASES = 12; export declare function contextLivePreregistration(corpus: ContextLiveCorpus, marginRule: ContextLiveApproval['marginRule']): { schemaVersion: string; corpusDigest: `sha256:${string}`; estimator: { id: string; version: string; }; metrics: string[]; marginRule: { extraReserveBps: number; maximumMarginBps: number; }; stopFraction: number; automaticPromotion: boolean; providerFailurePolicy: { maxRetriesPerRequest: number; retryableReasons: string[]; terminalResponsesOnly: boolean; accounting: string; exhausted: string; marginPopulation: string; minimumMeasuredCases: number; rationale: string; stillStopImmediately: string[]; }; }; export declare function validateContextLiveApproval(approval: ContextLiveApproval, corpus: ContextLiveCorpus): void; export declare function assertContextLiveSource(root: string, expected: string): Promise; export interface ContextLiveRecord { source: 'provider' | 'synthetic'; estimator: { id: string; version: string; }; wireDigest: string; wireBytes: number; caseId: string; partitionId: string; planDigest: string; profileDigest: string; servedModel: string; requestId: string; estimatedInputTokens: number; actualInputTokens: number; errorTokens: number; absoluteErrorTokens: number; undercountBps: number; usageRef: string; usageArtifactDigest: string; inputTokens: number; outputTokens: number; costUsd: number | null; } /** Pure accounting guard. Reservations are never refunded, including uncertain failed calls. */ export declare class ContextLiveBudget { private readonly approval; readonly started: number; private readonly now; requests: number; tokens: number; usd: number; private usdMicros; constructor(approval: Pick, started: number, now?: () => number); reserve(): void; } /** Most requests the 80% stop admits, derived from the same arithmetic as `ContextLiveBudget.reserve`. */ export declare function contextLiveRequestCapacity(approval: Pick): number; export interface ContextLiveEstimate { schemaVersion: 'context-live-estimate/v2'; providerCalls: 0; credentialResolved: false; cases: Array<{ id: string; dimension: string; rejectedBeforeDispatch: boolean; partitions: Array<{ id: string; questions: number; estimatedInputTokens: number; }>; }>; requests: number; maximumRequestsWithRetries: number; estimatedInputTokens: number; maxPartitionEstimate: number; reserved: { requests: number; tokens: number; usd: number; }; requestCapacityAtStop: number; fitsBeforeStop: boolean; } /** Dry run: the exact partitions collection would dispatch, without credentials, transport or writes. */ export declare function estimateContextLiveCollection(approval: ContextLiveApproval, corpus: ContextLiveCorpus): Promise; export interface ContextLiveProviderFailure { schemaVersion: 'context-live-provider-failure/v1'; source: 'provider' | 'synthetic'; caseId: string; partitionId: string; attempt: number; reason: string; measurementFailure: boolean; httpStatus: number | null; requestId: string | null; servedModel: string | null; inputTokens: number | null; outputTokens: number | null; costUsd: number | null; } /** Collection-only native request. Exposed for offline guard tests; mocks remain synthetic. */ export declare function collectContextLiveCase(item: ContextLiveCase, corpus: ContextLiveCorpus, approval: ContextLiveApproval, host: ContextLiveHost, budget: ContextLiveBudget, signal: AbortSignal, offlineFetch?: typeof fetch): Promise<{ rejected: boolean; records: ContextLiveRecord[]; failures: ContextLiveProviderFailure[]; synthetic: boolean; }>; /** `exact` (run evidence) requires the canonical root itself; `within` (prepared inputs) allows a descendant. */ export declare function assertContextArtifactRoot(sourceRoot: string, artifactRoot: string, mode?: 'exact' | 'within'): Promise; /** Writes only sanitized evidence. The caller must resolve the canonical artifact root first. */ export declare function runContextLiveCollection(options: { approval: ContextLiveApproval; corpus: ContextLiveCorpus; sourceRoot: string; artifactRoot: string; host: ContextLiveHost; offlineTransport?: typeof fetch; }): Promise; //# sourceMappingURL=context-live-qualification.d.ts.map