# M4b task 05: `[gateway]` in `brokerd.toml` **Branch:** `m4b` (run `git switch m4b`; `git status --short` must be empty, otherwise stop) **Commit subject:** `brokerd: config, [gateway] socket for Mattermost approvals` ## Goal `brokerd` carries pending approvals to `gatewayd` only when `brokerd.toml` says where (M4b spec, section 3): ```toml [gateway] # absent: Mattermost approvals are off, as in M3 socket = "" # empty: /run/gateway/gateway.sock ``` ## Files - Copy: `crates/brokerd/tests/config_gateway.rs`, and a **new version** of the given `crates/brokerd/tests/support/rig.rs` (its `Config` gains `gateway: None,`) - Modify: `crates/brokerd/src/config.rs`, `docs/implementer-log.md` ## The changes, exactly In `crates/brokerd/src/config.rs`: 1. Before `fn default_podman`, the section: ```rust /// `[gateway]`: where `gatewayd` takes approvals to post in Mattermost. Without the section, /// Mattermost approvals are off and only `bxctl` answers. An empty path means the default. #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Default)] #[serde(deny_unknown_fields, default)] pub struct Gateway { pub socket: PathBuf, } ``` 2. In `struct Config`, after `pub runner: Option,`: ```rust #[serde(default)] pub gateway: Option, ``` 3. In `impl Config`, before `audit_dir`: ```rust /// `gateway.sock`, when `[gateway]` is set. pub fn gateway_socket(&self) -> Option { let gateway = self.gateway.as_ref()?; if gateway.socket.as_os_str().is_empty() { Some(self.paths.home.join("run/gateway/gateway.sock")) } else { Some(gateway.socket.clone()) } } ``` ## Steps - [ ] **1. Copy.** `git switch m4b`, then `cp docs/plans/M4b/files/crates/brokerd/tests/config_gateway.rs crates/brokerd/tests/ && cp docs/plans/M4b/files/crates/brokerd/tests/support/rig.rs crates/brokerd/tests/support/` - [ ] **2. See it fail.** `cargo test -p brokerd --test config_gateway`. Expected: it does not compile. - [ ] **3. Make the three changes.** Run `cargo fmt --all`. - [ ] **4. See it pass.** `cargo test -p brokerd`. Expected: every suite passes; `config_gateway` 4 passed. - [ ] **5. Run the gate.** `make gate`. Expected last line: `gate: ok`. - [ ] **6. Log and commit.** `git add crates/brokerd docs/implementer-log.md Cargo.lock && git commit` ## Done when - `cargo test -p brokerd` passes; `make gate` prints `gate: ok`.