Files
OwnCord/Server
J3vbandClaude e13adaf8b1 refactor(b3-4): hub constructor options — required collaborators validated at construction (S-11) (#1470)
ws.NewHub(opts HubOptions) (*Hub, error). The dispositions came from what
each setter's own implementation said, not the plan's guesses:

- The four rejectIfRunning-guarded knobs were construction wiring
  pretending to be mutable state and became validated options with their
  setters deleted: SetLiveKit, SetLiveKitProcess, SetPluginRegistry,
  ConfigureReplay. rejectIfRunning died with its last caller. The plan
  left SetLiveKitProcess "depends on whether the supervised process can
  restart" — it cannot: the restart path relaunches the whole app, so a
  process without a client is now refused at construction.
- The genuinely runtime-mutable stay setters, each with its why:
  SetEventPersister / SetEventStore / SetPluginEventSink are atomic
  hot-swaps internal/app wires one lifecycle stage after Run (the
  persister cannot exist before the hub; the sink consumes the built
  hub's broadcaster), and SetPendingVoiceModFlags is per-user state.
- DB and Limiter are required — before this change ws.NewHub(nil, nil,
  nil) succeeded (api's LiveKit-proxy tests built exactly that hub) and
  a missing collaborator surfaced as a later panic. Services stays
  optional: nil is the degraded fixture half the ws suite builds, and
  forcing a real service layer would change which handler paths the
  frozen tests take.

internal/app.StartRuntime builds the LiveKit client/process first
(buildVoice), passes everything through HubOptions, and starts the
supervised process only once the hub holds it (OC-0019 ordering kept);
construction failure is a startHub boot error now. Test migration:
newTestHub / newTestHubDeps / newTestHubWith keep the old call shape at
~76 sites across both ws package namespaces; the eighteen former setter
sites construct with options; TestNewHub_RequiredCollaborators and
TestHub_LiveKitProcessRequiresClient pin the refusals.

server-boundaries.md gains the after-B3-4 setter table; the plan's B3-4
section gains the dated evidence block.


Claude-Session: https://claude.ai/code/session_01B8dwVLEihnGZYtH9X631F4

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-31 08:47:24 +00:00
..