Skip to content

fix(steward): preserve microseconds in Core monitor recovery cooldown - #9544

Open
hhyykk wants to merge 1 commit into
mainfrom
codex/steward-core-monitor-cooldown-precision
Open

hhyykk wants to merge 1 commit into
mainfrom
codex/steward-core-monitor-cooldown-precision

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

Core's chained monitor recovery check parsed retained completion times into whole milliseconds. A completion one microsecond after a whole second could be treated as if it happened on that second, shortening its 300-second cooldown.

Fix

Compare the retained completion and wire clock sample in integer UTC microseconds. Reuse the existing calendar-checked timestamp parser. Convert finite epoch-second numbers from their exact binary value so the conversion cannot round an observation up. The wire clock remains in seconds. Recovery still requires the original receipt, journal, identity and ownership checks.

Verification

  • The previous code admits the synthetic one-microsecond-early case. The regression holds that case, allows later valid samples, and preserves eligibility at an exact fractional cutoff expressed with a UTC offset. Missing or nonfinite clock observations and prior journal/identity refusals still fail.
  • All 32 Core timestamp and Steward tests and 2 local Python recovery integration tests passed. A deterministic differential check matched Python integer-ratio results for 4,095 finite synthetic clock samples.
  • Lean 4.22.0 proves that flooring a rational clock sample preserves comparison with an integer deadline, that the cutoff is inclusive, and that elapsed time cannot replace the required evidence. The model begins after parsing and decoding. Making the modeled cooldown a microsecond shorter breaks the regression theorem.
  • Core type checking and all seven local premerge checks passed on the submitted commit.

PR #9543 covers the Python retry callers. This patch applies the matching timing rule to the Core admission boundary.

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-27T19:12:25.121467Z 6181d8c 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 监控恢复的用户需要这个边界可预测。让 Core 的链式 Monitor 恢复等待满 300 秒,并保留主机观察和原 journal、身份、租约前置条件。 在目标基线运行同一 Core 准入用例,早一微秒的样本错误放行,原应抛出的拒绝没有发生。 候选在同一精确输入上拒绝,过线样本与带 +08:00 的等值小数边界通过,原调用仍返回 observation_only。 本地覆盖了实际 Core 准入、原生恢复集成与算术边界。Lean 模型仅核对源码,本次未独立重跑。远端 CI 依本队列设置未查询。 评审依据

改动思路 / Approach

复用 Todo 的 UTC 微秒 codec 读取留存完成时间。按已收到的 binary64 位表示向下取整观测时钟,两值以 BigInt 差计算冷却。整数时钟走直接乘法。 Steward Core 用留存 carrier、collector、journal 与当前绑定判断准入。时间 codec 保持解析和 UTC 换算责任。

具体改动 / Changes

精确提交 6181d8c7a64ad430d1ecd58e413171c442382cab 对照 509360fb0d3e9e6e578ddf5c12db587886016b23。5 个文件,增加 112 行,删除 7 行。生产变更位于现有 Core 准入与时间 codec 两处。其余为两个测试文件和 Lean 模型。 monitor-cooldown 对照主路径,original-evidence 核对控制边界。

关键代码讲解

  • admitMonitorRestartRecovery。对已失败的原 Monitor 进行观察恢复准入。上次观察结束于整秒后一微秒时,Core 会借毫秒级 Date.parse 抹掉该微秒,在 300 秒尚未满时错误重试。 候选在同一精确输入上拒绝,过线样本与带 +08:00 的等值小数边界通过,原调用仍返回 observation_only。 源码
  • floorEpochSecondsMicros。解码实际收到的 binary64 观测秒数。有限值精确取 floor,整数与正负次正规数由独立样本核对。 源码
  • parseTodoTimestampMicros。解析留存 ISO 时间并归一 UTC。复用已有的日历、时区和微秒检查,保留留存偏移时间在同一时刻的语义。 源码
  • admitStewardManagedTurn。选择原管理型 Turn 的准入分支。合格链式恢复依旧是观测,其他来源沿原检查。 源码

对主干的风险 / Risks

无效或非有限时钟、身份或作用域拒绝的链式重试,以及既有 journal 和效果门仍按原条件拒绝。 32 个 Core 测试、3 个原生恢复测试和 Core 类型检查通过。1,030 个独立有限 binary64 样本逐一等于 Python 整数分数的 floor。与 #9543 的三方试合无冲突。 本地覆盖了实际 Core 准入、原生恢复集成与算术边界。Lean 模型仅核对源码,本次未独立重跑。远端 CI 依本队列设置未查询。

我的整体评价 / Verdict

APPROVE。 链式恢复可以按原流程推进。 冷却、资格与作用域的本地对照通过。修复点位于原 Core 准入门,可以独立落地。它与 Python 一侧共享同一时间边界,两处都保留原恢复身份和证据条件。

English verdict: APPROVE at 6181d8c. The exact Core admission path now rejects a retry one microsecond early, accepts the inclusive cutoff and preserves existing recovery evidence gates.

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