/** * Pure policy-engine primitives (Phase 0.6): a hard-constraint evaluator, break-even * scoring helpers, and reason-code formatting. No provider calls, no I/O, no wiring into * prompt construction, model routing, or validation yet. * * The one invariant every helper here must uphold: a hard constraint can never be * overridden by a positive expected saving. Scoring only runs for candidates that already * cleared the hard-constraint layer. */ import type { HardConstraintFlags, PolicyAction, PolicyCandidateScore, PolicyFeatures, PolicyHardConstraintCode } from "./policy-types.ts"; /** * Evaluate hard constraints for a single candidate action. Returns the (possibly empty) * list of violated constraint codes; any non-empty result means the action must be * rejected outright, never merely down-weighted by scoring. */ export declare function evaluateHardConstraints(action: PolicyAction, features: PolicyFeatures, flags: HardConstraintFlags): PolicyHardConstraintCode[]; /** * Inputs to the context-retention break-even formula from decision-math-and-research.md: * saving(i) = N_remaining * (T_raw - T_digest) * C_token - C_pack - P_need*C_retrieve * - P_error*C_error - C_cache */ export interface ContextRetentionSavingInputs { rawTokens: number; compactTokens: number; expectedRemainingTurns: number; marginalInputTokenCost: number; packCostTokens: number; probabilityNeededAgain: number; retrievalCostTokens: number; probabilityErrorIfDropped: number; errorCostTokens: number; cacheImpactTokens: number; } export declare function computeContextRetentionSaving(inputs: ContextRetentionSavingInputs): number; /** * N_break_even(i) from decision-math-and-research.md: the number of remaining turns at * which packing/summarizing first becomes worthwhile. Returns +Infinity when the raw vs. * compact token gap never pays for itself (per-turn saving is zero or negative). */ export declare function computeBreakEvenRemainingTurns(inputs: Omit & { margin: number; }): number; /** * Hard cap override from policy-engine-spec.md: oversized raw tool output must be packed * regardless of break-even math, unless the item is pinned, current, or the latest * failure. */ export declare function exceedsHardOutputCap(rawTokens: number, maxRawToolOutputTokens: number, features: Pick): boolean; export interface ContextRetentionCandidateInput { action: PolicyAction; features: PolicyFeatures; flags: HardConstraintFlags; saving: ContextRetentionSavingInputs; margin: number; confidence: "low" | "medium" | "high"; } /** * Score one context-retention candidate. Hard constraints are checked first and, if any * fire, the candidate is returned as unappliable (infinite cost, zero savings) no matter * what the break-even math says — a hard constraint can never be overridden by savings. */ export declare function scoreContextRetentionCandidate(input: ContextRetentionCandidateInput): PolicyCandidateScore; export declare function formatHardConstraintReason(code: PolicyHardConstraintCode): string; /** Human-readable, deterministic summary of a scored candidate's reason codes. */ export declare function formatCandidateReason(candidate: Pick): string; //# sourceMappingURL=policy-engine.d.ts.map