/** * GitMem Performance Metrics Service * * Tracks latency, result counts, and relevance signals for all GitMem tools. * Instrumentation layer for performance tracking. */ /** * Tool names that can be tracked */ export type ToolName = "recall" | "search" | "log" | "session_start" | "session_refresh" | "session_close" | "create_learning" | "create_decision" | "record_scar_usage" | "record_scar_usage_batch" | "save_transcript" | "get_transcript" | "search_transcripts" | "analyze" | "graph_traverse" | "prepare_context" | "absorb_observations" | "list_threads" | "resolve_thread" | "create_thread" | "confirm_scars" | "reflect_scars" | "cleanup_threads" | "health"; /** * Phase tags for context */ export type PhaseTag = "session_start" | "session_refresh" | "session_close" | "recall" | "learning_capture" | "decision_capture" | "scar_tracking" | "ad_hoc"; /** * Agent identities */ export type AgentIdentity = "cli" | "desktop" | "autonomous" | "local" | "cloud"; /** * Metrics data for a query */ export interface QueryMetrics { id: string; session_id?: string; agent?: AgentIdentity; tool_name: ToolName; query_text?: string; tables_searched?: string[]; latency_ms: number; result_count: number; similarity_scores?: number[]; context_bytes?: number; phase_tag?: PhaseTag; linear_issue?: string; memories_surfaced?: string[]; metadata?: Record; } /** * Performance targets */ export declare const PERFORMANCE_TARGETS: Record; /** * Timer utility for tracking operation duration */ export declare class Timer { private startTime; private endTime?; constructor(); stop(): number; elapsed(): number; } /** * Track a query and record metrics. * * Wrapped by Effect Tracker — failures are recorded instead of swallowed. * Callers can still use `.catch(() => {})` but failures will appear in health reports. */ export declare function recordMetrics(metrics: QueryMetrics): Promise; /** * Re-export performance types from types/index.ts * Enhanced instrumentation for test harness validation */ export type { PerformanceData, PerformanceBreakdown, ComponentPerformance, DataSource, CacheStatus, } from "../types/index.js"; import type { PerformanceData, PerformanceBreakdown, ComponentPerformance, DataSource, CacheStatus } from "../types/index.js"; /** * Build component performance data */ export declare function buildComponentPerformance(latencyMs: number, source: DataSource, networkCall: boolean, cacheStatus?: CacheStatus): ComponentPerformance; /** * Count network calls from breakdown */ export declare function countNetworkCalls(breakdown?: PerformanceBreakdown): number; export declare function buildPerformanceData(toolName: ToolName, latencyMs: number, resultCount: number, options?: { memoriesSurfaced?: string[]; similarityScores?: number[]; cache_hit?: boolean; cache_age_ms?: number; search_mode?: "local" | "remote"; breakdown?: PerformanceBreakdown; }): PerformanceData; /** * Calculate response size in bytes (approximate) */ export declare function calculateContextBytes(data: unknown): number; /** * Wrap an async operation with timing and metrics */ export declare function withMetrics(toolName: ToolName, operation: () => Promise, options?: { sessionId?: string; agent?: AgentIdentity; queryText?: string; tablesSearched?: string[]; phaseTag?: PhaseTag; linearIssue?: string; }): Promise<{ result: T; metrics: QueryMetrics; }>; /** * Update metrics with relevance data (called at session close) * * Wrapped by Effect Tracker — failures are visible in health reports. */ export declare function updateRelevanceData(sessionId: string, memoriesApplied: string[]): Promise; /** * Detect re-query pattern (similar query with different terms) */ export declare function detectRequery(sessionId: string, currentQuery: string, toolName: ToolName): Promise; //# sourceMappingURL=metrics.d.ts.map