Fix the review triage for a deadline merge

Review the AI's codeEasy10 minAnthropic and OpenAI style

Your task

An agent wrote 400 lines of Rust for a new rate limiter that must ship today. You cannot read it all, so you split it into units and decide, per unit, what proof you need before merging. Unclassified risk is treated as the worst case, so the merge fails closed.

An assistant wrote triage_review_effort(risk_levels, covered_by_tests, read_budget). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • risk_levels: each unit's risk label, such as "irreversible", "degrades" or "cosmetic".
  • covered_by_tests: true when an existing test covers the unit at the same position. This list can be shorter.
  • read_budget: how many units you have time to read line by line.
  • Return one verdict per unit, in order: "read", "test", "trust" or "gate" (ship it behind a flag, with monitoring).

Rules the tests check:

  • Compare labels with whitespace trimmed from both ends, ignoring case.
  • A unit with no entry in covered_by_tests is not covered. A read_budget below 0 counts as 0.
  • degrades: "test".
  • cosmetic: "trust" when covered, otherwise "test".
  • Any other label, including irreversible, an unknown label or an empty one: "read" if any budget is left, which uses up one unit of budget, otherwise "gate".
  • The budget is used in list order.

Examples

triage_review_effort(risk_levels: list[str], covered_by_tests: list[bool], read_budget: int) -> list[str]
Example 1
Inputtriage_review_effort(["irreversible", "degrades", "cosmetic"], [False, True, True], 5)
Output["read", "test", "trust"]
Example 2
Inputtriage_review_effort(["irreversible", "irreversible", "irreversible"], [True, True, True], 1)
Output["read", "gate", "gate"]
Example 3
Inputtriage_review_effort(["cosmetic", "cosmetic"], [True, False], 0)
Output["trust", "test"]