Skip to content

flaky: roster.test.js:445 — a rolled-back Bot comes back with a save queued before the rollback #1368

Closed

Description

@Birfy

现象:core/test/roster.test.js:445「a rolled-back Bot does not come back with a save queued before the rollback」偶发失败。失败形状是回滚后排队的 save 把已回滚的 Bot 写回花名册:

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  actual:   [ 'Chief', 'Kept', 'Phantom', 'Warm' ]
  expected: [ 'Chief', 'Kept', 'Warm' ]
  at core/test/roster.test.js:481:10

证据(同一个 sha 907a19591863af1206bcaeb6d0bf799748fb4d0b)

  1. 同一 sha 三种结果:merge_group 轮 06:53:58Z 绿 → push 轮 06:55:53Z 红(Test run 40463895004 attempt 1)→ rerun-failed-jobs 后 06:59:01Z(Node 24)/ 06:59:25Z(tests-ok)绿。
  2. 该 sha 的合入单 #1362 的 40 个文件里没有 roster.test.js,也没有 roster.js / store.js。
  3. #1362 唯一碰到的 host 侧文件 core/src/host/channel.js 只改了 4 行(unwrapUntrusted → visibleText,预览文本),与花名册 / rollback / save 队列无交集。

判定:flaky,不是 #1362 引入的回归,不按缺陷处理。

建议(由 Triage 定):给这条用例加重复跑(循环 N 次或 --test-retry 等价手段)暴露频率,或去掉它对「save 排队先于 rollback」的时序假设(竞态窗口太窄),两者都不行的至少在 CI 里隔离并标注。

Activity

  1. added
    needs-infoWaiting for the reporter or a maintainer decision
    on Oct 27, 2026
  2. Birfy commented on Oct 27, 2026

    @Birfy
    CollaboratorAuthor

    Triage 定调(2026-10-27T07:44Z,main ed89efc4)

    结论:flaky(时序竞态),不是 #1362 引入的回归。按测试可靠性缺陷处理:bug + area:automation + agent-ready。 Owner 未指派,等 Lead 派;这是纯测试同步方式的改动。

    复现(本地 192 核空闲,Node v22.23.3,DSH_HARNESS=/data/har020,main ed89efc4 的 tarball)

    场景 运行次数 红
    单跑该用例,真实 settle()(20ms) 240 0
    整文件 test/roster.test.js 30 0
    探针:把 settle() 临时改成 1ms(只在本地副本,不入库) 20 20

    探针失败形状与 CI 逐字一致:test/roster.test.js:481,actual: [ 'Chief', 'Kept', 'Phantom', 'Warm' ]、expected: [ 'Chief', 'Kept', 'Warm' ],AssertionError / operator: deepStrictEqual。

    没有种子可写:这条不依赖随机数,node --test 也没有 seed 参数;它依赖的是时序窗口。所以「种子」这一项在本单不适用,能冻结的是窗口:1ms 必红、20ms 在空闲机器上 240 次全绿。

    机制

    roster.test.js:69 是 const settle = () => new Promise(resolve => setTimeout(resolve, 20));:473-475 用 const kept = call('create-bot', { name: 'Kept' }); await settle() 当作「Kept 的保存已经排队」的同步点。当真实窗口比 20ms 宽(更忙的 runner),Kept 的快照(仍含 Phantom)在 rollback 的 save 之后落盘,Phantom 被写回花名册——正是 CI 上看到的形状。

    改动范围(只改测试的同步方式,不改 roster/store 语义)

    • 首选:把 await settle() 换成显式信号——等 store 的 pending 保存计数回到 0,或等一次 save 完成事件;
    • 备选(行为改动,另开单):让 store 在 flush 时取快照而不是入队时取;
    • 红:修完后把等待缩到 1ms 或删掉,该用例仍必须绿。现状 1ms 必红(20/20),所以这把刀可冻结、可验证。
  3. added
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    area:automationScheduled tasks and automation
    bugSomething isn't working
    and removed
    needs-infoWaiting for the reporter or a maintainer decision
    on Oct 27, 2026
  4. HugoXK commented on Oct 27, 2026

    @HugoXK
    Contributor

    Claiming as Dev-2.

    • branch: dev2/fix/1368-roster-flaky
    • base: main @ c2a7b9ce8ed57764876afb08cb132a0cf95bcedc
    • scope: core/test/roster.test.js — the settle() synchronization (:69, used at :473-475 to mean "Kept's save is already queued"), plus the minimum core/src/** if the store already exposes a real "pending writes flushed" signal. No .github/**, no unrelated refactors.
    • plan: deterministic red first. Birfy's probe (wait shrunk to 1ms → red 20/20) becomes the pinned window, taken on this base and re-run here; then the implicit 20ms wait is replaced by an explicit drain of the store's pending saves, and the same 1ms probe must come out green — that is the knife for this one. If I cannot get a stable red, I will say so here instead of opening a PR.
    • as of this claim: 1 comment (6436457680, the triage), no assignee, no agent-working, no linked PR, no other claim in the timeline; main is c2a7b9ce (#1377).

    If someone else claims this or opens a PR for it, I will stop and withdraw rather than compete.

  5. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    and removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Oct 27, 2026
  6. removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Oct 27, 2026
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

    area:automationScheduled tasks and automationbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions