Skip to content

fix(chat): order completion history by UTC instant - #9533

Open
hhyykk wants to merge 1 commit into
mainfrom
codex/chat-completion-chronology
Open

hhyykk wants to merge 1 commit into
mainfrom
codex/chat-completion-chronology

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

Chat's Completed Todo and Goal Results endpoints sorted completion timestamps as text. In a retained history with whole-second, fractional-second and offset encodings, a completion one microsecond later could appear on the next page behind older records.

Both endpoints now use a shared UTC chronology key. Equal instants use the existing source-position tie break. Unreadable timestamps come after dated rows and keep their deterministic legacy order. The original timestamp strings and snapshot cursor behavior are preserved.

Author Declaration

  • Written by model_agent, OpenAI Codex (GPT-6 family).
  • Reproduced on main at 509360fb0 using real loopback Chat endpoints over disposable File and SQLite histories.
Criterion Disposition Evidence
Newest completed Todo and accepted result appear first implemented Real File and SQLite HTTP comparisons cover whole seconds, fractional seconds and equivalent offsets.
Preserve tie and paging behavior implemented Equal UTC instants keep their source-position order. Completing a new Todo leaves both old cursors on the original snapshot. A fresh page includes the new Todo first.
Preserve accepted-result verification implemented The regression creates accepted result artifacts through the canonical writer and reads them through the normal verified Goal Results endpoint.

Validation

Check Result Evidence
Baseline comparison passed Both provider fixtures reproduced the first-page inversion on main. A separate baseline probe reproduced it through both endpoints.
Chat completion-history suite 22 passed PYTHONPATH="$PWD" python3 -m pytest -q tests/test_chat_completed_todos.py
Canonical acceptance and accepted-report reads 2 passed PYTHONPATH="$PWD" python3 -m pytest -q tests/test_managed_research_team.py -k canonical_delivery_requires_completed_current_dependencies
Shared chronology regressions 6 passed tests/test_history_chronology.py
Lean 4.22.0 passed lean -DwarningAsError=true regression/ChatCompletionChronology.lean. Sorting equal instants by raw text rank makes the tie theorem fail.
Local premerge 10 checks passed python3 -m loopx.entrypoint canary premerge --from-git-diff --git-diff-base origin/main --tier quick
Ruff passed Both changed Python files.

The Lean model starts from parsed UTC microseconds and proves sortedness, retention, ties and page concatenation. The actual HTTP checks cover timestamp parsing and cursor behavior across a new completion.

Scope And Continuation

The patch is limited to the Chat read projection. Authority readback, result verification and cursor scope retain their existing contracts. All validation uses disposable local synthetic records.

Frontend / Visual Evidence

The data-order change affects completed history and Goal Results. Both existing consumers display server page order. In the two-row HTTP fixture, the whole-second record and its offset-equivalent appeared first on the baseline. After the fix, the newest fractional-second record appears first. Browser rendering was outside the validation run.

Type Of Change

  • Bug fix
  • Documentation update
  • Test update

LoopX Area

  • Capability or extension

Shared-authority RFC fixture impact

N/A.

Boundary Checklist

  • Changes and evidence use public-safe synthetic records.
  • The change is scoped to the reproduced Chat history issue.
  • No paired RFC changed.
  • The commit includes a DCO Signed-off-by trailer.

Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T17:24:42.824932Z 3af665c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

Workspace 的任务和成果读取者需要让最新完成项出现在当前分页的前面。 不同偏移、跨日期或小数秒编码按文本排序时,较新的任务和已验收成果会落到旧项后面。 两个 Chat 入口按 UTC 时刻从新到旧排序,同时保留原时间文本、同一时刻的源位置优先级及历史快照分页。 本次交付范围为完成任务与已验收成果的读取顺序。

改动思路 / Approach

复用现有 chronology_key 的时间解析,两个投影只共享一个局部排序键。同一有效时刻比较源位置,旧无效值留在可读时间之后并保持同类原顺序。 本次交付范围为完成任务与已验收成果的读取顺序。 成果仍按原读取路径核对内容摘要和生产者,同一个游标继续对应原快照。

具体改动 / Changes

审查精确提交 3af665c35390befeb8e8636b6d45ef14a4c8085b,当前比较基线 509360fb0d3e9e6e578ddf5c12db587886016b23。四个文件增加 233 行、删除 3 行。生产差异集中在 Chat 投影,另有双语用户指南、真实 HTTP 回归和 Lean 模型。 utc-completion-order 已验证两个入口按 UTC 排序,等时刻保留源位置。stable-snapshot-and-verified-results 已验证新增完成不移动旧游标,已验收结果和原时间字串可读回。 Workspace 读取契约

关键代码讲解

  • _completion_order。共享 chronology_key 解析,使用 UTC 时刻及源位置,旧坏值保持原确定次序。 源码
  • _goal_result_candidates。对原候选应用同一排序,原页的 sha256 与生产者检查继续执行。 源码
  • CompletedTodoPages.page。首读冻结新顺序,后续读取沿原游标和范围。 源码

对主干的风险 / Risks

精确头的真实 File 和 SQLite HTTP 对照中,两个接口都将跨本地日期的新记录放在旧的整秒或等价偏移同刻记录前。分页后完成另一个任务,旧 cursor 仍只见原三条,新请求把新任务排首。原时间字串、等时刻源顺序与验收成果核验均读回。 基线在两个接口均出现页首倒置。原保留历史对照通过,新旧比较分别复现无效时间落位、普通混合编码和跨本地日期差异。 30 项 Chat 历史和共享排序测试、2 项真实双提供方跨日两入口对照、2 项 canonical 验收成果测试、Ruff 与 Git diff 检查通过。Lean 4.22.0 验证排序、保留、同刻与分页,把原字串等级重新加入同刻排序会使证明失败。 验证覆盖本地 File 与 SQLite、真实 Chat HTTP 和前端消费者源码,浏览器和远端 CI 未运行。

我的整体评价 / Verdict

APPROVE。 两个 Chat 入口按 UTC 时刻从新到旧排序,同时保留原时间文本、同一时刻的源位置优先级及历史快照分页。 两种后端上的真实 API 已复核可见顺序和旧游标行为。验证覆盖本地 File 与 SQLite、真实 Chat HTTP 和前端消费者源码,浏览器和远端 CI 未运行。

English verdict: APPROVE at 3af665c. Both native Chat endpoints now sort mixed offsets and fractional times by UTC on File and SQLite, while retaining snapshot membership, accepted-result verification, and the original timestamp strings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants