@paradigma-inc/flywheel 0.2.61 → 0.2.67
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/package.json +1 -1
- package/skills/flywheel-repo/references/repository-commands.md +2 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js +19 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js +94 -42
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js +23 -15
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js +20 -27
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js +72 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/types.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js +55 -49
- package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js +3 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflict-view.js +288 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflict-view.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js +162 -11
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/edge-restoration.js +95 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/edge-restoration.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/graph-membership.js +351 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/graph-membership.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/local-replay.js +6 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/local-replay.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js +26 -18
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-artifacts.js +126 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-artifacts.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-state.js +412 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pulled-state.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay-walk.js +107 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay-walk.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js +139 -130
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js +245 -5
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js +33 -3
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js +14 -15
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js +4 -9
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/recover-departed.js +52 -9
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/recover-departed.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/snapshot-diff.js +12 -19
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/snapshot-diff.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/pending.js +85 -13
- package/src/runtime/vendor/flywheel-cli-dist/local/store/pending.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js +2 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js +4 -2
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js +7 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js +5 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js +5 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js +29 -9
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js +1 -4
- package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/main.js +1 -3
- package/src/runtime/vendor/flywheel-cli-dist/main.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-x64/node.napi.node +0 -0
- package/src/runtime/vendor/manifest.json +15 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { artifactReferenceSetDigest } from "../models/artifact-properties.js";
|
|
2
|
+
import { isRecord } from "../models/constants.js";
|
|
3
|
+
import { referenceDigest } from "../../store/projection/artifacts.js";
|
|
4
|
+
import { snapshotRows } from "../../store/snapshot/schema.js";
|
|
5
|
+
import { DROP, KEEP, refuse } from "./local-replay.js";
|
|
6
|
+
/** An artifact reference's owner as "kind\0id". */
|
|
7
|
+
function ownerKey(owner) {
|
|
8
|
+
return isRecord(owner) ? `${String(owner.owner_type)}\u0000${String(owner.owner_id)}` : "";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The pulled artifacts and their references, and the rules for replaying a
|
|
12
|
+
* local artifact operation on them, as projection/artifacts.ts checks it: an
|
|
13
|
+
* attachment needs a live owner and, for an artifact that exists, the same
|
|
14
|
+
* object; a detachment the pull already made is dropped, and otherwise it
|
|
15
|
+
* names the pulled reference; a content or properties change names the pulled
|
|
16
|
+
* reference set, which must still hold a live owner; a legacy metadata edit
|
|
17
|
+
* needs the reference it names. Properties are checked by the trial replay
|
|
18
|
+
* (store/pending.ts TrialGraph), which has their text.
|
|
19
|
+
*/
|
|
20
|
+
export class PulledArtifacts {
|
|
21
|
+
/** Each artifact's object digest. */
|
|
22
|
+
#objects = new Map();
|
|
23
|
+
/** Each artifact's references: owner as "kind\0id" to reference order. */
|
|
24
|
+
#references = new Map();
|
|
25
|
+
constructor(tables) {
|
|
26
|
+
for (const row of snapshotRows(tables, "repository_artifacts"))
|
|
27
|
+
this.#objects.set(row.artifact_id, row.object_digest);
|
|
28
|
+
for (const row of snapshotRows(tables, "repository_artifact_references")) {
|
|
29
|
+
this.#referencesOf(row.artifact_id).set(`${String(row.owner_kind)}\u0000${String(row.owner_id)}`, BigInt(row.reference_order));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
#referencesOf(artifactId) {
|
|
33
|
+
const references = this.#references.get(artifactId) ?? new Map();
|
|
34
|
+
this.#references.set(artifactId, references);
|
|
35
|
+
return references;
|
|
36
|
+
}
|
|
37
|
+
has(artifactId) {
|
|
38
|
+
return this.#objects.has(artifactId);
|
|
39
|
+
}
|
|
40
|
+
/** Artifacts that `kind` `ownerId` still holds a reference to. */
|
|
41
|
+
heldBy(kind, ownerId) {
|
|
42
|
+
const owner = `${kind}\u0000${ownerId}`;
|
|
43
|
+
return [...this.#references].flatMap(([artifactId, owners]) => owners.has(owner) ? [artifactId] : []);
|
|
44
|
+
}
|
|
45
|
+
/** How an artifact operation replays; other operations are kept. */
|
|
46
|
+
plan(operation, ownerLive) {
|
|
47
|
+
const payload = operation.payload;
|
|
48
|
+
const artifactId = payload.artifact_id;
|
|
49
|
+
switch (operation.type) {
|
|
50
|
+
case "artifact.attach.v1":
|
|
51
|
+
case "artifact.attach.v2": {
|
|
52
|
+
const [kind, ownerId] = ownerKey(payload.owner).split("\u0000");
|
|
53
|
+
if (!ownerLive(kind, ownerId)) {
|
|
54
|
+
return refuse(`${kind} ${ownerId} is not live in the remote history, so artifact ${artifactId} cannot be attached to it.`, { reason: "owner_unavailable", artifact_id: artifactId, owner_type: kind, owner_id: ownerId });
|
|
55
|
+
}
|
|
56
|
+
// Attaching an artifact that exists adds a reference to it as it was when the attachment was written.
|
|
57
|
+
const object = this.#objects.get(artifactId);
|
|
58
|
+
if (object !== undefined && object !== payload.object_digest) {
|
|
59
|
+
return refuse(`artifact ${artifactId} has other content in the remote history, so the local attachment cannot be applied.`, { reason: "artifact_changed", artifact_id: artifactId });
|
|
60
|
+
}
|
|
61
|
+
const order = this.#references.get(artifactId)?.get(ownerKey(payload.owner));
|
|
62
|
+
if (order === undefined)
|
|
63
|
+
return KEEP;
|
|
64
|
+
return order === BigInt(payload.order) ? DROP : refuse(`artifact ${artifactId} is already attached to ${kind} ${ownerId} at another position in the remote history, so the local attachment cannot be applied.`, { reason: "reference_changed", artifact_id: artifactId, owner_type: kind, owner_id: ownerId });
|
|
65
|
+
}
|
|
66
|
+
case "artifact.detach.v1": {
|
|
67
|
+
// A reference the pull already removed needs no detachment; otherwise the detachment names the pulled reference.
|
|
68
|
+
const order = this.#references.get(artifactId)?.get(ownerKey(payload.owner));
|
|
69
|
+
if (order === undefined)
|
|
70
|
+
return DROP;
|
|
71
|
+
const objectDigest = this.#objects.get(artifactId);
|
|
72
|
+
const [kind, ownerId] = ownerKey(payload.owner).split("\u0000");
|
|
73
|
+
return { action: "keep", rewrite: { object_digest: objectDigest, reference_digest: referenceDigest(artifactId, objectDigest, kind, ownerId, order) } };
|
|
74
|
+
}
|
|
75
|
+
case "artifact.content.set.v1":
|
|
76
|
+
case "artifact.properties.set.v1": {
|
|
77
|
+
// These changes name the artifact's whole reference set, which the pull may have changed, and the store
|
|
78
|
+
// accepts them only while the artifact has references whose owners are live.
|
|
79
|
+
const references = [...this.#references.get(artifactId) ?? []].map(([owner, order]) => {
|
|
80
|
+
const [kind, ownerId] = owner.split("\u0000");
|
|
81
|
+
return { owner_type: kind, owner_id: ownerId, order };
|
|
82
|
+
});
|
|
83
|
+
if (references.length === 0) {
|
|
84
|
+
return refuse(`artifact ${artifactId} has no references left in the remote history, so the local change to it cannot be applied.`, { reason: "unreferenced", artifact_id: artifactId });
|
|
85
|
+
}
|
|
86
|
+
const dead = references.find(({ owner_type, owner_id }) => !ownerLive(owner_type, owner_id));
|
|
87
|
+
if (dead !== undefined) {
|
|
88
|
+
return refuse(`artifact ${artifactId} is held by ${dead.owner_type} ${dead.owner_id}, which is not live in the remote history, so the local change to it cannot be applied.`, { reason: "owner_unavailable", artifact_id: artifactId, owner_type: dead.owner_type, owner_id: dead.owner_id });
|
|
89
|
+
}
|
|
90
|
+
return { action: "keep", rewrite: { expected_reference_digest: artifactReferenceSetDigest(references) } };
|
|
91
|
+
}
|
|
92
|
+
case "artifact.metadata.set.v1": {
|
|
93
|
+
// A legacy metadata edit goes through the reference it names, which must still be there.
|
|
94
|
+
if (this.#references.get(artifactId)?.has(ownerKey(payload.owner)))
|
|
95
|
+
return KEEP;
|
|
96
|
+
const [kind, ownerId] = ownerKey(payload.owner).split("\u0000");
|
|
97
|
+
return refuse(`artifact ${artifactId} is no longer attached to ${kind} ${ownerId} in the remote history, so the local metadata change cannot be applied.`, { reason: "owner_reference_missing", artifact_id: artifactId, owner_type: kind, owner_id: ownerId });
|
|
98
|
+
}
|
|
99
|
+
default:
|
|
100
|
+
return KEEP;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Records the effect of an artifact operation that replay emitted. */
|
|
104
|
+
apply(operation) {
|
|
105
|
+
const payload = operation.payload;
|
|
106
|
+
const artifactId = payload.artifact_id;
|
|
107
|
+
switch (operation.type) {
|
|
108
|
+
case "artifact.attach.v1":
|
|
109
|
+
case "artifact.attach.v2":
|
|
110
|
+
// An attachment creates the artifact when it is absent; an existing artifact keeps its object.
|
|
111
|
+
if (!this.#objects.has(artifactId))
|
|
112
|
+
this.#objects.set(artifactId, payload.object_digest);
|
|
113
|
+
this.#referencesOf(artifactId).set(ownerKey(payload.owner), BigInt(payload.order));
|
|
114
|
+
return;
|
|
115
|
+
case "artifact.detach.v1":
|
|
116
|
+
this.#referencesOf(artifactId).delete(ownerKey(payload.owner));
|
|
117
|
+
return;
|
|
118
|
+
case "artifact.content.set.v1":
|
|
119
|
+
if (this.#objects.has(artifactId))
|
|
120
|
+
this.#objects.set(artifactId, payload.object_digest);
|
|
121
|
+
return;
|
|
122
|
+
default:
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=pulled-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulled-artifacts.js","sourceRoot":"","sources":["../../../../src/local/domain/rebase/pulled-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE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AAC,aAAa,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,KAAe,CAAC,CAAC,CAAC;gBAC7F,OAAO;YACT,KAAK,oBAAoB;gBACvB,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC/D,OAAO;YACT,KAAK,yBAAyB;gBAC5B,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC;oBAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,aAAuB,CAAC,CAAC;gBAClG,OAAO;YACT,QAAQ;QACV,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,412 @@
|
|
|
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
|
+
#unavailableNode(nodeId) {
|
|
164
|
+
const state = this.#lifecycle.get(nodeId);
|
|
165
|
+
if (state === "live" || state === "tombstoned")
|
|
166
|
+
return undefined;
|
|
167
|
+
const target = this.#departures.get(nodeId);
|
|
168
|
+
if (target !== undefined) {
|
|
169
|
+
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 });
|
|
170
|
+
}
|
|
171
|
+
const described = state === "purged" ? "was purged" : "is not";
|
|
172
|
+
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 });
|
|
173
|
+
}
|
|
174
|
+
/** Refuses an operation the projection only applies to live nodes when one of them is not live on the pulled state. */
|
|
175
|
+
#notLive(nodeIds, needs) {
|
|
176
|
+
const nodeId = nodeIds.find(candidate => this.#lifecycle.get(candidate) !== "live");
|
|
177
|
+
if (nodeId === undefined)
|
|
178
|
+
return undefined;
|
|
179
|
+
const state = this.#lifecycle.get(nodeId);
|
|
180
|
+
if (state === undefined || state === "purged")
|
|
181
|
+
return this.#unavailableNode(nodeId);
|
|
182
|
+
return refuse(`node ${nodeId} is ${state} in the remote history, and ${needs} needs a live node.`, { reason: state, node_id: nodeId });
|
|
183
|
+
}
|
|
184
|
+
/** How `operation` replays on the current pulled state. */
|
|
185
|
+
plan(operation) {
|
|
186
|
+
const payload = operation.payload;
|
|
187
|
+
switch (operation.type) {
|
|
188
|
+
case "node.field.set.v1":
|
|
189
|
+
case "node.source_timestamps.recover.v1":
|
|
190
|
+
return this.#unavailableNode(payload.node_id) ?? KEEP;
|
|
191
|
+
case "node.tombstone.v1":
|
|
192
|
+
case "node.restore.v1": {
|
|
193
|
+
const nodeId = payload.node_id;
|
|
194
|
+
const target = operation.type === "node.tombstone.v1" ? "tombstoned" : "live";
|
|
195
|
+
if (this.#lifecycle.get(nodeId) === target)
|
|
196
|
+
return DROP;
|
|
197
|
+
return this.#unavailableNode(nodeId) ?? (operation.type === "node.restore.v1" ? this.#blockedRestore(nodeId) : undefined) ?? KEEP;
|
|
198
|
+
}
|
|
199
|
+
case "tag.define.v1": {
|
|
200
|
+
// Tag IDs are random, so a define that meets an existing tag re-activates it (a reverted retirement).
|
|
201
|
+
const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
|
|
202
|
+
if (tag?.state === "active")
|
|
203
|
+
return DROP;
|
|
204
|
+
const scope = this.#notLive([payload.scope_node_id], "defining a tag");
|
|
205
|
+
if (scope !== undefined)
|
|
206
|
+
return scope;
|
|
207
|
+
// A retired tag re-activates with the definition it was retired with, which the pull may have changed.
|
|
208
|
+
return tag === undefined ? KEEP : { action: "keep", rewrite: { definition: tag.definition } };
|
|
209
|
+
}
|
|
210
|
+
case "tag.update.v1":
|
|
211
|
+
case "tag.retire.v1": {
|
|
212
|
+
const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
|
|
213
|
+
if (tag?.state !== "active") {
|
|
214
|
+
if (operation.type === "tag.retire.v1" && tag?.state === "retired")
|
|
215
|
+
return DROP;
|
|
216
|
+
return refuse(`tag ${String(payload.tag_id)} is ${tag === undefined ? "not" : "retired"} in the remote history, so the local ` +
|
|
217
|
+
`${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 });
|
|
218
|
+
}
|
|
219
|
+
const scope = this.#notLive([payload.scope_node_id], operation.type === "tag.update.v1" ? "updating a tag" : "retiring a tag");
|
|
220
|
+
if (scope !== undefined)
|
|
221
|
+
return scope;
|
|
222
|
+
const rewrite = {
|
|
223
|
+
expected_definition_digest: projectionDigest(tag.definition),
|
|
224
|
+
previous_definition: tag.definition,
|
|
225
|
+
};
|
|
226
|
+
if (operation.type === "tag.update.v1") {
|
|
227
|
+
// History counters are service-controlled; the local update keeps its own name, colors, and flags.
|
|
228
|
+
const { history_of_tag_id, history_index, history_next_index } = tag.definition;
|
|
229
|
+
rewrite.definition = { ...payload.definition, history_of_tag_id, history_index, history_next_index };
|
|
230
|
+
}
|
|
231
|
+
return { action: "keep", rewrite };
|
|
232
|
+
}
|
|
233
|
+
case "node.tag.remove.v1":
|
|
234
|
+
return this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id).has(payload.node_id) ? KEEP : DROP;
|
|
235
|
+
case "node.tag.assign.v1": {
|
|
236
|
+
const holders = this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id);
|
|
237
|
+
const nodeId = payload.node_id;
|
|
238
|
+
// Giving a node the tag it already holds changes nothing. A tracked replacement also records history,
|
|
239
|
+
// which the pull's own assignment did not, and a same-holder assignment confirms the holding instead.
|
|
240
|
+
if (holders.has(nodeId) && payload.assignment_mode === "initial")
|
|
241
|
+
return DROP;
|
|
242
|
+
if (holders.has(nodeId) && payload.assignment_mode === "tracked_replacement") {
|
|
243
|
+
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 });
|
|
244
|
+
}
|
|
245
|
+
const external = payload.scope_repository_id !== undefined && payload.scope_repository_id !== null &&
|
|
246
|
+
payload.scope_repository_id !== this.#repositoryId;
|
|
247
|
+
const dead = this.#notLive(external ? [nodeId] : [payload.scope_node_id, nodeId], "giving a tag");
|
|
248
|
+
if (dead !== undefined)
|
|
249
|
+
return dead;
|
|
250
|
+
const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
|
|
251
|
+
if (!external && tag?.state !== "active") {
|
|
252
|
+
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 });
|
|
253
|
+
}
|
|
254
|
+
if (payload.assignment_mode === "same_holder") {
|
|
255
|
+
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 });
|
|
256
|
+
}
|
|
257
|
+
// A tag several nodes may hold accepts another holder; a one-only tag needs the holder the operation was written against.
|
|
258
|
+
if (payload.assignment_mode === "initial" && tag?.definition.one_only !== true)
|
|
259
|
+
return KEEP;
|
|
260
|
+
const current = [...holders];
|
|
261
|
+
const expected = payload.assignment_mode === "initial" ? [] : [payload.prior_holder];
|
|
262
|
+
const tracked = payload.assignment_mode === "tracked_replacement";
|
|
263
|
+
const sameHistory = !tracked ||
|
|
264
|
+
(tag?.definition.track_history === true && tag.definition.history_next_index === BigInt(payload.expected_history_next_index));
|
|
265
|
+
if (sameHistory && current.length === expected.length && current.every((holder, index) => holder === expected[index])) {
|
|
266
|
+
if (!tracked)
|
|
267
|
+
return KEEP;
|
|
268
|
+
// The history entry is named and colored after the tag's current definition, which the pull may have changed.
|
|
269
|
+
// A matching tracked replacement implies the tag exists and tracks history.
|
|
270
|
+
const { name, bg_color, text_color } = tag.definition;
|
|
271
|
+
const historyName = `${String(name)} (history ${String(payload.history_index)})`;
|
|
272
|
+
if ([...historyName].length > TAG_NAME_MAX_CODE_POINTS) {
|
|
273
|
+
return refuse(`the history entry of tag ${String(payload.tag_id)} would be named after its remote name, which leaves no room ` +
|
|
274
|
+
`for the history suffix, so the local replacement cannot be applied.`, { reason: "history_name_too_long", node_id: nodeId, tag_id: payload.tag_id });
|
|
275
|
+
}
|
|
276
|
+
return { action: "keep", rewrite: { history_tag: { ...payload.history_tag, name: historyName, bg_color, text_color } } };
|
|
277
|
+
}
|
|
278
|
+
return refuse(`tag ${String(payload.tag_id)} is held by ${current.length === 0 ? "no node" : current.join(", ")} in the remote history, ` +
|
|
279
|
+
`so the local assignment to node ${nodeId} cannot be applied.`, { reason: "holder_changed", node_id: nodeId, tag_id: payload.tag_id, holders: current });
|
|
280
|
+
}
|
|
281
|
+
case "containment.remove.v1": {
|
|
282
|
+
const containmentId = payload.containment_id;
|
|
283
|
+
const current = this.#containments.get(containmentId);
|
|
284
|
+
if (current === undefined)
|
|
285
|
+
return DROP;
|
|
286
|
+
if (current.child === payload.child_node_id && current.relationDigest === payload.relation_digest)
|
|
287
|
+
return KEEP;
|
|
288
|
+
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 });
|
|
289
|
+
}
|
|
290
|
+
case "containment.assign.v1": {
|
|
291
|
+
const childId = payload.child_node_id;
|
|
292
|
+
const current = [...this.#containments].find(([, containment]) => containment.child === childId);
|
|
293
|
+
if (current !== undefined) {
|
|
294
|
+
// The pull already made this exact placement (for example both sides reverted the same removal).
|
|
295
|
+
if (current[0] === payload.containment_id && current[1].container === payload.container_node_id &&
|
|
296
|
+
current[1].relationDigest === payload.relation_digest)
|
|
297
|
+
return DROP;
|
|
298
|
+
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] });
|
|
299
|
+
}
|
|
300
|
+
// Placing the child under a container that already sits beneath it would close a containment cycle.
|
|
301
|
+
const containerOf = this.#containerOf();
|
|
302
|
+
for (let ancestor = payload.container_node_id; ancestor !== undefined; ancestor = containerOf.get(ancestor)) {
|
|
303
|
+
if (ancestor === childId) {
|
|
304
|
+
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 });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return this.#notLive([payload.container_node_id, childId], "placing a node in a container") ?? KEEP;
|
|
308
|
+
}
|
|
309
|
+
case "edge.add.v1":
|
|
310
|
+
return this.#edgeAddition(payload.edge_id, payload);
|
|
311
|
+
case "edge.remove.v1": {
|
|
312
|
+
// An edge the pull already removed needs no removal; the store removes only the same relation, and not while artifacts hang off it.
|
|
313
|
+
const edgeId = payload.edge_id;
|
|
314
|
+
const current = this.#edges.get(edgeId);
|
|
315
|
+
if (current === undefined)
|
|
316
|
+
return DROP;
|
|
317
|
+
if (JSON.parse(current)[3] !== payload.relation_digest) {
|
|
318
|
+
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 });
|
|
319
|
+
}
|
|
320
|
+
const held = this.#artifacts.heldBy("edge", edgeId);
|
|
321
|
+
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 });
|
|
322
|
+
}
|
|
323
|
+
case "artifact.attach.v1":
|
|
324
|
+
case "artifact.attach.v2":
|
|
325
|
+
case "artifact.detach.v1":
|
|
326
|
+
case "artifact.content.set.v1":
|
|
327
|
+
case "artifact.properties.set.v1":
|
|
328
|
+
case "artifact.metadata.set.v1":
|
|
329
|
+
return this.#artifacts.plan(operation, (kind, ownerId) => this.#ownerLive(kind, ownerId));
|
|
330
|
+
default:
|
|
331
|
+
return KEEP;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** Records the effect of an operation that replay emitted. */
|
|
335
|
+
apply(operation) {
|
|
336
|
+
const payload = operation.payload;
|
|
337
|
+
switch (operation.type) {
|
|
338
|
+
case "node.create.v1":
|
|
339
|
+
case "node.restore.v1":
|
|
340
|
+
this.#lifecycle.set(payload.node_id, "live");
|
|
341
|
+
return;
|
|
342
|
+
case "node.tombstone.v1":
|
|
343
|
+
this.#lifecycle.set(payload.node_id, "tombstoned");
|
|
344
|
+
return;
|
|
345
|
+
case "node.purge.v1":
|
|
346
|
+
this.#lifecycle.set(payload.node_id, "purged");
|
|
347
|
+
return;
|
|
348
|
+
case "tag.define.v1":
|
|
349
|
+
case "tag.update.v1":
|
|
350
|
+
this.#tags.set(tagKey(payload.scope_node_id, payload.tag_id), { definition: payload.definition, state: "active" });
|
|
351
|
+
return;
|
|
352
|
+
case "tag.retire.v1": {
|
|
353
|
+
const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
|
|
354
|
+
if (tag !== undefined)
|
|
355
|
+
tag.state = "retired";
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
case "node.tag.assign.v1": {
|
|
359
|
+
const holders = this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id);
|
|
360
|
+
if (payload.assignment_mode === "tracked_replacement") {
|
|
361
|
+
holders.delete(payload.prior_holder);
|
|
362
|
+
const tag = this.#tags.get(tagKey(payload.scope_node_id, payload.tag_id));
|
|
363
|
+
if (tag !== undefined)
|
|
364
|
+
tag.definition = { ...tag.definition, history_next_index: BigInt(tag.definition.history_next_index) + 1n };
|
|
365
|
+
// The replacement also defines the history tag that records the previous holder (replaceTrackedAssignment).
|
|
366
|
+
const historyTag = payload.history_tag;
|
|
367
|
+
this.#tags.set(tagKey(payload.scope_node_id, payload.history_entry_id), {
|
|
368
|
+
definition: Object.fromEntries(TAG_DEFINITION_FIELDS.map(field => [field, historyTag[field]])), state: "active",
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
holders.add(payload.node_id);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
case "node.tag.remove.v1":
|
|
375
|
+
this.#holdersOf(payload.scope_repository_id, payload.scope_node_id, payload.tag_id).delete(payload.node_id);
|
|
376
|
+
return;
|
|
377
|
+
case "containment.assign.v1":
|
|
378
|
+
this.#containments.set(payload.containment_id, {
|
|
379
|
+
container: payload.container_node_id, child: payload.child_node_id, relationDigest: payload.relation_digest,
|
|
380
|
+
});
|
|
381
|
+
return;
|
|
382
|
+
case "containment.remove.v1":
|
|
383
|
+
this.#containments.delete(payload.containment_id);
|
|
384
|
+
return;
|
|
385
|
+
case "lineage.add.v1":
|
|
386
|
+
case "lineage.remove.v1": {
|
|
387
|
+
const link = JSON.stringify([payload.parent_repository_id ?? this.#repositoryId, payload.parent_node_id, payload.child_node_id]);
|
|
388
|
+
if (operation.type === "lineage.add.v1")
|
|
389
|
+
this.#lineage.add(link);
|
|
390
|
+
else
|
|
391
|
+
this.#lineage.delete(link);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
case "edge.add.v1":
|
|
395
|
+
this.#edges.set(payload.edge_id, edgeRelationKey(payload));
|
|
396
|
+
return;
|
|
397
|
+
case "edge.remove.v1":
|
|
398
|
+
this.#edges.delete(payload.edge_id);
|
|
399
|
+
return;
|
|
400
|
+
case "artifact.attach.v1":
|
|
401
|
+
case "artifact.attach.v2":
|
|
402
|
+
case "artifact.detach.v1":
|
|
403
|
+
case "artifact.content.set.v1":
|
|
404
|
+
case "artifact.properties.set.v1":
|
|
405
|
+
case "artifact.metadata.set.v1":
|
|
406
|
+
this.#artifacts.apply(operation);
|
|
407
|
+
return;
|
|
408
|
+
default:
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
//# 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,CA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