Commit b0dbbf1
authored
fix(watchd): resolve aliases, sync state at startup, tell the truth when a log is empty (#91)
Three defects from the first live run of the daemon against a real
homeserver. #88 said the sync loop was unverified; this is what running
it found.
## Every send through the socket failed
Commands hand the daemon the room argument a human typed, normally an
alias. They cannot resolve it themselves — resolving needs credentials,
and the daemon is holding those — so the socket received
`#test:example.org` and passed it to `room_send`, which wants a room id.
```
Error: LocalProtocolError: No such room with id #test:example.org found.
```
The daemon resolves now, checking its watched rooms first so the common
case costs nothing.
## And then it still failed, on the id
```
Error: LocalProtocolError: No such room with id !CkTNagkk...:example.org found.
```
A sync resumed from a stored token returns only what is new, so nio's
room list stayed empty — and `room_send` looks the room up there to
decide how to encrypt. The daemon now does one `full_state=True` sync
before serving anything.
Two errors, one message, different causes. The second only became
visible once the first was fixed, which is the ordinary shape of this: a
fix does not confirm a diagnosis, it exposes the next thing.
## The reader blamed the daemon for being absent while it was running
Any missing log produced:
```
No log for !room:example.org.
Start the daemon and add the room to watch_rooms:
matrix-watchd.py --start
```
A missing log has three causes, and that message names one. The most
common in practice is the one it does not cover: the daemon is running,
it is watching that room, and nothing has been said yet — a sync does
not replay history, so the log starts at the first event after the
daemon began watching. Telling someone to restart a healthy daemon is
worse than saying nothing.
It now asks the daemon over the socket and distinguishes the three,
exiting 0 for the case that is not an error.
## Verification
End to end against a live homeserver, in `#test` as the repository's
testing note requires:
```
$ matrix-send-e2ee.py '#test:example.org' "…"
Event ID: $k40enVvKZjibK3EjppBjqa3fU924dRlT9182CM3n6xY
$ matrix-watch.py '#test:example.org' --once
since last: 1 messages, 0 mentioning you
[10:34] Sebastian Mendel: 🤖 Daemon-Test: Runde durch den Socket
```
Socket in, homeserver, daemon sync, decryption, log, reader. A second
message sent while a reader was already following appeared in it within
the poll interval.
44 existing tests still pass. No test is added here: all three defects
are in the seam between the daemon and a live homeserver, which is the
part #88 documented as not unit-testable, and a mock of nio's room list
would assert my model of nio rather than nio.2 files changed
Lines changed: 50 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
133 | 153 | | |
134 | | - | |
135 | | - | |
| 154 | + | |
136 | 155 | | |
137 | 156 | | |
138 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
271 | 289 | | |
272 | 290 | | |
273 | 291 | | |
| |||
287 | 305 | | |
288 | 306 | | |
289 | 307 | | |
290 | | - | |
| 308 | + | |
291 | 309 | | |
292 | 310 | | |
293 | 311 | | |
| |||
296 | 314 | | |
297 | 315 | | |
298 | 316 | | |
299 | | - | |
| 317 | + | |
300 | 318 | | |
301 | 319 | | |
302 | 320 | | |
| |||
311 | 329 | | |
312 | 330 | | |
313 | 331 | | |
314 | | - | |
| 332 | + | |
315 | 333 | | |
316 | 334 | | |
317 | 335 | | |
| |||
369 | 387 | | |
370 | 388 | | |
371 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
372 | 398 | | |
373 | 399 | | |
374 | 400 | | |
| |||
0 commit comments