# M4b task 11: the approvals posted here, and the commands that answer them **Branch:** `m4b` (run `git switch m4b`; `git status --short` must be empty, otherwise stop) **Commit subject:** `gatewayd: approvals, the registry and the judging of commands` ## Goal `gatewayd` keeps the approvals it has posted and not yet seen answered. A command answers one only if **all** of these hold, checked in this order, each refusal answered in the thread with its own line (M4b spec, section 7): 1. its author is an approver (`NOT_APPROVER` otherwise); 2. it is well formed (`USAGE` otherwise); 3. that approval is pending here; 4. it was not too long to show (then only `bxctl` answers it); 5. the command is in the approval's own thread; 6. it was posted after the approval's last part. An accepted answer is **taken out** of the registry as it is sent to the approval's `gateway.sock` connection, so a second `!approve` finds nothing. ## Files - Copy: the skeleton `crates/gatewayd/src/approvals/mod.rs` (it replaces task 10's three lines; `pub mod text;` is still in it), and `crates/gatewayd/tests/approvals_judge.rs` - Modify: `docs/implementer-log.md` ## The skeleton Written: `NOT_APPROVER`, `USAGE`, `Posted`, `Judged`, `Registry` with `new` and `lock`. To fill: `add`, `remove`, `holds`, `waiting_sessions` (one line each), and `judge`, whose seven steps are above its `todo!()`. ## Steps - [ ] **1. Copy.** `git switch m4b`, then `cp docs/plans/M4b/files/crates/gatewayd/src/approvals/mod.rs crates/gatewayd/src/approvals/ && cp docs/plans/M4b/files/crates/gatewayd/tests/approvals_judge.rs crates/gatewayd/tests/` - [ ] **2. See it fail.** `cargo test -p gatewayd --test approvals_judge`. Expected: it compiles and 6 tests fail. - [ ] **3. Fill the four small functions, then `judge`**, `cargo check -p gatewayd` after each. - [ ] **4. See it pass.** `cargo test -p gatewayd --test approvals_judge --test approvals_text`. Expected: 6 and 6 passed. - [ ] **5. Run the gate.** `cargo fmt --all`, then `make gate`. Expected last line: `gate: ok`. - [ ] **6. Log and commit.** `git add crates/gatewayd docs/implementer-log.md Cargo.lock && git commit` ## Done when - Both suites pass; `make gate` prints `gate: ok`. ## Stop and report if - A comment above a `todo!()` does not fit its function, or contradicts a test: quote it.