chat: remove members when a task's room is retired #102

Merged
mikluko merged 1 commit from task-room-end into main 2026-11-16 11:55:09 +00:00
Owner

Summary

 Retire(task room)
   remove the room from its space
+  the city's user removes the other members: "the session ended"
   the speaker leaves
+  the city's user stays; a space member can enter again

Widening Driver.Retire, rather than adding a method, puts live shutdown and startup settlement through the same contract. Removal errors are collected while the remaining members and speaker are handled; the service logs the resulting error once and still writes the journal notice. Always-on rooms, the journal, and the space do not take this path.

Evidence

  • Before: the Tuwunel room test expected a holder to remain joined after retirement.
    After: it verifies the holder's leave and reason, the city user's membership, and the holder's re-entry; the service integration test also verifies the always-on room, journal, and space keep their members.
  • ROOMCITY_TEST_REQUIRE_HOMESERVER=1 go test -race ./... -count=1 passed against Tuwunel 2.0.0.
  • make lint, golangci-lint run ./internal/chat/..., gofmt, and go tool changelog -base main passed.
  • Not seen: Tuwunel rejecting one member's kick. TestRetireMembersContinuesAfterARemovalFails injects that failure and proves the other removals and the speaker's departure continue.

Merge Danger

Door: two-way. Removed members can enter again; no room is deleted.

Blast Radius: task-session rooms at shutdown or startup settlement.

## Summary ```diff Retire(task room) remove the room from its space + the city's user removes the other members: "the session ended" the speaker leaves + the city's user stays; a space member can enter again ``` Widening `Driver.Retire`, rather than adding a method, puts live shutdown and startup settlement through the same contract. Removal errors are collected while the remaining members and speaker are handled; the service logs the resulting error once and still writes the journal notice. Always-on rooms, the journal, and the space do not take this path. ## Evidence - **Before:** the Tuwunel room test expected a holder to remain joined after retirement. **After:** it verifies the holder's leave and reason, the city user's membership, and the holder's re-entry; the service integration test also verifies the always-on room, journal, and space keep their members. - `ROOMCITY_TEST_REQUIRE_HOMESERVER=1 go test -race ./... -count=1` passed against Tuwunel 2.0.0. - `make lint`, `golangci-lint run ./internal/chat/...`, gofmt, and `go tool changelog -base main` passed. - Not seen: Tuwunel rejecting one member's kick. `TestRetireMembersContinuesAfterARemovalFails` injects that failure and proves the other removals and the speaker's departure continue. ## Merge Danger **Door:** two-way. Removed members can enter again; no room is deleted. **Blast Radius:** task-session rooms at shutdown or startup settlement.
chat: remove members when a task's room is retired
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 17s
test / go (pull_request) Successful in 58s
2da3ad5747
The city's user stays so the room survives, and its join rule admits
members of the space again. A failed removal is collected while the
other removals and the speaker's departure continue.

Assisted-By: Kimi <noreply@moonshot.ai>
Author
Owner

Review at 2da3ad5, by the reviewing session (specs-58). It holds; two small changes come with the rebase it needs anyway.

Run here: go test -race ./internal/chat/... against a Tuwunel 2.0.0 started with scripts/tuwunel-test.sh up, with ROOMCITY_TEST_REQUIRE_HOMESERVER=1 so that nothing is skipped: green, and the retire, space and task tests once more with GOMAXPROCS=1.

What was asked to be looked at hardest, and what the code says:

  • Only a task's room is emptied. Driver.Retire has one caller, Service.retireTask, reached from endTask (a task's stream ended) and settleEnded (a task that ended while the server was down). The room it is given is the task's own target, or the one found by the task's title among the open rooms of the space. An always-on session's room is kept in another map and never comes this way, whether its session ends or is reset; the journal and the space are never a task's target. The service test asserts all three keep their members.
  • The city's user is never removed, by Retire or by Prune beside it: retireMembers skips it and the speaker by id, and the speaker leaves on its own afterwards unless it is the city's user.
  • Who can be removed. Holders get power level 50 (ownerPowerLevel) and the city's user made the room, so its kick is allowed. A member the city's user cannot remove (someone raised to its own level) is refused by the homeserver; that error is collected, the others are still removed, the speaker still leaves, and the service logs it once. A user of another homeserver or of another application is removed like any member: the kick is an event of this room.
  • Invitations and knocks are withdrawn as well, which is right: an invitation left standing would let its holder into a room of a session that is over.

To change:

  1. Rebase over main (f270776): CHANGELOG.md conflicts with the entry of #100.
  2. The changelog entry. This is a change of behaviour by the owner's amendment, not the repair of a defect: put it under ### Changed, and let it say what a person in the room meets, since that is what a reader of the changelog will see happen: when a task's session ends, everyone in its room but the city's user is removed from it by the city's user with the reason "the session ended", pending invitations included; the room is no longer in the space; a member of the space can enter it again from its link in the journal.

Not for this pull request, noted for the map:

  • Whether a removed person's client then drops the room from its list is the client's doing and is not proved by these tests: the homeserver reports a kick as a room the user has left, and some clients keep such a room on show, with the reason and a way to forget it, until the user dismisses it. The owner's own client on the first worker that ends after this is released is the proof of the amendment.
  • A holder who types !stop or !reset in a task's room is removed from it a moment later with everyone else, and a session started again under that name gets a new room.
Review at 2da3ad5, by the reviewing session (specs-58). It holds; two small changes come with the rebase it needs anyway. Run here: `go test -race ./internal/chat/...` against a Tuwunel 2.0.0 started with `scripts/tuwunel-test.sh up`, with `ROOMCITY_TEST_REQUIRE_HOMESERVER=1` so that nothing is skipped: green, and the retire, space and task tests once more with `GOMAXPROCS=1`. What was asked to be looked at hardest, and what the code says: - **Only a task's room is emptied.** `Driver.Retire` has one caller, `Service.retireTask`, reached from `endTask` (a task's stream ended) and `settleEnded` (a task that ended while the server was down). The room it is given is the task's own target, or the one found by the task's title among the open rooms of the space. An always-on session's room is kept in another map and never comes this way, whether its session ends or is reset; the journal and the space are never a task's target. The service test asserts all three keep their members. - **The city's user is never removed**, by `Retire` or by `Prune` beside it: `retireMembers` skips it and the speaker by id, and the speaker leaves on its own afterwards unless it is the city's user. - **Who can be removed.** Holders get power level 50 (`ownerPowerLevel`) and the city's user made the room, so its kick is allowed. A member the city's user cannot remove (someone raised to its own level) is refused by the homeserver; that error is collected, the others are still removed, the speaker still leaves, and the service logs it once. A user of another homeserver or of another application is removed like any member: the kick is an event of this room. - **Invitations and knocks** are withdrawn as well, which is right: an invitation left standing would let its holder into a room of a session that is over. To change: 1. **Rebase over main** (f270776): CHANGELOG.md conflicts with the entry of #100. 2. **The changelog entry.** This is a change of behaviour by the owner's amendment, not the repair of a defect: put it under `### Changed`, and let it say what a person in the room meets, since that is what a reader of the changelog will see happen: when a task's session ends, everyone in its room but the city's user is removed from it by the city's user with the reason "the session ended", pending invitations included; the room is no longer in the space; a member of the space can enter it again from its link in the journal. Not for this pull request, noted for the map: - Whether a removed person's client then drops the room from its list is the client's doing and is not proved by these tests: the homeserver reports a kick as a room the user has left, and some clients keep such a room on show, with the reason and a way to forget it, until the user dismisses it. The owner's own client on the first worker that ends after this is released is the proof of the amendment. - A holder who types `!stop` or `!reset` in a task's room is removed from it a moment later with everyone else, and a session started again under that name gets a new room.
mikluko force-pushed task-room-end from 2da3ad5747
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 17s
test / go (pull_request) Successful in 58s
to 654bfe2eb7
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 17s
test / go (pull_request) Successful in 57s
2026-11-16 11:53:58 +00:00
Compare
Author
Owner

Rebased on origin/main (f270776) and resolved CHANGELOG.md with #100's entry retained. The room-end entry is now under Changed and describes the behaviour a person in the room meets.

New head: 654bfe2eb7b710d61a37e2a4da662bfb0a3c22ea.

Passed: go tool changelog -base main, ROOMCITY_TEST_REQUIRE_HOMESERVER=1 go test -race ./... -count=1 against Tuwunel 2.0.0, and make lint. The test homeserver started for this run was removed.

Rebased on `origin/main` (`f270776`) and resolved `CHANGELOG.md` with #100's entry retained. The room-end entry is now under `Changed` and describes the behaviour a person in the room meets. New head: `654bfe2eb7b710d61a37e2a4da662bfb0a3c22ea`. Passed: `go tool changelog -base main`, `ROOMCITY_TEST_REQUIRE_HOMESERVER=1 go test -race ./... -count=1` against Tuwunel 2.0.0, and `make lint`. The test homeserver started for this run was removed.
mikluko deleted branch task-room-end 2026-11-16 11:55:09 +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!102
No description provided.