@lix-js/sdk 0.6.0-preview.4 → 0.6.0-preview.5

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 (234) hide show
  1. package/README.md +1 -1
  2. package/SKILL.md +65 -64
  3. package/dist/engine-wasm/index.js +4 -4
  4. package/dist/engine-wasm/wasm/lix_engine.d.ts +5 -5
  5. package/dist/engine-wasm/wasm/lix_engine.js +130 -118
  6. package/dist/engine-wasm/wasm/lix_engine.wasm +0 -0
  7. package/dist/engine-wasm/wasm/lix_engine.wasm.d.ts +9 -8
  8. package/dist/generated/builtin-schemas.d.ts +69 -69
  9. package/dist/generated/builtin-schemas.js +94 -94
  10. package/dist/open-lix.d.ts +33 -26
  11. package/dist/open-lix.js +10 -10
  12. package/dist/sqlite/index.js +86 -30
  13. package/dist-engine-src/README.md +3 -3
  14. package/dist-engine-src/src/backend/capabilities.rs +67 -0
  15. package/dist-engine-src/src/backend/conformance/baseline.rs +1127 -0
  16. package/dist-engine-src/src/backend/conformance/factory.rs +93 -0
  17. package/dist-engine-src/src/backend/conformance/failure_tests.rs +608 -0
  18. package/dist-engine-src/src/backend/conformance/fixtures.rs +26 -0
  19. package/dist-engine-src/src/backend/conformance/mod.rs +75 -0
  20. package/dist-engine-src/src/backend/conformance/model.rs +28 -0
  21. package/dist-engine-src/src/backend/conformance/model_based.rs +257 -0
  22. package/dist-engine-src/src/backend/conformance/persistence.rs +204 -0
  23. package/dist-engine-src/src/backend/conformance/projection.rs +21 -0
  24. package/dist-engine-src/src/backend/conformance/pushdown.rs +24 -0
  25. package/dist-engine-src/src/backend/conformance/runner.rs +90 -0
  26. package/dist-engine-src/src/backend/conformance/scan.rs +24 -0
  27. package/dist-engine-src/src/backend/conformance/write.rs +16 -0
  28. package/dist-engine-src/src/backend/error.rs +94 -0
  29. package/dist-engine-src/src/backend/in_memory.rs +670 -0
  30. package/dist-engine-src/src/backend/mod.rs +36 -9
  31. package/dist-engine-src/src/backend/predicate.rs +80 -0
  32. package/dist-engine-src/src/backend/traits.rs +260 -0
  33. package/dist-engine-src/src/backend/types.rs +224 -81
  34. package/dist-engine-src/src/binary_cas/context.rs +8 -8
  35. package/dist-engine-src/src/binary_cas/kv.rs +234 -259
  36. package/dist-engine-src/src/{version → branch}/context.rs +12 -12
  37. package/dist-engine-src/src/branch/lifecycle.rs +221 -0
  38. package/dist-engine-src/src/branch/mod.rs +13 -0
  39. package/dist-engine-src/src/branch/refs.rs +321 -0
  40. package/dist-engine-src/src/branch/stage_rows.rs +67 -0
  41. package/dist-engine-src/src/branch/types.rs +21 -0
  42. package/dist-engine-src/src/catalog/context.rs +18 -18
  43. package/dist-engine-src/src/catalog/snapshot.rs +8 -8
  44. package/dist-engine-src/src/changelog/bench_support.rs +785 -0
  45. package/dist-engine-src/src/changelog/change.rs +1 -0
  46. package/dist-engine-src/src/changelog/codec.rs +497 -0
  47. package/dist-engine-src/src/changelog/commit.rs +1 -0
  48. package/dist-engine-src/src/changelog/context.rs +1614 -0
  49. package/dist-engine-src/src/changelog/mod.rs +29 -0
  50. package/dist-engine-src/src/changelog/store.rs +163 -0
  51. package/dist-engine-src/src/changelog/test_support.rs +54 -0
  52. package/dist-engine-src/src/changelog/types.rs +213 -0
  53. package/dist-engine-src/src/commit_graph/context.rs +317 -274
  54. package/dist-engine-src/src/commit_graph/mod.rs +2 -4
  55. package/dist-engine-src/src/commit_graph/types.rs +22 -42
  56. package/dist-engine-src/src/commit_graph/walker.rs +133 -103
  57. package/dist-engine-src/src/common/error.rs +52 -18
  58. package/dist-engine-src/src/common/identity.rs +2 -2
  59. package/dist-engine-src/src/common/mod.rs +1 -1
  60. package/dist-engine-src/src/domain.rs +42 -46
  61. package/dist-engine-src/src/engine.rs +74 -96
  62. package/dist-engine-src/src/{entity_identity.rs → entity_pk.rs} +89 -92
  63. package/dist-engine-src/src/functions/context.rs +56 -52
  64. package/dist-engine-src/src/functions/state.rs +51 -52
  65. package/dist-engine-src/src/init.rs +288 -154
  66. package/dist-engine-src/src/json_store/context.rs +15 -266
  67. package/dist-engine-src/src/json_store/mod.rs +26 -0
  68. package/dist-engine-src/src/json_store/store.rs +103 -718
  69. package/dist-engine-src/src/json_store/types.rs +4 -9
  70. package/dist-engine-src/src/lib.rs +49 -19
  71. package/dist-engine-src/src/live_state/context.rs +654 -790
  72. package/dist-engine-src/src/live_state/mod.rs +9 -3
  73. package/dist-engine-src/src/live_state/overlay.rs +4 -4
  74. package/dist-engine-src/src/live_state/types.rs +30 -21
  75. package/dist-engine-src/src/live_state/visibility.rs +514 -71
  76. package/dist-engine-src/src/plugin/install.rs +48 -48
  77. package/dist-engine-src/src/plugin/manifest.rs +7 -7
  78. package/dist-engine-src/src/plugin/materializer.rs +0 -275
  79. package/dist-engine-src/src/plugin/plugin_manifest.json +4 -3
  80. package/dist-engine-src/src/schema/builtin/lix_binary_blob_ref.json +2 -2
  81. package/dist-engine-src/src/schema/builtin/lix_branch_descriptor.json +34 -0
  82. package/dist-engine-src/src/schema/builtin/lix_branch_ref.json +48 -0
  83. package/dist-engine-src/src/schema/builtin/lix_change.json +3 -3
  84. package/dist-engine-src/src/schema/builtin/lix_commit.json +1 -1
  85. package/dist-engine-src/src/schema/builtin/lix_label_assignment.json +6 -6
  86. package/dist-engine-src/src/schema/builtin/mod.rs +18 -20
  87. package/dist-engine-src/src/schema/compatibility.rs +11 -11
  88. package/dist-engine-src/src/schema/definition.json +2 -2
  89. package/dist-engine-src/src/schema/definition.rs +5 -5
  90. package/dist-engine-src/src/schema/key.rs +3 -3
  91. package/dist-engine-src/src/schema/mod.rs +1 -1
  92. package/dist-engine-src/src/schema/tests.rs +18 -18
  93. package/dist-engine-src/src/session/context.rs +803 -148
  94. package/dist-engine-src/src/session/create_branch.rs +94 -0
  95. package/dist-engine-src/src/session/execute.rs +223 -83
  96. package/dist-engine-src/src/session/merge/analysis.rs +9 -3
  97. package/dist-engine-src/src/session/merge/{version.rs → branch.rs} +119 -129
  98. package/dist-engine-src/src/session/merge/conflicts.rs +2 -2
  99. package/dist-engine-src/src/session/merge/mod.rs +5 -6
  100. package/dist-engine-src/src/session/merge/stats.rs +7 -11
  101. package/dist-engine-src/src/session/mod.rs +15 -12
  102. package/dist-engine-src/src/session/switch_branch.rs +113 -0
  103. package/dist-engine-src/src/session/transaction.rs +495 -14
  104. package/dist-engine-src/src/sql2/{classify.rs → bind/classify.rs} +3 -75
  105. package/dist-engine-src/src/sql2/bind/error.rs +5 -0
  106. package/dist-engine-src/src/sql2/bind/expr.rs +29 -0
  107. package/dist-engine-src/src/sql2/bind/mod.rs +12 -0
  108. package/dist-engine-src/src/sql2/{udfs/public_call.rs → bind/public_udf.rs} +71 -3
  109. package/dist-engine-src/src/sql2/bind/read.rs +65 -0
  110. package/dist-engine-src/src/sql2/bind/statement.rs +2236 -0
  111. package/dist-engine-src/src/sql2/bind/table.rs +273 -0
  112. package/dist-engine-src/src/sql2/bind/write.rs +86 -0
  113. package/dist-engine-src/src/sql2/branch_scope.rs +436 -0
  114. package/dist-engine-src/src/sql2/catalog/capability.rs +20 -0
  115. package/dist-engine-src/src/sql2/catalog/entity_surface.rs +296 -0
  116. package/dist-engine-src/src/sql2/catalog/mod.rs +15 -0
  117. package/dist-engine-src/src/sql2/catalog/registry.rs +556 -0
  118. package/dist-engine-src/src/sql2/catalog/schema.rs +88 -0
  119. package/dist-engine-src/src/sql2/catalog/surface.rs +41 -0
  120. package/dist-engine-src/src/sql2/change_materialization.rs +122 -0
  121. package/dist-engine-src/src/sql2/context.rs +36 -30
  122. package/dist-engine-src/src/sql2/error.rs +1 -1
  123. package/dist-engine-src/src/sql2/exec/bound_public_write.rs +1593 -0
  124. package/dist-engine-src/src/sql2/exec/datafusion.rs +5266 -0
  125. package/dist-engine-src/src/sql2/exec/fast_write.rs +82 -0
  126. package/dist-engine-src/src/sql2/exec/mod.rs +24 -0
  127. package/dist-engine-src/src/sql2/exec/write.rs +661 -0
  128. package/dist-engine-src/src/sql2/filesystem_planner.rs +72 -77
  129. package/dist-engine-src/src/sql2/filesystem_visibility.rs +21 -21
  130. package/dist-engine-src/src/sql2/history_projection.rs +8 -8
  131. package/dist-engine-src/src/sql2/history_route.rs +35 -31
  132. package/dist-engine-src/src/sql2/mod.rs +28 -23
  133. package/dist-engine-src/src/sql2/optimize/datafusion.rs +1 -0
  134. package/dist-engine-src/src/sql2/optimize/mod.rs +2 -0
  135. package/dist-engine-src/src/sql2/optimize/simple_write.rs +116 -0
  136. package/dist-engine-src/src/sql2/parse/mod.rs +69 -0
  137. package/dist-engine-src/src/sql2/parse/normalize.rs +1 -0
  138. package/dist-engine-src/src/sql2/plan/branch_scope.rs +24 -0
  139. package/dist-engine-src/src/sql2/plan/mod.rs +5 -0
  140. package/dist-engine-src/src/sql2/plan/predicate.rs +22 -0
  141. package/dist-engine-src/src/sql2/plan/write.rs +147 -0
  142. package/dist-engine-src/src/sql2/predicate_typecheck.rs +258 -0
  143. package/dist-engine-src/src/sql2/{version_provider.rs → providers/branch.rs} +218 -214
  144. package/dist-engine-src/src/sql2/{change_provider.rs → providers/change.rs} +156 -42
  145. package/dist-engine-src/src/sql2/{directory_provider.rs → providers/directory.rs} +291 -322
  146. package/dist-engine-src/src/sql2/{directory_history_provider.rs → providers/directory_history.rs} +56 -42
  147. package/dist-engine-src/src/sql2/providers/entity.rs +1484 -0
  148. package/dist-engine-src/src/sql2/{entity_history_provider.rs → providers/entity_history.rs} +43 -31
  149. package/dist-engine-src/src/sql2/{file_provider.rs → providers/file.rs} +323 -316
  150. package/dist-engine-src/src/sql2/{file_history_provider.rs → providers/file_history.rs} +60 -46
  151. package/dist-engine-src/src/sql2/{history_provider.rs → providers/history.rs} +46 -32
  152. package/dist-engine-src/src/sql2/{lix_state_provider.rs → providers/lix_state.rs} +359 -329
  153. package/dist-engine-src/src/sql2/providers/mod.rs +508 -0
  154. package/dist-engine-src/src/sql2/read_only.rs +2 -2
  155. package/dist-engine-src/src/sql2/session.rs +47 -96
  156. package/dist-engine-src/src/sql2/storage/constraints.rs +1 -0
  157. package/dist-engine-src/src/sql2/storage/mod.rs +1 -0
  158. package/dist-engine-src/src/sql2/test_support/differential.rs +712 -0
  159. package/dist-engine-src/src/sql2/test_support/generators.rs +354 -0
  160. package/dist-engine-src/src/sql2/test_support/mod.rs +2 -0
  161. package/dist-engine-src/src/sql2/udfs/{lix_active_version_commit_id.rs → lix_active_branch_commit_id.rs} +7 -7
  162. package/dist-engine-src/src/sql2/udfs/mod.rs +3 -6
  163. package/dist-engine-src/src/sql2/write_normalization.rs +45 -22
  164. package/dist-engine-src/src/storage/conformance.rs +399 -0
  165. package/dist-engine-src/src/storage/context.rs +552 -288
  166. package/dist-engine-src/src/storage/mod.rs +48 -10
  167. package/dist-engine-src/src/storage/point.rs +440 -0
  168. package/dist-engine-src/src/storage/read_scope.rs +43 -64
  169. package/dist-engine-src/src/storage/reader.rs +867 -0
  170. package/dist-engine-src/src/storage/scan.rs +784 -0
  171. package/dist-engine-src/src/storage/spaces.rs +236 -0
  172. package/dist-engine-src/src/storage/stats.rs +80 -0
  173. package/dist-engine-src/src/storage/write_set.rs +962 -0
  174. package/dist-engine-src/src/storage_bench.rs +136 -4828
  175. package/dist-engine-src/src/test_support.rs +360 -138
  176. package/dist-engine-src/src/tracked_state/bench_support.rs +394 -0
  177. package/dist-engine-src/src/tracked_state/codec.rs +155 -1057
  178. package/dist-engine-src/src/tracked_state/commit_root_rebuild.rs +358 -0
  179. package/dist-engine-src/src/tracked_state/context.rs +1927 -993
  180. package/dist-engine-src/src/tracked_state/diff.rs +1715 -261
  181. package/dist-engine-src/src/tracked_state/merge.rs +74 -88
  182. package/dist-engine-src/src/tracked_state/mod.rs +19 -16
  183. package/dist-engine-src/src/tracked_state/{materialization.rs → row_materialization.rs} +50 -178
  184. package/dist-engine-src/src/tracked_state/storage.rs +243 -191
  185. package/dist-engine-src/src/tracked_state/tree.rs +247 -371
  186. package/dist-engine-src/src/tracked_state/types.rs +49 -42
  187. package/dist-engine-src/src/transaction/bench_support.rs +407 -0
  188. package/dist-engine-src/src/transaction/commit.rs +821 -713
  189. package/dist-engine-src/src/transaction/context.rs +705 -600
  190. package/dist-engine-src/src/transaction/mod.rs +13 -2
  191. package/dist-engine-src/src/transaction/normalization.rs +63 -76
  192. package/dist-engine-src/src/transaction/prep.rs +13 -13
  193. package/dist-engine-src/src/transaction/schema_resolver.rs +19 -5
  194. package/dist-engine-src/src/transaction/staging.rs +228 -434
  195. package/dist-engine-src/src/transaction/types.rs +41 -98
  196. package/dist-engine-src/src/transaction/validation.rs +382 -446
  197. package/dist-engine-src/src/untracked_state/codec.rs +337 -29
  198. package/dist-engine-src/src/untracked_state/context.rs +7 -7
  199. package/dist-engine-src/src/untracked_state/materialization.rs +2 -2
  200. package/dist-engine-src/src/untracked_state/mod.rs +1 -1
  201. package/dist-engine-src/src/untracked_state/storage.rs +659 -157
  202. package/dist-engine-src/src/untracked_state/types.rs +21 -21
  203. package/package.json +71 -68
  204. package/dist-engine-src/src/backend/kv.rs +0 -358
  205. package/dist-engine-src/src/backend/testing.rs +0 -658
  206. package/dist-engine-src/src/commit_store/codec.rs +0 -887
  207. package/dist-engine-src/src/commit_store/context.rs +0 -944
  208. package/dist-engine-src/src/commit_store/materialization.rs +0 -84
  209. package/dist-engine-src/src/commit_store/mod.rs +0 -16
  210. package/dist-engine-src/src/commit_store/storage.rs +0 -600
  211. package/dist-engine-src/src/commit_store/types.rs +0 -215
  212. package/dist-engine-src/src/schema/builtin/lix_version_descriptor.json +0 -34
  213. package/dist-engine-src/src/schema/builtin/lix_version_ref.json +0 -48
  214. package/dist-engine-src/src/session/create_version.rs +0 -88
  215. package/dist-engine-src/src/session/merge/apply.rs +0 -23
  216. package/dist-engine-src/src/session/optimization9_sql2_bench.rs +0 -100
  217. package/dist-engine-src/src/session/switch_version.rs +0 -110
  218. package/dist-engine-src/src/sql2/entity_provider.rs +0 -3211
  219. package/dist-engine-src/src/sql2/execute.rs +0 -3533
  220. package/dist-engine-src/src/sql2/public_bind/assignment.rs +0 -46
  221. package/dist-engine-src/src/sql2/public_bind/capability.rs +0 -41
  222. package/dist-engine-src/src/sql2/public_bind/dml.rs +0 -172
  223. package/dist-engine-src/src/sql2/public_bind/mod.rs +0 -26
  224. package/dist-engine-src/src/sql2/public_bind/table.rs +0 -168
  225. package/dist-engine-src/src/sql2/version_scope.rs +0 -394
  226. package/dist-engine-src/src/storage/types.rs +0 -501
  227. package/dist-engine-src/src/tracked_state/by_file_index.rs +0 -98
  228. package/dist-engine-src/src/tracked_state/materializer.rs +0 -488
  229. package/dist-engine-src/src/transaction/live_state_overlay.rs +0 -35
  230. package/dist-engine-src/src/version/lifecycle.rs +0 -221
  231. package/dist-engine-src/src/version/mod.rs +0 -13
  232. package/dist-engine-src/src/version/refs.rs +0 -330
  233. package/dist-engine-src/src/version/stage_rows.rs +0 -67
  234. package/dist-engine-src/src/version/types.rs +0 -21
@@ -70,7 +70,7 @@ impl LixError {
70
70
  /// A SQL write targeted a read-only internal/component surface.
71
71
  pub const CODE_READ_ONLY: &'static str = "LIX_ERROR_READ_ONLY";
72
72
 
73
- /// A history table was queried without an explicit commit/version range.
73
+ /// A history table was queried without an explicit commit/branch range.
74
74
  pub const CODE_HISTORY_FILTER_REQUIRED: &'static str = "LIX_HISTORY_FILTER_REQUIRED";
75
75
 
76
76
  /// SQL syntax is valid, but the feature is intentionally outside the Lix
@@ -99,7 +99,7 @@ impl LixError {
99
99
  pub const CODE_FOREIGN_KEY: &'static str = "LIX_ERROR_FOREIGN_KEY";
100
100
 
101
101
  /// A row references a non-null `file_id` that has no matching `lix_file`
102
- /// descriptor in the same effective version scope.
102
+ /// descriptor in the same effective branch scope.
103
103
  pub const CODE_FILE_NOT_FOUND: &'static str = "LIX_ERROR_FILE_NOT_FOUND";
104
104
 
105
105
  /// A primary-key or `x-lix-unique` constraint was violated — another
@@ -126,18 +126,21 @@ impl LixError {
126
126
  /// A merge found incompatible changes to the same tracked-state identity.
127
127
  pub const CODE_MERGE_CONFLICT: &'static str = "LIX_MERGE_CONFLICT";
128
128
 
129
- /// A caller referenced a version id that has no matching version ref.
130
- pub const CODE_VERSION_NOT_FOUND: &'static str = "LIX_VERSION_NOT_FOUND";
129
+ /// A caller referenced a branch id that has no matching branch ref.
130
+ pub const CODE_BRANCH_NOT_FOUND: &'static str = "LIX_BRANCH_NOT_FOUND";
131
+
132
+ /// A caller referenced a commit id that has no matching commit record.
133
+ pub const CODE_COMMIT_NOT_FOUND: &'static str = "LIX_COMMIT_NOT_FOUND";
131
134
 
132
135
  /// A staged row's storage scope flags disagree, such as a global row not
133
- /// using the reserved global version id.
136
+ /// using the reserved global branch id.
134
137
  pub const CODE_INVALID_STORAGE_SCOPE: &'static str = "LIX_ERROR_INVALID_STORAGE_SCOPE";
135
138
 
136
139
  /// Merge graph analysis found multiple equally valid merge bases.
137
140
  pub const CODE_AMBIGUOUS_MERGE_BASE: &'static str = "LIX_AMBIGUOUS_MERGE_BASE";
138
141
 
139
142
  /// A merge request is well-formed but nonsensical for the commit graph,
140
- /// such as merging a version into itself.
143
+ /// such as merging a branch into itself.
141
144
  pub const CODE_INVALID_MERGE: &'static str = "LIX_INVALID_MERGE";
142
145
 
143
146
  pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self {
@@ -153,20 +156,39 @@ impl LixError {
153
156
  Self::new("LIX_ERROR_UNKNOWN", message)
154
157
  }
155
158
 
156
- pub fn version_not_found(
157
- version_id: impl Into<String>,
159
+ pub fn branch_not_found(
160
+ branch_id: impl Into<String>,
161
+ operation: impl Into<String>,
162
+ role: impl Into<String>,
163
+ ) -> Self {
164
+ let branch_id = branch_id.into();
165
+ let operation = operation.into();
166
+ let role = role.into();
167
+ Self::new(
168
+ Self::CODE_BRANCH_NOT_FOUND,
169
+ format!("branch '{branch_id}' was not found"),
170
+ )
171
+ .with_details(json!({
172
+ "branch_id": branch_id,
173
+ "operation": operation,
174
+ "role": role,
175
+ }))
176
+ }
177
+
178
+ pub fn commit_not_found(
179
+ commit_id: impl Into<String>,
158
180
  operation: impl Into<String>,
159
181
  role: impl Into<String>,
160
182
  ) -> Self {
161
- let version_id = version_id.into();
183
+ let commit_id = commit_id.into();
162
184
  let operation = operation.into();
163
185
  let role = role.into();
164
186
  Self::new(
165
- Self::CODE_VERSION_NOT_FOUND,
166
- format!("version '{version_id}' was not found"),
187
+ Self::CODE_COMMIT_NOT_FOUND,
188
+ format!("commit '{commit_id}' was not found"),
167
189
  )
168
190
  .with_details(json!({
169
- "version_id": version_id,
191
+ "commit_id": commit_id,
170
192
  "operation": operation,
171
193
  "role": role,
172
194
  }))
@@ -190,16 +212,16 @@ impl LixError {
190
212
  }))
191
213
  }
192
214
 
193
- pub fn invalid_self_merge(version_id: impl Into<String>) -> Self {
194
- let version_id = version_id.into();
215
+ pub fn invalid_self_merge(branch_id: impl Into<String>) -> Self {
216
+ let branch_id = branch_id.into();
195
217
  Self::new(
196
218
  Self::CODE_INVALID_MERGE,
197
- format!("cannot merge version '{version_id}' into itself"),
219
+ format!("cannot merge branch '{branch_id}' into itself"),
198
220
  )
199
221
  .with_details(json!({
200
- "operation": "merge_version",
201
- "target_version_id": version_id,
202
- "source_version_id": version_id,
222
+ "operation": "merge_branch",
223
+ "target_branch_id": branch_id,
224
+ "source_branch_id": branch_id,
203
225
  }))
204
226
  }
205
227
 
@@ -259,6 +281,18 @@ impl LixError {
259
281
  }
260
282
  }
261
283
 
284
+ impl From<crate::storage::StorageBackendError> for LixError {
285
+ fn from(error: crate::storage::StorageBackendError) -> Self {
286
+ Self::new(Self::CODE_STORAGE_ERROR, error.to_string())
287
+ }
288
+ }
289
+
290
+ impl From<crate::storage::StorageWriteSetError> for LixError {
291
+ fn from(error: crate::storage::StorageWriteSetError) -> Self {
292
+ Self::new(Self::CODE_STORAGE_ERROR, error.to_string())
293
+ }
294
+ }
295
+
262
296
  impl std::fmt::Display for LixError {
263
297
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
264
298
  write!(f, "{}", self.format())
@@ -106,9 +106,9 @@ macro_rules! canonical_identity_type {
106
106
  };
107
107
  }
108
108
 
109
- canonical_identity_type!(EntityId, "entity_id");
109
+ canonical_identity_type!(EntityPk, "entity_pk");
110
110
  canonical_identity_type!(FileId, "file_id");
111
- canonical_identity_type!(VersionId, "version_id");
111
+ canonical_identity_type!(BranchId, "branch_id");
112
112
  canonical_identity_type!(CanonicalSchemaKey, "schema_key");
113
113
  canonical_identity_type!(CanonicalPluginKey, "plugin_key");
114
114
 
@@ -14,7 +14,7 @@ pub(crate) use fs_path::{
14
14
  normalize_path_segment, parent_directory_path, ParsedFilePath,
15
15
  };
16
16
  pub(crate) use identity::{json_pointer_get, validate_non_empty_identity_value};
17
- pub use identity::{CanonicalPluginKey, CanonicalSchemaKey, EntityId, FileId, VersionId};
17
+ pub use identity::{BranchId, CanonicalPluginKey, CanonicalSchemaKey, EntityPk, FileId};
18
18
  pub(crate) use json_pointer::{format_json_pointer, parse_json_pointer, top_level_property_name};
19
19
  pub(crate) use metadata::{
20
20
  parse_row_metadata, parse_row_metadata_value, serialize_row_metadata, validate_row_metadata,
@@ -1,57 +1,57 @@
1
- use crate::entity_identity::EntityIdentity;
1
+ use crate::entity_pk::EntityPk;
2
2
  use crate::live_state::MaterializedLiveStateRow;
3
- use crate::{NullableKeyFilter, GLOBAL_VERSION_ID};
3
+ use crate::{NullableKeyFilter, GLOBAL_BRANCH_ID};
4
4
 
5
5
  /// Validation/storage coordinate for repository facts.
6
6
  ///
7
7
  /// A domain is the complete scope in which a row identity is meaningful:
8
- /// version, durability, and file scope. Projection methods on this type are
8
+ /// branch, durability, and file scope. Projection methods on this type are
9
9
  /// deliberately named so callers cannot silently erase part of the coordinate.
10
10
  #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
11
11
  pub(crate) struct Domain {
12
- version_id: String,
12
+ branch_id: String,
13
13
  untracked: bool,
14
14
  file_scope: DomainFileScope,
15
15
  }
16
16
 
17
17
  impl Domain {
18
18
  pub(crate) fn exact_file(
19
- version_id: impl Into<String>,
19
+ branch_id: impl Into<String>,
20
20
  untracked: bool,
21
21
  file_id: Option<String>,
22
22
  ) -> Self {
23
23
  Self {
24
- version_id: version_id.into(),
24
+ branch_id: branch_id.into(),
25
25
  untracked,
26
26
  file_scope: DomainFileScope::Exact(file_id),
27
27
  }
28
28
  }
29
29
 
30
- pub(crate) fn any_file(version_id: impl Into<String>, untracked: bool) -> Self {
30
+ pub(crate) fn any_file(branch_id: impl Into<String>, untracked: bool) -> Self {
31
31
  Self {
32
- version_id: version_id.into(),
32
+ branch_id: branch_id.into(),
33
33
  untracked,
34
34
  file_scope: DomainFileScope::Any,
35
35
  }
36
36
  }
37
37
 
38
- pub(crate) fn schema_catalog(version_id: impl Into<String>, untracked: bool) -> Self {
39
- Self::any_file(version_id, untracked)
38
+ pub(crate) fn schema_catalog(branch_id: impl Into<String>, untracked: bool) -> Self {
39
+ Self::any_file(branch_id, untracked)
40
40
  }
41
41
 
42
42
  pub(crate) fn for_live_row(row: &MaterializedLiveStateRow) -> Self {
43
- Self::exact_file(row.version_id.clone(), row.untracked, row.file_id.clone())
43
+ Self::exact_file(row.branch_id.clone(), row.untracked, row.file_id.clone())
44
44
  }
45
45
 
46
46
  pub(crate) fn schema_catalog_domain(&self) -> Self {
47
- // Schema definitions are version + durability scoped. They are not
47
+ // Schema definitions are branch + durability scoped. They are not
48
48
  // owned by a data file, so schema catalog lookup deliberately erases
49
49
  // row file scope into `Any`.
50
- Self::schema_catalog(self.version_id.clone(), self.untracked)
50
+ Self::schema_catalog(self.branch_id.clone(), self.untracked)
51
51
  }
52
52
 
53
- pub(crate) fn version_id(&self) -> &str {
54
- &self.version_id
53
+ pub(crate) fn branch_id(&self) -> &str {
54
+ &self.branch_id
55
55
  }
56
56
 
57
57
  pub(crate) fn untracked(&self) -> bool {
@@ -64,7 +64,7 @@ impl Domain {
64
64
  DomainFileScope::Exact(Some(file_id)) => format!("={file_id}"),
65
65
  DomainFileScope::Exact(None) => "=".to_string(),
66
66
  };
67
- format!("{}|{}|{}", self.version_id, self.untracked, file_scope)
67
+ format!("{}|{}|{}", self.branch_id, self.untracked, file_scope)
68
68
  }
69
69
 
70
70
  #[cfg(test)]
@@ -78,7 +78,7 @@ impl Domain {
78
78
 
79
79
  pub(crate) fn with_untracked(&self, untracked: bool) -> Self {
80
80
  Self {
81
- version_id: self.version_id.clone(),
81
+ branch_id: self.branch_id.clone(),
82
82
  untracked,
83
83
  file_scope: self.file_scope.clone(),
84
84
  }
@@ -86,7 +86,7 @@ impl Domain {
86
86
 
87
87
  pub(crate) fn with_file_scope(&self, file_scope: DomainFileScope) -> Self {
88
88
  Self {
89
- version_id: self.version_id.clone(),
89
+ branch_id: self.branch_id.clone(),
90
90
  untracked: self.untracked,
91
91
  file_scope,
92
92
  }
@@ -104,9 +104,9 @@ impl Domain {
104
104
  }
105
105
 
106
106
  pub(crate) fn contains(&self, row: &MaterializedLiveStateRow) -> bool {
107
- row.version_id == self.version_id
107
+ row.branch_id == self.branch_id
108
108
  && row.untracked == self.untracked
109
- && committed_row_is_exact_version_scoped(row, &self.version_id)
109
+ && committed_row_is_exact_branch_scoped(row, &self.branch_id)
110
110
  && match &self.file_scope {
111
111
  DomainFileScope::Any => true,
112
112
  DomainFileScope::Exact(file_id) => row.file_id == *file_id,
@@ -130,7 +130,7 @@ impl Domain {
130
130
  }
131
131
 
132
132
  fn can_reach(&self, target: &Self) -> bool {
133
- self.version_id == target.version_id
133
+ self.branch_id == target.branch_id
134
134
  && self.file_scope == target.file_scope
135
135
  && (self.untracked || !target.untracked)
136
136
  }
@@ -155,7 +155,7 @@ impl Domain {
155
155
  self.reachable_target_domains()
156
156
  }
157
157
 
158
- pub(crate) fn version_descriptor_domains_for_ref_delete(&self) -> Vec<Self> {
158
+ pub(crate) fn branch_descriptor_domains_for_ref_delete(&self) -> Vec<Self> {
159
159
  self.source_domains_that_can_reach()
160
160
  }
161
161
 
@@ -185,19 +185,15 @@ pub(crate) enum DomainFileScope {
185
185
  pub(crate) struct DomainRowIdentity {
186
186
  domain: Domain,
187
187
  schema_key: String,
188
- entity_id: EntityIdentity,
188
+ entity_pk: EntityPk,
189
189
  }
190
190
 
191
191
  impl DomainRowIdentity {
192
- pub(crate) fn new(
193
- domain: Domain,
194
- schema_key: impl Into<String>,
195
- entity_id: EntityIdentity,
196
- ) -> Self {
192
+ pub(crate) fn new(domain: Domain, schema_key: impl Into<String>, entity_pk: EntityPk) -> Self {
197
193
  Self {
198
194
  domain,
199
195
  schema_key: schema_key.into(),
200
- entity_id,
196
+ entity_pk,
201
197
  }
202
198
  }
203
199
 
@@ -205,30 +201,30 @@ impl DomainRowIdentity {
205
201
  Self::new(
206
202
  Domain::for_live_row(row),
207
203
  row.schema_key.clone(),
208
- row.entity_id.clone(),
204
+ row.entity_pk.clone(),
209
205
  )
210
206
  }
211
207
 
212
208
  pub(crate) fn in_domain(
213
209
  domain: Domain,
214
210
  schema_key: impl Into<String>,
215
- entity_id: EntityIdentity,
211
+ entity_pk: EntityPk,
216
212
  ) -> Self {
217
- Self::new(domain, schema_key, entity_id)
213
+ Self::new(domain, schema_key, entity_pk)
218
214
  }
219
215
 
220
216
  #[cfg(test)]
221
217
  pub(crate) fn exact(
222
- version_id: impl Into<String>,
218
+ branch_id: impl Into<String>,
223
219
  untracked: bool,
224
220
  file_id: Option<String>,
225
221
  schema_key: impl Into<String>,
226
- entity_id: EntityIdentity,
222
+ entity_pk: EntityPk,
227
223
  ) -> Self {
228
224
  Self::new(
229
- Domain::exact_file(version_id, untracked, file_id),
225
+ Domain::exact_file(branch_id, untracked, file_id),
230
226
  schema_key,
231
- entity_id,
227
+ entity_pk,
232
228
  )
233
229
  }
234
230
 
@@ -236,7 +232,7 @@ impl DomainRowIdentity {
236
232
  Self {
237
233
  domain,
238
234
  schema_key: self.schema_key.clone(),
239
- entity_id: self.entity_id.clone(),
235
+ entity_pk: self.entity_pk.clone(),
240
236
  }
241
237
  }
242
238
 
@@ -252,21 +248,21 @@ impl DomainRowIdentity {
252
248
  self.schema_key.clone()
253
249
  }
254
250
 
255
- pub(crate) fn entity_id(&self) -> &EntityIdentity {
256
- &self.entity_id
251
+ pub(crate) fn entity_pk(&self) -> &EntityPk {
252
+ &self.entity_pk
257
253
  }
258
254
 
259
- pub(crate) fn entity_id_owned(&self) -> EntityIdentity {
260
- self.entity_id.clone()
255
+ pub(crate) fn entity_pk_owned(&self) -> EntityPk {
256
+ self.entity_pk.clone()
261
257
  }
262
258
 
263
259
  pub(crate) fn matches_parts(
264
260
  &self,
265
261
  domain: &Domain,
266
262
  schema_key: &str,
267
- entity_id: &EntityIdentity,
263
+ entity_pk: &EntityPk,
268
264
  ) -> bool {
269
- &self.domain == domain && self.schema_key == schema_key && &self.entity_id == entity_id
265
+ &self.domain == domain && self.schema_key == schema_key && &self.entity_pk == entity_pk
270
266
  }
271
267
 
272
268
  pub(crate) fn reachable_target_identities(&self) -> Vec<Self> {
@@ -309,11 +305,11 @@ impl DomainSchemaIdentity {
309
305
  }
310
306
  }
311
307
 
312
- pub(crate) fn committed_row_is_exact_version_scoped(
308
+ pub(crate) fn committed_row_is_exact_branch_scoped(
313
309
  row: &MaterializedLiveStateRow,
314
- version_id: &str,
310
+ branch_id: &str,
315
311
  ) -> bool {
316
- row.version_id == version_id && row.global == (row.version_id == GLOBAL_VERSION_ID)
312
+ row.branch_id == branch_id && row.global == (row.branch_id == GLOBAL_BRANCH_ID)
317
313
  }
318
314
 
319
315
  fn nullable_filter_from_option(value: &Option<String>) -> NullableKeyFilter<String> {