Services

Baseline Worker

The baseline is computed by the baseline worker, a cold-path service that runs one fit cycle on a schedule. Each time it runs, it reads a source’s recent event history from external storage, reconstructs that history into trailing windows, fits and stores the baseline, emits a signal announcing that a new baseline is available for that source, and exits the process cleanly. That signal is the worker’s point of contact with the live pipeline: the detector listens for it and refreshes the corresponding source baseline it scores against, so newly fit baselines take effect without restarting anything.

Baseline Worker — Fit CycleThe baseline worker reads source history, reconstructs windows, creates a feature matrix, fits and stores a baseline, publishes a signal, and exits. The running detector receives the signal and activates the new baseline without restarting.Baseline Worker — Fit CycleCold-path job that fits a baseline, stores it, publishes a signal, and exits.1Read history2Reconstructwindows3Feature matrix4Fit baseline5Store baseline6Publish signalExternal storage(Postgres)Read recent eventsfor each source.Build trailing windowsper source & visitor(cadenced).req_countspan_sgap_ms4xx_ratew₁4218.41200.05w₂3715.1950.03wₘ5122.71800.07Rows = eligible windows (w₁ … wₘ)Columns = extracted features(registry order)Fit histogramper featureCompute rawscore quantiles(1001 cut points)baseline_runs(artifacts table)Store baseline withmetadata and quantiles.baseline signal(Kafka topic)Signal contains:• source_id• baseline_run_idFit gates (per source)Enough sampled windowsEnough distinct visitorsIf not metRecordinsufficient_historyand skip source.Live pipeline (no restart required)Detector (running)Scores windows using in-memory baselinesListens for baseline signalNew baseline activeUsed for scoring new windowsProcess behaviorRuns on a schedule,completes one cycle,and exits cleanly.

A source’s baseline can only be computed if it has enough history to support one. The worker examines two independent thresholds to determine if a baseline can be fit: a minimum number of windows, so the fit rests on enough samples to be stable, and a minimum number of distinct visitors, so that the computed baseline is representative of different visitors’ activity. A source that meets both criteria is fit; one that doesn’t is recorded as having insufficient history and skipped, without aborting the rest of the run.

Each source is fit independently, so one source failing to fit never blanks the whole run; the failure is recorded and the worker moves on to the next source.