export declare const ACCOUNTING_RECORD_SCHEMA_VERSION = "cortex-bench-accounting/1"; export declare const PROXY_EXPORT_SCHEMA_VERSION = "cortex-bench-proxy-export/1"; /** * Every figure is a tagged union rather than a number, so "the counter was never read" and "the * counter read zero" cannot share a representation. A rule that merely forbids zero is violated by * the next default initialiser; a shape that cannot hold a bare number is not. */ export type Available = { readonly status: 'available'; readonly value: T; }; export type Unavailable = { readonly status: 'unavailable'; readonly reason: UnavailableReason; }; export type Tagged = Available | Unavailable; /** Closed on purpose: a reason the other side of the seam does not know is a refusal, not a pass. */ export declare const UNAVAILABLE_REASONS: readonly ["proxy_not_started", "counter_unreadable", "audit_log_unreadable", "no_echo_received", "journal_absent", "journal_underivable", "operand_unavailable"]; export type UnavailableReason = typeof UNAVAILABLE_REASONS[number]; export declare const ACCOUNTING_CHECK_IDS: readonly ["accounting_requests_mismatch", "accounting_cost_out_of_tolerance", "accounting_operand_unavailable"]; export type AccountingCheckId = typeof ACCOUNTING_CHECK_IDS[number]; export interface AccountingCheck { readonly check_id: AccountingCheckId; readonly passed: boolean; readonly failure_code: number | null; readonly detail: string; } export interface ProxyAccounting { readonly requests: Tagged; readonly cost_usd: Tagged; readonly input_tokens: Tagged; readonly output_tokens: Tagged; readonly audit_log: Tagged>; readonly lease_echo: Tagged>; readonly source: 'proxy_export'; } export interface ProxyExport extends ProxyAccounting { readonly schema_version: typeof PROXY_EXPORT_SCHEMA_VERSION; readonly trial_id: string; readonly adapter_id: string; } export interface JournalAccounting { readonly requests: Tagged; readonly cost_usd: Tagged; readonly steps: Tagged; readonly tokens: { readonly input: Tagged; readonly output: Tagged; readonly cached: Tagged; }; readonly source: 'trajectory_merge'; } export interface JournalTotals extends JournalAccounting { /** The roles the attempt DAG did account for, so an excess can be reported against a named set. */ readonly roles: readonly string[]; } /** * Declared arm policy, frozen at compile and recorded in the record so a reader can see what was * applied. `requests_abs` is the literal 0: a request either traversed the proxy or it did not, and * a count has no rounding, so widening it is a type error rather than a judgement call. */ export interface AccountingTolerance { readonly requests_abs: 0; readonly cost_usd_rel: string; readonly cost_usd_abs_floor: string; } export declare const DEFAULT_ACCOUNTING_TOLERANCE: AccountingTolerance; /** The proxy metered requests the attempt DAG never claimed — OC-11's observable, listed not hidden. */ export interface UnaccountedRole { readonly kind: 'proxy_excess'; readonly journal_roles: readonly string[]; readonly requests: Tagged; readonly cost_usd: Tagged; } export interface AccountingRecord { readonly schema_version: typeof ACCOUNTING_RECORD_SCHEMA_VERSION; readonly trial_id: string; readonly proxy: ProxyAccounting; readonly journal: JournalAccounting; readonly tolerance: AccountingTolerance; readonly deltas: { readonly requests: Tagged; readonly cost_usd: Tagged; }; readonly reconciled: Tagged; readonly unaccounted_roles: readonly UnaccountedRole[]; readonly checks: readonly AccountingCheck[]; } export declare class AccountingInputError extends Error { constructor(detail: string); } /** * Compare the proxy's own totals against the journal's. Pure: it reads its two arguments, mutates * neither and writes nothing. Gate 4 places the result verbatim; it does not re-derive it. */ export declare function reconcileAccounting(proxyExport: ProxyExport, journalTotals: JournalTotals, tolerance?: AccountingTolerance): AccountingRecord; /** The journal reports cost as a JavaScript number; costs are compared as decimal strings. */ export declare function journalCostFromNumber(value: unknown): Tagged;