Files
boxmaker/docs/plans/M4b/11-gatewayd-approvals-registry.md
T
kyleandClaude Opus 5.5 2d415fc1be Plan M4b: approvals over Mattermost in 15 tasks
Skeletons for new files only; existing files change by exact edits, so no task overwrites an
earlier one's work. Each task's tests were run against a reference built in order from master,
with the gate at each step and mutations checked; each skeleton compiles and fails its tests, and
every todo!() comment was read beside its signature. The reference is kept off this machine.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 03:34:21 -07:00

53 lines
2.3 KiB
Markdown

# 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.