Skip to content

fix: refresh once-a-day marker files on Windows - #4047

Merged
pszymkowiak merged 3 commits into
rtk-ai:developfrom
yuefdev:fix/windows-marker-mtime
Nov 20, 2026
Merged

pszymkowiak merged 3 commits into
rtk-ai:developfrom
yuefdev:fix/windows-marker-mtime

Conversation

@yuefdev

@yuefdev yuefdev commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The hook reminder and telemetry markers were refreshed with fs::write(path, b""). Rewriting an existing empty file with empty content does not refresh its modification time on Windows, so an expired marker could allow the warning or ping on every command.

utils::touch_file creates the marker if needed and explicitly updates its modification time with File::set_modified. Both marker paths use it.

The current develop branch is merged. The conflict in src/core/utils.rs keeps both the marker regression and the upstream terminal-sanitisation regression.

Validation

  • cargo fmt --all -- --check
  • cargo fmt --manifest-path proxy/Cargo.toml --all -- --check
  • cargo clippy --all-targets
  • All test targets selected by cargo test --all

All checks passed on Ubuntu with Rust 1.99.1, Git 2.51.0 and RUST_TEST_THREADS=1. The main library reported 4,323 passed and eight ignored tests. Integration, workspace and documentation tests also passed. A timed-out run was resumed by running the remaining targets against the same staged tree.

The Linux checkout's tree matched the submitted tree, 2e9663d71abca991dcf7dddd7f733599bcae9bff. An engine example binary initially failed in the Linux loader before its tests started; rebuilding that package made its full test run pass.

test_touch_file_refreshes_existing_empty_marker creates a marker, backdates it by two days, touches it and checks its age and empty contents.

AI-assisted implementation and validation using gpt-6.1-sol.

The hook reminder and telemetry markers were refreshed with
`fs::write(path, b"")`. Rewriting an existing empty file with empty
content does not update its modification time on Windows, so once a
marker was older than 24 hours the rate limit never applied again: the
"No hook installed" reminder was printed on every command.

Add `utils::touch_file`, which sets the modification time explicitly,
and use it for both markers.
@CLAassistant

CLAassistant commented Sep 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes a Windows bug where once-a-day marker files (hook reminder and telemetry ping) never had their modification time updated because fs::write(path, b"") doesn't refresh mtime on an already-empty file on Windows. Introduces a new utils::touch_file helper that creates the file if needed and explicitly sets its mtime via File::set_modified, and switches both marker call sites to use it.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Thanks for this one, the diagnosis is spot on. I reproduced it natively on Windows (NTFS): rewriting an already-empty marker with fs::write(path, b"") leaves its mtime two days old, while Linux refreshes it, which is why CI never caught it. Your touch_file refreshes it and keeps the file empty. A temporary test that backdates the hook-warning marker and calls the real check_and_warn() fails on develop and passes with your change.

I merged develop into your branch. It was 480 commits behind, and the original CI run from October never started and can't be re-run anymore, so this gives it a fresh run. The PR's own diff is unchanged.

One more marker landed after you opened this: the Pro hint in rtk gain (src/analytics/gain.rs) uses the same fs::write(m, b"") pattern. No need to touch it here, I'll switch it to touch_file in a small follow-up once this is in.

@pszymkowiak pszymkowiak 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.

CI is green across the board on the refreshed branch, including both Windows jobs. Thanks again @yuefdev.

@pszymkowiak
pszymkowiak merged commit 74dd8fc into rtk-ai:develop Nov 20, 2026
16 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working platform-specific windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants