Tuning: the CI waits may be zero
The live review test sets ci_grace_s: 0, which the shared tuning parser
refused (every number had to be positive). A field now opts in to zero
with metadata {"zero": True}; ci_wait_s and ci_grace_s do.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
This commit is contained in:
1 parent
096eeea56b
commit
59fba3bb76
5 files changed
+42
-9
No files matched your search
@@ -81,13 +81,14 @@ def read_file(path: Path, errors: list[str]) -> dict[str, Any]:
|
||||
return loaded
|
||||
|
||||
|
||||
def positive(value: Any, kind: type) -> int | float | None:
|
||||
def positive(value: Any, kind: type, *, zero: bool = False) -> int | float | None:
|
||||
"""``value`` as ``kind`` if above 0 (or 0 itself, given ``zero``)."""
|
||||
# bool is an int in Python; `true` for a turn limit is a mistake.
|
||||
if isinstance(value, bool) or not isinstance(value, int | float):
|
||||
return None
|
||||
if kind is int and not float(value).is_integer():
|
||||
return None
|
||||
if value <= 0:
|
||||
if value < 0 or (value == 0 and not zero):
|
||||
return None
|
||||
return kind(value)
|
||||
|
||||
@@ -132,9 +133,13 @@ def parse_tuning(
|
||||
if spec is None:
|
||||
errors.append(f"tuning.{name}.{key}: unknown setting")
|
||||
continue
|
||||
number = positive(value, float if spec.type in (float, "float") else int)
|
||||
# A field with metadata {"zero": True} may also be 0 ("don't wait").
|
||||
zero = bool(spec.metadata.get("zero"))
|
||||
kind = float if spec.type in (float, "float") else int
|
||||
number = positive(value, kind, zero=zero)
|
||||
if number is None:
|
||||
errors.append(f"tuning.{name}.{key}: must be a positive number")
|
||||
need = "zero or more" if zero else "a positive number"
|
||||
errors.append(f"tuning.{name}.{key}: must be {need}")
|
||||
continue
|
||||
values[key] = number
|
||||
sections[name] = cls(**values)
|
||||
|
||||
Reference in new issue
Block a user