Skip to content

fix(periodic-report): preserve the exact cooldown cutoff - #9530

Open
hhyykk wants to merge 1 commit into
mainfrom
codex/report-cooldown-cutoff-precision
Open

hhyykk wants to merge 1 commit into
mainfrom
codex/report-cooldown-cutoff-precision

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

periodic-report evaluate-trigger used a floating-point Unix timestamp to advertise cooldown.next_eligible_at. At far-future but valid timestamps, this could return a cutoff one microsecond before or after the actual eligibility boundary. At the last representable UTC instant, rounding could also turn a valid cutoff into a year-10000 error.

The evaluator now compares exact datetime durations and adds the same duration to compute the advertised cutoff. The existing response shape and bypass rules remain in use.

Author Declaration

  • Written by model_agent, OpenAI Codex (GPT-6 family).
  • Implemented against the cooldown contract in docs/reference/protocols/periodic-report-v0.md, reproduced on main at 509360fb0.
Criterion Disposition Evidence
Keep the trigger blocked immediately before the exact cutoff implemented Three CLI cases report the exact cutoff with eligible=false, including the maximum representable UTC cutoff.
Permit the trigger exactly at the cutoff implemented Three matching CLI cases return eligible=true.
Preserve authorized bypass implemented An isolated comparison at the maximum UTC timestamp returns the same eligible manual-bypass decision before and after the patch.

Validation

Check Result Evidence
Baseline and fixed CLI passed Three earlier-than-cutoff cases fail before the change and pass after it. Three exact-cutoff controls pass on both revisions.
Trigger tests 23 passed Includes the six boundary cases.
Periodic-report regression suite 519 passed PYTHONPATH="$PWD" python3 -m pytest -q tests/capabilities/test_periodic_report*.py
Lean 4.22.0 passed lean -DwarningAsError=true regression/PeriodicReportCooldown.lean. The model proves equivalence between the duration check and the advertised cutoff. Using a non-strict cooldown comparison makes the check fail.
Local premerge 9 checks passed python3 -m loopx.entrypoint canary premerge --from-git-diff --git-diff-base origin/main --tier quick
Ruff passed Both changed Python files.

The Lean model assumes the correct cutoff is representable. The CLI tests exercise real datetime parsing and the decision with local synthetic inputs.

Scope And Continuation

The change covers the trigger evaluator's microsecond arithmetic and its cutoff response. Test execution performed no external report delivery.

Frontend / Visual Evidence

  • UI impact is none.

Type Of Change

  • Bug fix
  • Documentation update
  • Test update

LoopX Area

  • Capability or extension

Shared-authority RFC fixture impact

N/A.

Boundary Checklist

  • The diff and description use public-safe synthetic data.
  • The change is scoped to the reproduced cooldown cutoff issue.
  • No paired RFC changed.
  • UI impact is none.
  • The commit includes a DCO Signed-off-by trailer.

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-27T16:47:21.035729Z 6e7c5ad 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

使用周期报告触发器的操作者依赖 next_eligible_at 决定何时重新检查。原 CLI 把投递时间转成浮点时间戳再加间隔,远期微秒可能漂移,最后一个可表示时刻还可能变成错误。比较同一 UTC 截止点前一微秒、恰好截止点,以及同一时钟下的已授权手动请求。候选用精确日期差判断 cooldown,并用同一间隔返回精确的下次可执行时间。范围是已有触发器精确时间判断和相同 JSON 结果,报告准备与外部发布仍由原路径负责。

改动思路 / Approach

沿已有解析和触发候选筛选,在同一 trigger evaluator 中用 datetime 和 timedelta。授权绕过、报告类型和结果身份仍用既有规则。只替换已解析时间的精确判断和显示,沿用已有 cooldown 结果。 从仓库外用明确的临时 registry 与 runtime,调用真实 periodic-report evaluate-trigger。 这使比较覆盖真实 CLI 输出、退出码和当前任务依赖的结构化结果。

具体改动 / Changes

精确提交 6e7c5ad21520fa1ef57043d4abc08158f9c9a9ed,对照 509360fb0d3e9e6e578ddf5c12db587886016b23。本次有 4 个改动文件,增加 103 行、删除 18 行。

  • docs/reference/protocols/periodic-report-v0.md。说明 cooldown cutoff 必须保留投递时间的微秒。
  • loopx/capabilities/periodic_report/triggers.py。使用一个精确间隔确定 cooldown 与下一次触发时间。
  • regression/PeriodicReportCooldown.lean。以整数微秒推导边界的一致性。
  • tests/capabilities/test_periodic_report_triggers.py。在现有入口覆盖双向舍入偏差与最大可表示时间。

关键代码讲解

  • build_periodic_report_trigger_decision。接收并规范化报告触发事实后维持现有选择顺序。 源码
  • minimum_interval。以 timedelta 做精确时间比较。 源码
  • next_eligible_at。在 cooldown 且无授权绕过时返回可表示的精确 UTC 截止点。 源码

exact-cutoff 和 authorized-bypass 已用隔离的真实 CLI 复核。 保留原报告、原 cooldown 字段、手动绕过权限和业务词汇。 基线契约

对主干的风险 / Risks

同一组实际 CLI 共 12 个基线/候选案例。2500 年两种微秒在基线偏早或偏晚,9999 年最后一个可表示截止点的基线退出 1。候选三个截止前案例都返回正确微秒,四个恰好截止点与四个授权绕过均保持基线结果。519 项周期报告 pytest、9 项 quick premerge、Ruff 和 git diff --check 通过。Lean 模型的可表示截止点假设与实现范围一致,未独立运行 Lean。

我的整体评价 / Verdict

APPROVE。 候选修复了重复检查的时间提示,所有选取的授权绕过继续有效。最晚可表示时间之外的截止点、线上报告发布和托管 CI 不在已验证范围。 保留同一精确时间模型并沿现有触发器继续。

English verdict: APPROVE at 6e7c5ad. Paired native CLI checks confirm exact microseconds, an eligible exact cutoff, and unchanged authorized bypass.

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