Repository navigation
Closed
Labels
Description
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), plusNoteStorageinLiveNotes/andKnowledgeGraphStorageinFileIndexing/following the same shape. - Each repeats the pattern visible in
ActionItemStorage.swift: private_dbQueue: DatabasePool?+_dbGenerationcache, generation check againstRewindDatabase.shared.poolGeneration(), lazyinitialize(), and per-class FTS error/repair handling (isActionItemsFTSError/repairActionItemsFTSreach intoRewindDatabase). RewindDatabase.swiftis ~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.swiftamong 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
- No schema changes, no behavior changes — this is plumbing consolidation. Existing storage tests must pass unchanged; add tests only for the shared base (generation invalidation, repair hook).
- Migrate one storage class per commit within one PR for reviewability.
- Guard: a check that fails on new private
_dbQueue/generation caching outside the base. - Note:
TaskChatMessageStorage.saveMessageis also flagged in the refactor(macOS): converge chat, PTT, agents, tools, and continuity onto single owners #9515 task-chat persistence amendment — coordinate so this refactor doesn't churn that file while refactor(macOS): converge chat, PTT, agents, tools, and continuity onto single owners #9515 decides its ownership.
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
RewindDatabaseinto 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
- refactor(macOS): converge chat, PTT, agents, tools, and continuity onto single owners #9515 — macOS convergence (governing single-owner rule; the task-chat persistence row interacts with
TaskChatMessageStorage). - refactor(backend): converge conversation lifecycle onto a single mutation owner #9516 / refactor(backend): converge notification sending onto one dispatch owner (typed intents, single policy point) #9518 — backend siblings of the same complexity-collapse effort.
Activity