@dxos/echo-pipeline 0.1.56-next.a63ce79 → 0.1.56

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 (37) hide show
  1. package/dist/lib/browser/{chunk-3OTHGQEY.mjs → chunk-PV6A4BSQ.mjs} +258 -199
  2. package/dist/lib/browser/chunk-PV6A4BSQ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +1 -1
  6. package/dist/lib/node/index.cjs +262 -203
  7. package/dist/lib/node/index.cjs.map +3 -3
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/testing/index.cjs +264 -205
  10. package/dist/lib/node/testing/index.cjs.map +3 -3
  11. package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
  12. package/dist/types/src/pipeline/pipeline-stress.test.d.ts +2 -0
  13. package/dist/types/src/pipeline/pipeline-stress.test.d.ts.map +1 -0
  14. package/dist/types/src/pipeline/pipeline.d.ts +4 -3
  15. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  16. package/dist/types/src/space/control-pipeline.d.ts +4 -0
  17. package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
  18. package/dist/types/src/space/data-pipeline.d.ts +2 -0
  19. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  20. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  21. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  22. package/dist/types/src/space/space.d.ts.map +1 -1
  23. package/dist/types/src/testing/database-test-rig.d.ts +4 -1
  24. package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
  25. package/package.json +32 -32
  26. package/src/db-host/data-service-host.ts +9 -2
  27. package/src/pipeline/pipeline-stress.test.ts +226 -0
  28. package/src/pipeline/pipeline.test.ts +2 -214
  29. package/src/pipeline/pipeline.ts +47 -22
  30. package/src/space/control-pipeline.ts +47 -22
  31. package/src/space/data-pipeline.ts +20 -10
  32. package/src/space/space-manager.ts +1 -0
  33. package/src/space/space-protocol.ts +3 -1
  34. package/src/space/space.ts +1 -0
  35. package/src/testing/database-test-rig.ts +27 -2
  36. package/src/tests/database-unit.test.ts +39 -0
  37. package/dist/lib/browser/chunk-3OTHGQEY.mjs.map +0 -7
@@ -72,7 +72,7 @@ var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
72
72
 
73
73
  // packages/core/echo/echo-pipeline/src/common/feeds.ts
74
74
  var import_invariant = require("@dxos/invariant");
75
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
75
+ var __dxlog_file = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/common/feeds.ts";
76
76
  var createMappedFeedWriter = (mapper, writer) => {
77
77
  (0, import_invariant.invariant)(mapper, void 0, {
78
78
  F: __dxlog_file,
@@ -103,8 +103,9 @@ var import_context = require("@dxos/context");
103
103
  var import_echo_db = require("@dxos/echo-db");
104
104
  var import_invariant2 = require("@dxos/invariant");
105
105
  var import_log = require("@dxos/log");
106
+ var import_service = require("@dxos/protocols/proto/dxos/echo/service");
106
107
  var import_util = require("@dxos/util");
107
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
108
+ var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
108
109
  var DataServiceHost = class {
109
110
  constructor(_itemManager, _itemDemuxer, _writeStream) {
110
111
  this._itemManager = _itemManager;
@@ -130,11 +131,19 @@ var DataServiceHost = class {
130
131
  objects
131
132
  }
132
133
  });
134
+ this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
135
+ next({
136
+ action: import_service.EchoEvent.DatabaseAction.RESET,
137
+ batch: {
138
+ objects: snapshot.items
139
+ }
140
+ });
141
+ });
133
142
  this._itemDemuxer.mutation.on(ctx, (message) => {
134
143
  const { batch, meta } = message;
135
144
  (0, import_invariant2.invariant)(!meta.clientTag, "Unexpected client tag in mutation message", {
136
145
  F: __dxlog_file2,
137
- L: 61,
146
+ L: 68,
138
147
  S: this,
139
148
  A: [
140
149
  "!(meta as any).clientTag",
@@ -142,11 +151,11 @@ var DataServiceHost = class {
142
151
  ]
143
152
  });
144
153
  (0, import_log.log)("message", {
145
- batch,
154
+ batch: batch.objects?.length,
146
155
  meta
147
156
  }, {
148
157
  F: __dxlog_file2,
149
- L: 62,
158
+ L: 69,
150
159
  S: this,
151
160
  C: (f, a) => f(...a)
152
161
  });
@@ -174,7 +183,7 @@ var DataServiceHost = class {
174
183
  async write(request) {
175
184
  (0, import_invariant2.invariant)(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
176
185
  F: __dxlog_file2,
177
- L: 88,
186
+ L: 95,
178
187
  S: this,
179
188
  A: [
180
189
  "!this._ctx.disposed",
@@ -183,7 +192,7 @@ var DataServiceHost = class {
183
192
  });
184
193
  (0, import_invariant2.invariant)(this._writeStream, "Cannot write mutations in readonly mode", {
185
194
  F: __dxlog_file2,
186
- L: 89,
195
+ L: 96,
187
196
  S: this,
188
197
  A: [
189
198
  "this._writeStream",
@@ -195,7 +204,7 @@ var DataServiceHost = class {
195
204
  objectCount: request.batch.objects?.length ?? 0
196
205
  }, {
197
206
  F: __dxlog_file2,
198
- L: 91,
207
+ L: 98,
199
208
  S: this,
200
209
  C: (f, a) => f(...a)
201
210
  });
@@ -209,7 +218,7 @@ var DataServiceHost = class {
209
218
  seq: receipt2.seq
210
219
  }, {
211
220
  F: __dxlog_file2,
212
- L: 100,
221
+ L: 107,
213
222
  S: this,
214
223
  C: (f, a) => f(...a)
215
224
  });
@@ -370,7 +379,7 @@ var import_invariant3 = require("@dxos/invariant");
370
379
  var import_keys2 = require("@dxos/keys");
371
380
  var import_log2 = require("@dxos/log");
372
381
  var import_util2 = require("@dxos/util");
373
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
382
+ var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
374
383
  var DataServiceSubscriptions = class {
375
384
  constructor() {
376
385
  this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
@@ -525,7 +534,7 @@ function _ts_decorate2(decorators, target, key, desc) {
525
534
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
526
535
  return c > 3 && r && Object.defineProperty(target, key, r), r;
527
536
  }
528
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
537
+ var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
529
538
  var emptyEchoMetadata = () => ({
530
539
  version: import_protocols4.STORAGE_VERSION,
531
540
  spaces: [],
@@ -736,7 +745,7 @@ var import_util4 = require("@dxos/util");
736
745
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
737
746
  var import_invariant5 = require("@dxos/invariant");
738
747
  var import_log4 = require("@dxos/log");
739
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
748
+ var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
740
749
  var createMessageSelector = (timeframeClock) => {
741
750
  return (messages) => {
742
751
  for (let i = 0; i < messages.length; i++) {
@@ -778,7 +787,7 @@ function _ts_decorate3(decorators, target, key, desc) {
778
787
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
779
788
  return c > 3 && r && Object.defineProperty(target, key, r), r;
780
789
  }
781
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
790
+ var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
782
791
  var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
783
792
  feedKey,
784
793
  index
@@ -872,7 +881,7 @@ function _ts_decorate4(decorators, target, key, desc) {
872
881
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
873
882
  return c > 3 && r && Object.defineProperty(target, key, r), r;
874
883
  }
875
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
884
+ var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
876
885
  var PipelineState = class {
877
886
  // prettier-ignore
878
887
  constructor(_feeds, _timeframeClock) {
@@ -980,9 +989,11 @@ var Pipeline = class {
980
989
  // Waits for the message consumer to process the message and yield control back to the pipeline.
981
990
  this._processingTrigger = new import_async4.Trigger().wake();
982
991
  this._pauseTrigger = new import_async4.Trigger().wake();
992
+ // Pending downloads.
993
+ this._downloads = new import_util4.ComplexMap((value) => import_keys3.PublicKey.hash(value.key));
983
994
  this._isStopping = false;
984
995
  this._isStarted = false;
985
- this._isOpen = false;
996
+ this._isBeingConsumed = false;
986
997
  this._isPaused = false;
987
998
  }
988
999
  get state() {
@@ -991,7 +1002,7 @@ var Pipeline = class {
991
1002
  get writer() {
992
1003
  (0, import_invariant6.invariant)(this._writer, "Writer not set.", {
993
1004
  F: __dxlog_file7,
994
- L: 230,
1005
+ L: 233,
995
1006
  S: this,
996
1007
  A: [
997
1008
  "this._writer",
@@ -1013,12 +1024,14 @@ var Pipeline = class {
1013
1024
  if (this._feedSetIterator) {
1014
1025
  await this._feedSetIterator.addFeed(feed);
1015
1026
  }
1016
- this._setFeedDownloadState(feed);
1027
+ if (this._isStarted && !this._isPaused) {
1028
+ this._setFeedDownloadState(feed);
1029
+ }
1017
1030
  }
1018
1031
  setWriteFeed(feed) {
1019
1032
  (0, import_invariant6.invariant)(!this._writer, "Writer already set.", {
1020
1033
  F: __dxlog_file7,
1021
- L: 253,
1034
+ L: 260,
1022
1035
  S: this,
1023
1036
  A: [
1024
1037
  "!this._writer",
@@ -1027,7 +1040,7 @@ var Pipeline = class {
1027
1040
  });
1028
1041
  (0, import_invariant6.invariant)(feed.properties.writable, "Feed must be writable.", {
1029
1042
  F: __dxlog_file7,
1030
- L: 254,
1043
+ L: 261,
1031
1044
  S: this,
1032
1045
  A: [
1033
1046
  "feed.properties.writable",
@@ -1042,7 +1055,7 @@ var Pipeline = class {
1042
1055
  async start() {
1043
1056
  (0, import_invariant6.invariant)(!this._isStarted, "Pipeline is already started.", {
1044
1057
  F: __dxlog_file7,
1045
- L: 267,
1058
+ L: 274,
1046
1059
  S: this,
1047
1060
  A: [
1048
1061
  "!this._isStarted",
@@ -1051,7 +1064,7 @@ var Pipeline = class {
1051
1064
  });
1052
1065
  (0, import_log6.log)("starting...", void 0, {
1053
1066
  F: __dxlog_file7,
1054
- L: 268,
1067
+ L: 275,
1055
1068
  S: this,
1056
1069
  C: (f, a) => f(...a)
1057
1070
  });
@@ -1060,19 +1073,28 @@ var Pipeline = class {
1060
1073
  this._isStarted = true;
1061
1074
  (0, import_log6.log)("started", void 0, {
1062
1075
  F: __dxlog_file7,
1063
- L: 272,
1076
+ L: 279,
1064
1077
  S: this,
1065
1078
  C: (f, a) => f(...a)
1066
1079
  });
1080
+ if (!this._isPaused) {
1081
+ for (const feed of this._feeds.values()) {
1082
+ this._setFeedDownloadState(feed);
1083
+ }
1084
+ }
1067
1085
  }
1068
1086
  async stop() {
1069
1087
  (0, import_log6.log)("stopping...", void 0, {
1070
1088
  F: __dxlog_file7,
1071
- L: 277,
1089
+ L: 290,
1072
1090
  S: this,
1073
1091
  C: (f, a) => f(...a)
1074
1092
  });
1075
1093
  this._isStopping = true;
1094
+ for (const [feed, handle] of this._downloads.entries()) {
1095
+ feed.undownload(handle);
1096
+ }
1097
+ this._downloads.clear();
1076
1098
  await this._feedSetIterator?.close();
1077
1099
  await this._processingTrigger.wait();
1078
1100
  await this._state._ctx.dispose();
@@ -1081,7 +1103,7 @@ var Pipeline = class {
1081
1103
  this._isStarted = false;
1082
1104
  (0, import_log6.log)("stopped", void 0, {
1083
1105
  F: __dxlog_file7,
1084
- L: 285,
1106
+ L: 302,
1085
1107
  S: this,
1086
1108
  C: (f, a) => f(...a)
1087
1109
  });
@@ -1093,7 +1115,7 @@ var Pipeline = class {
1093
1115
  async setCursor(timeframe) {
1094
1116
  (0, import_invariant6.invariant)(!this._isStarted || this._isPaused, "Invalid state.", {
1095
1117
  F: __dxlog_file7,
1096
- L: 294,
1118
+ L: 311,
1097
1119
  S: this,
1098
1120
  A: [
1099
1121
  "!this._isStarted || this._isPaused",
@@ -1102,9 +1124,6 @@ var Pipeline = class {
1102
1124
  });
1103
1125
  this._state._startTimeframe = timeframe;
1104
1126
  this._timeframeClock.setTimeframe(timeframe);
1105
- for (const feed of this._feeds.values()) {
1106
- this._setFeedDownloadState(feed);
1107
- }
1108
1127
  if (this._feedSetIterator) {
1109
1128
  await this._feedSetIterator.close();
1110
1129
  await this._initIterator();
@@ -1115,15 +1134,6 @@ var Pipeline = class {
1115
1134
  * Calling pause while processing will cause a deadlock.
1116
1135
  */
1117
1136
  async pause() {
1118
- (0, import_invariant6.invariant)(this._isStarted, "Pipeline is not open.", {
1119
- F: __dxlog_file7,
1120
- L: 316,
1121
- S: this,
1122
- A: [
1123
- "this._isStarted",
1124
- "'Pipeline is not open.'"
1125
- ]
1126
- });
1127
1137
  if (this._isPaused) {
1128
1138
  return;
1129
1139
  }
@@ -1132,18 +1142,9 @@ var Pipeline = class {
1132
1142
  this._isPaused = true;
1133
1143
  }
1134
1144
  async unpause() {
1135
- (0, import_invariant6.invariant)(this._isStarted, "Pipeline is not open.", {
1136
- F: __dxlog_file7,
1137
- L: 328,
1138
- S: this,
1139
- A: [
1140
- "this._isStarted",
1141
- "'Pipeline is not open.'"
1142
- ]
1143
- });
1144
1145
  (0, import_invariant6.invariant)(this._isPaused, "Pipeline is not paused.", {
1145
1146
  F: __dxlog_file7,
1146
- L: 329,
1147
+ L: 340,
1147
1148
  S: this,
1148
1149
  A: [
1149
1150
  "this._isPaused",
@@ -1152,25 +1153,28 @@ var Pipeline = class {
1152
1153
  });
1153
1154
  this._pauseTrigger.wake();
1154
1155
  this._isPaused = false;
1156
+ for (const feed of this._feeds.values()) {
1157
+ this._setFeedDownloadState(feed);
1158
+ }
1155
1159
  }
1156
1160
  /**
1157
1161
  * Starts to iterate over the ordered messages from the added feeds.
1158
1162
  * Updates the timeframe clock after the message has bee processed.
1159
1163
  */
1160
1164
  async *consume() {
1161
- (0, import_invariant6.invariant)(!this._isOpen, "Pipeline is already being consumed.", {
1165
+ (0, import_invariant6.invariant)(!this._isBeingConsumed, "Pipeline is already being consumed.", {
1162
1166
  F: __dxlog_file7,
1163
- L: 340,
1167
+ L: 355,
1164
1168
  S: this,
1165
1169
  A: [
1166
- "!this._isOpen",
1170
+ "!this._isBeingConsumed",
1167
1171
  "'Pipeline is already being consumed.'"
1168
1172
  ]
1169
1173
  });
1170
- this._isOpen = true;
1174
+ this._isBeingConsumed = true;
1171
1175
  (0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
1172
1176
  F: __dxlog_file7,
1173
- L: 343,
1177
+ L: 358,
1174
1178
  S: this,
1175
1179
  A: [
1176
1180
  "this._feedSetIterator",
@@ -1184,7 +1188,7 @@ var Pipeline = class {
1184
1188
  if (lastFeedSetIterator !== this._feedSetIterator) {
1185
1189
  (0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
1186
1190
  F: __dxlog_file7,
1187
- L: 352,
1191
+ L: 367,
1188
1192
  S: this,
1189
1193
  A: [
1190
1194
  "this._feedSetIterator",
@@ -1204,32 +1208,42 @@ var Pipeline = class {
1204
1208
  this._timeframeClock.updateTimeframe();
1205
1209
  }
1206
1210
  }
1207
- this._isOpen = false;
1211
+ this._isBeingConsumed = false;
1208
1212
  }
1209
1213
  _setFeedDownloadState(feed) {
1214
+ let handle = this._downloads.get(feed);
1215
+ if (handle) {
1216
+ feed.undownload(handle);
1217
+ }
1210
1218
  const timeframe = this._state._startTimeframe;
1211
- const seq = timeframe.get(feed.key) ?? 0;
1212
- feed.undownload({
1213
- callback: () => (0, import_log6.log)("undownload", void 0, {
1214
- F: __dxlog_file7,
1215
- L: 377,
1216
- S: this,
1217
- C: (f, a) => f(...a)
1218
- })
1219
+ const seq = timeframe.get(feed.key) ?? -1;
1220
+ (0, import_log6.log)("download", {
1221
+ feed: feed.key.truncate(),
1222
+ seq,
1223
+ length: feed.length
1224
+ }, {
1225
+ F: __dxlog_file7,
1226
+ L: 396,
1227
+ S: this,
1228
+ C: (f, a) => f(...a)
1219
1229
  });
1220
- feed.download({
1230
+ handle = feed.download({
1221
1231
  start: seq + 1,
1222
1232
  linear: true
1223
- }).catch((err) => {
1224
- (0, import_log6.log)("failed to download feed", {
1225
- err
1226
- }, {
1227
- F: __dxlog_file7,
1228
- L: 379,
1229
- S: this,
1230
- C: (f, a) => f(...a)
1231
- });
1233
+ }, (err, data) => {
1234
+ if (err) {
1235
+ } else {
1236
+ import_log6.log.info("downloaded", {
1237
+ data
1238
+ }, {
1239
+ F: __dxlog_file7,
1240
+ L: 401,
1241
+ S: this,
1242
+ C: (f, a) => f(...a)
1243
+ });
1244
+ }
1232
1245
  });
1246
+ this._downloads.set(feed, handle);
1233
1247
  }
1234
1248
  async _initIterator() {
1235
1249
  this._feedSetIterator = new import_feed_store.FeedSetIterator(createMessageSelector(this._timeframeClock), {
@@ -1239,7 +1253,7 @@ var Pipeline = class {
1239
1253
  this._feedSetIterator.stalled.on((iterator) => {
1240
1254
  import_log6.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
1241
1255
  F: __dxlog_file7,
1242
- L: 390,
1256
+ L: 415,
1243
1257
  S: this,
1244
1258
  C: (f, a) => f(...a)
1245
1259
  });
@@ -1274,7 +1288,7 @@ var import_invariant7 = require("@dxos/invariant");
1274
1288
  var import_log7 = require("@dxos/log");
1275
1289
  var import_protocols5 = require("@dxos/protocols");
1276
1290
  var import_teleport = require("@dxos/teleport");
1277
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
1291
+ var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/auth.ts";
1278
1292
  var AuthExtension = class extends import_teleport.RpcExtension {
1279
1293
  constructor(_authParams) {
1280
1294
  super({
@@ -1374,22 +1388,36 @@ var import_async7 = require("@dxos/async");
1374
1388
  var import_invariant9 = require("@dxos/invariant");
1375
1389
  var import_log10 = require("@dxos/log");
1376
1390
  var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
1377
- var import_tracing = require("@dxos/tracing");
1391
+ var import_tracing3 = require("@dxos/tracing");
1378
1392
  var import_util7 = require("@dxos/util");
1379
1393
 
1380
1394
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
1395
+ var import_context5 = require("@dxos/context");
1381
1396
  var import_credentials = require("@dxos/credentials");
1382
1397
  var import_keys4 = require("@dxos/keys");
1383
1398
  var import_log8 = require("@dxos/log");
1384
1399
  var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
1385
1400
  var import_timeframe3 = require("@dxos/timeframe");
1401
+ var import_tracing = require("@dxos/tracing");
1386
1402
  var import_util5 = require("@dxos/util");
1387
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1403
+ function _ts_decorate5(decorators, target, key, desc) {
1404
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1405
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1406
+ r = Reflect.decorate(decorators, target, key, desc);
1407
+ else
1408
+ for (var i = decorators.length - 1; i >= 0; i--)
1409
+ if (d = decorators[i])
1410
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1411
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1412
+ }
1413
+ var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1388
1414
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1389
- var ControlPipeline = class {
1415
+ var ControlPipeline = class ControlPipeline2 {
1390
1416
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1391
1417
  this._lastTimeframeSaveTime = Date.now();
1392
1418
  this.onFeedAdmitted = new import_util5.Callback();
1419
+ this._usage = new import_tracing.TimeUsageCounter();
1420
+ this._mutations = new import_tracing.TimeSeriesCounter();
1393
1421
  this._spaceKey = spaceKey;
1394
1422
  this._metadata = metadataStore;
1395
1423
  this._pipeline = new Pipeline();
@@ -1400,7 +1428,7 @@ var ControlPipeline = class {
1400
1428
  key: info.key
1401
1429
  }, {
1402
1430
  F: __dxlog_file9,
1403
- L: 51,
1431
+ L: 61,
1404
1432
  S: this,
1405
1433
  C: (f, a) => f(...a)
1406
1434
  });
@@ -1411,7 +1439,7 @@ var ControlPipeline = class {
1411
1439
  } catch (err) {
1412
1440
  import_log8.log.catch(err, void 0, {
1413
1441
  F: __dxlog_file9,
1414
- L: 59,
1442
+ L: 69,
1415
1443
  S: this,
1416
1444
  C: (f, a) => f(...a)
1417
1445
  });
@@ -1434,57 +1462,66 @@ var ControlPipeline = class {
1434
1462
  async start() {
1435
1463
  (0, import_log8.log)("starting...", void 0, {
1436
1464
  F: __dxlog_file9,
1437
- L: 83,
1465
+ L: 93,
1438
1466
  S: this,
1439
1467
  C: (f, a) => f(...a)
1440
1468
  });
1441
1469
  setTimeout(async () => {
1442
- for await (const msg of this._pipeline.consume()) {
1443
- try {
1444
- (0, import_log8.log)("processing", {
1445
- key: msg.feedKey,
1446
- seq: msg.seq
1447
- }, {
1448
- F: __dxlog_file9,
1449
- L: 88,
1450
- S: this,
1451
- C: (f, a) => f(...a)
1452
- });
1453
- if (msg.data.payload.credential) {
1454
- const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
1455
- const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
1456
- timer.end();
1457
- if (!result) {
1458
- import_log8.log.warn("processing failed", {
1459
- msg
1460
- }, {
1461
- F: __dxlog_file9,
1462
- L: 98,
1463
- S: this,
1464
- C: (f, a) => f(...a)
1465
- });
1466
- } else {
1467
- await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1468
- }
1469
- }
1470
- } catch (err) {
1471
- import_log8.log.catch(err, void 0, {
1472
- F: __dxlog_file9,
1473
- L: 104,
1474
- S: this,
1475
- C: (f, a) => f(...a)
1476
- });
1477
- }
1478
- }
1470
+ void this._consumePipeline(new import_context5.Context());
1479
1471
  });
1480
1472
  await this._pipeline.start();
1481
1473
  (0, import_log8.log)("started", void 0, {
1482
1474
  F: __dxlog_file9,
1483
- L: 110,
1475
+ L: 99,
1484
1476
  S: this,
1485
1477
  C: (f, a) => f(...a)
1486
1478
  });
1487
1479
  }
1480
+ async _consumePipeline(ctx) {
1481
+ for await (const msg of this._pipeline.consume()) {
1482
+ const span = this._usage.beginRecording();
1483
+ this._mutations.inc();
1484
+ try {
1485
+ await this._processMessage(ctx, msg);
1486
+ } catch (err) {
1487
+ import_log8.log.catch(err, void 0, {
1488
+ F: __dxlog_file9,
1489
+ L: 111,
1490
+ S: this,
1491
+ C: (f, a) => f(...a)
1492
+ });
1493
+ }
1494
+ span.end();
1495
+ }
1496
+ }
1497
+ async _processMessage(ctx, msg) {
1498
+ (0, import_log8.log)("processing", {
1499
+ key: msg.feedKey,
1500
+ seq: msg.seq
1501
+ }, {
1502
+ F: __dxlog_file9,
1503
+ L: 121,
1504
+ S: this,
1505
+ C: (f, a) => f(...a)
1506
+ });
1507
+ if (msg.data.payload.credential) {
1508
+ const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
1509
+ const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
1510
+ timer.end();
1511
+ if (!result) {
1512
+ import_log8.log.warn("processing failed", {
1513
+ msg
1514
+ }, {
1515
+ F: __dxlog_file9,
1516
+ L: 131,
1517
+ S: this,
1518
+ C: (f, a) => f(...a)
1519
+ });
1520
+ } else {
1521
+ await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1522
+ }
1523
+ }
1524
+ }
1488
1525
  async _noteTargetStateIfNeeded(timeframe) {
1489
1526
  if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL) {
1490
1527
  this._lastTimeframeSaveTime = Date.now();
@@ -1494,7 +1531,7 @@ var ControlPipeline = class {
1494
1531
  async stop() {
1495
1532
  (0, import_log8.log)("stopping...", void 0, {
1496
1533
  F: __dxlog_file9,
1497
- L: 124,
1534
+ L: 149,
1498
1535
  S: this,
1499
1536
  C: (f, a) => f(...a)
1500
1537
  });
@@ -1502,7 +1539,7 @@ var ControlPipeline = class {
1502
1539
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1503
1540
  (0, import_log8.log)("stopped", void 0, {
1504
1541
  F: __dxlog_file9,
1505
- L: 127,
1542
+ L: 152,
1506
1543
  S: this,
1507
1544
  C: (f, a) => f(...a)
1508
1545
  });
@@ -1515,25 +1552,41 @@ var ControlPipeline = class {
1515
1552
  } catch (err) {
1516
1553
  (0, import_log8.log)(err, void 0, {
1517
1554
  F: __dxlog_file9,
1518
- L: 136,
1555
+ L: 161,
1519
1556
  S: this,
1520
1557
  C: (f, a) => f(...a)
1521
1558
  });
1522
1559
  }
1523
1560
  }
1524
1561
  };
1562
+ _ts_decorate5([
1563
+ import_tracing.trace.metricsCounter()
1564
+ ], ControlPipeline.prototype, "_usage", void 0);
1565
+ _ts_decorate5([
1566
+ import_tracing.trace.metricsCounter()
1567
+ ], ControlPipeline.prototype, "_mutations", void 0);
1568
+ _ts_decorate5([
1569
+ import_tracing.trace.span()
1570
+ ], ControlPipeline.prototype, "_consumePipeline", null);
1571
+ _ts_decorate5([
1572
+ import_tracing.trace.span()
1573
+ ], ControlPipeline.prototype, "_processMessage", null);
1574
+ ControlPipeline = _ts_decorate5([
1575
+ import_tracing.trace.resource()
1576
+ ], ControlPipeline);
1525
1577
 
1526
1578
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1527
1579
  var import_async6 = require("@dxos/async");
1528
- var import_context5 = require("@dxos/context");
1580
+ var import_context6 = require("@dxos/context");
1529
1581
  var import_credentials3 = require("@dxos/credentials");
1530
1582
  var import_echo_db3 = require("@dxos/echo-db");
1531
1583
  var import_errors2 = require("@dxos/errors");
1532
1584
  var import_invariant8 = require("@dxos/invariant");
1533
1585
  var import_log9 = require("@dxos/log");
1534
1586
  var import_timeframe4 = require("@dxos/timeframe");
1587
+ var import_tracing2 = require("@dxos/tracing");
1535
1588
  var import_util6 = require("@dxos/util");
1536
- function _ts_decorate5(decorators, target, key, desc) {
1589
+ function _ts_decorate6(decorators, target, key, desc) {
1537
1590
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1538
1591
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1539
1592
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1543,14 +1596,14 @@ function _ts_decorate5(decorators, target, key, desc) {
1543
1596
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1544
1597
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1545
1598
  }
1546
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1599
+ var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1547
1600
  var MESSAGES_PER_SNAPSHOT = 10;
1548
1601
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1549
1602
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1550
1603
  var DataPipeline = class DataPipeline2 {
1551
1604
  constructor(_params) {
1552
1605
  this._params = _params;
1553
- this._ctx = new import_context5.Context();
1606
+ this._ctx = new import_context6.Context();
1554
1607
  this._pipeline = void 0;
1555
1608
  this._targetTimeframe = void 0;
1556
1609
  this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
@@ -1558,6 +1611,8 @@ var DataPipeline = class DataPipeline2 {
1558
1611
  this._lastTimeframeSaveTime = 0;
1559
1612
  this._lastSnapshotSaveTime = 0;
1560
1613
  this._lastProcessedEpoch = -1;
1614
+ this._usage = new import_tracing2.TimeUsageCounter();
1615
+ this._mutations = new import_tracing2.TimeSeriesCounter();
1561
1616
  this.currentEpoch = void 0;
1562
1617
  this.appliedEpoch = void 0;
1563
1618
  this.onNewEpoch = new import_async6.Event();
@@ -1590,8 +1645,8 @@ var DataPipeline = class DataPipeline2 {
1590
1645
  }
1591
1646
  this._pipeline = new Pipeline();
1592
1647
  await this._params.onPipelineCreated(this._pipeline);
1593
- await this._pipeline.start();
1594
1648
  await this._pipeline.pause();
1649
+ await this._pipeline.start();
1595
1650
  if (this._targetTimeframe) {
1596
1651
  this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
1597
1652
  }
@@ -1599,7 +1654,7 @@ var DataPipeline = class DataPipeline2 {
1599
1654
  write: (data, options) => {
1600
1655
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1601
1656
  F: __dxlog_file10,
1602
- L: 145,
1657
+ L: 154,
1603
1658
  S: this,
1604
1659
  A: [
1605
1660
  "this._pipeline",
@@ -1608,7 +1663,7 @@ var DataPipeline = class DataPipeline2 {
1608
1663
  });
1609
1664
  (0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
1610
1665
  F: __dxlog_file10,
1611
- L: 146,
1666
+ L: 155,
1612
1667
  S: this,
1613
1668
  A: [
1614
1669
  "this.currentEpoch",
@@ -1634,7 +1689,7 @@ var DataPipeline = class DataPipeline2 {
1634
1689
  }
1635
1690
  (0, import_log9.log)("close", void 0, {
1636
1691
  F: __dxlog_file10,
1637
- L: 170,
1692
+ L: 179,
1638
1693
  S: this,
1639
1694
  C: (f, a) => f(...a)
1640
1695
  });
@@ -1649,14 +1704,14 @@ var DataPipeline = class DataPipeline2 {
1649
1704
  } catch (err) {
1650
1705
  import_log9.log.catch(err, void 0, {
1651
1706
  F: __dxlog_file10,
1652
- L: 183,
1707
+ L: 192,
1653
1708
  S: this,
1654
1709
  C: (f, a) => f(...a)
1655
1710
  });
1656
1711
  }
1657
1712
  await this.databaseHost?.close();
1658
1713
  await this.itemManager?.destroy();
1659
- this._ctx = new import_context5.Context();
1714
+ this._ctx = new import_context6.Context();
1660
1715
  this._pipeline = void 0;
1661
1716
  this._targetTimeframe = void 0;
1662
1717
  this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
@@ -1673,7 +1728,7 @@ var DataPipeline = class DataPipeline2 {
1673
1728
  }
1674
1729
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1675
1730
  F: __dxlog_file10,
1676
- L: 206,
1731
+ L: 215,
1677
1732
  S: this,
1678
1733
  A: [
1679
1734
  "this._pipeline",
@@ -1681,13 +1736,15 @@ var DataPipeline = class DataPipeline2 {
1681
1736
  ]
1682
1737
  });
1683
1738
  for await (const msg of this._pipeline.consume()) {
1739
+ const span = this._usage.beginRecording();
1740
+ this._mutations.inc();
1684
1741
  const { feedKey, seq, data } = msg;
1685
1742
  (0, import_log9.log)("processing message", {
1686
1743
  feedKey,
1687
1744
  seq
1688
1745
  }, {
1689
1746
  F: __dxlog_file10,
1690
- L: 209,
1747
+ L: 221,
1691
1748
  S: this,
1692
1749
  C: (f, a) => f(...a)
1693
1750
  });
@@ -1699,7 +1756,7 @@ var DataPipeline = class DataPipeline2 {
1699
1756
  feedKey
1700
1757
  }, {
1701
1758
  F: __dxlog_file10,
1702
- L: 215,
1759
+ L: 227,
1703
1760
  S: this,
1704
1761
  C: (f, a) => f(...a)
1705
1762
  });
@@ -1722,7 +1779,7 @@ var DataPipeline = class DataPipeline2 {
1722
1779
  spaceKey: this._params.spaceKey.toHex()
1723
1780
  }, {
1724
1781
  F: __dxlog_file10,
1725
- L: 232,
1782
+ L: 244,
1726
1783
  S: this,
1727
1784
  C: (f, a) => f(...a)
1728
1785
  });
@@ -1731,17 +1788,18 @@ var DataPipeline = class DataPipeline2 {
1731
1788
  } catch (err) {
1732
1789
  import_log9.log.catch(err, void 0, {
1733
1790
  F: __dxlog_file10,
1734
- L: 242,
1791
+ L: 254,
1735
1792
  S: this,
1736
1793
  C: (f, a) => f(...a)
1737
1794
  });
1738
1795
  }
1796
+ span.end();
1739
1797
  }
1740
1798
  }
1741
1799
  _createSnapshot() {
1742
1800
  (0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
1743
1801
  F: __dxlog_file10,
1744
- L: 248,
1802
+ L: 262,
1745
1803
  S: this,
1746
1804
  A: [
1747
1805
  "this.databaseHost",
@@ -1763,14 +1821,14 @@ var DataPipeline = class DataPipeline2 {
1763
1821
  const cache = {};
1764
1822
  try {
1765
1823
  const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
1766
- ((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === "dxos.sdk.client.Properties");
1824
+ ((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === import_echo_db3.TYPE_PROPERTIES);
1767
1825
  if (propertiesItem) {
1768
1826
  cache.properties = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)?.snapshot();
1769
1827
  }
1770
1828
  } catch (err) {
1771
1829
  import_log9.log.warn("Failed to cache properties", err, {
1772
1830
  F: __dxlog_file10,
1773
- L: 277,
1831
+ L: 291,
1774
1832
  S: this,
1775
1833
  C: (f, a) => f(...a)
1776
1834
  });
@@ -1791,19 +1849,19 @@ var DataPipeline = class DataPipeline2 {
1791
1849
  return;
1792
1850
  }
1793
1851
  await this._epochCtx?.dispose();
1794
- const ctx = new import_context5.Context({
1852
+ const ctx = new import_context6.Context({
1795
1853
  onError: (err) => {
1796
1854
  if (err instanceof import_errors2.CancelledError) {
1797
1855
  (0, import_log9.log)("Epoch processing cancelled.", void 0, {
1798
1856
  F: __dxlog_file10,
1799
- L: 309,
1857
+ L: 323,
1800
1858
  S: this,
1801
1859
  C: (f, a) => f(...a)
1802
1860
  });
1803
1861
  } else {
1804
1862
  import_log9.log.catch(err, void 0, {
1805
1863
  F: __dxlog_file10,
1806
- L: 311,
1864
+ L: 325,
1807
1865
  S: this,
1808
1866
  C: (f, a) => f(...a)
1809
1867
  });
@@ -1815,14 +1873,6 @@ var DataPipeline = class DataPipeline2 {
1815
1873
  if (!this._isOpen) {
1816
1874
  return;
1817
1875
  }
1818
- (0, import_log9.log)("process epoch", {
1819
- epoch
1820
- }, {
1821
- F: __dxlog_file10,
1822
- L: 321,
1823
- S: this,
1824
- C: (f, a) => f(...a)
1825
- });
1826
1876
  await this._processEpoch(ctx, epoch.subject.assertion);
1827
1877
  this.appliedEpoch = epoch;
1828
1878
  this.onNewEpoch.emit(epoch);
@@ -1831,7 +1881,7 @@ var DataPipeline = class DataPipeline2 {
1831
1881
  async _processEpoch(ctx, epoch) {
1832
1882
  (0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
1833
1883
  F: __dxlog_file10,
1834
- L: 331,
1884
+ L: 344,
1835
1885
  S: this,
1836
1886
  A: [
1837
1887
  "this._isOpen",
@@ -1840,7 +1890,7 @@ var DataPipeline = class DataPipeline2 {
1840
1890
  });
1841
1891
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
1842
1892
  F: __dxlog_file10,
1843
- L: 332,
1893
+ L: 345,
1844
1894
  S: this,
1845
1895
  A: [
1846
1896
  "this._pipeline",
@@ -1848,11 +1898,11 @@ var DataPipeline = class DataPipeline2 {
1848
1898
  ]
1849
1899
  });
1850
1900
  this._lastProcessedEpoch = epoch.number;
1851
- (0, import_log9.log)("Processing epoch", {
1852
- epoch
1901
+ (0, import_log9.log)("processing", {
1902
+ epoch: (0, import_log9.omit)(epoch, "proof")
1853
1903
  }, {
1854
1904
  F: __dxlog_file10,
1855
- L: 335,
1905
+ L: 348,
1856
1906
  S: this,
1857
1907
  C: (f, a) => f(...a)
1858
1908
  });
@@ -1860,9 +1910,9 @@ var DataPipeline = class DataPipeline2 {
1860
1910
  const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1861
1911
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1862
1912
  }
1863
- (0, import_log9.log)("restarting pipeline for epoch", void 0, {
1913
+ (0, import_log9.log)("restarting pipeline from epoch", void 0, {
1864
1914
  F: __dxlog_file10,
1865
- L: 343,
1915
+ L: 354,
1866
1916
  S: this,
1867
1917
  C: (f, a) => f(...a)
1868
1918
  });
@@ -1873,7 +1923,7 @@ var DataPipeline = class DataPipeline2 {
1873
1923
  async waitUntilTimeframe(timeframe) {
1874
1924
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1875
1925
  F: __dxlog_file10,
1876
- L: 351,
1926
+ L: 361,
1877
1927
  S: this,
1878
1928
  A: [
1879
1929
  "this._pipeline",
@@ -1885,7 +1935,7 @@ var DataPipeline = class DataPipeline2 {
1885
1935
  async createEpoch() {
1886
1936
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
1887
1937
  F: __dxlog_file10,
1888
- L: 357,
1938
+ L: 367,
1889
1939
  S: this,
1890
1940
  A: [
1891
1941
  "this._pipeline",
@@ -1894,7 +1944,7 @@ var DataPipeline = class DataPipeline2 {
1894
1944
  });
1895
1945
  (0, import_invariant8.invariant)(this.currentEpoch, void 0, {
1896
1946
  F: __dxlog_file10,
1897
- L: 358,
1947
+ L: 368,
1898
1948
  S: this,
1899
1949
  A: [
1900
1950
  "this.currentEpoch",
@@ -1917,24 +1967,31 @@ var DataPipeline = class DataPipeline2 {
1917
1967
  await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1918
1968
  }
1919
1969
  };
1920
- _ts_decorate5([
1970
+ _ts_decorate6([
1971
+ import_tracing2.trace.metricsCounter()
1972
+ ], DataPipeline.prototype, "_usage", void 0);
1973
+ _ts_decorate6([
1974
+ import_tracing2.trace.metricsCounter()
1975
+ ], DataPipeline.prototype, "_mutations", void 0);
1976
+ _ts_decorate6([
1921
1977
  import_async6.synchronized
1922
1978
  ], DataPipeline.prototype, "open", null);
1923
- _ts_decorate5([
1979
+ _ts_decorate6([
1924
1980
  import_async6.synchronized
1925
1981
  ], DataPipeline.prototype, "close", null);
1926
- _ts_decorate5([
1982
+ _ts_decorate6([
1927
1983
  import_async6.synchronized
1928
1984
  ], DataPipeline.prototype, "_processEpoch", null);
1929
- _ts_decorate5([
1985
+ _ts_decorate6([
1930
1986
  import_async6.synchronized
1931
1987
  ], DataPipeline.prototype, "createEpoch", null);
1932
- DataPipeline = _ts_decorate5([
1933
- (0, import_async6.trackLeaks)("open", "close")
1988
+ DataPipeline = _ts_decorate6([
1989
+ (0, import_async6.trackLeaks)("open", "close"),
1990
+ import_tracing2.trace.resource()
1934
1991
  ], DataPipeline);
1935
1992
 
1936
1993
  // packages/core/echo/echo-pipeline/src/space/space.ts
1937
- function _ts_decorate6(decorators, target, key, desc) {
1994
+ function _ts_decorate7(decorators, target, key, desc) {
1938
1995
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1939
1996
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1940
1997
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1944,7 +2001,7 @@ function _ts_decorate6(decorators, target, key, desc) {
1944
2001
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1945
2002
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1946
2003
  }
1947
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
2004
+ var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space.ts";
1948
2005
  var Space = class Space2 {
1949
2006
  constructor(params) {
1950
2007
  this._addFeedLock = new import_async7.Lock();
@@ -2060,7 +2117,7 @@ var Space = class Space2 {
2060
2117
  setControlFeed(feed) {
2061
2118
  (0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
2062
2119
  F: __dxlog_file11,
2063
- L: 183,
2120
+ L: 184,
2064
2121
  S: this,
2065
2122
  A: [
2066
2123
  "!this._controlFeed",
@@ -2074,7 +2131,7 @@ var Space = class Space2 {
2074
2131
  setDataFeed(feed) {
2075
2132
  (0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
2076
2133
  F: __dxlog_file11,
2077
- L: 190,
2134
+ L: 191,
2078
2135
  S: this,
2079
2136
  A: [
2080
2137
  "!this._dataFeed",
@@ -2100,7 +2157,7 @@ var Space = class Space2 {
2100
2157
  async open(ctx) {
2101
2158
  (0, import_log10.log)("opening...", void 0, {
2102
2159
  F: __dxlog_file11,
2103
- L: 212,
2160
+ L: 213,
2104
2161
  S: this,
2105
2162
  C: (f, a) => f(...a)
2106
2163
  });
@@ -2113,7 +2170,7 @@ var Space = class Space2 {
2113
2170
  this._isOpen = true;
2114
2171
  (0, import_log10.log)("opened", void 0, {
2115
2172
  F: __dxlog_file11,
2116
- L: 223,
2173
+ L: 224,
2117
2174
  S: this,
2118
2175
  C: (f, a) => f(...a)
2119
2176
  });
@@ -2123,7 +2180,7 @@ var Space = class Space2 {
2123
2180
  key: this._key
2124
2181
  }, {
2125
2182
  F: __dxlog_file11,
2126
- L: 228,
2183
+ L: 229,
2127
2184
  S: this,
2128
2185
  C: (f, a) => f(...a)
2129
2186
  });
@@ -2137,7 +2194,7 @@ var Space = class Space2 {
2137
2194
  this._isOpen = false;
2138
2195
  (0, import_log10.log)("closed", void 0, {
2139
2196
  F: __dxlog_file11,
2140
- L: 241,
2197
+ L: 242,
2141
2198
  S: this,
2142
2199
  C: (f, a) => f(...a)
2143
2200
  });
@@ -2145,13 +2202,13 @@ var Space = class Space2 {
2145
2202
  async initializeDataPipeline() {
2146
2203
  (0, import_log10.log)("initializeDataPipeline", void 0, {
2147
2204
  F: __dxlog_file11,
2148
- L: 246,
2205
+ L: 247,
2149
2206
  S: this,
2150
2207
  C: (f, a) => f(...a)
2151
2208
  });
2152
2209
  (0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
2153
2210
  F: __dxlog_file11,
2154
- L: 247,
2211
+ L: 248,
2155
2212
  S: this,
2156
2213
  A: [
2157
2214
  "this._isOpen",
@@ -2161,22 +2218,23 @@ var Space = class Space2 {
2161
2218
  await this._dataPipeline.open();
2162
2219
  }
2163
2220
  };
2164
- _ts_decorate6([
2165
- import_log10.logInfo
2221
+ _ts_decorate7([
2222
+ import_log10.logInfo,
2223
+ import_tracing3.trace.info()
2166
2224
  ], Space.prototype, "key", null);
2167
- _ts_decorate6([
2225
+ _ts_decorate7([
2168
2226
  import_async7.synchronized,
2169
- import_tracing.trace.span()
2227
+ import_tracing3.trace.span()
2170
2228
  ], Space.prototype, "open", null);
2171
- _ts_decorate6([
2229
+ _ts_decorate7([
2172
2230
  import_async7.synchronized
2173
2231
  ], Space.prototype, "close", null);
2174
- _ts_decorate6([
2232
+ _ts_decorate7([
2175
2233
  import_async7.synchronized
2176
2234
  ], Space.prototype, "initializeDataPipeline", null);
2177
- Space = _ts_decorate6([
2235
+ Space = _ts_decorate7([
2178
2236
  (0, import_async7.trackLeaks)("open", "close"),
2179
- import_tracing.trace.resource()
2237
+ import_tracing3.trace.resource()
2180
2238
  ], Space);
2181
2239
 
2182
2240
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
@@ -2196,7 +2254,7 @@ var import_teleport2 = require("@dxos/teleport");
2196
2254
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2197
2255
  var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
2198
2256
  var import_util8 = require("@dxos/util");
2199
- function _ts_decorate7(decorators, target, key, desc) {
2257
+ function _ts_decorate8(decorators, target, key, desc) {
2200
2258
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2201
2259
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2202
2260
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2206,7 +2264,7 @@ function _ts_decorate7(decorators, target, key, desc) {
2206
2264
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2207
2265
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2208
2266
  }
2209
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
2267
+ var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
2210
2268
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
2211
2269
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
2212
2270
  var SpaceProtocol = class {
@@ -2237,7 +2295,7 @@ var SpaceProtocol = class {
2237
2295
  key: feed.key
2238
2296
  }, {
2239
2297
  F: __dxlog_file12,
2240
- L: 95,
2298
+ L: 96,
2241
2299
  S: this,
2242
2300
  C: (f, a) => f(...a)
2243
2301
  });
@@ -2246,6 +2304,7 @@ var SpaceProtocol = class {
2246
2304
  session.replicator.addFeed(feed);
2247
2305
  }
2248
2306
  }
2307
+ // TODO(burdon): Rename open? Common open/close interfaces for all services?
2249
2308
  async start() {
2250
2309
  if (this._connection) {
2251
2310
  return;
@@ -2259,7 +2318,7 @@ var SpaceProtocol = class {
2259
2318
  await this.blobSync.open();
2260
2319
  (0, import_log11.log)("starting...", void 0, {
2261
2320
  F: __dxlog_file12,
2262
- L: 120,
2321
+ L: 122,
2263
2322
  S: this,
2264
2323
  C: (f, a) => f(...a)
2265
2324
  });
@@ -2269,11 +2328,11 @@ var SpaceProtocol = class {
2269
2328
  peerId: this._swarmIdentity.peerKey,
2270
2329
  topic,
2271
2330
  topology: new import_network_manager.MMSTTopology(topologyConfig),
2272
- label: `Protocol swarm: ${topic}`
2331
+ label: `space swarm ${topic.truncate()}`
2273
2332
  });
2274
2333
  (0, import_log11.log)("started", void 0, {
2275
2334
  F: __dxlog_file12,
2276
- L: 130,
2335
+ L: 132,
2277
2336
  S: this,
2278
2337
  C: (f, a) => f(...a)
2279
2338
  });
@@ -2283,14 +2342,14 @@ var SpaceProtocol = class {
2283
2342
  if (this._connection) {
2284
2343
  (0, import_log11.log)("stopping...", void 0, {
2285
2344
  F: __dxlog_file12,
2286
- L: 137,
2345
+ L: 139,
2287
2346
  S: this,
2288
2347
  C: (f, a) => f(...a)
2289
2348
  });
2290
2349
  await this._connection.close();
2291
2350
  (0, import_log11.log)("stopped", void 0, {
2292
2351
  F: __dxlog_file12,
2293
- L: 139,
2352
+ L: 141,
2294
2353
  S: this,
2295
2354
  C: (f, a) => f(...a)
2296
2355
  });
@@ -2313,10 +2372,10 @@ var SpaceProtocol = class {
2313
2372
  };
2314
2373
  }
2315
2374
  };
2316
- _ts_decorate7([
2375
+ _ts_decorate8([
2317
2376
  import_log11.logInfo
2318
2377
  ], SpaceProtocol.prototype, "_topic", void 0);
2319
- _ts_decorate7([
2378
+ _ts_decorate8([
2320
2379
  import_log11.logInfo
2321
2380
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
2322
2381
  var AuthStatus;
@@ -2357,7 +2416,7 @@ var SpaceProtocolSession = class {
2357
2416
  onAuthSuccess: () => {
2358
2417
  (0, import_log11.log)("Peer authenticated", void 0, {
2359
2418
  F: __dxlog_file12,
2360
- L: 236,
2419
+ L: 238,
2361
2420
  S: this,
2362
2421
  C: (f, a) => f(...a)
2363
2422
  });
@@ -2376,15 +2435,15 @@ var SpaceProtocolSession = class {
2376
2435
  await this._teleport.close();
2377
2436
  }
2378
2437
  };
2379
- _ts_decorate7([
2438
+ _ts_decorate8([
2380
2439
  import_log11.logInfo
2381
2440
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
2382
- _ts_decorate7([
2441
+ _ts_decorate8([
2383
2442
  import_log11.logInfo
2384
2443
  ], SpaceProtocolSession.prototype, "authStatus", null);
2385
2444
 
2386
2445
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
2387
- function _ts_decorate8(decorators, target, key, desc) {
2446
+ function _ts_decorate9(decorators, target, key, desc) {
2388
2447
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2389
2448
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2390
2449
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2394,7 +2453,7 @@ function _ts_decorate8(decorators, target, key, desc) {
2394
2453
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2395
2454
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2396
2455
  }
2397
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2456
+ var __dxlog_file13 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2398
2457
  var SpaceManager = class SpaceManager2 {
2399
2458
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
2400
2459
  this._spaces = new import_util9.ComplexMap(import_keys6.PublicKey.hash);
@@ -2460,20 +2519,20 @@ var SpaceManager = class SpaceManager2 {
2460
2519
  id: this._instanceId
2461
2520
  }), {
2462
2521
  F: __dxlog_file13,
2463
- L: 125,
2522
+ L: 126,
2464
2523
  S: this,
2465
2524
  C: (f, a) => f(...a)
2466
2525
  });
2467
2526
  return space;
2468
2527
  }
2469
2528
  };
2470
- _ts_decorate8([
2529
+ _ts_decorate9([
2471
2530
  import_async8.synchronized
2472
2531
  ], SpaceManager.prototype, "open", null);
2473
- _ts_decorate8([
2532
+ _ts_decorate9([
2474
2533
  import_async8.synchronized
2475
2534
  ], SpaceManager.prototype, "close", null);
2476
- SpaceManager = _ts_decorate8([
2535
+ SpaceManager = _ts_decorate9([
2477
2536
  (0, import_async8.trackLeaks)("open", "close")
2478
2537
  ], SpaceManager);
2479
2538
  // Annotate the CommonJS export names for ESM import in node: