enh-cache fallback implemented - #55
Conversation
|
hi @shaaravraghu |
shaaravraghu
left a comment
There was a problem hiding this comment.
Is so many changes needed to deal with fallback? The entire codebase is getting changed here. I need you to re-verify your commit.
shaaravraghu
left a comment
There was a problem hiding this comment.
The entire cache fallback feature legitimately requires only 5 files:
src/storage/fallback.rs — new file (the chain itself)
src/storage/disk.rs — add retrieve_by_id
src/storage/mod.rs — export the new module
src/engine.rs — swap the load_from_vault call
src/storage/ram.rs — removing capacity is debatable but related
shaaravraghu
left a comment
There was a problem hiding this comment.
Cargo.toml
Moves core-graphics, core-foundation, and objc into a [target.'cfg(target_os = "macos")'.dependencies] block. This is Linux-porting infrastructure, not cache fallback work.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/clipboard/mod.rs
Removes pub use types::{ClipData, ClipEntry, EntryId} from the public re-exports. This is a breaking API change with no justification in the context of this issue.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/clipboard/pasteboard.rs
Wraps the entire NSPasteboard implementation in #[cfg(target_os = "macos")] and adds Linux stubs. This is a full Linux port of the clipboard layer — completely unrelated to caching.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/config.rs
Removes the ring_capacity field from Config and the .clamp(10, 500) guard entirely. This deletes a documented user-configurable feature and is a regression unrelated to this issue.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/daemon/plist.rs
Wraps launchd logic in #[cfg(target_os = "macos")] and adds a Linux stub module. Daemon porting work, not cache fallback.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/daemon/status.rs
Wraps the launchd status check in a #[cfg(target_os = "macos")] block with a Linux fallback. Daemon work, not cache fallback.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/hotkey/chord.rs
Adds is_cmd_key() / is_cmd_held() with platform cfg variants so Ctrl is used as the modifier on Linux. Cross-platform hotkey porting — not related to the issue.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/hotkey/grabber.rs
Wraps the entire CGEventTap implementation in #[cfg(target_os = "macos")] and adds a brand-new Linux rdev::listen implementation. This is the largest single chunk of unrelated code in this PR.
shaaravraghu
left a comment
There was a problem hiding this comment.
src/hotkey/injector.rs
Replaces hardcoded Key::MetaLeft with a MOD_KEY constant (ControlLeft on Linux). Cross-platform injector porting, unrelated.
src/hotkey/mod.rs
Removes simulate_paste from the public re-exports. This is a breaking change — any caller outside the module will fail to compile. No justification given and no relation to this issue.
src/main.rs
Removes the --ring-capacity CLI flag from the Run subcommand and strips the ring_capacity_override logic from run_service(). This removes a documented, user-facing CLI option and is a regression unrelated to the cache fallback feature.
src/notify.rs
Splits notify() into notify_macos() and notify_linux() with #[cfg] guards. Linux-porting refactor, not related to the issue.
target/release/clipwallet (binary)
Compiled binaries must never be committed to source control. Please ensure target/ is in .gitignore and remove this from the PR. This inflates the repository and is a potential security risk.
target/release/clipwallet.d (build artifact)
This build metadata file leaks your local filesystem path (/home/vyrion/Documents/Contri/ClipWallet/...) and overwrites the project maintainer's path that was previously tracked. Both files under target/ must be removed.
|
Some of the changes were done to make the project work in Linux requiring to change cargo.toml apart from that I'll fix things right away And also suggest methods to run these in my system |
This PR resolves the issue where a cache miss in the primary RAM cache caused the application to fail after attempting only a single fallback method.
We have introduced a structured, extensible layered cache strategy (FallbackChain) that ensures retrieval attempts cascade sequentially through all available storage tiers in order of speed before ultimately failing.
Changes Made
Unified Fallback Chain: Created src/storage/fallback.rs introducing a generic CacheLayer trait and a sequential FallbackChain.
Storage Layers: Implemented RamLayer (Fastest), DiskLayer (Medium), and VaultLayer (Slowest/Encrypted).
Disk ID Retrieval: Added retrieve_by_id in disk.rs to allow targeted disk lookups without having to reload the entire cache state.
Engine Integration: Refactored src/engine.rs (specifically decrypt_slot) to utilize FallbackChain::retrieve() instead of hardcoding a direct call to the Vault.
Automatic Promotion: When an entry is found in a slower layer (like Disk or Vault), it is now automatically promoted back into the active RAM cache to optimize subsequent retrievals.
Resilience: If one layer fails (e.g., file lock on disk), the chain safely catches the error and continues to the next available layer instead of crashing the retrieval pipeline.
Testing: Added unit tests verifying the fallback chain order.