fix(journal): turn_id DESC tie-break on same-ms turn listings#161
Merged
Conversation
get_session_turn_ids (SQLite + Postgres) and find_resumable_turn ordered by started_at_ms alone; two turns seeded within one wall-clock ms tie on the timestamp (begin_turn's integrity-collision retry bumps turn_id +1 but keeps started_at_ms), so the listing came back in scrambled natural-row order. Surfaced as a full-suite-only flake in test_fork_copies_completed_turns_faithfully — fork_session read its source through list_session_turns (which already carries the critical secondary sort) while the comparison helper read through get_session_turn_ids (which didn't). Aligns every turn listing on the same (started_at_ms DESC, turn_id DESC) contract + pins it with a forced same-ms regression test. Claude-Session: https://claude.ai/code/session_01TkyhWocv6Kyjym4jsGBnq5
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
7 个 gap-close PR(#114-#120)合并后,在合并树上跑全量套件时
test_fork_copies_completed_turns_faithfully偶发失败(单跑/单包跑均通过)。根因
begin_turn用同一个 wall-clock ms 生成turn_id与started_at_ms,主键冲突重试会 +1turn_id但不改时间戳 —— 同一毫秒内落库的两个 turn 在started_at_ms上平局。list_session_turns已带turn_id DESC次级排序(注释里明确写了这是 critical),但get_session_turn_ids(SQLite + Postgres 两个后端)和find_resumable_turn的两条 LIMIT 1 查询都没有 —— 平局时返回顺序退化为自然行序,fork 的 faithful-copy 比较在全量套件的时序下随机翻车。修复
所有 turn 列表查询统一到
(started_at_ms DESC, turn_id DESC)契约;新增强制同毫秒平局的回归测试。验证
https://claude.ai/code/session_01TkyhWocv6Kyjym4jsGBnq5