Skip to content

fix(mcp-plans): make cleanup test deterministic on Windows - #760

Merged
dobesv merged 1 commit into
mainfrom
fix-windows-cleanup-test-flake
Jun 6, 2026
Merged

fix(mcp-plans): make cleanup test deterministic on Windows#760
dobesv merged 1 commit into
mainfrom
fix-windows-cleanup-test-flake

Conversation

@dobesv

@dobesv dobesv commented Jun 5, 2026

Copy link
Copy Markdown
Owner

The test relied on millisecond-scale sleeps finer than Windows FS timestamp resolution. Now sets stale mtime explicitly via filetime dev-dep with a 60s retention margin.

Plan: fix-windows-cleanup-test-flake

Summary by CodeRabbit

  • Bug Fixes
    • Fixed intermittent Windows CI test failures in cleanup operations. Enhanced test reliability through improved file timestamp handling and more deterministic test setup, ensuring consistent execution across different environments.

The test relied on millisecond-scale sleeps finer than Windows FS
timestamp resolution. Now sets stale mtime explicitly via filetime
dev-dep with a 60s retention margin.

Plan: fix-windows-cleanup-test-flake
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Too many files changed? Review this PR in Change Stack to see how the pieces fit before you dive in.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 258dcc04-3a39-4100-a64b-fb8058eb6df6

📥 Commits

Reviewing files that changed from the base of the PR and between 501d788 and fcecf19.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .changeset/fix-windows-cleanup-test-flake.md
  • crates/harnx-mcp-plans/Cargo.toml
  • crates/harnx-mcp-plans/src/server/tests.rs

📝 Walkthrough

Walkthrough

The PR fixes a flaky cleanup test on Windows by replacing timing-dependent setup with explicit file modification time control. The test now uses the filetime crate to set stale plan mtimes to one hour in the past and fresh plan mtimes to the present, then runs cleanup with a 60-second retention interval to verify correct deletion behavior without relying on sleep duration or OS-specific timestamp precision.

Changes

Windows cleanup test flake fix

Layer / File(s) Summary
Deterministic file mtime handling for cleanup test
crates/harnx-mcp-plans/Cargo.toml, crates/harnx-mcp-plans/src/server/tests.rs, .changeset/fix-windows-cleanup-test-flake.md
The filetime crate is added as a dev dependency. The cleanup_deletes_stale_plan_but_keeps_fresh_plan test replaces tokio::time::sleep with explicit filetime::set_file_mtime calls to set a stale plan's mtime to one hour past and a fresh plan's mtime to now, using a 60-second retention interval for deterministic behavior across Windows and Unix platforms.

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • dobesv/harnx#656: Introduces inactivity-based cleanup logic with stale-vs-fresh plan tests, directly addressed by this PR's deterministic timestamp control fix.

Poem

🐰 Timestamps on Windows were playing so wild,
Sleep-based tests left us unreconciled,
Now filetime takes the reins so tight,
Making cleanups deterministic and right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main objective: fixing a flaky cleanup test on Windows by making it deterministic, as confirmed by all three file changes working toward this goal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-windows-cleanup-test-flake

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dobesv
dobesv merged commit 9f33792 into main Jun 6, 2026
8 checks passed
@dobesv
dobesv deleted the fix-windows-cleanup-test-flake branch June 6, 2026 00:18
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