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.
Files changed (74) hide show
  1. memuron/__init__.py +3 -0
  2. memuron/actions/__init__.py +12 -0
  3. memuron/actions/context.py +63 -0
  4. memuron/actions/helpers.py +88 -0
  5. memuron/actions/memory.py +340 -0
  6. memuron/actions/memory_write.py +290 -0
  7. memuron/actions/nodes.py +340 -0
  8. memuron/actions/registry.py +5 -0
  9. memuron/actions/runtime.py +37 -0
  10. memuron/actions/spaces_documents.py +720 -0
  11. memuron/actions/sync.py +155 -0
  12. memuron/application/__init__.py +1 -0
  13. memuron/application/api.py +206 -0
  14. memuron/application/app.py +103 -0
  15. memuron/application/capabilities.py +82 -0
  16. memuron/application/cli.py +35 -0
  17. memuron/application/config.py +176 -0
  18. memuron/application/mcp.py +44 -0
  19. memuron/application/mcp_oauth.py +290 -0
  20. memuron/application/registry.py +52 -0
  21. memuron/context.py +532 -0
  22. memuron/documents/__init__.py +1 -0
  23. memuron/documents/link_guardian.py +192 -0
  24. memuron/documents/linking.py +292 -0
  25. memuron/documents/parser.py +1152 -0
  26. memuron/documents/storage.py +151 -0
  27. memuron/documents/url_ingest.py +375 -0
  28. memuron/domain/__init__.py +1 -0
  29. memuron/domain/decoders.py +1 -0
  30. memuron/domain/encoders.py +185 -0
  31. memuron/domain/lifecycles.py +8 -0
  32. memuron/domain/limits.py +6 -0
  33. memuron/domain/representations.py +56 -0
  34. memuron/domain/schemas.py +581 -0
  35. memuron/domain/scope_filter.py +104 -0
  36. memuron/graphfs/__init__.py +1 -0
  37. memuron/graphfs/manual.py +635 -0
  38. memuron/graphfs/projection.py +578 -0
  39. memuron/graphfs/query.py +1782 -0
  40. memuron/graphfs/read_model.py +574 -0
  41. memuron/ingest/__init__.py +1 -0
  42. memuron/ingest/guardian.py +213 -0
  43. memuron/ingest/jobs.py +424 -0
  44. memuron/ingest/prompts.py +147 -0
  45. memuron/memory/__init__.py +1 -0
  46. memuron/memory/engine.py +35 -0
  47. memuron/memory/projections.py +452 -0
  48. memuron/memory/recipes.py +3247 -0
  49. memuron/persistence/__init__.py +1 -0
  50. memuron/persistence/db_pool.py +57 -0
  51. memuron/persistence/identity_store.py +918 -0
  52. memuron/persistence/store_helpers.py +16 -0
  53. memuron/search/__init__.py +1 -0
  54. memuron/search/fulltext.py +110 -0
  55. memuron/search/hybrid.py +284 -0
  56. memuron/search/pgvector.py +252 -0
  57. memuron/security/__init__.py +1 -0
  58. memuron/security/auth.py +143 -0
  59. memuron/security/auth_provider.py +119 -0
  60. memuron/security/authorization.py +53 -0
  61. memuron/security/clerk_scopes.py +94 -0
  62. memuron/security/clerk_webhooks.py +61 -0
  63. memuron/security/jwt_tokens.py +53 -0
  64. memuron/security/passwords.py +38 -0
  65. memuron/security/tenant.py +58 -0
  66. memuron/spaces/__init__.py +1 -0
  67. memuron/spaces/model.py +35 -0
  68. memuron/spaces/service.py +155 -0
  69. memuron/sync/__init__.py +25 -0
  70. memuron/sync/folder.py +828 -0
  71. memuron-0.1.1.dist-info/METADATA +242 -0
  72. memuron-0.1.1.dist-info/RECORD +74 -0
  73. memuron-0.1.1.dist-info/WHEEL +4 -0
  74. 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)