Skip to content

Add a built-in LiveKit token service with delegated leaves for MatrixRTC (1.1.3) - #598

Open
James-Chapman wants to merge 19 commits into
mainfrom
claude/livekit-token-service-bde17e
Open

James-Chapman wants to merge 19 commits into
mainfrom
claude/livekit-token-service-bde17e

Conversation

@James-Chapman

@James-Chapman James-Chapman commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Version 1.1.3. This adds MatrixRTC slice 4, a LiveKit token service built into the server (MSC4195), so a deployment needs no lk-jwt-service. It also adds MSC4195's delegated delayed leave, a LiveKit webhook that brings a delegation's check forward, and an exact state_after on /sync, measured from an in-memory log of resolved state changes. It adds migration 004 (livekit_delegations). This PR is stacked on #597.

What changed

  • Crypto boundary (ADR-0828):
    • LiveKit HS256 tokens are made only by typed signers: participant, room-create, and a one-room roomAdmin for GetParticipant.
    • verify_hs256_token checks webhooks and never reads alg.
    • There is no general HMAC-SHA256 or "sign these bytes" function, and HMAC-SHA1's allowed uses are unchanged.
  • Token service (ADR-0829, ADR-0830):
    • POST /_matrix/client/{v1,unstable/io.element.msc4195}/rtc/livekit/get_token issues a token only to an authenticated caller that this server's own current room state shows as joined.
    • Room names and identities are derived exactly as MSC4195 specifies.
    • The token never grants roomCreate, admin or hidden-participant rights, and its lifetime is bounded to 60 to 3600 seconds.
    • The API secret is a file read per use into a SecretBuffer.
    • LiveKit is called only at the configured address, under an outbound slot and one deadline, with the lock released and the response bounded.
    • /versions and rtc/transports advertise the service (m.livekit on stable only).
    • The external service (server.rtc.livekit.service_url) stays available, and the two cannot both be configured.
  • Federation (ADR-0831):
    • A token for another server's SFU is relayed to that server. The relay goes only to a server that is joined to the room and allowed by the room's server ACL, and only the returned jwt is passed on.
    • A user of another server gets a subscribe-only token, issued by main. The checks are: the X-Matrix origin is verified, the user belongs to that origin and is joined, and the room's ACL allows the origin.
    • The federation worker holds no secret. It relays the request to main through WorkerRelayKind::livekit_token, bound to the verified request by origin and a body-digest permit (ADR-0595).
  • Delegated delayed leave (ADR-0832):
    • POST .../rtc/livekit/delegate_delayed_leave stores one delegation per room, slot and member, with at most 20 per user.
    • The livekit-delegations job asks GetParticipant with the lock released. While the participant is connected it restarts the delayed leave; once LiveKit no longer shows the participant it sends the leave. It acts only through manage_delayed_event.
    • An answer applies only to the delegation it was asked for, and one run drops at most 64 delegations.
  • Webhook (ADR-0833):
    • POST /_merovingian/livekit/webhook is served on the client listener.
    • It checks the HS256 token and the body hash in constant time, caps the body at 64 KiB, and handles staleness and replay.
    • An event only brings forward the check of a matching delegation; it changes no state itself.
  • Review fixes (Codex):
    • The federation worker's Landlock secret-path guard lists the LiveKit API secret file, so a worker-readable placement refuses to start the worker (ADR-0062).
    • The delegation job asks the most overdue first, stamps each GetParticipant token when its call is made, and schedules the next check from when the calls ended (ADR-0832).
    • The webhook finds matching delegations through an index by room name and identity, and re-checks each match (ADR-0833).
    • A LiveKit call's host lookup and exchange share one deadline; no exchange starts once it is spent. The blocking lookup itself cannot be interrupted, which ADR-0830 says (ADR-0830).
  • Store: migration 004, the LiveKitDelegationTable in-memory table, store functions, strict hydration (a bad row is skipped and counted), deletion on deactivation, and the worker's load profile excludes the table.
  • state_after: deltas are measured from an in-memory log of resolved state changes.
  • Docs: user manual, both example configs, the Client-Server API status page, capability gaps, crypto boundary, threat model (the secret, outbound calls, federation route, webhook, delegation), architecture, HTTP transport, log filtering, database persistence, module AGENTS.md files, ADRs 0827 to 0833, and the CHANGELOG.

Why it changed

  • Token service: MatrixRTC clients (Element Call) need a LiveKit token from the homeserver's MSC4195 endpoint. Running a separate lk-jwt-service means an extra service with its own trust boundary. Building it in lets the server judge membership from its own state and keep the LiveKit secret behind the crypto boundary.
  • Delegated leave: without it, a client that disappears leaves a stale call membership until its delayed event fires. With it, the leave is sent once LiveKit no longer shows the participant.
  • Codex review: the four findings above: a secret the worker could read, a job a slow LiveKit could starve, a webhook whose cost grew with every user's delegations, and a lookup outside the deadline.
  • Coverage: patch coverage was 78%; the new scenarios cover the refusal and ignore paths that never ran.
  • Review fix: a security review found that the federated route skipped the room's server ACL, because the room is named in the body and not the path. That is now fixed.

CI tests

Modified tests

  • tests/integration/test_livekit_token_flow.cpp, tests/integration/test_livekit_delegation_flow.cpp, tests/integration/test_federation_worker_flow.cpp: five scenarios over CodeQL's 100-line limit are each split in two where their cases already divide, keeping every case (the worker relay, the webhook, the federated refusals, the relay errors and the refusals before any call).
  • tests/conformance/test_route_query_conformance.cpp: the get_token and delegate rows.
  • tests/conformance/test_sync_state_after_conformance.cpp
  • tests/integration/test_database_upgrade_flow.cpp: version 4, and the new table takes a row.
  • tests/integration/test_federation_worker_flow.cpp: the LiveKit relay is bound by origin and permit.
  • tests/integration/test_persistent_homeserver_flow.cpp
  • tests/integration/test_postgresql_store_behaviour_flow.cpp: delegation round trip.
  • tests/integration/test_sync_handler_flow.cpp, tests/integration/test_sync_state_after_flow.cpp
  • tests/unit/test_config_rtc.cpp: token-service config is refused, never repaired.
  • tests/unit/test_database_persistence.cpp: version 4 steps and plans.
  • tests/unit/test_worker_landlock.cpp: a LiveKit secret the worker could read is detected.
  • tests/unit/test_crypto_livekit_token.cpp: a correctly signed token with an undecodable header or payload, and the room-admin signer's refusals.
  • tests/integration/test_livekit_token_flow.cpp: the federation provider main wires; refusals with no outbound client, no slot, no usable signing key, no readable secret.
  • tests/integration/test_livekit_delegation_flow.cpp: fair scheduling under a slow LiveKit; the webhook index across replacement and drop; malformed tokens and claims; ignored events; the bounded event-ID memory; no secret; the service switched off; an unnameable stored delegation; an unreadable answer.
  • tests/integration/test_federation_worker_flow.cpp: main issues a token for a verified worker relay.
  • tests/unit/test_federation_inbound_request.cpp, tests/unit/test_federation_transactions.cpp
  • tests/unit/test_worker_relay_binding.cpp, tests/unit/test_worker_relay_frame.cpp, tests/unit/test_worker_table_load_profile.cpp
  • tests/tooling/test_outbound_answer_trust.py: livekit.relay is classified as unverified.
  • tests/smoke/meson.build: db-migrate plans to version 4.
  • tests/complement/merovingian.conf.template, tests/support/EduRelayContext.hpp

New tests

  • tests/unit/test_crypto_livekit_token.cpp: HS256 vectors, grant shapes, verification.
  • tests/unit/test_livekit_names.cpp: MSC4195 name vectors.
  • tests/unit/test_livekit_delegation_table.cpp, tests/unit/test_livekit_delegation_store.cpp
  • tests/unit/test_resolved_state.cpp, tests/unit/test_state_change_log.cpp
  • tests/conformance/test_livekit_token_conformance.cpp
  • tests/integration/test_livekit_token_flow.cpp: issuance, refusals, the server ACL, the relay, the log.
  • tests/integration/test_livekit_delegation_flow.cpp: validation, the per-user cap, restart, send, drops, a race with the lock released, the drop bound, webhook authentication, replay, staleness and 413.
  • tests/unit/test_livekit_room_service.cpp: the lookup draws from the call's deadline; the request builders' and the perform refusals.
  • tests/support/LiveKitTestSupport.hpp, tests/support/StatePduSupport.hpp

Verified:

  • python build.py vm on the Linux VM at this head (1b02594), committed tree: Ok 92, Fail 0, no Timeout, read from testlog.txt (1656 test cases, 1655 passed, 1 skipped). Integration 1012.5 s, unit 137.2 s, conformance 128.9 s.
  • An earlier full run of the same three test files before they were committed ended Ok 91, Fail 1: DB-7 concurrent writes to SQLite reuse at most database.pool_size connections (tests/integration/test_security_audit_write_pool_flow.cpp, lines 171 and 175, 61 == 64), after three write connections were refused with SQLITE_BUSY while opening. That run took 1392 s for integration, under load. The scenario then passed 20 times out of 20 run alone, and in the full run above. This PR does not touch the SQLite connection-open path; the failure is followed up in Give SQLite writes one pooled connection, and change the version only when the owner asks #599.
  • scripts/reject-unsafe.sh on the VM at 196a9f8 (the commit since changes only three test files): exit 0.
  • CI on 1b02594 was cancelled at the owner's request; the failed "Require every ... to pass" gate jobs are reacting to those cancellations. No CI run has completed on this head.

Integration suite time. Measured on the same VM, back to back:

Head Integration Unit Conformance Test cases
PR 597 (adf9d8e) 974.5 s 110.3 s 103.1 s 1615
This PR (1b02594) 1012.5 s 137.2 s 128.9 s 1656

The 38 s difference in the integration binary is mostly not the new tests. All 42 [livekit], [delegation], [webhook] and [rtc] integration test cases together take 4.13 s (--durations yes). The costliest are:

  • "A relayed request's refusal or error is passed on only in this server's words": 2.21 s over its 8 generated cases, each of which starts a TLS mock server.
  • "A token for another server's SFU is relayed to that server, and only its jwt is passed on": 0.37 s.
  • "The webhook remembers a bounded number of event IDs, the oldest forgotten first": 0.16 s for 1025 webhooks.
  • Every other new scenario takes under 0.15 s.

Earlier runs of the same binary ranged from 1012 s to 1719 s, so the time margin against the 1800 s limit depends on load on the VM. The limit is unchanged here; whether to trim, split or raise it is the owner's call.

Not verified:

  • The PostgreSQL scenarios do not run on the VM, which has no PostgreSQL. They skip, which is not a pass.
  • No real Element Call client and no real LiveKit server were tried; LiveKit is a local mock throughout.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 168 files, which is 68 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fdac08f5-0e5e-4c4b-8ba2-984a7a3ca82a
Commits

Reviewing files that changed from the base of the PR and between d4d7283 and a20f5da.

Files selected for processing: 168

  • .agent/skills/merovingian-review/SKILL.md
  • .agent/skills/merovingian-review/references/module-invariants.md
  • .agent/skills/merovingian-review/references/obligations.md
  • AGENTS.md
  • CHANGELOG.md
  • config/merovingian.conf.bsd.example
  • config/merovingian.conf.example
  • docs/AGENTS.md
  • docs/adr/0062-federation-worker-holds-no-secret-files-secrets-arrive-over-inherited-fds.md
  • docs/adr/0154-pool-database-write-connections.md
  • docs/adr/0349-an-outbound-answer-main-does-not-verify-comes-over-mains-own-connection.md
  • docs/adr/0464-documentation-only-changes-do-not-require-a-version-bump.md
  • docs/adr/0647-versions-from-1-0-0-are-major-minor-build.md
  • docs/adr/0819-a-state-after-delta-compares-the-two-states.md
  • docs/adr/0822-the-rtc-transport-is-advertised-as-type-livekit-with-livekit-service-url.md
  • docs/adr/0827-a-state-after-delta-is-measured-from-an-in-memory-log-of-resolved-state-changes.md
  • docs/adr/0828-livekit-tokens-are-signed-and-verified-only-through-typed-hs256-functions-in-the-crypto-boundary.md
  • docs/adr/0829-the-built-in-livekit-token-service-issues-tokens-only-to-users-this-server-finds-joined.md
  • docs/adr/0830-every-call-to-livekit-goes-to-the-configured-address-with-a-token-of-its-own.md
  • docs/adr/0831-a-federated-livekit-token-request-is-judged-by-main-and-answered-subscribe-only.md
  • docs/adr/0832-a-delegated-delayed-leave-is-restarted-while-livekit-shows-the-participant-and-sent-once-it-does-not.md
  • docs/adr/0833-the-livekit-webhook-is-served-on-the-client-listener-and-trusted-only-to-prompt-a-check.md
  • docs/adr/0834-sqlite-writes-share-one-pooled-connection.md
  • docs/adr/0835-the-version-changes-only-when-the-owner-asks.md
  • docs/adr/index.md
  • docs/architecture.md
  • docs/coding-rules.md
  • docs/crypto-boundary.md
  • docs/database-persistence.md
  • docs/http-transport.md
  • docs/log-filtering.md
  • docs/matrix-v1.19-client-server-api.md
  • docs/threat-model.md
  • docs/todos/capability-gaps.md
  • docs/user-manual.md
  • docs/versioning.md
  • include/merovingian/config/Config.hpp
  • include/merovingian/config/LiveKitTokenServiceConfig.hpp
  • include/merovingian/config/RtcConfig.hpp
  • include/merovingian/crypto/LiveKitParticipantGrant.hpp
  • include/merovingian/crypto/LiveKitToken.hpp
  • include/merovingian/crypto/VerifiedHs256Token.hpp
  • include/merovingian/database/LiveKitDelegationRowText.hpp
  • include/merovingian/database/LiveKitDelegationStore.hpp
  • include/merovingian/database/LiveKitDelegationTable.hpp
  • include/merovingian/database/Migration.hpp
  • include/merovingian/database/PersistentLiveKitDelegation.hpp
  • include/merovingian/database/PersistentStore.hpp
  • include/merovingian/database/Schema.hpp
  • include/merovingian/database/SqliteWritePool.hpp
  • include/merovingian/database/StateChangeLog.hpp
  • include/merovingian/federation/FederationEndpoint.hpp
  • include/merovingian/federation/FederationRuntimeState.hpp
  • include/merovingian/federation/InboundRequestProviders.hpp
  • include/merovingian/federation/Transactions.hpp
  • include/merovingian/federation/WorkerRelayKind.hpp
  • include/merovingian/federation_worker/WorkerRelayFrame.hpp
  • include/merovingian/homeserver/HomeserverRuntime.hpp
  • include/merovingian/homeserver/LiveKitDelegationProgress.hpp
  • include/merovingian/homeserver/LiveKitDelegations.hpp
  • include/merovingian/homeserver/LiveKitNames.hpp
  • include/merovingian/homeserver/LiveKitRequestFields.hpp
  • include/merovingian/homeserver/LiveKitRoomService.hpp
  • include/merovingian/homeserver/LiveKitTokenRequest.hpp
  • include/merovingian/homeserver/LiveKitTokenService.hpp
  • include/merovingian/homeserver/OutboundCallResult.hpp
  • include/merovingian/homeserver/RoomService.hpp
  • include/merovingian/homeserver/WorkerPool.hpp
  • include/merovingian/platform/LandlockHardening.hpp
  • include/merovingian/sync/ResolvedState.hpp
  • include/merovingian/sync/StateGroupLookup.hpp
  • meson.build
  • migrations/004_livekit_delegations.sql
  • migrations/AGENTS.md
  • packaging/freebsd/+MANIFEST
  • packaging/netbsd/Makefile
  • packaging/opensuse/merovingian.spec
  • packaging/rhel/merovingian.spec
  • packaging/rpm/merovingian.spec
  • scripts/build-deb.sh
  • scripts/build-freebsd-pkg.sh
  • scripts/build-netbsd-pkg.sh
  • scripts/build-openbsd-pkg.sh
  • scripts/build-opensuse-rpm.sh
  • scripts/build-rhel-rpm.sh
  • scripts/build-rpm.sh
  • scripts/build-static-linux.sh
  • src/config/Config.cpp
  • src/config/ConfigParser.cpp
  • src/config/ReloadPlan.cpp
  • src/config/ReloadPolicy.cpp
  • src/crypto/AGENTS.md
  • src/crypto/LiveKitToken.cpp
  • src/crypto/meson.build
  • src/database/AGENTS.md
  • src/database/LiveKitDelegationRowText.cpp
  • src/database/LiveKitDelegationStore.cpp
  • src/database/LiveKitDelegationTable.cpp
  • src/database/Migration.cpp
  • src/database/PersistentStore.cpp
  • src/database/PostgresqlStore.cpp
  • src/database/Schema.cpp
  • src/database/SqliteStore.cpp
  • src/database/StateChangeLog.cpp
  • src/database/meson.build
  • src/db_migrate.cpp
  • src/federation/InboundRequest.cpp
  • src/federation/Transactions.cpp
  • src/federation/WorkerRelayBinding.cpp
  • src/federation_worker/WorkerEventLoop.cpp
  • src/federation_worker/WorkerRelayFrame.cpp
  • src/homeserver/AGENTS.md
  • src/homeserver/AuthService.cpp
  • src/homeserver/ClientServerRuntime.cpp
  • src/homeserver/HomeserverRuntime.cpp
  • src/homeserver/LiveKitDelegations.cpp
  • src/homeserver/LiveKitNames.cpp
  • src/homeserver/LiveKitRequestFields.cpp
  • src/homeserver/LiveKitRoomService.cpp
  • src/homeserver/LiveKitTokenService.cpp
  • src/homeserver/LocalHttpRouter.cpp
  • src/homeserver/RoomService.cpp
  • src/homeserver/StateBookkeeping.cpp
  • src/homeserver/WorkerPool.cpp
  • src/homeserver/meson.build
  • src/http/RateLimit.cpp
  • src/main.cpp
  • src/platform/LandlockHardening.cpp
  • src/sync/AGENTS.md
  • src/sync/ResolvedState.cpp
  • src/sync/StateGroupLookup.cpp
  • src/sync/meson.build
  • tests/complement/merovingian.conf.template
  • tests/conformance/AGENTS.md
  • tests/conformance/test_livekit_token_conformance.cpp
  • tests/conformance/test_route_query_conformance.cpp
  • tests/conformance/test_sync_state_after_conformance.cpp
  • tests/integration/test_database_upgrade_flow.cpp
  • tests/integration/test_federation_worker_flow.cpp
  • tests/integration/test_livekit_delegation_flow.cpp
  • tests/integration/test_livekit_token_flow.cpp
  • tests/integration/test_persistent_homeserver_flow.cpp
  • tests/integration/test_postgresql_store_behaviour_flow.cpp
  • tests/integration/test_security_audit_write_pool_flow.cpp
  • tests/integration/test_sync_handler_flow.cpp
  • tests/integration/test_sync_state_after_flow.cpp
  • tests/meson.build
  • tests/smoke/meson.build
  • tests/support/AGENTS.md
  • tests/support/EduRelayContext.hpp
  • tests/support/LiveKitTestSupport.hpp
  • tests/support/StatePduSupport.hpp
  • tests/tooling/test_outbound_answer_trust.py
  • tests/unit/test_config_rtc.cpp
  • tests/unit/test_crypto_livekit_token.cpp
  • tests/unit/test_database_persistence.cpp
  • tests/unit/test_federation_inbound_request.cpp
  • tests/unit/test_federation_transactions.cpp
  • tests/unit/test_livekit_delegation_store.cpp
  • tests/unit/test_livekit_delegation_table.cpp
  • tests/unit/test_livekit_names.cpp
  • tests/unit/test_livekit_room_service.cpp
  • tests/unit/test_resolved_state.cpp
  • tests/unit/test_state_change_log.cpp
  • tests/unit/test_worker_landlock.cpp
  • tests/unit/test_worker_relay_binding.cpp
  • tests/unit/test_worker_relay_frame.cpp
  • tests/unit/test_worker_table_load_profile.cpp

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@James-Chapman
James-Chapman force-pushed the claude/livekit-token-service-bde17e branch from 2345e42 to fd571b6 Compare November 17, 2026 16:34
@James-Chapman
James-Chapman added this pull request to stack #596 November 17, 2026 16:42
@James-Chapman
James-Chapman force-pushed the claude/livekit-token-service-bde17e branch from 9b38886 to a1ef2ef Compare November 17, 2026 17:27
@James-Chapman

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T18:41:25.676571Z a1ef2ef Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1ef2ef01f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main.cpp Resolved
Comment thread src/homeserver/LiveKitDelegations.cpp Resolved
Comment thread src/homeserver/LiveKitDelegations.cpp Resolved
Comment thread src/homeserver/LiveKitRoomService.cpp Resolved
@James-Chapman
James-Chapman force-pushed the claude/livekit-token-service-bde17e branch from a1ef2ef to 196a9f8 Compare November 17, 2026 20:36
@sonarqubecloud

Copy link
Copy Markdown

Base automatically changed from claude/delayed-events-947f08 to main November 18, 2026 00:50
James-Chapman and others added 18 commits November 18, 2026 00:50
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anges

A state_after delta was measured from the state recorded for the newest event at
since. On a room forked at since, that is one branch's state, not the resolved
state the client was told, so a key that resolution later moved back was never
sent (review of PR 595). A backfilled event ordered at or below since did the same,
and the left-room delta had the same baseline.

Every change to a room's current state in the main process now goes into
PersistentStore::state_change_log. A change is filed at the causing event's stream
ordering, raised above every position a sync has answered, so the state told as of a
served position never changes. resolved_state_at and resolved_state_changes rebuild
the state told and the exact delta from that one record. A window of messages costs
no state row. A since from before start-up gets the room's whole state once. No
migration (ADR-0827, superseding part of ADR-0819).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rypto boundary

Add crypto/LiveKitToken: a participant-token signer whose grant type cannot
express roomCreate, roomAdmin or hidden, a room-creation signer with
roomCreate alone, and an HS256 verifier that never reads the header's alg.
libsodium's HMAC-SHA256 stays internal. Pinned vectors from Python's hmac
and RFC 7515 A.1 (ADR-0828).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sign_livekit_room_admin_token signs {"room":<name>,"roomAdmin":true} for one
MSC4195 room name and nothing else, with a vector computed apart from this
code. ADR-0828 and the crypto boundary doc now list four operations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds server.rtc.livekit.{url,api_url,api_key,api_secret_file,token_lifetime}
(exclusive with the external service_url) and serves get_token on the
unstable io.element.msc4195 and stable v1 client paths: a token only for a
caller this server finds joined, with MSC4195's room name and identity, no
create, admin or hidden rights, after CreateRoom at the configured API
address under an outbound slot with the lock released (ADR-0829, ADR-0830).

A request for another server's SFU is relayed over signed federation when
that server has a joined member here; its 403 M_FORBIDDEN and 400
M_INVALID_PARAM are passed on in this server's words, so the outbound call
now carries those two errcodes as well as M_INVITE_BLOCKED. A federated
request is judged from this server's state and answered subscribe-only
(ADR-0831). /versions and the transports list match what is served.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The relay of get_token to another server is a perform_outbound_call caller,
so ADR-0349's table and test_outbound_answer_trust.py name it: unverified,
over main's own client. Also wrap a changelog bullet line that ran to 121
characters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…elay (ADR-0831, ADR-0595)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…and hydration (ADR-0832)

Migration 004 creates livekit_delegations on SQLite and PostgreSQL, with LiveKitDelegationTable
holding the rows in memory and LiveKitDelegationStore.hpp writing them in one transaction each.
A new delegation replaces the row holding its key and the row holding its delay ID; account
deactivation deletes a user's rows beside the delayed events.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… LiveKit webhook

MSC4195 delegate_delayed_leave: a joined caller hands the server one delay ID
per (room, slot, member). The livekit-delegations job asks LiveKit's
GetParticipant (a one-room roomAdmin token, the configured address only, the
lock released) and restarts the delayed leave while the participant is
connected, or sends it once LiveKit no longer shows them (ADR-0832).
Delegations live in migration 004 and go with a cancel, a send, a leave or
a deactivation.

POST /_merovingian/livekit/webhook is served on the client listener: an
HS256 token from the configured key, a body SHA-256 match, a bounded body,
staleness and replay checks. It only brings a matching delegation's next
check forward; it never changes state itself (ADR-0833).

The MSC4195 request readers move to LiveKitRequestFields and the LiveKit
test fixture to tests/support/LiveKitTestSupport.hpp, shared by the token
and delegation flows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its delegation

The federated get_token names its room in the body, so the route-level server
ACL check never saw it, and an ACL leaves a denied server's users joined:
a denied server could get a subscribe-only token for the call. Main now
refuses a denied origin with the same 403, and a client's token request is
not relayed to a server the room denies (ADR-0831).

A GetParticipant answer is applied only to the delegation it was asked for
(slot, member, creation time, LiveKit names), so a delegation stored again
while the lock was free is not taken as seen. One run drops at most 64
delegations, keeping one lock hold bounded (ADR-0832).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The documentation site build (mkdocs --strict) refused the link to a
0079 file name that does not exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hared_ptrs

scripts/reject-unsafe.sh read "free (" in a comment as a call to free(),
and the LiveKit test helpers' shared_ptr lines had no review marker. Each
one shares a call log or mock with the std::function hook installed on the
runtime, which must be copyable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ex webhooks, bound DNS

Four findings from review of PR 598:

- The federation worker's Landlock secret-path guard now lists
  server.rtc.livekit.api_secret_file, so a worker-readable placement of the
  LiveKit API secret (beneath /etc/ssl/certs, say) refuses to start the
  worker, as for every other secret (ADR-0062).
- run_livekit_delegations asks the due delegations most overdue first,
  stamps each GetParticipant token when its call is made, and schedules the
  next check from when the calls ended, so a slow LiveKit cannot make the
  job ask the same 16 again while others wait (ADR-0832).
- The webhook finds matching delegations through an index by LiveKit room
  name and identity (livekit_delegation_participants, kept in step with the
  progress map), and checks each match against its progress, instead of
  scanning every delegation (ADR-0833).
- perform_livekit_request charges the host lookup and the exchange to one
  OutboundDeadline: the exchange gets what the lookup left, and none is
  started once it is spent (ADR-0830).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rker relay success path

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scenarios for the paths CI's coverage report showed unexecuted in
LiveKitDelegations.cpp: a malformed or over-long webhook token and claims
that are not an object (401); authentic events with no object body, no
participant, an unreadable createdAt, or a time before the delegation
(ignored); createdAt as a bare integer; the bounded memory of event IDs;
the API secret missing (no call, webhook 500); the token service switched
off (delegations dropped, webhook 404); a stored delegation whose names
cannot be derived (dropped); and an unreadable GetParticipant answer
(nothing changes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deadline stops a slow lookup from adding a whole exchange, and stops
an exchange from starting once it is spent. The lookup is a blocking
getaddrinfo the deadline cannot interrupt, so the comment, ADR-0830 and
the CHANGELOG no longer claim the call never outlasts its budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeQL's poorly-documented-function rule failed on five Catch2 scenarios
of 106 to 125 lines. Each is split where its cases already divide, so
every scenario is under 95 lines and no case is lost or changed:

- the worker relay: the admitted relay and the spent permit, apart from
  the refusals for another origin, no permit and another body's permit;
- the webhook: replayed, stale, other-kind and unknown signed webhooks
  apart from the signature, prompt and size cases, both on
  CheckedDelegation, now declared before its first user;
- the federated request: the 400s and the no-service 404 apart from the
  403s;
- the relay: the other server's refusals and errors apart from the
  success and the ACL;
- the refusals before any call: no outbound client apart from the
  budget, the signing key and the API secret.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… when the owner asks (#599)

* Give SQLite writes one pooled connection so a write never waits in SQLite's busy handler for another (1.1.4)

The DB-7 scenario lost three of 64 writes under load: three pooled SQLite
connections being opened polled SQLite's busy handler for the first one's
lock, lost to its back-to-back commits (every journal and database sync
runs under EXCLUSIVE) and were refused after 5 s with SQLITE_BUSY.

SQLite runs one write at a time, so the SQLite write pool now holds one
connection whatever database.pool_size says, and writers wait in the pool
instead (ADR-0834). database.pool_size applies to PostgreSQL only.

A new scenario holds SQLite's write lock on a leased pool slot for 7 s
while a second write runs; on the old code that write was refused at
BEGIN IMMEDIATE after the busy timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Name the one SQLite write connection in the review skill's database invariants

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Change the version only when the owner asks, and keep this branch at 1.1.3

The owner's rule from 2026-11-18: no branch increments the version on its
own; it changes only when the owner asks, and every change adds its
CHANGELOG bullets to the newest version's entry (ADR-0835, superseding
ADR-0464 and the per-branch increment of ADR-0647).

docs/versioning.md, the root AGENTS.md, docs/coding-rules.md,
docs/AGENTS.md and the review skill now say so. Under the new rule this
branch drops its 1.1.4 bump: every version location is back to its base's
1.1.3, and the SQLite fix's bullet and release-notes sentence move into
the 1.1.3 entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants