Problem
Every finished A/B test leaves the code of the losing variant in the product. Developers delete it by hand, for each experiment, sometimes across several repositories. At Agoda the tech team spends about 1200 dev days per quarter on this cleanup.
Example from the article: each repository wraps the shared experiment library in its own class (for logging, variant overrides and so on), so a find-and-replace on the library's class and method names does not work.
Solution in brief
Agoda fixes a coding convention: one wrapper function per experiment that returns true for variant B, tagged with a comment such as // AutoExp:EXP-1000:Wrapper. A syntax-tree refactoring tool (Polyglot Piranha) then replaces calls to the wrapper with true or false and simplifies the code. A containerized pipeline finds the repositories, runs the tool and opens merge requests.
Questions this case answers
- How to remove the dead branch of a finished experiment from many codebases and languages when each codebase wraps the shared experiment API in its own way
- How to make automated source refactoring reliable when generative models return inconsistent or invalid code
- How to remove the code of the losing variant after an A/B test without manual developer work?
- How to find every repository that contains code of one experiment and clean it in one run?
Tools and methods
- Polyglot Piranha — open-source tool that edits syntax trees by rules
- Tree-sitter — parser generator Piranha uses; supplies the Scala grammar
- Wrapper function and comment tags — convention that maps code and tests to an experiment
- GitLab API and CI — clone, merge requests, CI status
- scalafix and scalafmt — Scala code quality tools run after Piranha
- Apache Superset — dashboard of pipeline success and adoption
Google or a one-time email code. No password.