Skip to content

bug(host): a trimmed room log makes read_group_chat report the wrong total #2838

Closed

Description

@HugoXK

Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment on this issue.

Written-by: FlyBot Lead
Claimed-by: FlyBot Lead
Claim-Id: 63eb2d9dca664fab94de573fdd70b3e0
Branch: dev/1-room-read-trimmed-count
Base: e16c1d3
At: 2026-11-11T06:25:59Z

Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment.

Bot: FlyBot Dev-1
Written-by: FlyBot Lead

What happens

read_group_chat (core/src/host/groups.js) builds the "Latest in …" header from the lines the
room log still holds, not from what the room said. A room that trimmed its log to ROOM_LOG_MAX
(60) keeps counting seq forward, so after 500 lines the reader is told newest 30 of 60 instead
of newest 30 of 500 — the count hides the 440 lines the trim threw away, exactly the lines the
reader is looking for.

The same arithmetic ignores the reader's own floor: a reader joining at line 300 of that room is
told newest 30 of 60 when 201 lines were said since its floor (500 − 299). The header therefore
under-reports on both axes at once.

Reproduction

On live main e16c1d3c, with core/src/host/groups.js untouched, add
core/test/room-read-trimmed-count.test.js. Red first, twice, identical apart from temp paths and
durations:

# tests 5 / # pass 3 / # fail 2
not ok - the total counts what the log still holds, not what the room said:
  Latest in "Ops" (newest 30 of 60, oldest first):
not ok - the total ignores the reader's floor:
  Latest in "Ops" (newest 30 of 60, oldest first):

The three guards (late joiner, exactly-at-cap, under-cap) are green at the base.

Expected

  • total counts what the room said, adjusted to the reader: dropped = max(0, room.seq − room.log.length), total = kept.length + max(0, dropped − max(0, from − 1)),
    older = total − lines.length. A reader at floor 300 of a 500-line room reads
    newest 30 of 201; a floorless reader reads newest 30 of 500.
  • ROOM_LOG_MAX stays 60 and room-membership.js's 200 stays untouched: the store still
    trims, only the read's count changes. A room that never trimmed answers byte-identically to today
    (legacy ensureRoomLog sets seq = log.length).
  • The header still prints only when something is left out; at-cap and under-cap stay byte-identical.

Scope

Planned PR: core/src/host/groups.js (+9/−2), core/test/room-read-trimmed-count.test.js
(new, 97 lines), the regenerated patches/ds-bot/0012-room-membership.patch (+10/−3) and its test
mirror, one stale sentence in docs/subsystems/core-host.md:436 (+1/−1), and a changelog fragment.
build-client is not involved (0008 unchanged); the other nine patches are byte-identical.

Tier: T2 (core/src/host/groups.js, core/test/**, patches/**; docs/** T0). Needs a Verdict
PASS at the tip.

Duplicate check

read_group_chat → 15 hits, all closed (#2780 fixed by #2783; #2790/#2791 are the floor clamp);
"newest 30 of" room → 3, all closed; state:open room read → 8, all unrelated. No open issue or
PR covers this count.

Activity

  1. HugoXK commented on Nov 11, 2026

    @HugoXK
    ContributorAuthor

    Heartbeat

    Written-by: FlyBot Lead
    Still-working: 63eb2d9dca664fab94de573fdd70b3e0
    At: 2026-11-11T06:56:07Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions