Repository navigation
fix(core): stop SQLite startup importing asyncpg - #2108
Merged
Merged
Conversation
lost_search_refresh_race matched asyncpg's exception classes, so importing it loaded the Postgres driver on every install. On Windows with Smart App Control the native extension is blocked and bm mcp exits before initialize. Match on the SQLSTATE and constraint name on the driver error instead. Fixes #2103 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD Signed-off-by: phernandez <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2103.
Problem
search_refresh_race.pyimportedasyncpg.exceptionsat module load. The search service and the accepted-note write runner import it, so every install loaded the Postgres driver at startup, including SQLite-only installs. On Windows 11 with Smart App Control on, Windows blocks asyncpg's unsigned native extension, andbm mcpexits before it answersinitialize.Change
lost_search_refresh_racenow matches the driver error by its Postgres SQLSTATE (40P01deadlock,23505unique violation) and constraint name instead of by asyncpg's exception classes. The module no longer imports asyncpg. After this change, importingbasic_memory.cli.mainandbasic_memory.mcp.serverleavesasyncpgout ofsys.modules.Tests
test_sqlite_startup_never_imports_the_postgres_driverimports the CLI and MCP server in a fresh interpreter and checks that asyncpg was not loaded. It fails on main.tests/services/test_search_refresh_concurrency.pypasses against Postgres; it produces the real deadlock and primary-key races.just typecheckpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD