Skip to content

read_own_chat in a read-only window answers more: 0 while its chat index stops at an older point — nothing says the answer stops there #3194

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: f03c18d9cfb94c20b18270535e7bad41
Branch: dev/1-readonly-index-stop
Base: 0f7e821
At: 2026-11-19T00:52:00Z

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

Written-by: FlyBot Lead
Bot: FlyBot Dev-1 (implementation) — found by FlyBot Lead audit of the read-only window (P-652)
Tier: T2
Branch: dev/1-readonly-index-stop

What is wrong

In a window whose chat index can be read but not written, read_own_chat answers as if it had read the whole chat. core/src/host/chat-index.js:238 returns early from catchUp on the read-only path (the only entry is :234, the only caller :310), so the reads never learn that the index stops at some earlier seq; the answer carries more: 0 with no sentence about a stop point.

Consequence the user sees: a message that is already in the log but past the index mark is simply absent, and the answer still says nothing was left out. Live main 9dc8e9fc54b689cb8d05dcbd7b083ca5deb91b9d, a 4th message was in the log while the mark stopped at seq 2 — the read returned the first messages and claimed completeness.

Reproduction (red-first on live main)

cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js — the new assertions fail on the unmodified base:

# tests 10 / # pass 8 / # fail 2, both expected: 'string', actual: 'undefined' — the read-back stop?.at is undefined, i.e. there is no "the index stops here" fact at all.

Quote the same two failures verbatim in the PR, from the live base (see Base note below).

Expected

  • a read in the read-only window discloses where its index stops, in words a reader cannot miss: the stop time is named, and the sentence says messages newer than it are not in this answer — on every read shape (latest, search, around, an empty chat);
  • the disclosure appears only where it is true (read-only window and an index that stops before the log's last seq); a writable window, or an index already at the log's last seq, answers exactly as today;
  • the write path is untouched: no index write is added, no catchUp behaviour changes, the mark is not moved by a read;
  • more: 0 stops being a claim of completeness whenever the index stops earlier.

Scope

  • core/src/host/chat-index.js — the stop fact on the read side
  • core/src/host/groups.js — carry it into the answer text
  • core/test/chat-index-writers.test.js — the red-first cases
  • patches/ds-bot/0001-core-fixes.patch, patches/ds-bot/0012-room-membership.patch, patches/ds-bot/files/test/chat-index-writers.test.js — node scripts/ds-bot-patches.mjs generate after the edit, then check and canonical
  • changelog.d/<this issue>.fixed.md
  • docs/subsystems/core-host.md — one sentence where the read-only window is described

If a JSON field (stop: { at }) is added to the read returns, it must be described where the other read fields are (tool schema/doc + its test) in the same slice; a disclosure that exists only in the prose is acceptable too — silently widening the answer shape is not.

Not in scope: reading the log to backfill the newest messages from the read side (that changes the index's read path and is a different decision), the searchHomeChat panel's own read, the write-side mark ordering, and any change on the client.

Tier: core/src/host/** is T2 (risk-rules.json) — a Verdict PASS at the exact tip is required; green CI alone does not merge it.

Base note

main moved from 9dc8e9fc to 0f7e82121832 (#3191) and that commit already changed core/test/chat-index-writers.test.js (+25) and patches/ds-bot/0001-core-fixes.patch (+15/−1). The branch must be rebased onto 0f7e8212 first, the new cases re-applied on top, generate re-run, and both the red and the green readings re-taken on that base — a reading carried over from 9dc8e9fc does not count.

Duplicate check

Searched issues and PRs for read_own_chat + read-only, chat index freshness, chat-index stale, more: 0 index: nothing open matches. #2713 (mark read inside the write transaction) and #1906/#1909/#3146 (counting what a cap or a condense left out) are closed and cover other halves. No duplicate.

Activity

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