From 1de5155893d34941607a711c46f12ebdae81feb0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 19:55:16 -0800 Subject: [PATCH 1/3] chore(quest): claim quest/m1/precut-fixes/nix-auth-restart.md Quest-Claim: dc822df6ab09e555 From e25c3210e03364fcddfaa75f6eb923d8768e7f2d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 20:33:47 -0800 Subject: [PATCH 2/3] fix(nix): upgrading moq-auth restarts the relay through its handoff moq-auth is required by the relay and stopped on change, so nearly every switch stopped it and the stop propagated to the relay, which drained every session and bound cold. Restart it in place instead: the restart propagates as a restart, which the relay survives through SIGUSR2. Co-Authored-By: Claude Opus 5.5 --- nix/modules/moq-relay.nix | 3 +++ quest/m1/precut-fixes/nix-auth-restart.md | 28 ----------------------- 2 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 quest/m1/precut-fixes/nix-auth-restart.md diff --git a/nix/modules/moq-relay.nix b/nix/modules/moq-relay.nix index c922b367ffc..4ffa74310bc 100644 --- a/nix/modules/moq-relay.nix +++ b/nix/modules/moq-relay.nix @@ -260,6 +260,9 @@ in after = [ "network.target" ]; before = [ "moq-relay.service" ]; requiredBy = [ "moq-relay.service" ]; + # A stop would propagate to the relay and cut its sessions; a restart propagates as a + # restart, which the relay survives through its handoff. + stopIfChanged = false; preStart = '' ${lib.optionalString (cfg.auth.keyFile == null) '' diff --git a/quest/m1/precut-fixes/nix-auth-restart.md b/quest/m1/precut-fixes/nix-auth-restart.md deleted file mode 100644 index 56fd4d74c5f..00000000000 --- a/quest/m1/precut-fixes/nix-auth-restart.md +++ /dev/null @@ -1,28 +0,0 @@ -# [XS] Upgrading the NixOS moq-auth unit restarts the relay through its handoff - -## Goal - -With `services.moq-relay.handoff` on, a `nixos-rebuild switch` that changes -both units restarts the relay through `SIGUSR2` and keeps its sessions, -instead of stopping it cold because its required `moq-auth` unit stopped. - -## Plan - -Found by the 2026-11-17 pre-cut correctness audit; confirmed from source and -systemd's semantics. In `nix/modules/moq-relay.nix`, `moq-auth` is -`requiredBy` the relay and keeps the default `stopIfChanged = true`. Its -`ExecStart` names the `moq-cli` store path, so nearly every upgrade changes -it: switching stops `moq-auth`, `Requires=` propagates the stop to the relay, -and the relay drains every session and starts with no handoff. - -Decided 2026-11-17 (maintainer, [moq-dev/moq#9010](https://github.com/moq-dev/moq/pull/9010#issuecomment-6959731587)): ✅ `moq-auth` sets `stopIfChanged = false`, so it restarts in place -and nothing propagates (rejected: `wants` instead of `requiredBy`, which lets -the relay run with no auth server and refuse every session). Check it with -the module's NixOS VM test if one covers handoff, else by a switch on a -test host. - -Public API: none. Wire: none. - -Caused by, for the fix PR's `## Caused by`: - -- [moq-dev/moq#8596](https://github.com/moq-dev/moq/pull/8596) - made moq-auth a required unit of the relay From 2273970c81641e68f69b720ed756968ddeb9aa8a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 21:49:34 -0800 Subject: [PATCH 3/3] fix(nix): the moq-auth comment says a restart keeps sessions only with handoff on Co-Authored-By: Claude Opus 5.5 --- nix/modules/moq-relay.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/modules/moq-relay.nix b/nix/modules/moq-relay.nix index 4ffa74310bc..4283fc555cd 100644 --- a/nix/modules/moq-relay.nix +++ b/nix/modules/moq-relay.nix @@ -260,8 +260,8 @@ in after = [ "network.target" ]; before = [ "moq-relay.service" ]; requiredBy = [ "moq-relay.service" ]; - # A stop would propagate to the relay and cut its sessions; a restart propagates as a - # restart, which the relay survives through its handoff. + # A stop would propagate to the relay and cut its sessions. A restart propagates as a + # restart, which keeps them only when `handoff` is on; otherwise it is a cold restart. stopIfChanged = false; preStart = ''