Skip to content

fix(steward): use scheduler deadline parsing for idle backoff - #9542

Open
hhyykk wants to merge 1 commit into
mainfrom
codex/steward-idle-monitor-backoff-utc
Open

hhyykk wants to merge 1 commit into
mainfrom
codex/steward-idle-monitor-backoff-utc

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

The scheduler accepts future monitor deadlines with or without an explicit UTC offset. Steward's idle paths parsed those deadlines separately. Mixing offset-free and offset-bearing timestamps could send the portfolio pump into failure backoff. An offset-free deadline by itself could do the same to the managed Session pump.

Fix

Use the scheduler deadline parser in both idle paths. Compare and subtract UTC instants. Preserve the route filters, the existing error path for invalid deadlines, the persisted deadline text, and the 60-second idle wait cap.

Verification

  • The previous code reported a TypeError on both idle paths for all three new cases. The fixed pumps use the earliest eligible future deadline and set the expected wait at 0.25, 60, and 90 seconds from the test clock. The latter case caps the wait at 60 seconds. No dispatch occurs in these cases.
  • All 22 monitor contract and timestamp-history tests passed. Five additional native and background monitor integration cases passed with local fixtures.
  • Lean 4.22.0 verifies the minimum over parsed UTC deadlines, the preservation of the portfolio hint for overdue input, and agreement of the two wait formulas for future deadlines under the 60-second cap. Removing the cap breaks the proof. The Python regression exercises the scheduler parser and both idle pump entry paths.
  • All nine local premerge checks passed on the submitted commit.

PR #9541 handles dispatch order for due monitors. A local merge-tree check confirms the patches combine cleanly.

@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:46:38.425450Z 68a519c 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 或 managed Session 留下无时区偏移的未来 deadline。调度器已接受该格式,空闲泵随后独立解析并对有/无时区的对象比较或相减。 基线在 File 和 SQLite 的六组未来监控对照中,两条空闲路径都进入 TypeError 退避。 候选两条路径分别记录 0.25、60、60 秒等待,未提前派发。模拟时钟越过截止时间后,两条路径各提交一个 Monitor,原 deadline 字符串和 Turn ID 完整保留。 保持当前准入、租约、后台 Session 以及原 Monitor 的时间和身份。 Monitor 调度约定

改动思路 / Approach

两个空闲路径共用 monitor_todo_next_due_at。对最早合法时间计算单调时钟提示,保留原无效值故障路径。 Core Todo 权威读取提供原行,Monitor scheduler 定义到期资格,Steward pump 负责原前台/后台隔离和宿主派发。

具体改动 / Changes

精确提交 68a519c1d34e78ddd2821a1f0aad8bda16b06159 对照目标基线 509360fb0d3e9e6e578ddf5c12db587886016b23。3 个文件,增加 153 行,删除 7 行。合并已有时间解析调用,分别接入 portfolio 和 managed Session,增加泵级回归和 Lean 抽象模型。 monitor-timing 核对时间行为,original-monitor-scope 核对现有独立边界。

关键代码讲解

  • monitor_todo_next_due_at。沿已被 due 检查使用的 scheduler parser。 源码
  • _monitor_deadline。不可读时间仍进入原故障路径。 源码
  • _schedule_soonest_monitor_backoff。在原范围中找最早 UTC 时刻并将等待限制为 60 秒。 源码
  • _process_managed_session。同一 parser 计算 idle 时间,到期后带原身份提交。 源码

对主干的风险 / Risks

另一路由的较早时间不污染这个等待。原生后台隔离、注册后仍须显式启用和绑定变更拒绝的局部路径通过。 候选现有契约 16 项,原生集成 8 项通过。git diff --check 通过。Lean 模型的边界按源码核对。 Git 三方试合与 #9541 无冲突。 基线和候选均为精确提交的本地 File/SQLite。多条时间的实验记录宿主提交,原生测试另走现有持久化和本地模拟传输。外部模型、线上宿主与远端 CI 未运行。

我的整体评价 / Verdict

APPROVE。 当前提交可以按现有流程推进。两个空闲入口共用调度器的截止时间解释,也保留了原始提交标识和现有资格判断。后续若更改截止时间格式,应在这两个入口一起验证。

English verdict: APPROVE at 68a519c. Both idle routes now use scheduler deadline parsing. File and SQLite preserve the 60-second cap, avoid early dispatch, and submit the original deadline and Turn ID when due.

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