Good Time on the Enhancement — Python Bug Hunt

Modelled on the Washington State Department of Corrections sentencing error disclosed in December 2015.

  • Language: Python
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Validation, Time
  • Modelled on: Washington State DOC · 2015
  • Visible tests: a sentence without enhancements earns credit; an enhancement is served in full
  • Reward: 50 XP for a complete fix

Briefing

Modelled on the Washington State Department of Corrections sentencing error disclosed in December 2015. From 2002, the department's software applied good-time credit to sentence enhancements — extra time, for example for using a weapon, that the law requires to be served in full. An estimated 3,200 prisoners were released early before it was corrected.

This project is a reconstruction: credit.py computes how many days a sentence requires after earned-release credit, using the percentages in the locked rules.py. It applies the credit to the whole sentence, enhancements included.

Fix days_to_serve so credit is earned only on the base term.

Bug report

BUG-DOC-2015 · Priority: Critical (public safety) · Reported by: victim's family / records office

days_to_serve(base_days, enhancements, category):

  • enhancements is a list of day counts; every one is served in FULL, with no credit of any kind
  • credit = base_days * rules.CREDIT_PERCENT[category] // 100 (integer floor), and applies to the base term only
  • result = (base_days - credit) + sum(enhancements)

release_day(start_day, base_days, enhancements, category) = start_day + days_to_serve(...).

Observed: 300 days base + a 365-day firearm enhancement at 33 % credit computes 446 days to serve instead of 566.

Logs

[offender-mgmt] DOC#8841 base=300 enh=[365] cat=standard -> 446 days
[offender-mgmt] DOC#8841 release scheduled 120 days early (unflagged)

The code as shipped

src/sentencing/credit.py (editable)

rules = bug_require("./rules.py")


def days_to_serve(base_days, enhancements, category):
    total = base_days + sum(enhancements)
    credit = total * rules.CREDIT_PERCENT[category] // 100
    return total - credit


def release_day(start_day, base_days, enhancements, category):
    return start_day + days_to_serve(base_days, enhancements, category)

Read-only context: src/sentencing/rules.py.

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Python bug hunts.