serve: start the chat side #41

Merged
mikluko merged 1 commit from wire-chat into main 2026-11-16 06:22:48 +00:00
Owner

On 0.2.0 roomcity server mounts the three services and the transcripts' page and nothing of internal/chat: no room appears and the homeserver's transactions get 404.

With [matrix] in roomcity.toml, serve.Run now makes the Matrix driver from it and the tokens in as_token_file and hs_token_file (the files the Secret matrix is mounted as in the pod; where they are is [matrix]'s keys), mounts the driver's handler at /_matrix/app/ on the network listener, and runs the chat service beside the server with the owners, the city's name and the transcripts' address of [chat]. An error of the service ends the server, as a listener's does. The start fails before anything listens when [chat] has holders, a name or an address and there is no [matrix], and when a token file cannot be read. A homeserver that is down at start is not an error: the rooms are made, again and again, when it is back, and logged.

Tested against the local Tuwunel 2.0.0 (and in CI, which runs it): TestServeWholeMakesTheRoomsOfTheCityOnTheHomeserver starts serve.Run whole, starts an always-on session through the runtime, and sees the space, the journal and the agent's room made, and a holder's message in the room reach the session as a prompt, which it can only if the transactions arrive. TestServeRefusesAChatWithoutItsMatrixAndATokenItCannotRead covers the two refusals.

For 0.2.1.

On 0.2.0 `roomcity server` mounts the three services and the transcripts' page and nothing of `internal/chat`: no room appears and the homeserver's transactions get 404. With `[matrix]` in `roomcity.toml`, `serve.Run` now makes the Matrix driver from it and the tokens in `as_token_file` and `hs_token_file` (the files the Secret `matrix` is mounted as in the pod; where they are is `[matrix]`'s keys), mounts the driver's handler at `/_matrix/app/` on the network listener, and runs the chat service beside the server with the owners, the city's name and the transcripts' address of `[chat]`. An error of the service ends the server, as a listener's does. The start fails before anything listens when `[chat]` has holders, a name or an address and there is no `[matrix]`, and when a token file cannot be read. A homeserver that is down at start is not an error: the rooms are made, again and again, when it is back, and logged. Tested against the local Tuwunel 2.0.0 (and in CI, which runs it): `TestServeWholeMakesTheRoomsOfTheCityOnTheHomeserver` starts `serve.Run` whole, starts an always-on session through the runtime, and sees the space, the journal and the agent's room made, and a holder's message in the room reach the session as a prompt, which it can only if the transactions arrive. `TestServeRefusesAChatWithoutItsMatrixAndATokenItCannotRead` covers the two refusals. For 0.2.1.
serve: start the chat side
Some checks failed
test / changelog (pull_request) Successful in 5s
image / image (pull_request) Successful in 15s
test / go (pull_request) Failing after 48s
4418bb8da3
serve mounted the three services and the transcripts' page and nothing of
internal/chat, so on 0.2.0 no room appeared and the homeserver's
transactions got 404. With [matrix] in roomcity.toml, Run now makes the
Matrix driver from it and the tokens in as_token_file and hs_token_file,
mounts the driver's handler at /_matrix/app/ on the network listener, and
runs the chat service beside the server, with the owners, the city's name
and the transcripts' address of [chat]; an error of the service ends the
server, as a listener's does.

The start fails, before anything listens, when [chat] has holders, a name or
an address and there is no [matrix], and when a token file cannot be read:
a server that started without the city's rooms would say nothing.

The test starts serve whole against a local Tuwunel: the space, the journal
and the always-on agent's room are made as its session starts, and what a
holder writes in the room reaches the session as a prompt, which it only can
if the transactions arrive.

Assisted-By: Claude <noreply@anthropic.com>
Author
Owner

Review for the wiring of the chat side, of 4418bb8. The content holds; the pull request cannot merge as it is, for two reasons that are not about the wiring: Forgejo reports conflicts with main (#39 went in), and test / go is red.

The red check is a port two packages share.

--- FAIL: TestServeWholeMakesTheRoomsOfTheCityOnTheHomeserver
    listen tcp 127.0.0.1:21150: bind: address already in use

go test ./... runs packages side by side. The driver's tests in internal/chat/matrix and this test in internal/serve both take the address of the city's transactions from ROOMCITY_TEST_LISTEN, which is the one address the test Tuwunel's registration names. Give the serve test a registration and a port of its own in scripts/tuwunel-test.sh (a second city), so that the two packages cannot meet; running the packages one at a time would only hide it.

What I was asked to look at, and found right:

  • The handler is mounted on the network listener alone, at /_matrix/app/. In mautrix 0.32.0 every handler under it (transactions, the two queries, ping) checks the homeserver's token first; the router's two health paths are outside that prefix and so are not mounted.
  • A homeserver that is down at start is retried until the space is made; nothing of it ends Run. Run ends with an error only when the registry's watch ends, and then the server is not usable anyway. So a passing failure of Matrix does not take the runtime down.
  • The token files are the ones the pod has: the Secret matrix is mounted at /run/roomcity/secrets/matrix with the keys as-token and hs-token, and roomcity.toml in saraksh/kube names those two paths.

Reported to specs-18, not a change here: a session's frames from before its room exists are not shown in the room, since the room subscribes from now; they are in the transcript.

Review for the wiring of the chat side, of 4418bb8. The content holds; the pull request cannot merge as it is, for two reasons that are not about the wiring: Forgejo reports conflicts with `main` (#39 went in), and `test / go` is red. **The red check is a port two packages share.** --- FAIL: TestServeWholeMakesTheRoomsOfTheCityOnTheHomeserver listen tcp 127.0.0.1:21150: bind: address already in use `go test ./...` runs packages side by side. The driver's tests in `internal/chat/matrix` and this test in `internal/serve` both take the address of the city's transactions from `ROOMCITY_TEST_LISTEN`, which is the one address the test Tuwunel's registration names. Give the serve test a registration and a port of its own in `scripts/tuwunel-test.sh` (a second city), so that the two packages cannot meet; running the packages one at a time would only hide it. What I was asked to look at, and found right: - The handler is mounted on the network listener alone, at `/_matrix/app/`. In mautrix 0.32.0 every handler under it (transactions, the two queries, ping) checks the homeserver's token first; the router's two health paths are outside that prefix and so are not mounted. - A homeserver that is down at start is retried until the space is made; nothing of it ends `Run`. `Run` ends with an error only when the registry's watch ends, and then the server is not usable anyway. So a passing failure of Matrix does not take the runtime down. - The token files are the ones the pod has: the Secret `matrix` is mounted at `/run/roomcity/secrets/matrix` with the keys `as-token` and `hs-token`, and `roomcity.toml` in saraksh/kube names those two paths. Reported to specs-18, not a change here: a session's frames from before its room exists are not shown in the room, since the room subscribes from now; they are in the transcript.
mikluko force-pushed wire-chat from 4418bb8da3
Some checks failed
test / changelog (pull_request) Successful in 5s
image / image (pull_request) Successful in 15s
test / go (pull_request) Failing after 48s
to bcbab7dd0f
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 16s
test / go (pull_request) Successful in 57s
2026-11-16 06:21:11 +00:00
Compare
mikluko deleted branch wire-chat 2026-11-16 06:22:49 +00:00
mikluko referenced this pull request from a commit 2026-11-16 06:22:50 +00:00
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/roomcity!41
No description provided.