Skip to content

refactor: unify async/sync storage backend semantics #190

Closed

Description

@Sinity

Problem

The storage layer has two parallel backend paths that must stay in sync manually:

  • Async path: polylogue/storage/backends/async_sqlite.py, used by the facade, MCP server, and most runtime operations.
  • Sync path: polylogue/storage/backends/connection.py, used by CLI query paths, schema tools, validation, and the sync bridge (SyncPolylogue).

Both paths currently own similar behavior:

  • schema bootstrap and version checking;
  • connection profiling and SQLite tuning;
  • read/write connection policy;
  • schema extension application;
  • sqlite-vec loading.

The async path is the canonical runtime, but the sync path is also production code. Correctness changes can land in one path and lag in the other. Schema extension handling already showed this drift: one backend used shared logic while the other duplicated the decision inline.

Scope

  1. Extract shared SQLite tuning into a single connection-profile contract that both backends consume.
  2. Factor schema bootstrap/version/extension decisions into shared logic with backend-specific I/O adapters.
  3. Keep sqlite-vec setup behavior consistent across sync and async paths.
  4. Document why the sync path exists and where async remains primary.

Non-goals

  • Removing the sync path entirely.
  • Changing the public API surface.

Acceptance criteria

  • SQLite tuning constants are defined in one place.
  • Schema version checking and extension application share one decision function.
  • Adding a schema extension requires touching one schema/bootstrap module, not two backend implementations.
  • Tests cover both sync and async bootstrap paths.

Activity

  1. added
    type:refactor
    on Apr 16, 2026
  2. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Starting this after #196.

    Tactic for the first PR:

    • Inspect async/sync backend duplication around SQLite tuning, schema bootstrap/version checks, schema extension application, and sqlite-vec loading.
    • Land a scoped shared connection/profile module first so tuning constants stop drifting.
    • Factor schema/bootstrap decision logic only where the existing structure gives a clean seam; avoid a broad backend rewrite or sync-path removal in this slice.
    • Keep tests targeted to storage backend semantics, then run the full local baseline once before PR.
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

    area:storagetype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions