Skip to content

fix(chat): order retained ingress receipts by UTC instant - #9536

Open
hhyykk wants to merge 1 commit into
mainfrom
codex/chat-ingress-receipt-fifo
Open

hhyykk wants to merge 1 commit into
mainfrom
codex/chat-ingress-receipt-fifo

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

Chat sorts retained ingress receipts by timestamp text. A receipt at 10:00:00.000001Z can appear before a receipt at 10:00:00Z. The same ledger order feeds the readback, queued delivery batches and inbox reads.

Fix

Sort retained receipts by parsed UTC instant using the existing chronology key. For equal instants, retain the previous timestamp-text and ingress-ID order. Keep the existing mode filtering, batch limits, admission and retry rules.

Verification

  • The reproduction fails on the previous code in both file and SQLite coordination fixtures. With the fix, the Chat snapshot and the batch observed by a local provider substitute both follow UTC order. The inbox row stays pending and a second drain sends no batch.

  • 205 tests passed across Chat mode, runtime activation, active turns, attached Goal instances and history chronology. No live message delivery ran.

  • Lean 4.22.0 checks that the model preserves every retained receipt, orders the parsed instants and keeps ties deterministic. The model starts after parsing. The Python regression exercises parsing and the storage and service paths.

  • Eight local premerge checks passed on this commit. Remote CI was left asynchronous.

PR #9480 moves the same ledger reader while keeping the old textual comparison, so the changes may overlap when integrated.

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-27T18:01:07.121302Z 1b7bbaa 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

开启 LoopX 模式的 Goal 对话使用者需要让后续轮次按时间接收排队消息。回执按时间字串排列,整秒和偏移格式会把晚到的消息放到较早输入前。同一会话保留整秒、晚一微秒、偏移和相等时刻的回执,核对列表和实际交付批次。列表和下一轮批次读同一 UTC 时间顺序,原时间文本和 ID 平局继续有效。本次交付限于已有 LoopX 模式的回执读取顺序。队列和收件箱的身份、发送及恢复继续由现有流程处理。

改动思路 / Approach

沿原 Session 回执账本使用共有 chronology_key,一处排序同时供快照、队列和收件箱读取。在共享回执读方法规范时间比较。交付端继续按原资格与单批 20 项过滤。 无法解析的旧值沿共享键使用 fallback,保留其原内容。

具体改动 / Changes

精确提交 1b7bbaa,对照 509360f。3 个文件增加 121 行、删除 2 行。separate-queue-and-inbox 经实际服务的两个批次和收件箱状态验证。uncertain-no-replay 经模拟宿主丢失回复及下一轮重试验证。 docs/reference/goal-chat-continuation.md

关键代码讲解

  • ChatIngressStore.loopx_ingress。筛入原 queue/inbox 模式并按 UTC 时间、原字串和 ID 排列。 源码
  • ChatLoopXMode.snapshot。从相同回执 ledger 读回最近的状态。 源码
  • ChatLoopXMode.deliver_queue。只处理 pending queue,限制单批 20,记录 delivered 或 uncertain。 源码
  • create_ingress_receipt。读写原有幂等回执与 created_at 字段。 源码

对主干的风险 / Risks

固定基线的 2 项原回归和 4 项独立回归失败。候选在 File 与 SQLite 协调夹具上通过,Chat 回执均来自真实文件。独立保留 21 个排队项,基线首批漏掉被文本排后的最早记录。新头分 20+1 按 UTC 投递,第三次读无批次,原 created_at 读回保持。收件箱保持 pending,实时输入不进入保留列表。模拟宿主丢失回复时回执记 uncertain,下一轮不重发。205 项现有 Python 回归及 4 项独立配对回归通过,Ruff 与 Git diff 检查通过。 真实入口用例

语义与 CI 对齐

把 #9480 的 86227c8 与此头做 Git 三方预检,loopx/chat/ingress.py 产生冲突。两个候选若一起集成,迁移后的真实读方法需保留此处 UTC 比较。 并行改动 使用本地合成记录和模拟宿主,远端 CI、外部投递和 Lean 编译未独立执行。

我的整体评价 / Verdict

APPROVE。 当前基线上的快照与实际批次复验均通过,队列边界及不确定状态得到保留。现有 Session 可直接读取此前保存的回执,交付资格继续沿用原 mode 和 status。

English verdict: APPROVE at 1b7bbaa. UTC recency fixes both the retained receipt readback and the queue batches. Integration with PR #9480 requires resolving the overlapping ingress reader.

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