/** * Policy Evaluator * * Evaluates telemetry routing decisions based on policy configuration. */ import { TelemetryPolicy, TelemetryTier } from "../types/policy.js"; /** * Result of a policy evaluation. */ export interface PolicyDecision { /** Should this data be retained locally? */ retainLocal: boolean; /** Should this data be exported? */ export: boolean; /** Sampling decision */ sampled: boolean; /** If blocked, the reason */ blockReason?: string; } /** * Evaluator for telemetry policy decisions. * * IMPORTANT: This evaluator determines ROUTING eligibility, not trace sampling. * * For TRACES: Sampling must be handled by the OTel SDK Sampler (parent-based, * trace-ID ratio) to ensure trace consistency. * * For METRICS/LOGS: sampleRate applies with deterministic trace-ID-based logic. */ export declare class TelemetryPolicyEvaluator { private readonly policy; constructor(policy: TelemetryPolicy); /** * Get the current policy. */ getPolicy(): TelemetryPolicy; /** * Evaluate whether a telemetry signal should be processed/exported. * * @param tier - The tier this signal belongs to * @param orgId - Optional org ID for org-specific overrides * @param traceId - Optional trace ID for deterministic sampling * @returns PolicyDecision */ evaluate(tier: TelemetryTier, orgId?: string, traceId?: string): PolicyDecision; /** * Check if export infrastructure should be created for a tier. * * This checks ONLY whether export is enabled in policy configuration. * It does NOT apply sampling - use this for SDK initialization decisions. * * @param tier - The tier to check * @param orgId - Optional org ID for org-specific overrides * @returns true if export infrastructure should be created */ isExportEnabled(tier: TelemetryTier, orgId?: string): boolean; /** * Check if an export attempt is allowed (includes sampling). * * This applies sampling logic and should be used for per-span/per-signal * decisions at runtime, NOT for infrastructure initialization. * * @param tier - The tier to check * @param orgId - Optional org ID for org-specific overrides * @param traceId - Optional trace ID for deterministic sampling * @returns true if export is allowed for this specific signal */ canExport(tier: TelemetryTier, orgId?: string, traceId?: string): boolean; /** * Assert export is allowed, throwing or logging based on enforcement mode. * * @param tier - The tier to check * @param orgId - Optional org ID for org-specific overrides * @throws Error if in ENFORCE mode and export is blocked */ assertCanExport(tier: TelemetryTier, orgId?: string): void; /** * Check if Tier 3 content export is enabled. * * @returns true if Tier 3 prompts/responses can be exported */ canExportTier3Content(): boolean; /** * Get the effective policy for an org (applying overrides if present). * * Performs deep merge for nested objects (tiers, tier3Content) to ensure * partial overrides don't clobber unspecified configurations. * * @param orgId - Optional org ID * @returns Effective policy */ private getEffectivePolicy; /** * Deterministic sampling based on trace ID (W3C TraceContext recommendation). * Uses last 8 hex chars for uniform distribution in [0, 1). * * @param traceId - The trace ID (must be at least 8 hex characters) * @param sampleRate - Sample rate (0.0 - 1.0) * @returns true if sampled */ private traceIdBasedSample; } //# sourceMappingURL=policy-evaluator.d.ts.map