fix(core): adaptive_threshold input validation + boundary tests
Risponde alla code review di 7dc2fda:
- Valida percentile in [0,1] e 0 < min_days < target_days, raise
ValueError quando out-of-range. Fail-fast invece di IndexError o
silent wrong result.
- Aggiunge test boundary esattamente a min_days*96 e target_days*96
(spec §9.1 item 9 era mancante).
- Aggiunge 4 test sulle nuove guards.
- Fix typo docstring (Determinismic → Deterministic).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
Spec: ``docs/superpowers/specs/2026-05-08-iv-rv-adaptive-gate-design.md``.
|
||||
|
||||
Determinismic, no I/O. La query del repository è effettuata dal caller
|
||||
Deterministic, no I/O. La query del repository è effettuata dal caller
|
||||
(``runtime/entry_cycle``) prima di chiamare questa funzione.
|
||||
"""
|
||||
|
||||
@@ -45,6 +45,15 @@ def compute_adaptive_threshold(
|
||||
disabilitato), altrimenti il percentile della finestra,
|
||||
bounded dal floor.
|
||||
"""
|
||||
if not (Decimal(0) <= percentile <= Decimal(1)):
|
||||
raise ValueError(
|
||||
f"percentile must be in [0, 1], got {percentile}"
|
||||
)
|
||||
if min_days <= 0 or target_days <= 0 or min_days >= target_days:
|
||||
raise ValueError(
|
||||
f"require 0 < min_days < target_days, "
|
||||
f"got min_days={min_days}, target_days={target_days}"
|
||||
)
|
||||
if not history:
|
||||
return None
|
||||
n_ticks = len(history)
|
||||
|
||||
Reference in New Issue
Block a user