/** * Budget-Aware Principle Selection * * Phase: PRI-75 Prompt Injection SDK Migration Phase 2 * * Pure functions for selecting and formatting principles within a character budget. * No I/O dependencies — suitable for any host. */ import type { PrinciplePriority } from '../runtime-v2/types/principle-enums.js'; /** * Minimal principle shape required for injection selection. * Accepts both evolution-types.Principle and principle-tree-schema.Principle. */ export interface InjectablePrinciple { id: string; text: string; /** Priority level. Defaults to 'P1' if not set by the source. */ priority?: PrinciplePriority; /** ISO date string. Required for recency ordering in selectPrinciplesForInjection. */ createdAt: string; } /** * Result of principle selection for injection. */ export interface PrincipleSelectionResult { /** Selected principles in injection order (priority-first, then recency) */ selected: InjectablePrinciple[]; /** Total character count of selected principles' formatted output */ totalChars: number; /** Number of principles by priority tier */ breakdown: { p0: number; p1: number; p2: number; }; /** Whether at least one P0 principle was included */ hasP0: boolean; /** Whether the selection was truncated due to budget */ wasTruncated: boolean; } /** * Format a single principle for injection. * Returns the formatted string including ID and text. * * Format: "- [ID] text" (matches existing prompt.ts format) */ export declare function formatPrinciple(p: InjectablePrinciple): string; /** * Select principles for prompt injection within a character budget. * * Algorithm: * 1. Sort all principles by priority (P0 > P1 > P2), then by recency * 2. Iterate through sorted principles, accumulating character count * 3. Stop when adding the next principle would exceed budgetChars * 4. Ensure at least one P0 principle is included (even if it exceeds budget) * * @param principles - All available principles to select from * @param budgetChars - Maximum character budget for formatted output * @returns Selection result with chosen principles and metadata */ export declare function selectPrinciplesForInjection(principles: InjectablePrinciple[], budgetChars: number): PrincipleSelectionResult; /** * Default character budget for principle injection. * 4000 characters is ~800 tokens, leaving ample room for other prompt sections * within the 10K character injection limit. */ export declare const DEFAULT_PRINCIPLE_BUDGET = 4000; //# sourceMappingURL=principle-selection.d.ts.map