/** * Compaction lifecycle span helpers. * * Tracks the full context compaction state machine: * COMPACTION_CHECK | COMPACTION_AUTOCOMPACT | COMPACTION_REACTIVE * → COMPACTION_MICROCOMPACT | COMPACTION_COLLAPSE | COMPACTION_BOUNDARY_COMMIT * Terminal states: COMPACTION_DONE | COMPACTION_FAILED * * One span per compaction cycle. Captures token deltas and strategy. */ import type { Span, SpanAttributes } from '../types.js'; import type { RuntimeTracer } from '../tracer.js'; /** Context supplied when starting a compaction lifecycle span. */ export interface CompactionSpanContext { /** Session ID this compaction is running for. */ readonly sessionId: string; /** Compaction strategy (e.g. 'microcompact', 'collapse', 'auto'). */ readonly strategy: string; /** Token count at the time compaction was triggered. */ readonly tokenCount: number; /** Token threshold that triggered compaction (if applicable). */ readonly threshold?: number | undefined; /** Context limit that triggered reactive compaction (if applicable). */ readonly limit?: number | undefined; /** Trace ID for cross-span correlation. */ readonly traceId: string; } /** Phase transitions recordable on a compaction lifecycle span. */ export type CompactionPhase = 'microcompact' | 'collapse' | 'boundary_commit'; /** Result context supplied when ending a compaction lifecycle span. */ export interface CompactionSpanEndContext { /** Final outcome of the compaction cycle. */ readonly outcome: 'done' | 'failed'; /** Token count before compaction. */ readonly tokensBefore: number; /** Token count after compaction (only set when outcome is 'done'). */ readonly tokensAfter?: number | undefined; /** Duration of the compaction in milliseconds (only set when outcome is 'done'). */ readonly durationMs?: number | undefined; /** Error description when outcome is 'failed'. */ readonly error?: string | undefined; /** ID of the compaction checkpoint committed (when applicable). */ readonly checkpointId?: string | undefined; } /** * Start a compaction lifecycle span. * * @param tracer - RuntimeTracer instance. * @param ctx - Context from COMPACTION_CHECK, COMPACTION_AUTOCOMPACT, or COMPACTION_REACTIVE. */ export declare function startCompactionSpan(tracer: RuntimeTracer, ctx: CompactionSpanContext): Span; /** * Record a compaction phase transition event. * * @param span - The active compaction lifecycle span. * @param phase - The phase reached. * @param attrs - Optional additional attributes. */ export declare function recordCompactionPhase(span: Span, phase: CompactionPhase, attrs?: SpanAttributes): void; /** * End a compaction lifecycle span. * * @param span - The span returned by `startCompactionSpan`. * @param ctx - Compaction lifecycle end context. */ export declare function endCompactionSpan(span: Span, ctx: CompactionSpanEndContext): void; //# sourceMappingURL=compaction.d.ts.map