Skip to content

refactor: decouple Memory from asyncpg via StorageBackend protocol#3

Draft
Mearman wants to merge 3 commits intomainfrom
refactor/storage-backend-protocol
Draft

refactor: decouple Memory from asyncpg via StorageBackend protocol#3
Mearman wants to merge 3 commits intomainfrom
refactor/storage-backend-protocol

Conversation

@Mearman
Copy link
Copy Markdown
Member

@Mearman Mearman commented Apr 28, 2026

Introduces a StorageBackend protocol in pgkg/backend.py and a PostgresBackend implementation that wraps the existing asyncpg pool and SQL functions with zero behavioural change. Memory now depends on the protocol instead of holding an asyncpg.Pool directly. All raw SQL moved into PostgresBackend. PostgresExtractCache replaced by a BackendExtractCache adapter. 56/56 tests passing.

Mearman added 3 commits April 28, 2026 22:01
Decouple pgkg from direct asyncpg usage by defining a StorageBackend
protocol in pgkg/backend.py and a PostgresBackend implementation that
wraps the existing asyncpg pool and SQL functions (pgkg_search,
pgkg_link_entity, pgkg_bump_access) with zero behavioural change.
Memory now depends on the StorageBackend protocol instead of holding an
asyncpg.Pool directly. All raw SQL has moved into PostgresBackend.
PostgresExtractCache replaced by BackendExtractCache adapter. Updated
api.py, cli.py, bench scripts, and tests to construct PostgresBackend.
Thread asserted_at through StoredChunk, StoredProposition, Candidate,
and Result so the refactored backend preserves the feature added in
origin/main. Fix test_bench and test_memory to use backend fixture.
Base automatically changed from feat/bm25-scoring to feat/pgserver-embedded April 29, 2026 21:03
Base automatically changed from feat/pgserver-embedded to main April 29, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant