Find feature flags that are safe to remove
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, writtenname,environment,segment,serving_percent,flat_days, for example"checkout_v2,prod,default,100,180".serving_percentis the share of traffic on the new path, andflat_daysis 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:
- Every observation of it has the same
serving_percent, across all environments and segments. - That shared value is 0 or 100.
- Every observation of it has
flat_daysof at leastmin_flat_days.
Examples
select_removable_flags(observations: list[str], min_flat_days: int) -> list[str]Example 1
Input
select_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
Input
select_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
Input
select_removable_flags(["fast_path,prod,default,100,30", "fast_path,staging,default,100,120"], 90)Output
[]