Skip to content

fix(steward): order due monitors by UTC deadline - #9541

Open
hhyykk wants to merge 1 commit into
mainfrom
codex/steward-due-monitor-utc-order
Open

hhyykk wants to merge 1 commit into
mainfrom
codex/steward-due-monitor-utc-order

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

Steward sorted due monitor deadlines as text. A deadline at 10:00:00.000001Z could be attempted before a deadline at 10:00:00Z. The pump uses that order for its first eligible submission.

Fix

Use the shared UTC chronology key after the existing due, expiry, and routing filters. Keep the original deadline text as a tie breaker and retain the Todo ID tie breaker. The pump still passes the original deadline and derives the same Turn identity from it.

Verification

  • The old selector and pump chose the later monitor in the local regression. The fix chooses the earliest eligible monitor, preserves equal-instant tie order, and forwards its exact original deadline and Turn ID. The submission boundary uses a local substitute.
  • All 20 monitor contract and timestamp-history tests passed. Five additional native/background monitor integration cases passed with local fixtures.
  • Lean 4.22.0 verifies that the ordering preserves every eligible row and that the first ready attempt has the earliest deadline among ready rows. The model starts after timestamp parsing and represents the pump's skips as an input predicate. Reversing the comparison breaks the proof.
  • All nine local premerge checks passed on the submitted commit.

PR #9540 applies to follow-up creation dates. A local merge-tree check confirms both commits combine cleanly.

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:33:35.904550Z bac12a0 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

使用 Steward 自动巡检的人会遇到这个问题。同一个 Steward 同时读到整秒和晚一微秒的监控截止时间。按原文本排序时,带小数点的较晚监控先派发。 基线在 File 和 SQLite 的四组检查中均把晚一微秒的 Monitor 派在第一个。 候选在两种 Todo 存储先提交整秒的 Monitor。等时刻按原时间文本和 ID 打破平局;第一项拒绝后按顺序提交下一项,仍只成功派发一次。 保持当前准入、租约、后台 Session 以及原 Monitor 的时间和身份。 Monitor 调度约定

改动思路 / Approach

在 due_monitors 的现有资格过滤之后,复用 chronology_key 排序,继续把原始截止时间与 Turn ID 交给原有宿主。 Core Todo 权威读取提供原行,Monitor scheduler 定义到期资格,Steward pump 负责原前台/后台隔离和宿主派发。

具体改动 / Changes

精确提交 bac12a0b8f709d657a8a3264fbd96551e9d643e5 对照目标基线 509360fb0d3e9e6e578ddf5c12db587886016b23。3 个文件,增加 128 行,删除 1 行。在一个现有排序点换键,新增同一泵的回归和 Lean 抽象模型。 monitor-timing 核对时间行为,original-monitor-scope 核对现有独立边界。

关键代码讲解

  • StewardMonitor.todos。返回实际存储的原始 deadline。 源码
  • StewardMonitor.due_monitors。在原资格过滤后按 UTC 时刻、原文本和 Todo ID 排序。 源码
  • chronology_key。使用共享 UTC 解析并以原文本打破同刻平局。 源码
  • Steward Monitor 背景泵。保留故障退避、首个成功派发和原 deadline。 源码

对主干的风险 / Risks

候选在两种 Todo 存储先提交整秒的 Monitor。等时刻按原时间文本和 ID 打破平局;第一项拒绝后按顺序提交下一项,仍只成功派发一次。 未来、已过期、其他 Agent、被阻塞及另一路由的监控均未混入。真实原生巡检的绑定拒绝及后台隔离继续通过。 候选现有契约 14 项,原生集成 15 项通过。git diff --check 与两 PR 三方试合通过。Lean 模型的边界按源码核对。 Git 三方试合与 #9542 无冲突。 基线和候选均为精确提交的本地 File/SQLite。多条时间的实验记录宿主提交,原生测试另走现有持久化和本地模拟传输。外部模型、线上宿主与远端 CI 未运行。

我的整体评价 / Verdict

APPROVE。 按 UTC 时刻尝试最早合格的 Monitor。等时刻保留原时间文本和 Todo ID 作为次序。 候选在两种 Todo 存储先提交整秒的 Monitor。等时刻按原时间文本和 ID 打破平局;第一项拒绝后按顺序提交下一项,仍只成功派发一次。

English verdict: APPROVE at bac12a0. The real File and SQLite read paths now pick the earliest eligible UTC deadline, preserve deadline text and Turn identity, and advance to the next eligible monitor after a rejected submission.

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