@paradigma-inc/flywheel 0.2.66 → 0.2.68

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 (52) hide show
  1. package/package.json +1 -1
  2. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js +21 -12
  3. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js.map +1 -1
  4. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js +2 -0
  5. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js.map +1 -1
  6. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js +72 -0
  7. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js.map +1 -1
  8. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js +3 -1
  9. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js.map +1 -1
  10. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflict-view.js +300 -0
  11. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflict-view.js.map +1 -0
  12. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js +74 -25
  13. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js.map +1 -1
  14. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/edge-restoration.js +4 -50
  15. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/edge-restoration.js.map +1 -1
  16. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js +2 -3
  17. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js.map +1 -1
  18. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/local-replay.js +6 -0
  19. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/local-replay.js.map +1 -0
  20. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js +1 -7
  21. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js.map +1 -1
  22. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-artifacts.js +126 -0
  23. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-artifacts.js.map +1 -0
  24. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-state.js +423 -0
  25. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-state.js.map +1 -0
  26. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay-walk.js +133 -0
  27. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay-walk.js.map +1 -0
  28. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js +47 -127
  29. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js.map +1 -1
  30. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js +240 -9
  31. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js.map +1 -1
  32. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/tag-holders.js +78 -0
  33. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/tag-holders.js.map +1 -0
  34. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js +40 -1
  35. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js.map +1 -1
  36. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js +4 -9
  37. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js.map +1 -1
  38. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js +1 -1
  39. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js.map +1 -1
  40. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js +9 -2
  41. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js.map +1 -1
  42. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js +2 -0
  43. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js.map +1 -1
  44. package/src/runtime/vendor/flywheel-cli-dist/local/store/pending.js +79 -8
  45. package/src/runtime/vendor/flywheel-cli-dist/local/store/pending.js.map +1 -1
  46. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js +2 -1
  47. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js.map +1 -1
  48. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js +4 -2
  49. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js.map +1 -1
  50. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-arm64/node.napi.node +0 -0
  51. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-x64/node.napi.node +0 -0
  52. package/src/runtime/vendor/manifest.json +13 -1
@@ -0,0 +1,423 @@
1
+ import { RepositoryInvariantError, validateSemanticEdgeScale } from "../invariants.js";
2
+ import { TAG_DEFINITION_FIELDS } from "../models/constants.js";
3
+ import { TAG_NAME_MAX_CODE_POINTS } from "../models/tags.js";
4
+ import { definitionFromRow, projectionDigest } from "../../store/projection/tags.js";
5
+ import { snapshotRows } from "../../store/snapshot/schema.js";
6
+ import { DROP, KEEP, refuse } from "./local-replay.js";
7
+ import { PulledArtifacts } from "./pulled-artifacts.js";
8
+ function tagKey(scopeNodeId, tagId) {
9
+ return JSON.stringify([scopeNodeId, tagId]);
10
+ }
11
+ /** The relation no two semantic edges may share: graph, endpoints, and relation digest. */
12
+ function edgeRelationKey(relation) {
13
+ return JSON.stringify([relation.graph_node_id, relation.source_node_id, relation.target_node_id, relation.relation_digest]);
14
+ }
15
+ /** The pulled graph as far as lifecycle, tag, containment, and lineage preconditions go, updated as replay emits operations. */
16
+ export class PulledState {
17
+ #repositoryId;
18
+ #departures;
19
+ #lifecycle = new Map();
20
+ #tags = new Map();
21
+ #holders = new Map();
22
+ #containments = new Map();
23
+ /** Lineage links as JSON [parent repository, parent, child]. */
24
+ #lineage = new Set();
25
+ /** Each semantic edge's relation as JSON [graph, source, target, relation digest], the identity no two edges may share. */
26
+ #edges = new Map();
27
+ #artifacts;
28
+ /** `departures` maps a node the pulled history moved away to its new repository, for refusal messages. */
29
+ constructor(tables, repositoryId, departures = new Map()) {
30
+ this.#repositoryId = repositoryId;
31
+ this.#departures = departures;
32
+ for (const row of snapshotRows(tables, "repository_nodes"))
33
+ this.#lifecycle.set(row.node_id, row.lifecycle_state);
34
+ for (const row of snapshotRows(tables, "repository_tag_definitions")) {
35
+ this.#tags.set(tagKey(row.scope_node_id, row.tag_id), { state: row.state, definition: definitionFromRow(row) });
36
+ }
37
+ for (const row of snapshotRows(tables, "repository_tag_assignments")) {
38
+ this.#holdersOf(row.scope_repository_id, row.scope_node_id, row.tag_id).add(row.node_id);
39
+ }
40
+ for (const row of snapshotRows(tables, "repository_containments")) {
41
+ this.#containments.set(row.containment_id, {
42
+ container: row.container_node_id, child: row.child_node_id, relationDigest: row.relation_digest,
43
+ });
44
+ }
45
+ for (const row of snapshotRows(tables, "repository_lineage")) {
46
+ this.#lineage.add(JSON.stringify([row.parent_repository_id, row.parent_node_id, row.child_node_id]));
47
+ }
48
+ for (const row of snapshotRows(tables, "repository_semantic_edges")) {
49
+ this.#edges.set(row.edge_id, edgeRelationKey(row));
50
+ }
51
+ this.#artifacts = new PulledArtifacts(tables);
52
+ }
53
+ #links() {
54
+ return [...this.#lineage].map(link => JSON.parse(link));
55
+ }
56
+ /** Whether the artifact exists on the current pulled state. */
57
+ hasArtifact(artifactId) {
58
+ return this.#artifacts.has(artifactId);
59
+ }
60
+ /** Whether an artifact reference owner is live: a live node, or an edge whose graph and endpoints are live. */
61
+ #ownerLive(kind, ownerId) {
62
+ const edge = kind === "edge" ? this.#edges.get(ownerId) : undefined;
63
+ const nodes = kind === "node" ? [ownerId] : edge === undefined ? undefined : JSON.parse(edge).slice(0, 3);
64
+ return nodes !== undefined && nodes.every(nodeId => this.#lifecycle.get(nodeId) === "live");
65
+ }
66
+ /** Each contained node's container on the current pulled state. */
67
+ #containerOf() {
68
+ return new Map([...this.#containments.values()].map(({ container, child }) => [child, container]));
69
+ }
70
+ /**
71
+ * Adding edge `edgeId` with `relation` on the current pulled state, as the
72
+ * projection checks it: the edge must not exist yet, and its graph and
73
+ * endpoints must be live with both endpoints at the same depth beneath the
74
+ * graph. Equivalent edges are only a problem if both remain once replay is
75
+ * done (see equivalentEdge).
76
+ */
77
+ #edgeAddition(edgeId, relation) {
78
+ if (this.#edges.has(edgeId)) {
79
+ return refuse(`edge ${edgeId} already exists where replay adds it`, { reason: "edge_exists", edge_id: edgeId });
80
+ }
81
+ for (const endpoint of ["graph", "source", "target"]) {
82
+ const nodeId = relation[`${endpoint}_node_id`];
83
+ const lifecycle = this.#lifecycle.get(nodeId);
84
+ if (lifecycle === "live")
85
+ continue;
86
+ const target = lifecycle === undefined ? this.#departures.get(nodeId) : undefined;
87
+ const state = lifecycle ?? (target === undefined ? "missing" : "departed");
88
+ return refuse(`its ${endpoint} node ${nodeId} ${target === undefined ? `is ${state} where replay adds edge ${edgeId}` : `departed to repository ${target}`}`, {
89
+ reason: "endpoint_unavailable", edge_id: edgeId, endpoint, node_id: nodeId, node_state: state,
90
+ ...(target === undefined ? {} : { current_repository_id: target }),
91
+ });
92
+ }
93
+ const graphId = relation.graph_node_id;
94
+ const containerOf = this.#containerOf();
95
+ const scales = {};
96
+ for (const nodeId of [relation.source_node_id, relation.target_node_id]) {
97
+ let depth = 1;
98
+ for (let container = containerOf.get(nodeId); container !== undefined && depth <= containerOf.size; container = containerOf.get(container), depth += 1) {
99
+ if (container === graphId) {
100
+ scales[nodeId] = depth;
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ try {
106
+ validateSemanticEdgeScale(graphId, relation.source_node_id, relation.target_node_id, scales);
107
+ }
108
+ catch (error) {
109
+ if (!(error instanceof RepositoryInvariantError))
110
+ throw error;
111
+ return refuse(`its endpoints are not same-depth descendants of graph ${graphId} where replay adds edge ${edgeId}`, { reason: "graph_membership", edge_id: edgeId, graph_node_id: graphId });
112
+ }
113
+ return KEEP;
114
+ }
115
+ /**
116
+ * Another edge with the same graph, endpoints, and relation as edge
117
+ * `edgeId` on the current pulled state, which the service refuses to keep
118
+ * next to it; undefined when there is none or `edgeId` is gone.
119
+ */
120
+ equivalentEdge(edgeId) {
121
+ const key = this.#edges.get(edgeId);
122
+ if (key === undefined)
123
+ return undefined;
124
+ for (const [candidate, candidateKey] of this.#edges)
125
+ if (candidate !== edgeId && candidateKey === key)
126
+ return candidate;
127
+ return undefined;
128
+ }
129
+ /** The first containment or same-repository lineage counterpart of `nodeId` that is not live, as the projection checks on restore. */
130
+ #blockedRestore(nodeId) {
131
+ const counterparts = [
132
+ ...[...this.#containments.values()]
133
+ .flatMap(({ container, child }) => container === nodeId ? [["child", child]] : child === nodeId ? [["container", container]] : []),
134
+ ...this.#links().filter(([parentRepository]) => parentRepository === this.#repositoryId)
135
+ .flatMap(([, parent, child]) => parent === nodeId ? [["lineage child", child]] : child === nodeId ? [["lineage parent", parent]] : []),
136
+ ];
137
+ const blocked = counterparts.find(([, counterpart]) => this.#lifecycle.get(counterpart) !== "live");
138
+ if (blocked === undefined)
139
+ return undefined;
140
+ const [relation, counterpart] = blocked;
141
+ return refuse(`node ${nodeId} cannot be restored while its ${relation} ${counterpart} is ${this.#lifecycle.get(counterpart) ?? "absent"} in the remote history.`, { reason: "structure", node_id: nodeId, counterpart_node_id: counterpart });
142
+ }
143
+ /**
144
+ * Refuses leaving `nodeId` tombstoned while lineage still links it, which the
145
+ * store checks once a whole batch has applied (assertTombstonesReleaseLineage).
146
+ */
147
+ tombstoneBlockedByLineage(nodeId) {
148
+ if (this.#lifecycle.get(nodeId) !== "tombstoned")
149
+ return undefined;
150
+ const links = this.#links().filter(([parentRepository, parent, child]) => child === nodeId || (parentRepository === this.#repositoryId && parent === nodeId));
151
+ if (links.length === 0)
152
+ return undefined;
153
+ const linked = links.map(([, parent, child]) => (child === nodeId ? parent : child));
154
+ return refuse(`node ${nodeId} cannot stay tombstoned while lineage in the remote history links it to ${linked.join(", ")}.`, { reason: "lineage", node_id: nodeId, linked_node_ids: linked });
155
+ }
156
+ #holdersOf(scopeRepositoryId, scopeNodeId, tagId) {
157
+ const key = JSON.stringify([scopeRepositoryId ?? this.#repositoryId, scopeNodeId, tagId]);
158
+ let holders = this.#holders.get(key);
159
+ if (holders === undefined)
160
+ this.#holders.set(key, holders = new Set());
161
+ return holders;
162
+ }
163
+ /** The nodes holding a tag on the current pulled state. */
164
+ holders(scopeRepositoryId, scopeNodeId, tagId) {
165
+ return [...this.#holdersOf(scopeRepositoryId, scopeNodeId, tagId)];
166
+ }
167
+ #unavailableNode(nodeId) {
168
+ const state = this.#lifecycle.get(nodeId);
169
+ if (state === "live" || state === "tombstoned")
170
+ return undefined;
171
+ const target = this.#departures.get(nodeId);
172
+ if (target !== undefined) {
173
+ return refuse(`node ${nodeId} moved to repository ${target}, and resolving a conflict never restores a node.`, { reason: "departed", node_id: nodeId, current_repository_id: target });
174
+ }
175
+ const described = state === "purged" ? "was purged" : "is not";
176
+ return refuse(`node ${nodeId} ${described} in the remote history, and resolving a conflict never restores a node.`, { reason: state === "purged" ? "purged" : "missing", node_id: nodeId });
177
+ }
178
+ /** Refuses an operation the projection only applies to live nodes when one of them is not live on the pulled state. */
179
+ #notLive(nodeIds, needs) {
180
+ const nodeId = nodeIds.find(candidate => this.#lifecycle.get(candidate) !== "live");
181
+ if (nodeId === undefined)
182
+ return undefined;
183
+ const state = this.#lifecycle.get(nodeId);
184
+ if (state === undefined || state === "purged")
185
+ return this.#unavailableNode(nodeId);
186
+ return refuse(`node ${nodeId} is ${state} in the remote history, and ${needs} needs a live node.`, { reason: state, node_id: nodeId });
187
+ }
188
+ /** How `operation` replays on the current pulled state. */
189
+ plan(operation) {
190
+ const payload = operation.payload;
191
+ switch (operation.type) {
192
+ case "node.field.set.v1":
193
+ case "node.source_timestamps.recover.v1":
194
+ return this.#unavailableNode(payload.node_id) ?? KEEP;
195
+ case "node.tombstone.v1":
196
+ case "node.restore.v1": {
197
+ const nodeId = payload.node_id;
198
+ const target = operation.type === "node.tombstone.v1" ? "tombstoned" : "live";
199
+ if (this.#lifecycle.get(nodeId) === target)
200
+ return DROP;
201
+ return this.#unavailableNode(nodeId) ?? (operation.type === "node.restore.v1" ? this.#blockedRestore(nodeId) : undefined) ?? KEEP;
202
+ }
203
+ case "tag.define.v1": {
204
+ // Tag IDs are random, so a define that meets an existing tag re-activates it (a reverted retirement).
205
+ const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
206
+ if (tag?.state === "active")
207
+ return DROP;
208
+ const scope = this.#notLive([payload.scope_node_id], "defining a tag");
209
+ if (scope !== undefined)
210
+ return scope;
211
+ // A retired tag re-activates with the definition it was retired with, which the pull may have changed.
212
+ return tag === undefined ? KEEP : { action: "keep", rewrite: { definition: tag.definition } };
213
+ }
214
+ case "tag.update.v1":
215
+ case "tag.retire.v1": {
216
+ const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
217
+ if (tag?.state !== "active") {
218
+ if (operation.type === "tag.retire.v1" && tag?.state === "retired")
219
+ return DROP;
220
+ return refuse(`tag ${String(payload.tag_id)} is ${tag === undefined ? "not" : "retired"} in the remote history, so the local ` +
221
+ `${operation.type === "tag.update.v1" ? "update" : "retirement"} cannot be applied.`, { reason: tag === undefined ? "absent" : "retired", scope_node_id: payload.scope_node_id, tag_id: payload.tag_id });
222
+ }
223
+ const scope = this.#notLive([payload.scope_node_id], operation.type === "tag.update.v1" ? "updating a tag" : "retiring a tag");
224
+ if (scope !== undefined)
225
+ return scope;
226
+ const rewrite = {
227
+ expected_definition_digest: projectionDigest(tag.definition),
228
+ previous_definition: tag.definition,
229
+ };
230
+ if (operation.type === "tag.update.v1") {
231
+ // History counters are service-controlled; the local update keeps its own name, colors, and flags.
232
+ const { history_of_tag_id, history_index, history_next_index } = tag.definition;
233
+ rewrite.definition = { ...payload.definition, history_of_tag_id, history_index, history_next_index };
234
+ }
235
+ return { action: "keep", rewrite };
236
+ }
237
+ case "node.tag.remove.v1": {
238
+ const nodeId = payload.node_id;
239
+ if (!this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id).has(nodeId))
240
+ return DROP;
241
+ // The service removes a holder only while the holder, and a scope in this repository, are live.
242
+ const external = payload.scope_repository_id !== undefined && payload.scope_repository_id !== null &&
243
+ payload.scope_repository_id !== this.#repositoryId;
244
+ return this.#notLive(external ? [nodeId] : [payload.scope_node_id, nodeId], "removing a tag") ?? KEEP;
245
+ }
246
+ case "node.tag.assign.v1": {
247
+ const holders = this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id);
248
+ const nodeId = payload.node_id;
249
+ // Giving a node the tag it already holds changes nothing. A tracked replacement also records history,
250
+ // which the pull's own assignment did not, and a same-holder assignment confirms the holding instead.
251
+ if (holders.has(nodeId) && payload.assignment_mode === "initial")
252
+ return DROP;
253
+ if (holders.has(nodeId) && payload.assignment_mode === "tracked_replacement") {
254
+ return refuse(`node ${nodeId} already holds tag ${String(payload.tag_id)} in the remote history, so the local replacement and its history entry cannot be applied.`, { reason: "holder_changed", node_id: nodeId, tag_id: payload.tag_id });
255
+ }
256
+ const external = payload.scope_repository_id !== undefined && payload.scope_repository_id !== null &&
257
+ payload.scope_repository_id !== this.#repositoryId;
258
+ const dead = this.#notLive(external ? [nodeId] : [payload.scope_node_id, nodeId], "giving a tag");
259
+ if (dead !== undefined)
260
+ return dead;
261
+ const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
262
+ if (!external && tag?.state !== "active") {
263
+ return refuse(`tag ${String(payload.tag_id)} is ${tag === undefined ? "not" : "retired"} in the remote history, so node ${nodeId} cannot be given it.`, { reason: tag === undefined ? "absent" : "retired", node_id: nodeId, tag_id: payload.tag_id });
264
+ }
265
+ if (payload.assignment_mode === "same_holder") {
266
+ return holders.has(nodeId) ? KEEP : refuse(`node ${nodeId} no longer holds tag ${String(payload.tag_id)} in the remote history.`, { reason: "holder_changed", node_id: nodeId, tag_id: payload.tag_id });
267
+ }
268
+ // A tag several nodes may hold accepts another holder; a one-only tag needs the holder the operation was written against.
269
+ if (payload.assignment_mode === "initial" && tag?.definition.one_only !== true)
270
+ return KEEP;
271
+ const current = [...holders];
272
+ const expected = payload.assignment_mode === "initial" ? [] : [payload.prior_holder];
273
+ const tracked = payload.assignment_mode === "tracked_replacement";
274
+ const sameHistory = !tracked ||
275
+ (tag?.definition.track_history === true && tag.definition.history_next_index === BigInt(payload.expected_history_next_index));
276
+ if (sameHistory && current.length === expected.length && current.every((holder, index) => holder === expected[index])) {
277
+ if (!tracked)
278
+ return KEEP;
279
+ // The history entry is named and colored after the tag's current definition, which the pull may have changed.
280
+ // A matching tracked replacement implies the tag exists and tracks history.
281
+ const { name, bg_color, text_color } = tag.definition;
282
+ const historyName = `${String(name)} (history ${String(payload.history_index)})`;
283
+ if ([...historyName].length > TAG_NAME_MAX_CODE_POINTS) {
284
+ return refuse(`the history entry of tag ${String(payload.tag_id)} would be named after its remote name, which leaves no room ` +
285
+ `for the history suffix, so the local replacement cannot be applied.`, { reason: "history_name_too_long", node_id: nodeId, tag_id: payload.tag_id });
286
+ }
287
+ return { action: "keep", rewrite: { history_tag: { ...payload.history_tag, name: historyName, bg_color, text_color } } };
288
+ }
289
+ return refuse(`tag ${String(payload.tag_id)} is held by ${current.length === 0 ? "no node" : current.join(", ")} in the remote history, ` +
290
+ `so the local assignment to node ${nodeId} cannot be applied.`, { reason: "holder_changed", node_id: nodeId, tag_id: payload.tag_id, holders: current });
291
+ }
292
+ case "containment.remove.v1": {
293
+ const containmentId = payload.containment_id;
294
+ const current = this.#containments.get(containmentId);
295
+ if (current === undefined)
296
+ return DROP;
297
+ if (current.child === payload.child_node_id && current.relationDigest === payload.relation_digest)
298
+ return KEEP;
299
+ return refuse(`containment ${containmentId} was placed again differently in the remote history, so the local removal cannot be applied.`, { reason: "relation_changed", containment_id: containmentId, child_node_id: payload.child_node_id });
300
+ }
301
+ case "containment.assign.v1": {
302
+ const childId = payload.child_node_id;
303
+ const current = [...this.#containments].find(([, containment]) => containment.child === childId);
304
+ if (current !== undefined) {
305
+ // The pull already made this exact placement (for example both sides reverted the same removal).
306
+ if (current[0] === payload.containment_id && current[1].container === payload.container_node_id &&
307
+ current[1].relationDigest === payload.relation_digest)
308
+ return DROP;
309
+ return refuse(`node ${childId} is already placed by containment ${current[0]} in the remote history, so the local placement cannot be applied.`, { reason: "contained", child_node_id: childId, containment_id: current[0] });
310
+ }
311
+ // Placing the child under a container that already sits beneath it would close a containment cycle.
312
+ const containerOf = this.#containerOf();
313
+ for (let ancestor = payload.container_node_id; ancestor !== undefined; ancestor = containerOf.get(ancestor)) {
314
+ if (ancestor === childId) {
315
+ return refuse(`placing node ${childId} inside ${String(payload.container_node_id)} would create a containment cycle in the remote history.`, { reason: "cycle", child_node_id: childId, container_node_id: payload.container_node_id });
316
+ }
317
+ }
318
+ return this.#notLive([payload.container_node_id, childId], "placing a node in a container") ?? KEEP;
319
+ }
320
+ case "edge.add.v1":
321
+ return this.#edgeAddition(payload.edge_id, payload);
322
+ case "edge.remove.v1": {
323
+ // An edge the pull already removed needs no removal; the store removes only the same relation, and not while artifacts hang off it.
324
+ const edgeId = payload.edge_id;
325
+ const current = this.#edges.get(edgeId);
326
+ if (current === undefined)
327
+ return DROP;
328
+ if (JSON.parse(current)[3] !== payload.relation_digest) {
329
+ return refuse(`edge ${edgeId} was added again differently in the remote history, so the local removal cannot be applied.`, { reason: "relation_changed", edge_id: edgeId });
330
+ }
331
+ const held = this.#artifacts.heldBy("edge", edgeId);
332
+ return held.length === 0 ? KEEP : refuse(`edge ${edgeId} holds artifact ${held.join(", ")} in the remote history, so the local removal cannot be applied.`, { reason: "edge_referenced", edge_id: edgeId, artifact_ids: held });
333
+ }
334
+ case "artifact.attach.v1":
335
+ case "artifact.attach.v2":
336
+ case "artifact.detach.v1":
337
+ case "artifact.content.set.v1":
338
+ case "artifact.properties.set.v1":
339
+ case "artifact.metadata.set.v1":
340
+ return this.#artifacts.plan(operation, (kind, ownerId) => this.#ownerLive(kind, ownerId));
341
+ default:
342
+ return KEEP;
343
+ }
344
+ }
345
+ /** Records the effect of an operation that replay emitted. */
346
+ apply(operation) {
347
+ const payload = operation.payload;
348
+ switch (operation.type) {
349
+ case "node.create.v1":
350
+ case "node.restore.v1":
351
+ this.#lifecycle.set(payload.node_id, "live");
352
+ return;
353
+ case "node.tombstone.v1":
354
+ this.#lifecycle.set(payload.node_id, "tombstoned");
355
+ return;
356
+ case "node.purge.v1":
357
+ this.#lifecycle.set(payload.node_id, "purged");
358
+ return;
359
+ case "tag.define.v1":
360
+ case "tag.update.v1":
361
+ this.#tags.set(tagKey(payload.scope_node_id, payload.tag_id), { definition: payload.definition, state: "active" });
362
+ return;
363
+ case "tag.retire.v1": {
364
+ const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
365
+ if (tag !== undefined)
366
+ tag.state = "retired";
367
+ return;
368
+ }
369
+ case "node.tag.assign.v1": {
370
+ const holders = this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id);
371
+ if (payload.assignment_mode === "tracked_replacement") {
372
+ holders.delete(payload.prior_holder);
373
+ const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
374
+ if (tag !== undefined)
375
+ tag.definition = { ...tag.definition, history_next_index: BigInt(tag.definition.history_next_index) + 1n };
376
+ // The replacement also defines the history tag that records the previous holder (replaceTrackedAssignment).
377
+ const historyTag = payload.history_tag;
378
+ this.#tags.set(tagKey(payload.scope_node_id, payload.history_entry_id), {
379
+ definition: Object.fromEntries(TAG_DEFINITION_FIELDS.map(field => [field, historyTag[field]])), state: "active",
380
+ });
381
+ }
382
+ holders.add(payload.node_id);
383
+ return;
384
+ }
385
+ case "node.tag.remove.v1":
386
+ this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id).delete(payload.node_id);
387
+ return;
388
+ case "containment.assign.v1":
389
+ this.#containments.set(payload.containment_id, {
390
+ container: payload.container_node_id, child: payload.child_node_id, relationDigest: payload.relation_digest,
391
+ });
392
+ return;
393
+ case "containment.remove.v1":
394
+ this.#containments.delete(payload.containment_id);
395
+ return;
396
+ case "lineage.add.v1":
397
+ case "lineage.remove.v1": {
398
+ const link = JSON.stringify([payload.parent_repository_id ?? this.#repositoryId, payload.parent_node_id, payload.child_node_id]);
399
+ if (operation.type === "lineage.add.v1")
400
+ this.#lineage.add(link);
401
+ else
402
+ this.#lineage.delete(link);
403
+ return;
404
+ }
405
+ case "edge.add.v1":
406
+ this.#edges.set(payload.edge_id, edgeRelationKey(payload));
407
+ return;
408
+ case "edge.remove.v1":
409
+ this.#edges.delete(payload.edge_id);
410
+ return;
411
+ case "artifact.attach.v1":
412
+ case "artifact.attach.v2":
413
+ case "artifact.detach.v1":
414
+ case "artifact.content.set.v1":
415
+ case "artifact.properties.set.v1":
416
+ case "artifact.metadata.set.v1":
417
+ this.#artifacts.apply(operation);
418
+ return;
419
+ default:
420
+ }
421
+ }
422
+ }
423
+ //# sourceMappingURL=pulled-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulled-state.js","sourceRoot":"","sources":["../../../../src/local/domain/rebase/pulled-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,EAAE,YAAY,EAAuB,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAoB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAsBxD,SAAS,MAAM,CAAC,WAA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OAAO;YACT,QAAQ;QACV,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,133 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { RepositoryOperation } from "../models/operations.js";
3
+ import { localOperationNodeIds } from "../models/operation-identity.js";
4
+ import { edgeDependency, removedEdges, restoredEdgeOperation } from "./edge-restoration.js";
5
+ import { operationKey } from "./keys.js";
6
+ import { PulledState } from "./pulled-state.js";
7
+ import { tagHolderKey } from "./tag-holders.js";
8
+ /** The resolution recorded for `key`, if any. */
9
+ export function resolutionFor(resolutions, key) {
10
+ for (const [candidate, resolution] of resolutions) {
11
+ if (candidate.length === key.length && candidate.every((value, index) => value === key[index]))
12
+ return resolution;
13
+ }
14
+ return undefined;
15
+ }
16
+ /** Nodes whose departure to another repository was accepted with a remote choice. */
17
+ export function remoteDepartureNodeIds(resolutions) {
18
+ const nodeIds = new Set();
19
+ for (const [key, [strategy]] of resolutions) {
20
+ if (key.length === 3 && key[0] === "departure" && strategy === "remote")
21
+ nodeIds.add(key[1]);
22
+ }
23
+ return nodeIds;
24
+ }
25
+ /**
26
+ * Walks the local operations in order, one `steps` call per operation, keeping
27
+ * the pulled lifecycle, tag, containment, edge, and artifact reference state
28
+ * up to date with every operation the walk lets through.
29
+ */
30
+ export class ReplayWalk {
31
+ #input;
32
+ #departed;
33
+ #restorations;
34
+ #pending;
35
+ #discarded;
36
+ #discardedArtifacts = new Set();
37
+ /** Tag_holder conflict keys, as JSON, whose pulled holders a local choice has already removed. */
38
+ #tagsTaken = new Set();
39
+ /** The pulled state after every operation the walk has let through so far. */
40
+ state;
41
+ constructor(input) {
42
+ this.#input = input;
43
+ this.#departed = remoteDepartureNodeIds(input.resolutions);
44
+ const removed = removedEdges(input.resolutions, input.remoteTables, input.localTables, input.localCommitsNewestFirst, input.rebaseId);
45
+ this.#restorations = removed.restorations;
46
+ this.#pending = new Map(removed.restorations);
47
+ this.#discarded = removed.discarded;
48
+ this.state = new PulledState(input.remoteTables, input.repositoryId, input.departures);
49
+ }
50
+ /** The steps of every operation in `commit`, in order. */
51
+ *commitSteps(commit) {
52
+ for (const operation of commit.operations)
53
+ yield* this.steps(operation);
54
+ }
55
+ /** What replay does with `operation`, the next local operation in order. */
56
+ *steps(operation) {
57
+ const { graphMembership, resolutions } = this.#input;
58
+ for (const inserted of graphMembership.insertBefore.get(operation.operationId) ?? []) {
59
+ const restored = RepositoryOperation.fromMapping({ ...inserted, operation_id: randomUUID() });
60
+ this.state.apply(restored);
61
+ yield { kind: "inserted", operation: restored, original: operation };
62
+ }
63
+ if (graphMembership.drop.has(operation.operationId))
64
+ return;
65
+ if (localOperationNodeIds(operation).some(nodeId => this.#departed.has(nodeId)))
66
+ return;
67
+ const edgeId = edgeDependency(operation);
68
+ const artifactId = operation.type.startsWith("artifact.") ? operation.payload.artifact_id : undefined;
69
+ if (edgeId !== undefined && this.#discarded.has(edgeId)) {
70
+ if (artifactId !== undefined)
71
+ this.#discardedArtifacts.add(artifactId);
72
+ return;
73
+ }
74
+ // An artifact that only a discarded edge attachment created does not exist for later local operations,
75
+ // so they are skipped until a kept attachment replays: an attach carries the artifact's object and
76
+ // properties and creates it when absent (store/projection/artifacts.ts).
77
+ if (artifactId !== undefined && this.#discardedArtifacts.has(artifactId) && !this.state.hasArtifact(artifactId) &&
78
+ operation.type !== "artifact.attach.v1" && operation.type !== "artifact.attach.v2")
79
+ return;
80
+ // A tag_holder choice decides its tag's local holder operations; other operations follow their own key.
81
+ const holderKey = tagHolderKey(operation);
82
+ const holderResolution = holderKey === undefined ? undefined : resolutionFor(resolutions, holderKey);
83
+ const resolution = holderResolution ?? resolutionFor(resolutions, operationKey(operation));
84
+ if (resolution?.[0] === "remote")
85
+ return;
86
+ if (holderResolution?.[0] === "local" && operation.payload.assignment_mode === "initial" && !this.#tagsTaken.has(JSON.stringify(holderKey))) {
87
+ // Keeping this checkout's holder: the pulled holders lose the tag just before the first local assignment that needs
88
+ // it free. A tracked or same-holder assignment names the holder it expects and replays against the pulled one as written.
89
+ this.#tagsTaken.add(JSON.stringify(holderKey));
90
+ const { scope_repository_id: scopeRepositoryId, scope_node_id: scopeNodeId, tag_id: tagId } = operation.payload;
91
+ for (const holder of this.state.holders(scopeRepositoryId, scopeNodeId, tagId)) {
92
+ const removal = RepositoryOperation.fromMapping({
93
+ type: "node.tag.remove.v1", operation_id: randomUUID(), repository_id: operation.repositoryId,
94
+ ...(scopeRepositoryId === undefined ? {} : { scope_repository_id: scopeRepositoryId }),
95
+ scope_node_id: scopeNodeId, node_id: holder, tag_id: tagId, expected_holder: holder, relation_metadata: {},
96
+ });
97
+ const planned = this.state.plan(removal);
98
+ if (planned.action === "refuse") {
99
+ yield { kind: "refused", original: operation, resolution, problem: planned.problem, details: planned.details };
100
+ return;
101
+ }
102
+ this.state.apply(removal);
103
+ yield { kind: "inserted", operation: removal, original: operation };
104
+ }
105
+ }
106
+ const restoration = edgeId === undefined ? undefined : this.#pending.get(edgeId);
107
+ if (restoration !== undefined) {
108
+ this.#pending.delete(restoration.edgeId);
109
+ const restored = restoredEdgeOperation(restoration, randomUUID());
110
+ const planned = this.state.plan(restored);
111
+ if (planned.action === "refuse") {
112
+ yield { kind: "refused", original: operation, resolution, problem: planned.problem, details: planned.details, restoration };
113
+ return;
114
+ }
115
+ this.state.apply(restored);
116
+ yield { kind: "restored", restoration, operation: restored, original: operation };
117
+ }
118
+ // The restoration carries the first local content edit.
119
+ if (edgeId !== undefined && this.#restorations.get(edgeId)?.firstEdit.operation.operationId === operation.operationId)
120
+ return;
121
+ const planned = this.state.plan(operation);
122
+ if (planned.action === "drop")
123
+ return;
124
+ if (planned.action === "refuse") {
125
+ yield { kind: "refused", original: operation, resolution, problem: planned.problem, details: planned.details };
126
+ return;
127
+ }
128
+ const { rewrite } = planned;
129
+ this.state.apply(rewrite === undefined ? operation : RepositoryOperation.fromMapping({ ...operation.toMapping(), ...rewrite }));
130
+ yield { kind: "kept", original: operation, resolution, rewrite };
131
+ }
132
+ }
133
+ //# sourceMappingURL=replay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