/** * Context Compiler — A-CTX-1 * * Deterministic working-set selector. Given a set of ContextObject candidates, * a budget, a policy, and an explicit nowMs, produces a ContextManifest whose * hash is identical for identical inputs on any platform. * * Shadow mode: the manifest is computed and emitted but the original provider * packet is returned byte-for-byte unchanged. * * Standing invariants: * - nowMs is ALWAYS a captured input — never Date.now() internally * - No raw source text in manifest or ledger receipt — hashes and counts only * - No confidence float, no outcome_delta — both permanently banned * - Fault budget accumulates by taskId, not runId * - required-over-budget is an explicit failure, never a silent drop * - MAX_RENDER_PASSES = 5 — hard constant */ import type { ContextBudget, ContextLedgerEntry, ContextManifest, ContextObject, ContextPolicy } from "../contracts/index.js"; export declare const MAX_RENDER_PASSES = 5; /** * Minimal adapter interface for token recounting. * Implementations may call the provider SDK's token counter. * Must not make network calls to the provider inference endpoint. */ export interface ContextAdapter { readonly version: string; /** Recount the actual rendered tokens for a serialized text segment. */ recountTokens(text: string): number; } /** Fallback adapter: char÷4 heuristic, no external calls. */ export declare const HEURISTIC_ADAPTER: ContextAdapter; export interface CompileContextInput { taskId: string; runId: string; /** Must be a captured value — never call Date.now() inside the compiler. */ nowMs: number; candidates: readonly ContextObject[]; budget: ContextBudget; policy: ContextPolicy; adapter: ContextAdapter; } export type CompileContextOutput = { ok: true; manifest: ContextManifest; ledgerEntry: ContextLedgerEntry; } | { ok: false; reason: "required_over_budget" | "recount_exceeded_passes"; manifest: null; ledgerEntry: null; }; export declare function compileContext(input: CompileContextInput): CompileContextOutput;