skip to content

Which input checks should gate an inbound spam filter's nightly retrain, and what should each one do when it fails?

level: middleimportance: should knowfreq 46%

answer

  1. a gate decides, a chart asks
  2. valid input written down once, then reviewed
  3. presence, bounds, missing share, staleness
  4. hard failure keeps yesterday's model serving
  5. a warn tier for tolerable breaches

basics

~20 s

Four deterministic checks against a frozen, reviewed spec of valid input: schema, range and allowed values, per-feature null ceilings, and freshness of the newest event. A hard failure stops the retrain, keeping the current model serving; a minor breach warns.

solid answer

~50 s

Before the nightly retrain reads its batch, I would run four checks against a **validity spec** captured from the live model's training data and frozen under review: a **schema** check (every expected feature present, with the right type, nothing unexpected), **range and domain** checks (sender reputation inside its bounds, attachment counts non-negative, the share of unknown language codes under a ceiling), a **null-rate ceiling** set per feature from its normal level, and **freshness** - the newest message timestamp within a stated limit, catching a stuck upstream re-delivering old data. Each check has a tier. A hard failure fails the retrain closed: no candidate is trained or promoted, yesterday's model keeps serving, and the batch is held for its owner. A warning lets the run proceed and records the breach. That is a gate, not a drift signal: it decides use or do-not-use, while drift charts only raise questions.

go deeper

for a junior

Name the four checks - schema, range and allowed values, null-rate ceilings, freshness - and say that a failed hard check stops the retrain while the current model keeps serving.

for a middle

Explain why the spec is captured from training data and frozen rather than re-derived, why null ceilings are per feature, and why freshness must read the newest timestamp in the data rather than the job status.

for a senior

Show the tiering judgment: which breaches block and which only warn, how a legitimate change like a new tenant's language reaches the spec, and how the serving path degrades per check instead of failing closed.

for a principal

Frame the trade between a strict gate that blocks retrains on harmless novelty and a loose one that teams stop reading, and say who owns the spec and its review so it neither ossifies nor drifts.

## What stands between the batch and the retrain An inbound spam filter for a multi-tenant mail service is retrained every night. The **training batch** is assembled from messages whose verdicts have matured - recipient spam reports, quarantine releases, reviewer decisions - joined to the feature values the scorer logged when it scored them. The retrain trusts whatever that batch contains: if the sender-reputation feed was down for half the day, or an upstream job re-delivered last week's partition, the next candidate model learns from it without complaint. An **input gate** is the deterministic check that runs before the retrain reads the batch and answers one question: is this batch valid input for this model, yes or no? It does not ask whether the world changed. It asks whether the data is broken. ## The validity spec is captured once and frozen Every check is judged against a **validity spec**: a written description of what valid input looks like for this model - the expected features and their types, each numeric feature's bounds, each categorical feature's allowed values, each feature's normal null level, and the maximum acceptable staleness. It is typically captured from the live model's training data, then **reviewed, versioned and frozen**. Frozen is the important word. If the spec were re-derived from whatever arrived tonight, a batch in which the reputation feature is mostly defaulted would produce a spec saying "mostly defaulted is normal", and the gate would pass exactly the batch it exists to stop. The spec changes only through a reviewed edit - a new feature added, a new language admitted. ## The four checks and what a failure does | check | what it tests | typical failure | action on a hard failure | |---|---|---|---| | **schema** | every expected feature present, with the expected type; nothing unexpected | a feature column missing, or a count arriving as text | stop the retrain | | **range and domain** | numeric bounds; categorical values inside the allowed set, and the share outside it under a ceiling | negative attachment counts; a burst of language codes never seen | stop, or warn if the out-of-set share is small | | **null / default-rate ceiling** | each feature's share of missing or defaulted values, against a ceiling set from that feature's normal level | the reputation feature defaulted on a large share of rows | stop the retrain | | **freshness** | the age of the newest event timestamp in the batch, against a stated maximum staleness | a stuck upstream re-delivering yesterday's messages | stop the retrain | A few details make these work in practice: - **Ceilings are per feature.** An optional header that is absent on a third of mail and a mandatory reputation score that is almost never missing cannot share one null limit. - **Freshness reads the data, not the job.** A pipeline can finish green while writing an old partition; only the newest timestamp inside the batch says how current it is. A 26-hour limit on a nightly batch is an illustrative value, not a standard. - **Failing closed is cheap here.** When the retrain stops, yesterday's model - trained on a batch that passed - keeps serving. A skipped night costs one day of model freshness, far less than promoting a model trained on broken input. - **The failed batch is held, not deleted**, and routed to the owner of the failing feature with the check that tripped. ## Hard fail versus warn Not every breach should block. A gate usually carries two **tiers**: 1. **Hard fail** - the batch is unusable as it stands: a missing feature, an impossible value, a null rate far above its ceiling, a stale batch. The retrain does not run, and no candidate is promoted. 2. **Warn** - the batch is usable but something is off: a small share of unseen category values, a null rate slightly above its usual level. The retrain proceeds and the breach is recorded where someone will read it. Making every check a hard fail sounds safe and is not: a new tenant's unseen language code would block every retrain until someone edits the spec, and teams learn to switch the gate off. Making everything a warning turns the gate into another dashboard. ## A gate is not a drift signal The difference is in what each one decides: - A **gate** tests one batch against fixed validity rules and decides **use or do not use**. It is deterministic: against the same spec, the same batch always gets the same verdict. - A **drift signal** compares distributions over windows - this week's score histogram against a reference - and **raises a question** without blocking anything. A legitimate shift, such as a large tenant onboarding, should pass the gate and still show on the drift charts. A broken batch must not depend on a statistical test noticing it, and a gate is the wrong tool for a slow, legitimate change in the traffic mix. ## The same checks on the live scoring path The scorer applies the same spec to each request, but mail cannot wait for an owner to fix a feed, so the action is chosen per check by what a wrong verdict costs: a schema-broken request goes to a simpler fallback path, a missing feature is scored with its default and the decision flagged. Blocking at training time and degrading at serving time are one gate with two costs of saying no.

  • Why not re-derive the validity spec from each night's batch, so it always reflects current traffic?
    Because the batch would then define its own validity. A batch where the reputation feature is mostly defaulted produces a spec in which mostly defaulted is normal, and the gate passes exactly what it exists to stop. Legitimate changes - a new feature, a new language - reach the spec through a reviewed edit, and following the traffic mix is the drift charts' job.
  • The same broken reputation feed reaches the live scorer. Why can the serving path not simply fail closed like the retrain?
    A skipped retrain costs one day of model freshness while yesterday's model keeps serving; mail cannot be held until an owner fixes a feed. So serving degrades instead of blocking, chosen per check by what a wrong verdict costs: a schema-broken request goes to a simpler fallback path, a missing feature is scored with its default and the decision is flagged so the defaulted share stays visible.
  • A new tenant onboards with mail in a language the spec has never seen, and the domain check trips. What should happen?
    If the unseen share is below the hard ceiling, the check warns and the retrain proceeds. If it is above, the batch is held and the owner decides: a legitimate new language is added to the allowed set through a reviewed spec change and the batch is re-run. Either way the onboarding also shows on the drift charts, which is where a traffic-mix change belongs.

  • Re-derives the validity spec from each night's batch, so any batch passes.
  • Lets the retrain run on a failed batch and plans to fix the model afterwards.
  • Relies on a drift alert to stop a broken batch instead of a gate.
  • Applies one null-rate ceiling to every feature regardless of its normal level.
  • Treats a green pipeline run as proof the batch is fresh.
  • Makes every check a hard failure, so any new category value blocks retraining.