Repository navigation
feat: standalone relay supervisor for scheduled health checks (#166) - #175
Merged
Merged
Conversation
The standalone team relay can die while role chats stay configured; the auto-relay only starts on a live channel's request, so nobody noticed until the 2026-11-19 incident. A scheduled task now probes /v1/health: - healthy (service marker) → instant exit, no action; - unreachable → atomic supervisor-lock claim (wx, beside the DB) → detached serve start → bounded log line (capped at 200 lines); - cooldown marker (10 min) prevents a restart storm against a broken relay; an expired marker allows a new attempt; - ALREADY_RUNNING from the serve lock (#110) and a live supervisor claimant both exit quietly; a stale supervisor lock owned by a dead PID is cleaned up (my own lock, not the relay's); - serve.lock is never read or touched — stale-lock recovery belongs to the relay (#141). scripts/install-relay-supervisor.ps1 registers the 5-minute Scheduled Task idempotently (existing task → skip). Tests: healthy skip, single start, concurrent-run race, stale-lock cleanup, serve.lock untouched, bounded log, cooldown expiry, unknown-liveness conservatism.
CTO final review found the plumbing gap: the supervisor probed/logged against the custom home but spawned serve without the flag, so a relay would come up against the DEFAULT home (different DB/configs). startRelay now takes RelayStartOptions including synloqHome, and the argv builder (relayStartArgv, exported) appends --synloq-home. Regression test: the custom home reaches both the start options and the spawned argv.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проблема (issue #166)
Standalone team relay может умереть, пока ролевые чаты настроены — auto-relay (#124) поднимает его только по запросу живого канала. Инцидент 2026-11-19: relay умер в непустом контуре, и некому было его поднять (keepalive-задачу удалили 17.11, а она делала и рестарт).
Решение
synloq relay-supervisor(новый CLI-субкоманд, TS, в vitest-контуре) для запуска по расписанию (Scheduled Task, каждые 5 мин):GET /v1/healthс таймаутом 3 с; живой relay (маркерservice: synloq-relay) → мгновенный выход.serve.lockне читается и не трогается вообще — recovery локов целиком в коде relay (Relay resilience: stale-lock recovery (dead-PID verified) + fail-loud diagnostics instead of silent fetch failed #141). Тест-гард: файл serve.lock с контентом остаётся нетронутым.wx, рядом с БД в synloq-home data). Гонка двух запусков → один старт. Stale supervisor-лок мёртвого PID чистится (мой лок, не relay'ев). Liveness unknown → fail closed (никого не стартуем).ALREADY_RUNNINGиз serve ([P1] Advisory lock beside the project database: refuse a second synloq serve #110) = кто-то уже поднимает → тихий выход.scripts/install-relay-supervisor.ps1— тонкий идемпотентный регистратор Scheduled Task (существующая задача → пропуск; schtasks, без хрупких COM-командлетов).Тесты (test/cli/relay-supervisor.test.ts, 8 шт)
healthy-skip · один старт при мёртвом · гонка двух одновременных → один старт · stale supervisor-lock cleanup · serve.lock нетронут · лог capped на 200 строк · истёкший cooldown разрешает повтор · unknown-liveness fail-closed.
Полный
pnpm verifyзелёный: 138 файлов / 1253 теста.Ограничения
relay-keepalive.ps1удалял serve.lock вручную — этот путь не восстановлен и не нужен.Closes #166.