Drop board snapshots that arrive out of order
维护者通常 1 天内回复
@AchlysChang 已经在做这个了。
开始于 2026年11月19日。
评估
调研方向
Start at livekit::board::record and trace how the browser sends board streams and how HintAttempt.board_revisions uses recorded revisions. Then read tests/unit/livekit/board.rs and add the reverse-order delivery case described in the issue. Done means the older snapshot is dropped and the test observes one revision.
由索引模型根据 Issue 内容生成。
描述
Board snapshots reach livekit::board::record (src/livekit/board.rs:469) in the order their readers finish, not the order the browser sent them. Each byte stream is drained on its own spawned task (handle_board_event, src/livekit/board.rs:333) and the finished boards enter the room loop's queue in whatever order those tasks call tx.send. The browser sends one board at a time (board.publishing in web/interview.js, uploading in web/example-board.js), so the agent sees two streams back to back rather than overlapping, but with two drain tasks on a multi-threaded runtime the later stream can still finish first. record compares a board only with the previous one, so the older board is then taken as a new change: HintAttempt.board_revisions (#707) counts it, a Candidate-led hint held for lack of an attempt can be released by a board the candidate drew before the clue, and the interviewer and read_board are left on the older drawing.
Proposal
Number every board on the wire and have the agent drop a board that is not newer than the last one it recorded from the same page.
Where the sequence goes on the wire
boardStreamOptions (web/lib.js) already takes the sequence the page keeps (board.sequence in web/interview.js, st.boardSequence in web/task.js) and puts it only in the stream name, board-<n>.jpg, which the agent does not read. The proposal adds it to the stream attributes as sequence, a decimal string, beside strokes and checkpoint, because the attributes are the only part of the header the agent reads (strokes_from_attributes and checkpoint_from_attributes, src/livekit/board.rs:302 and :313). A new sequence_from_attributes reads it the same way, at the same place in handle_board_event, and BoardSnapshot carries it to record. The name keeps the number for logs.
A page reload
board.sequence starts at 0 on every page load, so after a reload the new page's boards are numbered below the old page's and would all be dropped. The ordering therefore has to restart with the page. Resetting the agent's last sequence when the candidate's participant reconnects is not enough on its own: a board the old page finished sending can still be waiting in the queue when the reconnect is handled, and recorded after the reset it would set the last sequence high again and drop the new page's boards until it caught up; the reset would also need a hook in each of the three room loops that read boards (src/livekit.rs, src/livekit/recovery.rs, src/livekit/tasks.rs). Instead the page generates a random id once per load and sends it as a second attribute, page, and the agent compares sequences only within one page id. A board from a different page id than the last one recorded starts a new page and is recorded; a board from the page id that was just replaced is dropped, which covers an old page's board that finishes after the new page's first one. The id is an opaque random string, not a timestamp, so no clock on either side is involved, and a client that lies about it can only cause its own boards to be dropped or kept.
What record does with a dropped board, and with one that carries no sequence
A dropped board changes nothing: not board_snapshots, hint_attempt.board_revisions, board_strokes, board_drawn, last_board_at_ms, latest, unsent or the phase checkpoints, and record returns false as it does for an unchanged board. The same check runs in keep (src/livekit/board.rs:501), the variant for a room with no interview state, and in keep_board in src/livekit/tasks.rs, which currently copies the stroke count before calling keep and has to make that copy only for a board that was kept. A dropped board is logged once to stderr with both sequences.
A board whose sequence or page is missing or does not parse is recorded exactly as today and does not move the last sequence. That follows the rule strokes_from_attributes already states: the picture is the message, and a board is still worth showing when an attribute beside it did not survive. Only a client that is not the browser sends such a board, and it can only lose ordering for its own boards.
Wire fixture and tests
tests/fixtures/board-stream.json is generated from boardStreamOptions by scripts/gen-wire-fixtures.mjs and read by reads_the_attributes_the_browser_sent (tests/unit/livekit/board.rs:136). Regenerating it puts sequence and page on its three cases, and that test also asserts the sequence and page each case parses to, so a browser that renames or stops sending either attribute fails there. The page id in the fixture is a fixed string passed in by the generator, so the fixture stays deterministic. tests/browser/lib.test.js asserts the new attributes in its boardStreamOptions case. Unit tests in tests/unit/livekit/board.rs: two boards recorded newest first count one revision and leave the newer image as latest; a board from a new page id after a high sequence is recorded; a board from the replaced page id after that is dropped; a board without a sequence is recorded and does not move the last sequence; and keep drops a stale board the same way.
The comment in web/interview.js
The comment on board.sequence says the agent reads the name for nothing, deliberately, and keeps the newest board it finished reading rather than the highest number. That is the behavior this issue changes, so the comment is rewritten to say the number is now on the wire as sequence and the agent drops a board numbered at or below the last one from the same page, while board.publishing remains what keeps the page itself from opening two streams at once.
Contract
This changes no prompt, score anchor or report shape, so per docs/interview-contract-versions.md ("Changing it") it opens no bundle and adds no row. The board_image wire description in docs/task-mode.md names the stroke count as the stream's attribute, so it gains sequence and page and the drop rule.
Out of scope
Run results and other packets travel on the reliable data channel in order and are not affected. Who sends a board and how large it may be stay as they are.
- 主要语言
- Rust
- 星标
- 236
- 派生
- 153
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 187
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/codetrial 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 70/100
维护者通常 1 天内回复
-
Unify Java harness validation error messages可能已有人在做 @weichieh0204 今天认领。 未关闭
sysprog21/codetrial#872 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Inferred void class operations are never checked against the starter's return type可能已有人在做 @papaya0112 今天认领。 未关闭
sysprog21/codetrial#871 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwrite可能已有人在做 @BOBOGUAGUA428 今天认领。 未关闭
sysprog21/codetrial#869 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 sysprog21/codetrial 的全部 Issue
相似的 Issue
-
needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
manaflow-ai/cmux#59692 ·
维护者通常 1 天内回复
-
Retire stale Python-parity labels in Rust ingress and auth tests可能已有人在做 @github-actions 今天认领。 未关闭factory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
难度 2/5 1-3 小时 新手友好度 82/100
JoshCLWren/comic-pile#5874 · 2 条评论 ·
维护者通常 1 天内回复
-
status:ready unit
难度 2/5 1-3 小时 新手友好度 75/100
nonagenticai/conveyor#787 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复