Skip to content

Home: fix the flaky picture-cache test that broke main's CI (wait for the file change time to tick) - #18334

Merged
bherbruck merged 1 commit into
tangency-labs:mainfrom
brett19:fix/18333-ctime-tick-test
Nov 17, 2026
Merged

bherbruck merged 1 commit into
tangency-labs:mainfrom
brett19:fix/18333-ctime-tick-test

Conversation

@brett19

@brett19 brett19 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

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, 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.

Changes a default: no

Validation

  • cargo fmt -p solidcraft-ui-egui --check: clean.
  • cargo clippy -p solidcraft-ui-egui --all-targets -- -D warnings: clean.
  • 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.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU

Summary by CodeRabbit

  • Tests
    • Improved cache-identity test reliability on systems with coarse change-time resolution.

…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.

Fixes tangency-labs#18333

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: Minimal · up to e292b

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: Passed 5

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed 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 Passed 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
Recent review info

Run configuration

Commits

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.

@github-actions github-actions Bot added the area:ui desktop/web front end, dialogs, viewport label Nov 17, 2026
@brett19
brett19 marked this pull request as ready for review November 17, 2026 04:27
@bherbruck 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
@bherbruck
bherbruck enabled auto-merge November 17, 2026 04:39
@bherbruck
bherbruck added this pull request to the merge queue Nov 17, 2026
@bherbruck
bherbruck removed this pull request from the merge queue due to a manual request Nov 17, 2026
@bherbruck
bherbruck added this pull request to the merge queue Nov 17, 2026
Merged via the queue into tangency-labs:main with commit 7ea1d3d Nov 17, 2026
151 of 163 checks passed
brett19 added a commit to brett19/solidcraft that referenced this pull request Nov 17, 2026
@brett19
brett19 deleted the fix/18333-ctime-tick-test branch November 24, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) area:ui desktop/web front end, dialogs, viewport owner-approved Owner reviewed a sensitive-path change (kernel, CI, build scripts, deps); only the owner adds this ready to merge reviewed, every ask addressed; merge once CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Main CI broken: home::tests::library_cache_identity_tracks_replacements_with_preserved_mtime fails (#2717)

2 participants