You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Home: fix the flaky picture-cache test that broke main's CI (wait for the file change time to tick) - #18334
Fixes#18333. Main's CI fails solidcraft-ui-egui::home::tests::library_cache_identity_tracks_replacements_with_preserved_mtime (added by #2717). This PR changes only that test.
Root cause: the Home picture cache key (cache_path) hashes the path, length, mtime and, on Unix, the inode change time (ctime, ctime_nsec). The test rewrites the file with content of the same length (old, then new) and restores the old mtime, so only ctime can change the key. The kernel stamps ctime from its coarse clock, which advances once per jiffy (4 ms at HZ=250, 10 ms at HZ=100). Kernels with multigrain timestamps (6.13+) can stamp finer, which is why the test passes on some machines. The test slept only 2 ms between the writes, so on the CI runner both writes often fell in the same tick and got the same ctime and the same cache path.
The production key is not changed. A same-length, in-place rewrite with a restored mtime inside one clock tick leaves every inode field the same, so no key built from metadata can tell the two files apart. Only hashing the file's content could, and that is a different design. The test assumed a ctime resolution the filesystem does not promise.
Fix: the test now repeats the replacement, with a 1 ms sleep each time and a 2 s bound, until ctime moves. It then asserts that ctime moved and that the mtime is still the restored value, and keeps the original assert_ne! on the cache path. The original assertion is not weakened. The two new checks make sure the test exercises the case it names: same length, preserved mtime, changed ctime.
The fixed test, run alone 50 times in a row: 50 passed, 0 failed.
home::tests (the whole module): 34 passed, 1 ignored.
The local machine runs a newer kernel than the CI runner, so I could not reproduce the CI failure here. The fix does not depend on the timestamp granularity: the loop runs until ctime has moved, whatever the tick length.
Integration status
Branched from origin/main at 1ad2057. Test-only change, so this is case 5 of our gate rules: fmt, clippy and the crate's tests.
…e time to tick
library_cache_identity_tracks_replacements_with_preserved_mtime rewrote a
file with same-length content and its old mtime after a 2 ms sleep, so the
cache key could only change through the inode change time. ctime advances
at the kernel's coarse clock (one jiffy, 4 ms or more), so on CI both
writes often landed in the same tick and the key stayed equal.
The test now repeats the replacement (bounded at 2 s) until ctime moves,
asserts that it moved and that the mtime was preserved, then asserts the
cache path changed as before.
Fixestangency-labs#18333
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
No actionable comments were generated in the recent review.
Walkthrough
The Unix cache-identity test retries file replacement until the file’s change time advances or two seconds elapse. It verifies that the modification time remains unchanged before comparing cache paths.
Changes: Cache identity test
Layer / File(s)
Summary
Replacement retry and assertions crates/ui-egui/src/home.rs
The test retries file replacement every millisecond and restores the original modification time. It asserts that the change time advanced and the modification time stayed unchanged before checking the cache path.
This change only makes a flaky Unix test more reliable by waiting for the file change time to advance. It does not affect product behavior and is safe to merge.
Architecture risk: Low · up to e292b
The change affects 1 system.
Changed systems:crates
Architecture concerns
No architecture-level concerns identified.
Review details
Systems and components
observed — crates (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
observed — Modified behavior in crates/ui-egui/src/home.rs: The Unix replacement test replaces a fixed sleep and single rewrite with retries every millisecond, restoring the original modification time each time, until the file’s change time differs or two seconds elapse. It asserts that the change time advanced and the modification time is still unchanged before the existing cache-path comparison.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title names the main change: a fix to the flaky Home picture-cache test, which now waits for the file change time to tick. It is specific and matches the changeset, which modifies only that test i…
Description check
The description follows the template. It has a Change section that explains the problem, the root cause, and the fix, and it links issue #18333. It includes the required 'Changes a default: no' line a…
Linked Issues check
Issue #18333 asks for a fix to the test home::tests::library_cache_identity_tracks_replacements_with_preserved_mtime. The issue suggests either waiting until metadata().ctime() changes (bounded, e…
Out of Scope Changes check
The whole-PR diff against the merge base 1ad2057 changes only the test body in crates/ui-egui/src/home.rs. It adds a ctime-polling loop, a ctime helper closure, and two assertions. All edits sit i…
Existing Defaults Unchanged
The check fails only if the pull request changes a UX default: a default setting or preference, a command's usual behaviour, the default UI layout or behaviour, or shortcuts. The reviewed range change…
Full details: Title check
Explanation
The title names the main change: a fix to the flaky Home picture-cache test, which now waits for the file change time to tick. It is specific and matches the changeset, which modifies only that test in crates/ui-egui/src/home.rs. It is slightly long at 99 characters, but it is still clear.
Full details: Description check
Explanation
The description follows the template. It has a Change section that explains the problem, the root cause, and the fix, and it links issue #18333. It includes the required 'Changes a default: no' line and a Validation section with commands and results. The Screenshots section is missing, but this is a test-only change with no observable UI behaviour, so the template allows omitting it. The Integration status section is present. The Test change line is not required because the PR adds or changes assertions in a test and does not touch a kernel test, which the template applies only to solidcore/ and crates/smlib/.
Full details: Linked Issues check
Explanation
Issue #18333 asks for a fix to the test home::tests::library_cache_identity_tracks_replacements_with_preserved_mtime. The issue suggests either waiting until metadata().ctime() changes (bounded, e.g. 1 s) or changing the file length. The diff in crates/ui-egui/src/home.rs takes the first option. After the initial old write, the test records ctime. It then loops: sleep 1 ms, write new, restore the original mtime, and check ctime. The loop stops when ctime differs or after a 2 s deadline. It then asserts that ctime changed, that mtime equals the restored value, and that cache_path differs (the original assert_ne!). The test still uses same-length content and a preserved mtime, so it keeps the case the issue names. The issue lists the ctime cause as unconfirmed. The PR does not confirm it either, but the requirement is to make the test robust, and the change does that. Test-only change; no coding requirement is unmet. Remaining uncertainty: the test was not run in CI here, so the fix is validated only by the author's reported local runs.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base 1ad2057 changes only the test body in crates/ui-egui/src/home.rs. It adds a ctime-polling loop, a ctime helper closure, and two assertions. All edits sit inside library_cache_identity_tracks_replacements_with_preserved_mtime. The production cache_path key is not changed. No unrelated files or production code changed, so no out-of-scope change was found.
Full details: Existing Defaults Unchanged
Explanation
The check fails only if the pull request changes a UX default: a default setting or preference, a command's usual behaviour, the default UI layout or behaviour, or shortcuts. The reviewed range changes one file, crates/ui-egui/src/home.rs (status M). The only hunk is inside the test library_cache_identity_tracks_replacements_with_preserved_mtime, which is in the mod tests block. It replaces a fixed 2 ms sleep with a bounded loop (1 ms sleeps, 2 s deadline) that waits for ctime to change. It adds two assertions. The production cache_path code and all runtime UI code are untouched. No default value, preference, layout, shortcut, or command behaviour changes. The description's Changes a default: no agrees with the diff. The check passes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 1ad2057 and e292ba5.
Files selected for processing: 1
crates/ui-egui/src/home.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
bherbruck
added
approved-for-ci
Reviewed: run the full PR CI (build, tests, goldens, Clippy)
ready to merge
reviewed, every ask addressed; merge once CI is green
owner-approved
Owner reviewed a sensitive-path change (kernel, CI, build scripts, deps); only the owner adds this
labels
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approved-for-ciReviewed: run the full PR CI (build, tests, goldens, Clippy)area:uidesktop/web front end, dialogs, viewportowner-approvedOwner reviewed a sensitive-path change (kernel, CI, build scripts, deps); only the owner adds thisready to mergereviewed, every ask addressed; merge once CI is green
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Fixes #18333. Main's CI fails
solidcraft-ui-egui::home::tests::library_cache_identity_tracks_replacements_with_preserved_mtime(added by #2717). This PR changes only that test.Root cause: the Home picture cache key (
cache_path) hashes the path, length, mtime and, on Unix, the inode change time (ctime,ctime_nsec). The test rewrites the file with content of the same length (old, thennew) and restores the old mtime, so only ctime can change the key. The kernel stamps ctime from its coarse clock, which advances once per jiffy (4 ms at HZ=250, 10 ms at HZ=100). Kernels with multigrain timestamps (6.13+) can stamp finer, which is why the test passes on some machines. The test slept only 2 ms between the writes, so on the CI runner both writes often fell in the same tick and got the same ctime and the same cache path.The production key is not changed. A same-length, in-place rewrite with a restored mtime inside one clock tick leaves every inode field the same, so no key built from metadata can tell the two files apart. Only hashing the file's content could, and that is a different design. The test assumed a ctime resolution the filesystem does not promise.
Fix: the test now repeats the replacement, with a 1 ms sleep each time and a 2 s bound, until ctime moves. It then asserts that ctime moved and that the mtime is still the restored value, and keeps the original
assert_ne!on the cache path. The original assertion is not weakened. The two new checks make sure the test exercises the case it names: same length, preserved mtime, changed ctime.Changes a default: no
Validation
cargo fmt -p solidcraft-ui-egui --check: clean.cargo clippy -p solidcraft-ui-egui --all-targets -- -D warnings: clean.home::tests(the whole module): 34 passed, 1 ignored.The local machine runs a newer kernel than the CI runner, so I could not reproduce the CI failure here. The fix does not depend on the timestamp granularity: the loop runs until ctime has moved, whatever the tick length.
Integration status
Branched from origin/main at 1ad2057. Test-only change, so this is case 5 of our gate rules: fmt, clippy and the crate's tests.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
Summary by CodeRabbit