/** * Low-cardinality telemetry contract for coordinator-owned realtime work. * * The values are per-item observations and every timing carries an explicit * denominator. Paths, causality IDs, area IDs, tenant IDs, and worker PIDs are * intentionally excluded: they belong in bounded diagnostic traces, never in * metric labels. */ export declare const REALTIME_TELEMETRY_EVENT = "sync.realtime.timing"; export declare const REALTIME_TELEMETRY_SCHEMA_VERSION = 5; export declare const REALTIME_TIMING_STAGES: readonly ["queue", "conflict", "worker", "operationGate", "appendLock", "network", "commit"]; export type RealtimeTimingStage = (typeof REALTIME_TIMING_STAGES)[number]; export type RealtimeTelemetrySource = "watcher" | "receiver" | "wake"; export type RealtimeTelemetryDirection = "push" | "pull"; export type RealtimeTelemetrySizeClass = "small" | "large" | "unknown"; export declare const REALTIME_NETWORK_PHASES: readonly ["apiPresign", "s3Request", "retryWait", "connectionSetup", "eventLoopDelay"]; export type RealtimeNetworkPhase = (typeof REALTIME_NETWORK_PHASES)[number]; export declare function recordRealtimeConnectionSetup(durationMs: number): void; export declare function recordRealtimeConnectionReuse(): void; export declare function measureRealtimeNetworkPhase(phase: RealtimeNetworkPhase, run: () => Promise): Promise; export type RealtimeTelemetryOutcome = "durable" | "retryable" | "refused"; export declare const REALTIME_TELEMETRY_REASONS: readonly ["superseded", "stale-epoch", "admission-timeout", "drain-burst", "pass-exit", "unresolved-company", "shutdown"]; export type RealtimeTelemetryReason = (typeof REALTIME_TELEMETRY_REASONS)[number]; export type RealtimeTelemetryRecord = { event: typeof REALTIME_TELEMETRY_EVENT; schemaVersion: typeof REALTIME_TELEMETRY_SCHEMA_VERSION; source: RealtimeTelemetrySource; direction: RealtimeTelemetryDirection; sizeClass: RealtimeTelemetrySizeClass; outcome: RealtimeTelemetryOutcome; items: number; /** Active realtime workers at the point this pass entered the operation gate. */ occupancy: number; timingMs: Record; denominator: Record; networkTimingMs: Record; connectionsReused: number; /** Closed enum only — never a path, tenant, or causality id. */ reason?: RealtimeTelemetryReason; }; export type RealtimeTelemetrySink = (record: RealtimeTelemetryRecord) => void; export type RealtimeTelemetryClock = () => number; /** Reject dynamic dimensions before they can become a metric-key convention. */ export declare function assertRealtimeTelemetryLowCardinality(record: RealtimeTelemetryRecord): void; /** * A bridge executor currently exposes one composite sync pass. It marks all * seven contract stages around that pass so dashboards remain denominator-safe * while child workers gain finer internal probes. The stages are separately * named now, so that refinement does not change the published schema. */ export declare class RealtimeTelemetrySpan { private readonly source; private readonly directionValue; private readonly items; private readonly sink; private readonly now; private readonly sizeClassValue; private readonly startedAt; private readonly marks; private occupancy; private readonly networkTimingMs; private connectionsReused; get direction(): RealtimeTelemetryDirection; get sizeClass(): RealtimeTelemetrySizeClass; constructor(source: RealtimeTelemetrySource, directionValue: RealtimeTelemetryDirection, items: number, sink: RealtimeTelemetrySink, now?: RealtimeTelemetryClock, sizeClassValue?: RealtimeTelemetrySizeClass); mark(stage: RealtimeTimingStage): void; /** Records the bounded worker count after the guarded pass has been admitted. */ setOccupancy(occupancy: number): void; recordNetworkPhase(phase: RealtimeNetworkPhase, durationMs: number): void; recordConnectionReuse(): void; measureNetwork(run: () => Promise): Promise; finish(outcome: RealtimeTelemetryOutcome, reason?: RealtimeTelemetryReason): RealtimeTelemetryRecord; } export declare function writeRealtimeTelemetryToStderr(record: RealtimeTelemetryRecord): void; //# sourceMappingURL=realtime-telemetry.d.ts.map