/** * Effect Tracker — Lightweight in-process accounting for async side effects. * * Wraps fire-and-forget operations so failures are recorded instead of * swallowed. Provides aggregate stats queryable via the `gitmem-health` * MCP tool. * * Design principles (from docs/silent-failures.md): * - Non-blocking: registration and completion are synchronous Map ops. * - Fire-and-forget stays fire-and-forget for latency; failures become visible. * - In-memory ring buffer — no persistence across restarts (acceptable for * metrics, cache warming, knowledge graph triples). * - Aggregate stats per write path, not per individual write. */ export interface PathStats { attempted: number; succeeded: number; failed: number; lastFailure?: { error: string; timestamp: string; }; totalDurationMs: number; } export interface EffectFailure { path: string; target: string; error: string; timestamp: string; durationMs: number; } export interface EffectHealthReport { /** Per-path aggregate stats */ byPath: Record; /** Overall aggregate */ overall: { attempted: number; succeeded: number; failed: number; successRate: string; paths_with_failures: string[]; }; /** Recent failures (newest first) */ recentFailures: EffectFailure[]; /** Session uptime */ uptimeMs: number; } export declare class EffectTracker { private stats; private failures; private startedAt; /** * Wrap an async fire-and-forget operation for tracking. * * - On success: records success + duration, returns the result. * - On failure: records failure + error message, returns undefined. * The error is **not** rethrown — this is intentionally fire-and-forget. */ track(path: string, target: string, fn: () => Promise): Promise; /** * Generate a health report for the `gitmem-health` tool. */ getHealthReport(failureLimit?: number): EffectHealthReport; /** * Format a human-readable health summary for session close. */ formatSummary(): string; private getOrCreatePath; } export declare function getEffectTracker(): EffectTracker; //# sourceMappingURL=effect-tracker.d.ts.map