@klum-db/lobby 0.2.0-pre.33 → 0.3.0-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -129,13 +129,13 @@ async function writeMultiVaultBundle(compartments, opts = {}) {
129
129
  const inner = [];
130
130
  const entries = [];
131
131
  for (const c of compartments) {
132
- const innerBytes = await (0, import_bundle.writeNoydbBundle)(c.vault, c.bundleOptions ?? {});
133
- const header = (0, import_bundle.readNoydbBundleHeader)(innerBytes);
132
+ const innerBytes = await (0, import_pod.writePod)(c.vault, c.bundleOptions ?? {});
133
+ const header = (0, import_pod.readPodHeader)(innerBytes);
134
134
  const entry = {
135
135
  handle: header.handle,
136
136
  exportedAt: c.exportedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
137
137
  innerBytes: innerBytes.length,
138
- innerSha256: await (0, import_kernel.sha256Hex)(innerBytes)
138
+ innerSha256: await (0, import_cargo.sha256Hex)(innerBytes)
139
139
  };
140
140
  if (c.roleTag !== void 0) entry.roleTag = c.roleTag;
141
141
  if (c.disclose?.name !== void 0 && c.disclose.name !== false) {
@@ -158,7 +158,7 @@ async function writeMultiVaultBundle(compartments, opts = {}) {
158
158
  }
159
159
  const manifest = {
160
160
  multiFormatVersion: NOYDB_MULTI_BUNDLE_VERSION,
161
- handle: opts.handle ?? (0, import_kernel.generateULID)(),
161
+ handle: opts.handle ?? (0, import_cargo.generateULID)(),
162
162
  compartments: entries
163
163
  };
164
164
  return encodeMultiBundle(manifest, inner);
@@ -166,12 +166,12 @@ async function writeMultiVaultBundle(compartments, opts = {}) {
166
166
  async function readNoydbBundleManifest(bytes) {
167
167
  if (hasMultiMagic(bytes)) return [...decodeMultiBundle(bytes).manifest.compartments];
168
168
  if ((0, import_hub.hasNoydbBundleMagic)(bytes)) {
169
- const header = (0, import_bundle.readNoydbBundleHeader)(bytes);
169
+ const header = (0, import_pod.readPodHeader)(bytes);
170
170
  const env = (0, import_hub.readNoydbBundlePublicEnvelope)(bytes);
171
171
  const entry = {
172
172
  handle: header.handle,
173
173
  innerBytes: bytes.length,
174
- innerSha256: await (0, import_kernel.sha256Hex)(bytes)
174
+ innerSha256: await (0, import_cargo.sha256Hex)(bytes)
175
175
  };
176
176
  if (env !== void 0) entry.publicEnvelope = env;
177
177
  return [entry];
@@ -183,7 +183,7 @@ function readMultiVaultBundleCompartment(bytes, selector) {
183
183
  throw new Error(`readMultiVaultBundleCompartment: numeric selector must be an integer, got ${selector}.`);
184
184
  }
185
185
  if ((0, import_hub.hasNoydbBundleMagic)(bytes) && !hasMultiMagic(bytes)) {
186
- const header = (0, import_bundle.readNoydbBundleHeader)(bytes);
186
+ const header = (0, import_pod.readPodHeader)(bytes);
187
187
  if (selector === 0 || selector === header.handle) return bytes;
188
188
  throw new Error(`readMultiVaultBundleCompartment: single v1 bundle has only compartment "${header.handle}".`);
189
189
  }
@@ -192,12 +192,12 @@ function readMultiVaultBundleCompartment(bytes, selector) {
192
192
  if (idx < 0 || idx >= inner.length) throw new Error(`readMultiVaultBundleCompartment: no compartment ${typeof selector === "number" ? `at index ${selector}` : `"${selector}"`}.`);
193
193
  return inner[idx];
194
194
  }
195
- var import_kernel, import_bundle, import_hub, NOYDB_MULTI_BUNDLE_MAGIC, NOYDB_MULTI_BUNDLE_PREFIX_BYTES, NOYDB_MULTI_BUNDLE_VERSION;
195
+ var import_cargo, import_pod, import_hub, NOYDB_MULTI_BUNDLE_MAGIC, NOYDB_MULTI_BUNDLE_PREFIX_BYTES, NOYDB_MULTI_BUNDLE_VERSION;
196
196
  var init_multi_bundle = __esm({
197
197
  "src/bundle/multi-bundle.ts"() {
198
198
  "use strict";
199
- import_kernel = require("@noy-db/hub/kernel");
200
- import_bundle = require("@noy-db/hub/bundle");
199
+ import_cargo = require("@noy-db/hub/cargo");
200
+ import_pod = require("@noy-db/hub/pod");
201
201
  import_hub = require("@noy-db/hub");
202
202
  init_uint32();
203
203
  NOYDB_MULTI_BUNDLE_MAGIC = new Uint8Array([78, 68, 66, 77]);
@@ -271,7 +271,7 @@ async function walkCrossVaultClosure(openVault, opts) {
271
271
  for (const vaultName of batch) {
272
272
  const seeds = perVaultSeeds.get(vaultName);
273
273
  const v = await openVault(vaultName);
274
- const { closure } = await (0, import_bundle2.walkClosure)(v, {
274
+ const { closure } = await (0, import_bundle.walkClosure)(v, {
275
275
  seeds,
276
276
  ...opts.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {}
277
277
  });
@@ -323,20 +323,20 @@ async function extractCrossVaultPartition(openVault, opts) {
323
323
  const sealIds = {};
324
324
  for (const [vaultName, seeds] of plan.perVaultSeeds) {
325
325
  const v = await openVault(vaultName);
326
- const { bundleBytes, transferKey, sealId } = await (0, import_bundle2.extractPartition)(v, {
326
+ const { bundleBytes, transferKey, sealId } = await (0, import_bundle.extractPartition)(v, {
327
327
  seeds,
328
328
  ...opts.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {},
329
329
  carrySchemas: opts.carrySchemas ?? true,
330
330
  carryLedger: opts.carryLedger ?? false,
331
331
  ...opts.compression !== void 0 ? { compression: opts.compression } : {}
332
332
  });
333
- const header = (0, import_bundle2.readNoydbBundleHeader)(bundleBytes);
333
+ const header = (0, import_pod2.readPodHeader)(bundleBytes);
334
334
  const meta = opts.compartmentMeta?.[vaultName];
335
335
  const entry = {
336
336
  handle: header.handle,
337
337
  exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
338
338
  innerBytes: bundleBytes.length,
339
- innerSha256: await (0, import_kernel2.sha256Hex)(bundleBytes)
339
+ innerSha256: await (0, import_cargo2.sha256Hex)(bundleBytes)
340
340
  };
341
341
  if (meta?.roleTag !== void 0) entry.roleTag = meta.roleTag;
342
342
  if (meta?.disclose?.name !== void 0 && meta.disclose.name !== false) {
@@ -355,7 +355,7 @@ async function extractCrossVaultPartition(openVault, opts) {
355
355
  }
356
356
  const manifest = {
357
357
  multiFormatVersion: NOYDB_MULTI_BUNDLE_VERSION,
358
- handle: (0, import_kernel2.generateULID)(),
358
+ handle: (0, import_cargo2.generateULID)(),
359
359
  compartments
360
360
  };
361
361
  return { bundle: encodeMultiBundle(manifest, inner), transferKeys, sealIds };
@@ -365,7 +365,7 @@ async function describeCrossVaultExtraction(openVault, opts) {
365
365
  const compartments = [];
366
366
  for (const [vaultName, seeds] of plan.perVaultSeeds) {
367
367
  const v = await openVault(vaultName);
368
- const preview = await (0, import_bundle2.describeExtraction)(v, {
368
+ const preview = await (0, import_bundle.describeExtraction)(v, {
369
369
  seeds,
370
370
  ...opts.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {}
371
371
  });
@@ -373,12 +373,13 @@ async function describeCrossVaultExtraction(openVault, opts) {
373
373
  }
374
374
  return { compartments, dangling: plan.dangling };
375
375
  }
376
- var import_bundle2, import_kernel2, CrossVaultDanglingRefError;
376
+ var import_bundle, import_pod2, import_cargo2, CrossVaultDanglingRefError;
377
377
  var init_extract_cross_vault = __esm({
378
378
  "src/interchange/extract-cross-vault.ts"() {
379
379
  "use strict";
380
- import_bundle2 = require("@noy-db/hub/bundle");
381
- import_kernel2 = require("@noy-db/hub/kernel");
380
+ import_bundle = require("@noy-db/hub/bundle");
381
+ import_pod2 = require("@noy-db/hub/pod");
382
+ import_cargo2 = require("@noy-db/hub/cargo");
382
383
  init_multi_bundle();
383
384
  CrossVaultDanglingRefError = class extends Error {
384
385
  constructor(dangling) {
@@ -464,7 +465,7 @@ async function mergeDecryptedRecords(receiver, decrypted, opts) {
464
465
  incomingSource.set(coll, srcMap);
465
466
  incomingSourceTs.set(coll, stsMap);
466
467
  }
467
- const diff = await (0, import_hub2.diffVault)(receiver, candidate);
468
+ const diff = await (0, import_cargo3.diffVault)(receiver, candidate);
468
469
  const byCollection = {};
469
470
  const conflicts = [];
470
471
  const writes = [];
@@ -580,15 +581,15 @@ async function mergeDecryptedRecords(receiver, decrypted, opts) {
580
581
  };
581
582
  }
582
583
  async function mergeCompartment(receiver, compartmentBytes, opts) {
583
- const incoming = await (0, import_bundle3.decryptExtractedPartition)(compartmentBytes, opts.transferKey);
584
+ const incoming = await (0, import_bundle2.decryptExtractedPartition)(compartmentBytes, opts.transferKey);
584
585
  return mergeDecryptedRecords(receiver, incoming, opts);
585
586
  }
586
- var import_hub2, import_bundle3, FieldLevelDeferredError;
587
+ var import_cargo3, import_bundle2, FieldLevelDeferredError;
587
588
  var init_merge_compartment = __esm({
588
589
  "src/interchange/merge-compartment.ts"() {
589
590
  "use strict";
590
- import_hub2 = require("@noy-db/hub");
591
- import_bundle3 = require("@noy-db/hub/bundle");
591
+ import_cargo3 = require("@noy-db/hub/cargo");
592
+ import_bundle2 = require("@noy-db/hub/bundle");
592
593
  init_field_authority();
593
594
  FieldLevelDeferredError = class extends Error {
594
595
  constructor(collection) {
@@ -684,7 +685,7 @@ async function graduate(noydb, docked, opts) {
684
685
  await mergeDecryptedRecords(vault, staged, { strategy: "take-incoming", reason: "dock:graduate" });
685
686
  let deedSealed = false;
686
687
  if (opts.deed) {
687
- await (0, import_hub3.createDeedOwner)(noydb._store, opts.vaultName, opts.deed.ownerId, opts.deed.sealingProvider);
688
+ await (0, import_cargo4.createDeedOwner)(noydb._store, opts.vaultName, opts.deed.ownerId, opts.deed.sealingProvider);
688
689
  deedSealed = true;
689
690
  }
690
691
  if (opts.stateVault) {
@@ -704,11 +705,11 @@ async function graduate(noydb, docked, opts) {
704
705
  event: { type: "unit-graduated", unitId: docked.unitId, vault: opts.vaultName }
705
706
  };
706
707
  }
707
- var import_hub3, UnitGraduationError, ISO_EPOCH;
708
+ var import_cargo4, UnitGraduationError, ISO_EPOCH;
708
709
  var init_graduate = __esm({
709
710
  "src/dock/graduate.ts"() {
710
711
  "use strict";
711
- import_hub3 = require("@noy-db/hub");
712
+ import_cargo4 = require("@noy-db/hub/cargo");
712
713
  init_merge_compartment();
713
714
  init_stage_records();
714
715
  UnitGraduationError = class extends Error {
@@ -738,7 +739,7 @@ __export(surface_exports, {
738
739
  async function proposeSurface(smv, def, proposedBy, now) {
739
740
  const row = {
740
741
  ...def,
741
- id: def.id ?? (0, import_kernel3.generateULID)(),
742
+ id: def.id ?? (0, import_cargo5.generateULID)(),
742
743
  status: "proposed",
743
744
  proposedBy,
744
745
  createdAt: now
@@ -759,7 +760,7 @@ async function exportSurface(source, surface) {
759
760
  throw new SurfaceStateError(surface.id, surface.status, "agreed");
760
761
  }
761
762
  const seeds = Object.fromEntries(surface.collections.map((c) => [c, () => true]));
762
- const { bundleBytes, transferKey } = await (0, import_bundle5.extractPartition)(source, {
763
+ const { bundleBytes, transferKey } = await (0, import_bundle4.extractPartition)(source, {
763
764
  seeds,
764
765
  maxDepth: 0,
765
766
  ...surface.fields ? { fieldProjection: surface.fields } : {},
@@ -797,12 +798,12 @@ async function markSynced(smv, id, now) {
797
798
  nextSyncDueAt: now + cadenceMs
798
799
  });
799
800
  }
800
- var import_kernel3, import_bundle5, SurfaceNotFoundError, SurfaceStateError, SurfaceCadenceScheduler;
801
+ var import_cargo5, import_bundle4, SurfaceNotFoundError, SurfaceStateError, SurfaceCadenceScheduler;
801
802
  var init_surface = __esm({
802
803
  "src/interchange/surface.ts"() {
803
804
  "use strict";
804
- import_kernel3 = require("@noy-db/hub/kernel");
805
- import_bundle5 = require("@noy-db/hub/bundle");
805
+ import_cargo5 = require("@noy-db/hub/cargo");
806
+ import_bundle4 = require("@noy-db/hub/bundle");
806
807
  init_merge_compartment();
807
808
  SurfaceNotFoundError = class extends Error {
808
809
  name = "SurfaceNotFoundError";
@@ -907,38 +908,38 @@ function canonical(value) {
907
908
  return `{${keys.map((k) => `${JSON.stringify(k)}:${canonical(obj[k])}`).join(",")}}`;
908
909
  }
909
910
  async function fingerprintBlueprint(bp) {
910
- return (0, import_kernel4.sha256Hex)(new TextEncoder().encode(canonical(bp)));
911
+ return (0, import_cargo6.sha256Hex)(new TextEncoder().encode(canonical(bp)));
911
912
  }
912
- var import_kernel4;
913
+ var import_cargo6;
913
914
  var init_schema_manifest = __esm({
914
915
  "src/federation/schema-manifest.ts"() {
915
916
  "use strict";
916
- import_kernel4 = require("@noy-db/hub/kernel");
917
+ import_cargo6 = require("@noy-db/hub/cargo");
917
918
  }
918
919
  });
919
920
 
920
921
  // src/federation/constants.ts
921
- var import_hub4;
922
+ var import_cargo7;
922
923
  var init_constants = __esm({
923
924
  "src/federation/constants.ts"() {
924
925
  "use strict";
925
- import_hub4 = require("@noy-db/hub");
926
+ import_cargo7 = require("@noy-db/hub/cargo");
926
927
  }
927
928
  });
928
929
 
929
930
  // src/federation/state-vault.ts
930
931
  var state_vault_exports = {};
931
932
  __export(state_vault_exports, {
932
- STATE_VAULT_NAME: () => import_hub4.STATE_VAULT_NAME,
933
+ STATE_VAULT_NAME: () => import_cargo7.STATE_VAULT_NAME,
933
934
  StateManagementVault: () => StateManagementVault
934
935
  });
935
- var import_kernel5, REGISTRY, MANIFEST, EVENTS, MIGRATION_STATUS, SURFACES, StateManagementVault;
936
+ var import_cargo8, REGISTRY, MANIFEST, EVENTS, MIGRATION_STATUS, SURFACES, StateManagementVault;
936
937
  var init_state_vault = __esm({
937
938
  "src/federation/state-vault.ts"() {
938
939
  "use strict";
939
940
  init_schema_manifest();
940
941
  init_constants();
941
- import_kernel5 = require("@noy-db/hub/kernel");
942
+ import_cargo8 = require("@noy-db/hub/cargo");
942
943
  init_constants();
943
944
  REGISTRY = "vaultRegistry";
944
945
  MANIFEST = "schemaManifest";
@@ -968,7 +969,7 @@ var init_state_vault = __esm({
968
969
  #surfaces;
969
970
  /** Idempotently open the reserved state vault and bind the control-plane collections. */
970
971
  static async open(db) {
971
- const vault = await db.openVault(import_hub4.STATE_VAULT_NAME);
972
+ const vault = await db.openVault(import_cargo7.STATE_VAULT_NAME);
972
973
  return new _StateManagementVault(
973
974
  vault.collection(REGISTRY),
974
975
  vault.collection(MANIFEST),
@@ -1028,7 +1029,7 @@ var init_state_vault = __esm({
1028
1029
  */
1029
1030
  async appendEvent(event) {
1030
1031
  const ts = event.ts ?? Date.now();
1031
- const id = (0, import_kernel5.generateULID)();
1032
+ const id = (0, import_cargo8.generateULID)();
1032
1033
  await this.#events.put(id, { ...event, id, ts });
1033
1034
  }
1034
1035
  /**
@@ -1070,13 +1071,13 @@ var init_state_vault = __esm({
1070
1071
 
1071
1072
  // src/federation/classify-skip.ts
1072
1073
  function classifyShardSkip(err) {
1073
- return err instanceof import_kernel6.NoAccessError ? "no-grant" : "error";
1074
+ return err instanceof import_cargo9.NoAccessError ? "no-grant" : "error";
1074
1075
  }
1075
- var import_kernel6;
1076
+ var import_cargo9;
1076
1077
  var init_classify_skip = __esm({
1077
1078
  "src/federation/classify-skip.ts"() {
1078
1079
  "use strict";
1079
- import_kernel6 = require("@noy-db/hub/kernel");
1080
+ import_cargo9 = require("@noy-db/hub/cargo");
1080
1081
  }
1081
1082
  });
1082
1083
 
@@ -1101,7 +1102,7 @@ async function applyBroadcastLegs(rows, legs) {
1101
1102
  for (const leg of legs) {
1102
1103
  const map = /* @__PURE__ */ new Map();
1103
1104
  for (const rec of await leg.from.list()) {
1104
- const k = coerceKey((0, import_kernel7.readPath)(rec, leg.on));
1105
+ const k = coerceKey((0, import_cargo10.readPath)(rec, leg.on));
1105
1106
  if (k !== null && !map.has(k)) map.set(k, rec);
1106
1107
  }
1107
1108
  indexes.push({ leg, map });
@@ -1109,7 +1110,7 @@ async function applyBroadcastLegs(rows, legs) {
1109
1110
  return rows.map((row) => {
1110
1111
  const out = { ...row };
1111
1112
  for (const { leg, map } of indexes) {
1112
- const key = coerceKey((0, import_kernel7.readPath)(row, leg.field));
1113
+ const key = coerceKey((0, import_cargo10.readPath)(row, leg.field));
1113
1114
  const match = key === null ? null : map.get(key) ?? null;
1114
1115
  if (match === null && leg.mode === "warn") {
1115
1116
  warnOnceBroadcastMiss(leg.field, leg.as, key ?? "<null>");
@@ -1119,11 +1120,11 @@ async function applyBroadcastLegs(rows, legs) {
1119
1120
  return out;
1120
1121
  });
1121
1122
  }
1122
- var import_kernel7, warnedBroadcastKeys;
1123
+ var import_cargo10, warnedBroadcastKeys;
1123
1124
  var init_cross_shard_join = __esm({
1124
1125
  "src/federation/cross-shard-join.ts"() {
1125
1126
  "use strict";
1126
- import_kernel7 = require("@noy-db/hub/kernel");
1127
+ import_cargo10 = require("@noy-db/hub/cargo");
1127
1128
  warnedBroadcastKeys = /* @__PURE__ */ new Set();
1128
1129
  }
1129
1130
  });
@@ -1334,12 +1335,12 @@ var init_partial_reduce = __esm({
1334
1335
  });
1335
1336
 
1336
1337
  // src/federation/aggregate-across.ts
1337
- var import_kernel8, import_kernel9, CrossVaultAggregation, CrossVaultGroupedAggregation;
1338
+ var import_cargo11, import_cargo12, CrossVaultAggregation, CrossVaultGroupedAggregation;
1338
1339
  var init_aggregate_across = __esm({
1339
1340
  "src/federation/aggregate-across.ts"() {
1340
1341
  "use strict";
1341
- import_kernel8 = require("@noy-db/hub/kernel");
1342
- import_kernel9 = require("@noy-db/hub/kernel");
1342
+ import_cargo11 = require("@noy-db/hub/cargo");
1343
+ import_cargo12 = require("@noy-db/hub/cargo");
1343
1344
  init_cross_vault_live();
1344
1345
  init_partial_reduce();
1345
1346
  CrossVaultAggregation = class {
@@ -1357,7 +1358,7 @@ var init_aggregate_across = __esm({
1357
1358
  return { result: finalizePartial(this.spec, mergePartials(this.spec, partials)), skippedVaults: skippedVaults2 };
1358
1359
  }
1359
1360
  const { records, skippedVaults } = await this.src.fanoutRecords(options);
1360
- return { result: (0, import_kernel8.reduceRecords)(records, this.spec), skippedVaults };
1361
+ return { result: (0, import_cargo11.reduceRecords)(records, this.spec), skippedVaults };
1361
1362
  }
1362
1363
  live(options = {}) {
1363
1364
  if (!this.bind) throw new Error("CrossVaultAggregation: live() requires a LiveBinding \u2014 use ShardedQuery.aggregate()");
@@ -1368,7 +1369,7 @@ var init_aggregate_across = __esm({
1368
1369
  isRelevant: this.bind.isRelevant,
1369
1370
  compute: async () => {
1370
1371
  const { records, skippedVaults } = await src.fanoutRecords(options);
1371
- return { value: (0, import_kernel8.reduceRecords)(records, spec), skipped: skippedVaults };
1372
+ return { value: (0, import_cargo11.reduceRecords)(records, spec), skipped: skippedVaults };
1372
1373
  },
1373
1374
  initialSnapshot: { value: void 0, skipped: [] },
1374
1375
  ...options.debounceMs !== void 0 ? { debounceMs: options.debounceMs } : {}
@@ -1403,7 +1404,7 @@ var init_aggregate_across = __esm({
1403
1404
  async run(options = {}) {
1404
1405
  const { records, skippedVaults } = await this.src.fanoutRecords(options);
1405
1406
  return {
1406
- results: (0, import_kernel9.groupAndReduce)(records, this.field, this.spec),
1407
+ results: (0, import_cargo12.groupAndReduce)(records, this.field, this.spec),
1407
1408
  skippedVaults
1408
1409
  };
1409
1410
  }
@@ -1418,7 +1419,7 @@ var init_aggregate_across = __esm({
1418
1419
  compute: async () => {
1419
1420
  const { records, skippedVaults } = await src.fanoutRecords(options);
1420
1421
  return {
1421
- records: (0, import_kernel9.groupAndReduce)(records, field, spec),
1422
+ records: (0, import_cargo12.groupAndReduce)(records, field, spec),
1422
1423
  skipped: skippedVaults
1423
1424
  };
1424
1425
  },
@@ -1491,7 +1492,7 @@ async function retrieveAcross(group, collectionName, query, opts = {}) {
1491
1492
  }
1492
1493
  return pv.hits.map((h) => ({ ...h, id: pv.vault + SEP + h.id }));
1493
1494
  });
1494
- const fused = (0, import_kernel10.fuseRetrieval)(lists, {
1495
+ const fused = (0, import_cargo13.fuseRetrieval)(lists, {
1495
1496
  ...opts.limit !== void 0 ? { limit: opts.limit } : {},
1496
1497
  ...opts.rrfK !== void 0 ? { k: opts.rrfK } : {}
1497
1498
  });
@@ -1501,11 +1502,11 @@ async function retrieveAcross(group, collectionName, query, opts = {}) {
1501
1502
  });
1502
1503
  return { hits, skippedVaults };
1503
1504
  }
1504
- var import_kernel10, SEP;
1505
+ var import_cargo13, SEP;
1505
1506
  var init_retrieve_across = __esm({
1506
1507
  "src/federation/retrieve-across.ts"() {
1507
1508
  "use strict";
1508
- import_kernel10 = require("@noy-db/hub/kernel");
1509
+ import_cargo13 = require("@noy-db/hub/cargo");
1509
1510
  init_classify_skip();
1510
1511
  SEP = "\0";
1511
1512
  }
@@ -1525,28 +1526,28 @@ function autoPushConfig(spec) {
1525
1526
  }
1526
1527
  function assertSafePartitionKey(partitionKey) {
1527
1528
  if (partitionKey.length === 0) {
1528
- throw new import_kernel11.ValidationError("partitionKey must be a non-empty string");
1529
+ throw new import_cargo14.ValidationError("partitionKey must be a non-empty string");
1529
1530
  }
1530
- if (partitionKey === import_hub4.STATE_VAULT_NAME) {
1531
- throw new import_kernel11.ReservedVaultNameError(partitionKey);
1531
+ if (partitionKey === import_cargo7.STATE_VAULT_NAME) {
1532
+ throw new import_cargo14.ReservedVaultNameError(partitionKey);
1532
1533
  }
1533
1534
  if (!SAFE_PARTITION_KEY.test(partitionKey)) {
1534
- throw new import_kernel11.ValidationError(
1535
+ throw new import_cargo14.ValidationError(
1535
1536
  `partitionKey "${partitionKey}" contains characters outside [A-Za-z0-9._-]. Map your records to a store-safe key in sharding.keyOf.`
1536
1537
  );
1537
1538
  }
1538
1539
  if (partitionKey.includes(SHARD_SEPARATOR)) {
1539
- throw new import_kernel11.ValidationError(
1540
+ throw new import_cargo14.ValidationError(
1540
1541
  `partitionKey "${partitionKey}" must not contain "--" \u2014 it is reserved as the shard vault-id separator and would risk shard-id collisions.`
1541
1542
  );
1542
1543
  }
1543
1544
  }
1544
- var import_kernel11, SHARD_SEPARATOR, SAFE_PARTITION_KEY, VaultGroup, ShardedCollection, ShardedQuery, ShardedGroupedQuery;
1545
+ var import_cargo14, SHARD_SEPARATOR, SAFE_PARTITION_KEY, VaultGroup, ShardedCollection, ShardedQuery, ShardedGroupedQuery;
1545
1546
  var init_vault_group = __esm({
1546
1547
  "src/federation/vault-group.ts"() {
1547
1548
  "use strict";
1548
1549
  init_state_vault();
1549
- import_kernel11 = require("@noy-db/hub/kernel");
1550
+ import_cargo14 = require("@noy-db/hub/cargo");
1550
1551
  init_constants();
1551
1552
  init_classify_skip();
1552
1553
  init_cross_shard_join();
@@ -1567,7 +1568,7 @@ var init_vault_group = __esm({
1567
1568
  this.cutoverOnOpen = cutoverOnOpen;
1568
1569
  this.meta = meta;
1569
1570
  if (name.includes(SHARD_SEPARATOR)) {
1570
- throw new import_kernel11.ValidationError(
1571
+ throw new import_cargo14.ValidationError(
1571
1572
  `VaultGroup name "${name}" must not contain "--" (reserved shard vault-id separator).`
1572
1573
  );
1573
1574
  }
@@ -1672,11 +1673,11 @@ var init_vault_group = __esm({
1672
1673
  const vaultId = this.shardVaultId(partitionKey);
1673
1674
  const row = await this.registry.get(this.registryId(partitionKey));
1674
1675
  const provisioned = await this.db._shardVaultProvisioned(vaultId);
1675
- if (row && !provisioned) throw new import_kernel11.ShardProvisioningError(vaultId, partitionKey);
1676
+ if (row && !provisioned) throw new import_cargo14.ShardProvisioningError(vaultId, partitionKey);
1676
1677
  if (row && provisioned) return this.openShard(partitionKey);
1677
1678
  if (region !== void 0) {
1678
1679
  const backendRegion = this.db._resolveBackend(vaultId).capabilities?.region;
1679
- if (backendRegion !== region) throw new import_kernel11.DataResidencyError(vaultId, region, backendRegion);
1680
+ if (backendRegion !== region) throw new import_cargo14.DataResidencyError(vaultId, region, backendRegion);
1680
1681
  }
1681
1682
  const vault = await this.db.openVault(vaultId);
1682
1683
  this.template.configure(vault);
@@ -1710,9 +1711,9 @@ var init_vault_group = __esm({
1710
1711
  async shard(partitionKey) {
1711
1712
  const vaultId = this.shardVaultId(partitionKey);
1712
1713
  const row = await this.registry.get(this.registryId(partitionKey));
1713
- if (!row) throw new import_kernel11.UnknownShardError(partitionKey, this.name);
1714
+ if (!row) throw new import_cargo14.UnknownShardError(partitionKey, this.name);
1714
1715
  const provisioned = await this.db._shardVaultProvisioned(vaultId);
1715
- if (!provisioned) throw new import_kernel11.ShardProvisioningError(vaultId, partitionKey);
1716
+ if (!provisioned) throw new import_cargo14.ShardProvisioningError(vaultId, partitionKey);
1716
1717
  return this.openShard(partitionKey);
1717
1718
  }
1718
1719
  /** A sharded view over one logical collection across all shards. */
@@ -1744,7 +1745,7 @@ var init_vault_group = __esm({
1744
1745
  for (const p of probes) {
1745
1746
  if ("error" in p) skipped.push({ vaultId: p.row.vaultId, reason: "error", error: p.error });
1746
1747
  else if (p.provisioned) eligible.push(p.row);
1747
- else skipped.push({ vaultId: p.row.vaultId, reason: "error", error: new import_kernel11.ShardProvisioningError(p.row.vaultId, p.row.partitionKey) });
1748
+ else skipped.push({ vaultId: p.row.vaultId, reason: "error", error: new import_cargo14.ShardProvisioningError(p.row.vaultId, p.row.partitionKey) });
1748
1749
  }
1749
1750
  return { eligible, skipped };
1750
1751
  }
@@ -1781,7 +1782,7 @@ var init_vault_group = __esm({
1781
1782
  withCrossVaultDerivation(spec) {
1782
1783
  const target = spec.target.vault;
1783
1784
  if (target === this.name || target.startsWith(`${this.name}${SHARD_SEPARATOR}`)) {
1784
- throw new import_kernel11.ValidationError(
1785
+ throw new import_cargo14.ValidationError(
1785
1786
  `withCrossVaultDerivation: target.vault "${target}" is the "${this.name}" group itself or one of its shards \u2014 an Insight summary must target a SEPARATE analytics vault, never write back into client-shard data (it would breach the per-shard DEK boundary). Use a distinct vault name.`
1786
1787
  );
1787
1788
  }
@@ -1907,7 +1908,7 @@ var init_vault_group = __esm({
1907
1908
  async cutoverShard(partitionKey) {
1908
1909
  const vaultId = this.shardVaultId(partitionKey);
1909
1910
  const row = await this.registry.get(this.registryId(partitionKey));
1910
- if (!row) throw new import_kernel11.UnknownShardError(partitionKey, this.name);
1911
+ if (!row) throw new import_cargo14.UnknownShardError(partitionKey, this.name);
1911
1912
  const target = this.template.version;
1912
1913
  const sv = await this.ensureStateVault();
1913
1914
  const base = { vaultId, group: this.name, currentVersion: row.schemaVersion, targetVersion: target };
@@ -1990,7 +1991,7 @@ var init_vault_group = __esm({
1990
1991
  let vault;
1991
1992
  if (!row) {
1992
1993
  if (this.group.sharding.autoCreate === false) {
1993
- throw new import_kernel11.UnknownShardError(key, this.group.name);
1994
+ throw new import_cargo14.UnknownShardError(key, this.group.name);
1994
1995
  }
1995
1996
  vault = await this.group.createShard(key, this.group.sharding.regionOf?.(record));
1996
1997
  } else {
@@ -2073,7 +2074,7 @@ var init_vault_group = __esm({
2073
2074
  this.group.template.configure(probe);
2074
2075
  for (const leg of this.coPartitionedLegs) {
2075
2076
  if (!probe.resolveRef(this.collectionName, leg.field)) {
2076
- throw new import_kernel11.CrossShardJoinError(
2077
+ throw new import_cargo14.CrossShardJoinError(
2077
2078
  `crossShardJoin("${leg.field}"): no ref() declared for "${leg.field}" on collection "${this.collectionName}" in template "${this.group.sharding.vaultTemplate}". Add refs: { ${leg.field}: ref('<target>') } to the template's collection options.`
2078
2079
  );
2079
2080
  }
@@ -2238,10 +2239,10 @@ var init_vault_group = __esm({
2238
2239
  // src/index.ts
2239
2240
  var index_exports = {};
2240
2241
  __export(index_exports, {
2241
- CrossShardJoinError: () => import_kernel13.CrossShardJoinError,
2242
+ CrossShardJoinError: () => import_cargo16.CrossShardJoinError,
2242
2243
  CrossVaultDanglingRefError: () => CrossVaultDanglingRefError,
2243
- CustodyApi: () => import_hub6.CustodyApi,
2244
- DataResidencyError: () => import_kernel13.DataResidencyError,
2244
+ CustodyApi: () => import_cargo17.CustodyApi,
2245
+ DataResidencyError: () => import_cargo16.DataResidencyError,
2245
2246
  DockedUnit: () => DockedUnit,
2246
2247
  FieldAuthorityPolicyMissingError: () => FieldAuthorityPolicyMissingError,
2247
2248
  FieldLevelDeferredError: () => FieldLevelDeferredError,
@@ -2252,17 +2253,17 @@ __export(index_exports, {
2252
2253
  NOYDB_MULTI_BUNDLE_MAGIC: () => NOYDB_MULTI_BUNDLE_MAGIC,
2253
2254
  NOYDB_MULTI_BUNDLE_PREFIX_BYTES: () => NOYDB_MULTI_BUNDLE_PREFIX_BYTES,
2254
2255
  NOYDB_MULTI_BUNDLE_VERSION: () => NOYDB_MULTI_BUNDLE_VERSION,
2255
- ReservedVaultNameError: () => import_kernel13.ReservedVaultNameError,
2256
- ShardProvisioningError: () => import_kernel13.ShardProvisioningError,
2256
+ ReservedVaultNameError: () => import_cargo16.ReservedVaultNameError,
2257
+ ShardProvisioningError: () => import_cargo16.ShardProvisioningError,
2257
2258
  SurfaceCadenceScheduler: () => SurfaceCadenceScheduler,
2258
2259
  SurfaceNotFoundError: () => SurfaceNotFoundError,
2259
2260
  SurfaceStateError: () => SurfaceStateError,
2260
2261
  UnitGraduationError: () => UnitGraduationError,
2261
- UnknownShardError: () => import_kernel13.UnknownShardError,
2262
- VaultTemplateNotFoundError: () => import_kernel13.VaultTemplateNotFoundError,
2262
+ UnknownShardError: () => import_cargo16.UnknownShardError,
2263
+ VaultTemplateNotFoundError: () => import_cargo16.VaultTemplateNotFoundError,
2263
2264
  agreeSurface: () => agreeSurface,
2264
2265
  applySurface: () => applySurface,
2265
- createDeedOwner: () => import_hub6.createDeedOwner,
2266
+ createDeedOwner: () => import_cargo17.createDeedOwner,
2266
2267
  createLobby: () => createLobby,
2267
2268
  decodeMultiBundle: () => decodeMultiBundle,
2268
2269
  describeCrossVaultExtraction: () => describeCrossVaultExtraction,
@@ -2270,11 +2271,11 @@ __export(index_exports, {
2270
2271
  exportSurface: () => exportSurface,
2271
2272
  extractCrossVaultPartition: () => extractCrossVaultPartition,
2272
2273
  groupInspector: () => groupInspector,
2273
- isDeedVault: () => import_hub6.isDeedVault,
2274
+ isDeedVault: () => import_cargo17.isDeedVault,
2274
2275
  isSurfaceDue: () => isSurfaceDue,
2275
- liberateVault: () => import_hub6.liberateVault,
2276
+ liberateVault: () => import_cargo17.liberateVault,
2276
2277
  listDueSurfaces: () => listDueSurfaces,
2277
- loadDeedMarker: () => import_hub6.loadDeedMarker,
2278
+ loadDeedMarker: () => import_cargo17.loadDeedMarker,
2278
2279
  markSynced: () => markSynced,
2279
2280
  mergeCompartment: () => mergeCompartment,
2280
2281
  mergeDecryptedRecords: () => mergeDecryptedRecords,
@@ -2289,8 +2290,7 @@ __export(index_exports, {
2289
2290
  writeMultiVaultBundle: () => writeMultiVaultBundle
2290
2291
  });
2291
2292
  module.exports = __toCommonJS(index_exports);
2292
- var import_kernel12 = require("@noy-db/hub/kernel");
2293
- var import_hub5 = require("@noy-db/hub");
2293
+ var import_cargo15 = require("@noy-db/hub/cargo");
2294
2294
 
2295
2295
  // src/dock/docked-unit.ts
2296
2296
  var DockedUnit = class {
@@ -2372,13 +2372,13 @@ async function meterGroup(group, opts = {}) {
2372
2372
  }
2373
2373
 
2374
2374
  // src/index.ts
2375
- var import_kernel13 = require("@noy-db/hub/kernel");
2375
+ var import_cargo16 = require("@noy-db/hub/cargo");
2376
2376
  init_multi_bundle();
2377
2377
  init_extract_cross_vault();
2378
2378
  init_merge_compartment();
2379
2379
 
2380
2380
  // src/interchange/migrate-then-merge.ts
2381
- var import_bundle4 = require("@noy-db/hub/bundle");
2381
+ var import_bundle3 = require("@noy-db/hub/bundle");
2382
2382
  init_merge_compartment();
2383
2383
  init_stage_records();
2384
2384
  init_stage_records();
@@ -2403,7 +2403,7 @@ async function migrateThenMerge(receiver, compartmentBytes, opts) {
2403
2403
  );
2404
2404
  }
2405
2405
  if (fromVersion > toVersion) throw new MinVersionError(fromVersion, toVersion);
2406
- const incoming = await (0, import_bundle4.decryptExtractedPartition)(compartmentBytes, opts.transferKey);
2406
+ const incoming = await (0, import_bundle3.decryptExtractedPartition)(compartmentBytes, opts.transferKey);
2407
2407
  const transformsByCollection = {};
2408
2408
  const migrationByCollection = {};
2409
2409
  for (const [coll, recs] of Object.entries(incoming)) {
@@ -2426,7 +2426,7 @@ async function migrateThenMerge(receiver, compartmentBytes, opts) {
2426
2426
 
2427
2427
  // src/index.ts
2428
2428
  init_field_authority();
2429
- var import_hub6 = require("@noy-db/hub");
2429
+ var import_cargo17 = require("@noy-db/hub/cargo");
2430
2430
 
2431
2431
  // src/dock/unit-driver.ts
2432
2432
  var InMemoryUnitDriver = class {
@@ -2460,10 +2460,10 @@ var Lobby = class {
2460
2460
  }
2461
2461
  async openVaultGroup(name, opts) {
2462
2462
  const db = this.noydb;
2463
- if (db.isClosed) throw new import_kernel12.ValidationError("Instance is closed");
2464
- if (name === import_hub5.STATE_VAULT_NAME) throw new import_kernel12.ReservedVaultNameError(name);
2463
+ if (db.isClosed) throw new import_cargo15.ValidationError("Instance is closed");
2464
+ if (name === import_cargo15.STATE_VAULT_NAME) throw new import_cargo15.ReservedVaultNameError(name);
2465
2465
  const template = this.vaultTemplates.get(opts.sharding.vaultTemplate);
2466
- if (!template) throw new import_kernel12.VaultTemplateNotFoundError(opts.sharding.vaultTemplate);
2466
+ if (!template) throw new import_cargo15.VaultTemplateNotFoundError(opts.sharding.vaultTemplate);
2467
2467
  const { VaultGroup: VaultGroup2 } = await Promise.resolve().then(() => (init_vault_group(), vault_group_exports));
2468
2468
  const { StateManagementVault: StateManagementVault2 } = await Promise.resolve().then(() => (init_state_vault(), state_vault_exports));
2469
2469
  const stateVault = opts.registry ? void 0 : await StateManagementVault2.open(db);
@@ -2482,7 +2482,7 @@ var Lobby = class {
2482
2482
  }
2483
2483
  async openStateManagementVault() {
2484
2484
  const db = this.noydb;
2485
- if (db.isClosed) throw new import_kernel12.ValidationError("Instance is closed");
2485
+ if (db.isClosed) throw new import_cargo15.ValidationError("Instance is closed");
2486
2486
  const { StateManagementVault: StateManagementVault2 } = await Promise.resolve().then(() => (init_state_vault(), state_vault_exports));
2487
2487
  return StateManagementVault2.open(db);
2488
2488
  }