Clamp system metrics to safe integers

This commit is contained in:
benjcooley
2026-08-31 12:50:58 -07:00
parent 4c665f3263
commit 0733f88f8e
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ MAX_VOLUMES = 64
MAX_ACCELERATORS = 64
MAX_LABEL_LENGTH = 128
MAX_NAME_LENGTH = 256
MAX_BYTES = 2**63 - 1
MAX_BYTES = 2**53 - 1
_cache_lock = threading.Lock()
_cached_at = -math.inf
@@ -134,3 +134,8 @@ def test_missing_optional_sensors_are_null():
assert accelerator["name"] == "Fallback GPU"
assert accelerator["utilization_percent"] is None
assert accelerator["temperature_c"] is None
def test_byte_totals_fit_the_cross_language_safe_integer_contract():
assert system_monitor._bytes(2**63) == 2**53 - 1
assert system_monitor._bytes(-1) == 0