Skip to content

test: stop rewinding monotonic instants in tmux/git tests - #354

Merged
Yeachan-Heo merged 1 commit into
devfrom
test/353-monotonic-rewind
Sep 3, 2026
Merged

Yeachan-Heo merged 1 commit into
devfrom
test/353-monotonic-rewind

Conversation

@Yeachan-Heo

Copy link
Copy Markdown
Owner

Fixes #353.

What

Four tests rewound a monotonic clock (Instant::now() - Duration::from_secs(3600) in the tmux stale tests, probe_at - Duration::from_secs(1) in the git quarantine test). They now advance the observation instant instead of rewinding "now", and the git probe uses an explicit checked_sub with a stated precondition.

Why

Instant - Duration is checked_sub(..).expect("overflow when subtracting duration from instant"), and overflow is platform-dependent:

  • Linux keeps Instant as a signed Timespec, so the rewind is representable — verified on a host with 3_820_556s uptime, rewinding by uptime + 3600s does not panic.
  • Windows keeps Instant as an unsigned QPC tick count, so the subtraction panics whenever the rewind exceeds system uptime.

Result: a Windows contributor running the full cargo test --bin clawhip on a machine booted less than an hour ago panics in stale_minutes_zero_disables_stale_detection, stale_minutes_nonzero_still_emits, and pane_dead_suppresses_stale_alert for reasons unrelated to what those tests assert. Linux CI never caught it, and the Windows CI job only runs issue_317 and config_backup_cleanup.

should_emit_stale only compares last_change against the supplied instant, so pinning last_change and passing last_change + 3600s is semantically identical while being uptime-independent. It also removes an incidental second Instant::now() call per test.

Verification

  • cargo test --bin clawhip → 1101 passed, 0 failed
  • cargo fmt --check → clean
  • cargo clippy --all-targets -- -D warnings → clean; clippy::unchecked_duration_subtraction now reports 0 sites (was 4)
  • Test-only change; no production code touched.

Base dev@7bad9d24df18984a2e68612862246ce7263eae19.

—
[repo owner's gaebal-gajae (clawdbot) 🦞]

`Instant - Duration` panics where `Instant` is an unsigned tick counter
(Windows QPC) and the rewind exceeds system uptime. The tmux stale tests
rewound `Instant::now()` by an hour and the git quarantine test rewound a
probe instant by a second, so a full `cargo test --bin clawhip` on a
freshly booted Windows host panicked in unrelated assertions. Linux stores
`Instant` as a signed `Timespec` and does not panic, which is why CI never
caught it (the Windows job only runs `issue_317` and
`config_backup_cleanup`).

Advance the observation instant instead: pin `last_change` and pass
`last_change + Duration::from_secs(3600)` as the current instant to
`should_emit_stale`. This is semantically identical -- the function only
compares the two instants -- and also removes the incidental second
`Instant::now()` call. The git probe now uses an explicit `checked_sub`
with a stated precondition.

Clears all four `clippy::unchecked_duration_subtraction` sites.

Fixes #353
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Yeachan-Heo
Yeachan-Heo merged commit bf8f475 into dev Sep 3, 2026
13 checks passed
@Yeachan-Heo
Yeachan-Heo deleted the test/353-monotonic-rewind branch September 3, 2026 10:13
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.

1 participant