/** * log10x_pattern_detail — L4 surface. * * Composes a full single-pattern view by calling three internal helpers: * 1. event_lookup — identity, first_seen, per-service cost breakdown * 2. pattern_trend — time series for the lineChart() render * 3. pattern_examples — sample events from your stack (when available) * * must_render_verbatim: * - "Pattern X" header (descriptor, not hash) * - lineChart() output from src/lib/line-chart.ts (height up to 12 rows) * - BarRow chart (ASCII horizontal bars) for cross-service distribution * - Severity breakdown * - up to 3 full sample events (uncropped at 2048 chars; quality over quantity) * * must_ask_user: "Back to preview list" or "Apply with this in the picture". * * Data sources: event_lookup (TSDB + optional SIEM), pattern_trend (TSDB), * pattern_examples (SIEM connector, skipped gracefully when unavailable). */ import { z } from 'zod'; import type { EnvConfig } from '../lib/environments.js'; import { type DisplayToken } from '../lib/pattern-df.js'; import { type StructuredOutput } from '../lib/output-types.js'; import { type VolumeLensResolution } from '../lib/volume-lens.js'; export declare const patternDetailSchema: { pattern_hash: z.ZodOptional; pattern: z.ZodOptional; include_samples: z.ZodDefault; timeRange: z.ZodDefault; environment: z.ZodOptional; monthly_volume_gb: z.ZodOptional; }; export interface PatternDetailEnvelope { pattern_hash: string; /** Resolved pattern name (Symbol Message). Null if not resolvable from metrics. */ pattern_name: string | null; /** RENDER-ONLY (Layer 2): discriminator-first display name over the shared * env df-map — the SAME label top_patterns shows. Identity is pattern_name. */ display_name?: string; /** RENDER-ONLY: per-token {text, distinctive} classification of pattern_name. */ display_tokens?: DisplayToken[]; /** Per-service bytes breakdown. */ services: Array<{ service: string; severity: string; bytes: number; bytes_display: string; share_pct: number; share_pct_display: string; }>; total_bytes: number; total_bytes_display: string; first_seen_age_seconds: number | null; /** Bytes/sec time series (24h, 10min step). */ trend_time_series: Array<{ ts: number; bytes_per_sec: number; }>; /** Full sample events, capped at 2048 chars each. Up to 3 shown. */ sample_events: string[]; /** * Volume projection lens resolution. {lensed:false,factor:1} on a normal * (measured) run — the stamp + headline prefix only fire when lensed. */ volume_lens: VolumeLensResolution; must_render_verbatim: string; must_ask_user: { question: string; options: string[]; }; } /** * Plain-text horizontal bar chart for cross-service distribution. * No external dependency — builds from scratch using Unicode block chars. * Max bar width: 30 columns. */ declare function renderAsciiBarChart(rows: Array<{ label: string; value: number; }>, title: string, maxBarWidth?: number): string; /** * Resolve the pattern name (Symbol Message) from the tenx_hash via TSDB. * Returns the most-emitting pattern label for this hash over 7d. */ declare function resolvePatternName(env: EnvConfig, hash: string, metricsEnv: string): Promise; /** Fetch per-service breakdown for this hash over 30d. */ declare function fetchServiceBreakdown(env: EnvConfig, hash: string, metricsEnv: string): Promise>; /** * Fetch the ENV-WIDE total bytes over 30d (the volume-lens basis). MUST be * env-wide, not this pattern's own total — scaling against the pattern's own * bytes would blow a single pattern up to the whole stated volume. Returns 0 * on any failure (=> resolveVolumeLens treats it as no_basis). */ declare function fetchEnvMonthlyBytes(env: EnvConfig, metricsEnv: string): Promise; /** Fetch trend (bytes/sec) for this hash at adaptive resolution. */ declare function fetchTrend(env: EnvConfig, hash: string, timeRange?: string): Promise>; export declare function executePatternDetail(args: { pattern_hash?: string; pattern?: string; include_samples?: boolean; timeRange?: string; environment?: string; monthly_volume_gb?: number; }): Promise; /** Exported for unit tests only. */ export declare const __testables: { renderAsciiBarChart: typeof renderAsciiBarChart; resolvePatternName: typeof resolvePatternName; fetchServiceBreakdown: typeof fetchServiceBreakdown; fetchEnvMonthlyBytes: typeof fetchEnvMonthlyBytes; fetchTrend: typeof fetchTrend; }; export {};