Fix the evidence check behind a dead code claim
Your task
You asked an AI to trace your /checkout endpoint, and it said the legacy CheckoutV1 module is dead code you can ignore. Your team only accepts a dead code claim when the evidence backs it. So you classify each module from a repo-wide reference count and its live traffic.
An assistant wrote classify_dead_code(module_names, static_refs, request_counts, window_days). It is in the editor. It has a bug. Find it and fix it.
Input and output:
module_names: the module names, in order.static_refs: for the module at the same index, how many references a repo-wide search found, including config, route tables and dependency injection wiring. The list can be shorter thanmodule_names. A negative value means the search failed.request_counts: for the module at the same index, how many requests it served in the traffic window. The list can be shorter thanmodule_names. A negative value means the metric is missing.window_days: how many days of trafficrequest_countscovers.- Return one string per module, in input order: the name, then
=, then the verdict.
Rules the tests check:
- A module's verdict is the first of these that applies:
unprovenwhenstatic_refsorrequest_countshas no value at its index, or either value is negative.livewhen its request count is above 0.referencedwhen its reference count is above 0.unprovenwhenwindow_daysis under 30.deadotherwise.
- An empty
module_namesreturns an empty list.
Examples
classify_dead_code(module_names: list[str], static_refs: list[int], request_counts: list[int], window_days: int) -> list[str]Example 1
Input
classify_dead_code(["CheckoutV1", "CheckoutV2", "LegacyPromo"], [0, 5, 0], [0, 0, 3], 60)Output
["CheckoutV1=dead", "CheckoutV2=referenced", "LegacyPromo=live"]Example 2
Input
classify_dead_code(["CheckoutV1"], [0], [0], 29)Output
["CheckoutV1=unproven"]