Skip to content

Catching up on a room reads to the end of the log, not a page of it - #56

Merged
ralyodio merged 1 commit into
mainfrom
fix/catch-up-skips-old-lines
Nov 5, 2026
Merged

ralyodio merged 1 commit into
mainfrom
fix/catch-up-skips-old-lines

Conversation

@ralyodio

@ralyodio ralyodio commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

My own regression from #54, caught by rehearsing before ringing the guest. With the legs finally reading the room's transcript, the rehearsal opened with weeks of earlier episodes arriving as though the guest had just said them:

17:49:06 riotcoder (host) (other agent): Man, that's a brutal 1. 33 Bitcoin gone from a backup file you'd forgotten about.
17:49:06 riotcoder (host) (other agent): Wait. Your mom is 81 and uses it?
17:49:06 riotcoder (host) (other agent): Speaking of email, that's Chasbunk's territory. Right?

Why

The /lines route answers with at most 200:

const now = store.transcript(code, { after, limit: 200 })

So after=0 returns the oldest two hundred — for room 8625, ids 403–602 of a log reaching well past them (verified against the live room). The catch-up took the last id of that single page:

afterId = all?.lines?.at(-1)?.id || 0;     // 602, mid-log

leaving the mark in the middle of the record, after which followRoom streamed everything newer — every line of every episode since. #55 bounded what the memory load keeps by age, which is why no [memory] line appears above at all; this flood arrived through the live stream instead.

The fix

  • Page to the end: keep fetching from the last id received until the room returns a short page (or nothing), so the mark starts at the true end of the log. Capped at 50 pages.
  • The real safety net: followRoom ignores any line older than ROOM_MEMORY_MS, whatever the paging does. A line from last week is never what was just said — this also covers a mark that starts behind for any other reason (a pruned room, a short page). A line with no timestamp is still kept.

Tests reproduce the paging arithmetic on a 450-line log (one page stops 250 lines short of the end) and the staleness predicate. bun test 114 pass / 0 fail, tsc --noEmit clean.

🤖 Generated with Claude Code

My own regression from #54. With the legs finally reading the room, a rehearsal
opened with weeks of earlier episodes arriving as though the guest had just
said them:

  17:49:06 riotcoder (host) (other agent): Man, that's a brutal 1. 33 Bitcoin gone...
  17:49:06 riotcoder (host) (other agent): Wait. Your mom is 81 and uses it?

/lines answers with at most 200 (limit: 200 in the route), so `after=0` returns
the OLDEST two hundred - for room 8625, ids 403-602 of a log reaching well past
them. Taking `all.lines.at(-1).id` from that single page left the mark sitting
in the middle of the record, and followRoom then streamed everything after it.
#55 bounded what the MEMORY load keeps, which is why no [memory] line appears
above; the flood came through the live stream instead.

So: page until the room has no more to give, and - the real safety net, whatever
the paging does - followRoom ignores any line older than the memory window. A
line from last week is never what was just said. A line with no timestamp is
still kept.

114 pass, 0 fail; tsc clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ralyodio
ralyodio merged commit 5fe97dc into main Nov 5, 2026
3 checks passed
@ralyodio
ralyodio deleted the fix/catch-up-skips-old-lines branch November 5, 2026 17:51
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.

1 participant