← Back to the CV

Work project · model evaluation

Retiring a model with a canary

At work I replaced an image-classification model with a deterministic resolver that reads the page's DOM. I shadow-tested it in production behind a canary flag, where it agreed with the model 99.5% of the time when it gave an answer. I then made it the only path, after which the model was removed. This page describes the design in general terms and leaves out the employer's systems, data and names.

The problem

A test-automation step had to say whether a checkbox was ticked. A native checkbox reports that itself. Custom widgets don't: a styled element or an icon toggle carries its state in whatever way its developer chose. For those, the product sent a screenshot of the element to an image-classification model. Before the change, the model was called on nearly half (47.3%) of those steps. That meant a remote call on the critical path of every such test, a separate service to run and pay for, and an answer nobody could explain when it was wrong. Most of that load turned out to be a workaround for weak element resolution, not a real need for vision. The page usually already knew the answer.

What it does

Architecture

When a checkbox step runs, the test runner injects one read-only script into the page under test. The script finds the target element and walks a fixed ladder of tiers, each a pure check on DOM and ARIA state, stopping at the first tier that gives an unambiguous answer. It hands back either a state with the deciding tier, or an abstain with a reason. During the canary, the runner still called the model for the real result, then ran the resolver alongside it and logged whether the two agreed, per tier, without changing the outcome. Abstains went to the error tracker. A separate offline tool read run records from the database and scanned each run's logs to work out agreement, abstains and errors per tier. Once the resolver became the only path, the model client was removed, and the step's only dependency became the page itself.

How it was proven

Outcome

The rollout went in stages: design, then canary only, then new tiers week by week, then a flag that made the resolver the only path with no model fallback, rolled out gradually. Once the model was receiving no real traffic, it was removed. From that point, rolling back meant reverting a single change. The checkbox step no longer waits on a remote model, and every answer can be traced to the DOM signal that decided it.

What it doesn't do

About 2% of cases are genuinely visual or exotic widgets. They now fail with a clear way to fix the test rather than a model's guess. That was a deliberate choice over keeping the model as a safety net.

Built with