Fix storage cache stamps - #2505
Conversation
✅ Bunny Review CompletedTip Review posted. The specimen has left the observation table.
|
🐰 Bunny ReviewBunny Merge Signal: Ready With NotesWarning READY WITH NOTES
Note Mode: 🧭 Specimen Summary
🔎 Isolated DefectsTip No actionable defects isolated. ✅ Resolved Since Last Review
🧹 Nitpicks
✅ Control Checks
🧪 Observations
🧰 CI Status
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| }; | ||
| let refreshed_stamp = collection_content_stamp(&path)?; | ||
| if refreshed_stamp != stamp { | ||
| return Err(AppError::new( |
There was a problem hiding this comment.
⚠️ MEDIUM: Unstable index build escapes as a read failure
Location: src-tauri/crates/storage/src/lib.rs:1853
A fascinating cure: the index no longer caches bytes it failed to prove, but the mechanism now exports an ordinary concurrent collection rewrite as
storage_index_unstable. Agetor projectedgetracing another writer can fail outright even though a bounded retry or uncached read of the refreshed file could produce the correct answer. The stale-cache invariant is protected; the read contract is merely shoved off the table.
Tip
Suggested fix: On stamp mismatch, refuse the cache entry but retry once or fall back to an uncached read of the current disk bytes instead of presenting transient instability as the lookup result.
Linked issue
Closes #2497
Closes #2498
Why this change
What changed
getand projectedgetcalls can reuse indexed record ranges without loading full pretty JSON collections.Refactor impact
Primary owner:
Rust storage
Impact areas reviewed:
src-tauri/crates/storage/src/lib.rsBoundary notes:
Pressure points touched:
src-tauri/src/lib.rscommand registration, or import modules touched.Validation
pnpm typecheck,pnpm build,pnpm check:architecture,pnpm check:docs, or fullpnpm checkwhen warranted)pnpm checkpasses before PR push/handoffManual verification notes
cargo test --manifest-path src-tauri/crates/storage/Cargo.toml repeated_get_uses_cached_id_index_after_disk_readpassed.cargo test --manifest-path src-tauri/crates/storage/Cargo.toml repeated_projected_get_uses_cached_id_index_after_disk_readpassed.cargo test --manifest-path src-tauri/crates/storage/Cargo.toml projected_get_id_index_avoids_caching_full_pretty_rowspassed.cargo test --manifest-path src-tauri/crates/storage/Cargo.toml projected_collection_stamp_uses_metadata_without_content_signaturepassed.cargo test --manifest-path src-tauri/crates/storage/Cargo.toml list_projected_cache_detects_same_length_rewrite_when_mtime_changespassed.pnpm checkpassed.Feature Discoverability
Check exactly one:
src/features/shell/discovery/because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.Reason:
Docs and release impact
README.mdCONTRIBUTING.mddocs/developer/AGENTS.mdUI evidence
N/A. Rust storage-only change; no visible UI behavior changed.