fix: three errors that ended with the wrong exit code

Found compiling the environment-variable table for AGENTS.md:
- A REVIEW_GATES_MEM_RESERVE_MB that is no number threw
  std::invalid_argument, which nothing caught: the process aborted where
  it should end with a ValueError, exit 1. nan and inf were an unchecked
  cast. They raise ValueError / OverflowError now; a value past int64
  saturates.
- An env file that is not UTF-8: `run` ended with exit 1 where its
  preflight should stop it (exit 3), and `seats` parsed the raw bytes. Both
  read it as strict UTF-8 text now.
- A broker address with a port past 65535 was cut to 16 bits; it is an
  OverflowError now, uncaught (exit 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-31 16:35:26 +01:00
commit 53b7d6de31
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
9 changed files with 58 additions and 14 deletions

View file

@ -104,6 +104,19 @@ int main() {
Check("memory: MemAvailable and MemTotal in MB; the reserve is 10 % of MemTotal (at least 2048 MB) unless REVIEW_GATES_MEM_RESERVE_MB says otherwise; no file, no number",
Memory::Available(mi) == 80194 && Platform::MemInfo(mi).at("MemTotal") == 128292 && Memory::Reserve(std::nullopt, mi) == 12829 && Memory::Reserve(std::string("4096"), mi) == 4096
&& Memory::Reserve(std::nullopt, td / "none") == 2048 && !Memory::Available(td / "none"));
auto raised = [&](std::string_view value) {
try {
Memory::Reserve(std::string(value), mi);
return std::string("nothing");
} catch (const Dyn::Error& e) {
return std::format("{}: {}", e.Kind(), e.what());
}
};
Check("memory: a reserve that is no number raises (exit 1); one past int64 saturates; every number spelling is taken",
raised("x") == "ValueError: could not convert string to float: 'x'" && raised("nan") == "ValueError: cannot convert float NaN to integer"
&& raised("-inf") == "OverflowError: cannot convert float infinity to integer" && Memory::Reserve(std::string("1e30"), mi) == std::numeric_limits<std::int64_t>::max()
&& Memory::Reserve(std::string(" 4_096.9 "), mi) == 4096,
raised("x") + raised("nan"));
const std::int64_t me = getpid();
const std::vector<std::int64_t> tree = Platform::Tree(me, Platform::PpidMap());
const std::vector<std::int64_t> gone = {(1 << 22) + 7};