Skip to content

refactor(macOS): shared repository base for Rewind local storage classes (collapse duplicated DB plumbing) #9519

Closed

Description

@Git-on-my-level

Summary

Collapse the duplicated storage plumbing in desktop/macos/Desktop/Sources/Rewind/Core/ into a shared repository base. This is a milder disease than #9515/#9516: there is one DB owner (RewindDatabase), but nine *Storage classes each privately copy the same connection-lifecycle boilerplate — cached _dbQueue, pool-generation checks, re-initialization, and FTS-repair reach-ins. Mechanical, low-risk, good between-big-things work.

Evidence (verified in tree)

  • Storage classes in Rewind/Core/: ActionItemStorage (61.6K), TranscriptionStorage (42.2K), MemoryStorage (30.4K), RewindStorage (28.9K), StagedTaskStorage (17.9K), ProactiveStorage (17.6K), TaskChatMessageStorage (12.5K), GoalStorage (8.6K), plus NoteStorage in LiveNotes/ and KnowledgeGraphStorage in FileIndexing/ following the same shape.
  • Each repeats the pattern visible in ActionItemStorage.swift: private _dbQueue: DatabasePool? + _dbGeneration cache, generation check against RewindDatabase.shared.poolGeneration(), lazy initialize(), and per-class FTS error/repair handling (isActionItemsFTSError / repairActionItemsFTS reach into RewindDatabase).
  • RewindDatabase.swift is ~3,300 lines with ~107 raw sqlite call sites, accumulating per-domain repair helpers that belong with the domains.
  • Churn: Rewind/ 103 commits since 2026-05-15; RewindDatabase.swift among the most-touched files in the app outside the chat/PTT area.

Target shape

One repository base (actor or protocol + shared helper) that exclusively owns:

  • connection acquisition + pool-generation invalidation (write once, delete nine copies);
  • the initialize/reopen lifecycle;
  • a generic FTS-repair hook parameterized by table, so per-domain repair methods leave RewindDatabase.

Domain storages keep their queries and models; they lose their plumbing. RewindDatabase shrinks toward schema/migrations/pool ownership only.

Scope & guardrails

Definition of done

  • All Rewind-pattern storage classes use the shared base; zero private pool/generation caches remain (guard at zero).
  • Per-domain FTS repair moved out of RewindDatabase into the parameterized hook.
  • Full desktop Swift test suite green; clean debug build; named-bundle smoke run (OMI_APP_NAME=omi-rewind-repo ./run.sh) exercising rewind capture, action items, and task chat reads.

Related

Activity

  1. added
    maintainer
    on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    desktopmacOSmaintainerrefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions