Skip to content

fix(T-34): record only the repos the trending digest actually delivered - #29

Merged
DamengRandom merged 2 commits into
masterfrom
fix/T-34-record-only-delivered-repos
Aug 1, 2026
Merged

fix(T-34): record only the repos the trending digest actually delivered#29
DamengRandom merged 2 commits into
masterfrom
fix/T-34-record-only-delivered-repos

Conversation

@DamengRandom

Copy link
Copy Markdown
Owner

Closes #26

The bug

buildTrendingMessage drops 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, and news-telegram.test.ts:87 exists to pin it.

The bug is what happened afterwards. The drop was invisible outside the tool, which returned { success: true } either way, so runNewsAgent persisted the full, undropped list with sent = true:

const sent = await WorkCoordinator.sendTelegram(curated)   // true — the send did succeed
await WorkCoordinator.saveTrending(curated, sent, now)     // `curated`, not what was delivered

Repos that never appeared in the outgoing message were recorded as delivered. Since github_trending.sent is 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

  • fitRepos exposes which repos survived; buildTrendingMessage is now assemble(fitRepos(...)), so the message and the kept list can't disagree
  • the tool returns the delivered names and logs a warning when it drops any
  • saveTrending tags each repo individually with whether it was actually delivered

Verification

Ran the real tool against issue #26's own reproduction (8 repos with summaries that expand under HTML escaping), with fetch stubbed to capture the outgoing body:

curated handed to sendTelegram : 8
entries actually in the message: 4

  owner0/project-0       sent=true  delivered=true
  owner1/project-1       sent=true  delivered=true
  owner2/project-2       sent=true  delivered=true
  owner3/project-3       sent=true  delivered=true
  owner4/project-4       sent=false delivered=false
  owner5/project-5       sent=false delivered=false
  owner6/project-6       sent=false delivered=false
  owner7/project-7       sent=false delivered=false

rows recorded sent=true but never delivered: 0     (was 4)

The truncation is no longer silent:

WARN ✂️ Digest too long for Telegram — dropped 4 of 8 repos: owner4/project-4, owner5/project-5, owner6/project-6, owner7/project-7
  • pnpm test — 73 pass (2 new), pnpm tsc and pnpm format:check clean

Worth a look during review

sendTelegram now returns Set<string> instead of boolean. A failed send returns an empty set, so nothing gets marked sent — same outcome as the old false, 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

DamengRandom and others added 2 commits August 1, 2026 19:38
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
@DamengRandom
DamengRandom merged commit 3388f24 into master Aug 1, 2026
4 checks passed
@DamengRandom
DamengRandom deleted the fix/T-34-record-only-delivered-repos branch August 1, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trending digest drops repos to fit Telegram's limit, then records them as sent

1 participant