@githolon/runtime 0.115.0 → 0.116.4

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.
@@ -7879,8 +7879,10 @@
7879
7879
  var SignOfferPreparationRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 37);
7880
7880
  var SigningIdentityRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 39);
7881
7881
  var KernelRefusalSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 55);
7882
+ var QueryResponseSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 56);
7882
7883
  var ApplicationResultDeltaSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 58);
7883
7884
  var InterfaceCompatibilityQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 60);
7885
+ var ReadIndexPendingSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 64);
7884
7886
  var MaintenanceQuantumQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 65);
7885
7887
  var CarriedWorkspaceOfferSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 80);
7886
7888
  var PrepareOutboundOfferSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 84);
@@ -8158,32 +8160,44 @@
8158
8160
  // ../../platform-shells/browser/runtime_fetch.ts
8159
8161
  init_define_NOMOS_KERNEL_RELEASE();
8160
8162
  init_shims();
8161
- function browserRuntimeFetch(base, fetchImpl, caches, repositoryUrl) {
8163
+
8164
+ // ../../platform-shells/shared/retained_boot_fetch.ts
8165
+ init_define_NOMOS_KERNEL_RELEASE();
8166
+ init_shims();
8167
+ function retainedBootFetch(base, fetchImpl, store, repositoryUrl) {
8162
8168
  const root = base.replace(/\/+$/, "");
8163
8169
  return async (input, init) => {
8164
8170
  const url = String(input);
8165
8171
  const bootArtifact = url === (repositoryUrl ?? `${root}/v1/runtime/repository.xml`) || url === `${root}/v1/runtime/nomos.law.usdz`;
8166
8172
  if (!bootArtifact) return fetchImpl(input, init);
8167
- const networkInit = {
8168
- ...init,
8169
- cache: "no-store",
8170
- signal: init?.signal ?? AbortSignal.timeout(15e3)
8171
- };
8172
- if (!caches) return fetchImpl(input, networkInit);
8173
- const cache = await caches.open("nomos-browser-boot-v1");
8173
+ const networkInit = { ...init, cache: "no-store", signal: init?.signal ?? AbortSignal.timeout(15e3) };
8174
+ if (!store) return fetchImpl(input, networkInit);
8174
8175
  let response;
8176
+ let failure;
8175
8177
  try {
8176
8178
  response = await fetchImpl(input, networkInit);
8177
8179
  } catch (error) {
8178
- const retained = await cache.match(url);
8179
- if (retained) return retained;
8180
- throw error;
8180
+ failure = error;
8181
8181
  }
8182
- if (response.ok) await cache.put(url, response.clone());
8183
- return response;
8182
+ if (response !== void 0 && response.status < 500) {
8183
+ if (response.ok) await store.put(url, response.clone());
8184
+ return response;
8185
+ }
8186
+ const retained = await store.match(url);
8187
+ if (retained) return retained;
8188
+ if (response !== void 0) return response;
8189
+ throw failure;
8184
8190
  };
8185
8191
  }
8186
8192
 
8193
+ // ../../platform-shells/browser/runtime_fetch.ts
8194
+ function browserRuntimeFetch(base, fetchImpl, caches, repositoryUrl) {
8195
+ return retainedBootFetch(base, fetchImpl, caches === void 0 ? void 0 : {
8196
+ match: async (url) => (await caches.open("nomos-browser-boot-v1")).match(url),
8197
+ put: async (url, response) => (await caches.open("nomos-browser-boot-v1")).put(url, response)
8198
+ }, repositoryUrl);
8199
+ }
8200
+
8187
8201
  // ../../adapter/proto/nomos/runtime/v2/runtime_pb.js
8188
8202
  init_define_NOMOS_KERNEL_RELEASE();
8189
8203
  init_shims();
@@ -8324,7 +8338,7 @@
8324
8338
  var CustodyBreakPolicy = /* @__PURE__ */ tsEnum(CustodyBreakPolicySchema);
8325
8339
 
8326
8340
  // ../../adapter/proto/nomos/runtime/v2/observability_desk_pb.js
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QABIUChBMSU5LX1NUQVRVU19PUEVOEAESFgoSTElOS19TVEFUVVNfQ0xPU0VEEAIqdgoMVHJhbnNmZXJLaW5kEh0KGVRSQU5TRkVSX0tJTkRfVU5TUEVDSUZJRUQQABIXChNUUkFOU0ZFUl9LSU5EX0RFTFRBEAESFgoSVFJBTlNGRVJfS0lORF9GVUxMEAISFgoSVFJBTlNGRVJfS0lORF9QVVNIEANiBnByb3RvMw", [file_google_protobuf_any, file_nomos_kernel_v1_kernel, file_nomos_kernel_v1_progress, file_nomos_runtime_v2_correspondence_desk, file_nomos_runtime_v2_custody_desk, file_nomos_runtime_v2_placement_desk, file_nomos_runtime_v2_maintenance_desk, file_nomos_runtime_v2_model_adoption_desk, file_nomos_runtime_v2_receiving_group_desk, file_nomos_runtime_v2_recovery_desk]);
8341
+ var file_nomos_runtime_v2_observability_desk = /* @__PURE__ */ fileDesc("Cilub21vcy9ydW50aW1lL3YyL29ic2VydmFiaWxpdHlfZGVzay5wcm90bxIQbm9tb3MucnVudGltZS52MiJCCgxUcmFjZUNvbnRleHQSEAoIdHJhY2VfaWQYASABKAwSDwoHc3Bhbl9pZBgCIAEoDBIPCgdzYW1wbGVkGAMgASgIIp0CCg5SdW50aW1lRmFpbHVyZRIMCgRjb2RlGAEgASgJEg8KB21lc3NhZ2UYAiABKAkSEQoJY29tcG9uZW50GAMgASgJEhYKCXdvcmtzcGFjZRgEIAEoCUgAiAEBEhMKBmRvbWFpbhgFIAEoCUgBiAEBEhYKCWRpcmVjdGl2ZRgGIAEoCUgCiAEBEjkKCmF0dHJpYnV0ZXMYByADKAsyJS5ub21vcy5ydW50aW1lLnYyLkRpYWdub3N0aWNBdHRyaWJ1dGUSMgoEa2luZBgIIAEoDjIkLm5vbW9zLnJ1bnRpbWUudjIuUnVudGltZUZhaWx1cmVLaW5kQgwKCl93b3Jrc3BhY2VCCQoHX2RvbWFpbkIMCgpfZGlyZWN0aXZlIr4BChJSdW50aW1lVW5hdmFpbGFibGUSOgoGcmV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HX0RFUEVOREVOQ1kQBRIkCiBGT0xMT1dfT0JTRVJWQVRJT05fUEhBU0VfT0ZGTElORRAGEi8KK0ZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9JTlZBTElEX0NSRURFTlRJQUwQBxIkCiBGT0xMT1dfT0JTRVJWQVRJT05fUEhBU0VfQkFDS09GRhAIEiwKKEZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9SRUJPUk5fUkVNT1RFTFkQCRIsCihGT0xMT1dfT0JTRVJWQVRJT05fUEhBU0VfUkVQTEFDSU5HX0xPQ0FMEAoSMgouRk9MTE9XX09CU0VSVkFUSU9OX1BIQVNFX0xPQ0FMX0NPUFlfVU5SRUFEQUJMRRALEisKJ0ZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9LRVJORUxfUkVGVVNFRBAMKlcKCkxpbmtTdGF0dXMSGwoXTElOS19TVEFUVVNfVU5TUEVDSUZJRUQQABIUChBMSU5LX1NUQVRVU19PUEVOEAESFgoSTElOS19TVEFUVVNfQ0xPU0VEEAIqdgoMVHJhbnNmZXJLaW5kEh0KGVRSQU5TRkVSX0tJTkRfVU5TUEVDSUZJRUQQABIXChNUUkFOU0ZFUl9LSU5EX0RFTFRBEAESFgoSVFJBTlNGRVJfS0lORF9GVUxMEAISFgoSVFJBTlNGRVJfS0lORF9QVVNIEANiBnByb3RvMw", [file_google_protobuf_any, file_nomos_kernel_v1_kernel, file_nomos_kernel_v1_progress, file_nomos_runtime_v2_correspondence_desk, file_nomos_runtime_v2_custody_desk, file_nomos_runtime_v2_placement_desk, file_nomos_runtime_v2_maintenance_desk, file_nomos_runtime_v2_model_adoption_desk, file_nomos_runtime_v2_receiving_group_desk, file_nomos_runtime_v2_recovery_desk]);
8328
8342
  var RuntimeFailureSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 1);
8329
8343
  var RuntimeUnavailableSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 2);
8330
8344
  var RuntimeRefusalSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 3);
@@ -11896,6 +11910,11 @@
11896
11910
  if (!READINESS_DEBT.test(message)) return void 0;
11897
11911
  return new KernelReadinessPending(/source workspace '([^']+)'/.exec(message)?.[1]?.trim(), message);
11898
11912
  };
11913
+ var READ_INDEX_BUILDING = /the read index of (.+?) is (?:being built \(\d+ of \d+ documents\)|built \(\d+ documents\) and is being bound); read maintenance (?:continues|finishes) it/;
11914
+ var kernelReadIndexBuilding = (message) => {
11915
+ const workspace = READ_INDEX_BUILDING.exec(message)?.[1]?.trim();
11916
+ return workspace === void 0 ? void 0 : { workspace };
11917
+ };
11899
11918
  var requiredForeignWorkspace = (message) => {
11900
11919
  const patterns = [
11901
11920
  /workspace '([^']+)' must be resident in the kernel/,
@@ -11919,9 +11938,31 @@
11919
11938
  throw new KernelWorkspaceResidencyRequired(workspace, failure.message);
11920
11939
  }
11921
11940
  }
11941
+ var KernelRefusal = class extends Error {
11942
+ constructor(failure) {
11943
+ super(`${failure.code}: ${failure.message}`);
11944
+ __publicField(this, "code");
11945
+ __publicField(this, "failure");
11946
+ this.name = "KernelRefusal";
11947
+ this.code = failure.code;
11948
+ this.failure = failure;
11949
+ }
11950
+ };
11922
11951
  function throwKernelFailure(failure) {
11923
11952
  throwIfKernelControlRequired(failure);
11924
- throw new Error(`${failure.code}: ${failure.message}`);
11953
+ throw new KernelRefusal(failure);
11954
+ }
11955
+ var KERNEL_FAILURE_TEXT = /^(NMS-[A-Z0-9]+(?:-[A-Z0-9]+)*): ([\s\S]*)$/;
11956
+ var ENVIRONMENTAL = /NMS-KERNEL-TRAP|\btrap\b|unreachable|out of bounds|out of memory|memory allocation|\block\b|File exists|No such file|os error|I\/O|Permission denied|No space|\bE(?:EXIST|NOENT|ACCES|NOSPC|IO|AGAIN|BUSY)\b/i;
11957
+ function deterministicKernelRefusal(error) {
11958
+ if (error instanceof KernelWorkspaceResidencyRequired || error instanceof KernelHistoryRequired || error instanceof KernelReadinessPending) return void 0;
11959
+ if (error instanceof KernelRefusal && (error.failure.historyRequired !== void 0 || error.failure.identityProviderWitnessRequired !== void 0)) return void 0;
11960
+ const text = error instanceof Error ? error.message : typeof error === "string" ? error : "";
11961
+ const match = KERNEL_FAILURE_TEXT.exec(text);
11962
+ if (!match) return void 0;
11963
+ const [, code, message] = match;
11964
+ if (ENVIRONMENTAL.test(text) || READINESS_DEBT.test(message) || requiredForeignWorkspace(message) !== void 0) return void 0;
11965
+ return { code, message };
11925
11966
  }
11926
11967
  function rethrowTypedKernelFailure(error) {
11927
11968
  if (error instanceof KernelWorkspaceResidencyRequired || error instanceof KernelHistoryRequired) throw error;
@@ -15284,8 +15325,9 @@
15284
15325
 
15285
15326
  // ../src/runtime/live_inbound_stream.ts
15286
15327
  var LEVEL_BATCH = "level:";
15328
+ var HISTORY_REQUIRED = "nomos.stream.history_required";
15329
+ var CONTAINMENT_ASK_SUFFIX = ":contain";
15287
15330
  var STREAM_WINDOW_CHUNKS = 8;
15288
- var ASK_AGAIN_NANOS = 15000000000n;
15289
15331
  var historySlot = (workspace) => `${workspace}#history`;
15290
15332
  var _ports, _staging, _by, _LiveInboundStream_instances, of_fn, refusalReceipt_fn, offered_fn, completed_fn, askHistory_fn, sliceOffered_fn, sliceChunk_fn, askCheckpoint_fn, askLevel_fn;
15291
15333
  var LiveInboundStream = class {
@@ -15297,7 +15339,10 @@
15297
15339
  __privateSet(this, _ports, ports);
15298
15340
  __privateSet(this, _staging, ports.staging ?? memoryCheckpointStaging());
15299
15341
  }
15300
- /** When this workspace's stream last delivered anything (a waiting procedure is progressing). */
15342
+ /** When this workspace's stream last delivered data to an ask (a waiting procedure is progressing).
15343
+ * A refusal, a frontier, unrelated traffic on the socket and this copy's own re-asking are not
15344
+ * progress: a procedure whose stream only ever says "ask again" gives up and its round fails over
15345
+ * (CAP-838). */
15301
15346
  lastHeard(workspace) {
15302
15347
  return __privateGet(this, _by).get(workspace)?.lastHeard;
15303
15348
  }
@@ -15320,7 +15365,8 @@
15320
15365
  inbound.wants.level = {
15321
15366
  effectId: effect.effectId,
15322
15367
  maxOffers: Math.max(1, request.value.maxOffers),
15323
- remountAfterOffers: request.value.remountAfterOffers
15368
+ remountAfterOffers: request.value.remountAfterOffers,
15369
+ contain: effect.effectId.endsWith(CONTAINMENT_ASK_SUFFIX)
15324
15370
  };
15325
15371
  __privateMethod(this, _LiveInboundStream_instances, askLevel_fn).call(this, effect.workspace, inbound);
15326
15372
  }
@@ -15380,7 +15426,7 @@
15380
15426
  const batch = inbound.levelBatch;
15381
15427
  if (batch) {
15382
15428
  inbound.levelBatch = void 0;
15383
- if (batch.base === __privateGet(this, _ports).head(effect.workspace)) {
15429
+ if (batch.base === __privateGet(this, _ports).head(effect.workspace) || batch.base === request.value.head) {
15384
15430
  inbound.wants.level = void 0;
15385
15431
  return create(PeerStreamReceiptSchema, {
15386
15432
  outcome: { case: "pack", value: batch },
@@ -15391,14 +15437,14 @@
15391
15437
  __privateMethod(this, _LiveInboundStream_instances, askLevel_fn).call(this, effect.workspace, inbound);
15392
15438
  }
15393
15439
  const head = __privateGet(this, _ports).head(effect.workspace);
15394
- if (head && inbound.announced && head === inbound.announced) {
15440
+ if (inbound.announced && (head === inbound.announced || inbound.askedFrom === inbound.announced)) {
15395
15441
  inbound.wants.level = void 0;
15396
15442
  return create(PeerStreamReceiptSchema, {
15397
- outcome: { case: "level", value: head },
15443
+ outcome: { case: "level", value: inbound.announced },
15398
15444
  ...inbound.sealed ? { sealed: inbound.sealed } : {}
15399
15445
  });
15400
15446
  }
15401
- return __privateMethod(this, _LiveInboundStream_instances, refusalReceipt_fn).call(this, inbound);
15447
+ return __privateMethod(this, _LiveInboundStream_instances, refusalReceipt_fn).call(this, inbound, inbound.wants.level?.effectId === effect.effectId && inbound.wants.level.contain);
15402
15448
  }
15403
15449
  if (request.case === "history" || request.case === "ref") {
15404
15450
  const want = inbound.wants.packs.get(request.value.requestId);
@@ -15440,7 +15486,9 @@
15440
15486
  /** One frame from the peer. True when it was the stream's (the live desk handles the rest). */
15441
15487
  frame(workspace, message) {
15442
15488
  const inbound = __privateMethod(this, _LiveInboundStream_instances, of_fn).call(this, workspace);
15443
- inbound.lastHeard = __privateGet(this, _ports).monotonicNanoseconds();
15489
+ if (message.case === "checkpointOffer" || message.case === "checkpointChunk" || message.case === "pack") {
15490
+ inbound.lastHeard = __privateGet(this, _ports).monotonicNanoseconds();
15491
+ }
15444
15492
  switch (message.case) {
15445
15493
  case "frontier":
15446
15494
  if (message.value.response && message.value.head) {
@@ -15495,18 +15543,26 @@
15495
15543
  return false;
15496
15544
  }
15497
15545
  }
15498
- /** Re-ask what is due: a refusal's retry time passed, or an ask heard nothing for too long. */
15546
+ /**
15547
+ * Ask again when a refusal said when to (the peer was opening, or acquiring history). Nothing else
15548
+ * here runs on a timer (CAP-838): the socket is ordered and reliable, every ask is answered on it,
15549
+ * and an ask is re-sent only when its socket re-opens (`opened`) or its refusal's time comes. The
15550
+ * stream used to re-ask whatever had heard nothing for 15 s, and that resend - itself counted as
15551
+ * hearing - hid an ask answered "come back" for ever.
15552
+ */
15499
15553
  drive(workspace) {
15500
15554
  const inbound = __privateGet(this, _by).get(workspace);
15501
- if (!inbound || !this.wanted(workspace)) return void 0;
15555
+ if (!inbound || inbound.askAgainAt === void 0) return void 0;
15556
+ if (!this.wanted(workspace)) {
15557
+ inbound.askAgainAt = void 0;
15558
+ return void 0;
15559
+ }
15502
15560
  const now2 = __privateGet(this, _ports).monotonicNanoseconds();
15503
- const due2 = inbound.askAgainAt ?? inbound.lastHeard + ASK_AGAIN_NANOS;
15504
- if (now2 < due2) return due2 - now2;
15561
+ if (now2 < inbound.askAgainAt) return inbound.askAgainAt - now2;
15505
15562
  inbound.askAgainAt = void 0;
15506
15563
  inbound.refused = void 0;
15507
- inbound.lastHeard = now2;
15508
15564
  this.opened(workspace);
15509
- return ASK_AGAIN_NANOS;
15565
+ return void 0;
15510
15566
  }
15511
15567
  };
15512
15568
  _ports = new WeakMap();
@@ -15522,10 +15578,16 @@
15522
15578
  return inbound;
15523
15579
  };
15524
15580
  /** A terminal refusal (not one that only says when to ask again) ends the procedure's wait. */
15525
- refusalReceipt_fn = function(inbound) {
15581
+ refusalReceipt_fn = function(inbound, contain = false) {
15526
15582
  const refused = inbound.refused;
15527
- if (!refused || refused.retryAfterMillis !== void 0) return void 0;
15583
+ if (!refused) return void 0;
15584
+ const answersContainment = contain && refused.code === HISTORY_REQUIRED;
15585
+ if (refused.retryAfterMillis !== void 0 && !answersContainment) return void 0;
15528
15586
  inbound.refused = void 0;
15587
+ if (answersContainment) {
15588
+ inbound.askAgainAt = void 0;
15589
+ inbound.wants.level = void 0;
15590
+ }
15529
15591
  return create(PeerStreamReceiptSchema, { outcome: { case: "refusal", value: refused } });
15530
15592
  };
15531
15593
  offered_fn = function(workspace, inbound, offer) {
@@ -15569,6 +15631,7 @@
15569
15631
  const held = !taken ? -1 : "pack" in taken ? taken.pack.byteLength : taken.bytes;
15570
15632
  if (held !== transfer.bytes || transfer.received !== transfer.bytes) {
15571
15633
  if (taken && "stagedPackFile" in taken) __privateGet(this, _staging).clear(workspace);
15634
+ if (inbound.wants.checkpoint) __privateMethod(this, _LiveInboundStream_instances, askCheckpoint_fn).call(this, workspace, inbound);
15572
15635
  return;
15573
15636
  }
15574
15637
  inbound.complete = {
@@ -15686,8 +15749,12 @@
15686
15749
  __privateMethod(this, _LiveInboundStream_instances, askCheckpoint_fn).call(this, workspace, inbound);
15687
15750
  return;
15688
15751
  }
15752
+ inbound.announced = void 0;
15753
+ inbound.sealed = void 0;
15754
+ const head = __privateGet(this, _ports).head(workspace) ?? "";
15755
+ inbound.askedFrom = head;
15689
15756
  __privateGet(this, _ports).send(workspace, { case: "frontier", value: create(LiveFrontierSchema, {
15690
- head: __privateGet(this, _ports).head(workspace) ?? "",
15757
+ head,
15691
15758
  response: false,
15692
15759
  maxOffers: level.maxOffers,
15693
15760
  remountAfterOffers: level.remountAfterOffers,
@@ -16222,6 +16289,24 @@
16222
16289
  return void 0;
16223
16290
  }
16224
16291
  var PLACEMENT_REFERENCE = "refs/nomos/placement";
16292
+ function readIndexPendingAnswer(request, message) {
16293
+ if (request.operation.case !== "query" || request.operation.value.query.case === "maintenanceQuantum") return void 0;
16294
+ const building = kernelReadIndexBuilding(message);
16295
+ if (building === void 0) return void 0;
16296
+ const target3 = request.operation.value.target;
16297
+ return create(CallResponseSchema, {
16298
+ protocolVersion: request.protocolVersion,
16299
+ requestId: request.requestId,
16300
+ outcome: { case: "query", value: create(QueryResponseSchema, {
16301
+ result: { case: "readIndexPending", value: create(ReadIndexPendingSchema, {
16302
+ workspace: target3?.workspace || building.workspace,
16303
+ branch: target3?.branch ?? "",
16304
+ // The sliced build names no frontier: it restarts at whatever head main holds when it continues.
16305
+ requestedFrontier: ""
16306
+ }) }
16307
+ }) }
16308
+ });
16309
+ }
16225
16310
  var _kernel, _activeOperation, _signingSequence, _releaseSequence, _onWorkspaceUse, _onPlacementMoved, _attached, _residency, _KernelPort_instances, mount_fn, custodyCall_fn, call_fn, timedCall_fn, exclusive_fn;
16226
16311
  var KernelPort = class {
16227
16312
  /** `onPlacementMoved` hears of every placement frontier this port sees move: an admitted
@@ -17243,6 +17328,8 @@
17243
17328
  const nested = request.operation.case === "custody" ? request.operation.value.operation.case ?? "empty" : request.operation.case === "query" ? request.operation.value.query.case === "named" ? `named:${request.operation.value.query.value.operation}` : request.operation.value.query.case ?? "empty" : "";
17244
17329
  error.message = `kernel-operation=${top}/${nested}: ${error.message}`;
17245
17330
  }
17331
+ const pending = readIndexPendingAnswer(request, error instanceof Error ? error.message : String(error));
17332
+ if (pending !== void 0) return pending;
17246
17333
  rethrowTypedKernelFailure(error);
17247
17334
  }
17248
17335
  if (response.requestId !== request.requestId) {
@@ -17253,6 +17340,9 @@
17253
17340
  __privateGet(this, _residency).after(request, response);
17254
17341
  const placementMoved = placementMovedBy(request, response);
17255
17342
  if (placementMoved !== void 0) __privateGet(this, _onPlacementMoved).call(this, placementMoved);
17343
+ if (response.outcome.case === "failure") {
17344
+ return readIndexPendingAnswer(request, response.outcome.value.message) ?? response;
17345
+ }
17256
17346
  return response;
17257
17347
  };
17258
17348
  /** [#call] with the opt-in timeline trace: encode, kernel and decode timed separately. */
@@ -23830,7 +23920,7 @@
23830
23920
  var DURABILITY_FLUSH_MAX_DELAY_NANOSECONDS = LOCAL_WRITE_STALENESS_CAP_NANOSECONDS;
23831
23921
  var CUSTODY_PACKING_PAUSE_NANOSECONDS = 1500000000n;
23832
23922
  var CUSTODY_BURST_SLICE_INTERVAL_NANOSECONDS = 250000000n;
23833
- var _queries3, _sessions5, _trace6, _observer, _clock7, _pending, _pins, _deferredDurability, _burst, _ownsBurst, _loosePressure, _lastBurstSliceNanoseconds, _flush, _sequence8, _revision3, _ReadMaintenanceDesk_instances, schedule_fn, oweFlush_fn, notePressure_fn, flushDueAt_fn, custodyBurstSlice_fn, tickFlush_fn, tickPin_fn, nextDelay_fn;
23923
+ var _queries3, _sessions5, _trace6, _observer, _clock7, _pending, _pins, _deferredDurability, _burst, _ownsBurst, _loosePressure, _lastBurstSliceNanoseconds, _flush, _sequence8, _revision3, _ReadMaintenanceDesk_instances, schedule_fn, turn_fn, oweFlush_fn, notePressure_fn, flushDueAt_fn, custodyBurstSlice_fn, tickFlush_fn, tickPin_fn, nextDelay_fn;
23834
23924
  var ReadMaintenanceDesk = class {
23835
23925
  constructor(queries, sessions, trace, clock2, observer = {}, deferredDurability = false, writeBurst) {
23836
23926
  __privateAdd(this, _ReadMaintenanceDesk_instances);
@@ -23925,188 +24015,26 @@
23925
24015
  * (a waiting read's own turn advances read readiness only).
23926
24016
  */
23927
24017
  tick(request, sessionlessNotBeforeNanoseconds = 0n, backgroundNotBeforeNanoseconds = 0n, durability = true) {
23928
- const now2 = __privateGet(this, _clock7).monotonicNanoseconds();
23929
- const custodySlice = (workspace2) => __privateMethod(this, _ReadMaintenanceDesk_instances, custodyBurstSlice_fn).call(this, now2, workspace2);
23930
- const due2 = (demand2) => {
23931
- const held = demand2.session || demand2.awaited || demand2.retryNotBeforeNanoseconds > sessionlessNotBeforeNanoseconds ? demand2.retryNotBeforeNanoseconds : sessionlessNotBeforeNanoseconds;
23932
- const ordinary = demand2.read || demand2.awaited || held > backgroundNotBeforeNanoseconds ? held : backgroundNotBeforeNanoseconds;
23933
- const hold = demand2.read || demand2.awaited || !demand2.background?.maintainGitCustody ? void 0 : custodySlice(demand2.workspace);
23934
- if (!hold) return ordinary;
23935
- if (hold.slice && durability) return held > hold.at ? held : hold.at;
23936
- return ordinary > hold.at ? ordinary : hold.at;
23937
- };
23938
- const entry = [...__privateGet(this, _pending).entries()].find(([, demand2]) => due2(demand2) <= now2);
23939
- const flush = __privateGet(this, _flush);
23940
- if (durability && flush && __privateMethod(this, _ReadMaintenanceDesk_instances, flushDueAt_fn).call(this, flush) <= now2 && !entry?.[1].read && (flush.local || !entry || flush.owedSinceNanoseconds + DURABILITY_FLUSH_MAX_DELAY_NANOSECONDS <= now2)) {
23941
- return __privateMethod(this, _ReadMaintenanceDesk_instances, tickFlush_fn).call(this, flush, request);
23942
- }
23943
- const pinDue = (pin) => {
23944
- const held = pin.session ? 0n : sessionlessNotBeforeNanoseconds;
23945
- return [pin.notBeforeNanoseconds, held, backgroundNotBeforeNanoseconds].reduce((latest, at) => at > latest ? at : latest, 0n);
23946
- };
23947
- if (!entry) {
23948
- const pin = [...__privateGet(this, _pins).entries()].find(([, idle]) => pinDue(idle) <= now2);
23949
- if (pin) return __privateMethod(this, _ReadMaintenanceDesk_instances, tickPin_fn).call(this, pin[0], pin[1], request);
23950
- return create(MaintenanceTickedSchema, {
23951
- pending: this.hasPending(),
23952
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, now2, due2, pinDue)
23953
- });
23954
- }
23955
- const [workspace, demand] = entry;
23956
- const mount = demand.session ? __privateGet(this, _sessions5).mountForSession(demand.session) : __privateGet(this, _sessions5).mountForWorkspace(workspace);
23957
- const read = demand.read;
23958
- const activeCause = read?.cause ?? demand.background?.cause;
23959
- if (activeCause === void 0) {
23960
- throw new Error(`maintenance demand for '${workspace}' has no work`);
23961
- }
23962
- const command = read ? void 0 : demand.background?.command;
23963
- const burstSlice = read === void 0 && demand.background?.maintainGitCustody === true && durability && custodySlice(workspace)?.slice === true;
23964
- const synthetic = request ?? create(RuntimeRequestSchema, {
23965
- protocolVersion: 2,
23966
- requestId: ++__privateWrapper(this, _sequence8)._
24018
+ const turn = __privateMethod(this, _ReadMaintenanceDesk_instances, turn_fn).call(this, request, sessionlessNotBeforeNanoseconds, { case: "until", atNanoseconds: backgroundNotBeforeNanoseconds }, durability);
24019
+ return turn.case === "ran" ? turn.ticked : create(MaintenanceTickedSchema, {
24020
+ pending: turn.pending,
24021
+ nextTickAfterMillis: turn.nextDelayMillis ?? 0
23967
24022
  });
23968
- try {
23969
- const progress = __privateGet(this, _trace6).measure(
23970
- "peer.read-maintenance.quantum",
23971
- { request: synthetic, ...demand.session ? { session: demand.session } : {}, workspace },
23972
- {
23973
- "maintenance.cause": ReadMaintenanceCause[activeCause],
23974
- ...command ? {
23975
- "maintenance.domain": command.domain,
23976
- "maintenance.package": command.packageHash,
23977
- ...command.directive ? { "maintenance.directive": command.directive } : {}
23978
- } : {}
23979
- },
23980
- () => __privateGet(this, _queries3).maintenanceQuantum(demand.session ?? "", mount, synthetic.requestId, {
23981
- ...command?.domain === void 0 ? {} : { requestedDomain: command.domain },
23982
- ...command?.packageHash === void 0 ? {} : { requestedPackage: command.packageHash },
23983
- ...command?.directive === void 0 ? {} : { requestedDirective: command.directive },
23984
- maintainGitCustody: read === void 0 && demand.background?.maintainGitCustody === true,
23985
- // Only reached inside a burst under the growth guard: one small packing slice.
23986
- ...burstSlice ? { localWriteBurst: true } : {},
23987
- // Readiness is one kernel-reported fact per workspace frontier. Every
23988
- // read demand repays all of it; no cause selects a weaker variant that
23989
- // would leave the workspace unusable as a foreign-read source.
23990
- readIndexOnly: read !== void 0
23991
- })
23992
- );
23993
- const elapsedNanoseconds = __privateGet(this, _clock7).monotonicNanoseconds() - now2;
23994
- if (slowQuantumObserver && elapsedNanoseconds >= 300000000n) {
23995
- slowQuantumObserver(`[nomos-kernel-perf] ${JSON.stringify({
23996
- op: "peer_maintenance_quantum",
23997
- totalMs: Number(elapsedNanoseconds / 1000000n),
23998
- cause: ReadMaintenanceCause[activeCause],
23999
- read: read !== void 0,
24000
- awaited: demand.awaited === true,
24001
- session: demand.session !== void 0,
24002
- backgroundHoldMs: Number((backgroundNotBeforeNanoseconds - now2) / 1000000n),
24003
- sessionlessHoldMs: Number((sessionlessNotBeforeNanoseconds - now2) / 1000000n),
24004
- caller: (new Error().stack ?? "").split("\n").slice(2, 6).map((frame2) => frame2.trim()).join(" < ")
24005
- })}`);
24006
- }
24007
- __privateMethod(this, _ReadMaintenanceDesk_instances, notePressure_fn).call(this, workspace, progress.looseCustodyPressure);
24008
- if (burstSlice) __privateSet(this, _lastBurstSliceNanoseconds, now2);
24009
- const observed = create(ReadMaintenanceProgressSchema, {
24010
- workspace,
24011
- cause: activeCause,
24012
- kernel: progress
24013
- });
24014
- __privateGet(this, _trace6).emit(demand.session, {
24015
- case: "maintenanceProgress",
24016
- value: observed
24017
- });
24018
- if (__privateGet(this, _deferredDurability)) __privateMethod(this, _ReadMaintenanceDesk_instances, oweFlush_fn).call(this, workspace, demand.session, false);
24019
- __privateGet(this, _pending).delete(workspace);
24020
- if (progress.maintenancePending) {
24021
- if (read) {
24022
- const rest = [...__privateGet(this, _pending).entries()];
24023
- __privateGet(this, _pending).clear();
24024
- __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
24025
- for (const [key, value] of rest) __privateGet(this, _pending).set(key, value);
24026
- } else {
24027
- __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
24028
- }
24029
- } else if (read && demand.background) {
24030
- const { read: _settled4, awaited: _served, ...backgroundDemand } = demand;
24031
- __privateGet(this, _pending).set(workspace, {
24032
- ...backgroundDemand,
24033
- background: read.owedByAdvance ? { ...demand.background, announced: true } : demand.background,
24034
- failures: 0
24035
- });
24036
- __privateGet(this, _trace6).emit(demand.session, {
24037
- case: "maintenanceProgress",
24038
- value: create(ReadMaintenanceProgressSchema, {
24039
- workspace,
24040
- cause: demand.background.cause
24041
- })
24042
- });
24043
- }
24044
- if (!progress.maintenancePending) {
24045
- if (read?.owedByAdvance) __privateGet(this, _observer).frontierAdvanced?.(workspace);
24046
- else if (read) __privateGet(this, _observer).readReady?.(workspace);
24047
- else if (demand.background?.maintainGitCustody && !demand.background.announced) {
24048
- __privateGet(this, _observer).frontierAdvanced?.(workspace);
24049
- }
24050
- }
24051
- return create(MaintenanceTickedSchema, {
24052
- pending: __privateGet(this, _pending).size > 0,
24053
- progress: observed,
24054
- // With no debt left, an armed idle pin names when the host should wake next.
24055
- nextTickAfterMillis: progress.maintenancePending ? 20 : __privateGet(this, _pending).size === 0 && this.hasIdleWork() ? __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) : 0
24056
- });
24057
- } catch (error) {
24058
- const format = localCopyFormatRefusal(error);
24059
- if (format !== void 0) {
24060
- __privateGet(this, _pending).delete(workspace);
24061
- __privateGet(this, _pins).delete(workspace);
24062
- __privateSet(this, _revision3, __privateGet(this, _revision3) + 1);
24063
- __privateGet(this, _observer).localCopyUnreadable?.(workspace, format);
24064
- __privateGet(this, _trace6).emit(demand.session, {
24065
- case: "maintenanceProgress",
24066
- value: create(ReadMaintenanceProgressSchema, {
24067
- workspace,
24068
- cause: activeCause,
24069
- stopped: true
24070
- })
24071
- });
24072
- return create(MaintenanceTickedSchema, {
24073
- pending: __privateGet(this, _pending).size > 0,
24074
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24075
- });
24076
- }
24077
- const failures = demand.failures + 1;
24078
- __privateGet(this, _pending).delete(workspace);
24079
- const retryMillis = Math.min(30 * 60 * 1e3, 1e3 * 2 ** Math.min(failures - 1, 10));
24080
- slowQuantumObserver?.(`[nomos-kernel-perf] ${JSON.stringify({
24081
- op: "peer_maintenance_failure",
24082
- failed: true,
24083
- workspace,
24084
- cause: ReadMaintenanceCause[activeCause],
24085
- failures,
24086
- retryAfterMillis: retryMillis,
24087
- totalMs: Number((__privateGet(this, _clock7).monotonicNanoseconds() - now2) / 1000000n),
24088
- error: (error instanceof Error ? error.message : String(error)).slice(0, 600)
24089
- })}`);
24090
- __privateGet(this, _pending).set(workspace, {
24091
- ...demand,
24092
- failures,
24093
- retryNotBeforeNanoseconds: __privateGet(this, _clock7).monotonicNanoseconds() + BigInt(retryMillis) * 1000000n
24094
- });
24095
- __privateGet(this, _trace6).emit(demand.session, {
24096
- case: "maintenanceProgress",
24097
- value: create(ReadMaintenanceProgressSchema, {
24098
- workspace,
24099
- cause: activeCause,
24100
- retryAfterMillis: retryMillis
24101
- })
24102
- });
24103
- return create(MaintenanceTickedSchema, {
24104
- pending: true,
24105
- // Backoff belongs to the failed workspace. Another workspace's ready
24106
- // index or changed watches must not wait for this retry deadline.
24107
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24108
- });
24023
+ }
24024
+ /**
24025
+ * A waiting read's turn: advance read readiness only. It never runs a background command, closure
24026
+ * warm, pack import or durability flush on the foreground's turn, and never reports a wake for
24027
+ * that background work: with only background work owed its wake is `none`.
24028
+ */
24029
+ tickReadReadiness() {
24030
+ const turn = __privateMethod(this, _ReadMaintenanceDesk_instances, turn_fn).call(this, void 0, 0n, { case: "readReadinessOnly" }, false);
24031
+ if (turn.case === "ran") {
24032
+ return { ticked: turn.ticked, wake: { case: "after", millis: turn.ticked.nextTickAfterMillis } };
24109
24033
  }
24034
+ return {
24035
+ ticked: create(MaintenanceTickedSchema, { pending: turn.pending, nextTickAfterMillis: turn.nextDelayMillis ?? 0 }),
24036
+ wake: turn.nextDelayMillis === void 0 ? { case: "none" } : { case: "after", millis: turn.nextDelayMillis }
24037
+ };
24110
24038
  }
24111
24039
  /** Drop any demand for a workspace no maintenance can serve (an unreadable copy). */
24112
24040
  forget(workspace) {
@@ -24199,6 +24127,7 @@
24199
24127
  for (const [key, value] of entries.filter(([key2]) => key2 !== workspace)) __privateGet(this, _pending).set(key, value);
24200
24128
  }
24201
24129
  __privateSet(this, _revision3, __privateGet(this, _revision3) + 1);
24130
+ if (read && (!existing?.read || isReadDemand)) __privateGet(this, _observer).readinessMayChange?.(workspace);
24202
24131
  if (!existing || existing.read?.cause !== read?.cause || existing.background?.cause !== background?.cause) {
24203
24132
  __privateGet(this, _trace6).emit(session ?? existing?.session, {
24204
24133
  case: "maintenanceProgress",
@@ -24206,6 +24135,197 @@
24206
24135
  });
24207
24136
  }
24208
24137
  };
24138
+ turn_fn = function(request, sessionlessNotBeforeNanoseconds, backgroundHold, durability) {
24139
+ const now2 = __privateGet(this, _clock7).monotonicNanoseconds();
24140
+ const backgroundNotBeforeNanoseconds = backgroundHold.case === "until" ? backgroundHold.atNanoseconds : void 0;
24141
+ const custodySlice = (workspace2) => __privateMethod(this, _ReadMaintenanceDesk_instances, custodyBurstSlice_fn).call(this, now2, workspace2);
24142
+ const due2 = (demand2) => {
24143
+ const held = demand2.session || demand2.awaited || demand2.retryNotBeforeNanoseconds > sessionlessNotBeforeNanoseconds ? demand2.retryNotBeforeNanoseconds : sessionlessNotBeforeNanoseconds;
24144
+ if (!demand2.read && !demand2.awaited && backgroundNotBeforeNanoseconds === void 0) return void 0;
24145
+ const ordinary = demand2.read || demand2.awaited || backgroundNotBeforeNanoseconds === void 0 || held > backgroundNotBeforeNanoseconds ? held : backgroundNotBeforeNanoseconds;
24146
+ const hold = demand2.read || demand2.awaited || !demand2.background?.maintainGitCustody ? void 0 : custodySlice(demand2.workspace);
24147
+ if (!hold) return ordinary;
24148
+ if (hold.slice && durability) return held > hold.at ? held : hold.at;
24149
+ return ordinary > hold.at ? ordinary : hold.at;
24150
+ };
24151
+ const entry = [...__privateGet(this, _pending).entries()].find(([, demand2]) => {
24152
+ const at = due2(demand2);
24153
+ return at !== void 0 && at <= now2;
24154
+ });
24155
+ const flush = __privateGet(this, _flush);
24156
+ if (durability && flush && __privateMethod(this, _ReadMaintenanceDesk_instances, flushDueAt_fn).call(this, flush) <= now2 && !entry?.[1].read && (flush.local || !entry || flush.owedSinceNanoseconds + DURABILITY_FLUSH_MAX_DELAY_NANOSECONDS <= now2)) {
24157
+ return { case: "ran", ticked: __privateMethod(this, _ReadMaintenanceDesk_instances, tickFlush_fn).call(this, flush, request) };
24158
+ }
24159
+ const pinDue = (pin) => {
24160
+ if (backgroundNotBeforeNanoseconds === void 0) return void 0;
24161
+ const held = pin.session ? 0n : sessionlessNotBeforeNanoseconds;
24162
+ return [pin.notBeforeNanoseconds, held, backgroundNotBeforeNanoseconds].reduce((latest, at) => at > latest ? at : latest, 0n);
24163
+ };
24164
+ if (!entry) {
24165
+ const pin = [...__privateGet(this, _pins).entries()].find(([, idle]) => {
24166
+ const at = pinDue(idle);
24167
+ return at !== void 0 && at <= now2;
24168
+ });
24169
+ if (pin) return { case: "ran", ticked: __privateMethod(this, _ReadMaintenanceDesk_instances, tickPin_fn).call(this, pin[0], pin[1], request) };
24170
+ return { case: "idle", pending: this.hasPending(), nextDelayMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, now2, due2, pinDue, durability) };
24171
+ }
24172
+ const [workspace, demand] = entry;
24173
+ const mount = demand.session ? __privateGet(this, _sessions5).mountForSession(demand.session) : __privateGet(this, _sessions5).mountForWorkspace(workspace);
24174
+ const read = demand.read;
24175
+ const activeCause = read?.cause ?? demand.background?.cause;
24176
+ if (activeCause === void 0) {
24177
+ throw new Error(`maintenance demand for '${workspace}' has no work`);
24178
+ }
24179
+ const command = read ? void 0 : demand.background?.command;
24180
+ const burstSlice = read === void 0 && demand.background?.maintainGitCustody === true && durability && custodySlice(workspace)?.slice === true;
24181
+ const synthetic = request ?? create(RuntimeRequestSchema, {
24182
+ protocolVersion: 2,
24183
+ requestId: ++__privateWrapper(this, _sequence8)._
24184
+ });
24185
+ try {
24186
+ const progress = __privateGet(this, _trace6).measure(
24187
+ "peer.read-maintenance.quantum",
24188
+ { request: synthetic, ...demand.session ? { session: demand.session } : {}, workspace },
24189
+ {
24190
+ "maintenance.cause": ReadMaintenanceCause[activeCause],
24191
+ ...command ? {
24192
+ "maintenance.domain": command.domain,
24193
+ "maintenance.package": command.packageHash,
24194
+ ...command.directive ? { "maintenance.directive": command.directive } : {}
24195
+ } : {}
24196
+ },
24197
+ () => __privateGet(this, _queries3).maintenanceQuantum(demand.session ?? "", mount, synthetic.requestId, {
24198
+ ...command?.domain === void 0 ? {} : { requestedDomain: command.domain },
24199
+ ...command?.packageHash === void 0 ? {} : { requestedPackage: command.packageHash },
24200
+ ...command?.directive === void 0 ? {} : { requestedDirective: command.directive },
24201
+ maintainGitCustody: read === void 0 && demand.background?.maintainGitCustody === true,
24202
+ // Only reached inside a burst under the growth guard: one small packing slice.
24203
+ ...burstSlice ? { localWriteBurst: true } : {},
24204
+ // Readiness is one kernel-reported fact per workspace frontier. Every
24205
+ // read demand repays all of it; no cause selects a weaker variant that
24206
+ // would leave the workspace unusable as a foreign-read source.
24207
+ readIndexOnly: read !== void 0
24208
+ })
24209
+ );
24210
+ const elapsedNanoseconds = __privateGet(this, _clock7).monotonicNanoseconds() - now2;
24211
+ if (slowQuantumObserver && elapsedNanoseconds >= 300000000n) {
24212
+ slowQuantumObserver(`[nomos-kernel-perf] ${JSON.stringify({
24213
+ op: "peer_maintenance_quantum",
24214
+ totalMs: Number(elapsedNanoseconds / 1000000n),
24215
+ cause: ReadMaintenanceCause[activeCause],
24216
+ read: read !== void 0,
24217
+ awaited: demand.awaited === true,
24218
+ session: demand.session !== void 0,
24219
+ backgroundHoldMs: backgroundNotBeforeNanoseconds === void 0 ? "read-readiness-only" : Number((backgroundNotBeforeNanoseconds - now2) / 1000000n),
24220
+ sessionlessHoldMs: Number((sessionlessNotBeforeNanoseconds - now2) / 1000000n),
24221
+ caller: (new Error().stack ?? "").split("\n").slice(2, 6).map((frame2) => frame2.trim()).join(" < ")
24222
+ })}`);
24223
+ }
24224
+ __privateMethod(this, _ReadMaintenanceDesk_instances, notePressure_fn).call(this, workspace, progress.looseCustodyPressure);
24225
+ if (burstSlice) __privateSet(this, _lastBurstSliceNanoseconds, now2);
24226
+ const observed = create(ReadMaintenanceProgressSchema, {
24227
+ workspace,
24228
+ cause: activeCause,
24229
+ kernel: progress
24230
+ });
24231
+ __privateGet(this, _trace6).emit(demand.session, {
24232
+ case: "maintenanceProgress",
24233
+ value: observed
24234
+ });
24235
+ if (__privateGet(this, _deferredDurability)) __privateMethod(this, _ReadMaintenanceDesk_instances, oweFlush_fn).call(this, workspace, demand.session, false);
24236
+ __privateGet(this, _pending).delete(workspace);
24237
+ if (progress.maintenancePending) {
24238
+ if (read) {
24239
+ const rest = [...__privateGet(this, _pending).entries()];
24240
+ __privateGet(this, _pending).clear();
24241
+ __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
24242
+ for (const [key, value] of rest) __privateGet(this, _pending).set(key, value);
24243
+ } else {
24244
+ __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
24245
+ }
24246
+ } else if (read && demand.background) {
24247
+ const { read: _settled4, awaited: _served, ...backgroundDemand } = demand;
24248
+ __privateGet(this, _pending).set(workspace, {
24249
+ ...backgroundDemand,
24250
+ background: read.owedByAdvance ? { ...demand.background, announced: true } : demand.background,
24251
+ failures: 0
24252
+ });
24253
+ __privateGet(this, _trace6).emit(demand.session, {
24254
+ case: "maintenanceProgress",
24255
+ value: create(ReadMaintenanceProgressSchema, {
24256
+ workspace,
24257
+ cause: demand.background.cause
24258
+ })
24259
+ });
24260
+ }
24261
+ if (!progress.maintenancePending) {
24262
+ if (read?.owedByAdvance) __privateGet(this, _observer).frontierAdvanced?.(workspace);
24263
+ else if (read) __privateGet(this, _observer).readReady?.(workspace);
24264
+ else if (demand.background?.maintainGitCustody && !demand.background.announced) {
24265
+ __privateGet(this, _observer).frontierAdvanced?.(workspace);
24266
+ }
24267
+ }
24268
+ __privateGet(this, _observer).readinessMayChange?.(workspace);
24269
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
24270
+ pending: __privateGet(this, _pending).size > 0,
24271
+ progress: observed,
24272
+ // With no debt left, an armed idle pin names when the host should wake next.
24273
+ nextTickAfterMillis: progress.maintenancePending ? 20 : __privateGet(this, _pending).size === 0 && this.hasIdleWork() ? __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0 : 0
24274
+ }) };
24275
+ } catch (error) {
24276
+ const format = localCopyFormatRefusal(error);
24277
+ if (format !== void 0) {
24278
+ __privateGet(this, _pending).delete(workspace);
24279
+ __privateGet(this, _pins).delete(workspace);
24280
+ __privateSet(this, _revision3, __privateGet(this, _revision3) + 1);
24281
+ __privateGet(this, _observer).localCopyUnreadable?.(workspace, format);
24282
+ __privateGet(this, _trace6).emit(demand.session, {
24283
+ case: "maintenanceProgress",
24284
+ value: create(ReadMaintenanceProgressSchema, {
24285
+ workspace,
24286
+ cause: activeCause,
24287
+ stopped: true
24288
+ })
24289
+ });
24290
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
24291
+ pending: __privateGet(this, _pending).size > 0,
24292
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24293
+ }) };
24294
+ }
24295
+ const failures = demand.failures + 1;
24296
+ __privateGet(this, _pending).delete(workspace);
24297
+ const retryMillis = Math.min(30 * 60 * 1e3, 1e3 * 2 ** Math.min(failures - 1, 10));
24298
+ slowQuantumObserver?.(`[nomos-kernel-perf] ${JSON.stringify({
24299
+ op: "peer_maintenance_failure",
24300
+ failed: true,
24301
+ workspace,
24302
+ cause: ReadMaintenanceCause[activeCause],
24303
+ failures,
24304
+ retryAfterMillis: retryMillis,
24305
+ totalMs: Number((__privateGet(this, _clock7).monotonicNanoseconds() - now2) / 1000000n),
24306
+ error: (error instanceof Error ? error.message : String(error)).slice(0, 600)
24307
+ })}`);
24308
+ __privateGet(this, _pending).set(workspace, {
24309
+ ...demand,
24310
+ failures,
24311
+ retryNotBeforeNanoseconds: __privateGet(this, _clock7).monotonicNanoseconds() + BigInt(retryMillis) * 1000000n
24312
+ });
24313
+ __privateGet(this, _trace6).emit(demand.session, {
24314
+ case: "maintenanceProgress",
24315
+ value: create(ReadMaintenanceProgressSchema, {
24316
+ workspace,
24317
+ cause: activeCause,
24318
+ retryAfterMillis: retryMillis
24319
+ })
24320
+ });
24321
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
24322
+ pending: true,
24323
+ // Backoff belongs to the failed workspace. Another workspace's ready
24324
+ // index or changed watches must not wait for this retry deadline.
24325
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24326
+ }) };
24327
+ }
24328
+ };
24209
24329
  /** Owe the kernel its ordered flush. The first write it covers fixes `owedSince`; the shared
24210
24330
  * burst signal then releases it once the offers pause, or at the cap (CAP-750: one detector). */
24211
24331
  oweFlush_fn = function(workspace, session, local) {
@@ -24268,7 +24388,7 @@
24268
24388
  }
24269
24389
  return create(MaintenanceTickedSchema, {
24270
24390
  pending: this.hasPending(),
24271
- nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24391
+ nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24272
24392
  });
24273
24393
  } catch (error) {
24274
24394
  const failures = flush.failures + 1;
@@ -24292,7 +24412,7 @@
24292
24412
  });
24293
24413
  return create(MaintenanceTickedSchema, {
24294
24414
  pending: this.hasPending(),
24295
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24415
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24296
24416
  });
24297
24417
  }
24298
24418
  };
@@ -24323,7 +24443,7 @@
24323
24443
  }
24324
24444
  return create(MaintenanceTickedSchema, {
24325
24445
  pending: this.hasPending(),
24326
- nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24446
+ nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24327
24447
  });
24328
24448
  } catch (error) {
24329
24449
  slowQuantumObserver?.(`[nomos-kernel-perf] ${JSON.stringify({
@@ -24335,44 +24455,51 @@
24335
24455
  })}`);
24336
24456
  return create(MaintenanceTickedSchema, {
24337
24457
  pending: this.hasPending(),
24338
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24458
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24339
24459
  });
24340
24460
  }
24341
24461
  };
24342
- nextDelay_fn = function(now2, due2 = (demand) => demand.retryNotBeforeNanoseconds, pinDue = (pin) => pin.notBeforeNanoseconds) {
24462
+ /** Milliseconds until the earliest owed work this turn serves; `undefined` when none is owed. */
24463
+ nextDelay_fn = function(now2, due2 = (demand) => demand.retryNotBeforeNanoseconds, pinDue = (pin) => pin.notBeforeNanoseconds, flushes = true) {
24343
24464
  let earliest;
24344
24465
  for (const demand of __privateGet(this, _pending).values()) {
24345
24466
  const at = due2(demand);
24467
+ if (at === void 0) continue;
24346
24468
  if (at <= now2) return 0;
24347
24469
  if (earliest === void 0 || at < earliest) earliest = at;
24348
24470
  }
24349
24471
  for (const pin of __privateGet(this, _pins).values()) {
24350
24472
  const at = pinDue(pin);
24473
+ if (at === void 0) continue;
24351
24474
  if (at <= now2) return 0;
24352
24475
  if (earliest === void 0 || at < earliest) earliest = at;
24353
24476
  }
24354
- if (__privateGet(this, _flush)) {
24477
+ if (flushes && __privateGet(this, _flush)) {
24355
24478
  const at = __privateMethod(this, _ReadMaintenanceDesk_instances, flushDueAt_fn).call(this, __privateGet(this, _flush));
24356
24479
  if (at <= now2) return 0;
24357
24480
  if (earliest === void 0 || at < earliest) earliest = at;
24358
24481
  }
24359
- return earliest === void 0 ? 0 : Number((earliest - now2 + 999999n) / 1000000n);
24482
+ return earliest === void 0 ? void 0 : Number((earliest - now2 + 999999n) / 1000000n);
24360
24483
  };
24361
24484
 
24362
24485
  // ../src/runtime/read_response_desk.ts
24363
24486
  init_define_NOMOS_KERNEL_RELEASE();
24364
24487
  init_shims();
24365
- var _waiting5, _clock8, _tick, _read2, _sequence9, _ReadResponseDesk_instances, now_fn3, pending_fn;
24488
+ var READ_RETENTION_MILLIS = 12e4;
24489
+ var READ_RESUME_MAX_MILLIS = 1e3;
24490
+ var _waiting5, _clock8, _tick, _owe, _read2, _sequence9, _ReadResponseDesk_instances, now_fn3, pending_fn;
24366
24491
  var ReadResponseDesk = class {
24367
- constructor(clock2, tick, read) {
24492
+ constructor(clock2, tick, owe, read) {
24368
24493
  __privateAdd(this, _ReadResponseDesk_instances);
24369
24494
  __privateAdd(this, _waiting5, /* @__PURE__ */ new Map());
24370
24495
  __privateAdd(this, _clock8);
24371
24496
  __privateAdd(this, _tick);
24497
+ __privateAdd(this, _owe);
24372
24498
  __privateAdd(this, _read2);
24373
24499
  __privateAdd(this, _sequence9, 0);
24374
24500
  __privateSet(this, _clock8, clock2);
24375
24501
  __privateSet(this, _tick, tick);
24502
+ __privateSet(this, _owe, owe);
24376
24503
  __privateSet(this, _read2, read);
24377
24504
  }
24378
24505
  begin(request, dependency) {
@@ -24382,18 +24509,27 @@
24382
24509
  const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24383
24510
  for (const [id, work] of __privateGet(this, _waiting5)) if (work.deadline <= now2) __privateGet(this, _waiting5).delete(id);
24384
24511
  const workId2 = `local-read-${++__privateWrapper(this, _sequence9)._}`;
24385
- __privateGet(this, _waiting5).set(workId2, { request, dependency, deadline: now2 + 12e4, notBefore: now2 });
24512
+ __privateGet(this, _waiting5).set(workId2, {
24513
+ request,
24514
+ dependency,
24515
+ deadline: now2 + READ_RETENTION_MILLIS,
24516
+ notBefore: now2,
24517
+ idle: false,
24518
+ // The office owed this frontier's debt when the kernel first answered pending.
24519
+ owedFor: dependency.requestedFrontier,
24520
+ waiters: /* @__PURE__ */ new Set()
24521
+ });
24386
24522
  return create(LocalReadPendingSchema, { workId: workId2 });
24387
24523
  }
24388
24524
  resume(workId2, requestId) {
24389
24525
  const work = __privateGet(this, _waiting5).get(workId2);
24390
24526
  if (!work || work.request.requestId !== requestId) throw new Error(`unknown local read continuation '${workId2}'`);
24391
24527
  const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24528
+ work.waiters.clear();
24392
24529
  if (now2 >= work.deadline) {
24393
24530
  __privateGet(this, _waiting5).delete(workId2);
24394
24531
  throw new Error(`Local read index for '${work.dependency.workspace}' did not catch up to ${work.dependency.requestedFrontier} within its retained maintenance window`);
24395
24532
  }
24396
- if (now2 < work.notBefore) return __privateMethod(this, _ReadResponseDesk_instances, pending_fn).call(this, workId2, work, now2);
24397
24533
  try {
24398
24534
  const response = __privateGet(this, _read2).call(this, work.request);
24399
24535
  if (response.outcome.case !== "query" || response.outcome.value.result.case !== "readIndexPending") {
@@ -24401,33 +24537,75 @@
24401
24537
  return { case: "ready", request: work.request, response };
24402
24538
  }
24403
24539
  work.dependency = response.outcome.value.result.value;
24404
- const tick = __privateGet(this, _tick).call(this);
24540
+ if (now2 < work.notBefore) return __privateMethod(this, _ReadResponseDesk_instances, pending_fn).call(this, workId2, work, now2);
24541
+ let { ticked, wake } = __privateGet(this, _tick).call(this);
24542
+ if (wake.case === "none" && ticked.progress === void 0 && work.owedFor !== work.dependency.requestedFrontier) {
24543
+ work.owedFor = work.dependency.requestedFrontier;
24544
+ __privateGet(this, _owe).call(this, work.request);
24545
+ ({ ticked, wake } = __privateGet(this, _tick).call(this));
24546
+ }
24405
24547
  const afterTick = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24406
- work.notBefore = afterTick + tick.nextTickAfterMillis;
24407
- work.deadline = afterTick + Math.max(12e4, tick.nextTickAfterMillis + 6e4);
24548
+ work.idle = wake.case === "none";
24549
+ const backoff = wake.case === "after" ? wake.millis : 0;
24550
+ work.notBefore = afterTick + backoff;
24551
+ work.deadline = afterTick + Math.max(READ_RETENTION_MILLIS, backoff + 6e4);
24408
24552
  return __privateMethod(this, _ReadResponseDesk_instances, pending_fn).call(this, workId2, work, afterTick);
24409
24553
  } catch (error) {
24410
24554
  __privateGet(this, _waiting5).delete(workId2);
24411
24555
  throw error;
24412
24556
  }
24413
24557
  }
24558
+ /**
24559
+ * Wait in process for a held read to become worth continuing. `notify` is called once, when read
24560
+ * readiness for its workspace changes (a slice or binding finished, a frontier advanced, readiness
24561
+ * newly owed). `afterMillis` is the only timer the shell needs: the read's own scheduled quantum
24562
+ * when it has one, otherwise its deadline. Undefined for an unknown or finished read.
24563
+ */
24564
+ onResumable(workId2, notify) {
24565
+ const work = __privateGet(this, _waiting5).get(workId2);
24566
+ if (!work) return void 0;
24567
+ const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24568
+ const due2 = work.idle ? work.deadline : Math.min(work.notBefore, work.deadline);
24569
+ work.waiters.add(notify);
24570
+ return { afterMillis: Math.max(0, due2 - now2), cancel: () => {
24571
+ work.waiters.delete(notify);
24572
+ } };
24573
+ }
24574
+ /** Read readiness for `workspace` changed: every read waiting on it may continue now. */
24575
+ readinessChanged(workspace) {
24576
+ const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24577
+ for (const work of __privateGet(this, _waiting5).values()) {
24578
+ if (work.dependency.workspace !== workspace) continue;
24579
+ work.idle = false;
24580
+ if (work.notBefore > now2) work.notBefore = now2;
24581
+ const waiters = [...work.waiters];
24582
+ work.waiters.clear();
24583
+ for (const notify of waiters) notify();
24584
+ }
24585
+ }
24414
24586
  clear() {
24587
+ const waiters = [...__privateGet(this, _waiting5).values()].flatMap((work) => [...work.waiters]);
24415
24588
  __privateGet(this, _waiting5).clear();
24589
+ for (const notify of waiters) notify();
24416
24590
  }
24417
24591
  };
24418
24592
  _waiting5 = new WeakMap();
24419
24593
  _clock8 = new WeakMap();
24420
24594
  _tick = new WeakMap();
24595
+ _owe = new WeakMap();
24421
24596
  _read2 = new WeakMap();
24422
24597
  _sequence9 = new WeakMap();
24423
24598
  _ReadResponseDesk_instances = new WeakSet();
24424
24599
  now_fn3 = function() {
24425
24600
  return Number(__privateGet(this, _clock8).monotonicNanoseconds() / 1000000n);
24426
24601
  };
24602
+ /** The protocol wake is a bounded re-poll inside the read's retention deadline, never the raw backoff. */
24427
24603
  pending_fn = function(workId2, work, now2) {
24604
+ const due2 = work.idle ? READ_RESUME_MAX_MILLIS : work.notBefore - now2;
24605
+ const resumeAfterMillis = Math.max(0, Math.min(due2, work.deadline - now2, READ_RESUME_MAX_MILLIS));
24428
24606
  return { case: "pending", value: create(LocalReadPendingSchema, {
24429
24607
  workId: workId2,
24430
- resumeAfterMillis: Math.max(0, work.notBefore - now2)
24608
+ resumeAfterMillis: Number.isFinite(resumeAfterMillis) ? Math.ceil(resumeAfterMillis) : READ_RESUME_MAX_MILLIS
24431
24609
  }) };
24432
24610
  };
24433
24611
 
@@ -25373,13 +25551,15 @@
25373
25551
  DependencyAdvanced: "dependency_advanced",
25374
25552
  RebornRemotely: "reborn_remotely",
25375
25553
  LocalCopyDropAuthorized: "local_copy_drop_authorized",
25376
- LocalCopyUnreadable: "local_copy_unreadable"
25554
+ LocalCopyUnreadable: "local_copy_unreadable",
25555
+ RuntimeStarted: "runtime_started"
25377
25556
  });
25378
25557
  var ReplicaFollowEffectKind = Object.freeze({
25379
25558
  ScheduleWake: "schedule_wake",
25380
25559
  RunSync: "run_sync",
25381
25560
  RefreshCredential: "refresh_credential"
25382
25561
  });
25562
+ var KERNEL_REFUSAL_EVENT_FLOOR_MILLIS = 1e4;
25383
25563
  var boundedRetry = (policy, attempt) => Math.min(policy.fallbackMillis, Math.max(250, policy.debounceMillis) * 2 ** Math.min(attempt - 1, 20));
25384
25564
  var attempts = (state) => {
25385
25565
  switch (state.case) {
@@ -25406,13 +25586,14 @@
25406
25586
  state: { case: ReplicaFollowPhase.Due, dueAtUnixMillis: atUnixMillis },
25407
25587
  effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis }]
25408
25588
  });
25409
- var run = (attempt, replaceLocalHead, warmingSinceUnixMillis) => ({
25589
+ var run = (attempt, replaceLocalHead, warmingSinceUnixMillis, refused) => ({
25410
25590
  state: {
25411
25591
  case: ReplicaFollowPhase.Running,
25412
25592
  attempt,
25413
25593
  observed: false,
25414
25594
  ...replaceLocalHead === void 0 ? {} : { replaceLocalHead },
25415
- ...warmingSinceUnixMillis === void 0 ? {} : { warmingSinceUnixMillis }
25595
+ ...warmingSinceUnixMillis === void 0 ? {} : { warmingSinceUnixMillis },
25596
+ ...refused === void 0 ? {} : { refused }
25416
25597
  },
25417
25598
  effects: [{ case: ReplicaFollowEffectKind.RunSync }]
25418
25599
  });
@@ -25421,6 +25602,16 @@
25421
25602
  effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis }]
25422
25603
  });
25423
25604
  var quiet = (state) => ({ state, effects: [] });
25605
+ var blockedRefusal = (state) => state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked ? state.refusal : void 0;
25606
+ var refusedEvent = (state, refusal2, nowUnixMillis) => {
25607
+ const earliest = Math.max(nowUnixMillis, refusal2.atUnixMillis + KERNEL_REFUSAL_EVENT_FLOOR_MILLIS);
25608
+ const rerunAtUnixMillis = refusal2.rerunAtUnixMillis === void 0 ? earliest : Math.min(refusal2.rerunAtUnixMillis, earliest);
25609
+ return {
25610
+ state: { ...state, refusal: { ...refusal2, rerunAtUnixMillis } },
25611
+ effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: rerunAtUnixMillis }]
25612
+ };
25613
+ };
25614
+ var refusedByKernel = (state) => state.case === ReplicaFollowPhase.Backoff && (state.refusal !== void 0 || deterministicKernelRefusal(state.failure) !== void 0);
25424
25615
  function reduceReplicaFollow(state, event, policy) {
25425
25616
  switch (event.case) {
25426
25617
  case ReplicaFollowEventKind.Activate:
@@ -25433,6 +25624,9 @@
25433
25624
  if (state.case === ReplicaFollowPhase.Running) {
25434
25625
  return { state: { ...state, observed: true }, effects: [] };
25435
25626
  }
25627
+ if (state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked) {
25628
+ return refusedEvent(state, state.refusal, event.nowUnixMillis);
25629
+ }
25436
25630
  if (state.case === ReplicaFollowPhase.RebornRemotely || state.case === ReplicaFollowPhase.LocalCopyUnreadable) return quiet(state);
25437
25631
  if (state.case === ReplicaFollowPhase.InvalidCredential) {
25438
25632
  return {
@@ -25442,6 +25636,9 @@
25442
25636
  }
25443
25637
  return due(event.nowUnixMillis);
25444
25638
  case ReplicaFollowEventKind.Reconnected:
25639
+ if (state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked) {
25640
+ return refusedEvent(state, state.refusal, event.nowUnixMillis);
25641
+ }
25445
25642
  switch (state.case) {
25446
25643
  case ReplicaFollowPhase.Running:
25447
25644
  return { state: { ...state, observed: true }, effects: [] };
@@ -25487,15 +25684,25 @@
25487
25684
  }
25488
25685
  return run(state.attempt + 1, state.expectedLocalHead);
25489
25686
  case ReplicaFollowPhase.Offline:
25490
- case ReplicaFollowPhase.Backoff:
25687
+ case ReplicaFollowPhase.Backoff: {
25688
+ const blocked = blockedRefusal(state);
25689
+ if (blocked) {
25690
+ if (blocked.rerunAtUnixMillis === void 0) return quiet(state);
25691
+ if (event.nowUnixMillis < blocked.rerunAtUnixMillis) {
25692
+ return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: blocked.rerunAtUnixMillis }] };
25693
+ }
25694
+ return run(state.attempt + 1, void 0, void 0, state.failure);
25695
+ }
25491
25696
  if (event.nowUnixMillis < state.retryAtUnixMillis) {
25492
25697
  return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: state.retryAtUnixMillis }] };
25493
25698
  }
25494
25699
  return run(
25495
25700
  state.attempt + 1,
25496
25701
  void 0,
25497
- state.case === ReplicaFollowPhase.Backoff ? state.warming?.sinceUnixMillis : void 0
25702
+ state.case === ReplicaFollowPhase.Backoff ? state.warming?.sinceUnixMillis : void 0,
25703
+ state.case === ReplicaFollowPhase.Backoff && state.refusal ? state.failure : void 0
25498
25704
  );
25705
+ }
25499
25706
  case ReplicaFollowPhase.InvalidCredential:
25500
25707
  if (!state.refreshDue && event.nowUnixMillis < state.retryAtUnixMillis) {
25501
25708
  return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: state.retryAtUnixMillis }] };
@@ -25572,6 +25779,31 @@
25572
25779
  };
25573
25780
  }
25574
25781
  case ReplicaFollowEventKind.Failed: {
25782
+ if (event.refusal && !(state.case === ReplicaFollowPhase.Running && state.replaceLocalHead !== void 0)) {
25783
+ const attempt2 = Math.max(1, attempts(state));
25784
+ const blocked = state.case === ReplicaFollowPhase.Running && state.refused === event.failure || state.case === ReplicaFollowPhase.Backoff && state.refusal !== void 0 && state.failure === event.failure;
25785
+ const refusal2 = {
25786
+ code: event.refusal.code,
25787
+ blocked,
25788
+ runtime: event.refusal.runtime,
25789
+ atUnixMillis: event.nowUnixMillis
25790
+ };
25791
+ if (!blocked) {
25792
+ const retryAtUnixMillis2 = event.nowUnixMillis + boundedRetry(policy, attempt2);
25793
+ return {
25794
+ state: { case: ReplicaFollowPhase.Backoff, attempt: attempt2, retryAtUnixMillis: retryAtUnixMillis2, failure: event.failure, refusal: refusal2 },
25795
+ effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: retryAtUnixMillis2 }]
25796
+ };
25797
+ }
25798
+ const waiting = {
25799
+ case: ReplicaFollowPhase.Backoff,
25800
+ attempt: attempt2,
25801
+ retryAtUnixMillis: event.nowUnixMillis,
25802
+ failure: event.failure,
25803
+ refusal: refusal2
25804
+ };
25805
+ return state.case === ReplicaFollowPhase.Running && state.observed ? refusedEvent(waiting, refusal2, event.nowUnixMillis) : quiet(waiting);
25806
+ }
25575
25807
  if (state.case === ReplicaFollowPhase.Running && state.observed) {
25576
25808
  return due(event.nowUnixMillis);
25577
25809
  }
@@ -25609,6 +25841,11 @@
25609
25841
  return quiet({ case: ReplicaFollowPhase.RebornRemotely, rebirth: event.rebirth });
25610
25842
  case ReplicaFollowEventKind.LocalCopyUnreadable:
25611
25843
  return quiet({ case: ReplicaFollowPhase.LocalCopyUnreadable, format: event.format });
25844
+ case ReplicaFollowEventKind.RuntimeStarted:
25845
+ if (state.case === ReplicaFollowPhase.Backoff && refusedByKernel(state) && state.refusal?.runtime !== event.runtime) {
25846
+ return due(event.nowUnixMillis);
25847
+ }
25848
+ return quiet(state);
25612
25849
  case ReplicaFollowEventKind.LocalCopyDropAuthorized:
25613
25850
  if (state.case === ReplicaFollowPhase.Running) return invalid2(state, event);
25614
25851
  return replacing(event.expectedLocalHead, 0, event.nowUnixMillis);
@@ -25635,9 +25872,9 @@
25635
25872
  debounceMillis: 1e3,
25636
25873
  fallbackMillis: 6e4
25637
25874
  });
25638
- var _desk, _clock11, _recovered, _placementRecheck, _replicaId, _birthRefusals, _ReplicaFollowController_instances, quarantineChild_fn, event_fn, binding_fn, now_fn5;
25875
+ var _desk, _clock11, _recovered, _placementRecheck, _replicaId, _birthRefusals, _runtime, _ReplicaFollowController_instances, quarantineChild_fn, event_fn, binding_fn, now_fn5;
25639
25876
  var ReplicaFollowController = class {
25640
- constructor(desk, clock2, replicaId, birthRefusals) {
25877
+ constructor(desk, clock2, replicaId, birthRefusals, runtime = "unidentified") {
25641
25878
  __privateAdd(this, _ReplicaFollowController_instances);
25642
25879
  __privateAdd(this, _desk);
25643
25880
  __privateAdd(this, _clock11);
@@ -25658,10 +25895,14 @@
25658
25895
  __privateAdd(this, _replicaId);
25659
25896
  /** Local children whose births custody refused (CAP-804): quarantined, never followed. */
25660
25897
  __privateAdd(this, _birthRefusals);
25898
+ /** The kernel/runtime identity this process runs: a refusal is recorded under it, and a refusal
25899
+ * drawn under another identity is retried once when this process starts. */
25900
+ __privateAdd(this, _runtime);
25661
25901
  __privateSet(this, _desk, desk);
25662
25902
  __privateSet(this, _clock11, clock2);
25663
25903
  __privateSet(this, _replicaId, replicaId);
25664
25904
  __privateSet(this, _birthRefusals, birthRefusals ?? new BirthRefusalRegister(new MemoryPeerDeskStore()));
25905
+ __privateSet(this, _runtime, runtime);
25665
25906
  }
25666
25907
  /** The durable quarantine of a local child whose birth custody refused; undefined otherwise. */
25667
25908
  birthRefusal(workspace) {
@@ -25750,6 +25991,13 @@
25750
25991
  recover() {
25751
25992
  const now2 = __privateMethod(this, _ReplicaFollowController_instances, now_fn5).call(this);
25752
25993
  if (!__privateGet(this, _recovered)) {
25994
+ for (const follow of __privateGet(this, _desk).all()) {
25995
+ __privateGet(this, _desk).transition(follow.spec.workspace, {
25996
+ case: ReplicaFollowEventKind.RuntimeStarted,
25997
+ nowUnixMillis: now2,
25998
+ runtime: __privateGet(this, _runtime)
25999
+ });
26000
+ }
25753
26001
  for (const follow of __privateGet(this, _desk).all()) {
25754
26002
  if (follow.state.case === ReplicaFollowPhase.Settled || follow.state.case === ReplicaFollowPhase.AwaitingDependency) {
25755
26003
  __privateGet(this, _placementRecheck).add(follow.spec.workspace);
@@ -25838,11 +26086,12 @@
25838
26086
  placementAnnounced(workspace) {
25839
26087
  if (!this.followForWorkspace(workspace)) return void 0;
25840
26088
  __privateGet(this, _placementRecheck).add(workspace);
25841
- return this.reconnected(workspace);
26089
+ return this.reconnected(workspace, true);
25842
26090
  }
25843
- /** The upstream live link opened or reopened: reconcile once for missed pushes. */
25844
- reconnected(workspace) {
25845
- return __privateMethod(this, _ReplicaFollowController_instances, event_fn).call(this, workspace, ReplicaFollowEventKind.Reconnected);
26091
+ /** The upstream live link opened or reopened: reconcile once for missed pushes. With
26092
+ * `remoteAdvanced`, the upstream announced a new frontier. Either re-runs a blocked refusal. */
26093
+ reconnected(workspace, remoteAdvanced = false) {
26094
+ return __privateMethod(this, _ReplicaFollowController_instances, event_fn).call(this, workspace, ReplicaFollowEventKind.Reconnected, remoteAdvanced);
25846
26095
  }
25847
26096
  /** Another workspace advanced or settled; every held dependency gets one retry. */
25848
26097
  dependencyAdvanced(except) {
@@ -25993,7 +26242,9 @@
25993
26242
  * still opening the workspace and named when to ask again. */
25994
26243
  failed(workspace, error, custodianRetryAfterMillis) {
25995
26244
  if (!__privateGet(this, _recovered)) this.recover();
25996
- custodianRetryAfterMillis ?? (custodianRetryAfterMillis = warmingFromFailureMessage(error instanceof Error ? error.message : String(error)));
26245
+ const refusal2 = deterministicKernelRefusal(error);
26246
+ if (refusal2 !== void 0) custodianRetryAfterMillis = void 0;
26247
+ else custodianRetryAfterMillis ?? (custodianRetryAfterMillis = warmingFromFailureMessage(error instanceof Error ? error.message : String(error)));
25997
26248
  if (!__privateGet(this, _desk).get(workspace)) return;
25998
26249
  const format = localCopyFormatRefusal(error);
25999
26250
  if (format !== void 0) {
@@ -26008,9 +26259,15 @@
26008
26259
  case: ReplicaFollowEventKind.Failed,
26009
26260
  nowUnixMillis: __privateMethod(this, _ReplicaFollowController_instances, now_fn5).call(this),
26010
26261
  failure: error instanceof Error ? error.message : String(error),
26011
- ...custodianRetryAfterMillis === void 0 ? {} : { custodianRetryAfterMillis }
26262
+ ...custodianRetryAfterMillis === void 0 ? {} : { custodianRetryAfterMillis },
26263
+ ...refusal2 === void 0 ? {} : { refusal: { code: refusal2.code, runtime: __privateGet(this, _runtime) } }
26012
26264
  });
26013
26265
  }
26266
+ /** The kernel refusal behind this follow's backoff (`blocked` once the kernel repeated it). */
26267
+ refusal(workspace) {
26268
+ const state = this.followForWorkspace(workspace)?.state;
26269
+ return state?.case === ReplicaFollowPhase.Backoff ? state.refusal : void 0;
26270
+ }
26014
26271
  /** Closing an interaction realm must not erase a peer-owned follow. */
26015
26272
  closeInteractionRealm() {
26016
26273
  }
@@ -26021,6 +26278,7 @@
26021
26278
  _placementRecheck = new WeakMap();
26022
26279
  _replicaId = new WeakMap();
26023
26280
  _birthRefusals = new WeakMap();
26281
+ _runtime = new WeakMap();
26024
26282
  _ReplicaFollowController_instances = new WeakSet();
26025
26283
  /**
26026
26284
  * QUARANTINE a local child whose birth custody refused: record it durably and stop its follow, so
@@ -26032,11 +26290,11 @@
26032
26290
  __privateGet(this, _desk).stop(child);
26033
26291
  __privateGet(this, _placementRecheck).delete(child);
26034
26292
  };
26035
- event_fn = function(workspace, kind) {
26293
+ event_fn = function(workspace, kind, remoteAdvanced = false) {
26036
26294
  const follow = __privateGet(this, _recovered) ? __privateGet(this, _desk).get(workspace) : void 0;
26037
26295
  if (!follow) return void 0;
26038
26296
  const nowUnixMillis = __privateMethod(this, _ReplicaFollowController_instances, now_fn5).call(this);
26039
- __privateGet(this, _desk).transition(workspace, { case: kind, nowUnixMillis });
26297
+ __privateGet(this, _desk).transition(workspace, kind === ReplicaFollowEventKind.Reconnected && remoteAdvanced ? { case: kind, nowUnixMillis, remoteAdvanced } : { case: kind, nowUnixMillis });
26040
26298
  const nextDueAt = dueAt(__privateGet(this, _desk).get(workspace));
26041
26299
  return nextDueAt === void 0 ? void 0 : Math.max(0, nextDueAt - nowUnixMillis);
26042
26300
  };
@@ -26068,9 +26326,12 @@
26068
26326
  case ReplicaFollowPhase.RebornRemotely:
26069
26327
  case ReplicaFollowPhase.LocalCopyUnreadable:
26070
26328
  return void 0;
26329
+ case ReplicaFollowPhase.Backoff: {
26330
+ const blocked = blockedRefusal(follow.state);
26331
+ return blocked ? blocked.rerunAtUnixMillis : follow.state.retryAtUnixMillis;
26332
+ }
26071
26333
  case ReplicaFollowPhase.Offline:
26072
26334
  case ReplicaFollowPhase.InvalidCredential:
26073
- case ReplicaFollowPhase.Backoff:
26074
26335
  return follow.state.retryAtUnixMillis;
26075
26336
  default: {
26076
26337
  const exhaustive = follow.state;
@@ -26086,6 +26347,11 @@
26086
26347
  return nextDueAt === void 0 ? void 0 : Math.max(0, nextDueAt - nowUnixMillis);
26087
26348
  }
26088
26349
 
26350
+ // ../src/runtime/runtime_identity.ts
26351
+ init_define_NOMOS_KERNEL_RELEASE();
26352
+ init_shims();
26353
+ var PEER_RUNTIME_IDENTITY = "0.116.4" ? `@githolon/runtime@${"0.116.4"}` : "@githolon/runtime@unbundled";
26354
+
26089
26355
  // ../src/runtime/replica_follow_desk.ts
26090
26356
  init_define_NOMOS_KERNEL_RELEASE();
26091
26357
  init_shims();
@@ -26115,6 +26381,16 @@
26115
26381
  ...Number.isFinite(warming.hintMillis) ? { hintMillis: warming.hintMillis } : {}
26116
26382
  } } : {};
26117
26383
  };
26384
+ var decodeRefusal = (value) => {
26385
+ const refusal2 = value;
26386
+ return refusal2 && typeof refusal2.code === "string" && typeof refusal2.runtime === "string" && Number.isFinite(refusal2.atUnixMillis) ? { refusal: {
26387
+ code: refusal2.code,
26388
+ blocked: refusal2.blocked === true,
26389
+ runtime: refusal2.runtime,
26390
+ atUnixMillis: refusal2.atUnixMillis,
26391
+ ...Number.isFinite(refusal2.rerunAtUnixMillis) ? { rerunAtUnixMillis: refusal2.rerunAtUnixMillis } : {}
26392
+ } } : {};
26393
+ };
26118
26394
  var decodeState = (record, value) => {
26119
26395
  if (!value || typeof value !== "object") throw corrupt(record, "state is not an object");
26120
26396
  const state = value;
@@ -26129,7 +26405,8 @@
26129
26405
  attempt: state.attempt,
26130
26406
  observed: state.observed === true,
26131
26407
  ...state.replaceLocalHead === void 0 ? {} : { replaceLocalHead: state.replaceLocalHead },
26132
- ...Number.isFinite(state.warmingSinceUnixMillis) ? { warmingSinceUnixMillis: state.warmingSinceUnixMillis } : {}
26408
+ ...Number.isFinite(state.warmingSinceUnixMillis) ? { warmingSinceUnixMillis: state.warmingSinceUnixMillis } : {},
26409
+ ...typeof state.refused === "string" ? { refused: state.refused } : {}
26133
26410
  };
26134
26411
  case ReplicaFollowPhase.Settled:
26135
26412
  return {
@@ -26161,7 +26438,8 @@
26161
26438
  attempt: state.attempt,
26162
26439
  retryAtUnixMillis: state.retryAtUnixMillis,
26163
26440
  failure: state.failure,
26164
- ...decodeWarming(state.warming)
26441
+ ...decodeWarming(state.warming),
26442
+ ...decodeRefusal(state.refusal)
26165
26443
  };
26166
26444
  case ReplicaFollowPhase.RebornRemotely: {
26167
26445
  const rebirth = state.rebirth ?? {};
@@ -26350,9 +26628,15 @@
26350
26628
  break;
26351
26629
  }
26352
26630
  case ReplicaFollowPhase.Offline:
26353
- case ReplicaFollowPhase.Backoff:
26354
- wakes.push({ workspace: follow.spec.workspace, atUnixMillis: follow.state.retryAtUnixMillis });
26631
+ case ReplicaFollowPhase.Backoff: {
26632
+ const blocked = blockedRefusal(follow.state);
26633
+ if (blocked && blocked.rerunAtUnixMillis === void 0) break;
26634
+ wakes.push({
26635
+ workspace: follow.spec.workspace,
26636
+ atUnixMillis: blocked?.rerunAtUnixMillis ?? follow.state.retryAtUnixMillis
26637
+ });
26355
26638
  break;
26639
+ }
26356
26640
  case ReplicaFollowPhase.InvalidCredential:
26357
26641
  wakes.push({
26358
26642
  workspace: follow.spec.workspace,
@@ -27045,7 +27329,9 @@
27045
27329
  message,
27046
27330
  ...retryAfterMillis === void 0 ? {} : { retryAfterMillis }
27047
27331
  }) });
27048
- var _kernel12, _now, _historyWanted, _sealed, _checkpoints3, _slices, _cachedBytes, _LiveStreamServer_instances, frontier_fn, batch_fn, checkpoint_fn, current_fn, sealedOnMain_fn, outcomes_fn, build_fn, evict_fn, history_fn, buildSlice_fn, ref_fn;
27332
+ var OFF_MAIN_AFTER_MILLIS = 6e4;
27333
+ var MAX_UNFOUND_HEADS = 1024;
27334
+ var _kernel12, _now, _historyWanted, _sealed, _checkpoints3, _slices, _cachedBytes, _unfound, _LiveStreamServer_instances, frontier_fn, shallow_fn, batch_fn, checkpoint_fn, current_fn, sealedOnMain_fn, outcomes_fn, build_fn, evict_fn, history_fn, buildSlice_fn, ref_fn;
27049
27335
  var LiveStreamServer = class {
27050
27336
  constructor(kernel, now2 = Date.now, historyWanted = () => {
27051
27337
  }, sealed = () => void 0) {
@@ -27062,6 +27348,10 @@
27062
27348
  /** By workspace: the history slices copies are fetching (a few, newest last). */
27063
27349
  __privateAdd(this, _slices, /* @__PURE__ */ new Map());
27064
27350
  __privateAdd(this, _cachedBytes, 0);
27351
+ /** By workspace and asked head: when this peer first answered "acquiring its own history" to a level
27352
+ * ask from a head it could not find. A shallow custody can never prove the head is off its main (its
27353
+ * walk is never `complete`), so after OFF_MAIN_AFTER_MILLIS of the same answer it says so anyway. */
27354
+ __privateAdd(this, _unfound, /* @__PURE__ */ new Map());
27065
27355
  __privateSet(this, _kernel12, kernel);
27066
27356
  __privateSet(this, _sealed, sealed);
27067
27357
  __privateSet(this, _historyWanted, historyWanted);
@@ -27098,6 +27388,7 @@
27098
27388
  _checkpoints3 = new WeakMap();
27099
27389
  _slices = new WeakMap();
27100
27390
  _cachedBytes = new WeakMap();
27391
+ _unfound = new WeakMap();
27101
27392
  _LiveStreamServer_instances = new WeakSet();
27102
27393
  frontier_fn = function(workspace, requestId, frontier) {
27103
27394
  const mount = workspaceMount(workspace);
@@ -27116,9 +27407,12 @@
27116
27407
  if (!head) return [...answer, ...__privateMethod(this, _LiveStreamServer_instances, checkpoint_fn).call(this, workspace, requestId, create(LiveCheckpointRequestSchema))];
27117
27408
  if (head === main) return answer;
27118
27409
  let behind;
27410
+ let offMain = false;
27119
27411
  try {
27120
27412
  const summary = __privateGet(this, _kernel12).historySummary(mount, requestId, head, main);
27121
27413
  behind = summary.reachedBase ? summary.commitCount : void 0;
27414
+ offMain = !summary.reachedBase && (summary.complete || !__privateMethod(this, _LiveStreamServer_instances, shallow_fn).call(this, mount, requestId));
27415
+ if (summary.reachedBase) __privateGet(this, _unfound).delete(`${workspace}\0${head}`);
27122
27416
  } catch {
27123
27417
  behind = void 0;
27124
27418
  }
@@ -27127,6 +27421,22 @@
27127
27421
  if (remountAfter > 0) {
27128
27422
  return [...answer, ...__privateMethod(this, _LiveStreamServer_instances, checkpoint_fn).call(this, workspace, requestId, create(LiveCheckpointRequestSchema), behind ?? 0n)];
27129
27423
  }
27424
+ const key = `${workspace}\0${head}`;
27425
+ const firstUnfound = __privateGet(this, _unfound).get(key);
27426
+ if (!offMain && firstUnfound === void 0) {
27427
+ if (__privateGet(this, _unfound).size >= MAX_UNFOUND_HEADS) __privateGet(this, _unfound).delete(__privateGet(this, _unfound).keys().next().value);
27428
+ __privateGet(this, _unfound).set(key, __privateGet(this, _now).call(this));
27429
+ } else if (!offMain && __privateGet(this, _now).call(this) - firstUnfound >= OFF_MAIN_AFTER_MILLIS) {
27430
+ offMain = true;
27431
+ }
27432
+ if (offMain) {
27433
+ __privateGet(this, _unfound).delete(key);
27434
+ return [...answer, refusal(
27435
+ "",
27436
+ "nomos.stream.off_main",
27437
+ "the copy's head is not on this peer's main; it must converge its own work, not level from it"
27438
+ )];
27439
+ }
27130
27440
  __privateGet(this, _historyWanted).call(this, workspace);
27131
27441
  return [...answer, refusal(
27132
27442
  "",
@@ -27138,6 +27448,17 @@
27138
27448
  const maxOffers = Math.min(Math.max(1, frontier.maxOffers || MAX_STREAM_BATCH_OFFERS), MAX_STREAM_BATCH_OFFERS);
27139
27449
  return [...answer, __privateMethod(this, _LiveStreamServer_instances, batch_fn).call(this, workspace, requestId, head, main, maxOffers)];
27140
27450
  };
27451
+ /** Whether this peer's custody of the workspace is shallow. Unknown counts as shallow: it keeps the
27452
+ * existing wait for history rather than calling a head off main. */
27453
+ shallow_fn = function(mount, requestId) {
27454
+ const boundaries = __privateGet(this, _kernel12).shallowBoundaries;
27455
+ if (!boundaries) return true;
27456
+ try {
27457
+ return boundaries.call(__privateGet(this, _kernel12), mount, requestId).length > 0;
27458
+ } catch {
27459
+ return true;
27460
+ }
27461
+ };
27141
27462
  /**
27142
27463
  * The `maxOffers` offers directly above `base`, as the commits this peer admitted them in: one
27143
27464
  * bounded walk and one bounded pack (O(batch)). The copy's kernel adopts exactly these commits on
@@ -27515,12 +27836,11 @@
27515
27836
  };
27516
27837
  _commits = new WeakMap();
27517
27838
  _requests = new WeakMap();
27518
- var _links, _pending3, _own, _progress, _progressOwedSince, _recounting, _sequence12, _requestId3, _closures, _LiveCorrespondenceDesk_instances, recordClosure_fn, closeByRuntime_fn, count_fn, chain_fn, holds_fn, cursor_fn, effect_fn, open_fn2, send_fn, admitted_fn, declined_fn, announced_fn, placementAnnounced_fn, outcomesDigest_fn, outcomesAnnounced_fn, outcomesArrived_fn, hello_fn, fittingBatch_fn;
27839
+ var _links, _own, _progress, _progressOwedSince, _recounting, _sequence12, _requestId3, _closures, _LiveCorrespondenceDesk_instances, recordClosure_fn, closeByRuntime_fn, count_fn, chain_fn, holds_fn, heldPeerMain_fn, cursor_fn, effect_fn, open_fn2, send_fn, admitted_fn, declined_fn, announced_fn, placementAnnounced_fn, outcomesDigest_fn, outcomesAnnounced_fn, outcomesArrived_fn, fittingBatch_fn;
27519
27840
  var LiveCorrespondenceDesk = class {
27520
27841
  constructor(kernel, events, clock2, relayOrigin, staging) {
27521
27842
  __privateAdd(this, _LiveCorrespondenceDesk_instances);
27522
27843
  __privateAdd(this, _links, /* @__PURE__ */ new Map());
27523
- __privateAdd(this, _pending3, /* @__PURE__ */ new Map());
27524
27844
  /** What procedures asked of each workspace's stream, and what it delivered (peer_catchup.md). */
27525
27845
  __publicField(this, "inbound");
27526
27846
  __privateAdd(this, _own, new OwnOffers());
@@ -27556,13 +27876,6 @@
27556
27876
  * never held. Absent (a custodian, a relay, a test), every write goes out on the next drive.
27557
27877
  */
27558
27878
  __publicField(this, "writeBurst");
27559
- /**
27560
- * An application peer's receive step (CAP-757; sized by time, CAP-762). A received batch of other
27561
- * senders' offers larger than one step is not admitted on the socket, in one kernel-thread hold:
27562
- * the follow receives it instead, in yielding steps of the policy's current size. Absent (a
27563
- * custodian, a relay, a test), every received batch is admitted as it arrives.
27564
- */
27565
- __publicField(this, "receiveStep");
27566
27879
  /** The last progress counted per workspace, served while a burst holds recounting back. */
27567
27880
  __privateAdd(this, _progress, /* @__PURE__ */ new Map());
27568
27881
  /** When a held-back progress recount became owed; it reports at the burst's next due point. */
@@ -27616,10 +27929,12 @@
27616
27929
  sent: link.stream?.sent,
27617
27930
  unansweredAgesMs: (link.stream?.unanswered ?? []).map((entry) => Number((now2 - (entry.due - LIVE_ANSWER_WINDOW)) / 1000000n)),
27618
27931
  custodianLocal: link.custodian?.local,
27619
- convergeDue: link.convergeDue !== void 0
27932
+ convergeDue: link.convergeDue !== void 0,
27933
+ resident: false
27620
27934
  };
27621
27935
  try {
27622
27936
  if (this.kernel.isResident(link.binding.workspace) !== false) {
27937
+ state.resident = true;
27623
27938
  const mount = workspaceMount(link.binding.workspace);
27624
27939
  state.head = this.kernel.head(mount, ++__privateWrapper(this, _requestId3)._);
27625
27940
  state.tracked = this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2);
@@ -27728,7 +28043,7 @@
27728
28043
  evidencePack: options.carryCommits || intents.some((intent) => intent.transportRequirement === IntentTransportRequirement.COMMIT_TREE) ? this.kernel.packDelta(mount, requestId, batchHead, base) : new Uint8Array()
27729
28044
  });
27730
28045
  }
27731
- receive(request, receipt) {
28046
+ receive(receipt) {
27732
28047
  const link = [...__privateGet(this, _links).values()].find((item) => item.id === receipt.connectionId);
27733
28048
  if (!link) return;
27734
28049
  if (receipt.observation.case === "closed" || receipt.observation.case === "closure") {
@@ -27742,6 +28057,7 @@
27742
28057
  link.ownMains = [];
27743
28058
  delete link.lastAnnounced;
27744
28059
  delete link.lastPlacementAnnounced;
28060
+ link.peerMain = void 0;
27745
28061
  link.dirty = true;
27746
28062
  link.due = this.clock.monotonicNanoseconds() + BigInt(Math.min(3e4, 250 * 2 ** Math.min(link.failures++, 7))) * 1000000n;
27747
28063
  return;
@@ -27751,7 +28067,6 @@
27751
28067
  link.openedAt = this.clock.monotonicNanoseconds();
27752
28068
  link.failures = 0;
27753
28069
  link.unheard = void 0;
27754
- if (!link.publisher) __privateMethod(this, _LiveCorrespondenceDesk_instances, hello_fn).call(this, link);
27755
28070
  if (!link.publisher) this.inbound.opened(link.binding.workspace);
27756
28071
  this.linkOpened?.(link.binding.workspace);
27757
28072
  return;
@@ -27785,18 +28100,6 @@
27785
28100
  if (this.inbound.frame(link.binding.workspace, frame2.message)) return;
27786
28101
  if (frame2.message.case === "frontier") {
27787
28102
  __privateMethod(this, _LiveCorrespondenceDesk_instances, announced_fn).call(this, link, frame2.message.value.head);
27788
- if (this.kernel.isResident(link.binding.workspace) === false) return;
27789
- if (!frame2.message.value.response) {
27790
- __privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "frontier", value: {
27791
- head: this.kernel.head(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId3)._) ?? "",
27792
- response: true
27793
- } });
27794
- }
27795
- try {
27796
- const batch2 = this.export(link.binding, frame2.message.value.head, ++__privateWrapper(this, _requestId3)._);
27797
- if (batch2.source.case === "inline" && batch2.source.value.offers.length) __privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "offers", value: batch2 });
27798
- } catch {
27799
- }
27800
28103
  return;
27801
28104
  }
27802
28105
  if (frame2.message.case === "admission") {
@@ -27804,57 +28107,18 @@
27804
28107
  this.progressChanged?.(link.binding.workspace);
27805
28108
  return;
27806
28109
  }
27807
- if (frame2.message.case !== "offers") return;
27808
- const batch = frame2.message.value;
27809
- if (batch.protocolVersion !== 2 || !batch.requestId || batch.source.case !== "inline" || !batch.source.value.offers.length) return;
27810
- const offers = batch.source.value.offers.filter((offer) => !__privateGet(this, _own).hasCommit(link.binding.workspace, offer.commitOid));
27811
- if (!offers.length) return;
27812
- if (this.kernel.isResident(link.binding.workspace) === false && !this.inbound.wanted(link.binding.workspace)) {
27813
- this.remoteAdvanced?.(link.binding.workspace);
27814
- return;
27815
- }
27816
- if (this.receiveStep !== void 0 && offers.length > this.receiveStep.offers) {
27817
- this.remoteAdvanced?.(link.binding.workspace);
27818
- return;
27819
- }
27820
- if ([...__privateGet(this, _pending3).values()].some((pending) => pending.link === link && pending.bytes.length === bytes.length && pending.bytes.every((byte, index) => byte === bytes[index]))) return;
27821
- if (__privateGet(this, _pending3).size >= 32) return;
27822
- __privateGet(this, _pending3).set(request.requestId, { link, bytes });
27823
- return create(RuntimeRequestSchema, {
27824
- protocolVersion: 2,
27825
- requestId: request.requestId,
27826
- target: { workspace: link.binding.workspace, session: link.binding.replicaId },
27827
- // HTTP sender reconciliation controls are not part of a live proposal.
27828
- // Keeping fastForwardOnly while removing baseHead silently skips every
27829
- // offer against a nonempty local head. The Kernel judges sealed causality;
27830
- // live receivers neither ask for a return archive nor confirm the sender.
27831
- command: { case: "admitCustodyOffers", value: create(CustodyOfferBatchRequestSchema, {
27832
- ...batch,
27833
- baseHead: void 0,
27834
- observedHead: void 0,
27835
- fastForwardOnly: false,
27836
- ...offers.length === batch.source.value.offers.length ? {} : { source: { case: "inline", value: { ...batch.source.value, offers } } }
27837
- }) }
27838
- });
28110
+ }
28111
+ /** The newest local commit the custodian admitted unchanged over this workspace's open link: its
28112
+ * main holds that commit, sealed or not, so it is no work to offer (CAP-838). */
28113
+ admittedLocal(workspace) {
28114
+ const link = __privateGet(this, _links).get(workspace);
28115
+ const cursor = link?.state === "open" && !link.publisher ? link.custodian : void 0;
28116
+ return cursor && cursor.main === cursor.local ? cursor.local : void 0;
27839
28117
  }
27840
28118
  /** Offers this replica sent another way (the HTTP lane): their echo on the live link is its own. */
27841
28119
  offered(workspace, commitOids) {
27842
28120
  __privateGet(this, _own).commits(workspace, commitOids);
27843
28121
  }
27844
- /** Whether this request is the admission of a batch relayed to this follower over its live link.
27845
- * Such an admission is never answered to a sender, so it keeps no custody receipts (CAP-759). */
27846
- relayed(requestId) {
27847
- return __privateGet(this, _pending3).has(requestId);
27848
- }
27849
- settled(request, response) {
27850
- if (response.outcome.case === "correspondencePending" || response.outcome.case === "localReadPending") return;
27851
- __privateGet(this, _pending3).delete(request.requestId);
27852
- }
27853
- failed(requestId) {
27854
- const pending = __privateGet(this, _pending3).get(requestId);
27855
- __privateGet(this, _pending3).delete(requestId);
27856
- if (pending) this.remoteAdvanced?.(pending.link.binding.workspace);
27857
- }
27858
28122
  disconnect(workspace) {
27859
28123
  const link = __privateGet(this, _links).get(workspace);
27860
28124
  if (!link) return;
@@ -27862,7 +28126,6 @@
27862
28126
  if (link.state === "open") this.linkClosed?.(workspace, closure);
27863
28127
  __privateGet(this, _links).delete(workspace);
27864
28128
  __privateGet(this, _progress).delete(workspace);
27865
- for (const [id, pending] of __privateGet(this, _pending3)) if (pending.link === link) __privateGet(this, _pending3).delete(id);
27866
28129
  }
27867
28130
  drive() {
27868
28131
  const now2 = this.clock.monotonicNanoseconds();
@@ -27912,7 +28175,8 @@
27912
28175
  link.custodian = void 0;
27913
28176
  }
27914
28177
  __privateMethod(this, _LiveCorrespondenceDesk_instances, cursor_fn).call(this, link, mount);
27915
- const answered2 = link.publisher ? link.published ?? (link.published = head ?? "") : link.custodian?.local ?? this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2) ?? "";
28178
+ let answered2 = link.publisher ? link.published ?? (link.published = head ?? "") : link.custodian?.local ?? this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2) ?? "";
28179
+ if (!link.publisher && !link.custodian) answered2 = __privateMethod(this, _LiveCorrespondenceDesk_instances, heldPeerMain_fn).call(this, link, mount, head, answered2) ?? answered2;
27916
28180
  const fence = link.custodian?.main ?? answered2;
27917
28181
  if (link.stream && !(head && __privateMethod(this, _LiveCorrespondenceDesk_instances, holds_fn).call(this, mount, link.stream.sent, head))) {
27918
28182
  link.stream = void 0;
@@ -27985,11 +28249,9 @@
27985
28249
  }
27986
28250
  close() {
27987
28251
  for (const workspace of [...__privateGet(this, _links).keys()]) this.disconnect(workspace);
27988
- __privateGet(this, _pending3).clear();
27989
28252
  }
27990
28253
  };
27991
28254
  _links = new WeakMap();
27992
- _pending3 = new WeakMap();
27993
28255
  _own = new WeakMap();
27994
28256
  _progress = new WeakMap();
27995
28257
  _progressOwedSince = new WeakMap();
@@ -28035,7 +28297,7 @@
28035
28297
  };
28036
28298
  count_fn = function(link, mount) {
28037
28299
  const head = this.kernel.head(mount, ++__privateWrapper(this, _requestId3)._);
28038
- const acknowledged = __privateMethod(this, _LiveCorrespondenceDesk_instances, cursor_fn).call(this, link, mount)?.local ?? this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2);
28300
+ const acknowledged = __privateMethod(this, _LiveCorrespondenceDesk_instances, cursor_fn).call(this, link, mount)?.local ?? __privateMethod(this, _LiveCorrespondenceDesk_instances, heldPeerMain_fn).call(this, link, mount, head) ?? this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2);
28039
28301
  if (!head || !acknowledged) return void 0;
28040
28302
  const count = (base, tip) => {
28041
28303
  if (base === tip) return 0;
@@ -28069,6 +28331,14 @@
28069
28331
  holds_fn = function(mount, base, tip) {
28070
28332
  return __privateMethod(this, _LiveCorrespondenceDesk_instances, chain_fn).call(this, mount, base, tip)?.reachedBase === true;
28071
28333
  };
28334
+ /** The custodian's main as last heard, when this copy holds it on its own head's chain above the
28335
+ * sealed bookmark: the commits up to it came from the stream and are the custodian's (CAP-838). */
28336
+ heldPeerMain_fn = function(link, mount, head, tracked = this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2)) {
28337
+ const main = link.peerMain;
28338
+ if (!main || !head || main === tracked) return void 0;
28339
+ if (tracked && !__privateMethod(this, _LiveCorrespondenceDesk_instances, holds_fn).call(this, mount, tracked, main)) return void 0;
28340
+ return __privateMethod(this, _LiveCorrespondenceDesk_instances, holds_fn).call(this, mount, main, head) ? main : void 0;
28341
+ };
28072
28342
  /** This connection's admission cursor, while it still leads the saved bookmark. A cursor on local
28073
28343
  * history (admitted, not yet sealed) remembers the bookmark it was set above; once anything else
28074
28344
  * moves the bookmark (a follow round adopting the custodian's main) the bookmark rules again, so
@@ -28122,9 +28392,10 @@
28122
28392
  ...admission.sealedMain ? { sealed: admission.sealedMain } : {}
28123
28393
  };
28124
28394
  }
28125
- if (!admission?.main || this.kernel.isResident(workspace) === false) return;
28395
+ if (!admission?.main) return;
28126
28396
  const ownBatchHead = __privateGet(this, _own).batchHead(workspace, live.requestId);
28127
28397
  const ours = ownBatchHead !== void 0;
28398
+ if (this.kernel.isResident(workspace) === false) return;
28128
28399
  let stale = false;
28129
28400
  if (ours) link.unheard = void 0;
28130
28401
  if (ours && link.stream) {
@@ -28212,6 +28483,7 @@
28212
28483
  * upstream head it already recorded. Re-announcing a known frontier - which is all an
28213
28484
  * upstream can do while this replica is ahead or held on a dependency - is not an event. */
28214
28485
  announced_fn = function(link, head) {
28486
+ if (head) link.peerMain = head;
28215
28487
  if (!head || link.lastAnnounced === head) return;
28216
28488
  link.lastAnnounced = head;
28217
28489
  if (this.kernel.isResident(link.binding.workspace) === false) {
@@ -28272,14 +28544,6 @@
28272
28544
  transfer.retain(create(PeerGitRefsFetchedSchema, { refs: [...wanted.refs], pack }));
28273
28545
  this.progressChanged?.(link.binding.workspace);
28274
28546
  };
28275
- hello_fn = function(link) {
28276
- if (this.kernel.isResident(link.binding.workspace) === false) return;
28277
- const head = this.kernel.head(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId3)._);
28278
- __privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "frontier", value: {
28279
- head: head ?? "",
28280
- outcomesDigest: __privateMethod(this, _LiveCorrespondenceDesk_instances, outcomesDigest_fn).call(this, link.binding.workspace)
28281
- } });
28282
- };
28283
28547
  /**
28284
28548
  * A follower's next batch above `base`: up to the link's commit bound, cut down until its carried
28285
28549
  * commits fit LIVE_CARRIED_COMMITS_BYTES and its frame fits MAX_LIVE_FRAME_BYTES. A single commit
@@ -29319,6 +29583,7 @@
29319
29583
  var RECEIVED_PLACEMENT_REF = "refs/remotes/nomos/placement";
29320
29584
  var STREAM_BATCH_OFFERS = 64;
29321
29585
  var REMOUNT_AFTER_OFFERS = 128;
29586
+ var MAX_REMOUNTS_LOST = 2;
29322
29587
  var HISTORY_SLICES = [8, 64, 256, 256];
29323
29588
  var WorkspaceSyncPhase = Object.freeze({
29324
29589
  Idle: "idle",
@@ -29339,13 +29604,17 @@
29339
29604
  var judgedThisLifetime = /* @__PURE__ */ new Map();
29340
29605
  function releaseSyncJudgment(workspace) {
29341
29606
  judgedThisLifetime.delete(workspace);
29607
+ notContainedThisLifetime.delete(workspace);
29342
29608
  }
29609
+ var notContainedThisLifetime = /* @__PURE__ */ new Map();
29610
+ var MAX_NOT_CONTAINED = 1024;
29611
+ var NOT_CONTAINED_REFUSALS = /* @__PURE__ */ new Set(["nomos.stream.off_main", "nomos.stream.history_required"]);
29343
29612
  var MAX_REBASES_PER_ROUND = 2;
29344
29613
  var elapsedMillis = (clock2, started) => {
29345
29614
  const finished = clock2.monotonicNanoseconds();
29346
29615
  return finished >= started ? Number(finished - started) / 1e6 : 0;
29347
29616
  };
29348
- var _kernel18, _credentials4, _clock14, _mount2, _binding, _route2, _rediscover, _reroute, _discoveredFrontier, _observePlacement, _recheckPlacement, _directoryAnswered, _placementFetched, _acquired, _streamSequence, _historySlices, _levelling, _boundaries, _sealedObserved, _command2, _requestId5, _started, _state, _localHead, _offerHead, _previousHead, _pushMillis, _pushBytes, _desiredHead, _candidateDurable, _admissionSummary, _offerReceipt, _pushError, _current3, _lastReceiptEffectId2, _offerSequence, _lastStep2, _probeOnly, _liveConnected, _establishedBase, _receiveState, _completeHistory, _lawProductsImported, _lawProductsInFlight, _shallowMounted, _fetchedLawProducts, _beforeConverge, _needsReconciliation, _offerAfterConverge, _rebaseFrom, _rebases, _parkedLocal, _replaceLocalHead, _repairMissingCommit, _receiveStep, _offered, _receiveSteps, _WorkspaceSyncWork_instances, openRound_fn, offerOrReconcile_fn, establishBase_fn, missingTrackedBase_fn, holdsLocalWork_fn, pullBeforeOffer_fn, acquire_fn, lawProductsFetch_fn, streamEffect_fn, acceptStream_fn, importStep_fn, imported_fn, historyOrMount_fn, remount_fn, beginOffer_fn, acceptOffer_fn, placementFrontier_fn, placementOnly_fn, acceptDiscovery_fn, providerCustody_fn, mountFetched_fn, lawProductsRequest_fn, acceptLawProducts_fn, providerCustodyMounted_fn, importLawProducts_fn, converge_fn2, convergeStep_fn, unrelatedLineageRefusal_fn, replaceLocal_fn, converged_fn, offerAfterRebase_fn, preservedCopy_fn, alreadyJudged_fn, rememberJudgment_fn, forgetJudgment_fn, present_fn, finishOfferOutcome_fn, finishWarming_fn, transportFailure_fn, remember_fn4, finish_fn2, cloudBase_fn, offerEndpoint_fn, workspaceEndpoint_fn, authToken_fn;
29617
+ var _kernel18, _credentials4, _clock14, _mount2, _binding, _route2, _rediscover, _reroute, _discoveredFrontier, _observePlacement, _recheckPlacement, _directoryAnswered, _placementFetched, _acquired, _streamSequence, _historySlices, _levelling, _boundaries, _sealedObserved, _command2, _requestId5, _started, _state, _localHead, _offerHead, _previousHead, _pushMillis, _pushBytes, _desiredHead, _candidateDurable, _admissionSummary, _offerReceipt, _pushError, _current3, _lastReceiptEffectId2, _offerSequence, _lastStep2, _probeOnly, _liveConnected, _liveAdmitted, _establishedBase, _receiveState, _completeHistory, _lawProductsImported, _lawProductsInFlight, _shallowMounted, _fetchedLawProducts, _beforeConverge, _needsReconciliation, _offerAfterConverge, _rebaseFrom, _rebases, _remountsLost, _containment, _containedBookmark, _parkedLocal, _replaceLocalHead, _repairMissingCommit, _receiveStep, _offered, _receiveSteps, _WorkspaceSyncWork_instances, openRound_fn, mayBeContained_fn, custodianMainOffLocalChain_fn, askContainment_fn, contained_fn, notContained_fn, offerOrReconcile_fn, establishBase_fn, missingTrackedBase_fn, holdsLocalWork_fn, holdsUnsyncedCommits_fn, pullBeforeOffer_fn, acquire_fn, lawProductsFetch_fn, streamEffect_fn, acceptStream_fn, importStep_fn, imported_fn, historyOrMount_fn, remount_fn, remountLost_fn, beginOffer_fn, acceptOffer_fn, placementFrontier_fn, placementOnly_fn, acceptDiscovery_fn, providerCustody_fn, mountFetched_fn, lawProductsRequest_fn, acceptLawProducts_fn, providerCustodyMounted_fn, importLawProducts_fn, converge_fn2, convergeStep_fn, unrelatedLineageRefusal_fn, replaceLocal_fn, converged_fn, offerAfterRebase_fn, preservedCopy_fn, alreadyJudged_fn, rememberJudgment_fn, forgetJudgment_fn, present_fn, finishOfferOutcome_fn, finishWarming_fn, transportFailure_fn, remember_fn4, finish_fn2, cloudBase_fn, offerEndpoint_fn, workspaceEndpoint_fn, authToken_fn;
29349
29618
  var WorkspaceSyncWork = class {
29350
29619
  constructor(args) {
29351
29620
  __privateAdd(this, _WorkspaceSyncWork_instances);
@@ -29398,6 +29667,7 @@
29398
29667
  __privateAdd(this, _lastStep2);
29399
29668
  __privateAdd(this, _probeOnly);
29400
29669
  __privateAdd(this, _liveConnected);
29670
+ __privateAdd(this, _liveAdmitted);
29401
29671
  /** Set when this round adopted the upstream's own head as its base (see #establishBase). */
29402
29672
  __privateAdd(this, _establishedBase);
29403
29673
  __privateAdd(this, _receiveState);
@@ -29414,6 +29684,11 @@
29414
29684
  /** The custodian head this round last offered or pulled from. */
29415
29685
  __privateAdd(this, _rebaseFrom);
29416
29686
  __privateAdd(this, _rebases, 0);
29687
+ __privateAdd(this, _remountsLost, 0);
29688
+ /** This round's level ask is a containment question (CAP-870): on a refusal, take this path. */
29689
+ __privateAdd(this, _containment);
29690
+ /** The stale bookmark a contained round replaces: its custodian's main holds the local head. */
29691
+ __privateAdd(this, _containedBookmark);
29417
29692
  /** Local intents this round's rebase refused and parked on the refused-offer desk. */
29418
29693
  __privateAdd(this, _parkedLocal, 0);
29419
29694
  /** An application-authorized drop: replace local custody at exactly this head. */
@@ -29430,6 +29705,7 @@
29430
29705
  __privateSet(this, _placementFetched, args.placementFetched);
29431
29706
  __privateSet(this, _probeOnly, args.probeOnly ?? false);
29432
29707
  __privateSet(this, _liveConnected, args.liveConnected === true);
29708
+ __privateSet(this, _liveAdmitted, args.liveAdmitted);
29433
29709
  __privateSet(this, _receiveState, args.receiveState);
29434
29710
  __privateSet(this, _completeHistory, args.completeHistory === true);
29435
29711
  __privateSet(this, _repairMissingCommit, args.repairMissingCommit === true);
@@ -29585,6 +29861,7 @@
29585
29861
  _lastStep2 = new WeakMap();
29586
29862
  _probeOnly = new WeakMap();
29587
29863
  _liveConnected = new WeakMap();
29864
+ _liveAdmitted = new WeakMap();
29588
29865
  _establishedBase = new WeakMap();
29589
29866
  _receiveState = new WeakMap();
29590
29867
  _completeHistory = new WeakMap();
@@ -29597,6 +29874,9 @@
29597
29874
  _offerAfterConverge = new WeakMap();
29598
29875
  _rebaseFrom = new WeakMap();
29599
29876
  _rebases = new WeakMap();
29877
+ _remountsLost = new WeakMap();
29878
+ _containment = new WeakMap();
29879
+ _containedBookmark = new WeakMap();
29600
29880
  _parkedLocal = new WeakMap();
29601
29881
  _replaceLocalHead = new WeakMap();
29602
29882
  _repairMissingCommit = new WeakMap();
@@ -29608,9 +29888,15 @@
29608
29888
  if (__privateGet(this, _receiveState)) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "full");
29609
29889
  if (__privateGet(this, _replaceLocalHead) !== void 0) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, __privateGet(this, _repairMissingCommit) ? "full" : "mount");
29610
29890
  if (!__privateGet(this, _localHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, __privateGet(this, _completeHistory) ? "full" : "mount");
29611
- if (__privateGet(this, _liveConnected) && !__privateGet(this, _probeOnly) && __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _previousHead)) {
29612
- return __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
29891
+ const unadmitted = __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _localHead) !== __privateGet(this, _liveAdmitted);
29892
+ if (__privateGet(this, _liveConnected) && unadmitted && __privateGet(this, _previousHead)) {
29893
+ if (__privateMethod(this, _WorkspaceSyncWork_instances, mayBeContained_fn).call(this)) return __privateMethod(this, _WorkspaceSyncWork_instances, askContainment_fn).call(this, "offer");
29894
+ return __privateMethod(this, _WorkspaceSyncWork_instances, notContained_fn).call(this);
29613
29895
  }
29896
+ if (__privateGet(this, _liveConnected) && __privateGet(this, _probeOnly) && __privateGet(this, _previousHead) && __privateMethod(this, _WorkspaceSyncWork_instances, holdsUnsyncedCommits_fn).call(this) && __privateGet(this, _command2).admit && __privateGet(this, _localHead) === __privateGet(this, _liveAdmitted)) {
29897
+ return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "level");
29898
+ }
29899
+ if (__privateGet(this, _liveConnected) && !__privateGet(this, _probeOnly) && !unadmitted) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "level");
29614
29900
  const requestId = `${__privateGet(this, _binding).replicaId}:${__privateGet(this, _requestId5)}:${this.workId}:frontier`;
29615
29901
  return __privateMethod(this, _WorkspaceSyncWork_instances, beginOffer_fn).call(this, encodeInlineCustodyOffer({
29616
29902
  session: __privateGet(this, _binding).replicaId,
@@ -29619,6 +29905,60 @@
29619
29905
  intents: []
29620
29906
  }), { case: "awaiting", requestId }, true);
29621
29907
  };
29908
+ /** Whether the custodian's main may hold this copy's head: not already refused in this lifetime. */
29909
+ mayBeContained_fn = function() {
29910
+ return !!__privateGet(this, _localHead) && __privateGet(this, _offerHead) === void 0 && notContainedThisLifetime.get(__privateGet(this, _mount2).workspace) !== __privateGet(this, _localHead);
29911
+ };
29912
+ /** The probe named a custodian main that is not on this copy's own chain, so the copy's head may be
29913
+ * on the custodian's. A main below the local head (the custodian is behind) cannot contain it. A
29914
+ * complete copy answers a main it does not hold after one existence check, and one it holds after
29915
+ * a walk to where the two chains join. A kernel that cannot say keeps the existing path. */
29916
+ custodianMainOffLocalChain_fn = function() {
29917
+ if (!__privateGet(this, _kernel18).historySummary || !__privateGet(this, _desiredHead) || !__privateGet(this, _localHead)) return false;
29918
+ try {
29919
+ return !__privateGet(this, _kernel18).historySummary(__privateGet(this, _mount2), __privateGet(this, _requestId5), __privateGet(this, _desiredHead), __privateGet(this, _localHead)).reachedBase;
29920
+ } catch (error) {
29921
+ return error instanceof KernelHistoryRequired;
29922
+ }
29923
+ };
29924
+ /** Level from the local head (CAP-870). The stream answers with the custodian's commits above it
29925
+ * (or "level") only when its main holds that head; then this round converges onto them, moves the
29926
+ * bookmark, and offers nothing. One custodian lookup, O(commits behind); no local enumeration. */
29927
+ askContainment_fn = function(otherwise) {
29928
+ __privateSet(this, _containment, otherwise);
29929
+ return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "level");
29930
+ };
29931
+ /** The stream answered from the local head: it is on the custodian's main. The stale bookmark
29932
+ * stays this round's to replace; the local head is the round's base from here. */
29933
+ contained_fn = function() {
29934
+ __privateSet(this, _containment, void 0);
29935
+ __privateSet(this, _containedBookmark, __privateGet(this, _previousHead));
29936
+ __privateSet(this, _previousHead, __privateGet(this, _localHead));
29937
+ };
29938
+ /** The custodian's main does not hold the local head (or the stream could not say): the copy holds
29939
+ * work of its own. Go straight on to the pull/rebase/offer path. A dependency planner's probe hands
29940
+ * the round back to it to plan the outbound suffix. */
29941
+ notContained_fn = function(code) {
29942
+ const otherwise = __privateGet(this, _containment) ?? "offer";
29943
+ __privateSet(this, _containment, void 0);
29944
+ if (code !== void 0 && NOT_CONTAINED_REFUSALS.has(code) && __privateGet(this, _localHead)) {
29945
+ if (notContainedThisLifetime.size >= MAX_NOT_CONTAINED && !notContainedThisLifetime.has(__privateGet(this, _mount2).workspace)) {
29946
+ notContainedThisLifetime.delete(notContainedThisLifetime.keys().next().value);
29947
+ }
29948
+ notContainedThisLifetime.set(__privateGet(this, _mount2).workspace, __privateGet(this, _localHead));
29949
+ }
29950
+ if (__privateGet(this, _probeOnly)) {
29951
+ __privateSet(this, _needsReconciliation, true);
29952
+ return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
29953
+ workspace: __privateGet(this, _mount2).workspace,
29954
+ currentHead: __privateGet(this, _localHead),
29955
+ previousHead: __privateGet(this, _previousHead),
29956
+ stillAhead: true,
29957
+ offerReceipt: __privateGet(this, _offerReceipt)
29958
+ }));
29959
+ }
29960
+ return otherwise === "pull" ? __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this) : __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
29961
+ };
29622
29962
  offerOrReconcile_fn = function() {
29623
29963
  var _a;
29624
29964
  if (__privateGet(this, _command2).admit && __privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead)) {
@@ -29693,7 +30033,14 @@
29693
30033
  return __privateGet(this, _previousHead) === void 0 && __privateGet(this, _localHead) !== void 0 && __privateGet(this, _replaceLocalHead) === void 0;
29694
30034
  };
29695
30035
  holdsLocalWork_fn = function() {
29696
- return __privateGet(this, _command2).admit && !!__privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead);
30036
+ return __privateGet(this, _command2).admit && __privateMethod(this, _WorkspaceSyncWork_instances, holdsUnsyncedCommits_fn).call(this);
30037
+ };
30038
+ /** Commits on local main the provider has not been seen to admit, whether or not this round may
30039
+ * offer them. Remount replaces local main, so it asks this, never the admit-gated question: a copy
30040
+ * holding unsynced work is offered and rebased, never remounted. A copy without a bookmark cannot
30041
+ * prove it holds nothing of its own. */
30042
+ holdsUnsyncedCommits_fn = function() {
30043
+ return !!__privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead);
29697
30044
  };
29698
30045
  /** Ask only for the custodian's delta; the offer follows once this peer has rebased. */
29699
30046
  pullBeforeOffer_fn = function() {
@@ -29731,13 +30078,13 @@
29731
30078
  }
29732
30079
  if (purpose === "level") {
29733
30080
  __privateSet(this, _state, { phase: WorkspaceSyncPhase.Stream, purpose, startedAt });
29734
- return __privateMethod(this, _WorkspaceSyncWork_instances, streamEffect_fn).call(this, "level", { case: "level", value: create(LiveFrontierSchema, {
30081
+ return __privateMethod(this, _WorkspaceSyncWork_instances, streamEffect_fn).call(this, __privateGet(this, _containment) ? "contain" : "level", { case: "level", value: create(LiveFrontierSchema, {
29735
30082
  head: __privateGet(this, _localHead) ?? "",
29736
30083
  response: false,
29737
30084
  maxOffers: __privateGet(this, _receiveStep)?.offers ?? STREAM_BATCH_OFFERS,
29738
30085
  // Only a copy holding no work above its bookmark may be remounted instead of replaying, and
29739
30086
  // never one whose durable copy must hold the complete history (a head-only mount it cannot keep).
29740
- remountAfterOffers: __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) || __privateGet(this, _completeHistory) ? 0 : REMOUNT_AFTER_OFFERS
30087
+ remountAfterOffers: __privateMethod(this, _WorkspaceSyncWork_instances, holdsUnsyncedCommits_fn).call(this) || __privateGet(this, _completeHistory) ? 0 : REMOUNT_AFTER_OFFERS
29741
30088
  }) });
29742
30089
  }
29743
30090
  const outcomes = new EffectOutcomeTransfer(__privateGet(this, _kernel18), __privateGet(this, _mount2), __privateGet(this, _requestId5));
@@ -29811,6 +30158,7 @@
29811
30158
  }
29812
30159
  if (answer.outcome.case === "refusal") {
29813
30160
  const refusal2 = answer.outcome.value;
30161
+ if (state.purpose === "level" && __privateGet(this, _containment)) return __privateMethod(this, _WorkspaceSyncWork_instances, notContained_fn).call(this, refusal2.code);
29814
30162
  if (state.afterPlacement) return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, state.afterPlacement);
29815
30163
  return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, `${refusal2.code}: ${refusal2.message}`, false);
29816
30164
  }
@@ -29843,6 +30191,11 @@
29843
30191
  for (const boundary of slice.shallow) __privateGet(this, _boundaries).add(boundary);
29844
30192
  return __privateMethod(this, _WorkspaceSyncWork_instances, historyOrMount_fn).call(this, state.candidateHead, state.receivedBytes + Number(answer.receivedBytes), state.startedAt);
29845
30193
  }
30194
+ if (state.purpose === "level" && __privateGet(this, _containment)) {
30195
+ const answeredFromHead = answer.outcome.case === "level" || answer.outcome.case === "pack" && answer.outcome.value.base === __privateGet(this, _localHead);
30196
+ if (!answeredFromHead) return __privateMethod(this, _WorkspaceSyncWork_instances, notContained_fn).call(this);
30197
+ __privateMethod(this, _WorkspaceSyncWork_instances, contained_fn).call(this);
30198
+ }
29846
30199
  if (state.purpose === "level" && answer.outcome.case === "pack" && answer.outcome.value.base) {
29847
30200
  const batch = answer.outcome.value;
29848
30201
  if (batch.base !== __privateGet(this, _previousHead) && batch.base !== __privateGet(this, _kernel18).head(__privateGet(this, _mount2), __privateGet(this, _requestId5))) {
@@ -29981,13 +30334,19 @@
29981
30334
  /**
29982
30335
  * A copy holding no work above its bookmark, too far behind to replay the backlog: mount the
29983
30336
  * peer's checkpoint in place of its exact local main (O(state), the same trust as a cold mount).
29984
- * The kernel keeps the replaced head at refs/heads/custody-preserved/<old>; that head was only a
29985
- * bookmark of the provider's own main, so the preservation is released at once.
30337
+ * The kernel keeps the replaced head at refs/heads/custody-preserved/<old>. That ref is custody the
30338
+ * kernel guards (custody may not delete an effectful branch), so it is left where it is: a remount
30339
+ * that deleted it threw after main had already moved, leaving the bookmark behind main and the
30340
+ * round failed for ever (2026-10-08, estate-5b493d6b).
30341
+ *
30342
+ * The copy may have moved while the checkpoint streamed (a live batch, a local write). Then it is
30343
+ * no longer the copy the remount was asked for: take the round up again from its new head. Local
30344
+ * work is offered first; a copy that is still only behind asks to level again.
29986
30345
  */
29987
30346
  remount_fn = function(candidateHead, receivedBytes, prefetchMillis) {
29988
30347
  const expected = __privateGet(this, _kernel18).head(__privateGet(this, _mount2), __privateGet(this, _requestId5));
29989
- if (expected === void 0 || expected !== __privateGet(this, _localHead) || __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this)) {
29990
- return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, "the copy changed while its remount was streaming", false);
30348
+ if (expected === void 0 || expected !== __privateGet(this, _localHead) || __privateMethod(this, _WorkspaceSyncWork_instances, holdsUnsyncedCommits_fn).call(this)) {
30349
+ return __privateMethod(this, _WorkspaceSyncWork_instances, remountLost_fn).call(this, expected);
29991
30350
  }
29992
30351
  const started = __privateGet(this, _clock14).monotonicNanoseconds();
29993
30352
  if (candidateHead !== expected) {
@@ -29995,7 +30354,6 @@
29995
30354
  if (!restored.accepted || restored.head !== candidateHead) {
29996
30355
  throw new Error(`kernel refused to remount '${__privateGet(this, _mount2).workspace}' at ${candidateHead}`);
29997
30356
  }
29998
- __privateGet(this, _kernel18).deleteRef?.(__privateGet(this, _mount2), __privateGet(this, _requestId5), `refs/heads/custody-preserved/${expected}`);
29999
30357
  __privateMethod(this, _WorkspaceSyncWork_instances, providerCustodyMounted_fn).call(this);
30000
30358
  }
30001
30359
  return __privateMethod(this, _WorkspaceSyncWork_instances, converged_fn).call(this, create(SyncResponseSchema, {
@@ -30005,6 +30363,25 @@
30005
30363
  admittedRemoteHead: candidateHead
30006
30364
  }), candidateHead, receivedBytes, prefetchMillis, started);
30007
30365
  };
30366
+ /** The remount's copy changed under it. Bounded: a copy that keeps moving under live traffic is
30367
+ * levelled by its live link anyway, and the next round starts from wherever it got to. */
30368
+ remountLost_fn = function(head) {
30369
+ if (head === void 0 || ++__privateWrapper(this, _remountsLost)._ > MAX_REMOUNTS_LOST) {
30370
+ return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, "the copy changed while its remount was streaming", false);
30371
+ }
30372
+ __privateSet(this, _localHead, head);
30373
+ __privateSet(this, _previousHead, __privateGet(this, _kernel18).resolveRef(__privateGet(this, _mount2), __privateGet(this, _requestId5), trackedMain));
30374
+ if (__privateGet(this, _desiredHead) === __privateGet(this, _localHead)) {
30375
+ return __privateMethod(this, _WorkspaceSyncWork_instances, converged_fn).call(this, create(SyncResponseSchema, {
30376
+ admitted: true,
30377
+ head,
30378
+ candidateHead: head,
30379
+ admittedRemoteHead: head
30380
+ }), head, 0, 0);
30381
+ }
30382
+ if (__privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _desiredHead) !== __privateGet(this, _previousHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this);
30383
+ return __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
30384
+ };
30008
30385
  beginOffer_fn = function(body, exchange, probe = false) {
30009
30386
  const phase = probe ? WorkspaceSyncPhase.Probe : WorkspaceSyncPhase.Offer;
30010
30387
  __privateSet(this, _state, { phase, exchange });
@@ -30125,6 +30502,10 @@
30125
30502
  offerReceipt: __privateGet(this, _offerReceipt)
30126
30503
  }));
30127
30504
  }
30505
+ const custodianMoved = __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _desiredHead) !== __privateGet(this, _previousHead);
30506
+ if (custodianMoved && __privateMethod(this, _WorkspaceSyncWork_instances, mayBeContained_fn).call(this) && __privateMethod(this, _WorkspaceSyncWork_instances, custodianMainOffLocalChain_fn).call(this)) {
30507
+ return __privateMethod(this, _WorkspaceSyncWork_instances, askContainment_fn).call(this, "pull");
30508
+ }
30128
30509
  if (__privateGet(this, _probeOnly)) {
30129
30510
  __privateSet(this, _needsReconciliation, true);
30130
30511
  return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
@@ -30135,9 +30516,7 @@
30135
30516
  offerReceipt: __privateGet(this, _offerReceipt)
30136
30517
  }));
30137
30518
  }
30138
- if (__privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _desiredHead) !== __privateGet(this, _previousHead)) {
30139
- return __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this);
30140
- }
30519
+ if (custodianMoved) return __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this);
30141
30520
  return __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
30142
30521
  }
30143
30522
  __privateSet(this, _admissionSummary, summarizeCustodyAdmission(admission));
@@ -30452,7 +30831,8 @@
30452
30831
  }));
30453
30832
  };
30454
30833
  converged_fn = function(verdict, candidateHead, receivedBytes, prefetchMillis, started = __privateGet(this, _clock14).monotonicNanoseconds(), rebirth) {
30455
- if (verdict.admitted && __privateGet(this, _candidateDurable) && candidateHead !== __privateGet(this, _previousHead) && __privateGet(this, _kernel18).resolveRef(__privateGet(this, _mount2), __privateGet(this, _requestId5), trackedMain) === __privateGet(this, _previousHead)) {
30834
+ const tracked = verdict.admitted && __privateGet(this, _candidateDurable) ? __privateGet(this, _kernel18).resolveRef(__privateGet(this, _mount2), __privateGet(this, _requestId5), trackedMain) : void 0;
30835
+ if (verdict.admitted && __privateGet(this, _candidateDurable) && tracked !== candidateHead && (tracked === __privateGet(this, _previousHead) || __privateGet(this, _containedBookmark) !== void 0 && tracked === __privateGet(this, _containedBookmark))) {
30456
30836
  __privateGet(this, _kernel18).writeRef(
30457
30837
  __privateGet(this, _mount2),
30458
30838
  __privateGet(this, _requestId5),
@@ -30737,10 +31117,16 @@
30737
31117
  __privateSet(this, _plan2, [__privateGet(this, _args).root]);
30738
31118
  return __privateMethod(this, _WorkspaceDependencySyncWork_instances, advance_fn4).call(this);
30739
31119
  }
30740
- if (__privateGet(this, _args).liveConnected && __privateGet(this, _args).kernel.resolveRef(__privateGet(this, _args).root.mount, __privateGet(this, _args).requestId, trackedMain2)) {
31120
+ const { kernel, requestId, root } = __privateGet(this, _args);
31121
+ const tracked = __privateGet(this, _args).liveConnected ? kernel.resolveRef(root.mount, requestId, trackedMain2) : void 0;
31122
+ if (tracked && kernel.head(root.mount, requestId) === tracked) {
30741
31123
  __privateSet(this, _plan2, __privateMethod(this, _WorkspaceDependencySyncWork_instances, planDependencies_fn).call(this));
30742
31124
  return __privateMethod(this, _WorkspaceDependencySyncWork_instances, advance_fn4).call(this);
30743
31125
  }
31126
+ if (tracked) {
31127
+ __privateSet(this, _current4, __privateMethod(this, _WorkspaceDependencySyncWork_instances, work_fn).call(this, root, `${this.workId}:contain`, true));
31128
+ return __privateMethod(this, _WorkspaceDependencySyncWork_instances, accept_fn).call(this, __privateGet(this, _current4).start());
31129
+ }
30744
31130
  __privateSet(this, _current4, __privateMethod(this, _WorkspaceDependencySyncWork_instances, work_fn).call(this, __privateGet(this, _args).root, `${this.workId}:frontier`, true));
30745
31131
  return __privateMethod(this, _WorkspaceDependencySyncWork_instances, accept_fn).call(this, __privateGet(this, _current4).start());
30746
31132
  }
@@ -31784,7 +32170,7 @@
31784
32170
  Letter: 0,
31785
32171
  Correspondent: 1
31786
32172
  });
31787
- var _delivery, _kernel20, _mailboxUrl, _settlement, _retention2, _admitted, _awaitingObservation, _pending4, _targetCall, _deferredRetryAfterMillis, _retryScope, _retaining, _settled2, _acquireOmittedHistory, _RemoteWorkspaceEffectDeliveryWork_instances, transportFailed_fn, advance_fn5, observeTargetOffer_fn, postTargetOffer_fn;
32173
+ var _delivery, _kernel20, _mailboxUrl, _settlement, _retention2, _admitted, _awaitingObservation, _pending3, _targetCall, _deferredRetryAfterMillis, _retryScope, _retaining, _settled2, _acquireOmittedHistory, _RemoteWorkspaceEffectDeliveryWork_instances, transportFailed_fn, advance_fn5, observeTargetOffer_fn, postTargetOffer_fn;
31788
32174
  var RemoteWorkspaceEffectDeliveryWork = class {
31789
32175
  constructor(args) {
31790
32176
  __privateAdd(this, _RemoteWorkspaceEffectDeliveryWork_instances);
@@ -31796,7 +32182,7 @@
31796
32182
  __privateAdd(this, _retention2);
31797
32183
  __privateAdd(this, _admitted);
31798
32184
  __privateAdd(this, _awaitingObservation, false);
31799
- __privateAdd(this, _pending4);
32185
+ __privateAdd(this, _pending3);
31800
32186
  __privateAdd(this, _targetCall);
31801
32187
  __privateAdd(this, _deferredRetryAfterMillis);
31802
32188
  __privateAdd(this, _retryScope, CorrespondenceRetryScope.Letter);
@@ -31821,8 +32207,8 @@
31821
32207
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next());
31822
32208
  }
31823
32209
  resume(receipt) {
31824
- if (__privateGet(this, _pending4)?.effect.case === "retainFrontier") {
31825
- const expected2 = __privateGet(this, _pending4).effect.value;
32210
+ if (__privateGet(this, _pending3)?.effect.case === "retainFrontier") {
32211
+ const expected2 = __privateGet(this, _pending3).effect.value;
31826
32212
  if (receipt.effectId !== expected2.effectId) throw new Error(`receipt '${receipt.effectId}' does not answer '${expected2.effectId}'`);
31827
32213
  const retained = receipt.outcome;
31828
32214
  if (retained.case !== "frontierRetained" || !retained.value.retained || retained.value.workspace !== expected2.workspace || retained.value.branch !== expected2.branch || retained.value.head !== expected2.head || !sameRetainedRefs(retained.value.refs, expected2.refs)) {
@@ -31837,7 +32223,7 @@
31837
32223
  settled.value.delivered = 0n;
31838
32224
  settled.value.refused = 0n;
31839
32225
  __privateSet(this, _settled2, void 0);
31840
- __privateSet(this, _pending4, void 0);
32226
+ __privateSet(this, _pending3, void 0);
31841
32227
  __privateSet(this, _retaining, void 0);
31842
32228
  return settled;
31843
32229
  }
@@ -31845,7 +32231,7 @@
31845
32231
  }
31846
32232
  const retaining = __privateGet(this, _retaining);
31847
32233
  __privateSet(this, _retaining, void 0);
31848
- __privateSet(this, _pending4, void 0);
32234
+ __privateSet(this, _pending3, void 0);
31849
32235
  if (retaining === WorkspaceEffectRetentionLeg.Source) return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, observeTargetOffer_fn).call(this);
31850
32236
  if (retaining === WorkspaceEffectRetentionLeg.Outcome) {
31851
32237
  const settled = __privateGet(this, _settled2);
@@ -31854,11 +32240,11 @@
31854
32240
  }
31855
32241
  const admitted = __privateGet(this, _admitted);
31856
32242
  __privateSet(this, _admitted, void 0);
31857
- __privateSet(this, _pending4, void 0);
32243
+ __privateSet(this, _pending3, void 0);
31858
32244
  __privateSet(this, _targetCall, void 0);
31859
32245
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(admitted, __privateGet(this, _settlement)));
31860
32246
  }
31861
- const expected = __privateGet(this, _pending4)?.effect.case === "http" ? __privateGet(this, _pending4).effect.value.effectId : void 0;
32247
+ const expected = __privateGet(this, _pending3)?.effect.case === "http" ? __privateGet(this, _pending3).effect.value.effectId : void 0;
31862
32248
  if (!expected || !__privateGet(this, _targetCall)) throw new Error(`correspondence work '${this.workId}' is not awaiting transport`);
31863
32249
  if (receipt.effectId !== expected) throw new Error(`receipt '${receipt.effectId}' does not answer '${expected}'`);
31864
32250
  if (receipt.outcome.case === "failure") {
@@ -31883,7 +32269,7 @@
31883
32269
  requestId: __privateGet(this, _targetCall).request.requestId,
31884
32270
  outcome: { case: "offer", value: status.judgment }
31885
32271
  });
31886
- __privateSet(this, _pending4, void 0);
32272
+ __privateSet(this, _pending3, void 0);
31887
32273
  __privateSet(this, _targetCall, void 0);
31888
32274
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(response2, __privateGet(this, _settlement)));
31889
32275
  }
@@ -31904,7 +32290,7 @@
31904
32290
  }
31905
32291
  }
31906
32292
  });
31907
- __privateSet(this, _pending4, void 0);
32293
+ __privateSet(this, _pending3, void 0);
31908
32294
  __privateSet(this, _targetCall, void 0);
31909
32295
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(held));
31910
32296
  }
@@ -31922,7 +32308,7 @@
31922
32308
  requestId: __privateGet(this, _targetCall).request.requestId,
31923
32309
  outcome: { case: "offer", value: applied }
31924
32310
  });
31925
- __privateSet(this, _pending4, void 0);
32311
+ __privateSet(this, _pending3, void 0);
31926
32312
  __privateSet(this, _targetCall, void 0);
31927
32313
  __privateSet(this, _admitted, void 0);
31928
32314
  __privateSet(this, _awaitingObservation, false);
@@ -31937,7 +32323,7 @@
31937
32323
  _retention2 = new WeakMap();
31938
32324
  _admitted = new WeakMap();
31939
32325
  _awaitingObservation = new WeakMap();
31940
- _pending4 = new WeakMap();
32326
+ _pending3 = new WeakMap();
31941
32327
  _targetCall = new WeakMap();
31942
32328
  _deferredRetryAfterMillis = new WeakMap();
31943
32329
  _retryScope = new WeakMap();
@@ -31948,7 +32334,7 @@
31948
32334
  transportFailed_fn = function(message) {
31949
32335
  const call = __privateGet(this, _targetCall);
31950
32336
  if (!call) throw new Error("failed transport has no target call");
31951
- __privateSet(this, _pending4, void 0);
32337
+ __privateSet(this, _pending3, void 0);
31952
32338
  __privateSet(this, _targetCall, void 0);
31953
32339
  __privateSet(this, _admitted, void 0);
31954
32340
  __privateSet(this, _awaitingObservation, false);
@@ -31978,7 +32364,7 @@
31978
32364
  const head2 = __privateGet(this, _kernel20).head(source2, 0n);
31979
32365
  if (!head2) throw new Error("effect outcome source has no custody frontier");
31980
32366
  __privateSet(this, _retaining, WorkspaceEffectRetentionLeg.Outcome);
31981
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32367
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
31982
32368
  workId: this.workId,
31983
32369
  effect: { case: "retainFrontier", value: create(RetainFrontierEffectSchema, {
31984
32370
  effectId: `${this.workId}:retain-outcome`,
@@ -31988,7 +32374,7 @@
31988
32374
  refs: __privateGet(this, _retention2).refs(source2.workspace)
31989
32375
  }) }
31990
32376
  }));
31991
- return { case: "pending", value: __privateGet(this, _pending4) };
32377
+ return { case: "pending", value: __privateGet(this, _pending3) };
31992
32378
  }
31993
32379
  return settled;
31994
32380
  }
@@ -32014,7 +32400,7 @@
32014
32400
  if (!head2 || !/^[0-9a-f]{40}$/i.test(head2)) return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, transportFailed_fn).call(this, "admitted target has no current custody frontier");
32015
32401
  __privateSet(this, _admitted, response);
32016
32402
  __privateSet(this, _retaining, WorkspaceEffectRetentionLeg.Target);
32017
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32403
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
32018
32404
  workId: this.workId,
32019
32405
  effect: { case: "retainFrontier", value: create(RetainFrontierEffectSchema, {
32020
32406
  effectId: `${this.workId}:retain:${offer.id}`,
@@ -32024,7 +32410,7 @@
32024
32410
  refs: __privateGet(this, _retention2).refs(step.value.mount.workspace)
32025
32411
  }) }
32026
32412
  }));
32027
- return { case: "pending", value: __privateGet(this, _pending4) };
32413
+ return { case: "pending", value: __privateGet(this, _pending3) };
32028
32414
  }
32029
32415
  __privateSet(this, _targetCall, void 0);
32030
32416
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(response, __privateGet(this, _settlement)));
@@ -32033,7 +32419,7 @@
32033
32419
  const head = __privateGet(this, _kernel20).head(source, 0n);
32034
32420
  if (!head) return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, transportFailed_fn).call(this, "effect source has no admitted custody frontier");
32035
32421
  __privateSet(this, _retaining, WorkspaceEffectRetentionLeg.Source);
32036
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32422
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
32037
32423
  workId: this.workId,
32038
32424
  effect: { case: "retainFrontier", value: create(RetainFrontierEffectSchema, {
32039
32425
  effectId: `${this.workId}:retain-source:${offer.id}`,
@@ -32043,14 +32429,14 @@
32043
32429
  refs: __privateGet(this, _retention2).refs(source.workspace)
32044
32430
  }) }
32045
32431
  }));
32046
- return { case: "pending", value: __privateGet(this, _pending4) };
32432
+ return { case: "pending", value: __privateGet(this, _pending3) };
32047
32433
  };
32048
32434
  observeTargetOffer_fn = function() {
32049
32435
  const offer = __privateGet(this, _targetCall)?.offer;
32050
32436
  if (!offer || !__privateGet(this, _mailboxUrl)) throw new Error("mailbox observation has no active offer");
32051
32437
  if (offer.effectDigest && offer.sourceWorkspaceGenesis) {
32052
32438
  __privateSet(this, _awaitingObservation, true);
32053
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, { workId: this.workId, effect: {
32439
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, { workId: this.workId, effect: {
32054
32440
  case: "http",
32055
32441
  value: create(PeerHttpEffectSchema, {
32056
32442
  effectId: `${this.workId}:observe:${offer.id}`,
@@ -32064,7 +32450,7 @@
32064
32450
  }))
32065
32451
  })
32066
32452
  } }));
32067
- return { case: "pending", value: __privateGet(this, _pending4) };
32453
+ return { case: "pending", value: __privateGet(this, _pending3) };
32068
32454
  }
32069
32455
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, postTargetOffer_fn).call(this);
32070
32456
  };
@@ -32087,11 +32473,11 @@
32087
32473
  accept: CARRIED_OFFER_RESPONSE,
32088
32474
  body: toBinary(OfferRequestSchema, body)
32089
32475
  });
32090
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32476
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
32091
32477
  workId: this.workId,
32092
32478
  effect: { case: "http", value: effect }
32093
32479
  }));
32094
- return { case: "pending", value: __privateGet(this, _pending4) };
32480
+ return { case: "pending", value: __privateGet(this, _pending3) };
32095
32481
  };
32096
32482
 
32097
32483
  // ../src/runtime/replica_follow_lane.ts
@@ -32127,6 +32513,11 @@
32127
32513
  const delay = __privateGet(this, _controller).reconnected(workspace);
32128
32514
  if (delay !== void 0) __privateMethod(this, _ReplicaFollowLane_instances, scheduleAt_fn).call(this, workspace, __privateMethod(this, _ReplicaFollowLane_instances, now_fn8).call(this) + delay);
32129
32515
  }
32516
+ /** The upstream announced a new frontier: news even to a follow the kernel refused. */
32517
+ remoteAdvanced(workspace) {
32518
+ const delay = __privateGet(this, _controller).reconnected(workspace, true);
32519
+ if (delay !== void 0) __privateMethod(this, _ReplicaFollowLane_instances, scheduleAt_fn).call(this, workspace, __privateMethod(this, _ReplicaFollowLane_instances, now_fn8).call(this) + delay);
32520
+ }
32130
32521
  /** The upstream rang for a new placement frontier (see ReplicaFollowController). */
32131
32522
  placementAnnounced(workspace) {
32132
32523
  const delay = __privateGet(this, _controller).placementAnnounced(workspace);
@@ -32309,7 +32700,7 @@
32309
32700
  init_shims();
32310
32701
  var PREPARATION_QUANTA_PER_TURN = 64;
32311
32702
  var RETRY_AFTER_MILLIS = 30000n;
32312
- var _command4, _source4, _kernel21, _clock19, _requestId7, _offer, _pending5, _settled3, _HttpObligationDeliveryWork_instances, complete_fn;
32703
+ var _command4, _source4, _kernel21, _clock19, _requestId7, _offer, _pending4, _settled3, _HttpObligationDeliveryWork_instances, complete_fn;
32313
32704
  var HttpObligationDeliveryWork = class {
32314
32705
  constructor(args) {
32315
32706
  __privateAdd(this, _HttpObligationDeliveryWork_instances);
@@ -32320,7 +32711,7 @@
32320
32711
  __privateAdd(this, _clock19);
32321
32712
  __privateAdd(this, _requestId7);
32322
32713
  __privateAdd(this, _offer);
32323
- __privateAdd(this, _pending5);
32714
+ __privateAdd(this, _pending4);
32324
32715
  __privateAdd(this, _settled3);
32325
32716
  this.workId = args.workId;
32326
32717
  __privateSet(this, _command4, args.command);
@@ -32331,7 +32722,7 @@
32331
32722
  }
32332
32723
  start() {
32333
32724
  if (__privateGet(this, _settled3)) return __privateGet(this, _settled3);
32334
- if (__privateGet(this, _pending5)) return { case: "pending", value: __privateGet(this, _pending5) };
32725
+ if (__privateGet(this, _pending4)) return { case: "pending", value: __privateGet(this, _pending4) };
32335
32726
  if (!__privateGet(this, _command4).sourceOfferPath) {
32336
32727
  throw new Error("HTTP obligation delivery requires an exact source offer path");
32337
32728
  }
@@ -32360,7 +32751,7 @@
32360
32751
  throw new Error("prepared HTTP obligation lacks its durable delivery identity");
32361
32752
  }
32362
32753
  __privateSet(this, _offer, offer);
32363
- __privateSet(this, _pending5, create(CorrespondencePendingSchema, {
32754
+ __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32364
32755
  workId: this.workId,
32365
32756
  effect: {
32366
32757
  case: "http",
@@ -32376,13 +32767,13 @@
32376
32767
  })
32377
32768
  }
32378
32769
  }));
32379
- return { case: "pending", value: __privateGet(this, _pending5) };
32770
+ return { case: "pending", value: __privateGet(this, _pending4) };
32380
32771
  }
32381
32772
  return __privateMethod(this, _HttpObligationDeliveryWork_instances, complete_fn).call(this, false, false, true);
32382
32773
  }
32383
32774
  resume(receipt) {
32384
32775
  if (__privateGet(this, _settled3)) return __privateGet(this, _settled3);
32385
- const pending = __privateGet(this, _pending5);
32776
+ const pending = __privateGet(this, _pending4);
32386
32777
  const offer = __privateGet(this, _offer);
32387
32778
  if (!pending || pending.effect.case !== "http" || !offer) {
32388
32779
  throw new Error(`HTTP obligation work '${this.workId}' is not awaiting transport`);
@@ -32390,7 +32781,7 @@
32390
32781
  if (receipt.effectId !== pending.effect.value.effectId) {
32391
32782
  throw new Error(`receipt '${receipt.effectId}' does not answer '${pending.effect.value.effectId}'`);
32392
32783
  }
32393
- __privateSet(this, _pending5, void 0);
32784
+ __privateSet(this, _pending4, void 0);
32394
32785
  __privateSet(this, _offer, void 0);
32395
32786
  if (receipt.outcome.case === "response" && receipt.outcome.value.status >= 200 && receipt.outcome.value.status < 300) {
32396
32787
  __privateGet(this, _kernel21).writeRef(
@@ -32410,7 +32801,7 @@
32410
32801
  _clock19 = new WeakMap();
32411
32802
  _requestId7 = new WeakMap();
32412
32803
  _offer = new WeakMap();
32413
- _pending5 = new WeakMap();
32804
+ _pending4 = new WeakMap();
32414
32805
  _settled3 = new WeakMap();
32415
32806
  _HttpObligationDeliveryWork_instances = new WeakSet();
32416
32807
  complete_fn = function(attempted, delivered, preparationPending, retryAtMillis) {
@@ -32429,7 +32820,7 @@
32429
32820
  var REFETCH_AWAITS_PROVIDER = "nomos.runtime.refetch_awaits_provider";
32430
32821
  var LOCAL_COPY_REFETCHING = "nomos.runtime.local_copy_refetching";
32431
32822
  var LIVE_ADMISSION_GRACE_MILLIS = 1e4;
32432
- var _kernel22, _retention3, _custodyStorage, _custody3, _sessions11, _credentials5, _placement3, _clock20, _outboxClock, _follows2, _followLane, _readability2, _origins3, _preserved, _dropReasons, _lawProductsImported2, _lawProductsInFlight2, _replacing, _providerServesSameCopy, _events4, _onSyncFrontier, _onSyncCompleted, _onPlacementFetched, _onShallowMount, _onOffered, _onOutboxHistoryRequired, _backgroundHistory, _receiveStep2, _remoteOffers, _recoveries, _deliveries, _httpDeliveries, _syncs, _syncWorkspaces, _retries, _remoteDeliveryKeys, _outboxDueAt, _settledFollowReported, _openLinks, _liveAdmissionDue, _linkReported, _lastClosure, _followsReported, _warming, _recoveredOutboxes, _outboxObservations, _outboxCursor, _httpDeliveryPaths, _executesCustodianObligations, _CorrespondenceDesk_instances, dropRoundsOf_fn, observeWarming_fn, eligibleOutboxEntry_fn, settleDelivery_fn, nowMillis_fn2, liveAdmissionOverdue_fn, warmingPosture_fn, activeSyncEffect_fn, dropReason_fn, roundInFlight_fn, observeSyncResult_fn, syncFailed_fn, scheduleFromResult_fn, syncCompleted_fn, recordPreserved_fn, scheduleOutbox_fn;
32823
+ var _kernel22, _retention3, _custodyStorage, _custody3, _sessions11, _credentials5, _placement3, _clock20, _outboxClock, _follows2, _followLane, _readability2, _origins3, _preserved, _dropReasons, _lawProductsImported2, _lawProductsInFlight2, _replacing, _providerServesSameCopy, _events4, _onSyncFrontier, _onSyncCompleted, _onPlacementFetched, _onShallowMount, _onOffered, _liveAdmitted2, _onOutboxHistoryRequired, _backgroundHistory, _receiveStep2, _remoteOffers, _recoveries, _deliveries, _httpDeliveries, _syncs, _syncWorkspaces, _retries, _remoteDeliveryKeys, _outboxDueAt, _settledFollowReported, _openLinks, _liveAdmissionDue, _linkReported, _lastClosure, _followsReported, _warming, _recoveredOutboxes, _outboxObservations, _outboxCursor, _httpDeliveryPaths, _executesCustodianObligations, _CorrespondenceDesk_instances, dropRoundsOf_fn, observeWarming_fn, eligibleOutboxEntry_fn, settleDelivery_fn, nowMillis_fn2, liveAdmissionOverdue_fn, warmingPosture_fn, activeSyncEffect_fn, dropReason_fn, roundInFlight_fn, observeSyncResult_fn, syncFailed_fn, scheduleFromResult_fn, syncCompleted_fn, recordPreserved_fn, scheduleOutbox_fn;
32433
32824
  var CorrespondenceDesk = class {
32434
32825
  constructor(args) {
32435
32826
  __privateAdd(this, _CorrespondenceDesk_instances);
@@ -32463,6 +32854,7 @@
32463
32854
  __privateAdd(this, _onPlacementFetched);
32464
32855
  __privateAdd(this, _onShallowMount);
32465
32856
  __privateAdd(this, _onOffered);
32857
+ __privateAdd(this, _liveAdmitted2);
32466
32858
  __privateAdd(this, _onOutboxHistoryRequired);
32467
32859
  __privateAdd(this, _backgroundHistory);
32468
32860
  __privateAdd(this, _receiveStep2);
@@ -32520,6 +32912,7 @@
32520
32912
  __privateSet(this, _onPlacementFetched, args.onPlacementFetched);
32521
32913
  __privateSet(this, _onShallowMount, args.onShallowMount);
32522
32914
  __privateSet(this, _onOffered, args.onOffered);
32915
+ __privateSet(this, _liveAdmitted2, args.liveAdmitted);
32523
32916
  __privateSet(this, _onOutboxHistoryRequired, args.onOutboxHistoryRequired);
32524
32917
  __privateSet(this, _backgroundHistory, args.backgroundHistory !== false);
32525
32918
  __privateSet(this, _receiveStep2, args.receiveStep);
@@ -32775,6 +33168,12 @@
32775
33168
  __privateGet(this, _followLane).reconnected(workspace);
32776
33169
  this.reportFollows();
32777
33170
  }
33171
+ /** The upstream announced a new frontier for this workspace over its live link: an event which
33172
+ * re-runs a round the kernel refused (its inputs changed). */
33173
+ replicaRemoteAdvanced(workspace) {
33174
+ __privateGet(this, _followLane).remoteAdvanced(workspace);
33175
+ this.reportFollows();
33176
+ }
32778
33177
  /** The upstream rang for a new placement frontier: the next round re-checks placement even
32779
33178
  * though main has not moved. */
32780
33179
  replicaPlacementAnnounced(workspace) {
@@ -32809,10 +33208,11 @@
32809
33208
  const state = __privateGet(this, _follows2).followForWorkspace(workspace)?.state;
32810
33209
  if (!state) return [];
32811
33210
  const isSettled = state.case === ReplicaFollowPhase.Settled;
33211
+ const refused = state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked === true;
32812
33212
  const isLive = __privateGet(this, _openLinks).has(workspace);
32813
33213
  if (isSettled) settled += 1;
32814
33214
  if (isLive) live += 1;
32815
- const phase = {
33215
+ const phase = refused ? FollowObservationPhase.KERNEL_REFUSED : {
32816
33216
  [ReplicaFollowPhase.Desired]: FollowObservationPhase.DESIRED,
32817
33217
  [ReplicaFollowPhase.Due]: FollowObservationPhase.DUE,
32818
33218
  [ReplicaFollowPhase.Running]: FollowObservationPhase.RUNNING,
@@ -32826,7 +33226,7 @@
32826
33226
  [ReplicaFollowPhase.LocalCopyUnreadable]: FollowObservationPhase.LOCAL_COPY_UNREADABLE
32827
33227
  }[state.case];
32828
33228
  const detail = state.case === ReplicaFollowPhase.AwaitingDependency ? state.reason : state.case === ReplicaFollowPhase.InvalidCredential || state.case === ReplicaFollowPhase.Backoff ? state.failure : state.case === ReplicaFollowPhase.RebornRemotely ? state.rebirth.detail : state.case === ReplicaFollowPhase.LocalCopyUnreadable ? state.format : void 0;
32829
- const retryAt = state.case === ReplicaFollowPhase.Offline || state.case === ReplicaFollowPhase.InvalidCredential || state.case === ReplicaFollowPhase.Backoff ? state.retryAtUnixMillis : void 0;
33229
+ const retryAt = refused ? state.case === ReplicaFollowPhase.Backoff ? state.refusal?.rerunAtUnixMillis : void 0 : state.case === ReplicaFollowPhase.Offline || state.case === ReplicaFollowPhase.InvalidCredential || state.case === ReplicaFollowPhase.Backoff ? state.retryAtUnixMillis : void 0;
32830
33230
  const dueAt2 = state.case === ReplicaFollowPhase.Due || state.case === ReplicaFollowPhase.ReplacingLocal ? state.dueAtUnixMillis : void 0;
32831
33231
  const attempt = state.case === ReplicaFollowPhase.Running || state.case === ReplicaFollowPhase.Offline || state.case === ReplicaFollowPhase.InvalidCredential || state.case === ReplicaFollowPhase.Backoff || state.case === ReplicaFollowPhase.ReplacingLocal ? state.attempt : void 0;
32832
33232
  const activeEffect = state.case === ReplicaFollowPhase.Running ? __privateMethod(this, _CorrespondenceDesk_instances, activeSyncEffect_fn).call(this, workspace) : void 0;
@@ -33264,6 +33664,7 @@
33264
33664
  const active = /* @__PURE__ */ new Set([mount.workspace]);
33265
33665
  let roundPlacementFrontier;
33266
33666
  const work = (target3, id, probeOnly = false, beforeConverge) => {
33667
+ var _a;
33267
33668
  active.add(target3.mount.workspace);
33268
33669
  const isRoot = target3.mount.workspace === mount.workspace;
33269
33670
  const targetRoute = isRoot ? route : __privateGet(this, _placement3).syncRoute(request, target3.mount);
@@ -33279,13 +33680,13 @@
33279
33680
  lawProductsImported: __privateGet(this, _lawProductsImported2),
33280
33681
  lawProductsInFlight: __privateGet(this, _lawProductsInFlight2),
33281
33682
  shallowMounted: (credentialCapability) => {
33282
- var _a;
33283
- return (_a = __privateGet(this, _onShallowMount)) == null ? void 0 : _a.call(this, target3.mount.workspace, credentialCapability);
33683
+ var _a2;
33684
+ return (_a2 = __privateGet(this, _onShallowMount)) == null ? void 0 : _a2.call(this, target3.mount.workspace, credentialCapability);
33284
33685
  },
33285
33686
  ...__privateGet(this, _receiveStep2) ? { receiveStep: __privateGet(this, _receiveStep2) } : {},
33286
33687
  ...__privateGet(this, _onOffered) ? { offered: (oids) => {
33287
- var _a;
33288
- return (_a = __privateGet(this, _onOffered)) == null ? void 0 : _a.call(this, target3.mount.workspace, oids);
33688
+ var _a2;
33689
+ return (_a2 = __privateGet(this, _onOffered)) == null ? void 0 : _a2.call(this, target3.mount.workspace, oids);
33289
33690
  } } : {},
33290
33691
  // A dropped copy's refetch authorization names the root workspace alone.
33291
33692
  command: target3.mount.workspace === mount.workspace || command.replaceLocalHead === void 0 ? command : create(SyncWorkspaceRequestSchema, { workspace: command.workspace, admit: command.admit }),
@@ -33293,6 +33694,7 @@
33293
33694
  workId: id,
33294
33695
  probeOnly,
33295
33696
  liveConnected: __privateGet(this, _openLinks).has(target3.mount.workspace),
33697
+ ...__privateGet(this, _openLinks).has(target3.mount.workspace) && ((_a = __privateGet(this, _liveAdmitted2)) == null ? void 0 : _a.call(this, target3.mount.workspace)) ? { liveAdmitted: __privateGet(this, _liveAdmitted2).call(this, target3.mount.workspace) } : {},
33296
33698
  ...beforeConverge === void 0 ? {} : { beforeConverge },
33297
33699
  ...target3.receiveState === void 0 ? {} : { receiveState: target3.receiveState },
33298
33700
  ...target3.offerHead === void 0 ? {} : { offerHead: target3.offerHead },
@@ -33307,8 +33709,8 @@
33307
33709
  ...isRoot ? {
33308
33710
  directoryAnswered: () => __privateGet(this, _follows2).placementRechecked(mount.workspace),
33309
33711
  placementFetched: () => {
33310
- var _a;
33311
- return (_a = __privateGet(this, _onPlacementFetched)) == null ? void 0 : _a.call(this, mount.workspace);
33712
+ var _a2;
33713
+ return (_a2 = __privateGet(this, _onPlacementFetched)) == null ? void 0 : _a2.call(this, mount.workspace);
33312
33714
  }
33313
33715
  } : {}
33314
33716
  });
@@ -33492,6 +33894,7 @@
33492
33894
  _onPlacementFetched = new WeakMap();
33493
33895
  _onShallowMount = new WeakMap();
33494
33896
  _onOffered = new WeakMap();
33897
+ _liveAdmitted2 = new WeakMap();
33495
33898
  _onOutboxHistoryRequired = new WeakMap();
33496
33899
  _backgroundHistory = new WeakMap();
33497
33900
  _receiveStep2 = new WeakMap();
@@ -33764,17 +34167,17 @@
33764
34167
  // ../src/runtime/birth_custody_desk.ts
33765
34168
  init_define_NOMOS_KERNEL_RELEASE();
33766
34169
  init_shims();
33767
- var _finalOutcome, _pending6, _completed7, _lastReceiptEffectId3;
34170
+ var _finalOutcome, _pending5, _completed7, _lastReceiptEffectId3;
33768
34171
  var BirthCustodyWork = class {
33769
34172
  constructor(args) {
33770
34173
  __publicField(this, "workId");
33771
34174
  __privateAdd(this, _finalOutcome);
33772
- __privateAdd(this, _pending6);
34175
+ __privateAdd(this, _pending5);
33773
34176
  __privateAdd(this, _completed7);
33774
34177
  __privateAdd(this, _lastReceiptEffectId3);
33775
34178
  this.workId = args.workId;
33776
34179
  __privateSet(this, _finalOutcome, args.finalOutcome);
33777
- __privateSet(this, _pending6, create(CorrespondencePendingSchema, {
34180
+ __privateSet(this, _pending5, create(CorrespondencePendingSchema, {
33778
34181
  workId: this.workId,
33779
34182
  effect: {
33780
34183
  case: "persistBornCustody",
@@ -33786,13 +34189,13 @@
33786
34189
  }));
33787
34190
  }
33788
34191
  start() {
33789
- return __privateGet(this, _completed7) ?? { case: "pending", value: __privateGet(this, _pending6) };
34192
+ return __privateGet(this, _completed7) ?? { case: "pending", value: __privateGet(this, _pending5) };
33790
34193
  }
33791
34194
  resume(receipt) {
33792
34195
  if (receipt.effectId === __privateGet(this, _lastReceiptEffectId3) && __privateGet(this, _completed7)) {
33793
34196
  return __privateGet(this, _completed7);
33794
34197
  }
33795
- const effect = __privateGet(this, _pending6).effect;
34198
+ const effect = __privateGet(this, _pending5).effect;
33796
34199
  if (effect.case !== "persistBornCustody") {
33797
34200
  throw new Error(`birth custody work '${this.workId}' has no persistence effect`);
33798
34201
  }
@@ -33832,7 +34235,7 @@
33832
34235
  }
33833
34236
  };
33834
34237
  _finalOutcome = new WeakMap();
33835
- _pending6 = new WeakMap();
34238
+ _pending5 = new WeakMap();
33836
34239
  _completed7 = new WeakMap();
33837
34240
  _lastReceiptEffectId3 = new WeakMap();
33838
34241
  var _kernel23, _work3, _publicationRefs, _origins4, _BirthCustodyDesk_instances, begin_fn3;
@@ -34395,13 +34798,13 @@
34395
34798
  init_define_NOMOS_KERNEL_RELEASE();
34396
34799
  init_shims();
34397
34800
  var cloneCall = (call) => fromBinary(CallRequestSchema, toBinary(CallRequestSchema, call));
34398
- var _identity, _application2, _pending7, _completed9, _completedOrder, _completedLimit2, _IdentityRecoveryDesk_instances, rememberCompleted_fn, adoptAndRetry_fn;
34801
+ var _identity, _application2, _pending6, _completed9, _completedOrder, _completedLimit2, _IdentityRecoveryDesk_instances, rememberCompleted_fn, adoptAndRetry_fn;
34399
34802
  var IdentityRecoveryDesk = class {
34400
34803
  constructor(identity, application) {
34401
34804
  __privateAdd(this, _IdentityRecoveryDesk_instances);
34402
34805
  __privateAdd(this, _identity);
34403
34806
  __privateAdd(this, _application2);
34404
- __privateAdd(this, _pending7, /* @__PURE__ */ new Map());
34807
+ __privateAdd(this, _pending6, /* @__PURE__ */ new Map());
34405
34808
  __privateAdd(this, _completed9, /* @__PURE__ */ new Map());
34406
34809
  __privateAdd(this, _completedOrder, []);
34407
34810
  __privateAdd(this, _completedLimit2, 128);
@@ -34432,25 +34835,25 @@
34432
34835
  return __privateMethod(this, _IdentityRecoveryDesk_instances, adoptAndRetry_fn).call(this, runtimeRequest, command, originalCall, requirement, step.value);
34433
34836
  }
34434
34837
  const requestKey = runtimeRequest.requestId.toString();
34435
- const waiters = __privateGet(this, _pending7).get(step.value.workId) ?? /* @__PURE__ */ new Map();
34838
+ const waiters = __privateGet(this, _pending6).get(step.value.workId) ?? /* @__PURE__ */ new Map();
34436
34839
  waiters.set(requestKey, {
34437
34840
  runtimeRequest,
34438
34841
  command,
34439
34842
  originalCall,
34440
34843
  requirement
34441
34844
  });
34442
- __privateGet(this, _pending7).set(step.value.workId, waiters);
34845
+ __privateGet(this, _pending6).set(step.value.workId, waiters);
34443
34846
  return step;
34444
34847
  }
34445
34848
  has(workId2, requestId) {
34446
34849
  const requestKey = requestId.toString();
34447
- return __privateGet(this, _pending7).get(workId2)?.has(requestKey) === true || __privateGet(this, _completed9).get(workId2)?.has(requestKey) === true;
34850
+ return __privateGet(this, _pending6).get(workId2)?.has(requestKey) === true || __privateGet(this, _completed9).get(workId2)?.has(requestKey) === true;
34448
34851
  }
34449
34852
  continue(workId2, receipt, requestId) {
34450
34853
  const requestKey = requestId.toString();
34451
34854
  const completed = __privateGet(this, _completed9).get(workId2)?.get(requestKey);
34452
34855
  if (completed) return completed;
34453
- const waiters = __privateGet(this, _pending7).get(workId2);
34856
+ const waiters = __privateGet(this, _pending6).get(workId2);
34454
34857
  const pending = waiters?.get(requestKey);
34455
34858
  if (!pending) {
34456
34859
  throw new Error(
@@ -34460,20 +34863,20 @@
34460
34863
  const step = __privateGet(this, _identity).continue(workId2, receipt);
34461
34864
  if (step.case === "pending") return step;
34462
34865
  waiters.delete(requestKey);
34463
- if (waiters.size === 0) __privateGet(this, _pending7).delete(workId2);
34866
+ if (waiters.size === 0) __privateGet(this, _pending6).delete(workId2);
34464
34867
  const result = __privateMethod(this, _IdentityRecoveryDesk_instances, adoptAndRetry_fn).call(this, pending.runtimeRequest, pending.command, pending.originalCall, pending.requirement, step.value);
34465
34868
  __privateMethod(this, _IdentityRecoveryDesk_instances, rememberCompleted_fn).call(this, workId2, requestKey, result);
34466
34869
  return result;
34467
34870
  }
34468
34871
  clear() {
34469
- __privateGet(this, _pending7).clear();
34872
+ __privateGet(this, _pending6).clear();
34470
34873
  __privateGet(this, _completed9).clear();
34471
34874
  __privateGet(this, _completedOrder).length = 0;
34472
34875
  }
34473
34876
  };
34474
34877
  _identity = new WeakMap();
34475
34878
  _application2 = new WeakMap();
34476
- _pending7 = new WeakMap();
34879
+ _pending6 = new WeakMap();
34477
34880
  _completed9 = new WeakMap();
34478
34881
  _completedOrder = new WeakMap();
34479
34882
  _completedLimit2 = new WeakMap();
@@ -35179,10 +35582,10 @@
35179
35582
  while (true) {
35180
35583
  __privateGet(this, _ports6).owe(owed.workspace);
35181
35584
  while (__privateGet(this, _ports6).owes(owed.workspace)) {
35182
- const tick = __privateGet(this, _ports6).tick();
35585
+ const { ticked, wake: readiness } = __privateGet(this, _ports6).tick();
35183
35586
  const delayMillis = Math.min(LONGEST_WAKE_MILLIS, Math.max(
35184
35587
  FIRST_WAKE_MILLIS,
35185
- tick.progress !== void 0 ? FIRST_WAKE_MILLIS : tick.nextTickAfterMillis
35588
+ ticked.progress !== void 0 ? FIRST_WAKE_MILLIS : readiness.case === "after" ? readiness.millis : LONGEST_WAKE_MILLIS
35186
35589
  ));
35187
35590
  const receipt = yield { case: "wake", value: create(PeerWakeEffectSchema, {
35188
35591
  effectId: `${workId2}:repay-${++wake}`,
@@ -35324,7 +35727,6 @@
35324
35727
  }
35325
35728
  var INTERACTIVE_PEER_CLASSES = /* @__PURE__ */ new Set(["personal-device", "browser"]);
35326
35729
  var INTERACTION_FIRST_MILLIS = 15e3;
35327
- var READ_READINESS_ONLY = 1n << 62n;
35328
35730
  var PLACEMENT_READ_RETRY_MILLIS = 60000n;
35329
35731
  var STREAM_WAKE_FIRST_MILLIS = 20;
35330
35732
  var HISTORY_STREAM_SLICES = [8, 64, 256];
@@ -35343,7 +35745,6 @@
35343
35745
  "continueLocalRead"
35344
35746
  ]);
35345
35747
  var APPLICATION_WAIT_NANOS = 5000000000n;
35346
- var READ_INDEX_BUILDING = /the read index of .+ is being built|read maintenance continues it/;
35347
35748
  var _kernel27, _sessions14, _interactivePeer, _interaction, _trace13, _credentials7, _credentialRecovery, _deviceIdentity, _receivingGroup2, _offerReadiness, _modelAdoption, _deviceChallenges, _enrolledCapabilities, _custody4, _readability3, _origins5, _seat2, _replicaId3, _custodyAdmission, _correspondence3, _birthCustody, _placement5, _access, _identity2, _custodianPlacement, _identityRecovery, _queries8, _application3, _compatibility2, _custodyVerification, _commandPreparation, _applicationReadiness, _authenticationReadiness, _lawPackages, _readMaintenance, _readResponses, _residency5, _residencyPins, _subscriptions5, _follows3, _replicaInventory, _placementDiscovery2, _live3, _liveStream, _streamWaits, _records6, _historicQueries, _authoringPreflight, _foregroundWork, _backgroundPapers, _backgroundWork, _yielded, _released, _applicationWork, _followUp, _writeBurst, _receiveStepBudget, _importStepBudget, _recovery, _lifecycle, _maintenance3, _background3, _paperSlots, _retentionObserver, _admissionDurability, _historyAcquisition, _historySliceRequest, _PeerOffice_instances, sliceBoundaries_fn, _responses, _placementRead, _placementUnread, _entryDepth, _clock23, drive_fn, timedBackgroundPaper_fn, nextBackgroundPaper_fn, invoke_fn, yieldBackground_fn, applicationWaiting_fn, resumeYielded_fn, streamed_fn, streamWoken_fn, streamReceipt_fn, streamWake_fn, fenced_fn, handleRequest_fn, localCopyUnreadable_fn, probeLocalCopyFormat_fn, protectedResidents_fn, bindInteraction_fn, keepCustodianPlacement_fn, dispatchRequest_fn, continuesHistoryAcquisition_fn, historyCredentialCapability_fn, preferredCredentialCapability_fn, backgroundTurn_fn, settleResidentPlacement_fn, readResidentPlacement_fn, _internalPlacementRequests, internalRequestId_fn, correspondenceResponse_fn, authenticationReadinessResponse_fn, completedKernelCall_fn, modelAdoptionResponse_fn, receivingGroupResponse_fn, deviceIdentityResponse_fn, deviceChallengeFor_fn, deviceChallengeForCapability_fn, credentialRecoveryResponse_fn, afterCredentialKernelCall_fn, offerReadinessResponse_fn, acknowledgedWhenDurable_fn, admissionDurabilityResponse_fn, birthCustodyResponse_fn, identityResponse_fn, identityRecoveryResponse_fn, response_fn, failure_fn, custodyRequired_fn, kernelResidencyRequired_fn, candidateCustodyRequired_fn;
35348
35749
  var PeerOffice = class {
35349
35750
  constructor(kernel, credentials, profile, observations, custodyStorage, peerDeskStore) {
@@ -35527,7 +35928,6 @@
35527
35928
  }
35528
35929
  }, (workspace) => __privateGet(this, _residency5).lastRetainedHead(workspace)));
35529
35930
  if (__privateGet(this, _writeBurst)) __privateGet(this, _live3).writeBurst = __privateGet(this, _writeBurst);
35530
- if (__privateGet(this, _interactivePeer)) __privateGet(this, _live3).receiveStep = __privateGet(this, _receiveStepBudget);
35531
35931
  __privateSet(this, _credentials7, new CredentialSessions(__privateGet(this, _sessions14), credentials, observations));
35532
35932
  __privateSet(this, _readability3, new LocalCopyReadability((workspace, format) => {
35533
35933
  __privateGet(this, _follows3).markLocalCopyUnreadable(workspace, format);
@@ -35545,7 +35945,8 @@
35545
35945
  new ReplicaFollowDesk(seatedStore),
35546
35946
  observations,
35547
35947
  __privateGet(this, _replicaId3),
35548
- new BirthRefusalRegister(seatedStore)
35948
+ new BirthRefusalRegister(seatedStore),
35949
+ PEER_RUNTIME_IDENTITY
35549
35950
  ));
35550
35951
  __privateSet(this, _compatibility2, new CompatibilityDesk(
35551
35952
  __privateGet(this, _queries8),
@@ -35564,13 +35965,20 @@
35564
35965
  __privateGet(this, _trace13),
35565
35966
  observations,
35566
35967
  {
35567
- readReady: (workspace) => __privateGet(this, _subscriptions5).readIndexReady(workspace),
35568
- frontierAdvanced: (workspace) => __privateGet(this, _subscriptions5).readIndexAdvanced(workspace),
35569
- localCopyUnreadable: (workspace, format) => __privateGet(this, _readability3).mark(
35570
- workspace,
35571
- __privateGet(this, _kernel27).head(workspaceMount(workspace), 0n),
35572
- format
35573
- ),
35968
+ // A read waiting on this workspace is released by the readiness event itself, not a timer.
35969
+ readReady: (workspace) => {
35970
+ __privateGet(this, _subscriptions5).readIndexReady(workspace);
35971
+ __privateGet(this, _readResponses)?.readinessChanged(workspace);
35972
+ },
35973
+ frontierAdvanced: (workspace) => {
35974
+ __privateGet(this, _subscriptions5).readIndexAdvanced(workspace);
35975
+ __privateGet(this, _readResponses)?.readinessChanged(workspace);
35976
+ },
35977
+ readinessMayChange: (workspace) => __privateGet(this, _readResponses)?.readinessChanged(workspace),
35978
+ localCopyUnreadable: (workspace, format) => {
35979
+ __privateGet(this, _readability3).mark(workspace, __privateGet(this, _kernel27).head(workspaceMount(workspace), 0n), format);
35980
+ __privateGet(this, _readResponses)?.readinessChanged(workspace);
35981
+ },
35574
35982
  isLocalCopyUnreadable: (workspace) => __privateGet(this, _readability3).decide(workspace) !== void 0
35575
35983
  },
35576
35984
  // The kernel owes this peer's writes to an ordered background flush the desk schedules.
@@ -35632,7 +36040,7 @@
35632
36040
  aggregateIds: new Set([...admitted.affected, ...admitted.created].map((ref) => ref.id)),
35633
36041
  // What the offer changed, typed as reads resolve it: watches it cannot change are not read.
35634
36042
  stateChange: admitted.stateChange
35635
- }, () => __privateGet(this, _readMaintenance).tick(void 0, 0n, READ_READINESS_ONLY, false).progress !== void 0));
36043
+ }, () => __privateGet(this, _readMaintenance).tickReadReadiness().ticked.progress !== void 0));
35636
36044
  noteTimeline("ownOffer", `${delivery.delivered}/${delivery.watches}`);
35637
36045
  noteTimeline("ownOfferSkipped", delivery.skipped);
35638
36046
  });
@@ -35647,7 +36055,12 @@
35647
36055
  observations,
35648
36056
  // A waiting read advances read readiness only: it must never run a background command or
35649
36057
  // closure warm on the foreground's turn.
35650
- () => __privateGet(this, _readMaintenance).tick(void 0, 0n, READ_READINESS_ONLY, false),
36058
+ () => __privateGet(this, _readMaintenance).tickReadReadiness(),
36059
+ // A read the kernel still finds behind, with nothing owing its index, owes it again (as a watch does).
36060
+ (request) => {
36061
+ if (request.command.case !== "kernelCall") throw new Error("local read continuation lost its query");
36062
+ __privateGet(this, _readMaintenance).schedule(request.command.value.session, ReadMaintenanceCause.READ_DEBT);
36063
+ },
35651
36064
  (request) => {
35652
36065
  if (request.command.case !== "kernelCall") throw new Error("local read continuation lost its query");
35653
36066
  return __privateGet(this, _application3).call(request, request.command.value);
@@ -35748,6 +36161,7 @@
35748
36161
  onShallowMount: (workspace, credentialCapability) => __privateGet(this, _historyAcquisition).materialise(workspace, credentialCapability),
35749
36162
  // The edge echoes an HTTP offer batch back over this replica's own live link (CAP-764).
35750
36163
  onOffered: (workspace, commitOids) => __privateGet(this, _live3).offered(workspace, commitOids),
36164
+ liveAdmitted: (workspace) => __privateGet(this, _live3).admittedLocal(workspace),
35751
36165
  onOutboxHistoryRequired: (workspace, credentialCapability) => __privateGet(this, _historyAcquisition).requestFromBackground(workspace, credentialCapability),
35752
36166
  backgroundHistory: profile.backgroundHistory !== false,
35753
36167
  onSyncCompleted: (session, event) => {
@@ -35773,7 +36187,7 @@
35773
36187
  __privateGet(this, _origins5).ignored(workspace, origin, "follow");
35774
36188
  return false;
35775
36189
  };
35776
- __privateGet(this, _live3).remoteAdvanced = (workspace) => __privateGet(this, _correspondence3).replicaLinkOpened(workspace);
36190
+ __privateGet(this, _live3).remoteAdvanced = (workspace) => __privateGet(this, _correspondence3).replicaRemoteAdvanced(workspace);
35777
36191
  __privateGet(this, _live3).declined = (workspace) => __privateGet(this, _correspondence3).liveAdmissionDeclined(workspace);
35778
36192
  __privateGet(this, _live3).acknowledged = (workspace, ack) => __privateGet(this, _correspondence3).liveAdmissionAcknowledged(workspace, ack);
35779
36193
  __privateGet(this, _live3).intentsAdmitted = (workspace, intentIds, local) => __privateGet(this, _correspondence3).liveIntentsAdmitted(workspace, intentIds, local);
@@ -35985,7 +36399,7 @@
35985
36399
  },
35986
36400
  owes: (workspace) => __privateGet(this, _readMaintenance).owesReadReadiness(workspace),
35987
36401
  // Read readiness only, as a waiting read takes: never a background command or pack import (CAP-806).
35988
- tick: () => __privateGet(this, _readMaintenance).tick(void 0, 0n, READ_READINESS_ONLY, false),
36402
+ tick: () => __privateGet(this, _readMaintenance).tickReadReadiness(),
35989
36403
  emit: (session, event) => __privateGet(this, _trace13).emit(session, event)
35990
36404
  }));
35991
36405
  __privateSet(this, _modelAdoption, new ModelAdoptionDesk({
@@ -36202,6 +36616,10 @@
36202
36616
  nextEvent() {
36203
36617
  return __privateGet(this, _trace13).nextEvent();
36204
36618
  }
36619
+ /** In-process shells wait on a held local read here instead of polling `resumeAfterMillis`. */
36620
+ localReadResumable(workId2, notify) {
36621
+ return __privateGet(this, _readResponses).onResumable(workId2, notify);
36622
+ }
36205
36623
  close() {
36206
36624
  if (this.retentionOutstanding() > 0) {
36207
36625
  throw new Error("custody retention pending; retain the acknowledged frontiers before disposing the peer");
@@ -36568,9 +36986,8 @@
36568
36986
  let pendingEffectId;
36569
36987
  try {
36570
36988
  if (request.command.case === "socketReceipt") {
36571
- const admission = __privateGet(this, _live3).receive(request, request.command.value);
36572
- if (!admission) return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, { case: "socketObserved", value: create(PeerSocketObservedSchema) });
36573
- request = admission;
36989
+ __privateGet(this, _live3).receive(request.command.value);
36990
+ return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, { case: "socketObserved", value: create(PeerSocketObservedSchema) });
36574
36991
  }
36575
36992
  const result = timelinePhase("access", () => __privateGet(this, _access).handle(request));
36576
36993
  if (result.outcome.case === "correspondencePending") {
@@ -36579,11 +36996,9 @@
36579
36996
  }
36580
36997
  if (result.outcome.case === "watchStarted") __privateGet(this, _subscriptions5).retainDependencies(result.outcome.value.subscriptionId, scope);
36581
36998
  __privateGet(this, _subscriptions5).recoverySettled(result);
36582
- __privateGet(this, _live3).settled(request, result);
36583
36999
  __privateGet(this, _correspondence3).observeResponse(result);
36584
37000
  return result;
36585
37001
  } catch (error) {
36586
- __privateGet(this, _live3).failed(request.requestId);
36587
37002
  const failure = __privateMethod(this, _PeerOffice_instances, failure_fn).call(this, request, "nomos.runtime.workspace_access", error instanceof Error ? error.message : String(error));
36588
37003
  __privateGet(this, _subscriptions5).recoverySettled(failure);
36589
37004
  __privateGet(this, _correspondence3).observeResponse(failure);
@@ -36838,11 +37253,7 @@
36838
37253
  try {
36839
37254
  const mount = __privateGet(this, _sessions14).mountForWorkspace(request.target.workspace);
36840
37255
  const previousHead = __privateGet(this, _kernel27).head(mount, request.requestId);
36841
- const admission = __privateGet(this, _custodyAdmission).admit(
36842
- request,
36843
- request.command.value,
36844
- { journal: !__privateGet(this, _live3).relayed(request.requestId) }
36845
- );
37256
+ const admission = __privateGet(this, _custodyAdmission).admit(request, request.command.value);
36846
37257
  admission.sealedMain = __privateGet(this, _residency5).retainedHead(request.target.workspace);
36847
37258
  if (custodyAdmissionNeedsReadMaintenance(admission)) {
36848
37259
  admission.localMaintenance = __privateGet(this, _readMaintenance).scheduleWorkspace(
@@ -36956,16 +37367,17 @@
36956
37367
  });
36957
37368
  case "historicQuery": {
36958
37369
  const answered2 = __privateGet(this, _historicQueries).execute(request, request.command.value);
36959
- if (answered2.outcome.case === "failure" && READ_INDEX_BUILDING.test(answered2.outcome.value.message)) {
37370
+ if (answered2.outcome.case === "query" && answered2.outcome.value.result.case === "readIndexPending") {
36960
37371
  __privateGet(this, _readMaintenance).schedule(request.command.value.session, ReadMaintenanceCause.READ_DEBT);
37372
+ const workspace = answered2.outcome.value.result.value.workspace || (__privateGet(this, _sessions14).bindingIfPresent(request.command.value.session)?.workspace ?? "");
36961
37373
  return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, {
36962
37374
  case: "unavailable",
36963
37375
  value: create(RuntimeUnavailableSchema, {
36964
37376
  reason: RuntimeUnavailableReason.LOCAL_REPLICA_NOT_READY,
36965
- workspace: __privateGet(this, _sessions14).bindingIfPresent(request.command.value.session)?.workspace ?? "",
37377
+ workspace,
36966
37378
  retryable: true,
36967
37379
  retryAfterMillis: 250,
36968
- detail: answered2.outcome.value.message
37380
+ detail: `the read index of ${workspace} is being built on this device; read maintenance continues it`
36969
37381
  })
36970
37382
  });
36971
37383
  }
@@ -37611,6 +38023,23 @@
37611
38023
  lanes?.wake(delayMillis);
37612
38024
  };
37613
38025
  const runner = {
38026
+ localReadResumable(workId2) {
38027
+ let resolve;
38028
+ const resumable = new Promise((done) => {
38029
+ resolve = done;
38030
+ });
38031
+ let timer;
38032
+ const wait = peer2.localReadResumable(workId2, () => {
38033
+ if (timer !== void 0) clearTimeout(timer);
38034
+ resolve();
38035
+ });
38036
+ if (wait === void 0) return void 0;
38037
+ timer = setTimeout(() => {
38038
+ wait.cancel();
38039
+ resolve();
38040
+ }, wait.afterMillis);
38041
+ return resumable;
38042
+ },
37614
38043
  handleFrame(frame2) {
37615
38044
  const response = peer2.invoke(frame2).responseProtobuf;
37616
38045
  drainEvents();
@@ -37840,7 +38269,7 @@
37840
38269
  if (response.outcome.case === "localReadPending") {
37841
38270
  if (yieldLocalReadToCaller) return responseFrame;
37842
38271
  const pending2 = response.outcome.value;
37843
- await new Promise((resolve) => setTimeout(resolve, pending2.resumeAfterMillis));
38272
+ await (runner.localReadResumable?.(pending2.workId) ?? new Promise((resolve) => setTimeout(resolve, pending2.resumeAfterMillis)));
37844
38273
  responseFrame = await turn(() => runner.handleFrame(toBinary(RuntimeRequestSchema, create(RuntimeRequestSchema, {
37845
38274
  protocolVersion: response.protocolVersion,
37846
38275
  requestId: response.requestId,
@@ -43579,11 +44008,30 @@
43579
44008
  const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
43580
44009
  return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
43581
44010
  };
43582
- var okBytes = async (fetchImpl, url) => {
44011
+ var okBytes = async (fetchImpl, url, progress, expectedBytes) => {
43583
44012
  const response = await fetchImpl(url);
43584
44013
  if (!response.ok) throw new Error(`runtime artifact ${url}: HTTP ${response.status}`);
43585
- return new Uint8Array(await response.arrayBuffer());
44014
+ const reader = progress ? response.body?.getReader() : void 0;
44015
+ if (!reader) return new Uint8Array(await response.arrayBuffer());
44016
+ const total = expectedBytes ?? Number(response.headers.get("content-length") ?? 0);
44017
+ const chunks = [];
44018
+ let received = 0;
44019
+ for (; ; ) {
44020
+ const { done, value } = await reader.read();
44021
+ if (done) break;
44022
+ chunks.push(value);
44023
+ received += value.byteLength;
44024
+ progress(received, total);
44025
+ }
44026
+ const bytes = new Uint8Array(received);
44027
+ let offset = 0;
44028
+ for (const chunk of chunks) {
44029
+ bytes.set(chunk, offset);
44030
+ offset += chunk.byteLength;
44031
+ }
44032
+ return bytes;
43586
44033
  };
44034
+ var elapsedSince = (started) => globalThis.performance.now() - started;
43587
44035
  async function selectReleaseKernel(args) {
43588
44036
  const fetchImpl = args.fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
43589
44037
  const base = args.base.replace(/\/+$/, "");
@@ -43611,11 +44059,27 @@
43611
44059
  }
43612
44060
  }
43613
44061
  const url = new URL(relativeUrl, repositoryUrl).toString();
43614
- const bytes = await okBytes(fetchImpl, url);
43615
- if (expected && (bytes.byteLength !== expected.size || await sha256Hex2(bytes) !== expected.sha256)) {
43616
- throw new Error(`runtime artifact ${url} does not match the OSGi resource it was selected by`);
44062
+ const report = (progress) => {
44063
+ try {
44064
+ args.onProgress?.(progress);
44065
+ } catch {
44066
+ }
44067
+ };
44068
+ let started = globalThis.performance.now();
44069
+ const bytes = await okBytes(fetchImpl, url, args.onProgress ? (receivedBytes, totalBytes) => report({ stage: "download", artifact: name, receivedBytes, totalBytes }) : void 0, expected?.size);
44070
+ report({ stage: "fetched", artifact: name, millis: elapsedSince(started) });
44071
+ if (expected) {
44072
+ started = globalThis.performance.now();
44073
+ if (bytes.byteLength !== expected.size || await sha256Hex2(bytes) !== expected.sha256) {
44074
+ throw new Error(`runtime artifact ${url} does not match the OSGi resource it was selected by`);
44075
+ }
44076
+ report({ stage: "verified", artifact: name, millis: elapsedSince(started) });
44077
+ }
44078
+ if (expected && args.cache) {
44079
+ started = globalThis.performance.now();
44080
+ await args.cache.write(resource.contentSha256, name, bytes);
44081
+ report({ stage: "stored", artifact: name, millis: elapsedSince(started) });
43617
44082
  }
43618
- if (expected && args.cache) await args.cache.write(resource.contentSha256, name, bytes);
43619
44083
  return bytes;
43620
44084
  };
43621
44085
  await verifySelectedKernel({
@@ -43701,6 +44165,8 @@
43701
44165
  var refusedGitTransport = (input) => Promise.reject(new Error(
43702
44166
  `refused: a tab moves no Git bytes itself (${String(input instanceof Request ? input.url : input).split("?")[0]}); custody comes from the workspace's stream`
43703
44167
  ));
44168
+ var DOWNLOAD_PROGRESS_BYTES = 1048576;
44169
+ var megabytes = (bytes) => (bytes / 1048576).toFixed(1);
43704
44170
  async function openBrowserPeer(options) {
43705
44171
  const bootStarted = performance.now();
43706
44172
  const progress = (stage) => {
@@ -43711,6 +44177,7 @@
43711
44177
  }
43712
44178
  };
43713
44179
  const fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
44180
+ const reportedBytes = /* @__PURE__ */ new Map();
43714
44181
  progress("opening browser custody and selecting Kernel artifacts");
43715
44182
  const selecting = selectReleaseKernel({
43716
44183
  base: options.base,
@@ -43718,7 +44185,19 @@
43718
44185
  release: options.release,
43719
44186
  fetchImpl: browserRuntimeFetch(options.base, fetchImpl, globalThis.caches, options.kernelRepositoryUrl),
43720
44187
  cache: options.kernelCache,
43721
- ...options.kernelTrustRoots === void 0 ? {} : { trustRoots: options.kernelTrustRoots }
44188
+ ...options.kernelTrustRoots === void 0 ? {} : { trustRoots: options.kernelTrustRoots },
44189
+ // A new kernel downloads (27 MB) and is verified and stored on the boot path: each step is
44190
+ // progress, so the host keeps waiting, and a slow boot's report times each one (CAP-799).
44191
+ onProgress: (step) => {
44192
+ if (step.stage !== "download") {
44193
+ progress(`${step.stage} ${step.artifact} in ${Math.round(step.millis)}ms`);
44194
+ return;
44195
+ }
44196
+ const last = reportedBytes.get(step.artifact) ?? 0;
44197
+ if (step.receivedBytes - last < DOWNLOAD_PROGRESS_BYTES && step.receivedBytes < step.totalBytes) return;
44198
+ reportedBytes.set(step.artifact, step.receivedBytes);
44199
+ progress(`downloading ${step.artifact} ${megabytes(step.receivedBytes)}/${megabytes(step.totalBytes)} MB`);
44200
+ }
43722
44201
  }).then((selected) => {
43723
44202
  progress("selected Kernel artifacts");
43724
44203
  return selected;