Skip to content

refactor(core): Phase 4 — relocate persistence into core::persistence with EventBus subscription #1407

@shm11C3

Description

@shm11C3

Parent

Part of #1402. Depends on Phase 3 and Phase 3.5.

Goal

Move the archive worker and DB writers into core::persistence (inside the root-level core crate), and switch persistence from sharing the MonitorResources Arc<Mutex> bag to subscribing to the EventBus.

Workspace Context

core::persistence::* lives at core/src/persistence/ inside the workspace core crate. The DB infrastructure that backs it lands at core/src/infrastructure/database/. None of these may depend on tauri.

Scope

  • Relocate src-tauri/src/workers/hardware_archive.rscore/src/persistence/archive.rs.
  • Move the relevant pieces of src-tauri/src/infrastructure/database/ (writers, archive logic, scheduled deletion, schema preflight) into the core crate at core/src/persistence/ and core/src/infrastructure/database/.
  • Persistence subscribes to the EventBus instead of sharing the Arc<Mutex> history bag with the collector.
  • core::persistence::preflight::check_db_compatibility() (moved in Phase 3.5) is still callable from App — it is consumed by the startup dialog in src-tauri/src/app/startup.rs.

Out of Scope

  • Lifecycle changes (Phase 5).
  • Tray UI (Phase 6).
  • Schema redesigns or migrations.

Definition of Done

  • Archive feature continues to record data correctly.
  • An integration test simulates DB-write latency (e.g. injected delay in the writer) and asserts that sensor polling cadence is unaffected.
  • core/src/persistence/ has unit tests that run via cargo test -p <core-crate> without a Tauri runtime.
  • No user-visible regression in the Insight (30-day history) view.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions