Watch
0
0
Fork
You've already forked hyperhive
0

keep the operator matrix admin grant record in nats kv, not on disk

This commit is contained in:
atlas 2026-11-22 23:33:40 +01:00
commit 28d847cb7e
2 changed files with 312 additions and 87 deletions

View file

@ -136,13 +136,15 @@ each member not yet in `#admins:<server_name>` it sends
lands on.
- **Leaving `admins` revokes what the sync granted.** The controller
records each account it sends a grant for in
`/var/lib/swarm-controller/operator-matrix-admins.json`. When one of
them is no longer in `admins` but still in `#admins`, it sends
records each account it sends a grant for under the key `granted` of the
`operator-matrix-admins` NATS KV bucket, which only the controller writes.
An upgraded controller imports the old
`/var/lib/swarm-controller/operator-matrix-admins.json` once and deletes it.
When one of them is no longer in `admins` but still in `#admins`, it sends
`!admin users force-leave-room @<name>:<server_name> <admin room id>`
there as `@swarm`; leaving that room is what ends homeserver admin.
- **Admins the sync didn't make keep admin.** An admin missing from that
file, `@swarm`, the server user `@conduit:<server_name>`, every agent's
record, `@swarm`, the server user `@conduit:<server_name>`, every agent's
account, and every user id in
`services.hyperhive.deploy.swarm-controller.matrixAdminSync.ignoreUsers` are never
revoked.

View file

@ -573,13 +573,22 @@ the store answers that it holds none, never because a read failed.
<!-- vale write-good.Passive = YES -->
- `operator-matrix-admins.json` — the matrix user ids the operator admin
sync has made homeserver admin, a JSON array. The sync revokes admin
only from these, so deleting the file leaves every current admin in
place; a missing file is an empty set. A file the controller can't
read or parse stops the sync, grants included, and the controller logs
`operator matrix admin: pass failed` on every pass. See
[`docs/2-handbook/swarm/matrix.md`](../../2-handbook/swarm/matrix.md#operators-are-homeserver-admins).
The operator admin sync's set of granted matrix user ids isn't kept here. It
lives in the `operator-matrix-admins` NATS KV bucket, under the key
`granted`, as a JSON array. Only the controller reads or writes it. The sync
revokes admin only from ids in that set, so a missing key leaves every
current admin in place; a key it can't parse stops the sync, grants
included, and the controller logs `operator matrix admin: pass failed` on
every pass. A controller that finds no key and an
`operator-matrix-admins.json` in this directory imports the file into the
key and deletes the file; the upgrade needs no manual step. See
[matrix.md](../../2-handbook/swarm/matrix.md#operators-are-homeserver-admins).
Everything else here is rebuildable once the store holds the webhook secret:
the legacy `webhook-secret` file, the forge avatar markers
`forge-config-org-avatar-set` and `forge-service-avatar-<login>` (losing one
costs one re-upload), and the optional host-only `bao-client.pem` and
`bao-client-key.pem`.
## Run-time dirs