fix(status): per-source stale threshold + dedup the brain alert#164
Merged
Conversation
O alerta de fonte STALE usava um limiar único de 3h pra TODAS as fontes. Os jobs diários (classifier/revisitar e briefing/daily às 07:00, memory-curation 04:15, memory-extraction 04:45) ficam ~21h/dia acima de 3h entre uma execução e a próxima, então o tick horário do brain-indexer disparava um push high-priority pra cada um a cada hora — afogando alertas reais (o oposto do objetivo do arquivo). Fix em duas partes: 1. Limiar por-fonte (src/rag/status.ts): jobs de cadência diária usam DAILY_STALE_THRESHOLD_SECONDS=26h (um dia + 2h de folga pra drift do cron); o resto mantém o default de 3h. summarizeStatus aplica thresholdForSource por linha; um thresholdSeconds explícito ainda força um limiar único (back-compat dos callers e dos testes). 2. Dedup do notify (src/index-indexer.ts): memória por-fonte em memória; só pusha quando a fonte ENTRA no estado ruim ou após um cooldown de 12h, e esquece a fonte quando ela recupera (a próxima falha alerta na hora). O console.error continua todo tick. Teste: src/rag/__tests__/status.test.ts cobre os limiares por-fonte (diário não fica stale a 23h, fica a 27h; horário continua stale a 4h) e o dedup (steady-bad alerta ~1x/cooldown, não 24x/dia). Build + 1481 testes verdes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
ENG-2
O alerta STALE usava limiar unico de 3h pra TODAS as fontes. Jobs diarios (classifier/revisitar e briefing/daily 07:00, memory-curation 04:15, memory-extraction 04:45) ficam ~21h/dia acima de 3h entre execucoes, entao o tick horario do brain-indexer disparava um push high-priority pra cada um a cada hora, afogando alertas reais.
Fix
src/rag/status.ts): jobs diarios usamDAILY_STALE_THRESHOLD_SECONDS=26h; o resto mantem 3h.summarizeStatusaplicathresholdForSourcepor linha; umthresholdSecondsexplicito ainda forca um limiar unico (back-compat).src/index-indexer.ts): memoria por-fonte; pusha so quando a fonte ENTRA no estado ruim ou apos cooldown de 12h, e esquece a fonte quando recupera. Oconsole.errorcontinua todo tick.Aceite
src/rag/__tests__/status.test.ts: diario nao fica stale a 23h, fica a 27h; horario continua stale a 4h; steady-bad alerta ~1x/cooldown (2x em 24h), nao 24x.npm run buildlimpo,npm test= 1481 pass / 0 fail.Generated with Claude Code