configurant 0.9.0

Schema-first configuration: declare values in a TOML schema, layer schema defaults with the file, environment and arguments your code hands in, validate with named errors, explain where each value came from. No generated code; secrets never printed.
Documentation
diff --git a/Cargo.lock b/Cargo.lock
index f5858eb7..d9648a1f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -637,9 +637,9 @@ dependencies = [
 
 [[package]]
 name = "configurant"
-version = "0.8.6"
+version = "0.8.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf9f8fd4b55d1ea5c0efd0c943e157ed5eb62beb6ea3c8739db0c419b5a11d21"
+checksum = "0248083ef23e64303fc23e60d2457fb643e8f0d7f1ad42deb94763f1dce91043"
 dependencies = [
  "clap",
  "redactant",
@@ -4263,7 +4263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
 dependencies = [
  "fastrand",
- "getrandom 0.3.4",
+ "getrandom 0.4.3",
  "once_cell",
  "rustix",
  "windows-sys 0.61.2",
diff --git a/crates/synapsed/Cargo.toml b/crates/synapsed/Cargo.toml
index 5aceb8cf..0621f631 100644
--- a/crates/synapsed/Cargo.toml
+++ b/crates/synapsed/Cargo.toml
@@ -28,7 +28,7 @@ base64 = "0.23"
 chrono = { version = "0.4", features = ["serde", "clock"] }
 ring = "0.17"
 uuid = { version = "1.6", features = ["v4"] }
-configurant = "0.8"
+configurant = { version = "0.8.11", features = ["ports"] }
 synapse-mailbox-persistant = { path = "../synapse-mailbox-persistant", version = "6.0.0-rc.279", optional = true }
 synapsed-client = { path = "../synapsed-client", version = "6.0.0-rc.279" }
 
diff --git a/crates/synapsed/src/settings.rs b/crates/synapsed/src/settings.rs
index fd4fb1dc..73447045 100644
--- a/crates/synapsed/src/settings.rs
+++ b/crates/synapsed/src/settings.rs
@@ -8,7 +8,8 @@
 use std::collections::BTreeMap;
 use std::net::SocketAddr;
 
-use configurant::{Loader, Origin, Schema};
+use configurant::modules::ports::Ports;
+use configurant::{Loader, Modules, Origin, Schema};
 
 /// The file in the home that may set the same values.
 pub const FILE_NAME: &str = "synapsed.toml";
@@ -64,7 +65,12 @@ pub fn load(env: &BTreeMap<String, String>, file: Option<&str>) -> Result<Settin
         .filter(|(name, value)| !(name.as_str() == "SYNAPSE_MAILBOX_STORE" && value.is_empty()))
         .map(|(k, v)| (k.clone(), v.clone()))
         .collect();
-    let mut loader = Loader::new(&schema).env(env);
+    // Port 0 ("any free port") stays accepted: the tests and `synapsectl` start daemons that way.
+    let mut modules = Modules::new();
+    modules
+        .register(Box::new(Ports::new().allow_zero()))
+        .map_err(|e| format!("the ports module: {e}"))?;
+    let mut loader = Loader::new(&schema).modules(&modules).env(env);
     if let Some(text) = file {
         loader = loader.file(FILE_NAME, text);
     }
diff --git a/crates/synapsed/synapsed.schema.toml b/crates/synapsed/synapsed.schema.toml
index feaa6f81..2528f801 100644
--- a/crates/synapsed/synapsed.schema.toml
+++ b/crates/synapsed/synapsed.schema.toml
@@ -18,6 +18,8 @@ schema_version = 1
 [[value]]
 key = "listen.addr"
 type = "string"
+provider = "ports"
+privileged = "the operator chooses the port; a low one was always accepted"
 default = "127.0.0.1:7920"
 env = "SYNAPSE_ADDR"
 description = "socket address synapsed listens on, host:port (loopback only; a value that is not an address is refused)"
diff --git a/crates/synapsed/tests/settings.rs b/crates/synapsed/tests/settings.rs
index 1c4efa05..e96d2468 100644
--- a/crates/synapsed/tests/settings.rs
+++ b/crates/synapsed/tests/settings.rs
@@ -238,3 +238,14 @@ fn launch_senders_mode_defaults_to_list_and_takes_any_but_not_ancestors_yet() {
     let err = settings(&[("SYNAPSE_LAUNCH_SENDERS_MODE", "everyone")], None).unwrap_err();
     assert!(err.contains("not a mode"), "{err}");
 }
+
+#[test]
+fn a_bad_listen_address_is_refused_at_load_naming_the_key() {
+    for bad in ["7920", "localhost:", "127.0.0.1:99999"] {
+        let env = [("SYNAPSE_ADDR".to_string(), bad.to_string())]
+            .into_iter()
+            .collect();
+        let error = synapsed::settings::load(&env, None).expect_err(bad);
+        assert!(error.contains("listen.addr"), "{bad}: {error}");
+    }
+}