@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
@@ -42,7 +42,7 @@ __export(testing_exports, {
42
42
  module.exports = __toCommonJS(testing_exports);
43
43
 
44
44
  // packages/core/echo/echo-pipeline/src/testing/test-agent-builder.ts
45
- var import_context6 = require("@dxos/context");
45
+ var import_context7 = require("@dxos/context");
46
46
  var import_credentials5 = require("@dxos/credentials");
47
47
  var import_document_model = require("@dxos/document-model");
48
48
  var import_keys7 = require("@dxos/keys");
@@ -61,8 +61,9 @@ var import_context = require("@dxos/context");
61
61
  var import_echo_db = require("@dxos/echo-db");
62
62
  var import_invariant = require("@dxos/invariant");
63
63
  var import_log = require("@dxos/log");
64
+ var import_service = require("@dxos/protocols/proto/dxos/echo/service");
64
65
  var import_util = require("@dxos/util");
65
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
66
+ var __dxlog_file = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
66
67
  var DataServiceHost = class {
67
68
  constructor(_itemManager, _itemDemuxer, _writeStream) {
68
69
  this._itemManager = _itemManager;
@@ -88,11 +89,19 @@ var DataServiceHost = class {
88
89
  objects
89
90
  }
90
91
  });
92
+ this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
93
+ next({
94
+ action: import_service.EchoEvent.DatabaseAction.RESET,
95
+ batch: {
96
+ objects: snapshot.items
97
+ }
98
+ });
99
+ });
91
100
  this._itemDemuxer.mutation.on(ctx, (message) => {
92
101
  const { batch, meta } = message;
93
102
  (0, import_invariant.invariant)(!meta.clientTag, "Unexpected client tag in mutation message", {
94
103
  F: __dxlog_file,
95
- L: 61,
104
+ L: 68,
96
105
  S: this,
97
106
  A: [
98
107
  "!(meta as any).clientTag",
@@ -100,11 +109,11 @@ var DataServiceHost = class {
100
109
  ]
101
110
  });
102
111
  (0, import_log.log)("message", {
103
- batch,
112
+ batch: batch.objects?.length,
104
113
  meta
105
114
  }, {
106
115
  F: __dxlog_file,
107
- L: 62,
116
+ L: 69,
108
117
  S: this,
109
118
  C: (f, a) => f(...a)
110
119
  });
@@ -132,7 +141,7 @@ var DataServiceHost = class {
132
141
  async write(request) {
133
142
  (0, import_invariant.invariant)(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
134
143
  F: __dxlog_file,
135
- L: 88,
144
+ L: 95,
136
145
  S: this,
137
146
  A: [
138
147
  "!this._ctx.disposed",
@@ -141,7 +150,7 @@ var DataServiceHost = class {
141
150
  });
142
151
  (0, import_invariant.invariant)(this._writeStream, "Cannot write mutations in readonly mode", {
143
152
  F: __dxlog_file,
144
- L: 89,
153
+ L: 96,
145
154
  S: this,
146
155
  A: [
147
156
  "this._writeStream",
@@ -153,7 +162,7 @@ var DataServiceHost = class {
153
162
  objectCount: request.batch.objects?.length ?? 0
154
163
  }, {
155
164
  F: __dxlog_file,
156
- L: 91,
165
+ L: 98,
157
166
  S: this,
158
167
  C: (f, a) => f(...a)
159
168
  });
@@ -167,7 +176,7 @@ var DataServiceHost = class {
167
176
  seq: receipt2.seq
168
177
  }, {
169
178
  F: __dxlog_file,
170
- L: 100,
179
+ L: 107,
171
180
  S: this,
172
181
  C: (f, a) => f(...a)
173
182
  });
@@ -328,7 +337,7 @@ var import_invariant2 = require("@dxos/invariant");
328
337
  var import_keys2 = require("@dxos/keys");
329
338
  var import_log2 = require("@dxos/log");
330
339
  var import_util2 = require("@dxos/util");
331
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
340
+ var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
332
341
  var DataServiceSubscriptions = class {
333
342
  constructor() {
334
343
  this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
@@ -434,7 +443,7 @@ function _ts_decorate2(decorators, target, key, desc) {
434
443
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
435
444
  return c > 3 && r && Object.defineProperty(target, key, r), r;
436
445
  }
437
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
446
+ var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
438
447
  var emptyEchoMetadata = () => ({
439
448
  version: import_protocols3.STORAGE_VERSION,
440
449
  spaces: [],
@@ -639,7 +648,7 @@ var import_invariant4 = require("@dxos/invariant");
639
648
  var import_log4 = require("@dxos/log");
640
649
  var import_protocols4 = require("@dxos/protocols");
641
650
  var import_teleport = require("@dxos/teleport");
642
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
651
+ var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/auth.ts";
643
652
  var AuthExtension = class extends import_teleport.RpcExtension {
644
653
  constructor(_authParams) {
645
654
  super({
@@ -739,15 +748,17 @@ var import_async7 = require("@dxos/async");
739
748
  var import_invariant9 = require("@dxos/invariant");
740
749
  var import_log10 = require("@dxos/log");
741
750
  var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
742
- var import_tracing = require("@dxos/tracing");
751
+ var import_tracing3 = require("@dxos/tracing");
743
752
  var import_util7 = require("@dxos/util");
744
753
 
745
754
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
755
+ var import_context5 = require("@dxos/context");
746
756
  var import_credentials = require("@dxos/credentials");
747
757
  var import_keys4 = require("@dxos/keys");
748
758
  var import_log8 = require("@dxos/log");
749
759
  var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
750
760
  var import_timeframe3 = require("@dxos/timeframe");
761
+ var import_tracing = require("@dxos/tracing");
751
762
  var import_util5 = require("@dxos/util");
752
763
 
753
764
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
@@ -769,7 +780,7 @@ var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
769
780
 
770
781
  // packages/core/echo/echo-pipeline/src/common/feeds.ts
771
782
  var import_invariant5 = require("@dxos/invariant");
772
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
783
+ var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/common/feeds.ts";
773
784
  var createMappedFeedWriter = (mapper, writer) => {
774
785
  (0, import_invariant5.invariant)(mapper, void 0, {
775
786
  F: __dxlog_file5,
@@ -797,7 +808,7 @@ var createMappedFeedWriter = (mapper, writer) => {
797
808
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
798
809
  var import_invariant6 = require("@dxos/invariant");
799
810
  var import_log5 = require("@dxos/log");
800
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
811
+ var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
801
812
  var createMessageSelector = (timeframeClock) => {
802
813
  return (messages) => {
803
814
  for (let i = 0; i < messages.length; i++) {
@@ -839,7 +850,7 @@ function _ts_decorate3(decorators, target, key, desc) {
839
850
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
840
851
  return c > 3 && r && Object.defineProperty(target, key, r), r;
841
852
  }
842
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
853
+ var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
843
854
  var mapFeedIndexesToTimeframe = (indexes) => new import_timeframe.Timeframe(indexes.map(({ feedKey, index }) => [
844
855
  feedKey,
845
856
  index
@@ -929,7 +940,7 @@ function _ts_decorate4(decorators, target, key, desc) {
929
940
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
930
941
  return c > 3 && r && Object.defineProperty(target, key, r), r;
931
942
  }
932
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
943
+ var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
933
944
  var PipelineState = class {
934
945
  // prettier-ignore
935
946
  constructor(_feeds, _timeframeClock) {
@@ -1037,9 +1048,11 @@ var Pipeline = class {
1037
1048
  // Waits for the message consumer to process the message and yield control back to the pipeline.
1038
1049
  this._processingTrigger = new import_async5.Trigger().wake();
1039
1050
  this._pauseTrigger = new import_async5.Trigger().wake();
1051
+ // Pending downloads.
1052
+ this._downloads = new import_util4.ComplexMap((value) => import_keys3.PublicKey.hash(value.key));
1040
1053
  this._isStopping = false;
1041
1054
  this._isStarted = false;
1042
- this._isOpen = false;
1055
+ this._isBeingConsumed = false;
1043
1056
  this._isPaused = false;
1044
1057
  }
1045
1058
  get state() {
@@ -1048,7 +1061,7 @@ var Pipeline = class {
1048
1061
  get writer() {
1049
1062
  (0, import_invariant7.invariant)(this._writer, "Writer not set.", {
1050
1063
  F: __dxlog_file8,
1051
- L: 230,
1064
+ L: 233,
1052
1065
  S: this,
1053
1066
  A: [
1054
1067
  "this._writer",
@@ -1070,12 +1083,14 @@ var Pipeline = class {
1070
1083
  if (this._feedSetIterator) {
1071
1084
  await this._feedSetIterator.addFeed(feed);
1072
1085
  }
1073
- this._setFeedDownloadState(feed);
1086
+ if (this._isStarted && !this._isPaused) {
1087
+ this._setFeedDownloadState(feed);
1088
+ }
1074
1089
  }
1075
1090
  setWriteFeed(feed) {
1076
1091
  (0, import_invariant7.invariant)(!this._writer, "Writer already set.", {
1077
1092
  F: __dxlog_file8,
1078
- L: 253,
1093
+ L: 260,
1079
1094
  S: this,
1080
1095
  A: [
1081
1096
  "!this._writer",
@@ -1084,7 +1099,7 @@ var Pipeline = class {
1084
1099
  });
1085
1100
  (0, import_invariant7.invariant)(feed.properties.writable, "Feed must be writable.", {
1086
1101
  F: __dxlog_file8,
1087
- L: 254,
1102
+ L: 261,
1088
1103
  S: this,
1089
1104
  A: [
1090
1105
  "feed.properties.writable",
@@ -1099,7 +1114,7 @@ var Pipeline = class {
1099
1114
  async start() {
1100
1115
  (0, import_invariant7.invariant)(!this._isStarted, "Pipeline is already started.", {
1101
1116
  F: __dxlog_file8,
1102
- L: 267,
1117
+ L: 274,
1103
1118
  S: this,
1104
1119
  A: [
1105
1120
  "!this._isStarted",
@@ -1108,7 +1123,7 @@ var Pipeline = class {
1108
1123
  });
1109
1124
  (0, import_log7.log)("starting...", void 0, {
1110
1125
  F: __dxlog_file8,
1111
- L: 268,
1126
+ L: 275,
1112
1127
  S: this,
1113
1128
  C: (f, a) => f(...a)
1114
1129
  });
@@ -1117,19 +1132,28 @@ var Pipeline = class {
1117
1132
  this._isStarted = true;
1118
1133
  (0, import_log7.log)("started", void 0, {
1119
1134
  F: __dxlog_file8,
1120
- L: 272,
1135
+ L: 279,
1121
1136
  S: this,
1122
1137
  C: (f, a) => f(...a)
1123
1138
  });
1139
+ if (!this._isPaused) {
1140
+ for (const feed of this._feeds.values()) {
1141
+ this._setFeedDownloadState(feed);
1142
+ }
1143
+ }
1124
1144
  }
1125
1145
  async stop() {
1126
1146
  (0, import_log7.log)("stopping...", void 0, {
1127
1147
  F: __dxlog_file8,
1128
- L: 277,
1148
+ L: 290,
1129
1149
  S: this,
1130
1150
  C: (f, a) => f(...a)
1131
1151
  });
1132
1152
  this._isStopping = true;
1153
+ for (const [feed, handle] of this._downloads.entries()) {
1154
+ feed.undownload(handle);
1155
+ }
1156
+ this._downloads.clear();
1133
1157
  await this._feedSetIterator?.close();
1134
1158
  await this._processingTrigger.wait();
1135
1159
  await this._state._ctx.dispose();
@@ -1138,7 +1162,7 @@ var Pipeline = class {
1138
1162
  this._isStarted = false;
1139
1163
  (0, import_log7.log)("stopped", void 0, {
1140
1164
  F: __dxlog_file8,
1141
- L: 285,
1165
+ L: 302,
1142
1166
  S: this,
1143
1167
  C: (f, a) => f(...a)
1144
1168
  });
@@ -1150,7 +1174,7 @@ var Pipeline = class {
1150
1174
  async setCursor(timeframe) {
1151
1175
  (0, import_invariant7.invariant)(!this._isStarted || this._isPaused, "Invalid state.", {
1152
1176
  F: __dxlog_file8,
1153
- L: 294,
1177
+ L: 311,
1154
1178
  S: this,
1155
1179
  A: [
1156
1180
  "!this._isStarted || this._isPaused",
@@ -1159,9 +1183,6 @@ var Pipeline = class {
1159
1183
  });
1160
1184
  this._state._startTimeframe = timeframe;
1161
1185
  this._timeframeClock.setTimeframe(timeframe);
1162
- for (const feed of this._feeds.values()) {
1163
- this._setFeedDownloadState(feed);
1164
- }
1165
1186
  if (this._feedSetIterator) {
1166
1187
  await this._feedSetIterator.close();
1167
1188
  await this._initIterator();
@@ -1172,15 +1193,6 @@ var Pipeline = class {
1172
1193
  * Calling pause while processing will cause a deadlock.
1173
1194
  */
1174
1195
  async pause() {
1175
- (0, import_invariant7.invariant)(this._isStarted, "Pipeline is not open.", {
1176
- F: __dxlog_file8,
1177
- L: 316,
1178
- S: this,
1179
- A: [
1180
- "this._isStarted",
1181
- "'Pipeline is not open.'"
1182
- ]
1183
- });
1184
1196
  if (this._isPaused) {
1185
1197
  return;
1186
1198
  }
@@ -1189,18 +1201,9 @@ var Pipeline = class {
1189
1201
  this._isPaused = true;
1190
1202
  }
1191
1203
  async unpause() {
1192
- (0, import_invariant7.invariant)(this._isStarted, "Pipeline is not open.", {
1193
- F: __dxlog_file8,
1194
- L: 328,
1195
- S: this,
1196
- A: [
1197
- "this._isStarted",
1198
- "'Pipeline is not open.'"
1199
- ]
1200
- });
1201
1204
  (0, import_invariant7.invariant)(this._isPaused, "Pipeline is not paused.", {
1202
1205
  F: __dxlog_file8,
1203
- L: 329,
1206
+ L: 340,
1204
1207
  S: this,
1205
1208
  A: [
1206
1209
  "this._isPaused",
@@ -1209,25 +1212,28 @@ var Pipeline = class {
1209
1212
  });
1210
1213
  this._pauseTrigger.wake();
1211
1214
  this._isPaused = false;
1215
+ for (const feed of this._feeds.values()) {
1216
+ this._setFeedDownloadState(feed);
1217
+ }
1212
1218
  }
1213
1219
  /**
1214
1220
  * Starts to iterate over the ordered messages from the added feeds.
1215
1221
  * Updates the timeframe clock after the message has bee processed.
1216
1222
  */
1217
1223
  async *consume() {
1218
- (0, import_invariant7.invariant)(!this._isOpen, "Pipeline is already being consumed.", {
1224
+ (0, import_invariant7.invariant)(!this._isBeingConsumed, "Pipeline is already being consumed.", {
1219
1225
  F: __dxlog_file8,
1220
- L: 340,
1226
+ L: 355,
1221
1227
  S: this,
1222
1228
  A: [
1223
- "!this._isOpen",
1229
+ "!this._isBeingConsumed",
1224
1230
  "'Pipeline is already being consumed.'"
1225
1231
  ]
1226
1232
  });
1227
- this._isOpen = true;
1233
+ this._isBeingConsumed = true;
1228
1234
  (0, import_invariant7.invariant)(this._feedSetIterator, "Iterator not initialized.", {
1229
1235
  F: __dxlog_file8,
1230
- L: 343,
1236
+ L: 358,
1231
1237
  S: this,
1232
1238
  A: [
1233
1239
  "this._feedSetIterator",
@@ -1241,7 +1247,7 @@ var Pipeline = class {
1241
1247
  if (lastFeedSetIterator !== this._feedSetIterator) {
1242
1248
  (0, import_invariant7.invariant)(this._feedSetIterator, "Iterator not initialized.", {
1243
1249
  F: __dxlog_file8,
1244
- L: 352,
1250
+ L: 367,
1245
1251
  S: this,
1246
1252
  A: [
1247
1253
  "this._feedSetIterator",
@@ -1261,32 +1267,42 @@ var Pipeline = class {
1261
1267
  this._timeframeClock.updateTimeframe();
1262
1268
  }
1263
1269
  }
1264
- this._isOpen = false;
1270
+ this._isBeingConsumed = false;
1265
1271
  }
1266
1272
  _setFeedDownloadState(feed) {
1273
+ let handle = this._downloads.get(feed);
1274
+ if (handle) {
1275
+ feed.undownload(handle);
1276
+ }
1267
1277
  const timeframe = this._state._startTimeframe;
1268
- const seq = timeframe.get(feed.key) ?? 0;
1269
- feed.undownload({
1270
- callback: () => (0, import_log7.log)("undownload", void 0, {
1271
- F: __dxlog_file8,
1272
- L: 377,
1273
- S: this,
1274
- C: (f, a) => f(...a)
1275
- })
1278
+ const seq = timeframe.get(feed.key) ?? -1;
1279
+ (0, import_log7.log)("download", {
1280
+ feed: feed.key.truncate(),
1281
+ seq,
1282
+ length: feed.length
1283
+ }, {
1284
+ F: __dxlog_file8,
1285
+ L: 396,
1286
+ S: this,
1287
+ C: (f, a) => f(...a)
1276
1288
  });
1277
- feed.download({
1289
+ handle = feed.download({
1278
1290
  start: seq + 1,
1279
1291
  linear: true
1280
- }).catch((err) => {
1281
- (0, import_log7.log)("failed to download feed", {
1282
- err
1283
- }, {
1284
- F: __dxlog_file8,
1285
- L: 379,
1286
- S: this,
1287
- C: (f, a) => f(...a)
1288
- });
1292
+ }, (err, data) => {
1293
+ if (err) {
1294
+ } else {
1295
+ import_log7.log.info("downloaded", {
1296
+ data
1297
+ }, {
1298
+ F: __dxlog_file8,
1299
+ L: 401,
1300
+ S: this,
1301
+ C: (f, a) => f(...a)
1302
+ });
1303
+ }
1289
1304
  });
1305
+ this._downloads.set(feed, handle);
1290
1306
  }
1291
1307
  async _initIterator() {
1292
1308
  this._feedSetIterator = new import_feed_store.FeedSetIterator(createMessageSelector(this._timeframeClock), {
@@ -1296,7 +1312,7 @@ var Pipeline = class {
1296
1312
  this._feedSetIterator.stalled.on((iterator) => {
1297
1313
  import_log7.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
1298
1314
  F: __dxlog_file8,
1299
- L: 390,
1315
+ L: 415,
1300
1316
  S: this,
1301
1317
  C: (f, a) => f(...a)
1302
1318
  });
@@ -1324,12 +1340,24 @@ _ts_decorate4([
1324
1340
  ], Pipeline.prototype, "unpause", null);
1325
1341
 
1326
1342
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
1327
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1343
+ function _ts_decorate5(decorators, target, key, desc) {
1344
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1345
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1346
+ r = Reflect.decorate(decorators, target, key, desc);
1347
+ else
1348
+ for (var i = decorators.length - 1; i >= 0; i--)
1349
+ if (d = decorators[i])
1350
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1351
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1352
+ }
1353
+ var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1328
1354
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1329
- var ControlPipeline = class {
1355
+ var ControlPipeline = class ControlPipeline2 {
1330
1356
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1331
1357
  this._lastTimeframeSaveTime = Date.now();
1332
1358
  this.onFeedAdmitted = new import_util5.Callback();
1359
+ this._usage = new import_tracing.TimeUsageCounter();
1360
+ this._mutations = new import_tracing.TimeSeriesCounter();
1333
1361
  this._spaceKey = spaceKey;
1334
1362
  this._metadata = metadataStore;
1335
1363
  this._pipeline = new Pipeline();
@@ -1340,7 +1368,7 @@ var ControlPipeline = class {
1340
1368
  key: info.key
1341
1369
  }, {
1342
1370
  F: __dxlog_file9,
1343
- L: 51,
1371
+ L: 61,
1344
1372
  S: this,
1345
1373
  C: (f, a) => f(...a)
1346
1374
  });
@@ -1351,7 +1379,7 @@ var ControlPipeline = class {
1351
1379
  } catch (err) {
1352
1380
  import_log8.log.catch(err, void 0, {
1353
1381
  F: __dxlog_file9,
1354
- L: 59,
1382
+ L: 69,
1355
1383
  S: this,
1356
1384
  C: (f, a) => f(...a)
1357
1385
  });
@@ -1374,57 +1402,66 @@ var ControlPipeline = class {
1374
1402
  async start() {
1375
1403
  (0, import_log8.log)("starting...", void 0, {
1376
1404
  F: __dxlog_file9,
1377
- L: 83,
1405
+ L: 93,
1378
1406
  S: this,
1379
1407
  C: (f, a) => f(...a)
1380
1408
  });
1381
1409
  setTimeout(async () => {
1382
- for await (const msg of this._pipeline.consume()) {
1383
- try {
1384
- (0, import_log8.log)("processing", {
1385
- key: msg.feedKey,
1386
- seq: msg.seq
1387
- }, {
1388
- F: __dxlog_file9,
1389
- L: 88,
1390
- S: this,
1391
- C: (f, a) => f(...a)
1392
- });
1393
- if (msg.data.payload.credential) {
1394
- const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
1395
- const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
1396
- timer.end();
1397
- if (!result) {
1398
- import_log8.log.warn("processing failed", {
1399
- msg
1400
- }, {
1401
- F: __dxlog_file9,
1402
- L: 98,
1403
- S: this,
1404
- C: (f, a) => f(...a)
1405
- });
1406
- } else {
1407
- await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1408
- }
1409
- }
1410
- } catch (err) {
1411
- import_log8.log.catch(err, void 0, {
1412
- F: __dxlog_file9,
1413
- L: 104,
1414
- S: this,
1415
- C: (f, a) => f(...a)
1416
- });
1417
- }
1418
- }
1410
+ void this._consumePipeline(new import_context5.Context());
1419
1411
  });
1420
1412
  await this._pipeline.start();
1421
1413
  (0, import_log8.log)("started", void 0, {
1422
1414
  F: __dxlog_file9,
1423
- L: 110,
1415
+ L: 99,
1424
1416
  S: this,
1425
1417
  C: (f, a) => f(...a)
1426
1418
  });
1427
1419
  }
1420
+ async _consumePipeline(ctx) {
1421
+ for await (const msg of this._pipeline.consume()) {
1422
+ const span = this._usage.beginRecording();
1423
+ this._mutations.inc();
1424
+ try {
1425
+ await this._processMessage(ctx, msg);
1426
+ } catch (err) {
1427
+ import_log8.log.catch(err, void 0, {
1428
+ F: __dxlog_file9,
1429
+ L: 111,
1430
+ S: this,
1431
+ C: (f, a) => f(...a)
1432
+ });
1433
+ }
1434
+ span.end();
1435
+ }
1436
+ }
1437
+ async _processMessage(ctx, msg) {
1438
+ (0, import_log8.log)("processing", {
1439
+ key: msg.feedKey,
1440
+ seq: msg.seq
1441
+ }, {
1442
+ F: __dxlog_file9,
1443
+ L: 121,
1444
+ S: this,
1445
+ C: (f, a) => f(...a)
1446
+ });
1447
+ if (msg.data.payload.credential) {
1448
+ const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
1449
+ const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
1450
+ timer.end();
1451
+ if (!result) {
1452
+ import_log8.log.warn("processing failed", {
1453
+ msg
1454
+ }, {
1455
+ F: __dxlog_file9,
1456
+ L: 131,
1457
+ S: this,
1458
+ C: (f, a) => f(...a)
1459
+ });
1460
+ } else {
1461
+ await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1462
+ }
1463
+ }
1464
+ }
1428
1465
  async _noteTargetStateIfNeeded(timeframe) {
1429
1466
  if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL) {
1430
1467
  this._lastTimeframeSaveTime = Date.now();
@@ -1434,7 +1471,7 @@ var ControlPipeline = class {
1434
1471
  async stop() {
1435
1472
  (0, import_log8.log)("stopping...", void 0, {
1436
1473
  F: __dxlog_file9,
1437
- L: 124,
1474
+ L: 149,
1438
1475
  S: this,
1439
1476
  C: (f, a) => f(...a)
1440
1477
  });
@@ -1442,7 +1479,7 @@ var ControlPipeline = class {
1442
1479
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1443
1480
  (0, import_log8.log)("stopped", void 0, {
1444
1481
  F: __dxlog_file9,
1445
- L: 127,
1482
+ L: 152,
1446
1483
  S: this,
1447
1484
  C: (f, a) => f(...a)
1448
1485
  });
@@ -1455,25 +1492,41 @@ var ControlPipeline = class {
1455
1492
  } catch (err) {
1456
1493
  (0, import_log8.log)(err, void 0, {
1457
1494
  F: __dxlog_file9,
1458
- L: 136,
1495
+ L: 161,
1459
1496
  S: this,
1460
1497
  C: (f, a) => f(...a)
1461
1498
  });
1462
1499
  }
1463
1500
  }
1464
1501
  };
1502
+ _ts_decorate5([
1503
+ import_tracing.trace.metricsCounter()
1504
+ ], ControlPipeline.prototype, "_usage", void 0);
1505
+ _ts_decorate5([
1506
+ import_tracing.trace.metricsCounter()
1507
+ ], ControlPipeline.prototype, "_mutations", void 0);
1508
+ _ts_decorate5([
1509
+ import_tracing.trace.span()
1510
+ ], ControlPipeline.prototype, "_consumePipeline", null);
1511
+ _ts_decorate5([
1512
+ import_tracing.trace.span()
1513
+ ], ControlPipeline.prototype, "_processMessage", null);
1514
+ ControlPipeline = _ts_decorate5([
1515
+ import_tracing.trace.resource()
1516
+ ], ControlPipeline);
1465
1517
 
1466
1518
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1467
1519
  var import_async6 = require("@dxos/async");
1468
- var import_context5 = require("@dxos/context");
1520
+ var import_context6 = require("@dxos/context");
1469
1521
  var import_credentials3 = require("@dxos/credentials");
1470
1522
  var import_echo_db3 = require("@dxos/echo-db");
1471
1523
  var import_errors2 = require("@dxos/errors");
1472
1524
  var import_invariant8 = require("@dxos/invariant");
1473
1525
  var import_log9 = require("@dxos/log");
1474
1526
  var import_timeframe4 = require("@dxos/timeframe");
1527
+ var import_tracing2 = require("@dxos/tracing");
1475
1528
  var import_util6 = require("@dxos/util");
1476
- function _ts_decorate5(decorators, target, key, desc) {
1529
+ function _ts_decorate6(decorators, target, key, desc) {
1477
1530
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1478
1531
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1479
1532
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1483,14 +1536,14 @@ function _ts_decorate5(decorators, target, key, desc) {
1483
1536
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1484
1537
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1485
1538
  }
1486
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1539
+ var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1487
1540
  var MESSAGES_PER_SNAPSHOT = 10;
1488
1541
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1489
1542
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1490
1543
  var DataPipeline = class DataPipeline2 {
1491
1544
  constructor(_params) {
1492
1545
  this._params = _params;
1493
- this._ctx = new import_context5.Context();
1546
+ this._ctx = new import_context6.Context();
1494
1547
  this._pipeline = void 0;
1495
1548
  this._targetTimeframe = void 0;
1496
1549
  this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
@@ -1498,6 +1551,8 @@ var DataPipeline = class DataPipeline2 {
1498
1551
  this._lastTimeframeSaveTime = 0;
1499
1552
  this._lastSnapshotSaveTime = 0;
1500
1553
  this._lastProcessedEpoch = -1;
1554
+ this._usage = new import_tracing2.TimeUsageCounter();
1555
+ this._mutations = new import_tracing2.TimeSeriesCounter();
1501
1556
  this.currentEpoch = void 0;
1502
1557
  this.appliedEpoch = void 0;
1503
1558
  this.onNewEpoch = new import_async6.Event();
@@ -1530,8 +1585,8 @@ var DataPipeline = class DataPipeline2 {
1530
1585
  }
1531
1586
  this._pipeline = new Pipeline();
1532
1587
  await this._params.onPipelineCreated(this._pipeline);
1533
- await this._pipeline.start();
1534
1588
  await this._pipeline.pause();
1589
+ await this._pipeline.start();
1535
1590
  if (this._targetTimeframe) {
1536
1591
  this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
1537
1592
  }
@@ -1539,7 +1594,7 @@ var DataPipeline = class DataPipeline2 {
1539
1594
  write: (data, options) => {
1540
1595
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1541
1596
  F: __dxlog_file10,
1542
- L: 145,
1597
+ L: 154,
1543
1598
  S: this,
1544
1599
  A: [
1545
1600
  "this._pipeline",
@@ -1548,7 +1603,7 @@ var DataPipeline = class DataPipeline2 {
1548
1603
  });
1549
1604
  (0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
1550
1605
  F: __dxlog_file10,
1551
- L: 146,
1606
+ L: 155,
1552
1607
  S: this,
1553
1608
  A: [
1554
1609
  "this.currentEpoch",
@@ -1574,7 +1629,7 @@ var DataPipeline = class DataPipeline2 {
1574
1629
  }
1575
1630
  (0, import_log9.log)("close", void 0, {
1576
1631
  F: __dxlog_file10,
1577
- L: 170,
1632
+ L: 179,
1578
1633
  S: this,
1579
1634
  C: (f, a) => f(...a)
1580
1635
  });
@@ -1589,14 +1644,14 @@ var DataPipeline = class DataPipeline2 {
1589
1644
  } catch (err) {
1590
1645
  import_log9.log.catch(err, void 0, {
1591
1646
  F: __dxlog_file10,
1592
- L: 183,
1647
+ L: 192,
1593
1648
  S: this,
1594
1649
  C: (f, a) => f(...a)
1595
1650
  });
1596
1651
  }
1597
1652
  await this.databaseHost?.close();
1598
1653
  await this.itemManager?.destroy();
1599
- this._ctx = new import_context5.Context();
1654
+ this._ctx = new import_context6.Context();
1600
1655
  this._pipeline = void 0;
1601
1656
  this._targetTimeframe = void 0;
1602
1657
  this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
@@ -1613,7 +1668,7 @@ var DataPipeline = class DataPipeline2 {
1613
1668
  }
1614
1669
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1615
1670
  F: __dxlog_file10,
1616
- L: 206,
1671
+ L: 215,
1617
1672
  S: this,
1618
1673
  A: [
1619
1674
  "this._pipeline",
@@ -1621,13 +1676,15 @@ var DataPipeline = class DataPipeline2 {
1621
1676
  ]
1622
1677
  });
1623
1678
  for await (const msg of this._pipeline.consume()) {
1679
+ const span = this._usage.beginRecording();
1680
+ this._mutations.inc();
1624
1681
  const { feedKey, seq, data } = msg;
1625
1682
  (0, import_log9.log)("processing message", {
1626
1683
  feedKey,
1627
1684
  seq
1628
1685
  }, {
1629
1686
  F: __dxlog_file10,
1630
- L: 209,
1687
+ L: 221,
1631
1688
  S: this,
1632
1689
  C: (f, a) => f(...a)
1633
1690
  });
@@ -1639,7 +1696,7 @@ var DataPipeline = class DataPipeline2 {
1639
1696
  feedKey
1640
1697
  }, {
1641
1698
  F: __dxlog_file10,
1642
- L: 215,
1699
+ L: 227,
1643
1700
  S: this,
1644
1701
  C: (f, a) => f(...a)
1645
1702
  });
@@ -1662,7 +1719,7 @@ var DataPipeline = class DataPipeline2 {
1662
1719
  spaceKey: this._params.spaceKey.toHex()
1663
1720
  }, {
1664
1721
  F: __dxlog_file10,
1665
- L: 232,
1722
+ L: 244,
1666
1723
  S: this,
1667
1724
  C: (f, a) => f(...a)
1668
1725
  });
@@ -1671,17 +1728,18 @@ var DataPipeline = class DataPipeline2 {
1671
1728
  } catch (err) {
1672
1729
  import_log9.log.catch(err, void 0, {
1673
1730
  F: __dxlog_file10,
1674
- L: 242,
1731
+ L: 254,
1675
1732
  S: this,
1676
1733
  C: (f, a) => f(...a)
1677
1734
  });
1678
1735
  }
1736
+ span.end();
1679
1737
  }
1680
1738
  }
1681
1739
  _createSnapshot() {
1682
1740
  (0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
1683
1741
  F: __dxlog_file10,
1684
- L: 248,
1742
+ L: 262,
1685
1743
  S: this,
1686
1744
  A: [
1687
1745
  "this.databaseHost",
@@ -1703,14 +1761,14 @@ var DataPipeline = class DataPipeline2 {
1703
1761
  const cache = {};
1704
1762
  try {
1705
1763
  const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
1706
- ((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === "dxos.sdk.client.Properties");
1764
+ ((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === import_echo_db3.TYPE_PROPERTIES);
1707
1765
  if (propertiesItem) {
1708
1766
  cache.properties = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)?.snapshot();
1709
1767
  }
1710
1768
  } catch (err) {
1711
1769
  import_log9.log.warn("Failed to cache properties", err, {
1712
1770
  F: __dxlog_file10,
1713
- L: 277,
1771
+ L: 291,
1714
1772
  S: this,
1715
1773
  C: (f, a) => f(...a)
1716
1774
  });
@@ -1731,19 +1789,19 @@ var DataPipeline = class DataPipeline2 {
1731
1789
  return;
1732
1790
  }
1733
1791
  await this._epochCtx?.dispose();
1734
- const ctx = new import_context5.Context({
1792
+ const ctx = new import_context6.Context({
1735
1793
  onError: (err) => {
1736
1794
  if (err instanceof import_errors2.CancelledError) {
1737
1795
  (0, import_log9.log)("Epoch processing cancelled.", void 0, {
1738
1796
  F: __dxlog_file10,
1739
- L: 309,
1797
+ L: 323,
1740
1798
  S: this,
1741
1799
  C: (f, a) => f(...a)
1742
1800
  });
1743
1801
  } else {
1744
1802
  import_log9.log.catch(err, void 0, {
1745
1803
  F: __dxlog_file10,
1746
- L: 311,
1804
+ L: 325,
1747
1805
  S: this,
1748
1806
  C: (f, a) => f(...a)
1749
1807
  });
@@ -1755,14 +1813,6 @@ var DataPipeline = class DataPipeline2 {
1755
1813
  if (!this._isOpen) {
1756
1814
  return;
1757
1815
  }
1758
- (0, import_log9.log)("process epoch", {
1759
- epoch
1760
- }, {
1761
- F: __dxlog_file10,
1762
- L: 321,
1763
- S: this,
1764
- C: (f, a) => f(...a)
1765
- });
1766
1816
  await this._processEpoch(ctx, epoch.subject.assertion);
1767
1817
  this.appliedEpoch = epoch;
1768
1818
  this.onNewEpoch.emit(epoch);
@@ -1771,7 +1821,7 @@ var DataPipeline = class DataPipeline2 {
1771
1821
  async _processEpoch(ctx, epoch) {
1772
1822
  (0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
1773
1823
  F: __dxlog_file10,
1774
- L: 331,
1824
+ L: 344,
1775
1825
  S: this,
1776
1826
  A: [
1777
1827
  "this._isOpen",
@@ -1780,7 +1830,7 @@ var DataPipeline = class DataPipeline2 {
1780
1830
  });
1781
1831
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
1782
1832
  F: __dxlog_file10,
1783
- L: 332,
1833
+ L: 345,
1784
1834
  S: this,
1785
1835
  A: [
1786
1836
  "this._pipeline",
@@ -1788,11 +1838,11 @@ var DataPipeline = class DataPipeline2 {
1788
1838
  ]
1789
1839
  });
1790
1840
  this._lastProcessedEpoch = epoch.number;
1791
- (0, import_log9.log)("Processing epoch", {
1792
- epoch
1841
+ (0, import_log9.log)("processing", {
1842
+ epoch: (0, import_log9.omit)(epoch, "proof")
1793
1843
  }, {
1794
1844
  F: __dxlog_file10,
1795
- L: 335,
1845
+ L: 348,
1796
1846
  S: this,
1797
1847
  C: (f, a) => f(...a)
1798
1848
  });
@@ -1800,9 +1850,9 @@ var DataPipeline = class DataPipeline2 {
1800
1850
  const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1801
1851
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1802
1852
  }
1803
- (0, import_log9.log)("restarting pipeline for epoch", void 0, {
1853
+ (0, import_log9.log)("restarting pipeline from epoch", void 0, {
1804
1854
  F: __dxlog_file10,
1805
- L: 343,
1855
+ L: 354,
1806
1856
  S: this,
1807
1857
  C: (f, a) => f(...a)
1808
1858
  });
@@ -1813,7 +1863,7 @@ var DataPipeline = class DataPipeline2 {
1813
1863
  async waitUntilTimeframe(timeframe) {
1814
1864
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1815
1865
  F: __dxlog_file10,
1816
- L: 351,
1866
+ L: 361,
1817
1867
  S: this,
1818
1868
  A: [
1819
1869
  "this._pipeline",
@@ -1825,7 +1875,7 @@ var DataPipeline = class DataPipeline2 {
1825
1875
  async createEpoch() {
1826
1876
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
1827
1877
  F: __dxlog_file10,
1828
- L: 357,
1878
+ L: 367,
1829
1879
  S: this,
1830
1880
  A: [
1831
1881
  "this._pipeline",
@@ -1834,7 +1884,7 @@ var DataPipeline = class DataPipeline2 {
1834
1884
  });
1835
1885
  (0, import_invariant8.invariant)(this.currentEpoch, void 0, {
1836
1886
  F: __dxlog_file10,
1837
- L: 358,
1887
+ L: 368,
1838
1888
  S: this,
1839
1889
  A: [
1840
1890
  "this.currentEpoch",
@@ -1857,24 +1907,31 @@ var DataPipeline = class DataPipeline2 {
1857
1907
  await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1858
1908
  }
1859
1909
  };
1860
- _ts_decorate5([
1910
+ _ts_decorate6([
1911
+ import_tracing2.trace.metricsCounter()
1912
+ ], DataPipeline.prototype, "_usage", void 0);
1913
+ _ts_decorate6([
1914
+ import_tracing2.trace.metricsCounter()
1915
+ ], DataPipeline.prototype, "_mutations", void 0);
1916
+ _ts_decorate6([
1861
1917
  import_async6.synchronized
1862
1918
  ], DataPipeline.prototype, "open", null);
1863
- _ts_decorate5([
1919
+ _ts_decorate6([
1864
1920
  import_async6.synchronized
1865
1921
  ], DataPipeline.prototype, "close", null);
1866
- _ts_decorate5([
1922
+ _ts_decorate6([
1867
1923
  import_async6.synchronized
1868
1924
  ], DataPipeline.prototype, "_processEpoch", null);
1869
- _ts_decorate5([
1925
+ _ts_decorate6([
1870
1926
  import_async6.synchronized
1871
1927
  ], DataPipeline.prototype, "createEpoch", null);
1872
- DataPipeline = _ts_decorate5([
1873
- (0, import_async6.trackLeaks)("open", "close")
1928
+ DataPipeline = _ts_decorate6([
1929
+ (0, import_async6.trackLeaks)("open", "close"),
1930
+ import_tracing2.trace.resource()
1874
1931
  ], DataPipeline);
1875
1932
 
1876
1933
  // packages/core/echo/echo-pipeline/src/space/space.ts
1877
- function _ts_decorate6(decorators, target, key, desc) {
1934
+ function _ts_decorate7(decorators, target, key, desc) {
1878
1935
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1879
1936
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1880
1937
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1884,7 +1941,7 @@ function _ts_decorate6(decorators, target, key, desc) {
1884
1941
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1885
1942
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1886
1943
  }
1887
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1944
+ var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space.ts";
1888
1945
  var Space = class Space2 {
1889
1946
  constructor(params) {
1890
1947
  this._addFeedLock = new import_async7.Lock();
@@ -2000,7 +2057,7 @@ var Space = class Space2 {
2000
2057
  setControlFeed(feed) {
2001
2058
  (0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
2002
2059
  F: __dxlog_file11,
2003
- L: 183,
2060
+ L: 184,
2004
2061
  S: this,
2005
2062
  A: [
2006
2063
  "!this._controlFeed",
@@ -2014,7 +2071,7 @@ var Space = class Space2 {
2014
2071
  setDataFeed(feed) {
2015
2072
  (0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
2016
2073
  F: __dxlog_file11,
2017
- L: 190,
2074
+ L: 191,
2018
2075
  S: this,
2019
2076
  A: [
2020
2077
  "!this._dataFeed",
@@ -2040,7 +2097,7 @@ var Space = class Space2 {
2040
2097
  async open(ctx) {
2041
2098
  (0, import_log10.log)("opening...", void 0, {
2042
2099
  F: __dxlog_file11,
2043
- L: 212,
2100
+ L: 213,
2044
2101
  S: this,
2045
2102
  C: (f, a) => f(...a)
2046
2103
  });
@@ -2053,7 +2110,7 @@ var Space = class Space2 {
2053
2110
  this._isOpen = true;
2054
2111
  (0, import_log10.log)("opened", void 0, {
2055
2112
  F: __dxlog_file11,
2056
- L: 223,
2113
+ L: 224,
2057
2114
  S: this,
2058
2115
  C: (f, a) => f(...a)
2059
2116
  });
@@ -2063,7 +2120,7 @@ var Space = class Space2 {
2063
2120
  key: this._key
2064
2121
  }, {
2065
2122
  F: __dxlog_file11,
2066
- L: 228,
2123
+ L: 229,
2067
2124
  S: this,
2068
2125
  C: (f, a) => f(...a)
2069
2126
  });
@@ -2077,7 +2134,7 @@ var Space = class Space2 {
2077
2134
  this._isOpen = false;
2078
2135
  (0, import_log10.log)("closed", void 0, {
2079
2136
  F: __dxlog_file11,
2080
- L: 241,
2137
+ L: 242,
2081
2138
  S: this,
2082
2139
  C: (f, a) => f(...a)
2083
2140
  });
@@ -2085,13 +2142,13 @@ var Space = class Space2 {
2085
2142
  async initializeDataPipeline() {
2086
2143
  (0, import_log10.log)("initializeDataPipeline", void 0, {
2087
2144
  F: __dxlog_file11,
2088
- L: 246,
2145
+ L: 247,
2089
2146
  S: this,
2090
2147
  C: (f, a) => f(...a)
2091
2148
  });
2092
2149
  (0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
2093
2150
  F: __dxlog_file11,
2094
- L: 247,
2151
+ L: 248,
2095
2152
  S: this,
2096
2153
  A: [
2097
2154
  "this._isOpen",
@@ -2101,22 +2158,23 @@ var Space = class Space2 {
2101
2158
  await this._dataPipeline.open();
2102
2159
  }
2103
2160
  };
2104
- _ts_decorate6([
2105
- import_log10.logInfo
2161
+ _ts_decorate7([
2162
+ import_log10.logInfo,
2163
+ import_tracing3.trace.info()
2106
2164
  ], Space.prototype, "key", null);
2107
- _ts_decorate6([
2165
+ _ts_decorate7([
2108
2166
  import_async7.synchronized,
2109
- import_tracing.trace.span()
2167
+ import_tracing3.trace.span()
2110
2168
  ], Space.prototype, "open", null);
2111
- _ts_decorate6([
2169
+ _ts_decorate7([
2112
2170
  import_async7.synchronized
2113
2171
  ], Space.prototype, "close", null);
2114
- _ts_decorate6([
2172
+ _ts_decorate7([
2115
2173
  import_async7.synchronized
2116
2174
  ], Space.prototype, "initializeDataPipeline", null);
2117
- Space = _ts_decorate6([
2175
+ Space = _ts_decorate7([
2118
2176
  (0, import_async7.trackLeaks)("open", "close"),
2119
- import_tracing.trace.resource()
2177
+ import_tracing3.trace.resource()
2120
2178
  ], Space);
2121
2179
 
2122
2180
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
@@ -2136,7 +2194,7 @@ var import_teleport2 = require("@dxos/teleport");
2136
2194
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2137
2195
  var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
2138
2196
  var import_util8 = require("@dxos/util");
2139
- function _ts_decorate7(decorators, target, key, desc) {
2197
+ function _ts_decorate8(decorators, target, key, desc) {
2140
2198
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2141
2199
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2142
2200
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2146,7 +2204,7 @@ function _ts_decorate7(decorators, target, key, desc) {
2146
2204
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2147
2205
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2148
2206
  }
2149
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
2207
+ var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
2150
2208
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
2151
2209
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
2152
2210
  var SpaceProtocol = class {
@@ -2177,7 +2235,7 @@ var SpaceProtocol = class {
2177
2235
  key: feed.key
2178
2236
  }, {
2179
2237
  F: __dxlog_file12,
2180
- L: 95,
2238
+ L: 96,
2181
2239
  S: this,
2182
2240
  C: (f, a) => f(...a)
2183
2241
  });
@@ -2186,6 +2244,7 @@ var SpaceProtocol = class {
2186
2244
  session.replicator.addFeed(feed);
2187
2245
  }
2188
2246
  }
2247
+ // TODO(burdon): Rename open? Common open/close interfaces for all services?
2189
2248
  async start() {
2190
2249
  if (this._connection) {
2191
2250
  return;
@@ -2199,7 +2258,7 @@ var SpaceProtocol = class {
2199
2258
  await this.blobSync.open();
2200
2259
  (0, import_log11.log)("starting...", void 0, {
2201
2260
  F: __dxlog_file12,
2202
- L: 120,
2261
+ L: 122,
2203
2262
  S: this,
2204
2263
  C: (f, a) => f(...a)
2205
2264
  });
@@ -2209,11 +2268,11 @@ var SpaceProtocol = class {
2209
2268
  peerId: this._swarmIdentity.peerKey,
2210
2269
  topic,
2211
2270
  topology: new import_network_manager.MMSTTopology(topologyConfig),
2212
- label: `Protocol swarm: ${topic}`
2271
+ label: `space swarm ${topic.truncate()}`
2213
2272
  });
2214
2273
  (0, import_log11.log)("started", void 0, {
2215
2274
  F: __dxlog_file12,
2216
- L: 130,
2275
+ L: 132,
2217
2276
  S: this,
2218
2277
  C: (f, a) => f(...a)
2219
2278
  });
@@ -2223,14 +2282,14 @@ var SpaceProtocol = class {
2223
2282
  if (this._connection) {
2224
2283
  (0, import_log11.log)("stopping...", void 0, {
2225
2284
  F: __dxlog_file12,
2226
- L: 137,
2285
+ L: 139,
2227
2286
  S: this,
2228
2287
  C: (f, a) => f(...a)
2229
2288
  });
2230
2289
  await this._connection.close();
2231
2290
  (0, import_log11.log)("stopped", void 0, {
2232
2291
  F: __dxlog_file12,
2233
- L: 139,
2292
+ L: 141,
2234
2293
  S: this,
2235
2294
  C: (f, a) => f(...a)
2236
2295
  });
@@ -2253,10 +2312,10 @@ var SpaceProtocol = class {
2253
2312
  };
2254
2313
  }
2255
2314
  };
2256
- _ts_decorate7([
2315
+ _ts_decorate8([
2257
2316
  import_log11.logInfo
2258
2317
  ], SpaceProtocol.prototype, "_topic", void 0);
2259
- _ts_decorate7([
2318
+ _ts_decorate8([
2260
2319
  import_log11.logInfo
2261
2320
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
2262
2321
  var AuthStatus;
@@ -2297,7 +2356,7 @@ var SpaceProtocolSession = class {
2297
2356
  onAuthSuccess: () => {
2298
2357
  (0, import_log11.log)("Peer authenticated", void 0, {
2299
2358
  F: __dxlog_file12,
2300
- L: 236,
2359
+ L: 238,
2301
2360
  S: this,
2302
2361
  C: (f, a) => f(...a)
2303
2362
  });
@@ -2316,15 +2375,15 @@ var SpaceProtocolSession = class {
2316
2375
  await this._teleport.close();
2317
2376
  }
2318
2377
  };
2319
- _ts_decorate7([
2378
+ _ts_decorate8([
2320
2379
  import_log11.logInfo
2321
2380
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
2322
- _ts_decorate7([
2381
+ _ts_decorate8([
2323
2382
  import_log11.logInfo
2324
2383
  ], SpaceProtocolSession.prototype, "authStatus", null);
2325
2384
 
2326
2385
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
2327
- function _ts_decorate8(decorators, target, key, desc) {
2386
+ function _ts_decorate9(decorators, target, key, desc) {
2328
2387
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2329
2388
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2330
2389
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2334,7 +2393,7 @@ function _ts_decorate8(decorators, target, key, desc) {
2334
2393
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2335
2394
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2336
2395
  }
2337
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2396
+ var __dxlog_file13 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2338
2397
  var SpaceManager = class SpaceManager2 {
2339
2398
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
2340
2399
  this._spaces = new import_util9.ComplexMap(import_keys6.PublicKey.hash);
@@ -2400,20 +2459,20 @@ var SpaceManager = class SpaceManager2 {
2400
2459
  id: this._instanceId
2401
2460
  }), {
2402
2461
  F: __dxlog_file13,
2403
- L: 125,
2462
+ L: 126,
2404
2463
  S: this,
2405
2464
  C: (f, a) => f(...a)
2406
2465
  });
2407
2466
  return space;
2408
2467
  }
2409
2468
  };
2410
- _ts_decorate8([
2469
+ _ts_decorate9([
2411
2470
  import_async8.synchronized
2412
2471
  ], SpaceManager.prototype, "open", null);
2413
- _ts_decorate8([
2472
+ _ts_decorate9([
2414
2473
  import_async8.synchronized
2415
2474
  ], SpaceManager.prototype, "close", null);
2416
- SpaceManager = _ts_decorate8([
2475
+ SpaceManager = _ts_decorate9([
2417
2476
  (0, import_async8.trackLeaks)("open", "close")
2418
2477
  ], SpaceManager);
2419
2478
 
@@ -2549,7 +2608,7 @@ var TestAgent = class {
2549
2608
  });
2550
2609
  space.setControlFeed(controlFeed);
2551
2610
  space.setDataFeed(dataFeed);
2552
- await space.open(new import_context6.Context());
2611
+ await space.open(new import_context7.Context());
2553
2612
  this._spaces.set(spaceKey, space);
2554
2613
  return space;
2555
2614
  }