Skip to content

测试:push-limits CLI 子进程与 Worker 共用固定时钟 - #280

Merged
moshui-claude-code-macmini[bot] merged 1 commit into
mainfrom
claude/fix-cli-limits-clock
Oct 12, 2026
Merged

moshui-claude-code-macmini[bot] merged 1 commit into
mainfrom
claude/fix-cli-limits-clock

Conversation

@moshui-claude-code-macmini

Copy link
Copy Markdown
Contributor

问题

cloudflare/native-worker/test/device-enrollment-cli.test.ts 的「activated device publishes two official windows; other-device failures cannot mask them」从约 2026-10-11 起在 main 上稳定失败(最后绿:2026-10-07)。

根因

Worker 侧用 AIUSAGE_NOW='2026-10-04T00:00:00Z' 固定时钟,但 publishLimits() 调用的 Python push-limits 子进程走 LimitsRuntime 默认 now_provider(limits_runtime._default_now,真实时钟)。_is_current_official_window 要求 reset_at > now,真实时间越过 fixture reset_at=2026-10-11 后两个窗口被判 provider_unavailable,CLI 返回 success=false / 退出码 1,test:160 expect(healthy).toBe(false) 失败。Python 不读 AIUSAGE_NOW。

修复

只改测试:抽出共享常量 fixedNow,Worker 绑定与 CLI 子进程共用;CLI 启动代码在导入 CLI 前把 _default_now 固定为 fixedNow,复用已有 now_provider 注入点。不改产品代码、断言、预期值。

证据

  • 修复前红:本地复现 test:160 失败(1 failed | 4 passed)
  • 修复后绿:该文件 5 passed
  • 变异:注入时钟改为 2026-10-11T00:00:01Z(越过 reset_at)→ 重新在 :160 变红;已备份还原
  • scripts/verify.sh:Python 795 tests OK(skipped=9);Worker 45 files / 378 tests passed
  • 证据等级 3(本地测试通过),等级 4 待本 PR CI

解除对 #279 的阻塞。

🤖 Generated with Claude Code

device-enrollment-cli 测试里 Worker 用 AIUSAGE_NOW 固定时钟,但 push-limits
的 Python 子进程走 LimitsRuntime 默认 now_provider(真实时钟)。真实时间越过
fixture reset_at(2026-10-11)后两个窗口被判 provider_unavailable,测试从
10-11 起在 main 稳定失败。

测试启动代码在导入 CLI 前把 limits_runtime._default_now 固定为同一个
fixedNow,复用已有 now_provider 注入点;不改产品代码、断言和预期值。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moshui-claude-code-macmini
moshui-claude-code-macmini Bot merged commit a059226 into main Oct 12, 2026
5 checks passed
@moshui-claude-code-macmini
moshui-claude-code-macmini Bot deleted the claude/fix-cli-limits-clock branch October 12, 2026 06:48
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.

0 participants