Find feature flags that are safe to remove

Agent buildEasy10 minMeta and Uber style

Your task

Your codebase carries hundreds of feature flags, many fully rolled out years ago. An agent opens a pull request to remove a flag, but only when every observation of it shows the same settled value for long enough.

Write select_removable_flags(observations, min_flat_days): the rule your agent follows to pick the flags it may remove.

  • observations (list of str): one per flag, environment and segment, written name,environment,segment,serving_percent,flat_days, for example "checkout_v2,prod,default,100,180". serving_percent is the share of traffic on the new path, and flat_days is how long it has stayed there. Both are whole numbers.
  • min_flat_days (int): how long every observation must have been flat.
  • Return the removable flag names, each once, sorted in ascending order.

A flag is removable only if all 3 hold:

  1. Every observation of it has the same serving_percent, across all environments and segments.
  2. That shared value is 0 or 100.
  3. Every observation of it has flat_days of at least min_flat_days.

Examples

select_removable_flags(observations: list[str], min_flat_days: int) -> list[str]
Example 1
Inputselect_removable_flags(["checkout_v2,prod,default,100,180", "checkout_v2,prod,enterprise_a,0,180", "new_pricing,prod,default,100,200", "new_pricing,staging,default,100,200"], 90)
Output["new_pricing"]
Example 2
Inputselect_removable_flags(["dark_mode,prod,default,0,365", "dark_mode,staging,default,0,365", "ab_test,prod,default,50,400"], 90)
Output["dark_mode"]
Example 3
Inputselect_removable_flags(["fast_path,prod,default,100,30", "fast_path,staging,default,100,120"], 90)
Output[]