service_livekit.nu: read [livekit] section from hero_cfg.toml for per-user ports #175

Closed
opened 2026-04-30 02:06:00 +00:00 by sameh-farouk · 0 comments
Member

Context

hero_livekit#34 makes rtc_tcp_port configurable via runtime.json + configure RPC. hero_skills#173 adds rtc_tcp_port: 0 to the configure call so it stops failing.

With both of those, the wrapper can hold per-user TCP-RTC ports — but service_livekit.nu always passes 0, so multi-user setups fall back to default 7881 (collision). Operators can manually call configure RPC via curl with explicit ports (the bypass workaround we used during the multi-user dev box debugging), but those values get destroyed on the next --reset or stale-config wipe.

Architecture

The right durable per-user source is hero_cfg.toml. It already carries [mycelium]; adding [livekit] follows the established pattern (service_router.nu / service_collab.nu read sections from the same file).

runtime.json under ~/hero/var/hero_livekit/ is correctly modeled as a derived cache. The wipe forces it regenerated on inconsistency — that intent is preserved. Values survive wipes because the next service_livekit start re-reads hero_cfg.toml and re-derives runtime.json from there.

Change

In service_livekit.nu:

  1. Add helper svx_lk_read_hero_cfg_livekit — reads [livekit] section from ~/hero/cfg/hero_cfg.toml, returns {} if missing.
  2. In svx_lk_install_and_configure, replace hardcoded 0 placeholders for livekit_port / rtc_tcp_port / backend_port with values read from the section. Each field still defaults to 0 ("keep current / use default") if absent.

Behavior

Scenario hero_cfg.toml [livekit] Result
Single-user install absent Defaults: 7880 / 7881 / 8081. Unchanged.
Multi-user, user without [livekit] absent Defaults applied — collides with sibling. Operator's responsibility to add the section.
Multi-user with [livekit] per user present, with non-overlapping triples Per-user values flow through configure RPC → runtime.json → yaml → livekit-server bind. Survives wipes.

What this issue does NOT cover

Per-user port allocation policy. The [livekit] section is operator-managed today. If automating it becomes useful, that's a separate, optional helper (e.g. hero_user_livekit_alloc <user>) — out of scope for this issue and intentionally NOT bolted onto multi_user_add (which stays mycelium-focused, in pattern with the rest of the codebase).

## Context [hero_livekit#34](https://forge.ourworld.tf/lhumina_code/hero_livekit/pulls/34) makes `rtc_tcp_port` configurable via runtime.json + configure RPC. [hero_skills#173](https://forge.ourworld.tf/lhumina_code/hero_skills/issues/173) adds `rtc_tcp_port: 0` to the configure call so it stops failing. With both of those, the wrapper *can* hold per-user TCP-RTC ports — but service_livekit.nu always passes 0, so multi-user setups fall back to default 7881 (collision). Operators can manually call configure RPC via curl with explicit ports (the bypass workaround we used during the multi-user dev box debugging), but those values get destroyed on the next `--reset` or stale-config wipe. ## Architecture The right durable per-user source is `hero_cfg.toml`. It already carries `[mycelium]`; adding `[livekit]` follows the established pattern (service_router.nu / service_collab.nu read sections from the same file). `runtime.json` under `~/hero/var/hero_livekit/` is correctly modeled as a derived cache. The wipe forces it regenerated on inconsistency — that intent is preserved. Values survive wipes because the **next** `service_livekit start` re-reads `hero_cfg.toml` and re-derives `runtime.json` from there. ## Change In `service_livekit.nu`: 1. Add helper `svx_lk_read_hero_cfg_livekit` — reads `[livekit]` section from `~/hero/cfg/hero_cfg.toml`, returns `{}` if missing. 2. In `svx_lk_install_and_configure`, replace hardcoded `0` placeholders for `livekit_port` / `rtc_tcp_port` / `backend_port` with values read from the section. Each field still defaults to 0 ("keep current / use default") if absent. ## Behavior | Scenario | hero_cfg.toml `[livekit]` | Result | |---|---|---| | Single-user install | absent | Defaults: 7880 / 7881 / 8081. Unchanged. | | Multi-user, user without `[livekit]` | absent | Defaults applied — collides with sibling. Operator's responsibility to add the section. | | Multi-user with `[livekit]` per user | present, with non-overlapping triples | Per-user values flow through configure RPC → runtime.json → yaml → livekit-server bind. Survives wipes. | ## What this issue does NOT cover **Per-user port allocation policy.** The `[livekit]` section is operator-managed today. If automating it becomes useful, that's a separate, optional helper (e.g. `hero_user_livekit_alloc <user>`) — out of scope for this issue and intentionally NOT bolted onto `multi_user_add` (which stays mycelium-focused, in pattern with the rest of the codebase).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
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
lhumina_code/hero_skills#175
No description provided.