lorebase-store 0.2.3__tar.gz → 0.3.1__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 (255) hide show
  1. lorebase_store-0.3.1/LICENSE +201 -0
  2. lorebase_store-0.3.1/PKG-INFO +44 -0
  3. lorebase_store-0.3.1/README.md +13 -0
  4. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0001_initial_schema.py +19 -2
  5. lorebase_store-0.3.1/migrations/versions/0038_reconciliation_candidates.py +131 -0
  6. lorebase_store-0.3.1/migrations/versions/0039_reconciliation_lookups.py +42 -0
  7. lorebase_store-0.3.1/migrations/versions/0040_source_written.py +148 -0
  8. lorebase_store-0.3.1/migrations/versions/0041_document_versions.py +121 -0
  9. lorebase_store-0.3.1/migrations/versions/0042_proposal_kinds.py +37 -0
  10. lorebase_store-0.3.1/migrations/versions/0043_source_last_seen.py +36 -0
  11. lorebase_store-0.3.1/migrations/versions/0044_mat_records_object_hash_index.py +85 -0
  12. lorebase_store-0.3.1/migrations/versions/0045_value_index.py +459 -0
  13. lorebase_store-0.3.1/migrations/versions/0046_vocabulary_and_coverage.py +159 -0
  14. lorebase_store-0.3.1/migrations/versions/0047_value_index_limits.py +261 -0
  15. lorebase_store-0.3.1/pyproject.toml +50 -0
  16. lorebase_store-0.3.1/src/lorebase_store/__init__.py +1 -0
  17. lorebase_store-0.3.1/src/lorebase_store/approval_rules.py +114 -0
  18. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/audit.py +2 -1
  19. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/principals.py +16 -0
  20. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/blobs.py +23 -3
  21. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/bundle.py +22 -11
  22. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/commit/changes.py +2 -1
  23. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/commit/pipeline.py +6 -0
  24. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/commit/schema.py +3 -0
  25. lorebase_store-0.3.1/src/lorebase_store/coverage.py +351 -0
  26. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/definer.py +3 -1
  27. lorebase_store-0.3.1/src/lorebase_store/duplicates.py +98 -0
  28. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/embeddings.py +155 -1
  29. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/extraction/materialize.py +7 -3
  30. lorebase_store-0.3.1/src/lorebase_store/extraction/modes.py +318 -0
  31. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/extraction/proposal.py +9 -2
  32. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/gc.py +10 -4
  33. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/jobs.py +63 -0
  34. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/merging/__init__.py +8 -0
  35. lorebase_store-0.3.1/src/lorebase_store/merging/preserved.py +62 -0
  36. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/merging/service.py +226 -9
  37. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/__init__.py +18 -0
  38. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/ingestion.py +163 -10
  39. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/materialized.py +112 -1
  40. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/proposals.py +5 -0
  41. lorebase_store-0.3.1/src/lorebase_store/models/reconciliation.py +62 -0
  42. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/versioning.py +4 -1
  43. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/objectstore.py +1 -0
  44. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/profiling/__init__.py +4 -0
  45. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/profiling/sql_databases.py +31 -19
  46. lorebase_store-0.3.1/src/lorebase_store/reconciliation.py +237 -0
  47. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/__init__.py +32 -0
  48. lorebase_store-0.3.1/src/lorebase_store/repositories/documents.py +637 -0
  49. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/domains.py +5 -1
  50. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/materialized.py +84 -0
  51. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/merges.py +2 -1
  52. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/proposal_items.py +63 -2
  53. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/proposals.py +34 -3
  54. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/provenance.py +12 -0
  55. lorebase_store-0.3.1/src/lorebase_store/repositories/quotes.py +40 -0
  56. lorebase_store-0.3.1/src/lorebase_store/repositories/reconciliation_candidates.py +575 -0
  57. lorebase_store-0.3.1/src/lorebase_store/repositories/source_written.py +351 -0
  58. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/suggestions.py +187 -10
  59. lorebase_store-0.3.1/src/lorebase_store/resolve_misses.py +257 -0
  60. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/settings.py +223 -0
  61. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/storage.py +34 -5
  62. lorebase_store-0.3.1/src/lorebase_store/values.py +931 -0
  63. lorebase_store-0.3.1/tests/test_approval_rules.py +78 -0
  64. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_bundle.py +27 -1
  65. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_definer_checks.py +29 -2
  66. lorebase_store-0.3.1/tests/test_document_quotes.py +43 -0
  67. lorebase_store-0.3.1/tests/test_ef_search.py +64 -0
  68. lorebase_store-0.3.1/tests/test_extraction_modes.py +140 -0
  69. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_gc.py +3 -1
  70. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_models.py +14 -1
  71. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_profiling_sql.py +19 -19
  72. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_reads.py +6 -1
  73. lorebase_store-0.3.1/tests/test_reconciliation_candidates_integration.py +398 -0
  74. lorebase_store-0.3.1/tests/test_reconciliation_wrapping.py +44 -0
  75. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_storage.py +21 -0
  76. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_suggestion_fold.py +50 -1
  77. lorebase_store-0.3.1/tests/test_values.py +810 -0
  78. lorebase_store-0.2.3/PKG-INFO +0 -13
  79. lorebase_store-0.2.3/pyproject.toml +0 -29
  80. lorebase_store-0.2.3/src/lorebase_store/__init__.py +0 -1
  81. lorebase_store-0.2.3/src/lorebase_store/repositories/documents.py +0 -305
  82. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/.gitignore +0 -0
  83. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/alembic.ini +0 -0
  84. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/env.py +0 -0
  85. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/script.py.mako +0 -0
  86. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0002_merge_attempt_details.py +0 -0
  87. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0003_webhooks.py +0 -0
  88. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0004_defer_revision_references.py +0 -0
  89. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0005_security_definer_reads.py +0 -0
  90. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0006_api_key_usage.py +0 -0
  91. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0007_document_extraction.py +0 -0
  92. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0008_definer_argument_checks.py +0 -0
  93. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0009_api_key_networks.py +0 -0
  94. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0010_overlay_branches.py +0 -0
  95. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0011_branch_scoped_search_index.py +0 -0
  96. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0012_overlay_neighborhood_lookups.py +0 -0
  97. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0013_web_sessions.py +0 -0
  98. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0014_embedding_jobs.py +0 -0
  99. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0015_append_only_audit_log.py +0 -0
  100. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0016_sealed_webhook_keys.py +0 -0
  101. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0017_background_branch_copies.py +0 -0
  102. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0018_search_lexicon.py +0 -0
  103. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0019_vault_bindings.py +0 -0
  104. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0020_outbox_consumers.py +0 -0
  105. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0021_schema_suggestions.py +0 -0
  106. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0022_read_audit_and_shared_rate_limits.py +0 -0
  107. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0023_agent_trace.py +0 -0
  108. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0024_embedding_template_keys.py +0 -0
  109. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0025_snapshot_refs.py +0 -0
  110. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0026_plain_reverse_link_index.py +0 -0
  111. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0027_vault_rotation_and_tombstones.py +0 -0
  112. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0028_operation_deferred_events.py +0 -0
  113. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0029_agent_trace_sessions.py +0 -0
  114. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0030_path_fanout.py +0 -0
  115. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0031_branch_builds.py +0 -0
  116. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0032_lineage_revisions.py +0 -0
  117. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0033_vault_moved_tokens.py +0 -0
  118. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0034_inference_endpoint_modes.py +0 -0
  119. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0035_search_truncation.py +0 -0
  120. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0036_lineage_maps.py +0 -0
  121. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/migrations/versions/0037_bm25_search.py +0 -0
  122. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/__init__.py +0 -0
  123. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/api_keys.py +0 -0
  124. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/checkpoints.py +0 -0
  125. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/grants.py +0 -0
  126. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/scope.py +0 -0
  127. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/sessions.py +0 -0
  128. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/unit.py +0 -0
  129. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/auth/usage.py +0 -0
  130. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/bm25.py +0 -0
  131. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/bulk.py +0 -0
  132. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/changefeed.py +0 -0
  133. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/commit/__init__.py +0 -0
  134. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/commit/errors.py +0 -0
  135. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/commit/migrations.py +0 -0
  136. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/db.py +0 -0
  137. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/digests.py +0 -0
  138. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/endpoint_modes.py +0 -0
  139. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/extraction/__init__.py +0 -0
  140. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/extraction/items.py +0 -0
  141. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/extraction/review.py +0 -0
  142. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/indexes.py +0 -0
  143. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/keyring.py +0 -0
  144. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/layout.py +0 -0
  145. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/__init__.py +0 -0
  146. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/apply.py +0 -0
  147. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/background.py +0 -0
  148. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/branch.py +0 -0
  149. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/build.py +0 -0
  150. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/derived.py +0 -0
  151. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/lineage_backfill.py +0 -0
  152. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/links.py +0 -0
  153. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/overlay.py +0 -0
  154. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/paths.py +0 -0
  155. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/rebuild.py +0 -0
  156. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/rows.py +0 -0
  157. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/sensitivity.py +0 -0
  158. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/snapshot.py +0 -0
  159. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/stale.py +0 -0
  160. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/materialize/verify.py +0 -0
  161. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/merging/attempts.py +0 -0
  162. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/merging/lineage.py +0 -0
  163. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/migrations.py +0 -0
  164. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/base.py +0 -0
  165. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/enums.py +0 -0
  166. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/governance.py +0 -0
  167. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/queues.py +0 -0
  168. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/tracing.py +0 -0
  169. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/models/webhooks.py +0 -0
  170. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/nodestore.py +0 -0
  171. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/outbox_events.py +0 -0
  172. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/profiling/delimited.py +0 -0
  173. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/profiling/postgres.py +0 -0
  174. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/profiling/record_files.py +0 -0
  175. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/profiling/records.py +0 -0
  176. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/ratelimit.py +0 -0
  177. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/reads.py +0 -0
  178. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/replicas.py +0 -0
  179. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/changesets.py +0 -0
  180. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/deferred_events.py +0 -0
  181. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/events.py +0 -0
  182. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/index_view.py +0 -0
  183. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/invocations.py +0 -0
  184. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/materializations.py +0 -0
  185. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/refs.py +0 -0
  186. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/revisions.py +0 -0
  187. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/scope.py +0 -0
  188. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/repositories/source_runs.py +0 -0
  189. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/runtime.py +0 -0
  190. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/schema_cache.py +0 -0
  191. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/telemetry.py +0 -0
  192. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/testing.py +0 -0
  193. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/tracing.py +0 -0
  194. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/traverse.py +0 -0
  195. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/vault/__init__.py +0 -0
  196. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/vault/keys.py +0 -0
  197. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/vault/quotes.py +0 -0
  198. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/vault/rotation.py +0 -0
  199. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/vault/settings.py +0 -0
  200. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/vault/store.py +0 -0
  201. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/vault/transfer.py +0 -0
  202. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/webhooks/__init__.py +0 -0
  203. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/webhooks/delivery.py +0 -0
  204. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/webhooks/keys.py +0 -0
  205. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/webhooks/repository.py +0 -0
  206. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/webhooks/settings.py +0 -0
  207. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/src/lorebase_store/webhooks/signing.py +0 -0
  208. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/auth/conftest.py +0 -0
  209. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/auth/test_audit_append_only_integration.py +0 -0
  210. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/auth/test_audit_integration.py +0 -0
  211. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/auth/test_audit_streams_integration.py +0 -0
  212. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/auth/test_principals_api_keys_grants_integration.py +0 -0
  213. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/auth/test_rls_scope.py +0 -0
  214. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/auth/test_sessions_integration.py +0 -0
  215. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/conftest.py +0 -0
  216. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/read_support.py +0 -0
  217. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/support.py +0 -0
  218. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_background_branches.py +0 -0
  219. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_background_pace.py +0 -0
  220. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_bm25.py +0 -0
  221. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_bundle_limits.py +0 -0
  222. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_bundle_vault.py +0 -0
  223. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_bundle_vault_values.py +0 -0
  224. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_commit.py +0 -0
  225. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_commit_helpers.py +0 -0
  226. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_derived.py +0 -0
  227. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_endpoint_modes_integration.py +0 -0
  228. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_extraction_items.py +0 -0
  229. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_indexes.py +0 -0
  230. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_jobs_depth.py +0 -0
  231. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_lineage_backfill.py +0 -0
  232. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_materialize.py +0 -0
  233. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_merging.py +0 -0
  234. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_migration_revisions.py +0 -0
  235. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_nodestore.py +0 -0
  236. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_outbox_events.py +0 -0
  237. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_outbox_integration.py +0 -0
  238. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_overlay.py +0 -0
  239. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_profiling.py +0 -0
  240. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_profiling_record_files.py +0 -0
  241. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_profiling_records.py +0 -0
  242. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_ratelimit_buckets_integration.py +0 -0
  243. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_replicas.py +0 -0
  244. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_repositories.py +0 -0
  245. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_schema_integration.py +0 -0
  246. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_search_bm25.py +0 -0
  247. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_sensitivity_refresh.py +0 -0
  248. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_settings.py +0 -0
  249. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_suggestion_repository_integration.py +0 -0
  250. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_traverse.py +0 -0
  251. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_vault.py +0 -0
  252. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_webhook_keys.py +0 -0
  253. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_webhook_keys_integration.py +0 -0
  254. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_webhook_timeouts_integration.py +0 -0
  255. {lorebase_store-0.2.3 → lorebase_store-0.3.1}/tests/test_webhooks.py +0 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Antonio Antenore
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.5
2
+ Name: lorebase-store
3
+ Version: 0.3.1
4
+ Summary: Lorebase store: persistence, repositories, migrations and materializer
5
+ Project-URL: Homepage, https://github.com/aantenore/lorebase
6
+ Project-URL: Documentation, https://aantenore.github.io/lorebase/
7
+ Project-URL: Repository, https://github.com/aantenore/lorebase
8
+ Project-URL: Changelog, https://github.com/aantenore/lorebase/blob/main/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/aantenore/lorebase/issues
10
+ Author: Antonio Antenore
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: knowledge-graph,mcp,ontology,postgres,versioning
14
+ Classifier: Development Status :: 2 - Pre-Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Database
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: alembic>=1.13
23
+ Requires-Dist: asyncpg>=0.29
24
+ Requires-Dist: cryptography>=42
25
+ Requires-Dist: lorebase-core<0.4,>=0.3
26
+ Requires-Dist: lorebase-platform<0.4,>=0.3
27
+ Requires-Dist: opentelemetry-api>=1.25
28
+ Requires-Dist: pgvector>=0.3
29
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.30
30
+ Description-Content-Type: text/markdown
31
+
32
+ # lorebase-store
33
+
34
+ Part of [Lorebase](https://github.com/aantenore/lorebase), an open-source ontology platform: a versioned, governed knowledge graph on Postgres with git-like branching and three-way merge.
35
+
36
+ The persistence layer of Lorebase on Postgres with pgvector: repositories, Alembic migrations (shipped in the wheel) and the materializer of branch heads.
37
+
38
+ ```sh
39
+ pip install lorebase-store
40
+ ```
41
+
42
+ It is a library of the other Lorebase packages and has no command of its own.
43
+
44
+ Documentation: [Store schema notes](https://aantenore.github.io/lorebase/store-schema-notes/) and the [documentation site](https://aantenore.github.io/lorebase/). License: Apache-2.0.
@@ -0,0 +1,13 @@
1
+ # lorebase-store
2
+
3
+ Part of [Lorebase](https://github.com/aantenore/lorebase), an open-source ontology platform: a versioned, governed knowledge graph on Postgres with git-like branching and three-way merge.
4
+
5
+ The persistence layer of Lorebase on Postgres with pgvector: repositories, Alembic migrations (shipped in the wheel) and the materializer of branch heads.
6
+
7
+ ```sh
8
+ pip install lorebase-store
9
+ ```
10
+
11
+ It is a library of the other Lorebase packages and has no command of its own.
12
+
13
+ Documentation: [Store schema notes](https://aantenore.github.io/lorebase/store-schema-notes/) and the [documentation site](https://aantenore.github.io/lorebase/). License: Apache-2.0.
@@ -7,7 +7,8 @@ Besides the tables, this revision installs what model metadata cannot express:
7
7
  - native enum types, created once and shared by several tables;
8
8
  - `store.layout.hash_partitions` hash partitions on `domain_id`;
9
9
  - lz4 TOAST compression of `tree_nodes.body`;
10
- - the HNSW index of `embeddings` for `store.embeddings.dims`;
10
+ - the HNSW index of `embeddings` for `store.embeddings.dims`, with the build parameters of
11
+ `store.storage` (`hnsw_m`, `hnsw_ef_construction`);
11
12
  - row-level security on `domain_id` keyed to the transaction setting `lorebase.domain_ids`
12
13
  (comma-separated Domain ids), bypassed when `lorebase.bypass_rls` is `on`.
13
14
 
@@ -100,6 +101,21 @@ def _settings() -> tuple[int, int]:
100
101
  return store.layout.hash_partitions, store.embeddings.dims
101
102
 
102
103
 
104
+ def _hnsw_options() -> str:
105
+ """`WITH (...)` of the HNSW index from `store.storage.hnsw_m` and `hnsw_ef_construction`
106
+ (null: pgvector's default)."""
107
+ storage = op.get_context().config.attributes["store_settings"].storage
108
+ options = [
109
+ f"{name} = {value}"
110
+ for name, value in (
111
+ ("m", storage.hnsw_m),
112
+ ("ef_construction", storage.hnsw_ef_construction),
113
+ )
114
+ if value is not None
115
+ ]
116
+ return f" WITH ({', '.join(options)})" if options else ""
117
+
118
+
103
119
  def _create_partitions(partitions: int) -> None:
104
120
  for table in HASH_PARTITIONED:
105
121
  for remainder in range(partitions):
@@ -1024,7 +1040,8 @@ def upgrade() -> None:
1024
1040
  _compress(partitions)
1025
1041
  op.execute(
1026
1042
  f"CREATE INDEX embeddings_hnsw_{dims} ON embeddings "
1027
- f"USING hnsw ((embedding::vector({dims})) vector_cosine_ops) WHERE dims = {dims}"
1043
+ f"USING hnsw ((embedding::vector({dims})) vector_cosine_ops){_hnsw_options()} "
1044
+ f"WHERE dims = {dims}"
1028
1045
  )
1029
1046
  _enable_row_security(partitions)
1030
1047
 
@@ -0,0 +1,131 @@
1
+ """Reconciliation candidates and validity periods on provenance (design 10.6).
2
+
3
+ `provenance.valid_from` and `valid_to` hold the validity period of the values of a `valid_time`
4
+ Attribute; existing entries read as "no period" (metadata-only change, no backfill).
5
+ `reconciliation_candidates` holds contradictions between Sources awaiting a decision, one per
6
+ `(domain_id, branch, fingerprint)`. Under the `domain_isolation` policy like every table with
7
+ a `domain_id`.
8
+
9
+ Revision ID: 0038
10
+ Revises: 0037
11
+ Create Date: 2026-10-29 09:00:00.000000
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from collections.abc import Sequence
17
+
18
+ import sqlalchemy as sa
19
+ from alembic import op
20
+ from sqlalchemy.dialects import postgresql
21
+
22
+ revision: str = "0038"
23
+ down_revision: str | Sequence[str] | None = "0037"
24
+ branch_labels: str | Sequence[str] | None = None
25
+ depends_on: str | Sequence[str] | None = None
26
+
27
+ CANDIDATES = "reconciliation_candidates"
28
+
29
+ DOMAIN_VISIBLE = (
30
+ "current_setting('lorebase.bypass_rls', true) = 'on' "
31
+ "OR domain_id = ANY (string_to_array(current_setting('lorebase.domain_ids', true), ','))"
32
+ )
33
+
34
+
35
+ def upgrade() -> None:
36
+ for column in ("valid_from", "valid_to"):
37
+ op.add_column("provenance", sa.Column(column, sa.DateTime(timezone=True), nullable=True))
38
+ op.create_table(
39
+ CANDIDATES,
40
+ sa.Column("domain_id", sa.Text(), nullable=False),
41
+ sa.Column("id", sa.Text(), nullable=False),
42
+ sa.Column("branch", sa.Text(), nullable=False),
43
+ sa.Column("type", sa.Text(), nullable=False),
44
+ sa.Column("status", sa.Text(), server_default=sa.text("'open'"), nullable=False),
45
+ sa.Column("fingerprint", sa.LargeBinary(), nullable=False),
46
+ sa.Column("kind_id", sa.Text(), nullable=False),
47
+ sa.Column("keys", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
48
+ sa.Column("attribute_id", sa.Text(), nullable=True),
49
+ sa.Column(
50
+ "claims",
51
+ postgresql.JSONB(astext_type=sa.Text()),
52
+ server_default=sa.text("'[]'::jsonb"),
53
+ nullable=False,
54
+ ),
55
+ sa.Column(
56
+ "signals",
57
+ postgresql.JSONB(astext_type=sa.Text()),
58
+ server_default=sa.text("'{}'::jsonb"),
59
+ nullable=False,
60
+ ),
61
+ sa.Column("claim_count", sa.Integer(), server_default=sa.text("0"), nullable=False),
62
+ sa.Column("proposal_id", sa.Text(), nullable=True),
63
+ sa.Column("decision", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
64
+ sa.Column("decided_by", sa.Text(), nullable=True),
65
+ sa.Column("decided_at", sa.DateTime(timezone=True), nullable=True),
66
+ sa.Column(
67
+ "created_at",
68
+ sa.DateTime(timezone=True),
69
+ server_default=sa.text("now()"),
70
+ nullable=False,
71
+ ),
72
+ sa.Column(
73
+ "updated_at",
74
+ sa.DateTime(timezone=True),
75
+ server_default=sa.text("now()"),
76
+ nullable=False,
77
+ ),
78
+ sa.CheckConstraint(
79
+ "octet_length(fingerprint) = 32",
80
+ name=op.f("ck_reconciliation_candidates_fingerprint_h32"),
81
+ ),
82
+ sa.CheckConstraint(
83
+ "type IN ('duplicate', 'contradiction', 'superseded', 'stale')",
84
+ name=op.f("ck_reconciliation_candidates_type"),
85
+ ),
86
+ sa.CheckConstraint(
87
+ "status IN ('open', 'resolved', 'dismissed', 'obsolete')",
88
+ name=op.f("ck_reconciliation_candidates_status"),
89
+ ),
90
+ sa.ForeignKeyConstraint(
91
+ ["domain_id"],
92
+ ["domains.id"],
93
+ name=op.f("fk_reconciliation_candidates_domain_id_domains"),
94
+ ondelete="CASCADE",
95
+ ),
96
+ sa.PrimaryKeyConstraint("domain_id", "id", name=op.f("pk_reconciliation_candidates")),
97
+ sa.UniqueConstraint(
98
+ "domain_id",
99
+ "branch",
100
+ "fingerprint",
101
+ name=op.f("uq_reconciliation_candidates_domain_id_branch_fingerprint"),
102
+ ),
103
+ )
104
+ op.create_index(
105
+ op.f("ix_reconciliation_candidates_domain_id_branch_status_type"),
106
+ CANDIDATES,
107
+ ["domain_id", "branch", "status", "type"],
108
+ )
109
+ op.create_index(
110
+ op.f("ix_reconciliation_candidates_domain_id_branch_kind_id_keys"),
111
+ CANDIDATES,
112
+ ["domain_id", "branch", "kind_id", "keys"],
113
+ )
114
+ op.execute(f"ALTER TABLE {CANDIDATES} ENABLE ROW LEVEL SECURITY")
115
+ op.execute(f"ALTER TABLE {CANDIDATES} FORCE ROW LEVEL SECURITY")
116
+ op.execute(
117
+ f"CREATE POLICY domain_isolation ON {CANDIDATES} "
118
+ f"USING ({DOMAIN_VISIBLE}) WITH CHECK ({DOMAIN_VISIBLE})"
119
+ )
120
+
121
+
122
+ def downgrade() -> None:
123
+ op.drop_index(
124
+ op.f("ix_reconciliation_candidates_domain_id_branch_kind_id_keys"), table_name=CANDIDATES
125
+ )
126
+ op.drop_index(
127
+ op.f("ix_reconciliation_candidates_domain_id_branch_status_type"), table_name=CANDIDATES
128
+ )
129
+ op.drop_table(CANDIDATES)
130
+ for column in ("valid_to", "valid_from"):
131
+ op.drop_column("provenance", column)
@@ -0,0 +1,42 @@
1
+ """Indexes of reconciliation candidate lookups (design 10.6).
2
+
3
+ `(domain_id, proposal_id)` serves the `reconciliation` Proposal check and the settlement of a
4
+ merged Proposal; a GIN index (`jsonb_path_ops`) on `keys` serves the containment test of the
5
+ Record page (`keys @> '["key"]'`), which the btree index on `(domain_id, branch, kind_id,
6
+ keys)` cannot answer.
7
+
8
+ Revision ID: 0039
9
+ Revises: 0038
10
+ Create Date: 2026-10-29 18:00:00.000000
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from collections.abc import Sequence
16
+
17
+ from alembic import op
18
+
19
+ revision: str = "0039"
20
+ down_revision: str | Sequence[str] | None = "0038"
21
+ branch_labels: str | Sequence[str] | None = None
22
+ depends_on: str | Sequence[str] | None = None
23
+
24
+ CANDIDATES = "reconciliation_candidates"
25
+ BY_PROPOSAL = "ix_reconciliation_candidates_domain_id_proposal_id"
26
+ BY_KEY = "ix_reconciliation_candidates_keys"
27
+
28
+
29
+ def upgrade() -> None:
30
+ op.create_index(BY_PROPOSAL, CANDIDATES, ["domain_id", "proposal_id"])
31
+ op.create_index(
32
+ BY_KEY,
33
+ CANDIDATES,
34
+ ["keys"],
35
+ postgresql_using="gin",
36
+ postgresql_ops={"keys": "jsonb_path_ops"},
37
+ )
38
+
39
+
40
+ def downgrade() -> None:
41
+ op.drop_index(BY_KEY, table_name=CANDIDATES)
42
+ op.drop_index(BY_PROPOSAL, table_name=CANDIDATES)
@@ -0,0 +1,148 @@
1
+ """Last-written state of Sources (design 9.1 "Corrections that stick").
2
+
3
+ `source_written` holds, per Source, target branch, Kind or Relation and key, the hashes of the
4
+ values the Source last wrote and the Source branch Revision that holds them;
5
+ `source_written_pending` the state a run carries in its open Proposal, moved to
6
+ `source_written` when the Proposal merges. Both are empty at first: Sources seed their state
7
+ on their next run. Under the `domain_isolation` policy like every table with a `domain_id`.
8
+
9
+ Revision ID: 0040
10
+ Revises: 0039
11
+ Create Date: 2026-10-29 20:00:00.000000
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from collections.abc import Sequence
17
+
18
+ import sqlalchemy as sa
19
+ from alembic import op
20
+ from sqlalchemy.dialects import postgresql
21
+
22
+ revision: str = "0040"
23
+ down_revision: str | Sequence[str] | None = "0039"
24
+ branch_labels: str | Sequence[str] | None = None
25
+ depends_on: str | Sequence[str] | None = None
26
+
27
+ WRITTEN = "source_written"
28
+ PENDING = "source_written_pending"
29
+
30
+ DOMAIN_VISIBLE = (
31
+ "current_setting('lorebase.bypass_rls', true) = 'on' "
32
+ "OR domain_id = ANY (string_to_array(current_setting('lorebase.domain_ids', true), ','))"
33
+ )
34
+
35
+
36
+ def _state_columns() -> list[sa.Column[object]]:
37
+ return [
38
+ sa.Column(
39
+ "written",
40
+ postgresql.JSONB(astext_type=sa.Text()),
41
+ server_default=sa.text("'{}'::jsonb"),
42
+ nullable=False,
43
+ ),
44
+ sa.Column("revision_id", sa.LargeBinary(), nullable=True),
45
+ sa.Column(
46
+ "value_revisions",
47
+ postgresql.JSONB(astext_type=sa.Text()),
48
+ server_default=sa.text("'{}'::jsonb"),
49
+ nullable=False,
50
+ ),
51
+ sa.Column("deleted", sa.Boolean(), server_default=sa.text("false"), nullable=False),
52
+ ]
53
+
54
+
55
+ def _tail_columns() -> list[sa.Column[object]]:
56
+ return [
57
+ sa.Column("run_id", sa.Text(), nullable=False),
58
+ sa.Column(
59
+ "updated_at",
60
+ sa.DateTime(timezone=True),
61
+ server_default=sa.text("now()"),
62
+ nullable=False,
63
+ ),
64
+ ]
65
+
66
+
67
+ def _isolate(table: str) -> None:
68
+ op.execute(f"ALTER TABLE {table} ENABLE ROW LEVEL SECURITY")
69
+ op.execute(f"ALTER TABLE {table} FORCE ROW LEVEL SECURITY")
70
+ op.execute(
71
+ f"CREATE POLICY domain_isolation ON {table} "
72
+ f"USING ({DOMAIN_VISIBLE}) WITH CHECK ({DOMAIN_VISIBLE})"
73
+ )
74
+
75
+
76
+ def upgrade() -> None:
77
+ op.create_table(
78
+ WRITTEN,
79
+ sa.Column("domain_id", sa.Text(), nullable=False),
80
+ sa.Column("source_id", sa.Text(), nullable=False),
81
+ sa.Column("target_branch", sa.Text(), nullable=False),
82
+ sa.Column("element", sa.Text(), nullable=False),
83
+ sa.Column("key", sa.Text(), nullable=False),
84
+ *_state_columns(),
85
+ *_tail_columns(),
86
+ sa.CheckConstraint(
87
+ "octet_length(revision_id) = 32", name=op.f("ck_source_written_revision_id_h32")
88
+ ),
89
+ sa.ForeignKeyConstraint(
90
+ ["domain_id"],
91
+ ["domains.id"],
92
+ name=op.f("fk_source_written_domain_id_domains"),
93
+ ondelete="CASCADE",
94
+ ),
95
+ sa.PrimaryKeyConstraint(
96
+ "domain_id",
97
+ "source_id",
98
+ "target_branch",
99
+ "element",
100
+ "key",
101
+ name=op.f("pk_source_written"),
102
+ ),
103
+ )
104
+ op.create_table(
105
+ PENDING,
106
+ sa.Column("domain_id", sa.Text(), nullable=False),
107
+ sa.Column("proposal_id", sa.Text(), nullable=False),
108
+ sa.Column("element", sa.Text(), nullable=False),
109
+ sa.Column("key", sa.Text(), nullable=False),
110
+ sa.Column("source_id", sa.Text(), nullable=False),
111
+ sa.Column("target_branch", sa.Text(), nullable=False),
112
+ *_state_columns(),
113
+ sa.Column(
114
+ "preserve",
115
+ postgresql.JSONB(astext_type=sa.Text()),
116
+ server_default=sa.text("'[]'::jsonb"),
117
+ nullable=False,
118
+ ),
119
+ *_tail_columns(),
120
+ sa.CheckConstraint(
121
+ "octet_length(revision_id) = 32",
122
+ name=op.f("ck_source_written_pending_revision_id_h32"),
123
+ ),
124
+ sa.ForeignKeyConstraint(
125
+ ["domain_id"],
126
+ ["domains.id"],
127
+ name=op.f("fk_source_written_pending_domain_id_domains"),
128
+ ondelete="CASCADE",
129
+ ),
130
+ sa.PrimaryKeyConstraint(
131
+ "domain_id", "proposal_id", "element", "key", name=op.f("pk_source_written_pending")
132
+ ),
133
+ )
134
+ op.create_index(
135
+ op.f("ix_source_written_pending_domain_id_source_id_target_branch"),
136
+ PENDING,
137
+ ["domain_id", "source_id", "target_branch"],
138
+ )
139
+ _isolate(WRITTEN)
140
+ _isolate(PENDING)
141
+
142
+
143
+ def downgrade() -> None:
144
+ op.drop_index(
145
+ op.f("ix_source_written_pending_domain_id_source_id_target_branch"), table_name=PENDING
146
+ )
147
+ op.drop_table(PENDING)
148
+ op.drop_table(WRITTEN)