@dxos/echo-pipeline 0.3.1 → 0.3.2-main.05033b7

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 (85) hide show
  1. package/dist/lib/browser/{chunk-523AYTYX.mjs → chunk-7IXNAFKL.mjs} +100 -113
  2. package/dist/lib/browser/chunk-7IXNAFKL.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 +244 -1
  6. package/dist/lib/browser/testing/index.mjs.map +4 -4
  7. package/dist/lib/node/index.cjs +136 -149
  8. package/dist/lib/node/index.cjs.map +3 -3
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +383 -151
  11. package/dist/lib/node/testing/index.cjs.map +4 -4
  12. package/dist/types/src/common/codec.d.ts +1 -1
  13. package/dist/types/src/common/codec.d.ts.map +1 -1
  14. package/dist/types/src/common/feeds.d.ts +2 -2
  15. package/dist/types/src/common/feeds.d.ts.map +1 -1
  16. package/dist/types/src/db-host/data-service-host.d.ts +4 -4
  17. package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
  18. package/dist/types/src/db-host/data-service.d.ts +3 -3
  19. package/dist/types/src/db-host/data-service.d.ts.map +1 -1
  20. package/dist/types/src/db-host/database-host.d.ts +5 -5
  21. package/dist/types/src/db-host/database-host.d.ts.map +1 -1
  22. package/dist/types/src/db-host/snapshot-manager.d.ts +3 -3
  23. package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
  24. package/dist/types/src/db-host/snapshot-store.d.ts +2 -2
  25. package/dist/types/src/db-host/snapshot-store.d.ts.map +1 -1
  26. package/dist/types/src/metadata/metadata-store.d.ts +3 -3
  27. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  28. package/dist/types/src/pipeline/index.d.ts +1 -1
  29. package/dist/types/src/pipeline/index.d.ts.map +1 -1
  30. package/dist/types/src/pipeline/message-selector.d.ts +2 -2
  31. package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
  32. package/dist/types/src/pipeline/pipeline.d.ts +2 -2
  33. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  34. package/dist/types/src/pipeline/timeframe-clock.d.ts +2 -2
  35. package/dist/types/src/pipeline/timeframe-clock.d.ts.map +1 -1
  36. package/dist/types/src/space/auth.d.ts +2 -2
  37. package/dist/types/src/space/auth.d.ts.map +1 -1
  38. package/dist/types/src/space/control-pipeline.d.ts +6 -6
  39. package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
  40. package/dist/types/src/space/data-pipeline.d.ts +6 -6
  41. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  42. package/dist/types/src/space/space-manager.d.ts +9 -9
  43. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  44. package/dist/types/src/space/space-protocol.d.ts +6 -6
  45. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  46. package/dist/types/src/space/space.d.ts +12 -12
  47. package/dist/types/src/space/space.d.ts.map +1 -1
  48. package/dist/types/src/testing/database-test-rig.d.ts +5 -4
  49. package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
  50. package/dist/types/src/testing/index.d.ts +1 -0
  51. package/dist/types/src/testing/index.d.ts.map +1 -1
  52. package/dist/types/src/testing/test-agent-builder.d.ts +4 -4
  53. package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
  54. package/dist/types/src/testing/util.d.ts +2 -2
  55. package/dist/types/src/testing/util.d.ts.map +1 -1
  56. package/package.json +32 -32
  57. package/src/common/codec.ts +1 -1
  58. package/src/common/feeds.ts +2 -2
  59. package/src/db-host/data-service-host.ts +6 -6
  60. package/src/db-host/data-service.ts +8 -8
  61. package/src/db-host/database-host.ts +5 -5
  62. package/src/db-host/snapshot-manager.ts +3 -5
  63. package/src/db-host/snapshot-store.test.ts +1 -1
  64. package/src/db-host/snapshot-store.ts +2 -2
  65. package/src/metadata/metadata-store.ts +7 -7
  66. package/src/pipeline/index.ts +1 -1
  67. package/src/pipeline/message-selector.ts +2 -2
  68. package/src/pipeline/pipeline-stress.test.ts +3 -3
  69. package/src/pipeline/pipeline.test.ts +1 -1
  70. package/src/pipeline/pipeline.ts +4 -4
  71. package/src/pipeline/timeframe-clock.ts +2 -2
  72. package/src/space/auth.ts +2 -2
  73. package/src/space/control-pipeline.test.ts +1 -1
  74. package/src/space/control-pipeline.ts +11 -10
  75. package/src/space/data-pipeline.ts +17 -12
  76. package/src/space/space-manager.ts +9 -9
  77. package/src/space/space-protocol.ts +10 -10
  78. package/src/space/space.ts +12 -12
  79. package/src/testing/database-test-rig.ts +9 -9
  80. package/src/testing/index.ts +1 -0
  81. package/src/testing/test-agent-builder.ts +5 -5
  82. package/src/testing/util.ts +3 -3
  83. package/src/tests/database-unit.test.ts +6 -4
  84. package/src/tests/database.test.ts +4 -4
  85. package/dist/lib/browser/chunk-523AYTYX.mjs.map +0 -7
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // packages/core/echo/echo-pipeline/src/testing/index.ts
31
31
  var testing_exports = {};
32
32
  __export(testing_exports, {
33
+ DatabaseTestBuilder: () => DatabaseTestBuilder,
34
+ DatabaseTestPeer: () => DatabaseTestPeer,
33
35
  MemoryNetworkManagerProvider: () => MemoryNetworkManagerProvider,
34
36
  TestAgent: () => TestAgent,
35
37
  TestAgentBuilder: () => TestAgentBuilder,
@@ -66,7 +68,7 @@ var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
66
68
 
67
69
  // packages/core/echo/echo-pipeline/src/common/feeds.ts
68
70
  var import_invariant = require("@dxos/invariant");
69
- var __dxlog_file = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/common/feeds.ts";
71
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
70
72
  var createMappedFeedWriter = (mapper, writer) => {
71
73
  (0, import_invariant.invariant)(mapper, void 0, {
72
74
  F: __dxlog_file,
@@ -108,7 +110,7 @@ var import_invariant2 = require("@dxos/invariant");
108
110
  var import_log = require("@dxos/log");
109
111
  var import_service = require("@dxos/protocols/proto/dxos/echo/service");
110
112
  var import_util = require("@dxos/util");
111
- var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
113
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
112
114
  var DataServiceHost = class {
113
115
  constructor(_itemManager, _itemDemuxer, _flush, _writeStream) {
114
116
  this._itemManager = _itemManager;
@@ -285,23 +287,12 @@ var DatabaseHost = class {
285
287
  };
286
288
 
287
289
  // packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
288
- var import_async = require("@dxos/async");
289
290
  var import_context2 = require("@dxos/context");
290
291
  var import_keys = require("@dxos/keys");
291
292
  var import_protocols2 = require("@dxos/protocols");
292
293
  var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
293
- function _ts_decorate(decorators, target, key, desc) {
294
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
295
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
296
- r = Reflect.decorate(decorators, target, key, desc);
297
- else
298
- for (var i = decorators.length - 1; i >= 0; i--)
299
- if (d = decorators[i])
300
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
301
- return c > 3 && r && Object.defineProperty(target, key, r), r;
302
- }
303
294
  var SpaceSnapshot = import_protocols2.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
304
- var SnapshotManager = class SnapshotManager2 {
295
+ var SnapshotManager = class {
305
296
  constructor(_snapshotStore, _blobStore, _blobSync) {
306
297
  this._snapshotStore = _snapshotStore;
307
298
  this._blobStore = _blobStore;
@@ -330,9 +321,6 @@ var SnapshotManager = class SnapshotManager2 {
330
321
  return import_keys.PublicKey.from(id).toHex();
331
322
  }
332
323
  };
333
- SnapshotManager = _ts_decorate([
334
- (0, import_async.trackLeaks)("open", "close")
335
- ], SnapshotManager);
336
324
 
337
325
  // packages/core/echo/echo-pipeline/src/db-host/snapshot-store.ts
338
326
  var import_crypto = require("@dxos/crypto");
@@ -385,7 +373,7 @@ var import_invariant3 = require("@dxos/invariant");
385
373
  var import_keys2 = require("@dxos/keys");
386
374
  var import_log2 = require("@dxos/log");
387
375
  var import_util2 = require("@dxos/util");
388
- var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
376
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
389
377
  var DataServiceSubscriptions = class {
390
378
  constructor() {
391
379
  this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
@@ -487,14 +475,14 @@ var DataServiceImpl = class {
487
475
 
488
476
  // packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
489
477
  var import_crc_32 = __toESM(require("crc-32"));
490
- var import_async2 = require("@dxos/async");
478
+ var import_async = require("@dxos/async");
491
479
  var import_invariant4 = require("@dxos/invariant");
492
480
  var import_keys3 = require("@dxos/keys");
493
481
  var import_log3 = require("@dxos/log");
494
482
  var import_protocols4 = require("@dxos/protocols");
495
483
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
496
484
  var import_util3 = require("@dxos/util");
497
- function _ts_decorate2(decorators, target, key, desc) {
485
+ function _ts_decorate(decorators, target, key, desc) {
498
486
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
499
487
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
500
488
  r = Reflect.decorate(decorators, target, key, desc);
@@ -504,7 +492,7 @@ function _ts_decorate2(decorators, target, key, desc) {
504
492
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
505
493
  return c > 3 && r && Object.defineProperty(target, key, r), r;
506
494
  }
507
- var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
495
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
508
496
  var emptyEchoMetadata = () => ({
509
497
  version: import_protocols4.STORAGE_VERSION,
510
498
  spaces: [],
@@ -520,7 +508,7 @@ var MetadataStore = class {
520
508
  this._metadata = emptyEchoMetadata();
521
509
  this._spaceLargeMetadata = new import_util3.ComplexMap(import_keys3.PublicKey.hash);
522
510
  this._metadataFile = void 0;
523
- this.update = new import_async2.Event();
511
+ this.update = new import_async.Event();
524
512
  }
525
513
  get metadata() {
526
514
  return this._metadata;
@@ -778,26 +766,26 @@ var MetadataStore = class {
778
766
  await this.flush();
779
767
  }
780
768
  };
781
- _ts_decorate2([
782
- import_async2.synchronized
769
+ _ts_decorate([
770
+ import_async.synchronized
783
771
  ], MetadataStore.prototype, "load", null);
784
- _ts_decorate2([
785
- import_async2.synchronized
772
+ _ts_decorate([
773
+ import_async.synchronized
786
774
  ], MetadataStore.prototype, "_save", null);
787
- _ts_decorate2([
788
- import_async2.synchronized
775
+ _ts_decorate([
776
+ import_async.synchronized
789
777
  ], MetadataStore.prototype, "_saveSpaceLargeMetadata", null);
790
778
  var fromBytesInt32 = (buf) => buf.readInt32LE(0);
791
779
 
792
780
  // packages/core/echo/echo-pipeline/src/space/auth.ts
793
- var import_async3 = require("@dxos/async");
781
+ var import_async2 = require("@dxos/async");
794
782
  var import_context3 = require("@dxos/context");
795
783
  var import_crypto2 = require("@dxos/crypto");
796
784
  var import_invariant5 = require("@dxos/invariant");
797
785
  var import_log4 = require("@dxos/log");
798
786
  var import_protocols5 = require("@dxos/protocols");
799
787
  var import_teleport = require("@dxos/teleport");
800
- var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/auth.ts";
788
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
801
789
  var AuthExtension = class extends import_teleport.RpcExtension {
802
790
  constructor(_authParams) {
803
791
  super({
@@ -848,7 +836,7 @@ var AuthExtension = class extends import_teleport.RpcExtension {
848
836
  }
849
837
  async onOpen(context) {
850
838
  await super.onOpen(context);
851
- (0, import_async3.scheduleTask)(this._ctx, async () => {
839
+ (0, import_async2.scheduleTask)(this._ctx, async () => {
852
840
  try {
853
841
  const challenge = (0, import_crypto2.randomBytes)(32);
854
842
  const { credential } = await this.rpc.AuthService.authenticate({
@@ -873,7 +861,7 @@ var AuthExtension = class extends import_teleport.RpcExtension {
873
861
  "'credential not verified'"
874
862
  ]
875
863
  });
876
- (0, import_async3.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
864
+ (0, import_async2.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
877
865
  } catch (err) {
878
866
  (0, import_log4.log)("auth failed", err, {
879
867
  F: __dxlog_file5,
@@ -897,7 +885,7 @@ var AuthExtension = class extends import_teleport.RpcExtension {
897
885
  };
898
886
 
899
887
  // packages/core/echo/echo-pipeline/src/space/space.ts
900
- var import_async8 = require("@dxos/async");
888
+ var import_async7 = require("@dxos/async");
901
889
  var import_invariant9 = require("@dxos/invariant");
902
890
  var import_log10 = require("@dxos/log");
903
891
  var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
@@ -905,7 +893,7 @@ var import_tracing3 = require("@dxos/tracing");
905
893
  var import_util7 = require("@dxos/util");
906
894
 
907
895
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
908
- var import_async6 = require("@dxos/async");
896
+ var import_async5 = require("@dxos/async");
909
897
  var import_context5 = require("@dxos/context");
910
898
  var import_credentials = require("@dxos/credentials");
911
899
  var import_keys5 = require("@dxos/keys");
@@ -916,7 +904,7 @@ var import_tracing = require("@dxos/tracing");
916
904
  var import_util5 = require("@dxos/util");
917
905
 
918
906
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
919
- var import_async5 = require("@dxos/async");
907
+ var import_async4 = require("@dxos/async");
920
908
  var import_context4 = require("@dxos/context");
921
909
  var import_debug3 = require("@dxos/debug");
922
910
  var import_feed_store = require("@dxos/feed-store");
@@ -929,7 +917,7 @@ var import_util4 = require("@dxos/util");
929
917
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
930
918
  var import_invariant6 = require("@dxos/invariant");
931
919
  var import_log5 = require("@dxos/log");
932
- var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
920
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
933
921
  var createMessageSelector = (timeframeClock) => {
934
922
  return (messages) => {
935
923
  for (let i = 0; i < messages.length; i++) {
@@ -957,11 +945,11 @@ var createMessageSelector = (timeframeClock) => {
957
945
  };
958
946
 
959
947
  // packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
960
- var import_async4 = require("@dxos/async");
948
+ var import_async3 = require("@dxos/async");
961
949
  var import_debug2 = require("@dxos/debug");
962
950
  var import_log6 = require("@dxos/log");
963
951
  var import_timeframe = require("@dxos/timeframe");
964
- function _ts_decorate3(decorators, target, key, desc) {
952
+ function _ts_decorate2(decorators, target, key, desc) {
965
953
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
966
954
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
967
955
  r = Reflect.decorate(decorators, target, key, desc);
@@ -971,7 +959,7 @@ function _ts_decorate3(decorators, target, key, desc) {
971
959
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
972
960
  return c > 3 && r && Object.defineProperty(target, key, r), r;
973
961
  }
974
- var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
962
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
975
963
  var mapFeedIndexesToTimeframe = (indexes) => new import_timeframe.Timeframe(indexes.map(({ feedKey, index }) => [
976
964
  feedKey,
977
965
  index
@@ -983,7 +971,7 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
983
971
  var TimeframeClock = class {
984
972
  constructor(_timeframe = new import_timeframe.Timeframe()) {
985
973
  this._timeframe = _timeframe;
986
- this.update = new import_async4.Event();
974
+ this.update = new import_async3.Event();
987
975
  this._pendingTimeframe = _timeframe;
988
976
  }
989
977
  /**
@@ -1045,12 +1033,12 @@ var TimeframeClock = class {
1045
1033
  });
1046
1034
  }
1047
1035
  };
1048
- _ts_decorate3([
1036
+ _ts_decorate2([
1049
1037
  (0, import_debug2.timed)(5e3)
1050
1038
  ], TimeframeClock.prototype, "waitUntilReached", null);
1051
1039
 
1052
1040
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
1053
- function _ts_decorate4(decorators, target, key, desc) {
1041
+ function _ts_decorate3(decorators, target, key, desc) {
1054
1042
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1055
1043
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1056
1044
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1060,14 +1048,14 @@ function _ts_decorate4(decorators, target, key, desc) {
1060
1048
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1061
1049
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1062
1050
  }
1063
- var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
1051
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
1064
1052
  var PipelineState = class {
1065
1053
  constructor(_feeds, _timeframeClock) {
1066
1054
  this._feeds = _feeds;
1067
1055
  this._timeframeClock = _timeframeClock;
1068
1056
  this._ctx = new import_context4.Context();
1069
1057
  this.timeframeUpdate = this._timeframeClock.update;
1070
- this.stalled = new import_async5.Event();
1058
+ this.stalled = new import_async4.Event();
1071
1059
  this._startTimeframe = new import_timeframe2.Timeframe();
1072
1060
  this._reachedTarget = false;
1073
1061
  }
@@ -1141,7 +1129,7 @@ var PipelineState = class {
1141
1129
  done = true;
1142
1130
  this._reachedTarget = true;
1143
1131
  }),
1144
- (0, import_async5.sleep)(timeout).then(() => {
1132
+ (0, import_async4.sleepWithContext)(this._ctx, timeout).then(() => {
1145
1133
  if (done) {
1146
1134
  return;
1147
1135
  }
@@ -1170,8 +1158,8 @@ var Pipeline = class {
1170
1158
  // External state accessor.
1171
1159
  this._state = new PipelineState(this._feeds, this._timeframeClock);
1172
1160
  // Waits for the message consumer to process the message and yield control back to the pipeline.
1173
- this._processingTrigger = new import_async5.Trigger().wake();
1174
- this._pauseTrigger = new import_async5.Trigger().wake();
1161
+ this._processingTrigger = new import_async4.Trigger().wake();
1162
+ this._pauseTrigger = new import_async4.Trigger().wake();
1175
1163
  // Pending downloads.
1176
1164
  this._downloads = new import_util4.ComplexMap((value) => import_keys4.PublicKey.hash(value.key));
1177
1165
  this._isStopping = false;
@@ -1448,24 +1436,24 @@ var Pipeline = class {
1448
1436
  }
1449
1437
  }
1450
1438
  };
1451
- _ts_decorate4([
1452
- import_async5.synchronized
1439
+ _ts_decorate3([
1440
+ import_async4.synchronized
1453
1441
  ], Pipeline.prototype, "start", null);
1454
- _ts_decorate4([
1455
- import_async5.synchronized
1442
+ _ts_decorate3([
1443
+ import_async4.synchronized
1456
1444
  ], Pipeline.prototype, "stop", null);
1457
- _ts_decorate4([
1458
- import_async5.synchronized
1445
+ _ts_decorate3([
1446
+ import_async4.synchronized
1459
1447
  ], Pipeline.prototype, "setCursor", null);
1460
- _ts_decorate4([
1461
- import_async5.synchronized
1448
+ _ts_decorate3([
1449
+ import_async4.synchronized
1462
1450
  ], Pipeline.prototype, "pause", null);
1463
- _ts_decorate4([
1464
- import_async5.synchronized
1451
+ _ts_decorate3([
1452
+ import_async4.synchronized
1465
1453
  ], Pipeline.prototype, "unpause", null);
1466
1454
 
1467
1455
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
1468
- function _ts_decorate5(decorators, target, key, desc) {
1456
+ function _ts_decorate4(decorators, target, key, desc) {
1469
1457
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1470
1458
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1471
1459
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1475,7 +1463,7 @@ function _ts_decorate5(decorators, target, key, desc) {
1475
1463
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1476
1464
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1477
1465
  }
1478
- var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1466
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1479
1467
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1480
1468
  var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
1481
1469
  var USE_SNAPSHOTS = true;
@@ -1486,8 +1474,8 @@ var ControlPipeline = class ControlPipeline2 {
1486
1474
  this.onFeedAdmitted = new import_util5.Callback();
1487
1475
  this._usage = new import_tracing.TimeUsageCounter();
1488
1476
  this._mutations = new import_tracing.TimeSeriesCounter();
1489
- this._snapshotTask = new import_async6.DeferredTask(this._ctx, async () => {
1490
- await (0, import_async6.sleep)(CONTROL_PIPELINE_SNAPSHOT_DELAY);
1477
+ this._snapshotTask = new import_async5.DeferredTask(this._ctx, async () => {
1478
+ await (0, import_async5.sleepWithContext)(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
1491
1479
  await this._saveSnapshot();
1492
1480
  });
1493
1481
  this._spaceKey = spaceKey;
@@ -1500,7 +1488,7 @@ var ControlPipeline = class ControlPipeline2 {
1500
1488
  key: info.key
1501
1489
  }, {
1502
1490
  F: __dxlog_file9,
1503
- L: 73,
1491
+ L: 74,
1504
1492
  S: this,
1505
1493
  C: (f, a) => f(...a)
1506
1494
  });
@@ -1512,7 +1500,7 @@ var ControlPipeline = class ControlPipeline2 {
1512
1500
  } catch (err) {
1513
1501
  import_log8.log.catch(err, void 0, {
1514
1502
  F: __dxlog_file9,
1515
- L: 82,
1503
+ L: 83,
1516
1504
  S: this,
1517
1505
  C: (f, a) => f(...a)
1518
1506
  });
@@ -1541,7 +1529,7 @@ var ControlPipeline = class ControlPipeline2 {
1541
1529
  tf: snapshot?.timeframe
1542
1530
  }, {
1543
1531
  F: __dxlog_file9,
1544
- L: 109,
1532
+ L: 110,
1545
1533
  S: this,
1546
1534
  C: (f, a) => f(...a)
1547
1535
  });
@@ -1550,7 +1538,7 @@ var ControlPipeline = class ControlPipeline2 {
1550
1538
  }
1551
1539
  (0, import_log8.log)("starting...", void 0, {
1552
1540
  F: __dxlog_file9,
1553
- L: 114,
1541
+ L: 115,
1554
1542
  S: this,
1555
1543
  C: (f, a) => f(...a)
1556
1544
  });
@@ -1560,7 +1548,7 @@ var ControlPipeline = class ControlPipeline2 {
1560
1548
  await this._pipeline.start();
1561
1549
  (0, import_log8.log)("started", void 0, {
1562
1550
  F: __dxlog_file9,
1563
- L: 120,
1551
+ L: 121,
1564
1552
  S: this,
1565
1553
  C: (f, a) => f(...a)
1566
1554
  });
@@ -1577,7 +1565,7 @@ var ControlPipeline = class ControlPipeline2 {
1577
1565
  message
1578
1566
  }, {
1579
1567
  F: __dxlog_file9,
1580
- L: 133,
1568
+ L: 134,
1581
1569
  S: this,
1582
1570
  C: (f, a) => f(...a)
1583
1571
  });
@@ -1599,7 +1587,7 @@ var ControlPipeline = class ControlPipeline2 {
1599
1587
  snapshot
1600
1588
  }, {
1601
1589
  F: __dxlog_file9,
1602
- L: 149,
1590
+ L: 150,
1603
1591
  S: this,
1604
1592
  C: (f, a) => f(...a)
1605
1593
  });
@@ -1614,7 +1602,7 @@ var ControlPipeline = class ControlPipeline2 {
1614
1602
  } catch (err) {
1615
1603
  import_log8.log.catch(err, void 0, {
1616
1604
  F: __dxlog_file9,
1617
- L: 162,
1605
+ L: 163,
1618
1606
  S: this,
1619
1607
  C: (f, a) => f(...a)
1620
1608
  });
@@ -1628,7 +1616,7 @@ var ControlPipeline = class ControlPipeline2 {
1628
1616
  seq: msg.seq
1629
1617
  }, {
1630
1618
  F: __dxlog_file9,
1631
- L: 172,
1619
+ L: 173,
1632
1620
  S: this,
1633
1621
  C: (f, a) => f(...a)
1634
1622
  });
@@ -1643,7 +1631,7 @@ var ControlPipeline = class ControlPipeline2 {
1643
1631
  msg
1644
1632
  }, {
1645
1633
  F: __dxlog_file9,
1646
- L: 181,
1634
+ L: 182,
1647
1635
  S: this,
1648
1636
  C: (f, a) => f(...a)
1649
1637
  });
@@ -1662,7 +1650,7 @@ var ControlPipeline = class ControlPipeline2 {
1662
1650
  async stop() {
1663
1651
  (0, import_log8.log)("stopping...", void 0, {
1664
1652
  F: __dxlog_file9,
1665
- L: 201,
1653
+ L: 202,
1666
1654
  S: this,
1667
1655
  C: (f, a) => f(...a)
1668
1656
  });
@@ -1671,7 +1659,7 @@ var ControlPipeline = class ControlPipeline2 {
1671
1659
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1672
1660
  (0, import_log8.log)("stopped", void 0, {
1673
1661
  F: __dxlog_file9,
1674
- L: 205,
1662
+ L: 206,
1675
1663
  S: this,
1676
1664
  C: (f, a) => f(...a)
1677
1665
  });
@@ -1684,36 +1672,37 @@ var ControlPipeline = class ControlPipeline2 {
1684
1672
  } catch (err) {
1685
1673
  (0, import_log8.log)(err, void 0, {
1686
1674
  F: __dxlog_file9,
1687
- L: 214,
1675
+ L: 215,
1688
1676
  S: this,
1689
1677
  C: (f, a) => f(...a)
1690
1678
  });
1691
1679
  }
1692
1680
  }
1693
1681
  };
1694
- _ts_decorate5([
1682
+ _ts_decorate4([
1695
1683
  import_tracing.trace.metricsCounter()
1696
1684
  ], ControlPipeline.prototype, "_usage", void 0);
1697
- _ts_decorate5([
1685
+ _ts_decorate4([
1698
1686
  import_tracing.trace.metricsCounter()
1699
1687
  ], ControlPipeline.prototype, "_mutations", void 0);
1700
- _ts_decorate5([
1688
+ _ts_decorate4([
1701
1689
  import_tracing.trace.span({
1702
1690
  showInBrowserTimeline: true
1703
1691
  })
1704
1692
  ], ControlPipeline.prototype, "start", null);
1705
- _ts_decorate5([
1693
+ _ts_decorate4([
1706
1694
  import_tracing.trace.span()
1707
1695
  ], ControlPipeline.prototype, "_consumePipeline", null);
1708
- _ts_decorate5([
1696
+ _ts_decorate4([
1709
1697
  import_tracing.trace.span()
1710
1698
  ], ControlPipeline.prototype, "_processMessage", null);
1711
- ControlPipeline = _ts_decorate5([
1712
- import_tracing.trace.resource()
1699
+ ControlPipeline = _ts_decorate4([
1700
+ import_tracing.trace.resource(),
1701
+ (0, import_async5.trackLeaks)("start", "stop")
1713
1702
  ], ControlPipeline);
1714
1703
 
1715
1704
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1716
- var import_async7 = require("@dxos/async");
1705
+ var import_async6 = require("@dxos/async");
1717
1706
  var import_context6 = require("@dxos/context");
1718
1707
  var import_credentials3 = require("@dxos/credentials");
1719
1708
  var import_echo_db3 = require("@dxos/echo-db");
@@ -1723,7 +1712,7 @@ var import_protocols6 = require("@dxos/protocols");
1723
1712
  var import_timeframe4 = require("@dxos/timeframe");
1724
1713
  var import_tracing2 = require("@dxos/tracing");
1725
1714
  var import_util6 = require("@dxos/util");
1726
- function _ts_decorate6(decorators, target, key, desc) {
1715
+ function _ts_decorate5(decorators, target, key, desc) {
1727
1716
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1728
1717
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1729
1718
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1733,7 +1722,7 @@ function _ts_decorate6(decorators, target, key, desc) {
1733
1722
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1734
1723
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1735
1724
  }
1736
- var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1725
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1737
1726
  var MESSAGES_PER_SNAPSHOT = 10;
1738
1727
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1739
1728
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 5e3;
@@ -1752,7 +1741,7 @@ var DataPipeline = class DataPipeline2 {
1752
1741
  this._mutations = new import_tracing2.TimeSeriesCounter();
1753
1742
  this.currentEpoch = void 0;
1754
1743
  this.appliedEpoch = void 0;
1755
- this.onNewEpoch = new import_async7.Event();
1744
+ this.onNewEpoch = new import_async6.Event();
1756
1745
  }
1757
1746
  get isOpen() {
1758
1747
  return this._isOpen;
@@ -1791,7 +1780,7 @@ var DataPipeline = class DataPipeline2 {
1791
1780
  write: (data, options) => {
1792
1781
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1793
1782
  F: __dxlog_file10,
1794
- L: 154,
1783
+ L: 159,
1795
1784
  S: this,
1796
1785
  A: [
1797
1786
  "this._pipeline",
@@ -1800,7 +1789,7 @@ var DataPipeline = class DataPipeline2 {
1800
1789
  });
1801
1790
  (0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
1802
1791
  F: __dxlog_file10,
1803
- L: 155,
1792
+ L: 160,
1804
1793
  S: this,
1805
1794
  A: [
1806
1795
  "this.currentEpoch",
@@ -1815,7 +1804,7 @@ var DataPipeline = class DataPipeline2 {
1815
1804
  this.databaseHost = new DatabaseHost(feedWriter, () => this._flush());
1816
1805
  this.itemManager = new import_echo_db3.ItemManager(this._params.modelFactory);
1817
1806
  await this.databaseHost.open(this.itemManager, this._params.modelFactory);
1818
- (0, import_async7.scheduleTask)(this._ctx, async () => {
1807
+ (0, import_async6.scheduleTask)(this._ctx, async () => {
1819
1808
  await this._consumePipeline();
1820
1809
  });
1821
1810
  this._isOpen = true;
@@ -1826,7 +1815,7 @@ var DataPipeline = class DataPipeline2 {
1826
1815
  }
1827
1816
  (0, import_log9.log)("close", void 0, {
1828
1817
  F: __dxlog_file10,
1829
- L: 179,
1818
+ L: 184,
1830
1819
  S: this,
1831
1820
  C: (f, a) => f(...a)
1832
1821
  });
@@ -1841,7 +1830,7 @@ var DataPipeline = class DataPipeline2 {
1841
1830
  } catch (err) {
1842
1831
  import_log9.log.catch(err, void 0, {
1843
1832
  F: __dxlog_file10,
1844
- L: 192,
1833
+ L: 197,
1845
1834
  S: this,
1846
1835
  C: (f, a) => f(...a)
1847
1836
  });
@@ -1866,7 +1855,7 @@ var DataPipeline = class DataPipeline2 {
1866
1855
  let messageCounter = 0;
1867
1856
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1868
1857
  F: __dxlog_file10,
1869
- L: 217,
1858
+ L: 222,
1870
1859
  S: this,
1871
1860
  A: [
1872
1861
  "this._pipeline",
@@ -1882,7 +1871,7 @@ var DataPipeline = class DataPipeline2 {
1882
1871
  seq
1883
1872
  }, {
1884
1873
  F: __dxlog_file10,
1885
- L: 223,
1874
+ L: 228,
1886
1875
  S: this,
1887
1876
  C: (f, a) => f(...a)
1888
1877
  });
@@ -1894,7 +1883,7 @@ var DataPipeline = class DataPipeline2 {
1894
1883
  feedKey
1895
1884
  }, {
1896
1885
  F: __dxlog_file10,
1897
- L: 229,
1886
+ L: 234,
1898
1887
  S: this,
1899
1888
  C: (f, a) => f(...a)
1900
1889
  });
@@ -1917,7 +1906,7 @@ var DataPipeline = class DataPipeline2 {
1917
1906
  spaceKey: this._params.spaceKey.toHex()
1918
1907
  }, {
1919
1908
  F: __dxlog_file10,
1920
- L: 246,
1909
+ L: 251,
1921
1910
  S: this,
1922
1911
  C: (f, a) => f(...a)
1923
1912
  });
@@ -1926,7 +1915,7 @@ var DataPipeline = class DataPipeline2 {
1926
1915
  } catch (err) {
1927
1916
  import_log9.log.catch(err, void 0, {
1928
1917
  F: __dxlog_file10,
1929
- L: 256,
1918
+ L: 261,
1930
1919
  S: this,
1931
1920
  C: (f, a) => f(...a)
1932
1921
  });
@@ -1934,14 +1923,14 @@ var DataPipeline = class DataPipeline2 {
1934
1923
  span.end();
1935
1924
  if (++messageCounter > 1e3) {
1936
1925
  messageCounter = 0;
1937
- await (0, import_async7.sleep)(1);
1926
+ await (0, import_async6.sleep)(1);
1938
1927
  }
1939
1928
  }
1940
1929
  }
1941
1930
  _createSnapshot() {
1942
1931
  (0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
1943
1932
  F: __dxlog_file10,
1944
- L: 270,
1933
+ L: 275,
1945
1934
  S: this,
1946
1935
  A: [
1947
1936
  "this.databaseHost",
@@ -1970,7 +1959,7 @@ var DataPipeline = class DataPipeline2 {
1970
1959
  } catch (err) {
1971
1960
  import_log9.log.warn("Failed to cache properties", err, {
1972
1961
  F: __dxlog_file10,
1973
- L: 299,
1962
+ L: 304,
1974
1963
  S: this,
1975
1964
  C: (f, a) => f(...a)
1976
1965
  });
@@ -1999,14 +1988,14 @@ var DataPipeline = class DataPipeline2 {
1999
1988
  if (err instanceof import_protocols6.CancelledError) {
2000
1989
  (0, import_log9.log)("Epoch processing cancelled.", void 0, {
2001
1990
  F: __dxlog_file10,
2002
- L: 335,
1991
+ L: 340,
2003
1992
  S: this,
2004
1993
  C: (f, a) => f(...a)
2005
1994
  });
2006
1995
  } else {
2007
1996
  import_log9.log.catch(err, void 0, {
2008
1997
  F: __dxlog_file10,
2009
- L: 337,
1998
+ L: 342,
2010
1999
  S: this,
2011
2000
  C: (f, a) => f(...a)
2012
2001
  });
@@ -2014,7 +2003,7 @@ var DataPipeline = class DataPipeline2 {
2014
2003
  }
2015
2004
  });
2016
2005
  this._epochCtx = ctx;
2017
- (0, import_async7.scheduleTask)(ctx, async () => {
2006
+ (0, import_async6.scheduleTask)(ctx, async () => {
2018
2007
  if (!this._isOpen) {
2019
2008
  return;
2020
2009
  }
@@ -2026,7 +2015,7 @@ var DataPipeline = class DataPipeline2 {
2026
2015
  async _processEpoch(ctx, epoch) {
2027
2016
  (0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
2028
2017
  F: __dxlog_file10,
2029
- L: 356,
2018
+ L: 361,
2030
2019
  S: this,
2031
2020
  A: [
2032
2021
  "this._isOpen",
@@ -2035,7 +2024,7 @@ var DataPipeline = class DataPipeline2 {
2035
2024
  });
2036
2025
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
2037
2026
  F: __dxlog_file10,
2038
- L: 357,
2027
+ L: 362,
2039
2028
  S: this,
2040
2029
  A: [
2041
2030
  "this._pipeline",
@@ -2047,7 +2036,7 @@ var DataPipeline = class DataPipeline2 {
2047
2036
  epoch: (0, import_log9.omit)(epoch, "proof")
2048
2037
  }, {
2049
2038
  F: __dxlog_file10,
2050
- L: 360,
2039
+ L: 365,
2051
2040
  S: this,
2052
2041
  C: (f, a) => f(...a)
2053
2042
  });
@@ -2057,7 +2046,7 @@ var DataPipeline = class DataPipeline2 {
2057
2046
  }
2058
2047
  (0, import_log9.log)("restarting pipeline from epoch", void 0, {
2059
2048
  F: __dxlog_file10,
2060
- L: 366,
2049
+ L: 371,
2061
2050
  S: this,
2062
2051
  C: (f, a) => f(...a)
2063
2052
  });
@@ -2068,7 +2057,7 @@ var DataPipeline = class DataPipeline2 {
2068
2057
  async waitUntilTimeframe(timeframe) {
2069
2058
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
2070
2059
  F: __dxlog_file10,
2071
- L: 373,
2060
+ L: 378,
2072
2061
  S: this,
2073
2062
  A: [
2074
2063
  "this._pipeline",
@@ -2080,7 +2069,7 @@ var DataPipeline = class DataPipeline2 {
2080
2069
  async createEpoch() {
2081
2070
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
2082
2071
  F: __dxlog_file10,
2083
- L: 379,
2072
+ L: 384,
2084
2073
  S: this,
2085
2074
  A: [
2086
2075
  "this._pipeline",
@@ -2089,7 +2078,7 @@ var DataPipeline = class DataPipeline2 {
2089
2078
  });
2090
2079
  (0, import_invariant8.invariant)(this.currentEpoch, void 0, {
2091
2080
  F: __dxlog_file10,
2092
- L: 380,
2081
+ L: 385,
2093
2082
  S: this,
2094
2083
  A: [
2095
2084
  "this.currentEpoch",
@@ -2120,7 +2109,7 @@ var DataPipeline = class DataPipeline2 {
2120
2109
  } catch (err) {
2121
2110
  import_log9.log.catch(err, void 0, {
2122
2111
  F: __dxlog_file10,
2123
- L: 410,
2112
+ L: 415,
2124
2113
  S: this,
2125
2114
  C: (f, a) => f(...a)
2126
2115
  });
@@ -2128,31 +2117,31 @@ var DataPipeline = class DataPipeline2 {
2128
2117
  await this._params.metadataStore.flush();
2129
2118
  }
2130
2119
  };
2131
- _ts_decorate6([
2120
+ _ts_decorate5([
2132
2121
  import_tracing2.trace.metricsCounter()
2133
2122
  ], DataPipeline.prototype, "_usage", void 0);
2134
- _ts_decorate6([
2123
+ _ts_decorate5([
2135
2124
  import_tracing2.trace.metricsCounter()
2136
2125
  ], DataPipeline.prototype, "_mutations", void 0);
2137
- _ts_decorate6([
2138
- import_async7.synchronized
2126
+ _ts_decorate5([
2127
+ import_async6.synchronized
2139
2128
  ], DataPipeline.prototype, "open", null);
2140
- _ts_decorate6([
2141
- import_async7.synchronized
2129
+ _ts_decorate5([
2130
+ import_async6.synchronized
2142
2131
  ], DataPipeline.prototype, "close", null);
2143
- _ts_decorate6([
2144
- import_async7.synchronized
2132
+ _ts_decorate5([
2133
+ import_async6.synchronized
2145
2134
  ], DataPipeline.prototype, "_processEpoch", null);
2146
- _ts_decorate6([
2147
- import_async7.synchronized
2135
+ _ts_decorate5([
2136
+ import_async6.synchronized
2148
2137
  ], DataPipeline.prototype, "createEpoch", null);
2149
- DataPipeline = _ts_decorate6([
2150
- (0, import_async7.trackLeaks)("open", "close"),
2138
+ DataPipeline = _ts_decorate5([
2139
+ (0, import_async6.trackLeaks)("open", "close"),
2151
2140
  import_tracing2.trace.resource()
2152
2141
  ], DataPipeline);
2153
2142
 
2154
2143
  // packages/core/echo/echo-pipeline/src/space/space.ts
2155
- function _ts_decorate7(decorators, target, key, desc) {
2144
+ function _ts_decorate6(decorators, target, key, desc) {
2156
2145
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2157
2146
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2158
2147
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2162,12 +2151,12 @@ function _ts_decorate7(decorators, target, key, desc) {
2162
2151
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2163
2152
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2164
2153
  }
2165
- var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space.ts";
2154
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
2166
2155
  var Space = class Space2 {
2167
2156
  constructor(params) {
2168
- this._addFeedLock = new import_async8.Lock();
2157
+ this._addFeedLock = new import_async7.Lock();
2169
2158
  this.onCredentialProcessed = new import_util7.Callback();
2170
- this.stateUpdate = new import_async8.Event();
2159
+ this.stateUpdate = new import_async7.Event();
2171
2160
  this._isOpen = false;
2172
2161
  (0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
2173
2162
  F: __dxlog_file11,
@@ -2381,27 +2370,27 @@ var Space = class Space2 {
2381
2370
  await this._dataPipeline.open();
2382
2371
  }
2383
2372
  };
2384
- _ts_decorate7([
2373
+ _ts_decorate6([
2385
2374
  import_log10.logInfo,
2386
2375
  import_tracing3.trace.info()
2387
2376
  ], Space.prototype, "key", null);
2388
- _ts_decorate7([
2389
- import_async8.synchronized,
2377
+ _ts_decorate6([
2378
+ import_async7.synchronized,
2390
2379
  import_tracing3.trace.span()
2391
2380
  ], Space.prototype, "open", null);
2392
- _ts_decorate7([
2393
- import_async8.synchronized
2381
+ _ts_decorate6([
2382
+ import_async7.synchronized
2394
2383
  ], Space.prototype, "close", null);
2395
- _ts_decorate7([
2396
- import_async8.synchronized
2384
+ _ts_decorate6([
2385
+ import_async7.synchronized
2397
2386
  ], Space.prototype, "initializeDataPipeline", null);
2398
- Space = _ts_decorate7([
2399
- (0, import_async8.trackLeaks)("open", "close"),
2387
+ Space = _ts_decorate6([
2388
+ (0, import_async7.trackLeaks)("open", "close"),
2400
2389
  import_tracing3.trace.resource()
2401
2390
  ], Space);
2402
2391
 
2403
2392
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
2404
- var import_async9 = require("@dxos/async");
2393
+ var import_async8 = require("@dxos/async");
2405
2394
  var import_debug4 = require("@dxos/debug");
2406
2395
  var import_keys7 = require("@dxos/keys");
2407
2396
  var import_log12 = require("@dxos/log");
@@ -2417,7 +2406,7 @@ var import_teleport2 = require("@dxos/teleport");
2417
2406
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2418
2407
  var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
2419
2408
  var import_util8 = require("@dxos/util");
2420
- function _ts_decorate8(decorators, target, key, desc) {
2409
+ function _ts_decorate7(decorators, target, key, desc) {
2421
2410
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2422
2411
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2423
2412
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2427,7 +2416,7 @@ function _ts_decorate8(decorators, target, key, desc) {
2427
2416
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2428
2417
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2429
2418
  }
2430
- var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
2419
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
2431
2420
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
2432
2421
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
2433
2422
  var SpaceProtocol = class {
@@ -2535,10 +2524,10 @@ var SpaceProtocol = class {
2535
2524
  };
2536
2525
  }
2537
2526
  };
2538
- _ts_decorate8([
2527
+ _ts_decorate7([
2539
2528
  import_log11.logInfo
2540
2529
  ], SpaceProtocol.prototype, "_topic", void 0);
2541
- _ts_decorate8([
2530
+ _ts_decorate7([
2542
2531
  import_log11.logInfo
2543
2532
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
2544
2533
  var AuthStatus;
@@ -2607,15 +2596,15 @@ var SpaceProtocolSession = class {
2607
2596
  await this._teleport.abort();
2608
2597
  }
2609
2598
  };
2610
- _ts_decorate8([
2599
+ _ts_decorate7([
2611
2600
  import_log11.logInfo
2612
2601
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
2613
- _ts_decorate8([
2602
+ _ts_decorate7([
2614
2603
  import_log11.logInfo
2615
2604
  ], SpaceProtocolSession.prototype, "authStatus", null);
2616
2605
 
2617
2606
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
2618
- function _ts_decorate9(decorators, target, key, desc) {
2607
+ function _ts_decorate8(decorators, target, key, desc) {
2619
2608
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2620
2609
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2621
2610
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2625,7 +2614,7 @@ function _ts_decorate9(decorators, target, key, desc) {
2625
2614
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2626
2615
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2627
2616
  }
2628
- var __dxlog_file13 = "/mnt/ramdisk/work/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2617
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2629
2618
  var SpaceManager = class SpaceManager2 {
2630
2619
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
2631
2620
  this._spaces = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
@@ -2698,14 +2687,14 @@ var SpaceManager = class SpaceManager2 {
2698
2687
  return space;
2699
2688
  }
2700
2689
  };
2701
- _ts_decorate9([
2702
- import_async9.synchronized
2690
+ _ts_decorate8([
2691
+ import_async8.synchronized
2703
2692
  ], SpaceManager.prototype, "open", null);
2704
- _ts_decorate9([
2705
- import_async9.synchronized
2693
+ _ts_decorate8([
2694
+ import_async8.synchronized
2706
2695
  ], SpaceManager.prototype, "close", null);
2707
- SpaceManager = _ts_decorate9([
2708
- (0, import_async9.trackLeaks)("open", "close")
2696
+ SpaceManager = _ts_decorate8([
2697
+ (0, import_async8.trackLeaks)("open", "close")
2709
2698
  ], SpaceManager);
2710
2699
 
2711
2700
  // packages/core/echo/echo-pipeline/src/testing/test-agent-builder.ts
@@ -2882,7 +2871,7 @@ var TestAgent = class {
2882
2871
  };
2883
2872
 
2884
2873
  // packages/core/echo/echo-pipeline/src/testing/util.ts
2885
- var import_async10 = require("@dxos/async");
2874
+ var import_async9 = require("@dxos/async");
2886
2875
  var import_document_model2 = require("@dxos/document-model");
2887
2876
  var import_echo_db4 = require("@dxos/echo-db");
2888
2877
  var import_testing2 = require("@dxos/feed-store/testing");
@@ -2944,10 +2933,253 @@ var testLocalDatabase = async (create, check = create) => {
2944
2933
  ]
2945
2934
  }
2946
2935
  });
2947
- await (0, import_async10.asyncTimeout)(check.databaseHost._itemDemuxer.mutation.waitForCondition(() => check.itemManager.entities.has(objectId)), 2e3);
2936
+ await (0, import_async9.asyncTimeout)(check.databaseHost._itemDemuxer.mutation.waitForCondition(() => check.itemManager.entities.has(objectId)), 2e3);
2937
+ };
2938
+
2939
+ // packages/core/echo/echo-pipeline/src/testing/database-test-rig.ts
2940
+ var import_async10 = require("@dxos/async");
2941
+ var import_document_model3 = require("@dxos/document-model");
2942
+ var import_echo_db5 = require("@dxos/echo-db");
2943
+ var import_invariant10 = require("@dxos/invariant");
2944
+ var import_keys10 = require("@dxos/keys");
2945
+ var import_model_factory3 = require("@dxos/model-factory");
2946
+ var import_protocols8 = require("@dxos/protocols");
2947
+ var import_text_model = require("@dxos/text-model");
2948
+ var import_timeframe6 = require("@dxos/timeframe");
2949
+ var import_util11 = require("@dxos/util");
2950
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/testing/database-test-rig.ts";
2951
+ var SPACE_KEY = import_keys10.PublicKey.random();
2952
+ var DatabaseTestBuilder = class {
2953
+ constructor() {
2954
+ this.peers = new import_util11.ComplexMap(import_keys10.PublicKey.hash);
2955
+ }
2956
+ async createPeer(spaceKey = SPACE_KEY) {
2957
+ const peer = new DatabaseTestPeer(this, spaceKey);
2958
+ this.peers.set(peer.key, peer);
2959
+ await peer.open();
2960
+ return peer;
2961
+ }
2962
+ };
2963
+ var DatabaseTestPeer = class {
2964
+ constructor(rig, spaceKey) {
2965
+ this.rig = rig;
2966
+ this.spaceKey = spaceKey;
2967
+ this.modelFactory = new import_model_factory3.ModelFactory().registerModel(import_document_model3.DocumentModel).registerModel(import_text_model.TextModel);
2968
+ this.key = import_keys10.PublicKey.random();
2969
+ this.feedMessages = [];
2970
+ this.snapshots = /* @__PURE__ */ new Map();
2971
+ this.confirmed = -1;
2972
+ this.timeframe = new import_timeframe6.Timeframe();
2973
+ this._onConfirm = new import_async10.Event();
2974
+ this._writes = /* @__PURE__ */ new Set();
2975
+ }
2976
+ async open() {
2977
+ this.hostItems = new import_echo_db5.ItemManager(this.modelFactory);
2978
+ this.host = new DatabaseHost({
2979
+ write: async (message, { afterWrite }) => {
2980
+ const seq = this.feedMessages.push({
2981
+ timeframe: this.timeframe,
2982
+ payload: {
2983
+ data: message
2984
+ }
2985
+ }) - 1;
2986
+ const request = {
2987
+ receipt: {
2988
+ seq,
2989
+ feedKey: this.key
2990
+ },
2991
+ options: {
2992
+ afterWrite
2993
+ },
2994
+ trigger: new import_async10.Trigger()
2995
+ };
2996
+ this._writes.add(request);
2997
+ await request.trigger.wait();
2998
+ return request.receipt;
2999
+ }
3000
+ }, async () => {
3001
+ });
3002
+ await this.host.open(this.hostItems, this.modelFactory);
3003
+ if (this.snapshot) {
3004
+ this.host._itemDemuxer.restoreFromSnapshot(this.snapshot.database);
3005
+ }
3006
+ this.items = new import_echo_db5.ItemManager(this.modelFactory);
3007
+ this.proxy = new import_echo_db5.DatabaseProxy({
3008
+ service: this.host.createDataServiceHost(),
3009
+ itemManager: this.items,
3010
+ spaceKey: this.spaceKey
3011
+ });
3012
+ await this.proxy.open(this.modelFactory);
3013
+ }
3014
+ /**
3015
+ * Confirm mutations written to the local feed.
3016
+ * @param seq Sequence number of the mutation to confirm. If not specified, all mutations will be confirmed.
3017
+ */
3018
+ async confirm(seq) {
3019
+ this.confirmed = seq ?? this.feedMessages.length - 1;
3020
+ this._onConfirm.emit();
3021
+ for (const request of [
3022
+ ...this._writes
3023
+ ]) {
3024
+ if (this.confirmed >= request.receipt.seq) {
3025
+ this._writes.delete(request);
3026
+ await request.options.afterWrite?.(request.receipt);
3027
+ request.trigger.wake();
3028
+ }
3029
+ }
3030
+ this._processMessages(import_timeframe6.Timeframe.merge(this.timeframe, new import_timeframe6.Timeframe([
3031
+ [
3032
+ this.key,
3033
+ this.confirmed
3034
+ ]
3035
+ ])));
3036
+ }
3037
+ /**
3038
+ * Replicate the database to the specified timeframe.
3039
+ * @param to Timeframe to replicate to. If not specified, the database will be replicated to the latest timeframe (based on all other peers).
3040
+ */
3041
+ replicate(to) {
3042
+ const toTimeframe = import_timeframe6.Timeframe.merge(to ?? new import_timeframe6.Timeframe(Array.from(this.rig.peers.values()).map((peer) => [
3043
+ peer.key,
3044
+ peer.confirmed
3045
+ ])), this.timeframe);
3046
+ toTimeframe.set(this.key, this.confirmed);
3047
+ this._processMessages(toTimeframe);
3048
+ }
3049
+ /**
3050
+ * Reload data from the feed. Wipes unconfirmed mutations.
3051
+ */
3052
+ async reload() {
3053
+ await this.open();
3054
+ const timeframe = this.timeframe;
3055
+ this.timeframe = this.snapshot?.timeframe ?? new import_timeframe6.Timeframe();
3056
+ this._processMessages(timeframe);
3057
+ }
3058
+ /**
3059
+ * Create snapshot and use it for the next reload.
3060
+ */
3061
+ makeSnapshot() {
3062
+ this.snapshot = {
3063
+ spaceKey: SPACE_KEY.asUint8Array(),
3064
+ database: this.host.createSnapshot(),
3065
+ timeframe: this.timeframe
3066
+ };
3067
+ return this.snapshot;
3068
+ }
3069
+ createEpoch(mockSnapshot) {
3070
+ const snapshot = this.makeSnapshot();
3071
+ mockSnapshot && (snapshot.database = mockSnapshot);
3072
+ const snapshotCid = import_keys10.PublicKey.from(import_protocols8.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot)).toHex();
3073
+ this.snapshots.set(snapshotCid, snapshot);
3074
+ const epoch = {
3075
+ previousId: import_keys10.PublicKey.random(),
3076
+ timeframe: this.timeframe,
3077
+ number: this.currentEpoch ? this.currentEpoch.number + 1 : 0,
3078
+ snapshotCid
3079
+ };
3080
+ this.currentEpoch = epoch;
3081
+ this.host._itemDemuxer.restoreFromSnapshot(snapshot.database);
3082
+ }
3083
+ /**
3084
+ * Gets all candidate messages according to the current timeframe.
3085
+ * Does not take into account the current snapshot, timeframe dependencies, or the confirmed, or replicated state.
3086
+ */
3087
+ _getHeads() {
3088
+ return Array.from(this.rig.peers.values()).map((peer) => {
3089
+ const seq = this.timeframe.get(peer.key) ?? -1;
3090
+ const message = peer.feedMessages[seq + 1];
3091
+ return message && {
3092
+ feedKey: peer.key,
3093
+ seq: seq + 1,
3094
+ data: message
3095
+ };
3096
+ }).filter(import_util11.isNotNullOrUndefined);
3097
+ }
3098
+ _processMessages(to) {
3099
+ let run = true;
3100
+ while (run) {
3101
+ run = false;
3102
+ const heads = this._getHeads();
3103
+ for (const candidate of heads) {
3104
+ const toSeq = to.get(candidate.feedKey) ?? -1;
3105
+ if (toSeq < candidate.seq) {
3106
+ continue;
3107
+ }
3108
+ const snapshotSeq = this.snapshot?.timeframe?.get(candidate.feedKey) ?? -1;
3109
+ if (candidate.seq <= snapshotSeq) {
3110
+ continue;
3111
+ }
3112
+ if (!import_timeframe6.Timeframe.dependencies(candidate.data.timeframe, this.timeframe).isEmpty()) {
3113
+ continue;
3114
+ }
3115
+ run = true;
3116
+ this.host.echoProcessor({
3117
+ batch: candidate.data.payload.data.batch,
3118
+ meta: {
3119
+ feedKey: candidate.feedKey,
3120
+ seq: candidate.seq,
3121
+ memberKey: candidate.feedKey,
3122
+ timeframe: candidate.data.timeframe
3123
+ }
3124
+ });
3125
+ this.timeframe = import_timeframe6.Timeframe.merge(this.timeframe, new import_timeframe6.Timeframe([
3126
+ [
3127
+ candidate.feedKey,
3128
+ candidate.seq
3129
+ ]
3130
+ ]));
3131
+ }
3132
+ }
3133
+ }
3134
+ getModel(id) {
3135
+ const item = this.items.getItem(id);
3136
+ if (!item) {
3137
+ return;
3138
+ }
3139
+ (0, import_invariant10.invariant)(item.modelMeta, void 0, {
3140
+ F: __dxlog_file14,
3141
+ L: 262,
3142
+ S: this,
3143
+ A: [
3144
+ "item.modelMeta",
3145
+ ""
3146
+ ]
3147
+ });
3148
+ const ModelConstructor = this.modelFactory.getModel(item.modelMeta.type)?.constructor;
3149
+ (0, import_invariant10.invariant)(ModelConstructor, void 0, {
3150
+ F: __dxlog_file14,
3151
+ L: 264,
3152
+ S: this,
3153
+ A: [
3154
+ "ModelConstructor",
3155
+ ""
3156
+ ]
3157
+ });
3158
+ const model = new ModelConstructor(item.modelMeta, item.id, () => item.state, async (mutation) => {
3159
+ (0, import_invariant10.invariant)(item.modelMeta, void 0, {
3160
+ F: __dxlog_file14,
3161
+ L: 271,
3162
+ S: this,
3163
+ A: [
3164
+ "item.modelMeta",
3165
+ ""
3166
+ ]
3167
+ });
3168
+ this.proxy.mutate((0, import_echo_db5.createModelMutation)(id, (0, import_echo_db5.encodeModelMutation)(item.modelMeta, mutation)));
3169
+ return {
3170
+ feedKey: import_keys10.PublicKey.from("00"),
3171
+ seq: 0,
3172
+ waitToBeProcessed: () => Promise.resolve()
3173
+ };
3174
+ });
3175
+ model.initialize();
3176
+ return model;
3177
+ }
2948
3178
  };
2949
3179
  // Annotate the CommonJS export names for ESM import in node:
2950
3180
  0 && (module.exports = {
3181
+ DatabaseTestBuilder,
3182
+ DatabaseTestPeer,
2951
3183
  MemoryNetworkManagerProvider,
2952
3184
  TestAgent,
2953
3185
  TestAgentBuilder,