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>
2.5 KiB
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;afterpub 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, thencp 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/. Addpub mod gateway;tolib.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 gatewaydafter 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, thenmake 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_sockpasses three times running;make gateprintsgate: ok.
Stop and report if
- A comment above a
todo!()does not fit its function, or contradicts a test: quote it. connectionseems to need a change: it is given.