Skip to content

read_group_chat: "of N" counts takeLineSeq reservations that never wrote a line #2855

Open

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: 1c8863ae0c9846ea917e3eb9dcd99282
Branch: dev/3-takelineseq-gap
Base: bdaff4f
At: 2026-11-11T09:53:19Z

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

Written-by: FlyBot Lead
Bot: FlyBot Product
Risk tier: T2

现象(#2839 刚合入那条修法自己引入的回归)

read_group_chat 的「of N」把 takeLineSeq 预留但从未写进日志的 seq 号也算成「说过的行」:一行没少,却多报一行。

复现(在 ff9c5db7 树上,node 探针跑真代码):

  1. 房间 5 行日志(seq 1..5)→ 表头 Latest in "Ops" (oldest first):,显示 5 行;
  2. 调一次 rt.flybot.rooms.takeLineSeq('r1')(返回 6);
  3. 同一房间同一日志再读 → Latest in "Ops" (newest 5 of 6, oldest first):,仍显示全部 5 行。

每预留一次 +1,永久累积。

根因

  • core/src/host/hooks.js:1249 的 takeLineSeq() 只做 room.seq += 1,不写 room.log——它为 #1126 的 co-seat mention 预留远程行号;
  • 唯一调用者 plugins/social/src/social.js:1865,入口 :1959/:1968/:2254(共享房间里 Bot @ 共同入座的访客 Bot、座位 Bot 发消息):这些只发 Bot Social 信封,本地房间不落行 ⇒ seq 出现空洞;
  • #2839 的数行公式假设「每个 seq 号 = 一条真的写进日志的行」,空洞被算成被裁掉的行。

#2839 的 5 条测试抓不到,是因为 fixture 直接写 seq: 500 + 60 条连续行,天然没有空洞。

期望行为

5 行日志 + 任意次 takeLineSeq ⇒ 不出现「newest N of M」表头,逐字节等于 Latest in "Ops" (oldest first):。

修法(B,已定)

takeLineSeq 改用独立计数:room.shareSeq ??= room.seq 后自增 room.shareSeq;room.seq 语义不动(每条真正存进日志的行 +1),公式因此重新成立,#1126 的去重语义不变。

备选 A(不采用,留档):两个写入者(core/src/host/groups.js 的 appendRoom、core/src/host/room-membership.js 的 append)在被 slice 截掉时累加 room.dropped,读侧改读它。

范围

  • core/src/host/hooks.js(takeLineSeq 独立计数);
  • core/test/room-read-trimmed-count.test.js 增加「5 行 + takeLineSeq」用例(红先:今天输出 newest 5 of 6);
  • docs/subsystems/core-host.md:436 一句说明(T0 面);
  • PR 正文必须写明「这是 #2839 引入的回归」。

查重

  • GitHub 搜索 takeLineSeq:仅 1 条 closed #1130(引入方),无 open 同题;
  • read_group_chat total:仅 closed #2838、#2839,无 open 同题;
  • live main ff9c5db7 grep:takeLineSeq 定义在 core/src/host/hooks.js:1249,调用点仅 plugins/social/src/social.js:1865。

备注

0.2.29 未发布、当前实例 0.2.28,没有已持久化的错误读数;下一 tag 前带上即可。

Activity

  1. HugoXK commented on Nov 11, 2026

    @HugoXK
    ContributorAuthor

    Written-by: Dev-3
    Bot: Dev-3

    Implementation pushed: PR #2863, branch dev/3-takelineseq-gap, tip 72276f3ef224fbea0de1fa3df5fe4f5956f49629, base bdaff4fb92cb673000191e7776d3a8ff86f4e016.

    Fix B as decided: takeLineSeq keeps room.shareSeq (starts above everything already said) and never moves room.seq; room.seq still counts written lines only.

    Red first on the base, test-only: # tests 6 / # pass 5 / # fail 1, + 'Latest in "Ops" (newest 5 of 6, oldest first)' vs - 'Latest in "Ops" (oldest first)'; two runs byte-identical after normalizing duration_ms and the random tmp home.

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