fix(T-34): record only the repos the trending digest actually delivered - #29
Merged
Merged
Conversation
buildTrendingMessage drops trailing repos when the digest would exceed
Telegram's 4096-char limit. That truncation is deliberate and tested — without
it Telegram rejects the whole message. The bug is what happened next.
The drop was invisible outside the tool: it returned { success: true } either
way, so runNewsAgent persisted the full, undropped list with sent = true. Repos
that were never in the outgoing message were recorded as delivered, and since
the DB is the only record of what went out, nothing afterwards could tell them
apart.
fitRepos now exposes which repos survived, the tool returns their names and logs
a warning when it drops any, and saveTrending tags each repo with whether it was
actually delivered. Against issue #26's own reproduction:
owner0..3/project-* sent=true delivered=true
owner4..7/project-* sent=false delivered=false
rows recorded sent=true but never delivered: 0 (was 4)
WARN ✂️ Digest too long for Telegram — dropped 4 of 8 repos: owner4/project-4, ...
sendTelegram returns the delivered names instead of a boolean; a failed send
returns an empty set, so nothing is marked sent — same behaviour as before for
that path.
Closes #26
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F5CmYPdQcMeLzzJc3iDQ2u
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F5CmYPdQcMeLzzJc3iDQ2u
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.
Closes #26
The bug
buildTrendingMessagedrops trailing repos when the digest would exceed Telegram's 4096-char limit. That truncation is correct and stays — without it Telegram rejects the entire message, andnews-telegram.test.ts:87exists to pin it.The bug is what happened afterwards. The drop was invisible outside the tool, which returned
{ success: true }either way, sorunNewsAgentpersisted the full, undropped list withsent = true:Repos that never appeared in the outgoing message were recorded as delivered. Since
github_trending.sentis the only record of what went out, nothing afterwards could tell a delivered repo from a dropped one — and no log line mentioned it.The fix
fitReposexposes which repos survived;buildTrendingMessageis nowassemble(fitRepos(...)), so the message and the kept list can't disagreesaveTrendingtags each repo individually with whether it was actually deliveredVerification
Ran the real tool against issue #26's own reproduction (8 repos with summaries that expand under HTML escaping), with
fetchstubbed to capture the outgoing body:The truncation is no longer silent:
pnpm test— 73 pass (2 new),pnpm tscandpnpm format:checkcleanWorth a look during review
sendTelegramnow returnsSet<string>instead ofboolean. A failed send returns an empty set, so nothing gets marked sent — same outcome as the oldfalse, just carried differently.Since a dropped repo is now saved with
sent = false, it stays eligible to appear in a later digest rather than being silently written off. That seems right, but it is a behaviour change worth confirming.🤖 Generated with Claude Code