@lix-js/sdk 0.6.0-preview.2 → 0.6.0-preview.3
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.
- package/SKILL.md +4 -5
- package/dist/engine-wasm/wasm/lix_engine.js +1 -1
- package/dist/engine-wasm/wasm/lix_engine.wasm +0 -0
- package/dist/generated/builtin-schemas.d.ts +87 -162
- package/dist/generated/builtin-schemas.js +139 -236
- package/dist/open-lix.d.ts +1 -1
- package/dist-engine-src/src/binary_cas/types.rs +0 -6
- package/dist-engine-src/src/catalog/context.rs +412 -0
- package/dist-engine-src/src/catalog/mod.rs +10 -0
- package/dist-engine-src/src/catalog/schema.rs +4 -0
- package/dist-engine-src/src/catalog/snapshot.rs +1114 -0
- package/dist-engine-src/src/cel/mod.rs +1 -1
- package/dist-engine-src/src/cel/provider.rs +1 -1
- package/dist-engine-src/src/commit_graph/context.rs +328 -1015
- package/dist-engine-src/src/commit_graph/mod.rs +2 -3
- package/dist-engine-src/src/commit_graph/types.rs +7 -43
- package/dist-engine-src/src/commit_graph/walker.rs +57 -81
- package/dist-engine-src/src/commit_store/codec.rs +887 -0
- package/dist-engine-src/src/commit_store/context.rs +944 -0
- package/dist-engine-src/src/commit_store/materialization.rs +84 -0
- package/dist-engine-src/src/commit_store/mod.rs +16 -0
- package/dist-engine-src/src/commit_store/storage.rs +600 -0
- package/dist-engine-src/src/commit_store/types.rs +215 -0
- package/dist-engine-src/src/common/identity.rs +15 -5
- package/dist-engine-src/src/common/json_pointer.rs +67 -0
- package/dist-engine-src/src/common/metadata.rs +17 -12
- package/dist-engine-src/src/common/mod.rs +5 -5
- package/dist-engine-src/src/domain.rs +324 -0
- package/dist-engine-src/src/engine.rs +29 -43
- package/dist-engine-src/src/entity_identity.rs +238 -118
- package/dist-engine-src/src/functions/context.rs +17 -52
- package/dist-engine-src/src/functions/deterministic.rs +1 -1
- package/dist-engine-src/src/functions/mod.rs +1 -1
- package/dist-engine-src/src/functions/provider.rs +4 -4
- package/dist-engine-src/src/functions/state.rs +39 -66
- package/dist-engine-src/src/functions/types.rs +1 -1
- package/dist-engine-src/src/init.rs +204 -151
- package/dist-engine-src/src/json_store/context.rs +354 -60
- package/dist-engine-src/src/json_store/encoded.rs +6 -6
- package/dist-engine-src/src/json_store/mod.rs +4 -1
- package/dist-engine-src/src/json_store/store.rs +884 -11
- package/dist-engine-src/src/json_store/types.rs +166 -1
- package/dist-engine-src/src/lib.rs +10 -9
- package/dist-engine-src/src/live_state/context.rs +608 -830
- package/dist-engine-src/src/live_state/mod.rs +3 -3
- package/dist-engine-src/src/live_state/overlay.rs +7 -7
- package/dist-engine-src/src/live_state/reader.rs +5 -5
- package/dist-engine-src/src/live_state/types.rs +19 -36
- package/dist-engine-src/src/live_state/visibility.rs +19 -14
- package/dist-engine-src/src/plugin/archive.rs +3 -6
- package/dist-engine-src/src/plugin/install.rs +0 -18
- package/dist-engine-src/src/plugin/plugin_manifest.json +0 -1
- package/dist-engine-src/src/schema/annotations/defaults.rs +2 -7
- package/dist-engine-src/src/schema/builtin/lix_account.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_active_account.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_binary_blob_ref.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_change.json +11 -10
- package/dist-engine-src/src/schema/builtin/lix_change_author.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_commit.json +8 -46
- package/dist-engine-src/src/schema/builtin/lix_commit_edge.json +29 -22
- package/dist-engine-src/src/schema/builtin/lix_directory_descriptor.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_file_descriptor.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_key_value.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_label.json +10 -3
- package/dist-engine-src/src/schema/builtin/lix_label_assignment.json +74 -0
- package/dist-engine-src/src/schema/builtin/lix_registered_schema.json +2 -8
- package/dist-engine-src/src/schema/builtin/lix_version_descriptor.json +0 -1
- package/dist-engine-src/src/schema/builtin/lix_version_ref.json +0 -1
- package/dist-engine-src/src/schema/builtin/mod.rs +10 -59
- package/dist-engine-src/src/schema/compatibility.rs +787 -0
- package/dist-engine-src/src/schema/definition.json +47 -17
- package/dist-engine-src/src/schema/definition.rs +202 -96
- package/dist-engine-src/src/schema/key.rs +9 -77
- package/dist-engine-src/src/schema/mod.rs +4 -4
- package/dist-engine-src/src/schema/tests.rs +133 -92
- package/dist-engine-src/src/session/context.rs +40 -42
- package/dist-engine-src/src/session/create_version.rs +22 -14
- package/dist-engine-src/src/session/execute.rs +45 -14
- package/dist-engine-src/src/session/merge/apply.rs +4 -4
- package/dist-engine-src/src/session/merge/conflicts.rs +3 -2
- package/dist-engine-src/src/session/merge/stats.rs +1 -1
- package/dist-engine-src/src/session/merge/version.rs +35 -45
- package/dist-engine-src/src/session/mod.rs +4 -2
- package/dist-engine-src/src/session/optimization9_sql2_bench.rs +100 -0
- package/dist-engine-src/src/session/switch_version.rs +16 -28
- package/dist-engine-src/src/sql2/change_provider.rs +14 -20
- package/dist-engine-src/src/sql2/classify.rs +61 -26
- package/dist-engine-src/src/sql2/context.rs +22 -18
- package/dist-engine-src/src/sql2/directory_history_provider.rs +28 -20
- package/dist-engine-src/src/sql2/directory_provider.rs +131 -83
- package/dist-engine-src/src/sql2/entity_history_provider.rs +10 -14
- package/dist-engine-src/src/sql2/entity_provider.rs +680 -169
- package/dist-engine-src/src/sql2/error.rs +21 -1
- package/dist-engine-src/src/sql2/execute.rs +325 -264
- package/dist-engine-src/src/sql2/file_history_provider.rs +29 -21
- package/dist-engine-src/src/sql2/file_provider.rs +533 -108
- package/dist-engine-src/src/sql2/filesystem_planner.rs +58 -94
- package/dist-engine-src/src/sql2/filesystem_visibility.rs +37 -23
- package/dist-engine-src/src/sql2/history_projection.rs +3 -27
- package/dist-engine-src/src/sql2/history_provider.rs +11 -17
- package/dist-engine-src/src/sql2/history_route.rs +22 -8
- package/dist-engine-src/src/sql2/lix_state_provider.rs +178 -96
- package/dist-engine-src/src/sql2/mod.rs +6 -3
- package/dist-engine-src/src/sql2/predicate_typecheck.rs +246 -0
- package/dist-engine-src/src/sql2/public_bind/assignment.rs +46 -0
- package/dist-engine-src/src/sql2/public_bind/capability.rs +41 -0
- package/dist-engine-src/src/sql2/public_bind/dml.rs +166 -0
- package/dist-engine-src/src/sql2/public_bind/mod.rs +25 -0
- package/dist-engine-src/src/sql2/public_bind/table.rs +168 -0
- package/dist-engine-src/src/sql2/read_only.rs +10 -12
- package/dist-engine-src/src/sql2/session.rs +7 -10
- package/dist-engine-src/src/sql2/udfs/lix_timestamp.rs +76 -0
- package/dist-engine-src/src/sql2/udfs/mod.rs +8 -1
- package/dist-engine-src/src/sql2/udfs/public_call.rs +211 -0
- package/dist-engine-src/src/sql2/version_provider.rs +46 -31
- package/dist-engine-src/src/sql2/version_scope.rs +4 -4
- package/dist-engine-src/src/storage_bench.rs +1782 -325
- package/dist-engine-src/src/test_support.rs +183 -36
- package/dist-engine-src/src/tracked_state/by_file_index.rs +20 -24
- package/dist-engine-src/src/tracked_state/codec.rs +1519 -181
- package/dist-engine-src/src/tracked_state/context.rs +1155 -271
- package/dist-engine-src/src/tracked_state/diff.rs +249 -57
- package/dist-engine-src/src/tracked_state/materialization.rs +365 -103
- package/dist-engine-src/src/tracked_state/materializer.rs +488 -0
- package/dist-engine-src/src/tracked_state/merge.rs +37 -19
- package/dist-engine-src/src/tracked_state/mod.rs +8 -7
- package/dist-engine-src/src/tracked_state/storage.rs +138 -6
- package/dist-engine-src/src/tracked_state/tree.rs +695 -252
- package/dist-engine-src/src/tracked_state/types.rs +176 -6
- package/dist-engine-src/src/transaction/commit.rs +695 -435
- package/dist-engine-src/src/transaction/context.rs +551 -310
- package/dist-engine-src/src/transaction/live_state_overlay.rs +9 -8
- package/dist-engine-src/src/transaction/mod.rs +2 -0
- package/dist-engine-src/src/transaction/normalization.rs +311 -447
- package/dist-engine-src/src/transaction/prep.rs +37 -0
- package/dist-engine-src/src/transaction/schema_resolver.rs +93 -71
- package/dist-engine-src/src/transaction/staging.rs +701 -406
- package/dist-engine-src/src/transaction/types.rs +231 -122
- package/dist-engine-src/src/transaction/validation.rs +2717 -1698
- package/dist-engine-src/src/untracked_state/codec.rs +40 -96
- package/dist-engine-src/src/untracked_state/context.rs +21 -5
- package/dist-engine-src/src/untracked_state/materialization.rs +10 -104
- package/dist-engine-src/src/untracked_state/mod.rs +3 -5
- package/dist-engine-src/src/untracked_state/storage.rs +105 -57
- package/dist-engine-src/src/untracked_state/types.rs +63 -13
- package/dist-engine-src/src/version/context.rs +1 -13
- package/dist-engine-src/src/version/lifecycle.rs +221 -0
- package/dist-engine-src/src/version/mod.rs +3 -2
- package/dist-engine-src/src/version/refs.rs +12 -103
- package/dist-engine-src/src/version/stage_rows.rs +15 -19
- package/package.json +1 -1
- package/dist-engine-src/src/changelog/codec.rs +0 -321
- package/dist-engine-src/src/changelog/context.rs +0 -92
- package/dist-engine-src/src/changelog/materialization.rs +0 -121
- package/dist-engine-src/src/changelog/mod.rs +0 -13
- package/dist-engine-src/src/changelog/reader.rs +0 -20
- package/dist-engine-src/src/changelog/storage.rs +0 -220
- package/dist-engine-src/src/changelog/types.rs +0 -38
- package/dist-engine-src/src/schema/builtin/lix_change_set.json +0 -18
- package/dist-engine-src/src/schema/builtin/lix_change_set_element.json +0 -75
- package/dist-engine-src/src/schema/builtin/lix_entity_label.json +0 -63
- package/dist-engine-src/src/schema_registry.rs +0 -294
- package/dist-engine-src/src/sql2/commit_derived_provider.rs +0 -591
- package/dist-engine-src/src/tracked_state/rebuild.rs +0 -771
- package/dist-engine-src/src/tracked_state/tree_types.rs +0 -176
|
@@ -6,7 +6,6 @@ mod walker;
|
|
|
6
6
|
pub(crate) use context::{CommitGraphContext, CommitGraphStoreReader};
|
|
7
7
|
#[allow(unused_imports)]
|
|
8
8
|
pub(crate) use types::{
|
|
9
|
-
CommitGraphChangeHistoryEntry, CommitGraphChangeHistoryRequest,
|
|
10
|
-
|
|
11
|
-
CommitGraphReader, ReachableCommitGraphCommit,
|
|
9
|
+
CommitGraphChangeHistoryEntry, CommitGraphChangeHistoryRequest, CommitGraphCommit,
|
|
10
|
+
CommitGraphEdge, CommitGraphReader, ReachableCommitGraphCommit,
|
|
12
11
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
use crate::commit_store::{Change, LocatedChange};
|
|
2
|
+
use crate::entity_identity::EntityIdentity;
|
|
1
3
|
use crate::LixError;
|
|
2
|
-
use crate::{
|
|
3
|
-
changelog::{CanonicalChange, MaterializedCanonicalChange},
|
|
4
|
-
entity_identity::EntityIdentity,
|
|
5
|
-
};
|
|
6
4
|
|
|
7
5
|
/// Parsed `lix_commit` entity from the changelog.
|
|
8
6
|
///
|
|
@@ -13,9 +11,9 @@ use crate::{
|
|
|
13
11
|
/// newly minted copies.
|
|
14
12
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
15
13
|
pub(crate) struct CommitGraphCommit {
|
|
16
|
-
pub(crate)
|
|
14
|
+
pub(crate) canonical_change: Change,
|
|
15
|
+
pub(crate) change: Change,
|
|
17
16
|
pub(crate) commit_id: String,
|
|
18
|
-
pub(crate) change_set_id: String,
|
|
19
17
|
pub(crate) change_ids: Vec<String>,
|
|
20
18
|
pub(crate) author_account_ids: Vec<String>,
|
|
21
19
|
pub(crate) parent_commit_ids: Vec<String>,
|
|
@@ -33,20 +31,7 @@ pub(crate) struct ReachableCommitGraphCommit {
|
|
|
33
31
|
pub(crate) struct CommitGraphEdge {
|
|
34
32
|
pub(crate) parent_commit_id: String,
|
|
35
33
|
pub(crate) child_commit_id: String,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/// Derived change-set row for a commit.
|
|
39
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
40
|
-
pub(crate) struct CommitGraphChangeSet {
|
|
41
|
-
pub(crate) id: String,
|
|
42
|
-
pub(crate) commit_id: String,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/// Derived membership row for a commit's introduced/adopted change set.
|
|
46
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
47
|
-
pub(crate) struct CommitGraphChangeSetElement {
|
|
48
|
-
pub(crate) change_set_id: String,
|
|
49
|
-
pub(crate) change: MaterializedCanonicalChange,
|
|
34
|
+
pub(crate) parent_order: u32,
|
|
50
35
|
}
|
|
51
36
|
|
|
52
37
|
/// Filter for canonical change history from a chosen traversal start commit.
|
|
@@ -66,7 +51,7 @@ pub(crate) struct CommitGraphChangeHistoryRequest {
|
|
|
66
51
|
/// necessarily a graph root or a version head.
|
|
67
52
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
68
53
|
pub(crate) struct CommitGraphChangeHistoryEntry {
|
|
69
|
-
pub(crate)
|
|
54
|
+
pub(crate) located_change: LocatedChange,
|
|
70
55
|
pub(crate) observed_commit_id: String,
|
|
71
56
|
pub(crate) start_commit_id: String,
|
|
72
57
|
pub(crate) depth: u32,
|
|
@@ -76,6 +61,7 @@ pub(crate) struct CommitGraphChangeHistoryEntry {
|
|
|
76
61
|
///
|
|
77
62
|
/// SQL surfaces consume this trait so they depend on graph semantics, not on
|
|
78
63
|
/// changelog storage or traversal details.
|
|
64
|
+
#[allow(dead_code)]
|
|
79
65
|
#[async_trait::async_trait]
|
|
80
66
|
pub(crate) trait CommitGraphReader: Send + Sync {
|
|
81
67
|
#[allow(dead_code)]
|
|
@@ -115,31 +101,9 @@ pub(crate) trait CommitGraphReader: Send + Sync {
|
|
|
115
101
|
|
|
116
102
|
fn commit_edges(&self, commits: &[CommitGraphCommit]) -> Vec<CommitGraphEdge>;
|
|
117
103
|
|
|
118
|
-
fn change_sets(&self, commits: &[CommitGraphCommit]) -> Vec<CommitGraphChangeSet>;
|
|
119
|
-
|
|
120
|
-
async fn change_set_elements(
|
|
121
|
-
&mut self,
|
|
122
|
-
commits: &[CommitGraphCommit],
|
|
123
|
-
) -> Result<Vec<CommitGraphChangeSetElement>, LixError>;
|
|
124
|
-
|
|
125
104
|
async fn change_history_from_commit(
|
|
126
105
|
&mut self,
|
|
127
106
|
start_commit_id: &str,
|
|
128
107
|
request: &CommitGraphChangeHistoryRequest,
|
|
129
108
|
) -> Result<Vec<CommitGraphChangeHistoryEntry>, LixError>;
|
|
130
109
|
}
|
|
131
|
-
|
|
132
|
-
/// Canonical entity selected by resolving the commit graph at a commit head.
|
|
133
|
-
///
|
|
134
|
-
/// The changelog fact remains unchanged. The graph reader adds the commit that
|
|
135
|
-
/// made the fact visible at this head plus its distance from the requested
|
|
136
|
-
/// head, so tracked_state can materialize serving rows without knowing graph
|
|
137
|
-
/// traversal rules.
|
|
138
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
139
|
-
pub(crate) struct CommitGraphEntity {
|
|
140
|
-
pub(crate) change: MaterializedCanonicalChange,
|
|
141
|
-
pub(crate) source_commit_id: String,
|
|
142
|
-
pub(crate) depth: u32,
|
|
143
|
-
pub(crate) created_at: String,
|
|
144
|
-
pub(crate) updated_at: String,
|
|
145
|
-
}
|
|
@@ -223,11 +223,8 @@ mod tests {
|
|
|
223
223
|
use serde_json::json;
|
|
224
224
|
|
|
225
225
|
use crate::backend::testing::UnitTestBackend;
|
|
226
|
-
use crate::changelog::{
|
|
227
|
-
canonicalize_materialized_change, ChangelogContext, MaterializedCanonicalChange,
|
|
228
|
-
};
|
|
229
226
|
use crate::commit_graph::CommitGraphContext;
|
|
230
|
-
use crate::
|
|
227
|
+
use crate::commit_store::{Change, CommitDraftRef, CommitStoreContext};
|
|
231
228
|
use crate::storage::{StorageContext, StorageWriteSet};
|
|
232
229
|
use crate::LixError;
|
|
233
230
|
|
|
@@ -235,10 +232,8 @@ mod tests {
|
|
|
235
232
|
async fn reachable_commits_returns_commits_nearest_first() {
|
|
236
233
|
let backend = Arc::new(UnitTestBackend::new());
|
|
237
234
|
let storage = StorageContext::new(backend.clone());
|
|
238
|
-
let changelog = ChangelogContext::new();
|
|
239
235
|
append_changes(
|
|
240
236
|
storage.clone(),
|
|
241
|
-
&changelog,
|
|
242
237
|
&[
|
|
243
238
|
commit_change("commit-root-change", "commit-root", &[], &[]),
|
|
244
239
|
commit_change(
|
|
@@ -252,7 +247,7 @@ mod tests {
|
|
|
252
247
|
)
|
|
253
248
|
.await;
|
|
254
249
|
|
|
255
|
-
let graph = CommitGraphContext::new(
|
|
250
|
+
let graph = CommitGraphContext::new();
|
|
256
251
|
let mut reader = graph.reader(storage);
|
|
257
252
|
let commits = reader
|
|
258
253
|
.reachable_commits("commit-head")
|
|
@@ -272,10 +267,8 @@ mod tests {
|
|
|
272
267
|
async fn reachable_commits_errors_on_missing_parent_commit() {
|
|
273
268
|
let backend = Arc::new(UnitTestBackend::new());
|
|
274
269
|
let storage = StorageContext::new(backend.clone());
|
|
275
|
-
let changelog = ChangelogContext::new();
|
|
276
270
|
append_changes(
|
|
277
271
|
storage.clone(),
|
|
278
|
-
&changelog,
|
|
279
272
|
&[commit_change(
|
|
280
273
|
"commit-head-change",
|
|
281
274
|
"commit-head",
|
|
@@ -285,7 +278,7 @@ mod tests {
|
|
|
285
278
|
)
|
|
286
279
|
.await;
|
|
287
280
|
|
|
288
|
-
let graph = CommitGraphContext::new(
|
|
281
|
+
let graph = CommitGraphContext::new();
|
|
289
282
|
let mut reader = graph.reader(storage);
|
|
290
283
|
let error = reader
|
|
291
284
|
.reachable_commits("commit-head")
|
|
@@ -299,10 +292,8 @@ mod tests {
|
|
|
299
292
|
async fn reachable_commits_errors_on_cycle() {
|
|
300
293
|
let backend = Arc::new(UnitTestBackend::new());
|
|
301
294
|
let storage = StorageContext::new(backend.clone());
|
|
302
|
-
let changelog = ChangelogContext::new();
|
|
303
295
|
append_changes(
|
|
304
296
|
storage.clone(),
|
|
305
|
-
&changelog,
|
|
306
297
|
&[
|
|
307
298
|
commit_change("commit-a-change", "commit-a", &[], &["commit-b"]),
|
|
308
299
|
commit_change("commit-b-change", "commit-b", &[], &["commit-a"]),
|
|
@@ -310,7 +301,7 @@ mod tests {
|
|
|
310
301
|
)
|
|
311
302
|
.await;
|
|
312
303
|
|
|
313
|
-
let graph = CommitGraphContext::new(
|
|
304
|
+
let graph = CommitGraphContext::new();
|
|
314
305
|
let mut reader = graph.reader(storage);
|
|
315
306
|
let error = reader
|
|
316
307
|
.reachable_commits("commit-a")
|
|
@@ -324,10 +315,8 @@ mod tests {
|
|
|
324
315
|
async fn reachable_commits_dedupes_shared_ancestors_in_diamond() {
|
|
325
316
|
let backend = Arc::new(UnitTestBackend::new());
|
|
326
317
|
let storage = StorageContext::new(backend.clone());
|
|
327
|
-
let changelog = ChangelogContext::new();
|
|
328
318
|
append_changes(
|
|
329
319
|
storage.clone(),
|
|
330
|
-
&changelog,
|
|
331
320
|
&[
|
|
332
321
|
commit_change("commit-root-change", "commit-root", &[], &[]),
|
|
333
322
|
commit_change("commit-left-change", "commit-left", &[], &["commit-root"]),
|
|
@@ -342,7 +331,7 @@ mod tests {
|
|
|
342
331
|
)
|
|
343
332
|
.await;
|
|
344
333
|
|
|
345
|
-
let graph = CommitGraphContext::new(
|
|
334
|
+
let graph = CommitGraphContext::new();
|
|
346
335
|
let mut reader = graph.reader(storage);
|
|
347
336
|
let commits = reader
|
|
348
337
|
.reachable_commits("commit-head")
|
|
@@ -367,10 +356,8 @@ mod tests {
|
|
|
367
356
|
async fn reachable_commits_keeps_nearest_depth_for_multiple_paths() {
|
|
368
357
|
let backend = Arc::new(UnitTestBackend::new());
|
|
369
358
|
let storage = StorageContext::new(backend.clone());
|
|
370
|
-
let changelog = ChangelogContext::new();
|
|
371
359
|
append_changes(
|
|
372
360
|
storage.clone(),
|
|
373
|
-
&changelog,
|
|
374
361
|
&[
|
|
375
362
|
commit_change("commit-root-change", "commit-root", &[], &[]),
|
|
376
363
|
commit_change(
|
|
@@ -389,7 +376,7 @@ mod tests {
|
|
|
389
376
|
)
|
|
390
377
|
.await;
|
|
391
378
|
|
|
392
|
-
let graph = CommitGraphContext::new(
|
|
379
|
+
let graph = CommitGraphContext::new();
|
|
393
380
|
let mut reader = graph.reader(storage);
|
|
394
381
|
let commits = reader
|
|
395
382
|
.reachable_commits("commit-head")
|
|
@@ -409,10 +396,8 @@ mod tests {
|
|
|
409
396
|
async fn reachable_commits_orders_same_depth_commits_by_id() {
|
|
410
397
|
let backend = Arc::new(UnitTestBackend::new());
|
|
411
398
|
let storage = StorageContext::new(backend.clone());
|
|
412
|
-
let changelog = ChangelogContext::new();
|
|
413
399
|
append_changes(
|
|
414
400
|
storage.clone(),
|
|
415
|
-
&changelog,
|
|
416
401
|
&[
|
|
417
402
|
commit_change("commit-z-change", "commit-z", &[], &[]),
|
|
418
403
|
commit_change("commit-a-change", "commit-a", &[], &[]),
|
|
@@ -426,7 +411,7 @@ mod tests {
|
|
|
426
411
|
)
|
|
427
412
|
.await;
|
|
428
413
|
|
|
429
|
-
let graph = CommitGraphContext::new(
|
|
414
|
+
let graph = CommitGraphContext::new();
|
|
430
415
|
let mut reader = graph.reader(storage);
|
|
431
416
|
let commits = reader
|
|
432
417
|
.reachable_commits("commit-head")
|
|
@@ -446,7 +431,7 @@ mod tests {
|
|
|
446
431
|
async fn reachable_commits_errors_on_missing_head_commit() {
|
|
447
432
|
let backend = Arc::new(UnitTestBackend::new());
|
|
448
433
|
let storage = StorageContext::new(backend.clone());
|
|
449
|
-
let graph = CommitGraphContext::new(
|
|
434
|
+
let graph = CommitGraphContext::new();
|
|
450
435
|
let mut reader = graph.reader(storage);
|
|
451
436
|
|
|
452
437
|
let error = reader
|
|
@@ -461,10 +446,8 @@ mod tests {
|
|
|
461
446
|
async fn best_common_ancestors_returns_nearest_common_commit_in_simple_graph() {
|
|
462
447
|
let backend = Arc::new(UnitTestBackend::new());
|
|
463
448
|
let storage = StorageContext::new(backend.clone());
|
|
464
|
-
let changelog = ChangelogContext::new();
|
|
465
449
|
append_changes(
|
|
466
450
|
storage.clone(),
|
|
467
|
-
&changelog,
|
|
468
451
|
&[
|
|
469
452
|
commit_change("commit-a-change", "commit-a", &[], &[]),
|
|
470
453
|
commit_change("commit-b-change", "commit-b", &[], &["commit-a"]),
|
|
@@ -474,7 +457,7 @@ mod tests {
|
|
|
474
457
|
)
|
|
475
458
|
.await;
|
|
476
459
|
|
|
477
|
-
let graph = CommitGraphContext::new(
|
|
460
|
+
let graph = CommitGraphContext::new();
|
|
478
461
|
let mut reader = graph.reader(storage);
|
|
479
462
|
let ancestors = reader
|
|
480
463
|
.best_common_ancestors("commit-c", "commit-d")
|
|
@@ -494,10 +477,8 @@ mod tests {
|
|
|
494
477
|
async fn best_common_ancestors_returns_shared_fork_in_diamond_graph() {
|
|
495
478
|
let backend = Arc::new(UnitTestBackend::new());
|
|
496
479
|
let storage = StorageContext::new(backend.clone());
|
|
497
|
-
let changelog = ChangelogContext::new();
|
|
498
480
|
append_changes(
|
|
499
481
|
storage.clone(),
|
|
500
|
-
&changelog,
|
|
501
482
|
&[
|
|
502
483
|
commit_change("commit-root-change", "commit-root", &[], &[]),
|
|
503
484
|
commit_change("commit-left-change", "commit-left", &[], &["commit-root"]),
|
|
@@ -518,7 +499,7 @@ mod tests {
|
|
|
518
499
|
)
|
|
519
500
|
.await;
|
|
520
501
|
|
|
521
|
-
let graph = CommitGraphContext::new(
|
|
502
|
+
let graph = CommitGraphContext::new();
|
|
522
503
|
let mut reader = graph.reader(storage);
|
|
523
504
|
let ancestors = reader
|
|
524
505
|
.best_common_ancestors("commit-left-head", "commit-right-head")
|
|
@@ -538,10 +519,8 @@ mod tests {
|
|
|
538
519
|
async fn best_common_ancestors_returns_parent_when_one_side_is_ancestor() {
|
|
539
520
|
let backend = Arc::new(UnitTestBackend::new());
|
|
540
521
|
let storage = StorageContext::new(backend.clone());
|
|
541
|
-
let changelog = ChangelogContext::new();
|
|
542
522
|
append_changes(
|
|
543
523
|
storage.clone(),
|
|
544
|
-
&changelog,
|
|
545
524
|
&[
|
|
546
525
|
commit_change("commit-a-change", "commit-a", &[], &[]),
|
|
547
526
|
commit_change("commit-b-change", "commit-b", &[], &["commit-a"]),
|
|
@@ -550,7 +529,7 @@ mod tests {
|
|
|
550
529
|
)
|
|
551
530
|
.await;
|
|
552
531
|
|
|
553
|
-
let graph = CommitGraphContext::new(
|
|
532
|
+
let graph = CommitGraphContext::new();
|
|
554
533
|
let mut reader = graph.reader(storage);
|
|
555
534
|
let ancestors = reader
|
|
556
535
|
.best_common_ancestors("commit-b", "commit-c")
|
|
@@ -570,10 +549,8 @@ mod tests {
|
|
|
570
549
|
async fn best_common_ancestors_returns_multiple_bases_for_criss_cross_graph() {
|
|
571
550
|
let backend = Arc::new(UnitTestBackend::new());
|
|
572
551
|
let storage = StorageContext::new(backend.clone());
|
|
573
|
-
let changelog = ChangelogContext::new();
|
|
574
552
|
append_changes(
|
|
575
553
|
storage.clone(),
|
|
576
|
-
&changelog,
|
|
577
554
|
&[
|
|
578
555
|
commit_change("commit-root-change", "commit-root", &[], &[]),
|
|
579
556
|
commit_change("commit-left-change", "commit-left", &[], &["commit-root"]),
|
|
@@ -594,7 +571,7 @@ mod tests {
|
|
|
594
571
|
)
|
|
595
572
|
.await;
|
|
596
573
|
|
|
597
|
-
let graph = CommitGraphContext::new(
|
|
574
|
+
let graph = CommitGraphContext::new();
|
|
598
575
|
let mut reader = graph.reader(storage);
|
|
599
576
|
let ancestors = reader
|
|
600
577
|
.best_common_ancestors("commit-head-left", "commit-head-right")
|
|
@@ -614,10 +591,8 @@ mod tests {
|
|
|
614
591
|
async fn merge_base_returns_single_best_common_ancestor() {
|
|
615
592
|
let backend = Arc::new(UnitTestBackend::new());
|
|
616
593
|
let storage = StorageContext::new(backend.clone());
|
|
617
|
-
let changelog = ChangelogContext::new();
|
|
618
594
|
append_changes(
|
|
619
595
|
storage.clone(),
|
|
620
|
-
&changelog,
|
|
621
596
|
&[
|
|
622
597
|
commit_change("commit-a-change", "commit-a", &[], &[]),
|
|
623
598
|
commit_change("commit-b-change", "commit-b", &[], &["commit-a"]),
|
|
@@ -627,7 +602,7 @@ mod tests {
|
|
|
627
602
|
)
|
|
628
603
|
.await;
|
|
629
604
|
|
|
630
|
-
let graph = CommitGraphContext::new(
|
|
605
|
+
let graph = CommitGraphContext::new();
|
|
631
606
|
let mut reader = graph.reader(storage);
|
|
632
607
|
let base = reader
|
|
633
608
|
.merge_base("commit-c", "commit-d")
|
|
@@ -641,10 +616,8 @@ mod tests {
|
|
|
641
616
|
async fn merge_base_errors_when_histories_have_no_common_commit() {
|
|
642
617
|
let backend = Arc::new(UnitTestBackend::new());
|
|
643
618
|
let storage = StorageContext::new(backend.clone());
|
|
644
|
-
let changelog = ChangelogContext::new();
|
|
645
619
|
append_changes(
|
|
646
620
|
storage.clone(),
|
|
647
|
-
&changelog,
|
|
648
621
|
&[
|
|
649
622
|
commit_change("commit-left-change", "commit-left", &[], &[]),
|
|
650
623
|
commit_change("commit-right-change", "commit-right", &[], &[]),
|
|
@@ -652,7 +625,7 @@ mod tests {
|
|
|
652
625
|
)
|
|
653
626
|
.await;
|
|
654
627
|
|
|
655
|
-
let graph = CommitGraphContext::new(
|
|
628
|
+
let graph = CommitGraphContext::new();
|
|
656
629
|
let mut reader = graph.reader(storage);
|
|
657
630
|
let error = reader
|
|
658
631
|
.merge_base("commit-left", "commit-right")
|
|
@@ -666,10 +639,8 @@ mod tests {
|
|
|
666
639
|
async fn merge_base_errors_when_best_common_ancestor_is_ambiguous() {
|
|
667
640
|
let backend = Arc::new(UnitTestBackend::new());
|
|
668
641
|
let storage = StorageContext::new(backend.clone());
|
|
669
|
-
let changelog = ChangelogContext::new();
|
|
670
642
|
append_changes(
|
|
671
643
|
storage.clone(),
|
|
672
|
-
&changelog,
|
|
673
644
|
&[
|
|
674
645
|
commit_change("commit-root-change", "commit-root", &[], &[]),
|
|
675
646
|
commit_change("commit-left-change", "commit-left", &[], &["commit-root"]),
|
|
@@ -690,7 +661,7 @@ mod tests {
|
|
|
690
661
|
)
|
|
691
662
|
.await;
|
|
692
663
|
|
|
693
|
-
let graph = CommitGraphContext::new(
|
|
664
|
+
let graph = CommitGraphContext::new();
|
|
694
665
|
let mut reader = graph.reader(storage);
|
|
695
666
|
let error = reader
|
|
696
667
|
.merge_base("commit-head-left", "commit-head-right")
|
|
@@ -721,30 +692,40 @@ mod tests {
|
|
|
721
692
|
);
|
|
722
693
|
}
|
|
723
694
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
695
|
+
#[derive(Clone)]
|
|
696
|
+
struct TestCommitChange {
|
|
697
|
+
change: Change,
|
|
698
|
+
parent_commit_ids: Vec<String>,
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
async fn append_changes(storage: StorageContext, changes: &[TestCommitChange]) {
|
|
729
702
|
let mut tx = storage
|
|
730
703
|
.begin_write_transaction()
|
|
731
704
|
.await
|
|
732
705
|
.expect("transaction should open");
|
|
733
706
|
let mut writes = StorageWriteSet::new();
|
|
734
|
-
let
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
.
|
|
738
|
-
.
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
.
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
707
|
+
let commit_store = CommitStoreContext::new();
|
|
708
|
+
for change in changes {
|
|
709
|
+
let commit_id = change
|
|
710
|
+
.change
|
|
711
|
+
.entity_id
|
|
712
|
+
.as_single_string()
|
|
713
|
+
.expect("commit fixture should have single id")
|
|
714
|
+
.to_string();
|
|
715
|
+
let author_account_ids = Vec::new();
|
|
716
|
+
let commit = CommitDraftRef {
|
|
717
|
+
id: &commit_id,
|
|
718
|
+
change_id: &change.change.id,
|
|
719
|
+
parent_ids: &change.parent_commit_ids,
|
|
720
|
+
author_account_ids: &author_account_ids,
|
|
721
|
+
created_at: &change.change.created_at,
|
|
722
|
+
};
|
|
723
|
+
commit_store
|
|
724
|
+
.writer(tx.as_mut(), &mut writes)
|
|
725
|
+
.stage_commit_draft(commit, Vec::new(), Vec::new())
|
|
726
|
+
.await
|
|
727
|
+
.expect("commit-store fixture should append");
|
|
728
|
+
}
|
|
748
729
|
writes
|
|
749
730
|
.apply(&mut tx.as_mut())
|
|
750
731
|
.await
|
|
@@ -757,24 +738,19 @@ mod tests {
|
|
|
757
738
|
commit_id: &str,
|
|
758
739
|
change_ids: &[&str],
|
|
759
740
|
parent_commit_ids: &[&str],
|
|
760
|
-
) ->
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}))
|
|
774
|
-
.expect("snapshot should serialize"),
|
|
775
|
-
),
|
|
776
|
-
metadata: None,
|
|
777
|
-
created_at: "2026-01-01T00:00:00Z".to_string(),
|
|
741
|
+
) -> TestCommitChange {
|
|
742
|
+
let _ = change_ids;
|
|
743
|
+
TestCommitChange {
|
|
744
|
+
change: Change {
|
|
745
|
+
id: change_id.to_string(),
|
|
746
|
+
entity_id: crate::entity_identity::EntityIdentity::single(commit_id),
|
|
747
|
+
schema_key: "lix_commit".to_string(),
|
|
748
|
+
file_id: None,
|
|
749
|
+
snapshot_ref: None,
|
|
750
|
+
metadata_ref: None,
|
|
751
|
+
created_at: "2026-01-01T00:00:00Z".to_string(),
|
|
752
|
+
},
|
|
753
|
+
parent_commit_ids: parent_commit_ids.iter().map(|id| id.to_string()).collect(),
|
|
778
754
|
}
|
|
779
755
|
}
|
|
780
756
|
}
|