memuron 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- memuron/__init__.py +3 -0
- memuron/actions/__init__.py +12 -0
- memuron/actions/context.py +63 -0
- memuron/actions/helpers.py +88 -0
- memuron/actions/memory.py +340 -0
- memuron/actions/memory_write.py +290 -0
- memuron/actions/nodes.py +340 -0
- memuron/actions/registry.py +5 -0
- memuron/actions/runtime.py +37 -0
- memuron/actions/spaces_documents.py +720 -0
- memuron/actions/sync.py +155 -0
- memuron/application/__init__.py +1 -0
- memuron/application/api.py +206 -0
- memuron/application/app.py +103 -0
- memuron/application/capabilities.py +82 -0
- memuron/application/cli.py +35 -0
- memuron/application/config.py +176 -0
- memuron/application/mcp.py +44 -0
- memuron/application/mcp_oauth.py +290 -0
- memuron/application/registry.py +52 -0
- memuron/context.py +532 -0
- memuron/documents/__init__.py +1 -0
- memuron/documents/link_guardian.py +192 -0
- memuron/documents/linking.py +292 -0
- memuron/documents/parser.py +1152 -0
- memuron/documents/storage.py +151 -0
- memuron/documents/url_ingest.py +375 -0
- memuron/domain/__init__.py +1 -0
- memuron/domain/decoders.py +1 -0
- memuron/domain/encoders.py +185 -0
- memuron/domain/lifecycles.py +8 -0
- memuron/domain/limits.py +6 -0
- memuron/domain/representations.py +56 -0
- memuron/domain/schemas.py +581 -0
- memuron/domain/scope_filter.py +104 -0
- memuron/graphfs/__init__.py +1 -0
- memuron/graphfs/manual.py +635 -0
- memuron/graphfs/projection.py +578 -0
- memuron/graphfs/query.py +1782 -0
- memuron/graphfs/read_model.py +574 -0
- memuron/ingest/__init__.py +1 -0
- memuron/ingest/guardian.py +213 -0
- memuron/ingest/jobs.py +424 -0
- memuron/ingest/prompts.py +147 -0
- memuron/memory/__init__.py +1 -0
- memuron/memory/engine.py +35 -0
- memuron/memory/projections.py +452 -0
- memuron/memory/recipes.py +3247 -0
- memuron/persistence/__init__.py +1 -0
- memuron/persistence/db_pool.py +57 -0
- memuron/persistence/identity_store.py +918 -0
- memuron/persistence/store_helpers.py +16 -0
- memuron/search/__init__.py +1 -0
- memuron/search/fulltext.py +110 -0
- memuron/search/hybrid.py +284 -0
- memuron/search/pgvector.py +252 -0
- memuron/security/__init__.py +1 -0
- memuron/security/auth.py +143 -0
- memuron/security/auth_provider.py +119 -0
- memuron/security/authorization.py +53 -0
- memuron/security/clerk_scopes.py +94 -0
- memuron/security/clerk_webhooks.py +61 -0
- memuron/security/jwt_tokens.py +53 -0
- memuron/security/passwords.py +38 -0
- memuron/security/tenant.py +58 -0
- memuron/spaces/__init__.py +1 -0
- memuron/spaces/model.py +35 -0
- memuron/spaces/service.py +155 -0
- memuron/sync/__init__.py +25 -0
- memuron/sync/folder.py +828 -0
- memuron-0.1.1.dist-info/METADATA +242 -0
- memuron-0.1.1.dist-info/RECORD +74 -0
- memuron-0.1.1.dist-info/WHEEL +4 -0
- memuron-0.1.1.dist-info/entry_points.txt +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Database, identity-store, and projection persistence helpers."""
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""PostgreSQL connection pooling for memuron hot paths."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from contextlib import contextmanager
|
|
7
|
+
from typing import Any, Iterator
|
|
8
|
+
|
|
9
|
+
from psycopg.rows import dict_row
|
|
10
|
+
from psycopg_pool import ConnectionPool
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
_POOL_ATTR = "_memuron_connection_pool"
|
|
15
|
+
_ORIGINAL_CONNECT_ATTR = "_memuron_original_connect"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def install_postgres_pool(store: object, *, min_size: int = 1, max_size: int = 8) -> bool:
|
|
19
|
+
"""Replace per-query connects with a shared pool on Postgres stores."""
|
|
20
|
+
database_url = getattr(store, "database_url", None)
|
|
21
|
+
original_connect = getattr(store, "_connect", None)
|
|
22
|
+
if not database_url or original_connect is None:
|
|
23
|
+
return False
|
|
24
|
+
if getattr(store, _POOL_ATTR, None) is not None:
|
|
25
|
+
return True
|
|
26
|
+
|
|
27
|
+
pool = ConnectionPool(
|
|
28
|
+
conninfo=database_url,
|
|
29
|
+
min_size=min_size,
|
|
30
|
+
max_size=max_size,
|
|
31
|
+
kwargs={"row_factory": dict_row},
|
|
32
|
+
open=True,
|
|
33
|
+
)
|
|
34
|
+
setattr(store, _ORIGINAL_CONNECT_ATTR, original_connect)
|
|
35
|
+
|
|
36
|
+
@contextmanager
|
|
37
|
+
def pooled_connect() -> Iterator[Any]:
|
|
38
|
+
with pool.connection() as conn:
|
|
39
|
+
yield conn
|
|
40
|
+
|
|
41
|
+
store._connect = pooled_connect # type: ignore[method-assign]
|
|
42
|
+
setattr(store, _POOL_ATTR, pool)
|
|
43
|
+
logger.info("Postgres connection pool ready (min=%s max=%s)", min_size, max_size)
|
|
44
|
+
return True
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def close_postgres_pool(store: object) -> None:
|
|
48
|
+
pool = getattr(store, _POOL_ATTR, None)
|
|
49
|
+
if pool is None:
|
|
50
|
+
return
|
|
51
|
+
pool.close()
|
|
52
|
+
original_connect = getattr(store, _ORIGINAL_CONNECT_ATTR, None)
|
|
53
|
+
if original_connect is not None:
|
|
54
|
+
store._connect = original_connect # type: ignore[method-assign]
|
|
55
|
+
delattr(store, _POOL_ATTR)
|
|
56
|
+
if hasattr(store, _ORIGINAL_CONNECT_ATTR):
|
|
57
|
+
delattr(store, _ORIGINAL_CONNECT_ATTR)
|