/** * log10x_measure_compaction — measure real per-pattern compaction ratios * from live SIEM samples. * * Pulls N events from the stack scoped to a service, runs them through the * tenx engine, and returns per-pattern compaction ratios derived from actual * byte measurements rather than hardcoded model estimates. * * Flow: * 1. Fetch `sample_size` events from the stack for the given service over * `timeRange` via the existing connector.pullEvents() plumbing. * 2. Run events through tenx @apps/mcp-file via runMcpAppOnEvents(). * 3. Group encoded events by patternHash (tenxHash anchor on the encoded * line; falls back to templateHash). * 4. For each pattern: * - total_encoded_bytes = sum of EncodedEvent.lineBytes * - total_original_bytes = sum of expandedByteLength(template, values) * for each event (the reconstructed original text byte length) * - compaction_ratio_x = total_original_bytes / total_encoded_bytes * 5. Return per-pattern envelope with confidence tiers. * * The measured ratio replaces the hardcoded estimates in cost.ts * (compact_ratio_low/high) and configure-engine.ts's hardcoded 0.15. * That migration is a separate step — this tool just ships the measurements. */ import { z } from 'zod'; import type { EnvConfig } from '../lib/environments.js'; import { type StructuredOutput } from '../lib/output-types.js'; export declare const measureCompactionSchema: { service: z.ZodString; sample_size: z.ZodOptional>; timeRange: z.ZodOptional>; environment: z.ZodOptional; }; export type MeasureCompactionArgs = { service: string; sample_size?: number; timeRange?: string; environment?: string; }; export interface PatternCompactionResult { /** Stable per-pattern identity (tenxHash / patternHash). */ pattern_hash: string; /** Human-readable pattern name (symbolMessage), when available. */ symbol_message?: string; /** Number of events contributing to this measurement. */ sample_count: number; /** Sum of reconstructed original text byte lengths across all sampled events. */ total_original_bytes: number; /** Sum of encoded-line byte lengths (wire bytes) across all sampled events. */ total_encoded_bytes: number; /** * Compaction ratio: original_bytes / encoded_bytes. * A ratio of 8.5 means compaction shrinks events to ~11.8% of original size. * Higher is better. */ compaction_ratio_x: number; /** Confidence tier based on sample_count. */ confidence: 'low' | 'medium' | 'high'; } export declare function executeMeasureCompaction(args: MeasureCompactionArgs, _env: EnvConfig): Promise;