Rank a tech debt register by carrying cost

Agent buildEasy12 min

Your task

Leadership wants a ranked tech debt register, and an agent builds it from signals about each module. Old or large code is not debt by itself: debt is code that keeps costing you, through changes or incidents.

Write rank_debt_register(module_records): the rule your agent follows to build the register.

  • module_records (list of str): one module each, written as key=value pairs separated by ;, for example "name=checkout;churn=6;complexity=30;incidents=2". The keys are name, churn (changes this quarter), complexity and incidents, in any order. All values except the name are whole numbers.
  • Return the names of the modules on the register, in rank order.

Rules:

  1. Split a record on ;, and each part at its first =. A part with no = is ignored, and so is any key other than the 4.
  2. Drop a record that is missing any of the 4 keys, or whose name is empty.
  3. Drop a module whose churn and incidents are both 0: nothing about it costs you anything.
  4. Score each remaining module: churn * complexity + 50 * incidents.
  5. Return the names, highest score first. Equal scores go in ascending name order. A name that appears in two records is listed twice.

Examples

rank_debt_register(module_records: list[str]) -> list[str]
Example 1
Inputrank_debt_register(["name=checkout;churn=6;complexity=30;incidents=2", "name=legacy_report;churn=0;complexity=90;incidents=0", "name=auth;churn=3;complexity=20;incidents=0"])
Output["checkout", "auth"]
Example 2
Inputrank_debt_register([])
Output[]
Example 3
Inputrank_debt_register(["incidents=1;name=payments;complexity=10;churn=0", "name=search;churn=2;complexity=25;incidents=0"])
Output["payments", "search"]