Skip to content

fix(codex): respect full weekly reset date in auto-resume wait calc (#1869)#1874

Merged
konard merged 2 commits into
mainfrom
issue-1869-fcb33177270b
Jun 9, 2026
Merged

fix(codex): respect full weekly reset date in auto-resume wait calc (#1869)#1874
konard merged 2 commits into
mainfrom
issue-1869-fcb33177270b

Conversation

@konard

@konard konard commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1869 — "Reached limit is incorrect for --tool codex".

The issue had two distinct defects, because hive-mind had two independent reset-time parsers that drifted out of sync. Phase 1 (PR #1873) fixed the display/comment parser. This PR is Phase 2: the auto-resume wait parser in src/solve.validation.lib.mjs.

The Phase 2 bug

When Codex reports a weekly usage limit, the reset string carries an explicit year (e.g. Jun 11, 2026, 12:27 AM). After Phase 1 the display was correct, but the auto-resume path still:

  1. Crashed with ❌ Auto-continue failed: Invalid time format: Jun 11, 2026, 12:27 AM — its local parseResetTime stripped only Month Day, (not the year), so the leftover 2026, 12:27 AM failed the time regex.
  2. Resumed far too early — even when a string parsed, calculateWaitTime used only {hour, minute} and scheduled for today/tomorrow, discarding the date. A weekly reset days out collapsed to < 24h.

Fix

  • calculateWaitTime now delegates to the robust date-aware parseResetTime from src/usage-limit.lib.mjs (the Phase‑1 parser), which honors explicit year, weekly date, time-only, and optional timezone, then returns the real resetDate − now (clamped ≥ 0). Legacy time-only logic is kept only as a fallback. This consolidates onto a single reset-time parser, removing the two-parser drift.
  • The local parseResetTime helper is hardened to strip an optional ordinal + Year, so it no longer throws.
  • All three call sites now forward the timezone: solve.auto-continue.lib.mjs, solve.auto-merge.lib.mjs, solve.mjs.

Reproduction

docs/case-studies/issue-1869/data/solution-draft-log-pr-1781024271855.txt captures a real run showing the correct display (in 1d 7h 29m (Jun 11, 12:27 AM UTC)) followed by the Invalid time format crash. experiments/issue-1869-codex-weekly-limit-wait.mjs reproduces both defects directly.

Tests

tests/test-solve-validation-reset-time.mjs adds 4 Phase‑2 regression tests (year-bearing parse no-throw, calculateWaitTime no-throw, multi-day-out wait ~3 days, explicit-future-year wait ≥ 365 days). All pass. Related suites remain green: test-usage-limit (78), test-auto-resume-limit-reset (9), test-limit-reset-config (12), test-usage-limit-comment-auto-restart-1570 (15), test-auto-restart-usage-limit-1356 (26).

Auto-resume on weekly Codex limit
Before crash Invalid time format / resume in ~16h
After resumes at the real reset (Jun 11, ~31h)

Case study

docs/case-studies/issue-1869/README.md § 9 documents Phase 2 (timeline, root cause, fix, verification). The bug is internal to hive-mind; Codex itself reports correct info, so no external issues were filed.

Fixes #1869

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #1869
@konard konard self-assigned this Jun 9, 2026
@konard

konard commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

The suite is still running. I'll wait for the background monitor (b3qyprk32) to notify me when it completes, then proceed to commit and push.


This summary was automatically extracted from the AI working session output.

@konard konard changed the title [WIP] Reached limit is incorrect for --tool codex 'Reached limit is incorrect for ' Jun 9, 2026
@konard konard marked this pull request as ready for review June 9, 2026 17:26
@konard

konard commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $5.849129

📊 Context and tokens usage:

Claude Opus 4.8: (2 sub-sessions)

  1. 116.4K / 1M (12%) input tokens, 33.2K / 128K (26%) output tokens
  2. 56.4K / 1M (6%) input tokens, 10.9K / 128K (8%) output tokens

Total: (9.0K new + 184.6K cache writes + 6.8M cache reads) input tokens, 50.4K output tokens, $5.849129 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.8 (claude-opus-4-8)

📎 Log file uploaded as Gist (3031KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Auto-restart 1/5

Detected uncommitted changes from previous run. Starting new session to review and commit or discard them.

Uncommitted files:

D  .gitkeep
 M docs/case-studies/issue-1869/README.md
 M src/solve.auto-continue.lib.mjs
 M src/solve.auto-merge.lib.mjs
 M src/solve.mjs
 M src/solve.validation.lib.mjs
 M tests/test-solve-validation-reset-time.mjs
?? .changeset/issue-1869-codex-weekly-reset-autoresume.md
?? docs/case-studies/issue-1869/data/solution-draft-log-pr-1781024271855.txt
?? experiments/issue-1869-codex-weekly-limit-wait.mjs

Auto-restart will stop after changes are committed or discarded, or after 4 more iterations. Please wait until working session will end and give your feedback.

…1869 phase 2)

The auto-resume path used a separate reset-time parser in
solve.validation.lib.mjs that (a) crashed with 'Invalid time format' on
year-bearing weekly strings like 'Jun 11, 2026, 12:27 AM' and (b) when it
did parse, discarded the date and scheduled for today/tomorrow, so
auto-resume woke up far too early on multi-day weekly Codex limits.

calculateWaitTime now delegates to the robust date-aware parseResetTime
from usage-limit.lib.mjs (honoring explicit year, weekly date, and
timezone) and returns the real time-until-reset, consolidating onto a
single parser. parseResetTime helper hardened to strip optional ordinal +
year. All three call sites forward the timezone.

Adds 4 regression tests and a reproduction experiment; documents Phase 2
in the case study with the captured solution-draft log.
@konard konard changed the title 'Reached limit is incorrect for ' fix(codex): respect full weekly reset date in auto-resume wait calc (#1869) Jun 9, 2026
@konard

konard commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

Done. All uncommitted changes are resolved and the solution is complete.

Summary

The uncommitted changes were a legitimate Phase 2 fix for issue #1869. I verified, committed, and pushed them; CI is fully green.

The bug

Issue #1869 had two independent reset-time parsers that drifted apart. PR #1873 (already merged) fixed the display parser. But the auto-resume path used a separate parser in src/solve.validation.lib.mjs that:

  1. Crashed with Invalid time format: Jun 11, 2026, 12:27 AM — it stripped only Month Day, not the trailing year on Codex weekly-limit strings.
  2. Resumed far too earlycalculateWaitTime used only {hour, minute} and scheduled for today/tomorrow, collapsing a multi-day weekly reset to < 24h.

This is confirmed by the captured real run in data/solution-draft-log-pr-1781024271855.txt (correct display in 1d 7h 29m (Jun 11, 12:27 AM UTC) followed by the crash).

The fix

  • calculateWaitTime now delegates to the robust date-aware parseResetTime from usage-limit.lib.mjs (honoring explicit year, weekly date, time-only, timezone) and returns the real resetDate − now, consolidating onto a single parser and removing the drift.
  • Local parseResetTime helper hardened to strip optional ordinal + Year,.
  • All three call sites (solve.auto-continue.lib.mjs, solve.auto-merge.lib.mjs, solve.mjs) now forward the timezone.

Verification

  • 4 new regression tests in tests/test-solve-validation-reset-time.mjs (7/7 pass) plus a reproduction experiment.
  • Related suites green: test-usage-limit (78), test-auto-resume-limit-reset (9), test-limit-reset-config (12), test-usage-limit-comment-auto-restart-1570 (15), test-auto-restart-usage-limit-1356 (26).
  • All CI checks pass (test-suites, test-execution, lint, line-limits, docs, changesets, etc.).
  • Case study updated (docs/case-studies/issue-1869/README.md § 9). The bug is internal to hive-mind — Codex reports correct info — so no external issues were filed.

Working tree is clean; changeset added for the patch release.

PR: #1874


This summary was automatically extracted from the AI working session output.

@konard

konard commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Auto-restart 1/5 Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.095927

📊 Context and tokens usage:

  • 54.3K / 1M (5%) input tokens, 10.3K / 128K (8%) output tokens

Total: (3.2K new + 41.4K cache writes + 1.1M cache reads) input tokens, 10.3K output tokens, $1.095927 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.8 (claude-opus-4-8)

📎 Log file uploaded as Gist (3928KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard konard merged commit 32d1bc3 into main Jun 9, 2026
25 checks passed
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.

Reached limit is incorrect for --tool codex

1 participant