Case: A Predictive Service with Reliable Features

Alderbank Software, the company in this case, is fictional, like everything about it: its storefront, its carriers, its warehouses, and every number below. A deterministic generator written for this article produces the orders, the delivery files, and the lateness labels, and the service is built and run against that generator on a laptop. The results describe this simulation. They are not measurements of any real delivery network, model, or organization, and no external service, paid API, or GPU was used. The model is a logistic regression from scikit-learn, chosen because the case is about the data and the release around the model, not about model capacity.

The service predicts, at the moment an order leaves the warehouse, whether it will be delivered after the date promised to the customer. Support staff use the ranking to contact the riskiest ten percent of shipments before the customer notices. That sounds like a modeling task, and most of the work is elsewhere: deciding which facts the service may use at that moment, proving the training data used the same facts, evaluating the model the way it will be used, shipping it so that it can be undone, and noticing when it stops working.

The case assumes the ideas of Feature Pipelines and Point-in-Time Correctness (event time versus availability time, as-of selection, leakage, backfills), Versioning Models, Data, Prompts, and Evaluation Artifacts (content identity, releases as bundles, rollback of a combination), Model Serving: Batching, Autoscaling, and Tail Latency (latency targets and what a benchmark can claim), Prompt and Model Promotion with Evaluation Gates (thresholds, intervals, and an inconclusive outcome), and AI Platform Incident Response and Recovery (containment, bundle rollback, recovery verification). It is the second case built on the same fictional company; the previous one, Case: Deploying AI Development Tools Across Engineering Teams, rolled out coding tools. The two do not depend on each other’s code. Environment: Python 3.12.14, numpy 2.2.3, scikit-learn 1.9.0, macOS 26.7.1.

Requirements and the decisions they force

Alderbank’s data platform team writes five requirements for the service before touching any code.

RequirementDecisionWhat is given up
R1. A prediction uses only facts the platform had ingested when the order shippedEvery feature carries an event time and an availability time; training rows are built by an as-of rule on availabilityConvenience: a training query cannot simply join the latest table, and fresh-looking history is often excluded
R2. Training and serving compute each feature from one definitionA versioned feature spec, two implementations (a batch builder and an online store), and a parity test between themTwo code paths to keep equal, in exchange for being able to test equality
R3. Evaluation resembles useTrain on matured labels, test on a later period with a gap, compare against simple baselines with intervalsA smaller training set, and a headline score that is lower than the leaky one
R4. A release is one unitA bundle names the model weights and the feature spec together; promotion and rollback move the whole bundleBoth feature versions stay computed in parallel while a release is on probation
R5. Degradation is noticed before customers noticeMonitors on feed freshness, value ranges, input and score distributions, and cohort accuracy once labels matureSome monitors are fast and blunt; the one that measures accuracy lags by about two weeks

The prediction is made when the warehouse scans the order out, called the prediction time \(p\). The label (late or not) is known only when the carrier’s delivery file reaches the platform, between four and forty hours after delivery, so a label is not usable until days after \(p\). That label delay shapes everything below.

The simulated world and its clocks

The generator produces 41,464 orders over 160 days, of which 17.1 percent are delivered late. Each order has an order time, a warehouse that picks it, a ship time, a carrier, a destination zone, a weight class, and a promised delivery time that depends on the zone. Four carriers differ in base transit time and in a slowly varying daily condition. Three warehouses run small queues with occasional surge days. All of these are assumptions of the simulation, set so that the late rate is in a plausible range and so that carriers, zones, and warehouse congestion each carry some signal.

Three facts about when information reaches the platform matter more than the rest, and the generator builds them in on purpose.

    # delivery files from carriers reach the platform in batches: 4 to 40 hours after delivery
    deliv_ingested = delivered + rng.uniform(4, 40, n)

    # carrier exceptions: most are raised after shipment (so they are known only in the current-state table)
    has_exc = np.where(late == 1, rng.random(n) < 0.65, rng.random(n) < 0.04)
    pre_ship = rng.random(n) < 0.10
    exc_time = np.where(pre_ship, order_time + 0.5 * (ship_time - order_time), ship_time + rng.uniform(0.3, 0.8, n) * transit)
    exc_time = np.where(has_exc, exc_time, np.inf)

First, a carrier’s delivery file reaches the platform four to forty hours after the delivery it reports (mean 22 hours). Second, ship scans reach the platform about half an hour after they happen. Third, carrier exceptions (a delay code, a damage report) are raised after shipment for 91 percent of exceptions, and the platform stores them in a table that holds the current exception state of each shipment. A shipment that ends up late usually has an exception on it by the time anyone looks, which is exactly why the exception flag is a tempting feature.

The feature spec has four parts. carrier_late_rate is the share of the carrier’s deliveries in the trailing seven days (by delivery time) that were late, shrunk toward a prior of 0.19 with the weight of 20 deliveries. wh_backlog is the number of orders at the order’s warehouse that have been placed and not yet shipped. exception_flag says whether a carrier exception is recorded for the order. The rest (zone, weight class, promised hours) are fields of the request itself and have no timing problem.

Two feature pipelines and an independent online store

The offline builder produces training rows. Its mode argument is the heart of the case: pit applies the as-of rule on availability, and the other modes apply, one at a time or together, the two mistakes that the feature-pipeline article warned about.

def offline_features(w, idx, spec, mode):
    """mode 'pit': only what the platform had ingested by the prediction time.
    mode 'leaky': event-time only, and the exception flag read from the current-state table.
    modes 'event_time' and 'current_state' apply one of those two mistakes at a time."""
    event_only = mode in ("leaky", "event_time")
    current_state = mode in ("leaky", "current_state")
    p = w["ship_time"][idx]
    W = spec.window_days * 24.0
    rate = np.zeros(len(idx)); backlog = np.zeros(len(idx))
    for c in np.unique(w["carrier"]):
        sel = np.where(w["carrier"] == c)[0]
        order = np.argsort(w["delivered"][sel]); sel = sel[order]
        td, ing, late = w["delivered"][sel], w["deliv_ingested"][sel], w["late"][sel]
        for j in np.where(w["carrier"][idx] == c)[0]:
            lo, hi = np.searchsorted(td, p[j] - W, side="right"), np.searchsorted(td, p[j], side="right")
            keep = np.ones(hi - lo, bool) if event_only else ing[lo:hi] <= p[j]      # the availability condition
            rate[j] = (late[lo:hi][keep].sum() + spec.prior * spec.k) / (keep.sum() + spec.k)
    for h in np.unique(w["wh"]):
        sel = w["wh"] == h
        ot = np.sort(w["order_time"][sel])
        st = np.sort((w["ship_time"] if event_only else w["ship_ingested"])[sel])
        m = w["wh"][idx] == h
        backlog[m] = np.searchsorted(ot, p[m], side="right") - np.searchsorted(st, p[m], side="right")
    if current_state:
        exc = np.isfinite(w["exc_time"][idx]).astype(float)           # whatever the table says today
    else:
        exc = (w["exc_time"][idx] + RECORD_LAG <= p).astype(float)
    return assemble(w, idx, rate, backlog, exc)

The event_time mistake filters the carrier window by delivery time only, so a delivery that happened before the prediction but whose file had not arrived is counted. In the backlog it uses the final ship time instead of the time the scan reached the platform. The current_state mistake reads the exception flag from the table as it stands when the training set is built, so it sees exceptions raised after the prediction. Both mistakes run without errors and produce plausible numbers, which is why they survive code review.

The online store is a separate implementation. It consumes events in arrival order, keeps counters and a heap of recent deliveries per carrier, and answers one request at a time from its state. It shares no code with the batch builder except the final column assembly.

class OnlineStore:
    """Keeps state from events in arrival order and answers one request at a time."""
    def __init__(self, spec, window_by_ingest=False):
        self.spec, self.open, self.window_by_ingest = spec, {}, window_by_ingest
        self.heap = {}; self.sum = {}; self.cnt = {}; self.last_ingest = {}
        self.exc = set()

    def on_order(self, wh): self.open[wh] = self.open.get(wh, 0) + 1
    def on_ship(self, wh): self.open[wh] -= 1
    def on_exception(self, oid): self.exc.add(oid)
    def on_delivery(self, c, delivered, late, ingest_t):
        heapq.heappush(self.heap.setdefault(c, []), (ingest_t if self.window_by_ingest else delivered, late))
        self.sum = self.sum.get(c, 0) + late; self.cnt = self.cnt.get(c, 0) + 1
        self.last_ingest = ingest_t

    def serve(self, w, i, p, use_ttl=False):
        """Features for order i at prediction time p. Returns (row, carrier_feed_age_hours)."""
        c, W = int(w["carrier"][i]), self.spec.window_days * 24.0
        h = self.heap.get(c, [])
        while h and h[0][0] <= p - W:
            _, late = heapq.heappop(h); self.sum -= late; self.cnt -= 1
        age = p - self.last_ingest.get(c, -1e9)
        if use_ttl and age > self.spec.ttl_hours:
            rate = self.spec.prior                                    # feed is stale: fall back to the prior
        else:
            rate = (self.sum.get(c, 0) + self.spec.prior * self.spec.k) / (self.cnt.get(c, 0) + self.spec.k)
        row = assemble(w, np.array([i]), np.array([rate]), np.array([self.open.get(int(w["wh"][i]), 0)]),
                       np.array([float(int(w["order_id"][i]) in self.exc)]))[0]
        return row, age

A small replay function feeds it the world’s events and the requests in time order. At equal timestamps, arrivals are processed before requests, which mirrors the less-than-or-equal condition of the offline builder. The timing, stall, and unit_bug arguments are hooks used by later experiments.

def replay(w, idx, spec, use_ttl=False, stall=None, window_by_ingest=False, timing=None, unit_bug=False):
    """Replay the world's events and the requests in time order. `stall=(t0, t1)` holds back every delivery
    file that would have arrived in [t0, t1) until t1, as a stuck materialization job would."""
    ev = []
    for i in range(w["n"]):
        ev.append((w["order_time"][i], 0, "order", i))
        ev.append((w["ship_ingested"][i], 0, "ship", i))
        t = w["deliv_ingested"][i]
        if stall and stall[0] <= t < stall[1]:
            t = stall[1]
        ev.append((t, 0, "deliv", i))
        if np.isfinite(w["exc_time"][i]):
            ev.append((w["exc_time"][i] + RECORD_LAG, 0, "exc", i))
    for i in idx:
        ev.append((w["ship_time"][i], 1, "req", i))
    ev.sort(key=lambda e: (e[0], e[1]))
    st, rows, ages = OnlineStore(spec, window_by_ingest), {}, {}
    for t, _, kind, i in ev:
        if kind == "order": st.on_order(int(w["wh"][i]))
        elif kind == "ship": st.on_ship(int(w["wh"][i]))
        elif kind == "exc": st.on_exception(int(w["order_id"][i]))
        elif kind == "deliv": st.on_delivery(int(w["carrier"][i]), w["delivered"][i], int(w["late"][i]), t)
        else:
            t0 = time.perf_counter_ns()
            rows[i], ages[i] = st.serve(w, i, t, use_ttl)
            if unit_bug:
                rows[i][0] *= 100.0                                  # a defect in the online job: the rate is emitted in percent
            if timing is not None:
                timing.append(time.perf_counter_ns() - t0)
    order = [i for i in idx]
    return np.array([rows[i] for i in order]), np.array([ages[i] for i in order])

Tests that find the leaks

The feature-pipeline article described a perturbation test: change something that could not have been known at prediction time, and check that no feature changes. Two perturbations are needed, because the two mistakes are different in kind. The first appends 3,000 delivery records that the platform receives on day 300. The second rewrites the exception table after every prediction, adding exceptions that were raised on day 300.

def perturb(w, rng=np.random.default_rng(3), count=3000):
    p = {k: (np.concatenate([v, np.zeros(count, dtype=v.dtype)]) if isinstance(v, np.ndarray) else v) for k, v in w.items()}
    sl = slice(w["n"], w["n"] + count)
    p["n"] = w["n"] + count
    p["order_id"][sl] = np.arange(w["n"], w["n"] + count)
    for k in ("order_time", "ship_time", "ship_ingested"): p[k][sl] = -1000.0       # outside every window
    p["carrier"][sl] = rng.integers(0, 4, count); p["wh"][sl] = 0
    p["delivered"][sl] = rng.uniform(100 * 24, 150 * 24, count); p["late"][sl] = 1
    p["deliv_ingested"][sl] = 300 * 24.0                                              # known on day 300
    p["exc_time"][sl] = np.inf; p["zone"][sl] = 0; p["weight"][sl] = 0; p["promised_hours"][sl] = 58.0
    return p
def rewrite_later(w, rng=np.random.default_rng(4), count=2500):
    q = {k: (v.copy() if isinstance(v, np.ndarray) else v) for k, v in w.items()}
    none = np.where(~np.isfinite(q["exc_time"]))[0]
    pick = rng.choice(none, count, replace=False)
    q["exc_time"][pick] = 300 * 24.0
    return q

Each pipeline is built before and after each perturbation on the 3,616 rows of the test period, and the second experiment compares each offline pipeline with the online store on the same rows.

41464 orders over 160 days; late rate 0.171
ship scan reaches the platform after a mean of 30 minutes
delivery file reaches the platform 4 to 40 hours after delivery (mean 22.0)
exception recorded after shipment for 91% of exceptions

perturbation tests on the test-period rows: how many of 3616 feature rows change
  pipeline        late records appended  table rewritten later
  pit                                 0                      0
  event_time                       3605                      0
  current_state                       0                    214
  leaky                            3605                    214

parity: offline builder versus the online store replaying the same events (test-period requests)
  mode           carrier_late_r     wh_backlog exception_flag
  pit                         0              0              0
  event_time               3616           3616              0
  current_state               0              0            458
  leaky                    3616           3616            458
  (cells are the number of rows, out of 3616 , where the two implementations disagree)

offline score on the test period, by pipeline
  pit            AUC 0.822  AP 0.491  recall@10% 0.329
  event_time     AUC 0.827  AP 0.498  recall@10% 0.329
  current_state  AUC 0.926  AP 0.771  recall@10% 0.548
  leaky          AUC 0.927  AP 0.775  recall@10% 0.551

largest difference in carrier_late_rate caused by the event-time-only mistake: 0.046 (median 0.0050; the feature itself averages 0.179)

Read the first table by column. Appending late records leaves the point-in-time pipeline untouched and changes almost every row of the two pipelines that select by event time. Rewriting the table leaves both of those unchanged and moves 214 rows of the two pipelines that read the exception flag from the current state. Neither perturbation alone detects both mistakes. A test suite that includes only the first, the one the clocks discussion makes famous, would pass the current-state join.

The parity table gives a second view. The point-in-time pipeline agrees with the independently written online store on every row and every feature. The event-time mistake disagrees on the carrier rate and the backlog for every row, though only slightly: the largest difference in carrier_late_rate is 0.046, the median 0.005, against a feature that averages 0.179. The current-state mistake disagrees on 458 rows of the exception flag, those where an exception was raised after the prediction. Parity needs the serving implementation and a log of what was served, so it can run only where both exist, while the perturbations run in continuous integration on the offline builder alone. The two kinds of test cover different ground, and a release process wants both.

The last table of the output is the reason the mistakes survive. Scored offline on the test period with a model trained on each pipeline’s own features, the event-time mistake moves AUC from 0.822 to 0.827, a difference nobody would notice. The current-state mistake moves it to 0.926. The leak that most changes the score is the mutable table, not the late-arriving record, and the leak that most changes the features is the late-arriving record, which the score barely registers. A team that looked only at suspiciously good metrics would find the first and never the second.

Evaluating the model the way it will be used

A model is trained on rows shipped on days 21 through 90 whose labels reached the platform by day 100, which is 18,109 rows with a late rate of 0.161. It is tested on the 3,616 rows shipped on days 100 through 113 (late rate 0.159). The training rows end nine days before the test rows begin, which is longer than the longest possible label delay, so no training label is built from an outcome that was unknown when the test period started. The helper that selects the training rows enforces this.

H = 24.0
TRAIN_DAYS, TRAIN_CUTOFF_DAY = (21, 91), 100          # rows shipped in [21, 91); labels must be ingested by day 100
TEST_DAYS = (100, 114)                                # a nine-day gap separates the last training row from the first test row

def rows_between(w, days):
    return np.where((w["ship_time"] >= days[0] * H) & (w["ship_time"] < days[1] * H))[0]

def train_rows(w):
    idx = rows_between(w, TRAIN_DAYS)
    return idx[w["deliv_ingested"][idx] <= TRAIN_CUTOFF_DAY * H]      # only matured labels

The first evaluation compares protocols, not models.

train: 18109 rows shipped on days 21-90, labels ingested by day 100; prevalence 0.161
test : 3616 rows shipped on days 100-113; prevalence 0.159

protocol                                        AUC     AP  recall@10%
leaky features, random split                  0.918  0.785       0.539
leaky features, time split                    0.927  0.775       0.551
point-in-time features, random split          0.799  0.451       0.305
point-in-time features, time split            0.822  0.491       0.329
  same, but training rows use immature labels  0.823  0.490       0.330

scored on the features the online store actually serves for the same test rows
model / baseline                                AUC     AP  recall@10%  mean score
leaky-trained model                           0.823  0.489       0.327       0.101
point-in-time model                           0.822  0.491       0.329       0.173
baseline: carrier_late_rate alone             0.696  0.282       0.224           -
baseline: constant prior                      0.500  0.159       0.100           -
observed prevalence in the test rows: 0.159
gate on AP         : model minus baseline +0.209, 95% interval [+0.176, +0.240], required gain >= 0.05: PASS
gate on recall@10% : model minus baseline +0.104, 95% interval [+0.073, +0.141], required gain >= 0.05: PASS

The top half of the first table is the headline comparison. With leaky features and a random split the model scores an AUC of 0.918 and an average precision (AP) of 0.785. With point-in-time features and a time split it scores 0.822 and 0.491. Both numbers are honest descriptions of their protocols and only one is a description of production. Two other rows are worth reading. A random split with point-in-time features scores slightly lower than the time split (0.799 against 0.822), so in this world the random split did not inflate the estimate, because the features are not strongly autocorrelated over time and the period-to-period variation is modest. That would not be true of every dataset, and the time split is still the better habit, since it is the protocol that cannot be inflated by neighbors in time. The row that trains on immature labels, using the final outcome of rows whose delivery had not yet been reported at day 100, scores within 0.001 of the matured training. The rule about label maturity costs nothing here and prevents a leak that other data could make large.

The bottom half of the output scores the same test rows with the features the online store actually serves, which is what production would see. The leaky-trained model falls from the 0.927 it showed offline to 0.823, because the exception flag it relied on is almost always zero at prediction time. The point-in-time model scores 0.822 offline and 0.822 served. This is the property the whole pipeline is built for: the offline estimate predicts the production result.

Two further observations come from the same table. The leaky-trained model is not much worse than the point-in-time model in production ranking (0.823 against 0.822), because the weights on the real features are almost unchanged. Its damage is of two other kinds. It overstates what the service can do by about 0.10 in AUC and 0.29 in AP, which would distort any decision that depended on the estimate. And it is miscalibrated: its mean served score is 0.101 against an observed rate of 0.159, because the intercept learned to rely on the flag. A support team that alerts on a fixed score threshold would see far fewer alerts than planned. The point-in-time model’s mean score is 0.173, close to the observed rate.

The baselines show what the model adds. A constant prediction has an AUC of 0.5 and an AP equal to the late rate. The carrier’s recent late rate alone, which a data analyst could compute in a spreadsheet, scores an AUC of 0.696 and an AP of 0.282. The release gate asks whether the model beats this baseline by at least 0.05 in AP and in recall within the top ten percent, with a 95 percent interval from a paired bootstrap over test rows: the model’s AP is 0.209 higher (interval 0.176 to 0.240) and its top-decile recall 0.104 higher (0.073 to 0.141), so both gates pass. The gate would have returned INCONCLUSIVE if the interval had straddled the required gain, as in the evaluation-gate article.

What this evaluation does not establish: it tests one period of fourteen days in a simulated world, with a single model family, against two simple baselines. It says nothing about the weeks after day 114, which is the subject of the monitoring section.

One release, one identity

The service is deployed as a bundle: the model weights, the feature spec version with its window and shrinkage parameters, the feature names in model order, the training window, and the gate evidence. The release identifier is a hash of the canonical serialization of all of it, as in the artifact-versioning article.

@dataclass(frozen=True)
class Bundle:
    name: str
    spec: dict                 # feature definition version, window, shrinkage
    features: tuple            # feature names in model order
    model: dict                # exported weights
    train_rows: tuple          # (first day, last day, number of rows)
    evidence: dict             # gate result recorded at promotion

    def release_id(self):
        return sha(canon(asdict(self)))[:12]

class Registry:
    def __init__(self):
        self.bundles, self.history = {}, []          # history: (time, alias target)

    def register(self, b):
        self.bundles[b.release_id()] = b
        return b.release_id()

    def promote(self, rid, t):
        self.history.append((t, rid))

    def champion(self):
        return self.history[-1][1]

    def rollback(self, t):
        """Point the alias at the previous release. Everything the release names (model AND feature spec) moves together."""
        prev = self.history[-2][1]
        self.history.append((t, prev))
        return prev
release id: 3f963b7c3b2f
same content, same id: True
one weight changed in the 8th decimal -> id: ba1b9732e0e7
feature window 7 -> 3 days (same model)  -> id: c1dbecac3672

max |numpy scorer - trained pipeline| over 3616 test requests: 1.60e-10

feature lookup (state update excluded), 3616 calls: p50 22.4 us, p99 69.5 us, max 7939.9 us
scoring, 3616 calls: p50 5.2 us, p99 21.8 us, max 33.4 us
python 3.12.14, one process, no network, no real feature store

The identifier changes when one weight changes in the eighth decimal, and it changes when only the feature window changes from seven days to three with the model untouched. The second property is the one the case depends on later: a feature spec is part of the release, so changing it is a new release, never a configuration tweak. The numpy scorer used at serving time matches the trained scikit-learn pipeline to within 2e-10 over the test requests, so serving does not need the training library.

The latency numbers come from timing the in-process calls: a feature lookup takes a median of 22 microseconds and a 99th percentile of 70 microseconds, and scoring takes a median of 5 microseconds. The maximum lookup was 8 milliseconds, which is likely a garbage-collection pause, and shows why a tail percentile from a single process says little about a service. These figures count only Python work in one process, with state in memory. A real service adds a network hop, a store with its own tail latency, serialization, and queueing, which the serving article treats; a latency target must be set and measured on that whole path. What the local numbers do show is that the computation itself is far below any plausible budget, so the budget will be spent on the lookup path and not on the model.

Monitoring when labels are late

Once the model is live, the question changes from “is it good” to “is it still good.” The labels arrive late, so the monitors fall into two groups: fast ones that need no labels, and one slow one that measures accuracy.

The fast ones can be written down before launch. Feed freshness is the age of the newest delivery file for each carrier, and in this world it never exceeded 4.7 hours in healthy operation, so an alert at 24 hours has a large margin. A range check on each feature says that carrier_late_rate is a fraction. A distribution monitor compares each cohort of recent requests with the training distribution, using the population stability index (PSI) over five quantile bins from the training data.

def psi(ref, cur, bins=5):
    edges = np.unique(np.quantile(ref, np.linspace(0, 1, bins + 1)[1:-1]))
    r = np.bincount(np.searchsorted(edges, ref, side="right"), minlength=len(edges) + 1) / len(ref)
    c = np.bincount(np.searchsorted(edges, cur, side="right"), minlength=len(edges) + 1) / len(cur)
    r, c = np.clip(r, 1e-4, None), np.clip(c, 1e-4, None)
    return float(np.sum((c - r) * np.log(c / r)))

The slow monitor evaluates accuracy on a cohort of predictions after every label has matured. A cohort of requests shipped in a given week can be scored only after its slowest delivery is reported, which in this world is nine days after the cohort ends. Scoring a rolling window of the labels available today would be wrong, because the labels that arrive first are those of the fast deliveries, which are mostly on time. The rule is: weekly cohorts, scored once, and an alert when the upper end of a 90 percent bootstrap interval for the cohort’s AUC falls below the validated AUC minus 0.03, which is 0.792.

The monitors are tried in two simulated worlds that differ in one respect. In the second, a regional disruption from day 120 adds ten hours of last-mile delay in two destination zones for every carrier. The model serving them is the one trained above and nobody retrains it.

== no disruption
   cohort  prev mean score  max PSI  input alert    AUC   90% interval  outcome alert  known on day
 100-106   0.20       0.17     0.15            -  0.835 [0.817,0.854]              -           116
 107-113   0.12       0.18     2.47        ALERT  0.827 [0.806,0.848]              -           123
 114-120   0.06       0.13     0.45        ALERT  0.789 [0.756,0.817]              -           130
 121-127   0.16       0.12     1.91        ALERT  0.782 [0.760,0.809]              -           137
 128-134   0.16       0.15     1.03        ALERT  0.778 [0.758,0.800]              -           144
 135-141   0.18       0.18     0.07            -  0.829 [0.808,0.850]              -           151
 142-148   0.12       0.17     0.12            -  0.818 [0.794,0.839]              -           158
 149-155   0.19       0.16     1.93        ALERT  0.810 [0.789,0.829]              -           165
input alerts: 5 of 8 cohorts; outcome alerts: 0 of 8

== regional disruption from day 120
   cohort  prev mean score  max PSI  input alert    AUC   90% interval  outcome alert  known on day
 100-106   0.20       0.17     0.15            -  0.835 [0.815,0.852]              -           116
 107-113   0.12       0.18     2.47        ALERT  0.827 [0.805,0.847]              -           123
 114-120   0.06       0.13     0.45        ALERT  0.782 [0.740,0.814]              -           130
 121-127   0.19       0.13     1.82        ALERT  0.697 [0.667,0.726]          ALERT           137
 128-134   0.20       0.16     1.65        ALERT  0.690 [0.664,0.717]          ALERT           144
 135-141   0.22       0.19     0.35        ALERT  0.754 [0.729,0.780]          ALERT           151
 142-148   0.16       0.19     0.11            -  0.738 [0.711,0.764]          ALERT           158
 149-155   0.25       0.18     1.18        ALERT  0.724 [0.705,0.746]          ALERT           165
input alerts: 6 of 8 cohorts; outcome alerts: 5 of 8

In the world with no disruption, the outcome monitor raises no alert in eight cohorts, and the input monitor (any PSI above 0.25 on the carrier rate, the backlog, or the score) raises alerts in five of eight. The alerts come from the carrier rate, which is nearly discrete (each carrier has its own level) and does move when a carrier has a good or bad week. That movement is real and the model uses it as its signal, so it is not harmful. PSI on a feature like this is a prompt for a human to look and is a poor trigger for a page.

In the disrupted world, the cohort that begins on day 121 scores an AUC of 0.697 with an interval of 0.667 to 0.726, well under the threshold, and every later cohort does too. The first cohort affected is known on day 137, seventeen days after the disruption began. The input monitor fired on that cohort as well, and on five of the others, which would have been indistinguishable from its behavior in the quiet world. The practical reading is that no single monitor suffices. The input monitors are fast and non-specific. The outcome monitor is specific and slow. A fast monitor that is both would use a leading indicator of lateness, such as orders that are already past their promised date with no delivery reported, which this simulation does not model and a real design would study.

Failure one: the feed stalls

On day 135 the job that applies carrier delivery files stops for 72 hours and then catches up. The experiment replays the world with that stall and scores the requests from day 135 through the day after the catch-up with the deployed model, in three variants: a healthy feed, serving the stale values, and a policy that treats a carrier feed older than 24 hours as missing and substitutes the prior.

requests from day 135 to day 138 plus one day of catch-up: 1073; prevalence 0.225

variant                               AUC     AP  recall@10%  requests on prior
healthy feed                        0.792  0.590       0.336                  0
stalled, serve the stale value      0.785  0.578       0.324                  0
stalled, TTL 24 h then prior        0.756  0.539       0.299                532

feed age (hours since the last delivery file for the request's carrier), by 12-hour block
  block starting  max age   monitor (alert > 24 h)
    day 135 +0 h     12.4                        -
   day 135 +12 h     24.4                    ALERT
   day 135 +24 h     36.4                    ALERT
   day 135 +36 h     48.2                    ALERT
   day 135 +48 h     60.4                    ALERT
   day 135 +60 h     72.3                    ALERT
   day 135 +72 h      1.6                        -
   day 135 +84 h      1.8                        -
offline rebuild with original ingestion timestamps           :  796 of 1073 rows differ from what was served
offline rebuild with timestamps corrected to actual arrival  :    0 of 1073 rows differ from what was served

Serving stale values costs 0.007 in AUC (0.792 to 0.785). The fallback to the prior costs 0.036, and it was triggered for 532 of the 1,073 requests. The result is opposite to what the fallback’s design intends, and the reason is mechanical: a seven-day average over several hundred deliveries per carrier does not become wrong in a day, and when it eventually stops being informative the shrinkage toward the prior does the same job gradually. The fallback is a cliff laid over a slope. The decision that follows is to serve the stale value, mark the request as served from a stale feed, and alert on feed age at 24 hours, which the monitor does in the first block after the stall begins. A fallback belongs where stale data is more misleading than no data, and the data for that choice came from this experiment, not from the default TTL in the configuration. A feature with a much shorter window would be more sensitive to a stall, so a TTL should be set per feature from an experiment like this one.

The last two lines are the recovery lesson. After the catch-up the freshness monitor returns to normal at once, which is easy to see. The harder question is the record. If the offline store keeps the delivery files’ original timestamps, a training set rebuilt for the stall period will contain features the service never had: 796 of the 1,073 rebuilt rows differ from what was served. If the ingestion log is corrected to record when the files actually arrived, the rebuild matches the served features on all 1,073 rows. Retraining on the first would teach the model about a world with no stall. A recovery from an outage of this kind is not complete until the availability timestamps in the offline store say what happened, and a parity check against a served sample is the test of that.

Failure two: a rushed release

A month into the disruption, the data team retrains. Labels for rows shipped through day 140 are ingested by day 150, so the candidate is trained on 8,849 rows shipped on days 100 through 133 and evaluated on 1,829 rows shipped on days 134 through 140, which neither model saw during training. The candidate also changes the feature spec: the carrier window shrinks from seven days to three and the shrinkage weight from 20 to 10, so that the rate reacts faster. That makes it a new bundle, R2, replacing R1 (the seven-day bundle from the evaluation section). The promotion gate asks for non-inferiority to the incumbent with a margin of 0.01 in AUC and AP, using a 95 percent paired bootstrap over holdout rows.

candidate trained on 8849 rows shipped on days 100-133; holdout 1829 rows shipped on days 134-140 (labels ingested by day 150)

holdout days 134-140            AUC     AP  recall@10%  mean score   (prevalence 0.223)
incumbent R1 (v1 features)    0.767  0.561       0.327       0.188
candidate (v2 features)       0.804  0.593       0.327       0.193
gate on AUC: candidate minus incumbent +0.037, 95% interval [+0.022, +0.053], non-inferiority margin -0.010: PASS
gate on AP : candidate minus incumbent +0.032, 95% interval [+0.006, +0.055], non-inferiority margin -0.010: PASS
parity canary, online job as designed          : worst feature carrier_late_rate (max abs diff 0) -> PASS
parity canary, online job with the unit defect : worst feature carrier_late_rate (max abs diff 56.1) -> FAIL

registry: R1 = 4da57e833015, R2 = 71ceeb6bb25f; champion after promotion = 71ceeb6bb25f

first windows after the release (100 requests each), compared with the candidate's training distribution
  window 1 ends  9.4 h after release: PSI carrier_late_rate   7.36, score  7.36, carrier_late_rate in [5.74, 64.17]
  window 2 ends 19.2 h after release: PSI carrier_late_rate   7.36, score  7.36, carrier_late_rate in [4.15, 66.92]
  window 3 ends 28.7 h after release: PSI carrier_late_rate   7.36, score  7.36, carrier_late_rate in [3.31, 72.38]

option (514 requests on days 151-152)                         AUC     AP  recall@10%  mean score   (prevalence 0.222)
A  leave R2 running (v2 model, defective v2 job)            0.636  0.309       0.175       1.000
B  alias moves model back to R1; feature job stays v2 (defect)  0.671  0.368       0.202       1.000
C  roll back the bundle: R1 model + v1 feature job          0.782  0.598       0.360       0.168
D  fix the unit defect and re-release R2                    0.816  0.649       0.342       0.190

after bundle rollback the alias points at 4da57e833015; its spec version is v1 and its job is the v1 job

range check on carrier_late_rate at the serving boundary
  defective v2 job: first request violates it -> True; violations in the first 100 requests: 100
after the rollback: 475 requests served by R1 with the v1 job
  range violations: 0
  PSI carrier_late_rate vs R1 training: 1.92; score PSI: 0.02
  parity sample of 475 requests against the offline rebuild: max abs diff 0.0e+00

upper 95% bound on the violation rate after n clean requests: 1 - 0.05**(1/n)
  n=   50  <= 0.0582
  n=  200  <= 0.0149
  n= 1000  <= 0.0030
  n= 5000  <= 0.0006

The first block is the gate. On the holdout the candidate is better than the incumbent by 0.037 in AUC (interval 0.022 to 0.053) and 0.032 in AP (0.006 to 0.055), so both gates pass. This is a legitimate improvement for the disrupted period and nothing in this part is wrong. What goes wrong is the second block. The release process includes a parity canary, 500 requests compared between the online job and the offline rebuild, and in the rush it is skipped. The block shows what it would have done: the job as designed matches to within rounding, and the job that was actually deployed fails by 56 on carrier_late_rate, because a refactor made the online job emit the rate in percent. The defect is a unit error, the plainest case of training-serving skew, and the offline gate cannot see it because the gate evaluates the offline builder.

R2 is promoted on day 151. The third block shows the first requests it serves. In windows of 100 requests (about nine hours of traffic) the PSI of the rate and the score is 7.36, far past any threshold, and the rate ranges from 3 to 72 where it can only range from 0 to 1. A range check on the first request would have caught it, and the distribution monitor catches it in the first window. The accuracy cannot yet be known, since labels are days away. The decision therefore rests on the fast monitors and on a rule decided in advance: a range violation on a feature is a stop.

The last table lists the options on the 514 requests of days 151 and 152, scored with the labels the simulation holds (a real team would not have them until about day 162).

OptionMeaningAUCAPRecall in top 10%
ALeave R2 running0.6360.3090.175
BMove the model alias back to R1; the feature job stays at v20.6710.3680.202
CRoll back the bundle: R1’s model with the v1 feature job0.7820.5980.360
DFix the unit defect and release R2 again0.8160.6490.342

Option B is the instructive failure. The model alias is the visible part of the release, so moving it feels like a rollback, and the registry reports the old release as champion. But the feature job still emits the v2 features, in the defective unit, to a model that expects v1 features, and the mean score stays at 1.0, a saturated model. The bundle holds the feature spec so that the rollback restores the pair. Option C moves the alias and the feature path together, which requires that the v1 job has been kept running in parallel since the promotion. That is the cost named in the requirements table, and this is the incident it pays for. Option D is the best on the day’s data (AUC 0.816 against 0.782 for C), but 514 requests cannot distinguish C from D with confidence, and D requires fixing the code and passing the checks that were skipped. The order of operations is therefore C first and D after verification.

The registry call is one line (reg.rollback), and the verification block runs after it. Of the 514 requests, 475 were served after the rollback at three hours. They have no range violations, the score PSI against R1’s training distribution is 0.02, and a parity sample of all 475 against the offline rebuild differs by 0.0. The carrier-rate PSI against R1’s training distribution is 1.92 and does not return to normal, as the monitoring section predicts: the disruption has genuinely moved the carriers’ recent late rates, and this check cannot distinguish that from a defect. The checks that can are the range check, the parity sample, and the score distribution. This is the recovery-verification idea from the incident article applied to a feature path: a restored service is one for which the specific failure checks pass, not one for which the alert stopped.

Re-releasing D uses the same arithmetic as the incident article’s staged re-enabling. After \(n\) consecutive requests with no violation, an exact one-sided 95 percent upper bound on the violation rate is \(1 – 0.05^{1/n}\). It is 5.8 percent after 50 requests, 1.5 percent after 200, 0.30 percent after 1,000, and 0.06 percent after 5,000. The bound applies to independent requests from a similar distribution, and a unit error is deterministic, so in practice the parity canary before release is the real protection. The number’s use is to decide how long to hold a canary when the failure is probabilistic.

What this case does and does not show

The mechanisms are exact in the simulation and their sizes are not transferable. The exception flag dominates because the generator makes it so; in a real pipeline the leaking column is whatever table the team happens to join. The parity test passes without difficulty because both implementations are small and written by the same author. The window parameters, the disruption, and the carriers are invented. The simulation has no label noise, no delayed corrections to past records, and no personally identifying data, and a real pipeline has all three. The retention duties for stored feature history and served-feature logs, covered in the data engineering articles, are not exercised here. One world with one seed was used for the headline tables (seed 10 was chosen from the first twelve because its test period resembles its training period, with a late rate of 0.159 against 0.161; other seeds give a test period that differs more, which shifts the headline numbers but not the comparisons).

Three habits do carry over. Give every feature two clocks and test the pipeline against inputs that the platform could not have had. Evaluate with a protocol that matches use, and compare with a baseline that anyone could compute. Ship the model and the feature definition as one named thing, so that undoing a release means undoing both. The next case, Case: Migrating a Data Platform While Preserving AI Consumers, takes the opposite position: the consumers already exist, features among them, and the data underneath them has to move.

References


Discover more from Insightful Data Lab

Subscribe to get the latest posts sent to your email.

Similar Posts

Questions, corrections, or additional insights?

This site uses Akismet to reduce spam. Learn how your comment data is processed.