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>
51 lines
2.5 KiB
Markdown
51 lines
2.5 KiB
Markdown
# M4b task 13: `gateway.sock`, `gatewayd`'s side
|
|
|
|
**Branch:** `m4b` (run `git switch m4b`; `git status --short` must be empty, otherwise stop)
|
|
**Commit subject:** `gatewayd: gateway, the gateway.sock listener and one thread per connection`
|
|
|
|
## Goal
|
|
|
|
`gatewayd` listens on `gateway.sock`, a Unix socket (not TCP) in its own 0700 directory, the socket
|
|
0600, a stale socket from an earlier run replaced. Each `brokerd` connection gets a thread that
|
|
speaks the four frames of task 02 (M4b spec, sections 4 and 6).
|
|
|
|
A connection thread **only speaks the protocol**. Posting in Mattermost and writing the state file
|
|
are the serve loop's, which alone owns them (task 14): the thread asks the loop through a channel,
|
|
`ToLoop::Show` (post this; answers come on this channel) and `ToLoop::Ended` (it ended; mark it).
|
|
|
|
## Files
|
|
|
|
- Copy: the skeleton `crates/gatewayd/src/gateway.rs`, `crates/gatewayd/tests/gateway_sock.rs`
|
|
- Modify: `crates/gatewayd/src/lib.rs` (`pub mod gateway;` after `pub mod deliver;`),
|
|
`docs/implementer-log.md`
|
|
|
|
## The skeleton
|
|
|
|
Written: `Log`, `ToLoop`, `Ending`, `Timing`, `frame`, and **`connection`**, the protocol: read
|
|
frame 1, ask the loop to post, send frame 2, wait for an approver's answer or for `brokerd` to
|
|
close, send frame 3, read frame 4, tell the loop how it ended. Read it first. To fill, each with its
|
|
steps in its comment: `listen`, `serve`, `frames` (the same as `brokerd`'s courier's), `end`.
|
|
|
|
## Steps
|
|
|
|
- [ ] **1. Copy.** `git switch m4b`, then
|
|
`cp docs/plans/M4b/files/crates/gatewayd/src/gateway.rs crates/gatewayd/src/ && cp docs/plans/M4b/files/crates/gatewayd/tests/gateway_sock.rs crates/gatewayd/tests/`.
|
|
Add `pub mod gateway;` to `lib.rs`.
|
|
- [ ] **2. See it fail.** `cargo test -p gatewayd --test gateway_sock`. Expected: it compiles and 6
|
|
tests fail.
|
|
- [ ] **3. Fill `end`, `frames`, `listen`, `serve`**, `cargo check -p gatewayd` after each.
|
|
- [ ] **4. See it pass.** `cargo test -p gatewayd --test gateway_sock`, three times. Expected: 6
|
|
passed each time, in about a second.
|
|
- [ ] **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
|
|
|
|
- `cargo test -p gatewayd --test gateway_sock` passes three times running; `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.
|
|
- `connection` seems to need a change: it is given.
|