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
Reads the page, not a picture
The resolver runs one read-only script in the page, with no model and no network call. It returns a state and the tier that decided it, or it abstains.
Tries the strongest signal first
The tiers run from native inputs and their labels, through ARIA state on the element, a single child or a nearby ancestor (crossing shadow roots), to state attributes, tree-widget state and paired on/off icons. A state class on the element comes last.
Abstains instead of guessing
Conflicting signals, or none at all, mean no answer. It never infers "off" from a missing class, and it leaves tri-state controls alone.
Fails with guidance
When it abstains, the step fails with a message naming the kind of ambiguity it hit and how to fix the test: narrow the locator, or switch to a visual comparison step. The messages ship in English and Japanese.
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
Shadow mode
Behind a canary flag, the resolver ran after every real model decision and recorded whether it agreed, without affecting any result.
A scan over production logs
The offline tool split model calls from resolver decisions to give agreement, abstains and errors per tier, plus a backtest.
Tiers from failure clusters
Abstains were grouped into clusters, and each fixable cluster became a new tier. One tier that never fired across 4,074 results was removed. Cases where the "checkbox" is only an image stayed with vision on purpose.
Result
Over the canary there were 3,505 shadow decisions. 94.0% were resolved, and 99.5% of the resolved ones matched the model.
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
- TypeScript
- DOM and ARIA
- Error tracking
- Node.js log-scan tools
- PostgreSQL