Skip to content

fix(steward): order equal-priority follow-ups by UTC time - #9540

Open
hhyykk wants to merge 2 commits into
mainfrom
codex/steward-followup-utc-order
Open

hhyykk wants to merge 2 commits into
mainfrom
codex/steward-followup-utc-order

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

When two runnable Steward follow-ups have the same priority, timestamp-text order can put a newer Todo first. A whole-second timestamp ending in Z sorts after the fractional timestamp one microsecond later. The foreground pump consumes the selector's order.

Fix

Use the shared UTC chronology key for the creation-time comparison. Keep priority first and preserve the original timestamp text and Todo ID as tie breakers. Eligibility filters are unchanged.

Verification

  • A local selector fixture fails on the old code. The fix keeps the newer P0 first, orders equal-priority P1 Todos by UTC instant, resolves equal times deterministically, and keeps a Todo waiting to resume out of the result.
  • Lean 4.22.0 verifies that the model keeps exactly the eligible Todos, orders priority first, and orders parsed instants within a priority. The model starts after timestamp parsing. Reversing the time comparison breaks the proof.
  • The focused suites passed all 20 tests and the commit passed all 9 local premerge checks. The wider Steward run reported 219 passing tests and one failure in test_resolve_advancement_turn_id_handles_selection_deferral_and_precommit_retries. A clean snapshot of the base commit reproduced the same assertion and retry token. The retry code and its test are unchanged here.

@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-28T03:42:15.767929Z df6ee95 New commits
ℹ️ 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

REQUEST_CHANGES

[P2] 正常 Steward 跟进缺少排序所需的创建时间。 排序位置

动机 / Motivation

管家有多个同优先级、已就绪的跟进待办时,前台调度决定先启动哪个。选择器对记录的 created_at 按原文本比较。权威 Todo 记录缺少这个字段时,同优先级直接落到 Todo ID。 单测直注 created_at 时,基线将晚一微秒的记录提前,候选按 UTC 正确排序。真实调度也保留 P0 优先和每次 pump 单个提交。 File 与 SQLite 的普通创建和权威读取都不给跟进待办交付 created_at。两种后端上,基线和候选的真实 pump 在 P0 退出后都先提交晚一微秒的 Todo,按 ID 打破了空时间键。 范围为已启用 Steward 的前台跟进选择,使用本地真实权威存储和会话,提交宿主在配对测试中只记录请求。

改动思路 / Approach

在现有选择器复用 UTC chronology_key,保留原优先级、就绪过滤和 Todo ID 平局。补充了注入时间戳的回归和 Lean 抽象模型。 时间比较 helper 已有且适用。需要同步检查真实生产侧是否给读取端投影该字段。 现有调度入口和 Todo 类型所有者之间缺少同一份创建时间。

具体改动 / Changes

精确提交 69319bf1c39a9aad12a607c922c873a03f85544e。目标基线 509360fb0d3e9e6e578ddf5c12db587886016b23。3 个文件,增加 109 行、删除 1 行。 权威状态机 评审条件 native-todo-source、priority-and-single-dispatch。

关键代码讲解

  • StewardMonitor.runnable_advancement_todos。按所有者、状态、类型及恢复资格过滤,然后用优先级、created_at 和 Todo ID 排序。 源码
  • _process_steward_binding。前台空闲时按 selector 返回顺序发起第一个有效后续轮次。 源码
  • createCandidate。原生 Todo 创建只写 updated_at,统一进入权威版本化记录。 源码
  • chronology_key。解析 UTC 时间。缺失或旧非法值走稳定 fallback,保留已有文本次序。 源码

对主干的风险 / Risks

候选 Steward 套件 213 项通过,包含 PR 的选择器正反例。两个原生创建测试成功读回,四组 base/head 与 File/SQLite 的 pump 对照复现放错顺序。 让 P0 通过真实 CAS 离开队列后,核对下一次的提交请求、身份和单次分派。原生创建与读回不注入额外时间字段。 Lean 模型从时间字段已解析后起步,本机做了源码复核。

语义与 CI 对齐

两版共用的一项转向重试断言失败,返回相同的 precommit-retry token。实现和用例都不在此 diff。

我的整体评价 / Verdict

REQUEST_CHANGES。 给正常读路径提供权威且稳定的创建时间或创建序号,再按优先级和这一顺序选择。处理缺值的旧记录。若选用 updated_at,应明确语义改为最近更新时间,并验证编辑会怎样改变队列。 从 File 与 SQLite 的权威列表进入正常 pump,验证较早创建的同优先级 Todo 先提交、早晚判断不受 ID 和后续编辑影响,且一轮只提交一次。

English verdict: REQUEST_CHANGES at 69319bf. The real File and SQLite Todo projections omit created_at, so the foreground pump still dispatches equal-priority follow-ups by Todo ID. Use an authoritative creation-order field and verify both stores through the pump.

@mergify

mergify Bot commented Nov 28, 2026

Copy link
Copy Markdown

Hi @hhyykk, the DCO Sign-off check did not pass. Please inspect
its details first: checkout, fetch, timeout or infrastructure errors
need their own recovery, not a rewrite of otherwise signed commits.

If the log confirms a missing Signed-off-by trailer, amend the
affected commit with git commit --amend -s; for multiple commits,
use an interactive rebase against the current base from the correct
base-repository remote and sign off each affected commit. Push the
rewritten PR branch with git push --force-with-lease origin HEAD.

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.

3 participants