Clean-Context Forecasting for Zero-Shot Time Series Anomaly Detection

A common way to detect anomalies in a time series is to forecast the next few values and raise an alarm when reality departs from the forecast. Large pretrained forecasters, often called time series foundation models, should be good at this, since they forecast accurately across many domains without retraining. A careful audit found they are not. On a 23-domain benchmark, their anomaly scores correlate above 0.90 with trivial "one-liner" rules, such as the squared gap between the current value and the mean of the last three points (When Foundation Models are One-Liners). The audit names the cause. When an anomaly lasts more than a few steps, the forecaster's input window, its context, fills with anomalous values. The model then forecasts more of the anomaly, and the error that should signal it disappears. Better forecasting makes this worse, because a stronger model adapts to the corrupted history faster.

We propose to stop the forecaster from seeing what it is supposed to judge. Before each new observation enters the context, a gate checks whether the forecaster could explain it. Observations that fail the check are not written into the context as observed. Instead, a masked-reconstruction model fills those positions with a plausible normal continuation. The forecaster therefore always predicts from a repaired, "clean" history, and a sustained anomaly keeps producing large errors for as long as it lasts. Reconstruction stops being the anomaly scorer, a role in which it collapses to a variance proxy, and becomes the tool that repairs the context. We test the method strictly zero-shot across benchmark domains, with one gating rule fixed for all datasets.

Core Claim

The weakness of forecasting-based detection on long anomalies comes from what the forecaster is allowed to read, not from limited forecasting skill. If the context is kept free of flagged observations and the gaps are filled by pretrained reconstruction, a frozen forecaster should beat both the one-liner rules and the strongest reported training-free ensemble on the TSB-AD suites. The gain should be concentrated on long sequence anomalies, which is exactly where the audit shows forecasters fail. All of this should hold with no target-dataset tuning.

How This Differs From Prior Work

Two papers motivate the design. The one-liner audit (When Foundation Models are One-Liners) finds two problems. Forecasters adapt to anomalies that have entered their context. Reconstruction scores from MOMENT, which normalizes each window to zero mean and unit variance, reduce to moving-window variance, with a correlation of 0.991. The audit suggests forecasting far ahead as a remedy but does not implement it. We treat that suggestion as a baseline, not as our method.

Complexity- and Statistics-Guided Anomaly Detection makes two training-free fixes. MOMENT-Stat feeds the raw mean and standard deviation back into MOMENT's decoder. The complexity-aware ensemble (CAE) weights statistical detectors against MOMENT-Stat according to a data-complexity score. CAE combines detectors after the fact. It never changes what a forecaster conditions on, and it uses no forecaster at all. We take from it the lesson that scale information must survive normalization.

Three methods supply or constrain the reconstruction side. IGAD trains reconstruction models so that applying them twice changes nothing, which pushes perturbed inputs back onto the normal pattern. CrossAD reconstructs fine-scale detail from coarse-scale structure. MODEM uses coarse-to-fine diffusion. All three train on each target dataset and are evaluated within that dataset's own train/test split. Our setting requires no target training. We borrow IGAD's idea only as an optional check on repair quality: a repaired segment, fed back through the repair model, should not move.

TimeRadar is the closest work on zero-shot transfer. It pretrains a detection-only encoder on Monash+, a forecasting archive with injected synthetic anomalies, and transfers it to unseen benchmarks. It does not use forecasters and depends on synthetic anomaly shapes. Our method uses only off-the-shelf forecasters and imputers, so it sees no synthetic anomalies.

MOMENT supplies the repair operator: a masked-patch reconstruction model pretrained on 1.23 billion timestamps. TSB-UAD supplies the constraint behind our evaluation. Gains measured on a single dataset in this field are often an "illusion of progress," which is why all our tuning is leave-domain-out.

Research Program

At each time step, the forecaster (Chronos or TimesFM, frozen) predicts the next $h$ values from a context $\tilde{x}$ of length $L$. The context is the clean history, not the raw history.

The anomaly score for observation $x_t$ is

$$ s_t = \frac{|x_t - \hat{x}_t|}{\sigma(\tilde{x})} + \lambda \, \frac{|\mu(\tilde{x}) - \mu(x_{t-w:t})|}{\sigma(\tilde{x})}, $$

where $\hat{x}_t$ is the forecast, and $\mu(\cdot)$ and $\sigma(\cdot)$ are the mean and standard deviation, taken over the clean context or over the last $w$ raw points. The second term keeps level shifts visible after normalization, in the spirit of MOMENT-Stat. Because the scale $\sigma$ is computed on the clean context rather than the current window, the score cannot collapse into the current window's variance.

The gate works as follows. If $s_t$ exceeds a threshold $\tau$, then $x_t$ is masked in the context. MOMENT then fills the masked positions, conditioned on the unmasked points around them. To prevent a runaway loop, a masked stretch is capped at $K$ steps. Raw data is readmitted after $K$ steps, or earlier once scores fall back below $\tau$ for $m$ consecutive steps. The cap matters: without it, a real regime change would be flagged forever.

The threshold $\tau$ is not a raw number. It is a quantile of the score distribution over each series' own running history, so the same rule can be applied unchanged in every domain.

We will build this as a wrapper around frozen models, with no training. The analysis covers three points:

  • When the clean context helps. We stratify results by anomaly length and type using benchmark labels.
  • Whether the gains reflect information beyond one-liners. We measure correlation with the one-liner scores, as in the audit's protocol.
  • How far the learned repair falls short of a perfect one. We compare it against an oracle that masks exactly the labeled anomalies.

For multivariate data we run the method on each channel independently. We report this as a known limit, since anomalies defined by broken relationships between channels are not addressed.

Baselines

Naive reference points. These are the audit's one-liners: moving-window variance for reconstruction-style scoring, and the Last-3 and Centered-5 squared differences for forecasting-style scoring (When Foundation Models are One-Liners). They cost nothing and are the floor any claim must clear with statistical significance. We test significance with the Wilcoxon signed-rank test across series, the same test the audit used.

Vanilla forecaster residual. The same Chronos and TimesFM checkpoints are run with a raw, unrepaired context at context lengths 64, 256 and 512. Everything else is identical, so this isolates the effect of repair.

Multi-horizon gap forecasting. This is the audit's proposed fix. Each value is forecast from a context ending 64 or 128 steps earlier, so the anomaly has not yet entered the context. It is the most direct competitor on the exact failure we target.

Strongest existing method: CAE. CAE combines Sub-PCA with MOMENT-Stat. Its authors report a VUS-PR of 0.4679 on TSB-AD-U/M, against 0.4233 for Sub-PCA alone and 0.3857 for vanilla foundation models (Complexity- and Statistics-Guided Anomaly Detection). VUS-PR is the volume under the precision-recall surface across tolerance windows, a metric designed for time series detection. We rerun CAE with the authors' configuration on our exact splits, so differences in the evaluation code cannot create a gap. Beating CAE means a higher aggregate VUS-PR than our rerun of it, with significance across series, under an equal compute budget. If our rerun fails to reproduce roughly 0.4679, we report both numbers.

TimeRadar. We include it as a zero-shot detection model using its public code (mala-lab/TimeRadar). No reported result was found on Lacuna for TimeRadar on TSB-AD-U or TSB-AD-M, so we run it ourselves.

Ablations isolating the key ingredient. We run four:

  • Gate off. No repair; this is the vanilla forecaster with our scale-aware score.
  • Cheap repair. The repair uses linear interpolation instead of MOMENT. This tests whether learned reconstruction matters, or whether simply hiding the flagged points is enough.
  • Oracle mask. Ground-truth anomaly labels decide what to hide. This is the upper bound on what context cleaning can buy.
  • No level-shift term. We set $\lambda = 0$ to remove the scale term.

Fairness rules. Every method uses the same series and the same VUS-PR implementation. The only hyperparameters ($\tau$ quantile, $K$, $m$, $\lambda$) get a tuning budget matched to the baselines. Tuning is leave-domain-out: values chosen on the other 22 TSB-AD-U domains are applied to the held-out domain.

Why not just…?

Why not just use moving-window variance, which already matches foundation models? On vanilla foundation models the audit shows exactly this, and we accept it. Variance is blind, though, to anomalies that keep the level and spread normal but break the shape or the period. CrossAD's gains on PSM come from capturing such structure (VUS-PR 0.5596 against 0.4689 for ModernTCN, within-dataset). Our correlation analysis tests this directly. If clean-context scores still correlate above 0.90 with variance, the method has failed, regardless of its aggregate VUS-PR.

Why not just forecast from a context that ends far back, as the audit proposes? This is the most serious threat, because it also keeps the anomaly out of the context and needs no gate. Its cost is accuracy: a forecast 128 steps ahead is much worse on normal data, so the error gap shrinks from the other side. Our prediction is that gap forecasting matches us on long, slow anomalies and loses on short and medium ones, where its normal-data errors drown the signal. The length-stratified comparison settles this. If gap forecasting ties us across all strata, it is the better method, and we will say so.

Why not just hide flagged points without any learned reconstruction? The cheap-repair ablation tests this. If interpolation equals MOMENT repair, then the reconstruction direction contributes nothing, and the method reduces to a simpler gated forecaster, which we would then recommend.

Why not just train an idempotent or diffusion reconstruction model on each dataset? IGAD, MODEM and CrossAD all do this with strong within-dataset results. That requires normal training data from the target domain and per-dataset tuning, which is the setting TSB-UAD warns overstates progress. As a separate reference, not a competitor, we report one within-dataset IGAD-trained model on SMD and PSM, to show how much zero-shot detection gives up.

Proposed Experiments

Primary evaluation. We evaluate on TSB-AD-U (350 univariate series across 23 domains) and TSB-AD-M (17 multivariate datasets). VUS-PR is the primary metric. We also report delay between onset and detection, and correlation with the one-liners.

Secondary zero-shot check. We evaluate on SMD, PSM, MSL, SMAP, SWaT and the UCR archive, without tuning on any of them, so that results can be compared with TimeRadar's transfer setting.

Decisive checks. Four results determine whether the claim holds:

  • Long anomalies. On anomalies longer than the forecast horizon, clean-context VUS-PR should clearly exceed both the vanilla forecaster and gap forecasting. On point anomalies it should roughly tie, because spikes never poison the context much.
  • Held-out domains. The full method should beat our CAE rerun in aggregate, with leave-domain-out tuning. If it only wins when tuned on the evaluation domains, the cross-dataset claim fails.
  • Room for a better gate. The gap between the learned gate and the oracle mask measures how much a better gate could still add. If the oracle itself barely helps, context poisoning is not the bottleneck, and the premise is wrong.
  • Feedback failures. We will look for the two ways the gate loop can go wrong: missed anomaly onsets, and normal regime changes that keep being flagged. We will measure how often each occurs as $K$ varies, so the readmission rule is justified with evidence.