fix(mcp): treat ending_percent=-1 as unread sentinel in normalize_consumed

This commit is contained in:
RNL
2026-08-19 21:52:48 +10:00
parent 8a498e933e
commit df34ec8e3e
2 changed files with 10 additions and 1 deletions

View File

@@ -108,7 +108,10 @@ def normalize_consumed(starting_percent, ending_percent, initial_weight_grams):
fabricated zero (spec: 24/269 usage rows go negative; a -1 sentinel
subtracted as a real value produces e.g. consumed=-101%).
"""
if starting_percent is None or starting_percent == -1 or ending_percent is None:
if (
starting_percent is None or starting_percent == -1
or ending_percent is None or ending_percent == -1
):
return None, None, "unreliable"
consumed_percent = starting_percent - ending_percent
if consumed_percent < 0: