From 24d28c4cc52802d785bdf7ac57357e46a475e73d Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 4 Nov 2026 18:01:09 -0800 Subject: [PATCH] fix: derive threads and snippets on replicate-only nodes (#8) KNOX_LOCAL_SOURCES=none disabled the auto-threader and snippet extractor along with the ingesters. Both derive from rows already in the log, so a replica has everything they need: the dhg.lol node held 11.5k observations and 4.9k entries but only 2 of the origin's 28 threads, quietly degrading half the MCP surface. Ingestion stays gated; derivation always runs. --- internal/watch/watch.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/watch/watch.go b/internal/watch/watch.go index 7743c01..bd93334 100644 --- a/internal/watch/watch.go +++ b/internal/watch/watch.go @@ -233,16 +233,21 @@ func (w *Watcher) Start() error { snippetTicker := time.NewTicker(snippetInterval) gossipTicker := time.NewTicker(gossipInterval) - // A node that only replicates peers (a server with none of the local - // sources) skips the ingest/derive tickers entirely. Nil channels block - // forever, so the select simply never fires for them. - var browserC, giteaC, gitC, opencodeC, karakeepC, healthC, threadC, snippetC <-chan time.Time + // Derivation always runs. Threads and snippets are computed from rows that + // are already in the log, so a replica needs them exactly as much as the + // origin does — gating them with the ingesters left a replica with an + // almost empty thread list while the data sat right there. + threadC, snippetC := threadTicker.C, snippetTicker.C + + // Ingestion only runs where the sources exist. A node with no local + // sources (KNOX_LOCAL_SOURCES=none) leaves these nil: nil channels block + // forever, so the select never fires for them. + var browserC, giteaC, gitC, opencodeC, karakeepC, healthC <-chan time.Time if LocalSourcesEnabled() { browserC, giteaC, gitC = browserTicker.C, giteaTicker.C, gitTicker.C opencodeC, karakeepC, healthC = opencodeTicker.C, karakeepTicker.C, healthTicker.C - threadC, snippetC = threadTicker.C, snippetTicker.C } else { - log.Printf("[knox] KNOX_LOCAL_SOURCES=none: gossip-only mode, local ingest disabled") + log.Printf("[knox] KNOX_LOCAL_SOURCES=none: local ingest disabled, derivation still active") } var browserRunning, giteaRunning, gitRunning, threadRunning, gossipRunning atomic.Bool var opencodeRunning, karakeepRunning, healthRunning, snippetRunning atomic.Bool