mesa-memory 0.9.0__tar.gz

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 (387) hide show
  1. mesa_memory-0.9.0/LICENSE +21 -0
  2. mesa_memory-0.9.0/MANIFEST.in +7 -0
  3. mesa_memory-0.9.0/PKG-INFO +213 -0
  4. mesa_memory-0.9.0/README.md +123 -0
  5. mesa_memory-0.9.0/mesa_api/__init__.py +9 -0
  6. mesa_memory-0.9.0/mesa_api/admission.py +23 -0
  7. mesa_memory-0.9.0/mesa_api/identifier_validation.py +67 -0
  8. mesa_memory-0.9.0/mesa_api/routers/control/router.py +276 -0
  9. mesa_memory-0.9.0/mesa_api/schemas.py +16 -0
  10. mesa_memory-0.9.0/mesa_api/v4_router.py +1624 -0
  11. mesa_memory-0.9.0/mesa_client/__init__.py +27 -0
  12. mesa_memory-0.9.0/mesa_client/client.py +1265 -0
  13. mesa_memory-0.9.0/mesa_mcp/__init__.py +5 -0
  14. mesa_memory-0.9.0/mesa_mcp/adapter.py +226 -0
  15. mesa_memory-0.9.0/mesa_mcp/antigravity_bridge.py +466 -0
  16. mesa_memory-0.9.0/mesa_mcp/antigravity_cli.py +334 -0
  17. mesa_memory-0.9.0/mesa_mcp/bounded_cache.py +133 -0
  18. mesa_memory-0.9.0/mesa_mcp/codex_cli.py +631 -0
  19. mesa_memory-0.9.0/mesa_mcp/codex_hooks.py +161 -0
  20. mesa_memory-0.9.0/mesa_mcp/configuration.py +100 -0
  21. mesa_memory-0.9.0/mesa_mcp/errors.py +24 -0
  22. mesa_memory-0.9.0/mesa_mcp/gateway/__init__.py +1 -0
  23. mesa_memory-0.9.0/mesa_mcp/gateway/anomaly.py +30 -0
  24. mesa_memory-0.9.0/mesa_mcp/gateway/app.py +270 -0
  25. mesa_memory-0.9.0/mesa_mcp/gateway/approval.py +132 -0
  26. mesa_memory-0.9.0/mesa_mcp/gateway/auth.py +32 -0
  27. mesa_memory-0.9.0/mesa_mcp/gateway/codex_transport.py +148 -0
  28. mesa_memory-0.9.0/mesa_mcp/gateway/middleware.py +182 -0
  29. mesa_memory-0.9.0/mesa_mcp/gateway/operations.py +955 -0
  30. mesa_memory-0.9.0/mesa_mcp/gateway/policy/__init__.py +1 -0
  31. mesa_memory-0.9.0/mesa_mcp/gateway/policy/engine.py +80 -0
  32. mesa_memory-0.9.0/mesa_mcp/gateway/policy/simulator.py +45 -0
  33. mesa_memory-0.9.0/mesa_mcp/http_service.py +63 -0
  34. mesa_memory-0.9.0/mesa_mcp/local_cli.py +374 -0
  35. mesa_memory-0.9.0/mesa_mcp/security.py +68 -0
  36. mesa_memory-0.9.0/mesa_mcp/server.py +317 -0
  37. mesa_memory-0.9.0/mesa_mcp/service.py +25 -0
  38. mesa_memory-0.9.0/mesa_mcp/v4_service.py +582 -0
  39. mesa_memory-0.9.0/mesa_mcp/workspace.py +23 -0
  40. mesa_memory-0.9.0/mesa_memory/adapter/base.py +49 -0
  41. mesa_memory-0.9.0/mesa_memory/adapter/claude.py +220 -0
  42. mesa_memory-0.9.0/mesa_memory/adapter/data/cl100k_base.tiktoken +100256 -0
  43. mesa_memory-0.9.0/mesa_memory/adapter/endpoints.py +14 -0
  44. mesa_memory-0.9.0/mesa_memory/adapter/factory.py +288 -0
  45. mesa_memory-0.9.0/mesa_memory/adapter/live.py +274 -0
  46. mesa_memory-0.9.0/mesa_memory/adapter/ollama.py +113 -0
  47. mesa_memory-0.9.0/mesa_memory/adapter/tokenizer.py +98 -0
  48. mesa_memory-0.9.0/mesa_memory/api/middleware.py +91 -0
  49. mesa_memory-0.9.0/mesa_memory/api/server.py +926 -0
  50. mesa_memory-0.9.0/mesa_memory/config.py +993 -0
  51. mesa_memory-0.9.0/mesa_memory/consolidation/loop.py +1179 -0
  52. mesa_memory-0.9.0/mesa_memory/consolidation/parser.py +271 -0
  53. mesa_memory-0.9.0/mesa_memory/consolidation/policy.py +173 -0
  54. mesa_memory-0.9.0/mesa_memory/consolidation/router.py +392 -0
  55. mesa_memory-0.9.0/mesa_memory/consolidation/schemas.py +255 -0
  56. mesa_memory-0.9.0/mesa_memory/consolidation/validator.py +286 -0
  57. mesa_memory-0.9.0/mesa_memory/container_health.py +25 -0
  58. mesa_memory-0.9.0/mesa_memory/context_builder.py +693 -0
  59. mesa_memory-0.9.0/mesa_memory/document_chunking.py +99 -0
  60. mesa_memory-0.9.0/mesa_memory/embedding/__init__.py +21 -0
  61. mesa_memory-0.9.0/mesa_memory/embedding/service.py +752 -0
  62. mesa_memory-0.9.0/mesa_memory/extraction/service.py +614 -0
  63. mesa_memory-0.9.0/mesa_memory/graph/__init__.py +5 -0
  64. mesa_memory-0.9.0/mesa_memory/graph/projector.py +43 -0
  65. mesa_memory-0.9.0/mesa_memory/observability/http.py +122 -0
  66. mesa_memory-0.9.0/mesa_memory/observability/logger.py +259 -0
  67. mesa_memory-0.9.0/mesa_memory/observability/metrics.py +252 -0
  68. mesa_memory-0.9.0/mesa_memory/rebuild_runner.py +505 -0
  69. mesa_memory-0.9.0/mesa_memory/retrieval/adaptive.py +311 -0
  70. mesa_memory-0.9.0/mesa_memory/retrieval/core.py +2 -0
  71. mesa_memory-0.9.0/mesa_memory/retrieval/legal_resolver.py +15 -0
  72. mesa_memory-0.9.0/mesa_memory/runtime_entrypoint.py +49 -0
  73. mesa_memory-0.9.0/mesa_memory/security/admin_cli.py +204 -0
  74. mesa_memory-0.9.0/mesa_memory/security/api_keys.py +267 -0
  75. mesa_memory-0.9.0/mesa_memory/security/input_validation.py +50 -0
  76. mesa_memory-0.9.0/mesa_memory/security/rbac.py +787 -0
  77. mesa_memory-0.9.0/mesa_memory/security/rbac_constants.py +25 -0
  78. mesa_memory-0.9.0/mesa_memory/security/untrusted_memory.py +45 -0
  79. mesa_memory-0.9.0/mesa_memory/utils.py +36 -0
  80. mesa_memory-0.9.0/mesa_memory.egg-info/PKG-INFO +213 -0
  81. mesa_memory-0.9.0/mesa_memory.egg-info/SOURCES.txt +385 -0
  82. mesa_memory-0.9.0/mesa_memory.egg-info/dependency_links.txt +1 -0
  83. mesa_memory-0.9.0/mesa_memory.egg-info/entry_points.txt +8 -0
  84. mesa_memory-0.9.0/mesa_memory.egg-info/requires.txt +53 -0
  85. mesa_memory-0.9.0/mesa_memory.egg-info/top_level.txt +6 -0
  86. mesa_memory-0.9.0/mesa_storage/__init__.py +42 -0
  87. mesa_memory-0.9.0/mesa_storage/alembic/README +1 -0
  88. mesa_memory-0.9.0/mesa_storage/alembic/env.py +133 -0
  89. mesa_memory-0.9.0/mesa_storage/alembic/script.py.mako +28 -0
  90. mesa_memory-0.9.0/mesa_storage/alembic/versions/076eef5d1b6c_add_daily_limits.py +34 -0
  91. mesa_memory-0.9.0/mesa_storage/alembic/versions/087de6628c51_add_mcp_activity_approval.py +81 -0
  92. mesa_memory-0.9.0/mesa_storage/alembic/versions/0a7b8c9d0e1f_scope_catalog_physical_ids.py +42 -0
  93. mesa_memory-0.9.0/mesa_storage/alembic/versions/1e7a061f7f9e_add_mcp_clients_and_bindings.py +61 -0
  94. mesa_memory-0.9.0/mesa_storage/alembic/versions/41402f316580_add_temporal_validity_to_nodes.py +30 -0
  95. mesa_memory-0.9.0/mesa_storage/alembic/versions/4933fb5fd0ea_initial_schema.py +143 -0
  96. mesa_memory-0.9.0/mesa_storage/alembic/versions/9a1b2c3d4e5f_add_v4_catalog_provenance.py +367 -0
  97. mesa_memory-0.9.0/mesa_storage/alembic/versions/9c6c7ae69ed7_add_mcp_policy_rules.py +41 -0
  98. mesa_memory-0.9.0/mesa_storage/alembic/versions/a1d2e3f4b5c6_add_wal_projection_states.py +53 -0
  99. mesa_memory-0.9.0/mesa_storage/alembic/versions/a2b3c4d5e6f7_add_declared_content_hash.py +24 -0
  100. mesa_memory-0.9.0/mesa_storage/alembic/versions/a94df5d14fce_add_connections_and_settings.py +55 -0
  101. mesa_memory-0.9.0/mesa_storage/alembic/versions/b2e3f4a5c6d7_add_session_finalization_journal.py +32 -0
  102. mesa_memory-0.9.0/mesa_storage/alembic/versions/b3c4d5e6f7a8_allow_unknown_revision_content_hash.py +29 -0
  103. mesa_memory-0.9.0/mesa_storage/alembic/versions/bb2355d0cdd4_add_epistemic_columns.py +38 -0
  104. mesa_memory-0.9.0/mesa_storage/alembic/versions/c3d4e5f6a7b8_replace_daily_limit_credential_subject.py +45 -0
  105. mesa_memory-0.9.0/mesa_storage/alembic/versions/c4d5e6f7a8b9_add_assertion_fts_and_representation.py +119 -0
  106. mesa_memory-0.9.0/mesa_storage/alembic/versions/c4f1a8e2d9b0_add_purge_journal.py +62 -0
  107. mesa_memory-0.9.0/mesa_storage/alembic/versions/c5d6e7f8a9b0_add_mcp_operation_ledger.py +58 -0
  108. mesa_memory-0.9.0/mesa_storage/alembic/versions/d4e5f6a7b8c9_add_v4_mutation_ledger.py +96 -0
  109. mesa_memory-0.9.0/mesa_storage/alembic/versions/d5e6f7a8b9c0_add_typed_legal_identity.py +65 -0
  110. mesa_memory-0.9.0/mesa_storage/alembic/versions/d6e7f8a9b0c1_add_mcp_client_credentials.py +35 -0
  111. mesa_memory-0.9.0/mesa_storage/alembic/versions/e7f8a9b0c1d2_add_mcp_codex_profiles.py +33 -0
  112. mesa_memory-0.9.0/mesa_storage/alembic/versions/e9b7c3a1d4f2_add_claim_leases.py +61 -0
  113. mesa_memory-0.9.0/mesa_storage/alembic/versions/f6d4a7b8c9e0_add_dispatch_journal.py +48 -0
  114. mesa_memory-0.9.0/mesa_storage/alembic/versions/f7e5b9c0d1a2_add_dispatch_queue_payload_bytes.py +33 -0
  115. mesa_memory-0.9.0/mesa_storage/alembic/versions/f8a6c0d1e2b3_add_dispatch_completion_receipts.py +44 -0
  116. mesa_memory-0.9.0/mesa_storage/alembic/versions/f8a9b0c1d2e3_generalize_mcp_context_profiles.py +41 -0
  117. mesa_memory-0.9.0/mesa_storage/alembic/versions/f9a0b1c2d3e4_enforce_catalog_scope_integrity.py +44 -0
  118. mesa_memory-0.9.0/mesa_storage/alembic/versions/fa1b2c3d4e5f_add_mcp_credential_expiry.py +16 -0
  119. mesa_memory-0.9.0/mesa_storage/alembic/versions/fb2c3d4e5f6a_add_revision_manifest_hash.py +18 -0
  120. mesa_memory-0.9.0/mesa_storage/alembic/versions/fc3d4e5f6a7b_add_durable_projection_operations.py +172 -0
  121. mesa_memory-0.9.0/mesa_storage/alembic/versions/fd4e5f6a7b8c_add_embedding_provider_identity.py +20 -0
  122. mesa_memory-0.9.0/mesa_storage/alembic/versions/fe5f6a7b8c9d_enforce_active_head_invariant.py +35 -0
  123. mesa_memory-0.9.0/mesa_storage/alembic/versions/ff6a7b8c9d0e_freeze_revision_manifests.py +29 -0
  124. mesa_memory-0.9.0/mesa_storage/alembic.ini +148 -0
  125. mesa_memory-0.9.0/mesa_storage/control/__init__.py +0 -0
  126. mesa_memory-0.9.0/mesa_storage/control/activity_repo.py +159 -0
  127. mesa_memory-0.9.0/mesa_storage/control/approval_repo.py +141 -0
  128. mesa_memory-0.9.0/mesa_storage/control/client_repo.py +175 -0
  129. mesa_memory-0.9.0/mesa_storage/control/codex_profile_repo.py +105 -0
  130. mesa_memory-0.9.0/mesa_storage/control/connection_repo.py +118 -0
  131. mesa_memory-0.9.0/mesa_storage/control/credential_repo.py +196 -0
  132. mesa_memory-0.9.0/mesa_storage/control/policy_repo.py +81 -0
  133. mesa_memory-0.9.0/mesa_storage/control/settings_repo.py +56 -0
  134. mesa_memory-0.9.0/mesa_storage/dao.py +10747 -0
  135. mesa_memory-0.9.0/mesa_storage/embedding_identity.py +157 -0
  136. mesa_memory-0.9.0/mesa_storage/kuzu_migration.py +450 -0
  137. mesa_memory-0.9.0/mesa_storage/kuzu_provider.py +1768 -0
  138. mesa_memory-0.9.0/mesa_storage/kuzu_schema_migration.py +340 -0
  139. mesa_memory-0.9.0/mesa_storage/kuzu_setup.py +207 -0
  140. mesa_memory-0.9.0/mesa_storage/legal_identity.py +473 -0
  141. mesa_memory-0.9.0/mesa_storage/projection_generations.py +728 -0
  142. mesa_memory-0.9.0/mesa_storage/rebuild_cutover.py +573 -0
  143. mesa_memory-0.9.0/mesa_storage/rebuild_health.py +112 -0
  144. mesa_memory-0.9.0/mesa_storage/rebuild_observability.py +92 -0
  145. mesa_memory-0.9.0/mesa_storage/rebuild_preparation.py +533 -0
  146. mesa_memory-0.9.0/mesa_storage/rebuild_replay.py +745 -0
  147. mesa_memory-0.9.0/mesa_storage/recovery.py +503 -0
  148. mesa_memory-0.9.0/mesa_storage/repositories/__init__.py +20 -0
  149. mesa_memory-0.9.0/mesa_storage/repositories/catalog.py +230 -0
  150. mesa_memory-0.9.0/mesa_storage/repositories/operations.py +690 -0
  151. mesa_memory-0.9.0/mesa_storage/representation.py +99 -0
  152. mesa_memory-0.9.0/mesa_storage/retrieval_scope.py +160 -0
  153. mesa_memory-0.9.0/mesa_storage/schema_contract.py +453 -0
  154. mesa_memory-0.9.0/mesa_storage/schemas.py +292 -0
  155. mesa_memory-0.9.0/mesa_storage/sqlite_engine.py +498 -0
  156. mesa_memory-0.9.0/mesa_storage/vector_engine.py +1697 -0
  157. mesa_memory-0.9.0/mesa_storage/writer_lock.py +116 -0
  158. mesa_memory-0.9.0/mesa_workers/__init__.py +6 -0
  159. mesa_memory-0.9.0/mesa_workers/ingestion_worker.py +465 -0
  160. mesa_memory-0.9.0/mesa_workers/projection_worker.py +322 -0
  161. mesa_memory-0.9.0/mesa_workers/supervision.py +124 -0
  162. mesa_memory-0.9.0/pyproject.toml +289 -0
  163. mesa_memory-0.9.0/setup.cfg +4 -0
  164. mesa_memory-0.9.0/tests/test_adapter.py +69 -0
  165. mesa_memory-0.9.0/tests/test_adapter_factory.py +218 -0
  166. mesa_memory-0.9.0/tests/test_adapter_live.py +170 -0
  167. mesa_memory-0.9.0/tests/test_adapters.py +258 -0
  168. mesa_memory-0.9.0/tests/test_adaptive_router.py +170 -0
  169. mesa_memory-0.9.0/tests/test_antigravity_bridge_hardening.py +64 -0
  170. mesa_memory-0.9.0/tests/test_api_control_router_wiring.py +11 -0
  171. mesa_memory-0.9.0/tests/test_api_key_store.py +59 -0
  172. mesa_memory-0.9.0/tests/test_api_logging_contract.py +207 -0
  173. mesa_memory-0.9.0/tests/test_api_schemas.py +43 -0
  174. mesa_memory-0.9.0/tests/test_async_client_auth_contract.py +50 -0
  175. mesa_memory-0.9.0/tests/test_async_lock_loop.py +102 -0
  176. mesa_memory-0.9.0/tests/test_async_storage.py +398 -0
  177. mesa_memory-0.9.0/tests/test_auth_configuration_contract.py +29 -0
  178. mesa_memory-0.9.0/tests/test_catalog_repository_contract.py +60 -0
  179. mesa_memory-0.9.0/tests/test_chaos.py +228 -0
  180. mesa_memory-0.9.0/tests/test_ci_coverage_contracts.py +441 -0
  181. mesa_memory-0.9.0/tests/test_claim_recovery.py +49 -0
  182. mesa_memory-0.9.0/tests/test_client_v4_parity.py +104 -0
  183. mesa_memory-0.9.0/tests/test_codex_cli.py +95 -0
  184. mesa_memory-0.9.0/tests/test_codex_control_api.py +136 -0
  185. mesa_memory-0.9.0/tests/test_codex_gateway_credentials.py +209 -0
  186. mesa_memory-0.9.0/tests/test_codex_streamable_transport.py +94 -0
  187. mesa_memory-0.9.0/tests/test_colab_quickstart.py +39 -0
  188. mesa_memory-0.9.0/tests/test_confidence_revision.py +436 -0
  189. mesa_memory-0.9.0/tests/test_config.py +73 -0
  190. mesa_memory-0.9.0/tests/test_config_edge_cases.py +99 -0
  191. mesa_memory-0.9.0/tests/test_conflict_resolution.py +142 -0
  192. mesa_memory-0.9.0/tests/test_consolidation.py +128 -0
  193. mesa_memory-0.9.0/tests/test_control_activity.py +82 -0
  194. mesa_memory-0.9.0/tests/test_control_activity_approval.py +112 -0
  195. mesa_memory-0.9.0/tests/test_control_approval.py +146 -0
  196. mesa_memory-0.9.0/tests/test_control_client_repo.py +111 -0
  197. mesa_memory-0.9.0/tests/test_control_conn_settings.py +102 -0
  198. mesa_memory-0.9.0/tests/test_control_middleware.py +66 -0
  199. mesa_memory-0.9.0/tests/test_control_policy.py +86 -0
  200. mesa_memory-0.9.0/tests/test_d001_d002_aggregate_state.py +441 -0
  201. mesa_memory-0.9.0/tests/test_d003_d004_rollback_hash.py +283 -0
  202. mesa_memory-0.9.0/tests/test_d005_d006_tenant_migration.py +182 -0
  203. mesa_memory-0.9.0/tests/test_d007_d008_d009_composition_catalog.py +135 -0
  204. mesa_memory-0.9.0/tests/test_d008_model_enabled_runtime_e2e.py +475 -0
  205. mesa_memory-0.9.0/tests/test_d010_d011_d012_parity_bounded_hygiene.py +189 -0
  206. mesa_memory-0.9.0/tests/test_dao.py +365 -0
  207. mesa_memory-0.9.0/tests/test_dao_coverage.py +517 -0
  208. mesa_memory-0.9.0/tests/test_dao_extended.py +213 -0
  209. mesa_memory-0.9.0/tests/test_degraded_sources.py +74 -0
  210. mesa_memory-0.9.0/tests/test_deployment_assets.py +400 -0
  211. mesa_memory-0.9.0/tests/test_document_ingestion.py +513 -0
  212. mesa_memory-0.9.0/tests/test_domain_extraction.py +13 -0
  213. mesa_memory-0.9.0/tests/test_downstream_fence_reconciliation_contract.py +221 -0
  214. mesa_memory-0.9.0/tests/test_durable_dlq_contract.py +197 -0
  215. mesa_memory-0.9.0/tests/test_egress_fence.py +227 -0
  216. mesa_memory-0.9.0/tests/test_embedding_identity_adoption.py +213 -0
  217. mesa_memory-0.9.0/tests/test_embedding_restart_migration_lifecycle.py +377 -0
  218. mesa_memory-0.9.0/tests/test_embedding_service.py +750 -0
  219. mesa_memory-0.9.0/tests/test_embedding_settings_runtime.py +331 -0
  220. mesa_memory-0.9.0/tests/test_external_embedding_lifespan_e2e.py +162 -0
  221. mesa_memory-0.9.0/tests/test_f18_mcp_outputs.py +192 -0
  222. mesa_memory-0.9.0/tests/test_f21_mcp_recall_gateway.py +213 -0
  223. mesa_memory-0.9.0/tests/test_fact_extraction_service.py +519 -0
  224. mesa_memory-0.9.0/tests/test_golden_smoke_set.py +556 -0
  225. mesa_memory-0.9.0/tests/test_graph_optional_runtime.py +249 -0
  226. mesa_memory-0.9.0/tests/test_graph_projector.py +331 -0
  227. mesa_memory-0.9.0/tests/test_graph_text_privacy.py +308 -0
  228. mesa_memory-0.9.0/tests/test_graph_v2_purge.py +65 -0
  229. mesa_memory-0.9.0/tests/test_health_check.py +146 -0
  230. mesa_memory-0.9.0/tests/test_ingestion_worker.py +174 -0
  231. mesa_memory-0.9.0/tests/test_kuzu_isolation.py +523 -0
  232. mesa_memory-0.9.0/tests/test_kuzu_migration_coordinator.py +205 -0
  233. mesa_memory-0.9.0/tests/test_kuzu_performance.py +288 -0
  234. mesa_memory-0.9.0/tests/test_layer_import_contract.py +21 -0
  235. mesa_memory-0.9.0/tests/test_legal_audit.py +75 -0
  236. mesa_memory-0.9.0/tests/test_local_test_contract.py +26 -0
  237. mesa_memory-0.9.0/tests/test_logging_contract.py +186 -0
  238. mesa_memory-0.9.0/tests/test_mcp_api_boundary.py +157 -0
  239. mesa_memory-0.9.0/tests/test_mcp_gateway_operations.py +246 -0
  240. mesa_memory-0.9.0/tests/test_mcp_legacy_gateway_reachability.py +24 -0
  241. mesa_memory-0.9.0/tests/test_mcp_operation_finality.py +135 -0
  242. mesa_memory-0.9.0/tests/test_mcp_provenance.py +43 -0
  243. mesa_memory-0.9.0/tests/test_mcp_sdk_lifecycle.py +118 -0
  244. mesa_memory-0.9.0/tests/test_mcp_stdio_direct.py +131 -0
  245. mesa_memory-0.9.0/tests/test_mcp_v4_service.py +390 -0
  246. mesa_memory-0.9.0/tests/test_mcp_v4_tools.py +75 -0
  247. mesa_memory-0.9.0/tests/test_mesa_benchmark_enhancements.py +48 -0
  248. mesa_memory-0.9.0/tests/test_metrics.py +24 -0
  249. mesa_memory-0.9.0/tests/test_migration_closure.py +771 -0
  250. mesa_memory-0.9.0/tests/test_model_optional_runtime.py +866 -0
  251. mesa_memory-0.9.0/tests/test_mvp_core_smoke_flow.py +468 -0
  252. mesa_memory-0.9.0/tests/test_ollama_adapter.py +175 -0
  253. mesa_memory-0.9.0/tests/test_operation_repository_contract.py +372 -0
  254. mesa_memory-0.9.0/tests/test_operator_approval.py +221 -0
  255. mesa_memory-0.9.0/tests/test_operator_approval_lifecycle.py +285 -0
  256. mesa_memory-0.9.0/tests/test_optional_adapter_imports.py +135 -0
  257. mesa_memory-0.9.0/tests/test_p0_canonical_correction.py +496 -0
  258. mesa_memory-0.9.0/tests/test_p0_config_bootstrap.py +71 -0
  259. mesa_memory-0.9.0/tests/test_p0_context_builder.py +148 -0
  260. mesa_memory-0.9.0/tests/test_p0_cross_agent_vector_ownership.py +47 -0
  261. mesa_memory-0.9.0/tests/test_p0_embedding_contract.py +128 -0
  262. mesa_memory-0.9.0/tests/test_p0_experimental_isolation.py +8 -0
  263. mesa_memory-0.9.0/tests/test_p0_http_sdk_mcp_convergence.py +317 -0
  264. mesa_memory-0.9.0/tests/test_p0_model_disabled_truth.py +121 -0
  265. mesa_memory-0.9.0/tests/test_p0_multi_memory_extraction.py +159 -0
  266. mesa_memory-0.9.0/tests/test_p0_mutation_state_machine.py +130 -0
  267. mesa_memory-0.9.0/tests/test_p0_projection_fencing.py +693 -0
  268. mesa_memory-0.9.0/tests/test_p0_purge_fencing.py +200 -0
  269. mesa_memory-0.9.0/tests/test_p0_ram_oom_safety.py +23 -0
  270. mesa_memory-0.9.0/tests/test_p0_retrieval_count_safety.py +97 -0
  271. mesa_memory-0.9.0/tests/test_p0_retrieval_eligibility.py +165 -0
  272. mesa_memory-0.9.0/tests/test_p0_shared_write_admission.py +148 -0
  273. mesa_memory-0.9.0/tests/test_p0_tenant_accounting.py +112 -0
  274. mesa_memory-0.9.0/tests/test_p0_token_aware_batching.py +43 -0
  275. mesa_memory-0.9.0/tests/test_p0_worker_ownership.py +99 -0
  276. mesa_memory-0.9.0/tests/test_p0_write_hazards.py +54 -0
  277. mesa_memory-0.9.0/tests/test_p0a_batch.py +302 -0
  278. mesa_memory-0.9.0/tests/test_p0b_missing.py +231 -0
  279. mesa_memory-0.9.0/tests/test_p0c_loop.py +79 -0
  280. mesa_memory-0.9.0/tests/test_p402_mesa_sdk.py +277 -0
  281. mesa_memory-0.9.0/tests/test_p403_local_cli.py +343 -0
  282. mesa_memory-0.9.0/tests/test_p4_01_recommended_system_prompt.py +37 -0
  283. mesa_memory-0.9.0/tests/test_pre_final_repair_contracts.py +59 -0
  284. mesa_memory-0.9.0/tests/test_profile_b_compose_env_parity.py +175 -0
  285. mesa_memory-0.9.0/tests/test_projection_generation_contract.py +483 -0
  286. mesa_memory-0.9.0/tests/test_purge_journal_contract.py +302 -0
  287. mesa_memory-0.9.0/tests/test_pytest_exit_contract.py +30 -0
  288. mesa_memory-0.9.0/tests/test_queue_admission_contract.py +279 -0
  289. mesa_memory-0.9.0/tests/test_queue_trusted_root_contract.py +24 -0
  290. mesa_memory-0.9.0/tests/test_r4_durable_policy_snapshot.py +365 -0
  291. mesa_memory-0.9.0/tests/test_r4_extraction_validation_independence.py +401 -0
  292. mesa_memory-0.9.0/tests/test_r4_validation_e2e.py +354 -0
  293. mesa_memory-0.9.0/tests/test_r4_validation_mode_contract.py +139 -0
  294. mesa_memory-0.9.0/tests/test_r4_validation_policy.py +266 -0
  295. mesa_memory-0.9.0/tests/test_r4_validation_state_machine.py +213 -0
  296. mesa_memory-0.9.0/tests/test_r6_context_security_correctness.py +1078 -0
  297. mesa_memory-0.9.0/tests/test_r6_rbac_tenant_isolation.py +826 -0
  298. mesa_memory-0.9.0/tests/test_r7_lifecycle_catalog_correctness.py +1104 -0
  299. mesa_memory-0.9.0/tests/test_r8_integrated_recovery_durability.py +250 -0
  300. mesa_memory-0.9.0/tests/test_rate_limit_subject_contract.py +126 -0
  301. mesa_memory-0.9.0/tests/test_rbac.py +134 -0
  302. mesa_memory-0.9.0/tests/test_rbac_edge_cases.py +231 -0
  303. mesa_memory-0.9.0/tests/test_rbac_leak.py +174 -0
  304. mesa_memory-0.9.0/tests/test_rebuild_observability_contract.py +241 -0
  305. mesa_memory-0.9.0/tests/test_rebuild_preparation_contract.py +333 -0
  306. mesa_memory-0.9.0/tests/test_rebuild_provider_rehearsal.py +354 -0
  307. mesa_memory-0.9.0/tests/test_rebuild_replay_contract.py +1136 -0
  308. mesa_memory-0.9.0/tests/test_rebuild_runner_contract.py +414 -0
  309. mesa_memory-0.9.0/tests/test_recovery_contract.py +401 -0
  310. mesa_memory-0.9.0/tests/test_release_preflight.py +87 -0
  311. mesa_memory-0.9.0/tests/test_retrieval.py +6 -0
  312. mesa_memory-0.9.0/tests/test_retrieval_scope_contract.py +200 -0
  313. mesa_memory-0.9.0/tests/test_runtime_lifecycle_cleanup.py +93 -0
  314. mesa_memory-0.9.0/tests/test_runtime_profiles_contract.py +196 -0
  315. mesa_memory-0.9.0/tests/test_sdk_retry_contract.py +228 -0
  316. mesa_memory-0.9.0/tests/test_single_writer_contract.py +81 -0
  317. mesa_memory-0.9.0/tests/test_soak_profile_a.py +698 -0
  318. mesa_memory-0.9.0/tests/test_sol_r7_adversarial_certification.py +911 -0
  319. mesa_memory-0.9.0/tests/test_sol_r7_unknown_revision_hash.py +53 -0
  320. mesa_memory-0.9.0/tests/test_sqlite_engine_coverage.py +380 -0
  321. mesa_memory-0.9.0/tests/test_storage_unification.py +279 -0
  322. mesa_memory-0.9.0/tests/test_terra_round3_regressions.py +132 -0
  323. mesa_memory-0.9.0/tests/test_tier3_adapter_contract.py +36 -0
  324. mesa_memory-0.9.0/tests/test_tier3_provenance_policy.py +48 -0
  325. mesa_memory-0.9.0/tests/test_tier3_resilience.py +277 -0
  326. mesa_memory-0.9.0/tests/test_tier3_validator.py +653 -0
  327. mesa_memory-0.9.0/tests/test_triple_store_mutation_contract.py +208 -0
  328. mesa_memory-0.9.0/tests/test_typing_ratchet.py +61 -0
  329. mesa_memory-0.9.0/tests/test_untrusted_memory_rendering_paths.py +190 -0
  330. mesa_memory-0.9.0/tests/test_v3_orphan_reconciliation_boundaries.py +161 -0
  331. mesa_memory-0.9.0/tests/test_v4_admin_cli.py +95 -0
  332. mesa_memory-0.9.0/tests/test_v4_adversarial_self_audit.py +876 -0
  333. mesa_memory-0.9.0/tests/test_v4_api_contract.py +1414 -0
  334. mesa_memory-0.9.0/tests/test_v4_bm25_scope_isolation.py +208 -0
  335. mesa_memory-0.9.0/tests/test_v4_bounded_query_planner.py +818 -0
  336. mesa_memory-0.9.0/tests/test_v4_bounded_query_planner_surface.py +261 -0
  337. mesa_memory-0.9.0/tests/test_v4_catalog_ownership.py +655 -0
  338. mesa_memory-0.9.0/tests/test_v4_certification_contracts.py +372 -0
  339. mesa_memory-0.9.0/tests/test_v4_closure_evidence.py +158 -0
  340. mesa_memory-0.9.0/tests/test_v4_comprehensive_audit_hardening.py +427 -0
  341. mesa_memory-0.9.0/tests/test_v4_context_atomic_proof_budget.py +515 -0
  342. mesa_memory-0.9.0/tests/test_v4_context_jurisdiction_boundary.py +173 -0
  343. mesa_memory-0.9.0/tests/test_v4_dispatch_completion_contract.py +184 -0
  344. mesa_memory-0.9.0/tests/test_v4_document_privacy_runtime.py +474 -0
  345. mesa_memory-0.9.0/tests/test_v4_durable_dispatch_contract.py +101 -0
  346. mesa_memory-0.9.0/tests/test_v4_evidence_context_hardening.py +420 -0
  347. mesa_memory-0.9.0/tests/test_v4_final_extraction_legal_audit.py +184 -0
  348. mesa_memory-0.9.0/tests/test_v4_final_legal_audit.py +31 -0
  349. mesa_memory-0.9.0/tests/test_v4_graph_retrieval_hardening.py +1211 -0
  350. mesa_memory-0.9.0/tests/test_v4_graph_timeout_runtime.py +531 -0
  351. mesa_memory-0.9.0/tests/test_v4_hardening_final_verification.py +486 -0
  352. mesa_memory-0.9.0/tests/test_v4_independent_retrieval_audit.py +431 -0
  353. mesa_memory-0.9.0/tests/test_v4_ingestion_contract.py +831 -0
  354. mesa_memory-0.9.0/tests/test_v4_kuzu_runtime_closure.py +258 -0
  355. mesa_memory-0.9.0/tests/test_v4_mutation_agent_isolation.py +39 -0
  356. mesa_memory-0.9.0/tests/test_v4_principal_authorization.py +144 -0
  357. mesa_memory-0.9.0/tests/test_v4_projection_integration.py +284 -0
  358. mesa_memory-0.9.0/tests/test_v4_rebuild_runbook_contract.py +49 -0
  359. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase1.py +286 -0
  360. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase10.py +506 -0
  361. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase2.py +368 -0
  362. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase3.py +345 -0
  363. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase4.py +433 -0
  364. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase5.py +433 -0
  365. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase6.py +434 -0
  366. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase7.py +734 -0
  367. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase8.py +378 -0
  368. mesa_memory-0.9.0/tests/test_v4_retrieval_hardening_phase9.py +741 -0
  369. mesa_memory-0.9.0/tests/test_v4_retry_lifecycle.py +509 -0
  370. mesa_memory-0.9.0/tests/test_v4_round2_holdout.py +232 -0
  371. mesa_memory-0.9.0/tests/test_v4_round2_legal_identity.py +410 -0
  372. mesa_memory-0.9.0/tests/test_v4_rrf_ablation.py +32 -0
  373. mesa_memory-0.9.0/tests/test_v4_sdk_contract.py +211 -0
  374. mesa_memory-0.9.0/tests/test_v4_session_finalization_contract.py +111 -0
  375. mesa_memory-0.9.0/tests/test_v4_session_principal_route_isolation.py +231 -0
  376. mesa_memory-0.9.0/tests/test_v4_temporal_request_schema.py +704 -0
  377. mesa_memory-0.9.0/tests/test_v4_vector_consumer_contract.py +441 -0
  378. mesa_memory-0.9.0/tests/test_vector_engine.py +382 -0
  379. mesa_memory-0.9.0/tests/test_vector_engine_coverage.py +484 -0
  380. mesa_memory-0.9.0/tests/test_vector_failure_semantics.py +148 -0
  381. mesa_memory-0.9.0/tests/test_vector_maintenance.py +251 -0
  382. mesa_memory-0.9.0/tests/test_vector_migration_contract.py +49 -0
  383. mesa_memory-0.9.0/tests/test_vector_model_isolation.py +61 -0
  384. mesa_memory-0.9.0/tests/test_wal_claim_replay_contract.py +123 -0
  385. mesa_memory-0.9.0/tests/test_wal_recovery.py +65 -0
  386. mesa_memory-0.9.0/tests/test_worker_logging_contract.py +74 -0
  387. mesa_memory-0.9.0/tests/test_worker_supervision_contract.py +117 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MESA Core Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include mesa_storage/alembic.ini
2
+ recursive-include mesa_storage/alembic *
3
+ include mesa_memory/adapter/data/cl100k_base.tiktoken
4
+ global-exclude *.py[cod]
5
+ global-exclude __pycache__
6
+ prune mesa_storage/alembic/__pycache__
7
+ prune mesa_storage/alembic/versions/__pycache__
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: mesa-memory
3
+ Version: 0.9.0
4
+ Summary: Enterprise AI agent memory engine
5
+ Author: MESA Core Team
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 MESA Core Team
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/Yasou13/MESA
29
+ Project-URL: Repository, https://github.com/Yasou13/MESA
30
+ Project-URL: Documentation, https://github.com/Yasou13/MESA/tree/main/docs
31
+ Project-URL: Changelog, https://github.com/Yasou13/MESA/blob/main/CHANGELOG.md
32
+ Project-URL: Issues, https://github.com/Yasou13/MESA/issues
33
+ Keywords: ai,memory,agents,knowledge-graph,llm,cognitive
34
+ Classifier: Development Status :: 4 - Beta
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
37
+ Requires-Python: >=3.11
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: aiosqlite>=0.22.0
41
+ Requires-Dist: anyio>=4.0.0
42
+ Requires-Dist: httpx>=0.28.0
43
+ Requires-Dist: mcp<2.0.0,>=1.30.0
44
+ Requires-Dist: cryptography>=42.0.0
45
+ Requires-Dist: uvicorn>=0.29.0
46
+ Requires-Dist: fastapi>=0.139.0
47
+ Requires-Dist: starlette>=1.3.1
48
+ Requires-Dist: slowapi>=0.1.9
49
+ Requires-Dist: prometheus_client>=0.20.0
50
+ Requires-Dist: pydantic>=2.13.0
51
+ Requires-Dist: pydantic-settings>=2.14.0
52
+ Requires-Dist: lancedb>=0.30.0
53
+ Requires-Dist: pyarrow>=24.0.0
54
+ Requires-Dist: kuzu>=0.0.11
55
+ Requires-Dist: numpy>=2.2.0
56
+ Requires-Dist: tenacity>=9.0.0
57
+ Requires-Dist: psutil>=7.0.0
58
+ Requires-Dist: structlog>=24.0.0
59
+ Requires-Dist: python-dotenv>=1.2.0
60
+ Requires-Dist: tiktoken>=0.12.0
61
+ Requires-Dist: alembic>=1.13.0
62
+ Requires-Dist: sqlalchemy>=2.0.51
63
+ Requires-Dist: typing_extensions>=4.16.0
64
+ Provides-Extra: adapters
65
+ Requires-Dist: anthropic>=0.100.0; extra == "adapters"
66
+ Requires-Dist: openai>=2.36.0; extra == "adapters"
67
+ Requires-Dist: ollama>=0.6.1; extra == "adapters"
68
+ Provides-Extra: ml
69
+ Requires-Dist: torch>=2.11.0; extra == "ml"
70
+ Requires-Dist: transformers>=5.8.0; extra == "ml"
71
+ Requires-Dist: tokenizers>=0.22.0; extra == "ml"
72
+ Requires-Dist: safetensors>=0.7.0; extra == "ml"
73
+ Requires-Dist: huggingface_hub>=1.14.0; extra == "ml"
74
+ Requires-Dist: sentence-transformers>=3.0.0; extra == "ml"
75
+ Provides-Extra: loadtest
76
+ Requires-Dist: aiohttp>=3.14.3; extra == "loadtest"
77
+ Requires-Dist: locust>=2.29.0; extra == "loadtest"
78
+ Provides-Extra: dev
79
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
80
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
81
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
82
+ Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
83
+ Requires-Dist: cyclonedx-bom>=5.1.0; extra == "dev"
84
+ Requires-Dist: mypy>=1.10.0; extra == "dev"
85
+ Requires-Dist: black>=24.0.0; extra == "dev"
86
+ Requires-Dist: ruff>=0.4.0; extra == "dev"
87
+ Requires-Dist: datasets>=2.14.0; extra == "dev"
88
+ Requires-Dist: PyYAML>=6.0.0; extra == "dev"
89
+ Dynamic: license-file
90
+
91
+ # MESA — Memory Engine for Structured Agents
92
+
93
+ [![MESA CI](https://github.com/Yasou13/MESA/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Yasou13/MESA/actions/workflows/ci.yml?query=branch%3Amain)
94
+ [![Release](https://img.shields.io/github/v/release/Yasou13/MESA)](https://github.com/Yasou13/MESA/releases/latest)
95
+ [![License: MIT](https://img.shields.io/github/license/Yasou13/MESA)](https://github.com/Yasou13/MESA/blob/main/LICENSE)
96
+ [![Python: 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776AB?logo=python&logoColor=white)](https://github.com/Yasou13/MESA/blob/main/pyproject.toml)
97
+
98
+ MESA is an LLM-independent, source-linked memory engine for AI applications. It stores documents with exact provenance (document, revision, passage) and returns verifiable, scoped evidence over HTTP, Python SDK, and MCP. MESA returns evidence; it never writes the final answer or hallucinates sources.
99
+
100
+ Package version: **0.9.0**. V4 is the current API. Production qualification remains at the release candidate stage: **NO-GO** until the [release gates](https://github.com/Yasou13/MESA/blob/main/docs/release.md) pass.
101
+
102
+ ## Installation
103
+
104
+ ```bash
105
+ pip install "mesa-memory[adapters]"
106
+ ```
107
+
108
+ Supported on Linux and macOS natively. On Windows, run via Docker or WSL.
109
+
110
+ ## Start the server
111
+
112
+ ```bash
113
+ mesa start
114
+ ```
115
+
116
+ Starts the local server on `http://127.0.0.1:8000`, initializes storage at `~/.mesa/data`, and creates credentials at `~/.mesa/credentials.json` (mode 0600).
117
+
118
+ ## Add and search documents
119
+
120
+ In another terminal, add and search documents immediately:
121
+
122
+ ```bash
123
+ mesa add document.txt --source file://document.txt
124
+ mesa search "your query"
125
+ ```
126
+
127
+ ## Python SDK
128
+
129
+ ```python
130
+ from mesa_client import Mesa
131
+
132
+ mesa = Mesa()
133
+ mesa.add(open("document.txt").read(), source="file://document.txt")
134
+ print(mesa.context("your query"))
135
+ ```
136
+
137
+ `Mesa()` uses `MESA_API_KEY` and `MESA_BASE_URL` when they are set, otherwise the local credentials in `~/.mesa/credentials.json`.
138
+
139
+ ## Connect MCP clients
140
+
141
+ Generate a ready-to-paste configuration block for Claude Desktop or any MCP client:
142
+
143
+ ```bash
144
+ mesa mcp-config
145
+ ```
146
+
147
+ ## Internal models (optional)
148
+
149
+ Models stay off by default. Documents are stored and found through BM25 lexical search without any model running. `FactExtractionService` owns canonical V4 extraction when models are enabled.
150
+
151
+ To enable semantic vector search and fact extraction with local Ollama, add to `~/.mesa/.env`:
152
+
153
+ ```bash
154
+ MESA_MODEL_ENABLED=true
155
+ MESA_LLM_MODEL=ollama:qwen2.5:7b
156
+ MESA_EMBEDDING_MODEL=ollama:bge-m3
157
+ ```
158
+
159
+ Local `openai_compatible` servers (such as vLLM started with `--port 8001`, at `MESA_LLM_BASE_URL=http://127.0.0.1:8001/v1`; MESA itself uses port 8000) are also allowed with `MESA_EXTERNAL_PROVIDER_ENABLED=false` on a local endpoint (`localhost`, `127.0.0.1`, `::1`, `host.docker.internal`) and require no API key (D31). For cloud model providers (OpenAI, Anthropic), set `MESA_EXTERNAL_PROVIDER_ENABLED=true` and provide the required API keys.
160
+
161
+ ## Graph toggle
162
+
163
+ To run without the Kùzu graph database, set:
164
+
165
+ ```bash
166
+ MESA_GRAPH_ENABLED=false
167
+ ```
168
+
169
+ GRAPH lanes end `SKIPPED`, and turning the flag back on later backfills the graph at startup.
170
+
171
+ ## Docker
172
+
173
+ Run MESA in a single-user local container (D32):
174
+
175
+ ```bash
176
+ docker compose -f docker-compose.v4.yml up --build -d
177
+ ```
178
+
179
+ Credentials are written to `/var/lib/mesa/credentials.json` in the container volume:
180
+
181
+ ```bash
182
+ docker compose -f docker-compose.v4.yml exec mesa-v4 cat /var/lib/mesa/credentials.json
183
+ docker compose -f docker-compose.v4.yml exec -T mesa-v4 mesa add - --source file://document.txt < document.txt
184
+ docker compose -f docker-compose.v4.yml exec mesa-v4 mesa search "your query"
185
+ ```
186
+
187
+ No variables are required; models and external providers default off. If you set `MESA_API_KEY` and `MESA_PRINCIPAL_ID` for existing HTTP clients, the server accepts that key too, and the `mesa` commands inside the container use it first; add `-e MESA_API_KEY=` after `exec` to use the local credentials instead. The image includes `adapters`; build with `--build-arg MESA_EXTRAS=ml,adapters` to add local sentence-transformers. Ollama defaults to `http://host.docker.internal:11434` (the Docker host).
188
+
189
+ ## Google Colab
190
+
191
+ Run MESA with GPU-accelerated Ollama in Colab:
192
+ [Colab Quickstart](https://github.com/Yasou13/MESA/blob/main/examples/colab_quickstart.ipynb)
193
+
194
+ ## Development
195
+
196
+ ```bash
197
+ uv sync --locked --python 3.11
198
+ ```
199
+
200
+ See [testing](https://github.com/Yasou13/MESA/blob/main/docs/testing.md) for local tests, and [docs/testing.md](https://github.com/Yasou13/MESA/blob/main/docs/testing.md) for test markers.
201
+
202
+ ## Documentation
203
+
204
+ - [Getting Started Guide](https://github.com/Yasou13/MESA/blob/main/docs/getting-started.md)
205
+ - [Configuration Reference](https://github.com/Yasou13/MESA/blob/main/docs/configuration.md)
206
+ - [API Reference](https://github.com/Yasou13/MESA/blob/main/docs/api-reference.md)
207
+ - [MCP Integration Guide](https://github.com/Yasou13/MESA/blob/main/README_MCP.md)
208
+ - [Architecture](https://github.com/Yasou13/MESA/blob/main/ARCHITECTURE.md)
209
+ - [Documentation Index](https://github.com/Yasou13/MESA/blob/main/docs/README.md)
210
+
211
+ ## License
212
+
213
+ [MIT](https://github.com/Yasou13/MESA/blob/main/LICENSE).
@@ -0,0 +1,123 @@
1
+ # MESA — Memory Engine for Structured Agents
2
+
3
+ [![MESA CI](https://github.com/Yasou13/MESA/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Yasou13/MESA/actions/workflows/ci.yml?query=branch%3Amain)
4
+ [![Release](https://img.shields.io/github/v/release/Yasou13/MESA)](https://github.com/Yasou13/MESA/releases/latest)
5
+ [![License: MIT](https://img.shields.io/github/license/Yasou13/MESA)](https://github.com/Yasou13/MESA/blob/main/LICENSE)
6
+ [![Python: 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776AB?logo=python&logoColor=white)](https://github.com/Yasou13/MESA/blob/main/pyproject.toml)
7
+
8
+ MESA is an LLM-independent, source-linked memory engine for AI applications. It stores documents with exact provenance (document, revision, passage) and returns verifiable, scoped evidence over HTTP, Python SDK, and MCP. MESA returns evidence; it never writes the final answer or hallucinates sources.
9
+
10
+ Package version: **0.9.0**. V4 is the current API. Production qualification remains at the release candidate stage: **NO-GO** until the [release gates](https://github.com/Yasou13/MESA/blob/main/docs/release.md) pass.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install "mesa-memory[adapters]"
16
+ ```
17
+
18
+ Supported on Linux and macOS natively. On Windows, run via Docker or WSL.
19
+
20
+ ## Start the server
21
+
22
+ ```bash
23
+ mesa start
24
+ ```
25
+
26
+ Starts the local server on `http://127.0.0.1:8000`, initializes storage at `~/.mesa/data`, and creates credentials at `~/.mesa/credentials.json` (mode 0600).
27
+
28
+ ## Add and search documents
29
+
30
+ In another terminal, add and search documents immediately:
31
+
32
+ ```bash
33
+ mesa add document.txt --source file://document.txt
34
+ mesa search "your query"
35
+ ```
36
+
37
+ ## Python SDK
38
+
39
+ ```python
40
+ from mesa_client import Mesa
41
+
42
+ mesa = Mesa()
43
+ mesa.add(open("document.txt").read(), source="file://document.txt")
44
+ print(mesa.context("your query"))
45
+ ```
46
+
47
+ `Mesa()` uses `MESA_API_KEY` and `MESA_BASE_URL` when they are set, otherwise the local credentials in `~/.mesa/credentials.json`.
48
+
49
+ ## Connect MCP clients
50
+
51
+ Generate a ready-to-paste configuration block for Claude Desktop or any MCP client:
52
+
53
+ ```bash
54
+ mesa mcp-config
55
+ ```
56
+
57
+ ## Internal models (optional)
58
+
59
+ Models stay off by default. Documents are stored and found through BM25 lexical search without any model running. `FactExtractionService` owns canonical V4 extraction when models are enabled.
60
+
61
+ To enable semantic vector search and fact extraction with local Ollama, add to `~/.mesa/.env`:
62
+
63
+ ```bash
64
+ MESA_MODEL_ENABLED=true
65
+ MESA_LLM_MODEL=ollama:qwen2.5:7b
66
+ MESA_EMBEDDING_MODEL=ollama:bge-m3
67
+ ```
68
+
69
+ Local `openai_compatible` servers (such as vLLM started with `--port 8001`, at `MESA_LLM_BASE_URL=http://127.0.0.1:8001/v1`; MESA itself uses port 8000) are also allowed with `MESA_EXTERNAL_PROVIDER_ENABLED=false` on a local endpoint (`localhost`, `127.0.0.1`, `::1`, `host.docker.internal`) and require no API key (D31). For cloud model providers (OpenAI, Anthropic), set `MESA_EXTERNAL_PROVIDER_ENABLED=true` and provide the required API keys.
70
+
71
+ ## Graph toggle
72
+
73
+ To run without the Kùzu graph database, set:
74
+
75
+ ```bash
76
+ MESA_GRAPH_ENABLED=false
77
+ ```
78
+
79
+ GRAPH lanes end `SKIPPED`, and turning the flag back on later backfills the graph at startup.
80
+
81
+ ## Docker
82
+
83
+ Run MESA in a single-user local container (D32):
84
+
85
+ ```bash
86
+ docker compose -f docker-compose.v4.yml up --build -d
87
+ ```
88
+
89
+ Credentials are written to `/var/lib/mesa/credentials.json` in the container volume:
90
+
91
+ ```bash
92
+ docker compose -f docker-compose.v4.yml exec mesa-v4 cat /var/lib/mesa/credentials.json
93
+ docker compose -f docker-compose.v4.yml exec -T mesa-v4 mesa add - --source file://document.txt < document.txt
94
+ docker compose -f docker-compose.v4.yml exec mesa-v4 mesa search "your query"
95
+ ```
96
+
97
+ No variables are required; models and external providers default off. If you set `MESA_API_KEY` and `MESA_PRINCIPAL_ID` for existing HTTP clients, the server accepts that key too, and the `mesa` commands inside the container use it first; add `-e MESA_API_KEY=` after `exec` to use the local credentials instead. The image includes `adapters`; build with `--build-arg MESA_EXTRAS=ml,adapters` to add local sentence-transformers. Ollama defaults to `http://host.docker.internal:11434` (the Docker host).
98
+
99
+ ## Google Colab
100
+
101
+ Run MESA with GPU-accelerated Ollama in Colab:
102
+ [Colab Quickstart](https://github.com/Yasou13/MESA/blob/main/examples/colab_quickstart.ipynb)
103
+
104
+ ## Development
105
+
106
+ ```bash
107
+ uv sync --locked --python 3.11
108
+ ```
109
+
110
+ See [testing](https://github.com/Yasou13/MESA/blob/main/docs/testing.md) for local tests, and [docs/testing.md](https://github.com/Yasou13/MESA/blob/main/docs/testing.md) for test markers.
111
+
112
+ ## Documentation
113
+
114
+ - [Getting Started Guide](https://github.com/Yasou13/MESA/blob/main/docs/getting-started.md)
115
+ - [Configuration Reference](https://github.com/Yasou13/MESA/blob/main/docs/configuration.md)
116
+ - [API Reference](https://github.com/Yasou13/MESA/blob/main/docs/api-reference.md)
117
+ - [MCP Integration Guide](https://github.com/Yasou13/MESA/blob/main/README_MCP.md)
118
+ - [Architecture](https://github.com/Yasou13/MESA/blob/main/ARCHITECTURE.md)
119
+ - [Documentation Index](https://github.com/Yasou13/MESA/blob/main/docs/README.md)
120
+
121
+ ## License
122
+
123
+ [MIT](https://github.com/Yasou13/MESA/blob/main/LICENSE).
@@ -0,0 +1,9 @@
1
+ """Versioned MESA HTTP contracts.
2
+
3
+ ``mesa_api.v4_router`` exposes the breaking full-cognitive catalog, immutable
4
+ session, mutation, provenance, search, replay and rollback contract.
5
+ """
6
+
7
+ from .v4_router import create_v4_router
8
+
9
+ __all__ = ["create_v4_router"]
@@ -0,0 +1,23 @@
1
+ """Shared API admission policy for storage-root mutations."""
2
+
3
+ from fastapi import HTTPException
4
+
5
+ from mesa_storage.dao import MemoryDAO
6
+
7
+
8
+ async def require_mutation_admission(
9
+ dao: MemoryDAO, *, require_projection_consumer: bool = False
10
+ ) -> None:
11
+ """Fail closed while a durable projection rebuild owns the storage root."""
12
+ if require_projection_consumer and dao.canonical_v4_writes_enabled is False:
13
+ raise HTTPException(
14
+ status_code=503,
15
+ detail="canonical_processing_unavailable",
16
+ headers={"Retry-After": "5"},
17
+ )
18
+ if await dao.rebuild_admission.is_pending():
19
+ raise HTTPException(
20
+ status_code=503,
21
+ detail="maintenance_pending",
22
+ headers={"Retry-After": "5"},
23
+ )
@@ -0,0 +1,67 @@
1
+ """Shared public identifier constraints for versioned API boundaries."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from typing import Annotated
7
+
8
+ from pydantic import AfterValidator, Field
9
+
10
+ _RESERVED_SENTINELS = frozenset({"__unset__", "__system__", ""})
11
+ _ALLOWED_IDENTIFIER_PATTERN = re.compile(r"^[a-zA-Z0-9._-]+$")
12
+ _CONTROL_CHAR_PATTERN = re.compile(r"[\x00-\x1f\x7f]")
13
+
14
+
15
+ def validate_public_identifier(
16
+ value: str,
17
+ field_name: str = "identifier",
18
+ *,
19
+ max_length: int = 128,
20
+ restricted_charset: bool = True,
21
+ ) -> str:
22
+ """Validate one caller-controlled public identifier.
23
+
24
+ The 128-character form covers tenant, workspace, dataset, agent, session,
25
+ mutation, and operation identifiers. Source-owned document, revision, and
26
+ chunk identifiers retain their established 256-character boundary.
27
+ """
28
+ if _CONTROL_CHAR_PATTERN.search(value):
29
+ raise ValueError(
30
+ f"{field_name} contains illegal control characters. "
31
+ "Only printable ASCII characters are allowed."
32
+ )
33
+
34
+ stripped = value.strip()
35
+ if stripped in _RESERVED_SENTINELS:
36
+ raise ValueError(f"{field_name} cannot be empty or a reserved value")
37
+ if len(stripped) > max_length:
38
+ raise ValueError(f"{field_name} must be between 1 and {max_length} characters")
39
+ if restricted_charset and not _ALLOWED_IDENTIFIER_PATTERN.fullmatch(stripped):
40
+ raise ValueError(
41
+ f"{field_name} may contain only alphanumeric characters, hyphens, "
42
+ "underscores, or dots"
43
+ )
44
+ return stripped
45
+
46
+
47
+ def _validate_standard_identifier(value: str) -> str:
48
+ return validate_public_identifier(value)
49
+
50
+
51
+ def _validate_source_identifier(value: str) -> str:
52
+ # Document/revision/chunk aliases historically permit external naming
53
+ # punctuation. Preserve that compatibility while enforcing the shared
54
+ # control-character, sentinel, and size boundaries.
55
+ return validate_public_identifier(value, max_length=256, restricted_charset=False)
56
+
57
+
58
+ PublicIdentifier = Annotated[
59
+ str,
60
+ Field(min_length=1, max_length=128),
61
+ AfterValidator(_validate_standard_identifier),
62
+ ]
63
+ SourceIdentifier = Annotated[
64
+ str,
65
+ Field(min_length=1, max_length=256),
66
+ AfterValidator(_validate_source_identifier),
67
+ ]