Repository navigation
feat(database): route Storage Health through dispatch - #2157
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: shm11C3/HardwareVisualizer/.coderabbit.yml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Limit details: You’ve used all 4 included reviews currently available. Your 61 included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthroughStorage-health database operations now use the dispatch boundary. The boundary routes calls to SQLite or the selected native backend. Persistence and hardware-service reads use this boundary. A DuckDB-gated test verifies routing, reads, writes, and retention deletion. ChangesStorage Health Dispatch
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant StorageHealthPersistence
participant HardwareService
participant StorageHealthDispatch
participant SQLite
participant NativeBackend
StorageHealthPersistence->>StorageHealthDispatch: Insert or refresh records
StorageHealthDispatch->>SQLite: Route before native selection
StorageHealthDispatch->>NativeBackend: Route after native selection
HardwareService->>StorageHealthDispatch: Read latest records
StorageHealthDispatch-->>HardwareService: Return records or DispatchError
StorageHealthPersistence->>StorageHealthDispatch: Delete old records
StorageHealthDispatch->>NativeBackend: Delete from selected native storage
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Rust Tauri Coverage ReportCoverage Details |
Reconciles this branch's own standalone SQLite-refusal fix (bff007e, applied before this merge) with the same fix as it landed on the rest of the stack (#2154 -> #2156 -> #2157). Conflicts were both "this branch already has equivalent content the incoming side doesn't carry yet" - Cooling's own submodules (already on resolve_backend()/Backend here) and one restored doc comment - resolved by keeping this branch's content. No functional change: `cargo check`/`clippy`/`nextest` all green before and after, confirming the merge is a no-op over what PR #2161 already shipped.
Extends the #2134 dispatch boundary to Storage Health, reusing the same boundary/DispatchError plumbing PR #2154 proved with Process Stats and PR #2156 extended to the raw archive families. `insert_daily_records`, `refresh_daily_records`, `delete_old_data` and `latest_records` now go through `dispatch::storage_health` instead of calling `infrastructure::database::storage_health` directly, in both the persistence worker (`core/src/persistence/storage_health.rs`) and the App service (`src-tauri/src/services/hardware_service.rs`). `hardware_service::get_storage_health_latest_records`'s error type moves from `sqlx::Error` to `dispatch::DispatchError`; its only caller already formats the error as a string, so no other signature changes. Cooling's six projections, both baselines and the cooling rollup persistence remain unrouted - tracked separately, per the issue's explicit allowance to say so rather than route silently to SQLite.
Follow-up to the merge of #2154's fix: Storage Health's four dispatch functions now go through resolve_backend()/Backend like every other routed family, so DispatchError::NativeUnavailable covers this branch's consumer too instead of only the ones merged in from upstream.
f07e660 to
bd40abf
Compare
Summary
Stacked on #2156 (which is stacked on #2154). Extends the #2134 dispatch boundary to Storage Health, reusing the same
dispatch::DispatchError/native_handleplumbing the earlier PRs in this stack proved.insert_daily_records,refresh_daily_records,delete_old_dataandlatest_recordsnow go throughdispatch::storage_healthinstead of callinginfrastructure::database::storage_healthdirectly, in both the persistence worker and the App service.Why / What / How / Why Not
native_database::storage_health), and its own differential test suite (duckdb_storage_health.rs) - the same shape of work the earlier PRs in this stack already did.dispatch::storage_health::{insert_daily_records, refresh_daily_records, delete_old_data, latest_records}; the call sites incore/src/persistence/storage_health.rsandsrc-tauri/src/services/hardware_service.rs.match native_handle().await { Some(db) => native call, None => existing SQLite call }per function.get_storage_health_latest_records'ssqlx::Errorreturn type: dispatch's SQLite branch still returnssqlx::Errorunder the hood, but the native branch returns a different type, so the function has to return something both can convert into.DispatchErroris that type; its only caller (commands/hardware.rs) already formats the error as a string via{e}, so nothing downstream changes.Consumers routed / not yet routed
DATA_ARCHIVE,GPU_DATA_ARCHIVE, Ambient, Fan, Storage Health.cooling_rollup.rsalone commits six projections in one SQLite transaction across five other modules, several with their own baseline-resolution and pinning logic - and are tracked as follow-up work rather than attempted here, per the issue's explicit allowance to say so rather than route silently to SQLite.Test Plan
core/tests/duckdb_dispatch_storage_health.rs(new) - one sequential test proving Storage Health answers from SQLite before selection, answers identically from native afterreobserve_authority, that a post-selectionrefresh_daily_recordswrite lands in the native file (SQLite's own row count stays put), and thatdelete_old_datathrough the boundary reaches the native database. Usesstorage_device_id-shaped identities, perduckdb_storage_health.rs's own module doc on why an invented id shape would hide a broken join.cargo fmt --all -- --checkcargo clippy -p hardviz-core --features duckdb-archive --all-targets -- -D warningscargo clippy -p hardviz-core --all-targets -- -D warningscargo clippy -p hardware_visualizer --features duckdb-archive --all-targets -- -D warningscargo nextest run -p hardviz-core --features duckdb-archive- 1428 passedcargo test -p hardviz-core(feature off) - all passedcargo test -p hardware_visualizer --lib- the Storage Health / hardware_service tests pass; 9 unrelated_tests::commands::settings_testfailures are pre-existing in this sandbox (confirmed identical with this PR's diff stashed out - a file-write environment issue, not a regression from this change).Related Issues
Part of #2134. Stacked on #2156.
Type of Change
feat/branch)Checklist
Summary by CodeRabbit