Repository navigation
fix(settings): default fresh installs to the native retention period - #2246
Conversation
…y-only save Adds the pure helpers and tests the #2136 fix in the next commit relies on: - `app::native_lifecycle::is_fresh_profile` and `default_hardware_archive_retention_days` decide the Hardware Archive Retention Period default from on-disk authority facts alone, treating an empty profile (no source database, no native database, no marker) as heading for native authority rather than trusting `inspect_startup_authority`'s SqliteAuthoritative peek at face value. - `CoreSettings::save_identity_only_to_path` persists only the storage health identity section, so the one-time identity-key bootstrap in `AppState::new` (next commit) stops writing a never-saved retention default to disk as if it were explicitly chosen.
Fresh installs default the Hardware Archive Retention Period to 30 days instead of 365, and persist it as if the user had chosen it. `run()` picked the default with a read-only peek at on-disk authority facts, taken before `resolve_native_authority` creates and selects the native database for a fresh profile later in the same startup (#2203). On an empty profile the peek reports SqliteAuthoritative - correct about the instant it was read, but not about the backend startup ends up on - so the 30-day SQLite-era default was chosen. `AppState::new` then made it durable: its one-time identity-key bootstrap saved the whole `CoreSettings` object, writing the defaulted 30 to `settings.json` as if explicitly saved, after which the "365 only for a never-saved value" rule could never apply to that profile again. Switch the default selection to `native_lifecycle::default_hardware_archive_retention_days`, which treats an empty profile as native (#2136), and switch the identity-key bootstrap save to `save_identity_only_to_path`, which touches only the identity section it owns. Closes #2244
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. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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 (4)
Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 6 reviews per hour. 📝 WalkthroughWalkthroughSettings initialization now saves only the storage-health identity. Startup selects the hardware-archive retention default based on whether the profile is fresh and which authority it resolves to. ChangesFresh-profile retention defaults
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Fresh profiles receive the native retention default without saving it as a user choice. No merge-blocking issue was established. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Rust Tauri Coverage ReportCoverage Details |
CI telemetryCommit
|
| Job | Result | Queue | Duration | CPU avg / p95 | Mem peak | Disk peak | Caches |
|---|---|---|---|---|---|---|---|
Analyze (rust) |
✅ | 2s | 9m 22s | – | – | – | – |
Analyze (javascript-typescript) |
✅ | 2s | 1m 03s | – | – | – | – |
Analyze (actions) |
✅ | 2s | 48s | – | – | – | – |
Slowest steps
| Step | Duration |
|---|---|
Analyze (rust) › Perform CodeQL Analysis |
7m 25s |
Analyze (rust) › Setup Rust |
1m 26s |
Analyze (javascript-typescript) › Perform CodeQL Analysis |
38s |
Analyze (actions) › Perform CodeQL Analysis |
25s |
Analyze (javascript-typescript) › Initialize CodeQL |
18s |
CI · 20 jobs · 10 skipped
| Job | Result | Queue | Duration | CPU avg / p95 | Mem peak | Disk peak | Caches |
|---|---|---|---|---|---|---|---|
test-e2e-native |
✅ | 3s | 13m 40s | 80% / 100% · 3.2/4T T 79 · 82 · 79 · 81 |
4.6 / 15.6 GiB | 68 / 145 GiB | target exact · npm exact |
test-core (windows-latest) |
✅ | 4s | 10m 15s | 45% / 100% · 1.8/4T T 43 · 42 · 50 · 44 |
8.0 / 16.0 GiB | 24 / 150 GiB | target exact · sccache Rust 0% (0/1) · C/C++ n/a |
test-tauri (windows-latest) |
✅ | 5s | 7m 22s | 21% / 63% · 0.8/4T T 21 · 19 · 25 · 20 |
8.7 / 16.0 GiB | 14 / 220 GiB | target exact · sccache Rust 0% (0/1) · C/C++ n/a |
test-core (macos-latest) |
✅ | 7s | 6m 42s | 95% / 100% · 2.8/3T T 95 · 94 · 94 |
4.3 / 7.0 GiB | 239 / 320 GiB | target exact · sccache Rust 0% (0/1) · C/C++ n/a |
test-build (macos-latest) |
✅ | 8s | 5m 47s | 79% / 100% · 2.4/3T T 82 · 78 · 76 |
4.6 / 7.0 GiB | 232 / 320 GiB | target exact · sccache Rust 100% (615/616) · C/C++ 99% (292/295) |
test-core (ubuntu-22.04) |
✅ | 3s | 5m 10s | 41% / 98% · 1.6/4T T 40 · 43 · 40 · 43 |
2.6 / 15.6 GiB | 79 / 145 GiB | target exact · sccache Rust 0% (0/1) · C/C++ n/a |
test-tauri (macos-latest) |
✅ | 11s | 4m 23s | 79% / 100% · 2.4/3T T 82 · 78 · 76 |
4.4 / 7.0 GiB | 234 / 320 GiB | target exact · sccache Rust 0% (0/1) · C/C++ n/a |
lint-tauri (windows-latest) |
✅ | 3s | 4m 14s | 33% / 85% · 1.3/4T T 32 · 26 · 45 · 27 |
5.9 / 16.0 GiB | 17 / 150 GiB | target exact · sccache Rust n/a · C/C++ n/a |
test-build (ubuntu-22.04) |
✅ | 4s | 4m 14s | 45% / 87% · 1.8/4T T 40 · 43 · 51 · 46 |
3.5 / 15.6 GiB | 69 / 145 GiB | target exact · sccache Rust 100% (679/680) · C/C++ 99% (294/297) |
test-build (windows-latest) |
✅ | 4s | 3m 24s | 34% / 99% · 1.4/4T T 33 · 32 · 43 · 28 |
6.7 / 16.0 GiB | 13 / 150 GiB | target exact · sccache Rust 93% (13/14) · C/C++ n/a |
test-tauri (ubuntu-22.04) |
✅ | 3s | 3m 18s | 39% / 80% · 1.6/4T T 40 · 42 · 38 · 36 |
3.0 / 15.6 GiB | 73 / 145 GiB | target exact · sccache Rust 0% (0/1) · C/C++ n/a |
lint-core (windows-latest) |
✅ | 3s | 3m 17s | 20% / 54% · 0.8/4T T 21 · 15 · 29 · 15 |
5.5 / 16.0 GiB | 12 / 220 GiB | target exact · sccache Rust n/a · C/C++ n/a |
check-tauri-bindings |
✅ | 3s | 2m 42s | 26% / 47% · 1.0/4T T 25 · 21 · 22 · 36 |
2.2 / 15.6 GiB | 72 / 145 GiB | target exact · sccache Rust 0% (0/1) · C/C++ n/a |
lint-tauri (ubuntu-22.04) |
✅ | 2s | 2m 08s | 36% / 56% · 1.4/4T T 37 · 42 · 33 · 32 |
2.1 / 15.6 GiB | 76 / 145 GiB | target exact · sccache Rust n/a · C/C++ n/a |
lint-core (ubuntu-22.04) |
✅ | 3s | 1m 38s | 38% / 60% · 1.5/4T T 43 · 40 · 29 · 42 |
1.7 / 15.6 GiB | 72 / 145 GiB | target exact · sccache Rust n/a · C/C++ n/a |
lint-tauri (macos-latest) |
✅ | 6s | 1m 32s | 72% / 90% · 2.2/3T T 76 · 72 · 68 |
4.2 / 7.0 GiB | 235 / 320 GiB | target exact · sccache Rust n/a · C/C++ n/a |
lint-core (macos-latest) |
✅ | 10s | 1m 26s | 78% / 100% · 2.3/3T T 80 · 77 · 76 |
4.1 / 7.0 GiB | 234 / 320 GiB | target exact · sccache Rust n/a · C/C++ n/a |
change-detection |
✅ | 6s | 20s | – | – | – | – |
rust-format |
✅ | 2s | 17s | 32% / 32% · 1.3/4T T 35 · 17 · 33 · 44 |
1.7 / 15.6 GiB | 59 / 144 GiB | – |
Merge Gate |
✅ | 5s | 17s | – | – | – | – |
Slowest steps
| Step | Duration |
|---|---|
test-e2e-native › Run native E2E smoke |
12m 14s |
test-core (windows-latest) › Run Core tests |
7m 28s |
test-core (macos-latest) › Run Core tests |
5m 33s |
test-tauri (windows-latest) › Run Tauri tests |
4m 42s |
test-build (macos-latest) › Build Tauri Rust crate (CI optimized for PR) |
4m 42s |
Generated by the CI telemetry workflow from the GitHub API and job log markers. Queue = time from job creation to start. N/MT = average busy threads of M logical CPUs; T = per-thread average %.
Summary
Why: On a fresh install, the Hardware Archive Retention Period default ends up persisted as 30 days instead of 365, even though fresh installs create and select a native database directly (#2203). Confirmed during the 2026-09-24 release audit.
What:
src-tauri/src/lib.rs: replace the inlineinspect_startup_authoritypeek withapp::native_lifecycle::default_hardware_archive_retention_days, which treats an empty profile (nohv-database.db, nohv-database.duckdb, nohv-database.authority.json) as heading for native authority, since startup creates and selects a native database for it moments later. An existing SQLite source with no native artifacts yet still resolves to the SQLite-era default.src-tauri/src/commands/settings.rs(AppState::new): switch the one-time identity-key bootstrap save fromsave_to_path(which persists the wholeCoreSettingsobject, including a never-saved retention default, as if it had been explicitly chosen) to the newCoreSettings::save_identity_only_to_path, which touches only thestorageHealthIdentitysection it owns.core/src/settings/mod.rs: addsave_identity_only_to_path, refactoring the shared read/write-document logic out ofsave_to_pathso both can use it.src-tauri/src/app/native_lifecycle.rs: addis_fresh_profileanddefault_hardware_archive_retention_days.Evidence:
core/src/settings/mod.rs::settings::testsprove a defaulted retention value is never written to disk by the identity-key bootstrap save, and that an already-saved value is untouched (DP-06).src-tauri/src/app/native_lifecycle.rs::testsdriveis_fresh_profile/default_hardware_archive_retention_daysagainst temp directories for the three cases: empty profile → 365, directory with onlyhv-database.db→ 30, selected native profile → 365.cargo fmt --all -- --check: clean.cargo clippy -p hardviz-core --all-targets -- -D warningsand with--no-default-features: clean.cargo clippy -p hardware_visualizer --all-targets -- -D warningsand with--no-default-features: clean.cargo test -p hardviz-core --lib settings: 48 passed.cargo test -p hardware_visualizer --lib -- --test-threads=1: 383 passed, 0 failed.Closes #2244
Type of Change
fix/branch)Test Plan
Checklist
cargo tauri-lint && cargo tauri-fmt)cargo tauri-test)Summary by CodeRabbit