@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.
@@ -7613,8 +7613,10 @@
7613
7613
  var SignOfferPreparationRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 37);
7614
7614
  var SigningIdentityRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 39);
7615
7615
  var KernelRefusalSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 55);
7616
+ var QueryResponseSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 56);
7616
7617
  var ApplicationResultDeltaSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 58);
7617
7618
  var InterfaceCompatibilityQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 60);
7619
+ var ReadIndexPendingSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 64);
7618
7620
  var MaintenanceQuantumQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 65);
7619
7621
  var CarriedWorkspaceOfferSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 80);
7620
7622
  var PrepareOutboundOfferSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 84);
@@ -7892,32 +7894,44 @@
7892
7894
  // ../../platform-shells/browser/runtime_fetch.ts
7893
7895
  init_define_NOMOS_KERNEL_RELEASE();
7894
7896
  init_shims();
7895
- function browserRuntimeFetch(base, fetchImpl, caches2, repositoryUrl) {
7897
+
7898
+ // ../../platform-shells/shared/retained_boot_fetch.ts
7899
+ init_define_NOMOS_KERNEL_RELEASE();
7900
+ init_shims();
7901
+ function retainedBootFetch(base, fetchImpl, store, repositoryUrl) {
7896
7902
  const root = base.replace(/\/+$/, "");
7897
7903
  return async (input, init) => {
7898
7904
  const url = String(input);
7899
7905
  const bootArtifact = url === (repositoryUrl ?? `${root}/v1/runtime/repository.xml`) || url === `${root}/v1/runtime/nomos.law.usdz`;
7900
7906
  if (!bootArtifact) return fetchImpl(input, init);
7901
- const networkInit = {
7902
- ...init,
7903
- cache: "no-store",
7904
- signal: init?.signal ?? AbortSignal.timeout(15e3)
7905
- };
7906
- if (!caches2) return fetchImpl(input, networkInit);
7907
- const cache = await caches2.open("nomos-browser-boot-v1");
7907
+ const networkInit = { ...init, cache: "no-store", signal: init?.signal ?? AbortSignal.timeout(15e3) };
7908
+ if (!store) return fetchImpl(input, networkInit);
7908
7909
  let response;
7910
+ let failure;
7909
7911
  try {
7910
7912
  response = await fetchImpl(input, networkInit);
7911
7913
  } catch (error) {
7912
- const retained = await cache.match(url);
7913
- if (retained) return retained;
7914
- throw error;
7914
+ failure = error;
7915
7915
  }
7916
- if (response.ok) await cache.put(url, response.clone());
7917
- return response;
7916
+ if (response !== void 0 && response.status < 500) {
7917
+ if (response.ok) await store.put(url, response.clone());
7918
+ return response;
7919
+ }
7920
+ const retained = await store.match(url);
7921
+ if (retained) return retained;
7922
+ if (response !== void 0) return response;
7923
+ throw failure;
7918
7924
  };
7919
7925
  }
7920
7926
 
7927
+ // ../../platform-shells/browser/runtime_fetch.ts
7928
+ function browserRuntimeFetch(base, fetchImpl, caches2, repositoryUrl) {
7929
+ return retainedBootFetch(base, fetchImpl, caches2 === void 0 ? void 0 : {
7930
+ match: async (url) => (await caches2.open("nomos-browser-boot-v1")).match(url),
7931
+ put: async (url, response) => (await caches2.open("nomos-browser-boot-v1")).put(url, response)
7932
+ }, repositoryUrl);
7933
+ }
7934
+
7921
7935
  // ../../adapter/proto/nomos/runtime/v2/runtime_pb.js
7922
7936
  init_define_NOMOS_KERNEL_RELEASE();
7923
7937
  init_shims();
@@ -8058,7 +8072,7 @@
8058
8072
  var CustodyBreakPolicy = /* @__PURE__ */ tsEnum(CustodyBreakPolicySchema);
8059
8073
 
8060
8074
  // ../../adapter/proto/nomos/runtime/v2/observability_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DSUZJRUQQABIUChBMSU5LX1NUQVRVU19PUEVOEAESFgoSTElOS19TVEFUVVNfQ0xPU0VEEAIqdgoMVHJhbnNmZXJLaW5kEh0KGVRSQU5TRkVSX0tJTkRfVU5TUEVDSUZJRUQQABIXChNUUkFOU0ZFUl9LSU5EX0RFTFRBEAESFgoSVFJBTlNGRVJfS0lORF9GVUxMEAISFgoSVFJBTlNGRVJfS0lORF9QVVNIEANiBnByb3RvMw", [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]);
8075
+ var file_nomos_runtime_v2_observability_desk = /* @__PURE__ */ fileDesc("Cilub21vcy9ydW50aW1lL3YyL29ic2VydmFiaWxpdHlfZGVzay5wcm90bxIQbm9tb3MucnVudGltZS52MiJCCgxUcmFjZUNvbnRleHQSEAoIdHJhY2VfaWQYASABKAwSDwoHc3Bhbl9pZBgCIAEoDBIPCgdzYW1wbGVkGAMgASgIIp0CCg5SdW50aW1lRmFpbHVyZRIMCgRjb2RlGAEgASgJEg8KB21lc3NhZ2UYAiABKAkSEQoJY29tcG9uZW50GAMgASgJEhYKCXdvcmtzcGFjZRgEIAEoCUgAiAEBEhMKBmRvbWFpbhgFIAEoCUgBiAEBEhYKCWRpcmVjdGl2ZRgGIAEoCUgCiAEBEjkKCmF0dHJpYnV0ZXMYByADKAsyJS5ub21vcy5ydW50aW1lLnYyLkRpYWdub3N0aWNBdHRyaWJ1dGUSMgoEa2luZBgIIAEoDjIkLm5vbW9zLnJ1bnRpbWUudjIuUnVudGltZUZhaWx1cmVLaW5kQgwKCl93b3Jrc3BhY2VCCQoHX2RvbWFpbkIMCgpfZGlyZWN0aXZlIr4BChJSdW50aW1lVW5hdmFpbGFibGU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XQUlUSU5HX0RFUEVOREVOQ1kQBRIkCiBGT0xMT1dfT0JTRVJWQVRJT05fUEhBU0VfT0ZGTElORRAGEi8KK0ZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9JTlZBTElEX0NSRURFTlRJQUwQBxIkCiBGT0xMT1dfT0JTRVJWQVRJT05fUEhBU0VfQkFDS09GRhAIEiwKKEZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9SRUJPUk5fUkVNT1RFTFkQCRIsCihGT0xMT1dfT0JTRVJWQVRJT05fUEhBU0VfUkVQTEFDSU5HX0xPQ0FMEAoSMgouRk9MTE9XX09CU0VSVkFUSU9OX1BIQVNFX0xPQ0FMX0NPUFlfVU5SRUFEQUJMRRALEisKJ0ZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9LRVJORUxfUkVGVVNFRBAMKlcKCkxpbmtTdGF0dXMSGwoXTElOS19TVEFUVVNfVU5TUEVDSUZJRUQQABIUChBMSU5LX1NUQVRVU19PUEVOEAESFgoSTElOS19TVEFUVVNfQ0xPU0VEEAIqdgoMVHJhbnNmZXJLaW5kEh0KGVRSQU5TRkVSX0tJTkRfVU5TUEVDSUZJRUQQABIXChNUUkFOU0ZFUl9LSU5EX0RFTFRBEAESFgoSVFJBTlNGRVJfS0lORF9GVUxMEAISFgoSVFJBTlNGRVJfS0lORF9QVVNIEANiBnByb3RvMw", [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]);
8062
8076
  var RuntimeFailureSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 1);
8063
8077
  var RuntimeUnavailableSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 2);
8064
8078
  var RuntimeRefusalSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 3);
@@ -11630,6 +11644,11 @@
11630
11644
  if (!READINESS_DEBT.test(message)) return void 0;
11631
11645
  return new KernelReadinessPending(/source workspace '([^']+)'/.exec(message)?.[1]?.trim(), message);
11632
11646
  };
11647
+ 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/;
11648
+ var kernelReadIndexBuilding = (message) => {
11649
+ const workspace = READ_INDEX_BUILDING.exec(message)?.[1]?.trim();
11650
+ return workspace === void 0 ? void 0 : { workspace };
11651
+ };
11633
11652
  var requiredForeignWorkspace = (message) => {
11634
11653
  const patterns = [
11635
11654
  /workspace '([^']+)' must be resident in the kernel/,
@@ -11653,9 +11672,31 @@
11653
11672
  throw new KernelWorkspaceResidencyRequired(workspace, failure.message);
11654
11673
  }
11655
11674
  }
11675
+ var KernelRefusal = class extends Error {
11676
+ constructor(failure) {
11677
+ super(`${failure.code}: ${failure.message}`);
11678
+ __publicField(this, "code");
11679
+ __publicField(this, "failure");
11680
+ this.name = "KernelRefusal";
11681
+ this.code = failure.code;
11682
+ this.failure = failure;
11683
+ }
11684
+ };
11656
11685
  function throwKernelFailure(failure) {
11657
11686
  throwIfKernelControlRequired(failure);
11658
- throw new Error(`${failure.code}: ${failure.message}`);
11687
+ throw new KernelRefusal(failure);
11688
+ }
11689
+ var KERNEL_FAILURE_TEXT = /^(NMS-[A-Z0-9]+(?:-[A-Z0-9]+)*): ([\s\S]*)$/;
11690
+ 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;
11691
+ function deterministicKernelRefusal(error) {
11692
+ if (error instanceof KernelWorkspaceResidencyRequired || error instanceof KernelHistoryRequired || error instanceof KernelReadinessPending) return void 0;
11693
+ if (error instanceof KernelRefusal && (error.failure.historyRequired !== void 0 || error.failure.identityProviderWitnessRequired !== void 0)) return void 0;
11694
+ const text = error instanceof Error ? error.message : typeof error === "string" ? error : "";
11695
+ const match = KERNEL_FAILURE_TEXT.exec(text);
11696
+ if (!match) return void 0;
11697
+ const [, code, message] = match;
11698
+ if (ENVIRONMENTAL.test(text) || READINESS_DEBT.test(message) || requiredForeignWorkspace(message) !== void 0) return void 0;
11699
+ return { code, message };
11659
11700
  }
11660
11701
  function rethrowTypedKernelFailure(error) {
11661
11702
  if (error instanceof KernelWorkspaceResidencyRequired || error instanceof KernelHistoryRequired) throw error;
@@ -15018,8 +15059,9 @@
15018
15059
 
15019
15060
  // ../src/runtime/live_inbound_stream.ts
15020
15061
  var LEVEL_BATCH = "level:";
15062
+ var HISTORY_REQUIRED = "nomos.stream.history_required";
15063
+ var CONTAINMENT_ASK_SUFFIX = ":contain";
15021
15064
  var STREAM_WINDOW_CHUNKS = 8;
15022
- var ASK_AGAIN_NANOS = 15000000000n;
15023
15065
  var historySlot = (workspace) => `${workspace}#history`;
15024
15066
  var _ports, _staging, _by, _LiveInboundStream_instances, of_fn, refusalReceipt_fn, offered_fn, completed_fn, askHistory_fn, sliceOffered_fn, sliceChunk_fn, askCheckpoint_fn, askLevel_fn;
15025
15067
  var LiveInboundStream = class {
@@ -15031,7 +15073,10 @@
15031
15073
  __privateSet(this, _ports, ports);
15032
15074
  __privateSet(this, _staging, ports.staging ?? memoryCheckpointStaging());
15033
15075
  }
15034
- /** When this workspace's stream last delivered anything (a waiting procedure is progressing). */
15076
+ /** When this workspace's stream last delivered data to an ask (a waiting procedure is progressing).
15077
+ * A refusal, a frontier, unrelated traffic on the socket and this copy's own re-asking are not
15078
+ * progress: a procedure whose stream only ever says "ask again" gives up and its round fails over
15079
+ * (CAP-838). */
15035
15080
  lastHeard(workspace) {
15036
15081
  return __privateGet(this, _by).get(workspace)?.lastHeard;
15037
15082
  }
@@ -15054,7 +15099,8 @@
15054
15099
  inbound.wants.level = {
15055
15100
  effectId: effect.effectId,
15056
15101
  maxOffers: Math.max(1, request.value.maxOffers),
15057
- remountAfterOffers: request.value.remountAfterOffers
15102
+ remountAfterOffers: request.value.remountAfterOffers,
15103
+ contain: effect.effectId.endsWith(CONTAINMENT_ASK_SUFFIX)
15058
15104
  };
15059
15105
  __privateMethod(this, _LiveInboundStream_instances, askLevel_fn).call(this, effect.workspace, inbound);
15060
15106
  }
@@ -15114,7 +15160,7 @@
15114
15160
  const batch = inbound.levelBatch;
15115
15161
  if (batch) {
15116
15162
  inbound.levelBatch = void 0;
15117
- if (batch.base === __privateGet(this, _ports).head(effect.workspace)) {
15163
+ if (batch.base === __privateGet(this, _ports).head(effect.workspace) || batch.base === request.value.head) {
15118
15164
  inbound.wants.level = void 0;
15119
15165
  return create(PeerStreamReceiptSchema, {
15120
15166
  outcome: { case: "pack", value: batch },
@@ -15125,14 +15171,14 @@
15125
15171
  __privateMethod(this, _LiveInboundStream_instances, askLevel_fn).call(this, effect.workspace, inbound);
15126
15172
  }
15127
15173
  const head = __privateGet(this, _ports).head(effect.workspace);
15128
- if (head && inbound.announced && head === inbound.announced) {
15174
+ if (inbound.announced && (head === inbound.announced || inbound.askedFrom === inbound.announced)) {
15129
15175
  inbound.wants.level = void 0;
15130
15176
  return create(PeerStreamReceiptSchema, {
15131
- outcome: { case: "level", value: head },
15177
+ outcome: { case: "level", value: inbound.announced },
15132
15178
  ...inbound.sealed ? { sealed: inbound.sealed } : {}
15133
15179
  });
15134
15180
  }
15135
- return __privateMethod(this, _LiveInboundStream_instances, refusalReceipt_fn).call(this, inbound);
15181
+ return __privateMethod(this, _LiveInboundStream_instances, refusalReceipt_fn).call(this, inbound, inbound.wants.level?.effectId === effect.effectId && inbound.wants.level.contain);
15136
15182
  }
15137
15183
  if (request.case === "history" || request.case === "ref") {
15138
15184
  const want = inbound.wants.packs.get(request.value.requestId);
@@ -15174,7 +15220,9 @@
15174
15220
  /** One frame from the peer. True when it was the stream's (the live desk handles the rest). */
15175
15221
  frame(workspace, message) {
15176
15222
  const inbound = __privateMethod(this, _LiveInboundStream_instances, of_fn).call(this, workspace);
15177
- inbound.lastHeard = __privateGet(this, _ports).monotonicNanoseconds();
15223
+ if (message.case === "checkpointOffer" || message.case === "checkpointChunk" || message.case === "pack") {
15224
+ inbound.lastHeard = __privateGet(this, _ports).monotonicNanoseconds();
15225
+ }
15178
15226
  switch (message.case) {
15179
15227
  case "frontier":
15180
15228
  if (message.value.response && message.value.head) {
@@ -15229,18 +15277,26 @@
15229
15277
  return false;
15230
15278
  }
15231
15279
  }
15232
- /** Re-ask what is due: a refusal's retry time passed, or an ask heard nothing for too long. */
15280
+ /**
15281
+ * Ask again when a refusal said when to (the peer was opening, or acquiring history). Nothing else
15282
+ * here runs on a timer (CAP-838): the socket is ordered and reliable, every ask is answered on it,
15283
+ * and an ask is re-sent only when its socket re-opens (`opened`) or its refusal's time comes. The
15284
+ * stream used to re-ask whatever had heard nothing for 15 s, and that resend - itself counted as
15285
+ * hearing - hid an ask answered "come back" for ever.
15286
+ */
15233
15287
  drive(workspace) {
15234
15288
  const inbound = __privateGet(this, _by).get(workspace);
15235
- if (!inbound || !this.wanted(workspace)) return void 0;
15289
+ if (!inbound || inbound.askAgainAt === void 0) return void 0;
15290
+ if (!this.wanted(workspace)) {
15291
+ inbound.askAgainAt = void 0;
15292
+ return void 0;
15293
+ }
15236
15294
  const now2 = __privateGet(this, _ports).monotonicNanoseconds();
15237
- const due2 = inbound.askAgainAt ?? inbound.lastHeard + ASK_AGAIN_NANOS;
15238
- if (now2 < due2) return due2 - now2;
15295
+ if (now2 < inbound.askAgainAt) return inbound.askAgainAt - now2;
15239
15296
  inbound.askAgainAt = void 0;
15240
15297
  inbound.refused = void 0;
15241
- inbound.lastHeard = now2;
15242
15298
  this.opened(workspace);
15243
- return ASK_AGAIN_NANOS;
15299
+ return void 0;
15244
15300
  }
15245
15301
  };
15246
15302
  _ports = new WeakMap();
@@ -15256,10 +15312,16 @@
15256
15312
  return inbound;
15257
15313
  };
15258
15314
  /** A terminal refusal (not one that only says when to ask again) ends the procedure's wait. */
15259
- refusalReceipt_fn = function(inbound) {
15315
+ refusalReceipt_fn = function(inbound, contain = false) {
15260
15316
  const refused = inbound.refused;
15261
- if (!refused || refused.retryAfterMillis !== void 0) return void 0;
15317
+ if (!refused) return void 0;
15318
+ const answersContainment = contain && refused.code === HISTORY_REQUIRED;
15319
+ if (refused.retryAfterMillis !== void 0 && !answersContainment) return void 0;
15262
15320
  inbound.refused = void 0;
15321
+ if (answersContainment) {
15322
+ inbound.askAgainAt = void 0;
15323
+ inbound.wants.level = void 0;
15324
+ }
15263
15325
  return create(PeerStreamReceiptSchema, { outcome: { case: "refusal", value: refused } });
15264
15326
  };
15265
15327
  offered_fn = function(workspace, inbound, offer) {
@@ -15303,6 +15365,7 @@
15303
15365
  const held = !taken ? -1 : "pack" in taken ? taken.pack.byteLength : taken.bytes;
15304
15366
  if (held !== transfer.bytes || transfer.received !== transfer.bytes) {
15305
15367
  if (taken && "stagedPackFile" in taken) __privateGet(this, _staging).clear(workspace);
15368
+ if (inbound.wants.checkpoint) __privateMethod(this, _LiveInboundStream_instances, askCheckpoint_fn).call(this, workspace, inbound);
15306
15369
  return;
15307
15370
  }
15308
15371
  inbound.complete = {
@@ -15420,8 +15483,12 @@
15420
15483
  __privateMethod(this, _LiveInboundStream_instances, askCheckpoint_fn).call(this, workspace, inbound);
15421
15484
  return;
15422
15485
  }
15486
+ inbound.announced = void 0;
15487
+ inbound.sealed = void 0;
15488
+ const head = __privateGet(this, _ports).head(workspace) ?? "";
15489
+ inbound.askedFrom = head;
15423
15490
  __privateGet(this, _ports).send(workspace, { case: "frontier", value: create(LiveFrontierSchema, {
15424
- head: __privateGet(this, _ports).head(workspace) ?? "",
15491
+ head,
15425
15492
  response: false,
15426
15493
  maxOffers: level.maxOffers,
15427
15494
  remountAfterOffers: level.remountAfterOffers,
@@ -15956,6 +16023,24 @@
15956
16023
  return void 0;
15957
16024
  }
15958
16025
  var PLACEMENT_REFERENCE = "refs/nomos/placement";
16026
+ function readIndexPendingAnswer(request, message) {
16027
+ if (request.operation.case !== "query" || request.operation.value.query.case === "maintenanceQuantum") return void 0;
16028
+ const building = kernelReadIndexBuilding(message);
16029
+ if (building === void 0) return void 0;
16030
+ const target3 = request.operation.value.target;
16031
+ return create(CallResponseSchema, {
16032
+ protocolVersion: request.protocolVersion,
16033
+ requestId: request.requestId,
16034
+ outcome: { case: "query", value: create(QueryResponseSchema, {
16035
+ result: { case: "readIndexPending", value: create(ReadIndexPendingSchema, {
16036
+ workspace: target3?.workspace || building.workspace,
16037
+ branch: target3?.branch ?? "",
16038
+ // The sliced build names no frontier: it restarts at whatever head main holds when it continues.
16039
+ requestedFrontier: ""
16040
+ }) }
16041
+ }) }
16042
+ });
16043
+ }
15959
16044
  var _kernel, _activeOperation, _signingSequence, _releaseSequence, _onWorkspaceUse, _onPlacementMoved, _attached, _residency, _KernelPort_instances, mount_fn, custodyCall_fn, call_fn, timedCall_fn, exclusive_fn;
15960
16045
  var KernelPort = class {
15961
16046
  /** `onPlacementMoved` hears of every placement frontier this port sees move: an admitted
@@ -16977,6 +17062,8 @@
16977
17062
  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" : "";
16978
17063
  error.message = `kernel-operation=${top}/${nested}: ${error.message}`;
16979
17064
  }
17065
+ const pending = readIndexPendingAnswer(request, error instanceof Error ? error.message : String(error));
17066
+ if (pending !== void 0) return pending;
16980
17067
  rethrowTypedKernelFailure(error);
16981
17068
  }
16982
17069
  if (response.requestId !== request.requestId) {
@@ -16987,6 +17074,9 @@
16987
17074
  __privateGet(this, _residency).after(request, response);
16988
17075
  const placementMoved = placementMovedBy(request, response);
16989
17076
  if (placementMoved !== void 0) __privateGet(this, _onPlacementMoved).call(this, placementMoved);
17077
+ if (response.outcome.case === "failure") {
17078
+ return readIndexPendingAnswer(request, response.outcome.value.message) ?? response;
17079
+ }
16990
17080
  return response;
16991
17081
  };
16992
17082
  /** [#call] with the opt-in timeline trace: encode, kernel and decode timed separately. */
@@ -23567,7 +23657,7 @@
23567
23657
  var DURABILITY_FLUSH_MAX_DELAY_NANOSECONDS = LOCAL_WRITE_STALENESS_CAP_NANOSECONDS;
23568
23658
  var CUSTODY_PACKING_PAUSE_NANOSECONDS = 1500000000n;
23569
23659
  var CUSTODY_BURST_SLICE_INTERVAL_NANOSECONDS = 250000000n;
23570
- 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;
23660
+ 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;
23571
23661
  var ReadMaintenanceDesk = class {
23572
23662
  constructor(queries, sessions, trace, clock2, observer = {}, deferredDurability = false, writeBurst) {
23573
23663
  __privateAdd(this, _ReadMaintenanceDesk_instances);
@@ -23662,188 +23752,26 @@
23662
23752
  * (a waiting read's own turn advances read readiness only).
23663
23753
  */
23664
23754
  tick(request, sessionlessNotBeforeNanoseconds = 0n, backgroundNotBeforeNanoseconds = 0n, durability = true) {
23665
- const now2 = __privateGet(this, _clock7).monotonicNanoseconds();
23666
- const custodySlice = (workspace2) => __privateMethod(this, _ReadMaintenanceDesk_instances, custodyBurstSlice_fn).call(this, now2, workspace2);
23667
- const due2 = (demand2) => {
23668
- const held = demand2.session || demand2.awaited || demand2.retryNotBeforeNanoseconds > sessionlessNotBeforeNanoseconds ? demand2.retryNotBeforeNanoseconds : sessionlessNotBeforeNanoseconds;
23669
- const ordinary = demand2.read || demand2.awaited || held > backgroundNotBeforeNanoseconds ? held : backgroundNotBeforeNanoseconds;
23670
- const hold = demand2.read || demand2.awaited || !demand2.background?.maintainGitCustody ? void 0 : custodySlice(demand2.workspace);
23671
- if (!hold) return ordinary;
23672
- if (hold.slice && durability) return held > hold.at ? held : hold.at;
23673
- return ordinary > hold.at ? ordinary : hold.at;
23674
- };
23675
- const entry = [...__privateGet(this, _pending).entries()].find(([, demand2]) => due2(demand2) <= now2);
23676
- const flush = __privateGet(this, _flush);
23677
- 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)) {
23678
- return __privateMethod(this, _ReadMaintenanceDesk_instances, tickFlush_fn).call(this, flush, request);
23679
- }
23680
- const pinDue = (pin) => {
23681
- const held = pin.session ? 0n : sessionlessNotBeforeNanoseconds;
23682
- return [pin.notBeforeNanoseconds, held, backgroundNotBeforeNanoseconds].reduce((latest, at) => at > latest ? at : latest, 0n);
23683
- };
23684
- if (!entry) {
23685
- const pin = [...__privateGet(this, _pins).entries()].find(([, idle]) => pinDue(idle) <= now2);
23686
- if (pin) return __privateMethod(this, _ReadMaintenanceDesk_instances, tickPin_fn).call(this, pin[0], pin[1], request);
23687
- return create(MaintenanceTickedSchema, {
23688
- pending: this.hasPending(),
23689
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, now2, due2, pinDue)
23690
- });
23691
- }
23692
- const [workspace, demand] = entry;
23693
- const mount = demand.session ? __privateGet(this, _sessions5).mountForSession(demand.session) : __privateGet(this, _sessions5).mountForWorkspace(workspace);
23694
- const read = demand.read;
23695
- const activeCause = read?.cause ?? demand.background?.cause;
23696
- if (activeCause === void 0) {
23697
- throw new Error(`maintenance demand for '${workspace}' has no work`);
23698
- }
23699
- const command = read ? void 0 : demand.background?.command;
23700
- const burstSlice = read === void 0 && demand.background?.maintainGitCustody === true && durability && custodySlice(workspace)?.slice === true;
23701
- const synthetic = request ?? create(RuntimeRequestSchema, {
23702
- protocolVersion: 2,
23703
- requestId: ++__privateWrapper(this, _sequence8)._
23755
+ const turn = __privateMethod(this, _ReadMaintenanceDesk_instances, turn_fn).call(this, request, sessionlessNotBeforeNanoseconds, { case: "until", atNanoseconds: backgroundNotBeforeNanoseconds }, durability);
23756
+ return turn.case === "ran" ? turn.ticked : create(MaintenanceTickedSchema, {
23757
+ pending: turn.pending,
23758
+ nextTickAfterMillis: turn.nextDelayMillis ?? 0
23704
23759
  });
23705
- try {
23706
- const progress = __privateGet(this, _trace6).measure(
23707
- "peer.read-maintenance.quantum",
23708
- { request: synthetic, ...demand.session ? { session: demand.session } : {}, workspace },
23709
- {
23710
- "maintenance.cause": ReadMaintenanceCause[activeCause],
23711
- ...command ? {
23712
- "maintenance.domain": command.domain,
23713
- "maintenance.package": command.packageHash,
23714
- ...command.directive ? { "maintenance.directive": command.directive } : {}
23715
- } : {}
23716
- },
23717
- () => __privateGet(this, _queries3).maintenanceQuantum(demand.session ?? "", mount, synthetic.requestId, {
23718
- ...command?.domain === void 0 ? {} : { requestedDomain: command.domain },
23719
- ...command?.packageHash === void 0 ? {} : { requestedPackage: command.packageHash },
23720
- ...command?.directive === void 0 ? {} : { requestedDirective: command.directive },
23721
- maintainGitCustody: read === void 0 && demand.background?.maintainGitCustody === true,
23722
- // Only reached inside a burst under the growth guard: one small packing slice.
23723
- ...burstSlice ? { localWriteBurst: true } : {},
23724
- // Readiness is one kernel-reported fact per workspace frontier. Every
23725
- // read demand repays all of it; no cause selects a weaker variant that
23726
- // would leave the workspace unusable as a foreign-read source.
23727
- readIndexOnly: read !== void 0
23728
- })
23729
- );
23730
- const elapsedNanoseconds = __privateGet(this, _clock7).monotonicNanoseconds() - now2;
23731
- if (slowQuantumObserver && elapsedNanoseconds >= 300000000n) {
23732
- slowQuantumObserver(`[nomos-kernel-perf] ${JSON.stringify({
23733
- op: "peer_maintenance_quantum",
23734
- totalMs: Number(elapsedNanoseconds / 1000000n),
23735
- cause: ReadMaintenanceCause[activeCause],
23736
- read: read !== void 0,
23737
- awaited: demand.awaited === true,
23738
- session: demand.session !== void 0,
23739
- backgroundHoldMs: Number((backgroundNotBeforeNanoseconds - now2) / 1000000n),
23740
- sessionlessHoldMs: Number((sessionlessNotBeforeNanoseconds - now2) / 1000000n),
23741
- caller: (new Error().stack ?? "").split("\n").slice(2, 6).map((frame2) => frame2.trim()).join(" < ")
23742
- })}`);
23743
- }
23744
- __privateMethod(this, _ReadMaintenanceDesk_instances, notePressure_fn).call(this, workspace, progress.looseCustodyPressure);
23745
- if (burstSlice) __privateSet(this, _lastBurstSliceNanoseconds, now2);
23746
- const observed = create(ReadMaintenanceProgressSchema, {
23747
- workspace,
23748
- cause: activeCause,
23749
- kernel: progress
23750
- });
23751
- __privateGet(this, _trace6).emit(demand.session, {
23752
- case: "maintenanceProgress",
23753
- value: observed
23754
- });
23755
- if (__privateGet(this, _deferredDurability)) __privateMethod(this, _ReadMaintenanceDesk_instances, oweFlush_fn).call(this, workspace, demand.session, false);
23756
- __privateGet(this, _pending).delete(workspace);
23757
- if (progress.maintenancePending) {
23758
- if (read) {
23759
- const rest = [...__privateGet(this, _pending).entries()];
23760
- __privateGet(this, _pending).clear();
23761
- __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
23762
- for (const [key, value] of rest) __privateGet(this, _pending).set(key, value);
23763
- } else {
23764
- __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
23765
- }
23766
- } else if (read && demand.background) {
23767
- const { read: _settled4, awaited: _served, ...backgroundDemand } = demand;
23768
- __privateGet(this, _pending).set(workspace, {
23769
- ...backgroundDemand,
23770
- background: read.owedByAdvance ? { ...demand.background, announced: true } : demand.background,
23771
- failures: 0
23772
- });
23773
- __privateGet(this, _trace6).emit(demand.session, {
23774
- case: "maintenanceProgress",
23775
- value: create(ReadMaintenanceProgressSchema, {
23776
- workspace,
23777
- cause: demand.background.cause
23778
- })
23779
- });
23780
- }
23781
- if (!progress.maintenancePending) {
23782
- if (read?.owedByAdvance) __privateGet(this, _observer).frontierAdvanced?.(workspace);
23783
- else if (read) __privateGet(this, _observer).readReady?.(workspace);
23784
- else if (demand.background?.maintainGitCustody && !demand.background.announced) {
23785
- __privateGet(this, _observer).frontierAdvanced?.(workspace);
23786
- }
23787
- }
23788
- return create(MaintenanceTickedSchema, {
23789
- pending: __privateGet(this, _pending).size > 0,
23790
- progress: observed,
23791
- // With no debt left, an armed idle pin names when the host should wake next.
23792
- nextTickAfterMillis: progress.maintenancePending ? 20 : __privateGet(this, _pending).size === 0 && this.hasIdleWork() ? __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) : 0
23793
- });
23794
- } catch (error) {
23795
- const format = localCopyFormatRefusal(error);
23796
- if (format !== void 0) {
23797
- __privateGet(this, _pending).delete(workspace);
23798
- __privateGet(this, _pins).delete(workspace);
23799
- __privateSet(this, _revision3, __privateGet(this, _revision3) + 1);
23800
- __privateGet(this, _observer).localCopyUnreadable?.(workspace, format);
23801
- __privateGet(this, _trace6).emit(demand.session, {
23802
- case: "maintenanceProgress",
23803
- value: create(ReadMaintenanceProgressSchema, {
23804
- workspace,
23805
- cause: activeCause,
23806
- stopped: true
23807
- })
23808
- });
23809
- return create(MaintenanceTickedSchema, {
23810
- pending: __privateGet(this, _pending).size > 0,
23811
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
23812
- });
23813
- }
23814
- const failures = demand.failures + 1;
23815
- __privateGet(this, _pending).delete(workspace);
23816
- const retryMillis = Math.min(30 * 60 * 1e3, 1e3 * 2 ** Math.min(failures - 1, 10));
23817
- slowQuantumObserver?.(`[nomos-kernel-perf] ${JSON.stringify({
23818
- op: "peer_maintenance_failure",
23819
- failed: true,
23820
- workspace,
23821
- cause: ReadMaintenanceCause[activeCause],
23822
- failures,
23823
- retryAfterMillis: retryMillis,
23824
- totalMs: Number((__privateGet(this, _clock7).monotonicNanoseconds() - now2) / 1000000n),
23825
- error: (error instanceof Error ? error.message : String(error)).slice(0, 600)
23826
- })}`);
23827
- __privateGet(this, _pending).set(workspace, {
23828
- ...demand,
23829
- failures,
23830
- retryNotBeforeNanoseconds: __privateGet(this, _clock7).monotonicNanoseconds() + BigInt(retryMillis) * 1000000n
23831
- });
23832
- __privateGet(this, _trace6).emit(demand.session, {
23833
- case: "maintenanceProgress",
23834
- value: create(ReadMaintenanceProgressSchema, {
23835
- workspace,
23836
- cause: activeCause,
23837
- retryAfterMillis: retryMillis
23838
- })
23839
- });
23840
- return create(MaintenanceTickedSchema, {
23841
- pending: true,
23842
- // Backoff belongs to the failed workspace. Another workspace's ready
23843
- // index or changed watches must not wait for this retry deadline.
23844
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
23845
- });
23760
+ }
23761
+ /**
23762
+ * A waiting read's turn: advance read readiness only. It never runs a background command, closure
23763
+ * warm, pack import or durability flush on the foreground's turn, and never reports a wake for
23764
+ * that background work: with only background work owed its wake is `none`.
23765
+ */
23766
+ tickReadReadiness() {
23767
+ const turn = __privateMethod(this, _ReadMaintenanceDesk_instances, turn_fn).call(this, void 0, 0n, { case: "readReadinessOnly" }, false);
23768
+ if (turn.case === "ran") {
23769
+ return { ticked: turn.ticked, wake: { case: "after", millis: turn.ticked.nextTickAfterMillis } };
23846
23770
  }
23771
+ return {
23772
+ ticked: create(MaintenanceTickedSchema, { pending: turn.pending, nextTickAfterMillis: turn.nextDelayMillis ?? 0 }),
23773
+ wake: turn.nextDelayMillis === void 0 ? { case: "none" } : { case: "after", millis: turn.nextDelayMillis }
23774
+ };
23847
23775
  }
23848
23776
  /** Drop any demand for a workspace no maintenance can serve (an unreadable copy). */
23849
23777
  forget(workspace) {
@@ -23936,6 +23864,7 @@
23936
23864
  for (const [key, value] of entries.filter(([key2]) => key2 !== workspace)) __privateGet(this, _pending).set(key, value);
23937
23865
  }
23938
23866
  __privateSet(this, _revision3, __privateGet(this, _revision3) + 1);
23867
+ if (read && (!existing?.read || isReadDemand)) __privateGet(this, _observer).readinessMayChange?.(workspace);
23939
23868
  if (!existing || existing.read?.cause !== read?.cause || existing.background?.cause !== background?.cause) {
23940
23869
  __privateGet(this, _trace6).emit(session ?? existing?.session, {
23941
23870
  case: "maintenanceProgress",
@@ -23943,6 +23872,197 @@
23943
23872
  });
23944
23873
  }
23945
23874
  };
23875
+ turn_fn = function(request, sessionlessNotBeforeNanoseconds, backgroundHold, durability) {
23876
+ const now2 = __privateGet(this, _clock7).monotonicNanoseconds();
23877
+ const backgroundNotBeforeNanoseconds = backgroundHold.case === "until" ? backgroundHold.atNanoseconds : void 0;
23878
+ const custodySlice = (workspace2) => __privateMethod(this, _ReadMaintenanceDesk_instances, custodyBurstSlice_fn).call(this, now2, workspace2);
23879
+ const due2 = (demand2) => {
23880
+ const held = demand2.session || demand2.awaited || demand2.retryNotBeforeNanoseconds > sessionlessNotBeforeNanoseconds ? demand2.retryNotBeforeNanoseconds : sessionlessNotBeforeNanoseconds;
23881
+ if (!demand2.read && !demand2.awaited && backgroundNotBeforeNanoseconds === void 0) return void 0;
23882
+ const ordinary = demand2.read || demand2.awaited || backgroundNotBeforeNanoseconds === void 0 || held > backgroundNotBeforeNanoseconds ? held : backgroundNotBeforeNanoseconds;
23883
+ const hold = demand2.read || demand2.awaited || !demand2.background?.maintainGitCustody ? void 0 : custodySlice(demand2.workspace);
23884
+ if (!hold) return ordinary;
23885
+ if (hold.slice && durability) return held > hold.at ? held : hold.at;
23886
+ return ordinary > hold.at ? ordinary : hold.at;
23887
+ };
23888
+ const entry = [...__privateGet(this, _pending).entries()].find(([, demand2]) => {
23889
+ const at = due2(demand2);
23890
+ return at !== void 0 && at <= now2;
23891
+ });
23892
+ const flush = __privateGet(this, _flush);
23893
+ 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)) {
23894
+ return { case: "ran", ticked: __privateMethod(this, _ReadMaintenanceDesk_instances, tickFlush_fn).call(this, flush, request) };
23895
+ }
23896
+ const pinDue = (pin) => {
23897
+ if (backgroundNotBeforeNanoseconds === void 0) return void 0;
23898
+ const held = pin.session ? 0n : sessionlessNotBeforeNanoseconds;
23899
+ return [pin.notBeforeNanoseconds, held, backgroundNotBeforeNanoseconds].reduce((latest, at) => at > latest ? at : latest, 0n);
23900
+ };
23901
+ if (!entry) {
23902
+ const pin = [...__privateGet(this, _pins).entries()].find(([, idle]) => {
23903
+ const at = pinDue(idle);
23904
+ return at !== void 0 && at <= now2;
23905
+ });
23906
+ if (pin) return { case: "ran", ticked: __privateMethod(this, _ReadMaintenanceDesk_instances, tickPin_fn).call(this, pin[0], pin[1], request) };
23907
+ return { case: "idle", pending: this.hasPending(), nextDelayMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, now2, due2, pinDue, durability) };
23908
+ }
23909
+ const [workspace, demand] = entry;
23910
+ const mount = demand.session ? __privateGet(this, _sessions5).mountForSession(demand.session) : __privateGet(this, _sessions5).mountForWorkspace(workspace);
23911
+ const read = demand.read;
23912
+ const activeCause = read?.cause ?? demand.background?.cause;
23913
+ if (activeCause === void 0) {
23914
+ throw new Error(`maintenance demand for '${workspace}' has no work`);
23915
+ }
23916
+ const command = read ? void 0 : demand.background?.command;
23917
+ const burstSlice = read === void 0 && demand.background?.maintainGitCustody === true && durability && custodySlice(workspace)?.slice === true;
23918
+ const synthetic = request ?? create(RuntimeRequestSchema, {
23919
+ protocolVersion: 2,
23920
+ requestId: ++__privateWrapper(this, _sequence8)._
23921
+ });
23922
+ try {
23923
+ const progress = __privateGet(this, _trace6).measure(
23924
+ "peer.read-maintenance.quantum",
23925
+ { request: synthetic, ...demand.session ? { session: demand.session } : {}, workspace },
23926
+ {
23927
+ "maintenance.cause": ReadMaintenanceCause[activeCause],
23928
+ ...command ? {
23929
+ "maintenance.domain": command.domain,
23930
+ "maintenance.package": command.packageHash,
23931
+ ...command.directive ? { "maintenance.directive": command.directive } : {}
23932
+ } : {}
23933
+ },
23934
+ () => __privateGet(this, _queries3).maintenanceQuantum(demand.session ?? "", mount, synthetic.requestId, {
23935
+ ...command?.domain === void 0 ? {} : { requestedDomain: command.domain },
23936
+ ...command?.packageHash === void 0 ? {} : { requestedPackage: command.packageHash },
23937
+ ...command?.directive === void 0 ? {} : { requestedDirective: command.directive },
23938
+ maintainGitCustody: read === void 0 && demand.background?.maintainGitCustody === true,
23939
+ // Only reached inside a burst under the growth guard: one small packing slice.
23940
+ ...burstSlice ? { localWriteBurst: true } : {},
23941
+ // Readiness is one kernel-reported fact per workspace frontier. Every
23942
+ // read demand repays all of it; no cause selects a weaker variant that
23943
+ // would leave the workspace unusable as a foreign-read source.
23944
+ readIndexOnly: read !== void 0
23945
+ })
23946
+ );
23947
+ const elapsedNanoseconds = __privateGet(this, _clock7).monotonicNanoseconds() - now2;
23948
+ if (slowQuantumObserver && elapsedNanoseconds >= 300000000n) {
23949
+ slowQuantumObserver(`[nomos-kernel-perf] ${JSON.stringify({
23950
+ op: "peer_maintenance_quantum",
23951
+ totalMs: Number(elapsedNanoseconds / 1000000n),
23952
+ cause: ReadMaintenanceCause[activeCause],
23953
+ read: read !== void 0,
23954
+ awaited: demand.awaited === true,
23955
+ session: demand.session !== void 0,
23956
+ backgroundHoldMs: backgroundNotBeforeNanoseconds === void 0 ? "read-readiness-only" : Number((backgroundNotBeforeNanoseconds - now2) / 1000000n),
23957
+ sessionlessHoldMs: Number((sessionlessNotBeforeNanoseconds - now2) / 1000000n),
23958
+ caller: (new Error().stack ?? "").split("\n").slice(2, 6).map((frame2) => frame2.trim()).join(" < ")
23959
+ })}`);
23960
+ }
23961
+ __privateMethod(this, _ReadMaintenanceDesk_instances, notePressure_fn).call(this, workspace, progress.looseCustodyPressure);
23962
+ if (burstSlice) __privateSet(this, _lastBurstSliceNanoseconds, now2);
23963
+ const observed = create(ReadMaintenanceProgressSchema, {
23964
+ workspace,
23965
+ cause: activeCause,
23966
+ kernel: progress
23967
+ });
23968
+ __privateGet(this, _trace6).emit(demand.session, {
23969
+ case: "maintenanceProgress",
23970
+ value: observed
23971
+ });
23972
+ if (__privateGet(this, _deferredDurability)) __privateMethod(this, _ReadMaintenanceDesk_instances, oweFlush_fn).call(this, workspace, demand.session, false);
23973
+ __privateGet(this, _pending).delete(workspace);
23974
+ if (progress.maintenancePending) {
23975
+ if (read) {
23976
+ const rest = [...__privateGet(this, _pending).entries()];
23977
+ __privateGet(this, _pending).clear();
23978
+ __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
23979
+ for (const [key, value] of rest) __privateGet(this, _pending).set(key, value);
23980
+ } else {
23981
+ __privateGet(this, _pending).set(workspace, { ...demand, failures: 0 });
23982
+ }
23983
+ } else if (read && demand.background) {
23984
+ const { read: _settled4, awaited: _served, ...backgroundDemand } = demand;
23985
+ __privateGet(this, _pending).set(workspace, {
23986
+ ...backgroundDemand,
23987
+ background: read.owedByAdvance ? { ...demand.background, announced: true } : demand.background,
23988
+ failures: 0
23989
+ });
23990
+ __privateGet(this, _trace6).emit(demand.session, {
23991
+ case: "maintenanceProgress",
23992
+ value: create(ReadMaintenanceProgressSchema, {
23993
+ workspace,
23994
+ cause: demand.background.cause
23995
+ })
23996
+ });
23997
+ }
23998
+ if (!progress.maintenancePending) {
23999
+ if (read?.owedByAdvance) __privateGet(this, _observer).frontierAdvanced?.(workspace);
24000
+ else if (read) __privateGet(this, _observer).readReady?.(workspace);
24001
+ else if (demand.background?.maintainGitCustody && !demand.background.announced) {
24002
+ __privateGet(this, _observer).frontierAdvanced?.(workspace);
24003
+ }
24004
+ }
24005
+ __privateGet(this, _observer).readinessMayChange?.(workspace);
24006
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
24007
+ pending: __privateGet(this, _pending).size > 0,
24008
+ progress: observed,
24009
+ // With no debt left, an armed idle pin names when the host should wake next.
24010
+ 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
24011
+ }) };
24012
+ } catch (error) {
24013
+ const format = localCopyFormatRefusal(error);
24014
+ if (format !== void 0) {
24015
+ __privateGet(this, _pending).delete(workspace);
24016
+ __privateGet(this, _pins).delete(workspace);
24017
+ __privateSet(this, _revision3, __privateGet(this, _revision3) + 1);
24018
+ __privateGet(this, _observer).localCopyUnreadable?.(workspace, format);
24019
+ __privateGet(this, _trace6).emit(demand.session, {
24020
+ case: "maintenanceProgress",
24021
+ value: create(ReadMaintenanceProgressSchema, {
24022
+ workspace,
24023
+ cause: activeCause,
24024
+ stopped: true
24025
+ })
24026
+ });
24027
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
24028
+ pending: __privateGet(this, _pending).size > 0,
24029
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24030
+ }) };
24031
+ }
24032
+ const failures = demand.failures + 1;
24033
+ __privateGet(this, _pending).delete(workspace);
24034
+ const retryMillis = Math.min(30 * 60 * 1e3, 1e3 * 2 ** Math.min(failures - 1, 10));
24035
+ slowQuantumObserver?.(`[nomos-kernel-perf] ${JSON.stringify({
24036
+ op: "peer_maintenance_failure",
24037
+ failed: true,
24038
+ workspace,
24039
+ cause: ReadMaintenanceCause[activeCause],
24040
+ failures,
24041
+ retryAfterMillis: retryMillis,
24042
+ totalMs: Number((__privateGet(this, _clock7).monotonicNanoseconds() - now2) / 1000000n),
24043
+ error: (error instanceof Error ? error.message : String(error)).slice(0, 600)
24044
+ })}`);
24045
+ __privateGet(this, _pending).set(workspace, {
24046
+ ...demand,
24047
+ failures,
24048
+ retryNotBeforeNanoseconds: __privateGet(this, _clock7).monotonicNanoseconds() + BigInt(retryMillis) * 1000000n
24049
+ });
24050
+ __privateGet(this, _trace6).emit(demand.session, {
24051
+ case: "maintenanceProgress",
24052
+ value: create(ReadMaintenanceProgressSchema, {
24053
+ workspace,
24054
+ cause: activeCause,
24055
+ retryAfterMillis: retryMillis
24056
+ })
24057
+ });
24058
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
24059
+ pending: true,
24060
+ // Backoff belongs to the failed workspace. Another workspace's ready
24061
+ // index or changed watches must not wait for this retry deadline.
24062
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24063
+ }) };
24064
+ }
24065
+ };
23946
24066
  /** Owe the kernel its ordered flush. The first write it covers fixes `owedSince`; the shared
23947
24067
  * burst signal then releases it once the offers pause, or at the cap (CAP-750: one detector). */
23948
24068
  oweFlush_fn = function(workspace, session, local) {
@@ -24005,7 +24125,7 @@
24005
24125
  }
24006
24126
  return create(MaintenanceTickedSchema, {
24007
24127
  pending: this.hasPending(),
24008
- nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24128
+ nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24009
24129
  });
24010
24130
  } catch (error) {
24011
24131
  const failures = flush.failures + 1;
@@ -24029,7 +24149,7 @@
24029
24149
  });
24030
24150
  return create(MaintenanceTickedSchema, {
24031
24151
  pending: this.hasPending(),
24032
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24152
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24033
24153
  });
24034
24154
  }
24035
24155
  };
@@ -24060,7 +24180,7 @@
24060
24180
  }
24061
24181
  return create(MaintenanceTickedSchema, {
24062
24182
  pending: this.hasPending(),
24063
- nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24183
+ nextTickAfterMillis: progress.maintenancePending ? 20 : __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24064
24184
  });
24065
24185
  } catch (error) {
24066
24186
  slowQuantumObserver?.(`[nomos-kernel-perf] ${JSON.stringify({
@@ -24072,44 +24192,51 @@
24072
24192
  })}`);
24073
24193
  return create(MaintenanceTickedSchema, {
24074
24194
  pending: this.hasPending(),
24075
- nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds())
24195
+ nextTickAfterMillis: __privateMethod(this, _ReadMaintenanceDesk_instances, nextDelay_fn).call(this, __privateGet(this, _clock7).monotonicNanoseconds()) ?? 0
24076
24196
  });
24077
24197
  }
24078
24198
  };
24079
- nextDelay_fn = function(now2, due2 = (demand) => demand.retryNotBeforeNanoseconds, pinDue = (pin) => pin.notBeforeNanoseconds) {
24199
+ /** Milliseconds until the earliest owed work this turn serves; `undefined` when none is owed. */
24200
+ nextDelay_fn = function(now2, due2 = (demand) => demand.retryNotBeforeNanoseconds, pinDue = (pin) => pin.notBeforeNanoseconds, flushes = true) {
24080
24201
  let earliest;
24081
24202
  for (const demand of __privateGet(this, _pending).values()) {
24082
24203
  const at = due2(demand);
24204
+ if (at === void 0) continue;
24083
24205
  if (at <= now2) return 0;
24084
24206
  if (earliest === void 0 || at < earliest) earliest = at;
24085
24207
  }
24086
24208
  for (const pin of __privateGet(this, _pins).values()) {
24087
24209
  const at = pinDue(pin);
24210
+ if (at === void 0) continue;
24088
24211
  if (at <= now2) return 0;
24089
24212
  if (earliest === void 0 || at < earliest) earliest = at;
24090
24213
  }
24091
- if (__privateGet(this, _flush)) {
24214
+ if (flushes && __privateGet(this, _flush)) {
24092
24215
  const at = __privateMethod(this, _ReadMaintenanceDesk_instances, flushDueAt_fn).call(this, __privateGet(this, _flush));
24093
24216
  if (at <= now2) return 0;
24094
24217
  if (earliest === void 0 || at < earliest) earliest = at;
24095
24218
  }
24096
- return earliest === void 0 ? 0 : Number((earliest - now2 + 999999n) / 1000000n);
24219
+ return earliest === void 0 ? void 0 : Number((earliest - now2 + 999999n) / 1000000n);
24097
24220
  };
24098
24221
 
24099
24222
  // ../src/runtime/read_response_desk.ts
24100
24223
  init_define_NOMOS_KERNEL_RELEASE();
24101
24224
  init_shims();
24102
- var _waiting5, _clock8, _tick, _read2, _sequence9, _ReadResponseDesk_instances, now_fn3, pending_fn;
24225
+ var READ_RETENTION_MILLIS = 12e4;
24226
+ var READ_RESUME_MAX_MILLIS = 1e3;
24227
+ var _waiting5, _clock8, _tick, _owe, _read2, _sequence9, _ReadResponseDesk_instances, now_fn3, pending_fn;
24103
24228
  var ReadResponseDesk = class {
24104
- constructor(clock2, tick, read) {
24229
+ constructor(clock2, tick, owe, read) {
24105
24230
  __privateAdd(this, _ReadResponseDesk_instances);
24106
24231
  __privateAdd(this, _waiting5, /* @__PURE__ */ new Map());
24107
24232
  __privateAdd(this, _clock8);
24108
24233
  __privateAdd(this, _tick);
24234
+ __privateAdd(this, _owe);
24109
24235
  __privateAdd(this, _read2);
24110
24236
  __privateAdd(this, _sequence9, 0);
24111
24237
  __privateSet(this, _clock8, clock2);
24112
24238
  __privateSet(this, _tick, tick);
24239
+ __privateSet(this, _owe, owe);
24113
24240
  __privateSet(this, _read2, read);
24114
24241
  }
24115
24242
  begin(request, dependency) {
@@ -24119,18 +24246,27 @@
24119
24246
  const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24120
24247
  for (const [id, work] of __privateGet(this, _waiting5)) if (work.deadline <= now2) __privateGet(this, _waiting5).delete(id);
24121
24248
  const workId2 = `local-read-${++__privateWrapper(this, _sequence9)._}`;
24122
- __privateGet(this, _waiting5).set(workId2, { request, dependency, deadline: now2 + 12e4, notBefore: now2 });
24249
+ __privateGet(this, _waiting5).set(workId2, {
24250
+ request,
24251
+ dependency,
24252
+ deadline: now2 + READ_RETENTION_MILLIS,
24253
+ notBefore: now2,
24254
+ idle: false,
24255
+ // The office owed this frontier's debt when the kernel first answered pending.
24256
+ owedFor: dependency.requestedFrontier,
24257
+ waiters: /* @__PURE__ */ new Set()
24258
+ });
24123
24259
  return create(LocalReadPendingSchema, { workId: workId2 });
24124
24260
  }
24125
24261
  resume(workId2, requestId) {
24126
24262
  const work = __privateGet(this, _waiting5).get(workId2);
24127
24263
  if (!work || work.request.requestId !== requestId) throw new Error(`unknown local read continuation '${workId2}'`);
24128
24264
  const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24265
+ work.waiters.clear();
24129
24266
  if (now2 >= work.deadline) {
24130
24267
  __privateGet(this, _waiting5).delete(workId2);
24131
24268
  throw new Error(`Local read index for '${work.dependency.workspace}' did not catch up to ${work.dependency.requestedFrontier} within its retained maintenance window`);
24132
24269
  }
24133
- if (now2 < work.notBefore) return __privateMethod(this, _ReadResponseDesk_instances, pending_fn).call(this, workId2, work, now2);
24134
24270
  try {
24135
24271
  const response = __privateGet(this, _read2).call(this, work.request);
24136
24272
  if (response.outcome.case !== "query" || response.outcome.value.result.case !== "readIndexPending") {
@@ -24138,33 +24274,75 @@
24138
24274
  return { case: "ready", request: work.request, response };
24139
24275
  }
24140
24276
  work.dependency = response.outcome.value.result.value;
24141
- const tick = __privateGet(this, _tick).call(this);
24277
+ if (now2 < work.notBefore) return __privateMethod(this, _ReadResponseDesk_instances, pending_fn).call(this, workId2, work, now2);
24278
+ let { ticked, wake } = __privateGet(this, _tick).call(this);
24279
+ if (wake.case === "none" && ticked.progress === void 0 && work.owedFor !== work.dependency.requestedFrontier) {
24280
+ work.owedFor = work.dependency.requestedFrontier;
24281
+ __privateGet(this, _owe).call(this, work.request);
24282
+ ({ ticked, wake } = __privateGet(this, _tick).call(this));
24283
+ }
24142
24284
  const afterTick = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24143
- work.notBefore = afterTick + tick.nextTickAfterMillis;
24144
- work.deadline = afterTick + Math.max(12e4, tick.nextTickAfterMillis + 6e4);
24285
+ work.idle = wake.case === "none";
24286
+ const backoff = wake.case === "after" ? wake.millis : 0;
24287
+ work.notBefore = afterTick + backoff;
24288
+ work.deadline = afterTick + Math.max(READ_RETENTION_MILLIS, backoff + 6e4);
24145
24289
  return __privateMethod(this, _ReadResponseDesk_instances, pending_fn).call(this, workId2, work, afterTick);
24146
24290
  } catch (error) {
24147
24291
  __privateGet(this, _waiting5).delete(workId2);
24148
24292
  throw error;
24149
24293
  }
24150
24294
  }
24295
+ /**
24296
+ * Wait in process for a held read to become worth continuing. `notify` is called once, when read
24297
+ * readiness for its workspace changes (a slice or binding finished, a frontier advanced, readiness
24298
+ * newly owed). `afterMillis` is the only timer the shell needs: the read's own scheduled quantum
24299
+ * when it has one, otherwise its deadline. Undefined for an unknown or finished read.
24300
+ */
24301
+ onResumable(workId2, notify) {
24302
+ const work = __privateGet(this, _waiting5).get(workId2);
24303
+ if (!work) return void 0;
24304
+ const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24305
+ const due2 = work.idle ? work.deadline : Math.min(work.notBefore, work.deadline);
24306
+ work.waiters.add(notify);
24307
+ return { afterMillis: Math.max(0, due2 - now2), cancel: () => {
24308
+ work.waiters.delete(notify);
24309
+ } };
24310
+ }
24311
+ /** Read readiness for `workspace` changed: every read waiting on it may continue now. */
24312
+ readinessChanged(workspace) {
24313
+ const now2 = __privateMethod(this, _ReadResponseDesk_instances, now_fn3).call(this);
24314
+ for (const work of __privateGet(this, _waiting5).values()) {
24315
+ if (work.dependency.workspace !== workspace) continue;
24316
+ work.idle = false;
24317
+ if (work.notBefore > now2) work.notBefore = now2;
24318
+ const waiters = [...work.waiters];
24319
+ work.waiters.clear();
24320
+ for (const notify of waiters) notify();
24321
+ }
24322
+ }
24151
24323
  clear() {
24324
+ const waiters = [...__privateGet(this, _waiting5).values()].flatMap((work) => [...work.waiters]);
24152
24325
  __privateGet(this, _waiting5).clear();
24326
+ for (const notify of waiters) notify();
24153
24327
  }
24154
24328
  };
24155
24329
  _waiting5 = new WeakMap();
24156
24330
  _clock8 = new WeakMap();
24157
24331
  _tick = new WeakMap();
24332
+ _owe = new WeakMap();
24158
24333
  _read2 = new WeakMap();
24159
24334
  _sequence9 = new WeakMap();
24160
24335
  _ReadResponseDesk_instances = new WeakSet();
24161
24336
  now_fn3 = function() {
24162
24337
  return Number(__privateGet(this, _clock8).monotonicNanoseconds() / 1000000n);
24163
24338
  };
24339
+ /** The protocol wake is a bounded re-poll inside the read's retention deadline, never the raw backoff. */
24164
24340
  pending_fn = function(workId2, work, now2) {
24341
+ const due2 = work.idle ? READ_RESUME_MAX_MILLIS : work.notBefore - now2;
24342
+ const resumeAfterMillis = Math.max(0, Math.min(due2, work.deadline - now2, READ_RESUME_MAX_MILLIS));
24165
24343
  return { case: "pending", value: create(LocalReadPendingSchema, {
24166
24344
  workId: workId2,
24167
- resumeAfterMillis: Math.max(0, work.notBefore - now2)
24345
+ resumeAfterMillis: Number.isFinite(resumeAfterMillis) ? Math.ceil(resumeAfterMillis) : READ_RESUME_MAX_MILLIS
24168
24346
  }) };
24169
24347
  };
24170
24348
 
@@ -25110,13 +25288,15 @@
25110
25288
  DependencyAdvanced: "dependency_advanced",
25111
25289
  RebornRemotely: "reborn_remotely",
25112
25290
  LocalCopyDropAuthorized: "local_copy_drop_authorized",
25113
- LocalCopyUnreadable: "local_copy_unreadable"
25291
+ LocalCopyUnreadable: "local_copy_unreadable",
25292
+ RuntimeStarted: "runtime_started"
25114
25293
  });
25115
25294
  var ReplicaFollowEffectKind = Object.freeze({
25116
25295
  ScheduleWake: "schedule_wake",
25117
25296
  RunSync: "run_sync",
25118
25297
  RefreshCredential: "refresh_credential"
25119
25298
  });
25299
+ var KERNEL_REFUSAL_EVENT_FLOOR_MILLIS = 1e4;
25120
25300
  var boundedRetry = (policy, attempt) => Math.min(policy.fallbackMillis, Math.max(250, policy.debounceMillis) * 2 ** Math.min(attempt - 1, 20));
25121
25301
  var attempts = (state) => {
25122
25302
  switch (state.case) {
@@ -25143,13 +25323,14 @@
25143
25323
  state: { case: ReplicaFollowPhase.Due, dueAtUnixMillis: atUnixMillis },
25144
25324
  effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis }]
25145
25325
  });
25146
- var run = (attempt, replaceLocalHead, warmingSinceUnixMillis) => ({
25326
+ var run = (attempt, replaceLocalHead, warmingSinceUnixMillis, refused) => ({
25147
25327
  state: {
25148
25328
  case: ReplicaFollowPhase.Running,
25149
25329
  attempt,
25150
25330
  observed: false,
25151
25331
  ...replaceLocalHead === void 0 ? {} : { replaceLocalHead },
25152
- ...warmingSinceUnixMillis === void 0 ? {} : { warmingSinceUnixMillis }
25332
+ ...warmingSinceUnixMillis === void 0 ? {} : { warmingSinceUnixMillis },
25333
+ ...refused === void 0 ? {} : { refused }
25153
25334
  },
25154
25335
  effects: [{ case: ReplicaFollowEffectKind.RunSync }]
25155
25336
  });
@@ -25158,6 +25339,16 @@
25158
25339
  effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis }]
25159
25340
  });
25160
25341
  var quiet = (state) => ({ state, effects: [] });
25342
+ var blockedRefusal = (state) => state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked ? state.refusal : void 0;
25343
+ var refusedEvent = (state, refusal2, nowUnixMillis) => {
25344
+ const earliest = Math.max(nowUnixMillis, refusal2.atUnixMillis + KERNEL_REFUSAL_EVENT_FLOOR_MILLIS);
25345
+ const rerunAtUnixMillis = refusal2.rerunAtUnixMillis === void 0 ? earliest : Math.min(refusal2.rerunAtUnixMillis, earliest);
25346
+ return {
25347
+ state: { ...state, refusal: { ...refusal2, rerunAtUnixMillis } },
25348
+ effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: rerunAtUnixMillis }]
25349
+ };
25350
+ };
25351
+ var refusedByKernel = (state) => state.case === ReplicaFollowPhase.Backoff && (state.refusal !== void 0 || deterministicKernelRefusal(state.failure) !== void 0);
25161
25352
  function reduceReplicaFollow(state, event, policy) {
25162
25353
  switch (event.case) {
25163
25354
  case ReplicaFollowEventKind.Activate:
@@ -25170,6 +25361,9 @@
25170
25361
  if (state.case === ReplicaFollowPhase.Running) {
25171
25362
  return { state: { ...state, observed: true }, effects: [] };
25172
25363
  }
25364
+ if (state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked) {
25365
+ return refusedEvent(state, state.refusal, event.nowUnixMillis);
25366
+ }
25173
25367
  if (state.case === ReplicaFollowPhase.RebornRemotely || state.case === ReplicaFollowPhase.LocalCopyUnreadable) return quiet(state);
25174
25368
  if (state.case === ReplicaFollowPhase.InvalidCredential) {
25175
25369
  return {
@@ -25179,6 +25373,9 @@
25179
25373
  }
25180
25374
  return due(event.nowUnixMillis);
25181
25375
  case ReplicaFollowEventKind.Reconnected:
25376
+ if (state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked) {
25377
+ return refusedEvent(state, state.refusal, event.nowUnixMillis);
25378
+ }
25182
25379
  switch (state.case) {
25183
25380
  case ReplicaFollowPhase.Running:
25184
25381
  return { state: { ...state, observed: true }, effects: [] };
@@ -25224,15 +25421,25 @@
25224
25421
  }
25225
25422
  return run(state.attempt + 1, state.expectedLocalHead);
25226
25423
  case ReplicaFollowPhase.Offline:
25227
- case ReplicaFollowPhase.Backoff:
25424
+ case ReplicaFollowPhase.Backoff: {
25425
+ const blocked = blockedRefusal(state);
25426
+ if (blocked) {
25427
+ if (blocked.rerunAtUnixMillis === void 0) return quiet(state);
25428
+ if (event.nowUnixMillis < blocked.rerunAtUnixMillis) {
25429
+ return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: blocked.rerunAtUnixMillis }] };
25430
+ }
25431
+ return run(state.attempt + 1, void 0, void 0, state.failure);
25432
+ }
25228
25433
  if (event.nowUnixMillis < state.retryAtUnixMillis) {
25229
25434
  return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: state.retryAtUnixMillis }] };
25230
25435
  }
25231
25436
  return run(
25232
25437
  state.attempt + 1,
25233
25438
  void 0,
25234
- state.case === ReplicaFollowPhase.Backoff ? state.warming?.sinceUnixMillis : void 0
25439
+ state.case === ReplicaFollowPhase.Backoff ? state.warming?.sinceUnixMillis : void 0,
25440
+ state.case === ReplicaFollowPhase.Backoff && state.refusal ? state.failure : void 0
25235
25441
  );
25442
+ }
25236
25443
  case ReplicaFollowPhase.InvalidCredential:
25237
25444
  if (!state.refreshDue && event.nowUnixMillis < state.retryAtUnixMillis) {
25238
25445
  return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: state.retryAtUnixMillis }] };
@@ -25309,6 +25516,31 @@
25309
25516
  };
25310
25517
  }
25311
25518
  case ReplicaFollowEventKind.Failed: {
25519
+ if (event.refusal && !(state.case === ReplicaFollowPhase.Running && state.replaceLocalHead !== void 0)) {
25520
+ const attempt2 = Math.max(1, attempts(state));
25521
+ const blocked = state.case === ReplicaFollowPhase.Running && state.refused === event.failure || state.case === ReplicaFollowPhase.Backoff && state.refusal !== void 0 && state.failure === event.failure;
25522
+ const refusal2 = {
25523
+ code: event.refusal.code,
25524
+ blocked,
25525
+ runtime: event.refusal.runtime,
25526
+ atUnixMillis: event.nowUnixMillis
25527
+ };
25528
+ if (!blocked) {
25529
+ const retryAtUnixMillis2 = event.nowUnixMillis + boundedRetry(policy, attempt2);
25530
+ return {
25531
+ state: { case: ReplicaFollowPhase.Backoff, attempt: attempt2, retryAtUnixMillis: retryAtUnixMillis2, failure: event.failure, refusal: refusal2 },
25532
+ effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: retryAtUnixMillis2 }]
25533
+ };
25534
+ }
25535
+ const waiting = {
25536
+ case: ReplicaFollowPhase.Backoff,
25537
+ attempt: attempt2,
25538
+ retryAtUnixMillis: event.nowUnixMillis,
25539
+ failure: event.failure,
25540
+ refusal: refusal2
25541
+ };
25542
+ return state.case === ReplicaFollowPhase.Running && state.observed ? refusedEvent(waiting, refusal2, event.nowUnixMillis) : quiet(waiting);
25543
+ }
25312
25544
  if (state.case === ReplicaFollowPhase.Running && state.observed) {
25313
25545
  return due(event.nowUnixMillis);
25314
25546
  }
@@ -25346,6 +25578,11 @@
25346
25578
  return quiet({ case: ReplicaFollowPhase.RebornRemotely, rebirth: event.rebirth });
25347
25579
  case ReplicaFollowEventKind.LocalCopyUnreadable:
25348
25580
  return quiet({ case: ReplicaFollowPhase.LocalCopyUnreadable, format: event.format });
25581
+ case ReplicaFollowEventKind.RuntimeStarted:
25582
+ if (state.case === ReplicaFollowPhase.Backoff && refusedByKernel(state) && state.refusal?.runtime !== event.runtime) {
25583
+ return due(event.nowUnixMillis);
25584
+ }
25585
+ return quiet(state);
25349
25586
  case ReplicaFollowEventKind.LocalCopyDropAuthorized:
25350
25587
  if (state.case === ReplicaFollowPhase.Running) return invalid2(state, event);
25351
25588
  return replacing(event.expectedLocalHead, 0, event.nowUnixMillis);
@@ -25372,9 +25609,9 @@
25372
25609
  debounceMillis: 1e3,
25373
25610
  fallbackMillis: 6e4
25374
25611
  });
25375
- var _desk, _clock11, _recovered, _placementRecheck, _replicaId, _birthRefusals, _ReplicaFollowController_instances, quarantineChild_fn, event_fn, binding_fn, now_fn5;
25612
+ var _desk, _clock11, _recovered, _placementRecheck, _replicaId, _birthRefusals, _runtime, _ReplicaFollowController_instances, quarantineChild_fn, event_fn, binding_fn, now_fn5;
25376
25613
  var ReplicaFollowController = class {
25377
- constructor(desk, clock2, replicaId, birthRefusals) {
25614
+ constructor(desk, clock2, replicaId, birthRefusals, runtime = "unidentified") {
25378
25615
  __privateAdd(this, _ReplicaFollowController_instances);
25379
25616
  __privateAdd(this, _desk);
25380
25617
  __privateAdd(this, _clock11);
@@ -25395,10 +25632,14 @@
25395
25632
  __privateAdd(this, _replicaId);
25396
25633
  /** Local children whose births custody refused (CAP-804): quarantined, never followed. */
25397
25634
  __privateAdd(this, _birthRefusals);
25635
+ /** The kernel/runtime identity this process runs: a refusal is recorded under it, and a refusal
25636
+ * drawn under another identity is retried once when this process starts. */
25637
+ __privateAdd(this, _runtime);
25398
25638
  __privateSet(this, _desk, desk);
25399
25639
  __privateSet(this, _clock11, clock2);
25400
25640
  __privateSet(this, _replicaId, replicaId);
25401
25641
  __privateSet(this, _birthRefusals, birthRefusals ?? new BirthRefusalRegister(new MemoryPeerDeskStore()));
25642
+ __privateSet(this, _runtime, runtime);
25402
25643
  }
25403
25644
  /** The durable quarantine of a local child whose birth custody refused; undefined otherwise. */
25404
25645
  birthRefusal(workspace) {
@@ -25487,6 +25728,13 @@
25487
25728
  recover() {
25488
25729
  const now2 = __privateMethod(this, _ReplicaFollowController_instances, now_fn5).call(this);
25489
25730
  if (!__privateGet(this, _recovered)) {
25731
+ for (const follow of __privateGet(this, _desk).all()) {
25732
+ __privateGet(this, _desk).transition(follow.spec.workspace, {
25733
+ case: ReplicaFollowEventKind.RuntimeStarted,
25734
+ nowUnixMillis: now2,
25735
+ runtime: __privateGet(this, _runtime)
25736
+ });
25737
+ }
25490
25738
  for (const follow of __privateGet(this, _desk).all()) {
25491
25739
  if (follow.state.case === ReplicaFollowPhase.Settled || follow.state.case === ReplicaFollowPhase.AwaitingDependency) {
25492
25740
  __privateGet(this, _placementRecheck).add(follow.spec.workspace);
@@ -25575,11 +25823,12 @@
25575
25823
  placementAnnounced(workspace) {
25576
25824
  if (!this.followForWorkspace(workspace)) return void 0;
25577
25825
  __privateGet(this, _placementRecheck).add(workspace);
25578
- return this.reconnected(workspace);
25826
+ return this.reconnected(workspace, true);
25579
25827
  }
25580
- /** The upstream live link opened or reopened: reconcile once for missed pushes. */
25581
- reconnected(workspace) {
25582
- return __privateMethod(this, _ReplicaFollowController_instances, event_fn).call(this, workspace, ReplicaFollowEventKind.Reconnected);
25828
+ /** The upstream live link opened or reopened: reconcile once for missed pushes. With
25829
+ * `remoteAdvanced`, the upstream announced a new frontier. Either re-runs a blocked refusal. */
25830
+ reconnected(workspace, remoteAdvanced = false) {
25831
+ return __privateMethod(this, _ReplicaFollowController_instances, event_fn).call(this, workspace, ReplicaFollowEventKind.Reconnected, remoteAdvanced);
25583
25832
  }
25584
25833
  /** Another workspace advanced or settled; every held dependency gets one retry. */
25585
25834
  dependencyAdvanced(except) {
@@ -25730,7 +25979,9 @@
25730
25979
  * still opening the workspace and named when to ask again. */
25731
25980
  failed(workspace, error, custodianRetryAfterMillis) {
25732
25981
  if (!__privateGet(this, _recovered)) this.recover();
25733
- custodianRetryAfterMillis ?? (custodianRetryAfterMillis = warmingFromFailureMessage(error instanceof Error ? error.message : String(error)));
25982
+ const refusal2 = deterministicKernelRefusal(error);
25983
+ if (refusal2 !== void 0) custodianRetryAfterMillis = void 0;
25984
+ else custodianRetryAfterMillis ?? (custodianRetryAfterMillis = warmingFromFailureMessage(error instanceof Error ? error.message : String(error)));
25734
25985
  if (!__privateGet(this, _desk).get(workspace)) return;
25735
25986
  const format = localCopyFormatRefusal(error);
25736
25987
  if (format !== void 0) {
@@ -25745,9 +25996,15 @@
25745
25996
  case: ReplicaFollowEventKind.Failed,
25746
25997
  nowUnixMillis: __privateMethod(this, _ReplicaFollowController_instances, now_fn5).call(this),
25747
25998
  failure: error instanceof Error ? error.message : String(error),
25748
- ...custodianRetryAfterMillis === void 0 ? {} : { custodianRetryAfterMillis }
25999
+ ...custodianRetryAfterMillis === void 0 ? {} : { custodianRetryAfterMillis },
26000
+ ...refusal2 === void 0 ? {} : { refusal: { code: refusal2.code, runtime: __privateGet(this, _runtime) } }
25749
26001
  });
25750
26002
  }
26003
+ /** The kernel refusal behind this follow's backoff (`blocked` once the kernel repeated it). */
26004
+ refusal(workspace) {
26005
+ const state = this.followForWorkspace(workspace)?.state;
26006
+ return state?.case === ReplicaFollowPhase.Backoff ? state.refusal : void 0;
26007
+ }
25751
26008
  /** Closing an interaction realm must not erase a peer-owned follow. */
25752
26009
  closeInteractionRealm() {
25753
26010
  }
@@ -25758,6 +26015,7 @@
25758
26015
  _placementRecheck = new WeakMap();
25759
26016
  _replicaId = new WeakMap();
25760
26017
  _birthRefusals = new WeakMap();
26018
+ _runtime = new WeakMap();
25761
26019
  _ReplicaFollowController_instances = new WeakSet();
25762
26020
  /**
25763
26021
  * QUARANTINE a local child whose birth custody refused: record it durably and stop its follow, so
@@ -25769,11 +26027,11 @@
25769
26027
  __privateGet(this, _desk).stop(child);
25770
26028
  __privateGet(this, _placementRecheck).delete(child);
25771
26029
  };
25772
- event_fn = function(workspace, kind) {
26030
+ event_fn = function(workspace, kind, remoteAdvanced = false) {
25773
26031
  const follow = __privateGet(this, _recovered) ? __privateGet(this, _desk).get(workspace) : void 0;
25774
26032
  if (!follow) return void 0;
25775
26033
  const nowUnixMillis = __privateMethod(this, _ReplicaFollowController_instances, now_fn5).call(this);
25776
- __privateGet(this, _desk).transition(workspace, { case: kind, nowUnixMillis });
26034
+ __privateGet(this, _desk).transition(workspace, kind === ReplicaFollowEventKind.Reconnected && remoteAdvanced ? { case: kind, nowUnixMillis, remoteAdvanced } : { case: kind, nowUnixMillis });
25777
26035
  const nextDueAt = dueAt(__privateGet(this, _desk).get(workspace));
25778
26036
  return nextDueAt === void 0 ? void 0 : Math.max(0, nextDueAt - nowUnixMillis);
25779
26037
  };
@@ -25805,9 +26063,12 @@
25805
26063
  case ReplicaFollowPhase.RebornRemotely:
25806
26064
  case ReplicaFollowPhase.LocalCopyUnreadable:
25807
26065
  return void 0;
26066
+ case ReplicaFollowPhase.Backoff: {
26067
+ const blocked = blockedRefusal(follow.state);
26068
+ return blocked ? blocked.rerunAtUnixMillis : follow.state.retryAtUnixMillis;
26069
+ }
25808
26070
  case ReplicaFollowPhase.Offline:
25809
26071
  case ReplicaFollowPhase.InvalidCredential:
25810
- case ReplicaFollowPhase.Backoff:
25811
26072
  return follow.state.retryAtUnixMillis;
25812
26073
  default: {
25813
26074
  const exhaustive = follow.state;
@@ -25823,6 +26084,11 @@
25823
26084
  return nextDueAt === void 0 ? void 0 : Math.max(0, nextDueAt - nowUnixMillis);
25824
26085
  }
25825
26086
 
26087
+ // ../src/runtime/runtime_identity.ts
26088
+ init_define_NOMOS_KERNEL_RELEASE();
26089
+ init_shims();
26090
+ var PEER_RUNTIME_IDENTITY = "0.116.4" ? `@githolon/runtime@${"0.116.4"}` : "@githolon/runtime@unbundled";
26091
+
25826
26092
  // ../src/runtime/replica_follow_desk.ts
25827
26093
  init_define_NOMOS_KERNEL_RELEASE();
25828
26094
  init_shims();
@@ -25852,6 +26118,16 @@
25852
26118
  ...Number.isFinite(warming.hintMillis) ? { hintMillis: warming.hintMillis } : {}
25853
26119
  } } : {};
25854
26120
  };
26121
+ var decodeRefusal = (value) => {
26122
+ const refusal2 = value;
26123
+ return refusal2 && typeof refusal2.code === "string" && typeof refusal2.runtime === "string" && Number.isFinite(refusal2.atUnixMillis) ? { refusal: {
26124
+ code: refusal2.code,
26125
+ blocked: refusal2.blocked === true,
26126
+ runtime: refusal2.runtime,
26127
+ atUnixMillis: refusal2.atUnixMillis,
26128
+ ...Number.isFinite(refusal2.rerunAtUnixMillis) ? { rerunAtUnixMillis: refusal2.rerunAtUnixMillis } : {}
26129
+ } } : {};
26130
+ };
25855
26131
  var decodeState = (record, value) => {
25856
26132
  if (!value || typeof value !== "object") throw corrupt(record, "state is not an object");
25857
26133
  const state = value;
@@ -25866,7 +26142,8 @@
25866
26142
  attempt: state.attempt,
25867
26143
  observed: state.observed === true,
25868
26144
  ...state.replaceLocalHead === void 0 ? {} : { replaceLocalHead: state.replaceLocalHead },
25869
- ...Number.isFinite(state.warmingSinceUnixMillis) ? { warmingSinceUnixMillis: state.warmingSinceUnixMillis } : {}
26145
+ ...Number.isFinite(state.warmingSinceUnixMillis) ? { warmingSinceUnixMillis: state.warmingSinceUnixMillis } : {},
26146
+ ...typeof state.refused === "string" ? { refused: state.refused } : {}
25870
26147
  };
25871
26148
  case ReplicaFollowPhase.Settled:
25872
26149
  return {
@@ -25898,7 +26175,8 @@
25898
26175
  attempt: state.attempt,
25899
26176
  retryAtUnixMillis: state.retryAtUnixMillis,
25900
26177
  failure: state.failure,
25901
- ...decodeWarming(state.warming)
26178
+ ...decodeWarming(state.warming),
26179
+ ...decodeRefusal(state.refusal)
25902
26180
  };
25903
26181
  case ReplicaFollowPhase.RebornRemotely: {
25904
26182
  const rebirth = state.rebirth ?? {};
@@ -26087,9 +26365,15 @@
26087
26365
  break;
26088
26366
  }
26089
26367
  case ReplicaFollowPhase.Offline:
26090
- case ReplicaFollowPhase.Backoff:
26091
- wakes.push({ workspace: follow.spec.workspace, atUnixMillis: follow.state.retryAtUnixMillis });
26368
+ case ReplicaFollowPhase.Backoff: {
26369
+ const blocked = blockedRefusal(follow.state);
26370
+ if (blocked && blocked.rerunAtUnixMillis === void 0) break;
26371
+ wakes.push({
26372
+ workspace: follow.spec.workspace,
26373
+ atUnixMillis: blocked?.rerunAtUnixMillis ?? follow.state.retryAtUnixMillis
26374
+ });
26092
26375
  break;
26376
+ }
26093
26377
  case ReplicaFollowPhase.InvalidCredential:
26094
26378
  wakes.push({
26095
26379
  workspace: follow.spec.workspace,
@@ -26782,7 +27066,9 @@
26782
27066
  message,
26783
27067
  ...retryAfterMillis === void 0 ? {} : { retryAfterMillis }
26784
27068
  }) });
26785
- 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;
27069
+ var OFF_MAIN_AFTER_MILLIS = 6e4;
27070
+ var MAX_UNFOUND_HEADS = 1024;
27071
+ 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;
26786
27072
  var LiveStreamServer = class {
26787
27073
  constructor(kernel, now2 = Date.now, historyWanted = () => {
26788
27074
  }, sealed = () => void 0) {
@@ -26799,6 +27085,10 @@
26799
27085
  /** By workspace: the history slices copies are fetching (a few, newest last). */
26800
27086
  __privateAdd(this, _slices, /* @__PURE__ */ new Map());
26801
27087
  __privateAdd(this, _cachedBytes, 0);
27088
+ /** By workspace and asked head: when this peer first answered "acquiring its own history" to a level
27089
+ * ask from a head it could not find. A shallow custody can never prove the head is off its main (its
27090
+ * walk is never `complete`), so after OFF_MAIN_AFTER_MILLIS of the same answer it says so anyway. */
27091
+ __privateAdd(this, _unfound, /* @__PURE__ */ new Map());
26802
27092
  __privateSet(this, _kernel12, kernel);
26803
27093
  __privateSet(this, _sealed, sealed);
26804
27094
  __privateSet(this, _historyWanted, historyWanted);
@@ -26835,6 +27125,7 @@
26835
27125
  _checkpoints3 = new WeakMap();
26836
27126
  _slices = new WeakMap();
26837
27127
  _cachedBytes = new WeakMap();
27128
+ _unfound = new WeakMap();
26838
27129
  _LiveStreamServer_instances = new WeakSet();
26839
27130
  frontier_fn = function(workspace, requestId, frontier) {
26840
27131
  const mount = workspaceMount(workspace);
@@ -26853,9 +27144,12 @@
26853
27144
  if (!head) return [...answer, ...__privateMethod(this, _LiveStreamServer_instances, checkpoint_fn).call(this, workspace, requestId, create(LiveCheckpointRequestSchema))];
26854
27145
  if (head === main) return answer;
26855
27146
  let behind;
27147
+ let offMain = false;
26856
27148
  try {
26857
27149
  const summary = __privateGet(this, _kernel12).historySummary(mount, requestId, head, main);
26858
27150
  behind = summary.reachedBase ? summary.commitCount : void 0;
27151
+ offMain = !summary.reachedBase && (summary.complete || !__privateMethod(this, _LiveStreamServer_instances, shallow_fn).call(this, mount, requestId));
27152
+ if (summary.reachedBase) __privateGet(this, _unfound).delete(`${workspace}\0${head}`);
26859
27153
  } catch {
26860
27154
  behind = void 0;
26861
27155
  }
@@ -26864,6 +27158,22 @@
26864
27158
  if (remountAfter > 0) {
26865
27159
  return [...answer, ...__privateMethod(this, _LiveStreamServer_instances, checkpoint_fn).call(this, workspace, requestId, create(LiveCheckpointRequestSchema), behind ?? 0n)];
26866
27160
  }
27161
+ const key = `${workspace}\0${head}`;
27162
+ const firstUnfound = __privateGet(this, _unfound).get(key);
27163
+ if (!offMain && firstUnfound === void 0) {
27164
+ if (__privateGet(this, _unfound).size >= MAX_UNFOUND_HEADS) __privateGet(this, _unfound).delete(__privateGet(this, _unfound).keys().next().value);
27165
+ __privateGet(this, _unfound).set(key, __privateGet(this, _now).call(this));
27166
+ } else if (!offMain && __privateGet(this, _now).call(this) - firstUnfound >= OFF_MAIN_AFTER_MILLIS) {
27167
+ offMain = true;
27168
+ }
27169
+ if (offMain) {
27170
+ __privateGet(this, _unfound).delete(key);
27171
+ return [...answer, refusal(
27172
+ "",
27173
+ "nomos.stream.off_main",
27174
+ "the copy's head is not on this peer's main; it must converge its own work, not level from it"
27175
+ )];
27176
+ }
26867
27177
  __privateGet(this, _historyWanted).call(this, workspace);
26868
27178
  return [...answer, refusal(
26869
27179
  "",
@@ -26875,6 +27185,17 @@
26875
27185
  const maxOffers = Math.min(Math.max(1, frontier.maxOffers || MAX_STREAM_BATCH_OFFERS), MAX_STREAM_BATCH_OFFERS);
26876
27186
  return [...answer, __privateMethod(this, _LiveStreamServer_instances, batch_fn).call(this, workspace, requestId, head, main, maxOffers)];
26877
27187
  };
27188
+ /** Whether this peer's custody of the workspace is shallow. Unknown counts as shallow: it keeps the
27189
+ * existing wait for history rather than calling a head off main. */
27190
+ shallow_fn = function(mount, requestId) {
27191
+ const boundaries = __privateGet(this, _kernel12).shallowBoundaries;
27192
+ if (!boundaries) return true;
27193
+ try {
27194
+ return boundaries.call(__privateGet(this, _kernel12), mount, requestId).length > 0;
27195
+ } catch {
27196
+ return true;
27197
+ }
27198
+ };
26878
27199
  /**
26879
27200
  * The `maxOffers` offers directly above `base`, as the commits this peer admitted them in: one
26880
27201
  * bounded walk and one bounded pack (O(batch)). The copy's kernel adopts exactly these commits on
@@ -27258,12 +27579,11 @@
27258
27579
  };
27259
27580
  _commits = new WeakMap();
27260
27581
  _requests = new WeakMap();
27261
- 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;
27582
+ 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;
27262
27583
  var LiveCorrespondenceDesk = class {
27263
27584
  constructor(kernel, events, clock2, relayOrigin, staging) {
27264
27585
  __privateAdd(this, _LiveCorrespondenceDesk_instances);
27265
27586
  __privateAdd(this, _links, /* @__PURE__ */ new Map());
27266
- __privateAdd(this, _pending3, /* @__PURE__ */ new Map());
27267
27587
  /** What procedures asked of each workspace's stream, and what it delivered (peer_catchup.md). */
27268
27588
  __publicField(this, "inbound");
27269
27589
  __privateAdd(this, _own, new OwnOffers());
@@ -27299,13 +27619,6 @@
27299
27619
  * never held. Absent (a custodian, a relay, a test), every write goes out on the next drive.
27300
27620
  */
27301
27621
  __publicField(this, "writeBurst");
27302
- /**
27303
- * An application peer's receive step (CAP-757; sized by time, CAP-762). A received batch of other
27304
- * senders' offers larger than one step is not admitted on the socket, in one kernel-thread hold:
27305
- * the follow receives it instead, in yielding steps of the policy's current size. Absent (a
27306
- * custodian, a relay, a test), every received batch is admitted as it arrives.
27307
- */
27308
- __publicField(this, "receiveStep");
27309
27622
  /** The last progress counted per workspace, served while a burst holds recounting back. */
27310
27623
  __privateAdd(this, _progress, /* @__PURE__ */ new Map());
27311
27624
  /** When a held-back progress recount became owed; it reports at the burst's next due point. */
@@ -27359,10 +27672,12 @@
27359
27672
  sent: link.stream?.sent,
27360
27673
  unansweredAgesMs: (link.stream?.unanswered ?? []).map((entry) => Number((now2 - (entry.due - LIVE_ANSWER_WINDOW)) / 1000000n)),
27361
27674
  custodianLocal: link.custodian?.local,
27362
- convergeDue: link.convergeDue !== void 0
27675
+ convergeDue: link.convergeDue !== void 0,
27676
+ resident: false
27363
27677
  };
27364
27678
  try {
27365
27679
  if (this.kernel.isResident(link.binding.workspace) !== false) {
27680
+ state.resident = true;
27366
27681
  const mount = workspaceMount(link.binding.workspace);
27367
27682
  state.head = this.kernel.head(mount, ++__privateWrapper(this, _requestId3)._);
27368
27683
  state.tracked = this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2);
@@ -27471,7 +27786,7 @@
27471
27786
  evidencePack: options.carryCommits || intents.some((intent) => intent.transportRequirement === IntentTransportRequirement.COMMIT_TREE) ? this.kernel.packDelta(mount, requestId, batchHead, base) : new Uint8Array()
27472
27787
  });
27473
27788
  }
27474
- receive(request, receipt) {
27789
+ receive(receipt) {
27475
27790
  const link = [...__privateGet(this, _links).values()].find((item) => item.id === receipt.connectionId);
27476
27791
  if (!link) return;
27477
27792
  if (receipt.observation.case === "closed" || receipt.observation.case === "closure") {
@@ -27485,6 +27800,7 @@
27485
27800
  link.ownMains = [];
27486
27801
  delete link.lastAnnounced;
27487
27802
  delete link.lastPlacementAnnounced;
27803
+ link.peerMain = void 0;
27488
27804
  link.dirty = true;
27489
27805
  link.due = this.clock.monotonicNanoseconds() + BigInt(Math.min(3e4, 250 * 2 ** Math.min(link.failures++, 7))) * 1000000n;
27490
27806
  return;
@@ -27494,7 +27810,6 @@
27494
27810
  link.openedAt = this.clock.monotonicNanoseconds();
27495
27811
  link.failures = 0;
27496
27812
  link.unheard = void 0;
27497
- if (!link.publisher) __privateMethod(this, _LiveCorrespondenceDesk_instances, hello_fn).call(this, link);
27498
27813
  if (!link.publisher) this.inbound.opened(link.binding.workspace);
27499
27814
  this.linkOpened?.(link.binding.workspace);
27500
27815
  return;
@@ -27528,18 +27843,6 @@
27528
27843
  if (this.inbound.frame(link.binding.workspace, frame2.message)) return;
27529
27844
  if (frame2.message.case === "frontier") {
27530
27845
  __privateMethod(this, _LiveCorrespondenceDesk_instances, announced_fn).call(this, link, frame2.message.value.head);
27531
- if (this.kernel.isResident(link.binding.workspace) === false) return;
27532
- if (!frame2.message.value.response) {
27533
- __privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "frontier", value: {
27534
- head: this.kernel.head(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId3)._) ?? "",
27535
- response: true
27536
- } });
27537
- }
27538
- try {
27539
- const batch2 = this.export(link.binding, frame2.message.value.head, ++__privateWrapper(this, _requestId3)._);
27540
- if (batch2.source.case === "inline" && batch2.source.value.offers.length) __privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "offers", value: batch2 });
27541
- } catch {
27542
- }
27543
27846
  return;
27544
27847
  }
27545
27848
  if (frame2.message.case === "admission") {
@@ -27547,57 +27850,18 @@
27547
27850
  this.progressChanged?.(link.binding.workspace);
27548
27851
  return;
27549
27852
  }
27550
- if (frame2.message.case !== "offers") return;
27551
- const batch = frame2.message.value;
27552
- if (batch.protocolVersion !== 2 || !batch.requestId || batch.source.case !== "inline" || !batch.source.value.offers.length) return;
27553
- const offers = batch.source.value.offers.filter((offer) => !__privateGet(this, _own).hasCommit(link.binding.workspace, offer.commitOid));
27554
- if (!offers.length) return;
27555
- if (this.kernel.isResident(link.binding.workspace) === false && !this.inbound.wanted(link.binding.workspace)) {
27556
- this.remoteAdvanced?.(link.binding.workspace);
27557
- return;
27558
- }
27559
- if (this.receiveStep !== void 0 && offers.length > this.receiveStep.offers) {
27560
- this.remoteAdvanced?.(link.binding.workspace);
27561
- return;
27562
- }
27563
- if ([...__privateGet(this, _pending3).values()].some((pending) => pending.link === link && pending.bytes.length === bytes.length && pending.bytes.every((byte, index) => byte === bytes[index]))) return;
27564
- if (__privateGet(this, _pending3).size >= 32) return;
27565
- __privateGet(this, _pending3).set(request.requestId, { link, bytes });
27566
- return create(RuntimeRequestSchema, {
27567
- protocolVersion: 2,
27568
- requestId: request.requestId,
27569
- target: { workspace: link.binding.workspace, session: link.binding.replicaId },
27570
- // HTTP sender reconciliation controls are not part of a live proposal.
27571
- // Keeping fastForwardOnly while removing baseHead silently skips every
27572
- // offer against a nonempty local head. The Kernel judges sealed causality;
27573
- // live receivers neither ask for a return archive nor confirm the sender.
27574
- command: { case: "admitCustodyOffers", value: create(CustodyOfferBatchRequestSchema, {
27575
- ...batch,
27576
- baseHead: void 0,
27577
- observedHead: void 0,
27578
- fastForwardOnly: false,
27579
- ...offers.length === batch.source.value.offers.length ? {} : { source: { case: "inline", value: { ...batch.source.value, offers } } }
27580
- }) }
27581
- });
27853
+ }
27854
+ /** The newest local commit the custodian admitted unchanged over this workspace's open link: its
27855
+ * main holds that commit, sealed or not, so it is no work to offer (CAP-838). */
27856
+ admittedLocal(workspace) {
27857
+ const link = __privateGet(this, _links).get(workspace);
27858
+ const cursor = link?.state === "open" && !link.publisher ? link.custodian : void 0;
27859
+ return cursor && cursor.main === cursor.local ? cursor.local : void 0;
27582
27860
  }
27583
27861
  /** Offers this replica sent another way (the HTTP lane): their echo on the live link is its own. */
27584
27862
  offered(workspace, commitOids) {
27585
27863
  __privateGet(this, _own).commits(workspace, commitOids);
27586
27864
  }
27587
- /** Whether this request is the admission of a batch relayed to this follower over its live link.
27588
- * Such an admission is never answered to a sender, so it keeps no custody receipts (CAP-759). */
27589
- relayed(requestId) {
27590
- return __privateGet(this, _pending3).has(requestId);
27591
- }
27592
- settled(request, response) {
27593
- if (response.outcome.case === "correspondencePending" || response.outcome.case === "localReadPending") return;
27594
- __privateGet(this, _pending3).delete(request.requestId);
27595
- }
27596
- failed(requestId) {
27597
- const pending = __privateGet(this, _pending3).get(requestId);
27598
- __privateGet(this, _pending3).delete(requestId);
27599
- if (pending) this.remoteAdvanced?.(pending.link.binding.workspace);
27600
- }
27601
27865
  disconnect(workspace) {
27602
27866
  const link = __privateGet(this, _links).get(workspace);
27603
27867
  if (!link) return;
@@ -27605,7 +27869,6 @@
27605
27869
  if (link.state === "open") this.linkClosed?.(workspace, closure);
27606
27870
  __privateGet(this, _links).delete(workspace);
27607
27871
  __privateGet(this, _progress).delete(workspace);
27608
- for (const [id, pending] of __privateGet(this, _pending3)) if (pending.link === link) __privateGet(this, _pending3).delete(id);
27609
27872
  }
27610
27873
  drive() {
27611
27874
  const now2 = this.clock.monotonicNanoseconds();
@@ -27655,7 +27918,8 @@
27655
27918
  link.custodian = void 0;
27656
27919
  }
27657
27920
  __privateMethod(this, _LiveCorrespondenceDesk_instances, cursor_fn).call(this, link, mount);
27658
- const answered2 = link.publisher ? link.published ?? (link.published = head ?? "") : link.custodian?.local ?? this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2) ?? "";
27921
+ let answered2 = link.publisher ? link.published ?? (link.published = head ?? "") : link.custodian?.local ?? this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2) ?? "";
27922
+ if (!link.publisher && !link.custodian) answered2 = __privateMethod(this, _LiveCorrespondenceDesk_instances, heldPeerMain_fn).call(this, link, mount, head, answered2) ?? answered2;
27659
27923
  const fence = link.custodian?.main ?? answered2;
27660
27924
  if (link.stream && !(head && __privateMethod(this, _LiveCorrespondenceDesk_instances, holds_fn).call(this, mount, link.stream.sent, head))) {
27661
27925
  link.stream = void 0;
@@ -27728,11 +27992,9 @@
27728
27992
  }
27729
27993
  close() {
27730
27994
  for (const workspace of [...__privateGet(this, _links).keys()]) this.disconnect(workspace);
27731
- __privateGet(this, _pending3).clear();
27732
27995
  }
27733
27996
  };
27734
27997
  _links = new WeakMap();
27735
- _pending3 = new WeakMap();
27736
27998
  _own = new WeakMap();
27737
27999
  _progress = new WeakMap();
27738
28000
  _progressOwedSince = new WeakMap();
@@ -27778,7 +28040,7 @@
27778
28040
  };
27779
28041
  count_fn = function(link, mount) {
27780
28042
  const head = this.kernel.head(mount, ++__privateWrapper(this, _requestId3)._);
27781
- const acknowledged = __privateMethod(this, _LiveCorrespondenceDesk_instances, cursor_fn).call(this, link, mount)?.local ?? this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2);
28043
+ 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);
27782
28044
  if (!head || !acknowledged) return void 0;
27783
28045
  const count = (base, tip) => {
27784
28046
  if (base === tip) return 0;
@@ -27812,6 +28074,14 @@
27812
28074
  holds_fn = function(mount, base, tip) {
27813
28075
  return __privateMethod(this, _LiveCorrespondenceDesk_instances, chain_fn).call(this, mount, base, tip)?.reachedBase === true;
27814
28076
  };
28077
+ /** The custodian's main as last heard, when this copy holds it on its own head's chain above the
28078
+ * sealed bookmark: the commits up to it came from the stream and are the custodian's (CAP-838). */
28079
+ heldPeerMain_fn = function(link, mount, head, tracked = this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId3)._, TRACKED_MAIN2)) {
28080
+ const main = link.peerMain;
28081
+ if (!main || !head || main === tracked) return void 0;
28082
+ if (tracked && !__privateMethod(this, _LiveCorrespondenceDesk_instances, holds_fn).call(this, mount, tracked, main)) return void 0;
28083
+ return __privateMethod(this, _LiveCorrespondenceDesk_instances, holds_fn).call(this, mount, main, head) ? main : void 0;
28084
+ };
27815
28085
  /** This connection's admission cursor, while it still leads the saved bookmark. A cursor on local
27816
28086
  * history (admitted, not yet sealed) remembers the bookmark it was set above; once anything else
27817
28087
  * moves the bookmark (a follow round adopting the custodian's main) the bookmark rules again, so
@@ -27865,9 +28135,10 @@
27865
28135
  ...admission.sealedMain ? { sealed: admission.sealedMain } : {}
27866
28136
  };
27867
28137
  }
27868
- if (!admission?.main || this.kernel.isResident(workspace) === false) return;
28138
+ if (!admission?.main) return;
27869
28139
  const ownBatchHead = __privateGet(this, _own).batchHead(workspace, live.requestId);
27870
28140
  const ours = ownBatchHead !== void 0;
28141
+ if (this.kernel.isResident(workspace) === false) return;
27871
28142
  let stale = false;
27872
28143
  if (ours) link.unheard = void 0;
27873
28144
  if (ours && link.stream) {
@@ -27955,6 +28226,7 @@
27955
28226
  * upstream head it already recorded. Re-announcing a known frontier - which is all an
27956
28227
  * upstream can do while this replica is ahead or held on a dependency - is not an event. */
27957
28228
  announced_fn = function(link, head) {
28229
+ if (head) link.peerMain = head;
27958
28230
  if (!head || link.lastAnnounced === head) return;
27959
28231
  link.lastAnnounced = head;
27960
28232
  if (this.kernel.isResident(link.binding.workspace) === false) {
@@ -28015,14 +28287,6 @@
28015
28287
  transfer.retain(create(PeerGitRefsFetchedSchema, { refs: [...wanted.refs], pack }));
28016
28288
  this.progressChanged?.(link.binding.workspace);
28017
28289
  };
28018
- hello_fn = function(link) {
28019
- if (this.kernel.isResident(link.binding.workspace) === false) return;
28020
- const head = this.kernel.head(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId3)._);
28021
- __privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "frontier", value: {
28022
- head: head ?? "",
28023
- outcomesDigest: __privateMethod(this, _LiveCorrespondenceDesk_instances, outcomesDigest_fn).call(this, link.binding.workspace)
28024
- } });
28025
- };
28026
28290
  /**
28027
28291
  * A follower's next batch above `base`: up to the link's commit bound, cut down until its carried
28028
28292
  * commits fit LIVE_CARRIED_COMMITS_BYTES and its frame fits MAX_LIVE_FRAME_BYTES. A single commit
@@ -29062,6 +29326,7 @@
29062
29326
  var RECEIVED_PLACEMENT_REF = "refs/remotes/nomos/placement";
29063
29327
  var STREAM_BATCH_OFFERS = 64;
29064
29328
  var REMOUNT_AFTER_OFFERS = 128;
29329
+ var MAX_REMOUNTS_LOST = 2;
29065
29330
  var HISTORY_SLICES = [8, 64, 256, 256];
29066
29331
  var WorkspaceSyncPhase = Object.freeze({
29067
29332
  Idle: "idle",
@@ -29082,13 +29347,17 @@
29082
29347
  var judgedThisLifetime = /* @__PURE__ */ new Map();
29083
29348
  function releaseSyncJudgment(workspace) {
29084
29349
  judgedThisLifetime.delete(workspace);
29350
+ notContainedThisLifetime.delete(workspace);
29085
29351
  }
29352
+ var notContainedThisLifetime = /* @__PURE__ */ new Map();
29353
+ var MAX_NOT_CONTAINED = 1024;
29354
+ var NOT_CONTAINED_REFUSALS = /* @__PURE__ */ new Set(["nomos.stream.off_main", "nomos.stream.history_required"]);
29086
29355
  var MAX_REBASES_PER_ROUND = 2;
29087
29356
  var elapsedMillis = (clock2, started) => {
29088
29357
  const finished = clock2.monotonicNanoseconds();
29089
29358
  return finished >= started ? Number(finished - started) / 1e6 : 0;
29090
29359
  };
29091
- 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;
29360
+ 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;
29092
29361
  var WorkspaceSyncWork = class {
29093
29362
  constructor(args) {
29094
29363
  __privateAdd(this, _WorkspaceSyncWork_instances);
@@ -29141,6 +29410,7 @@
29141
29410
  __privateAdd(this, _lastStep2);
29142
29411
  __privateAdd(this, _probeOnly);
29143
29412
  __privateAdd(this, _liveConnected);
29413
+ __privateAdd(this, _liveAdmitted);
29144
29414
  /** Set when this round adopted the upstream's own head as its base (see #establishBase). */
29145
29415
  __privateAdd(this, _establishedBase);
29146
29416
  __privateAdd(this, _receiveState);
@@ -29157,6 +29427,11 @@
29157
29427
  /** The custodian head this round last offered or pulled from. */
29158
29428
  __privateAdd(this, _rebaseFrom);
29159
29429
  __privateAdd(this, _rebases, 0);
29430
+ __privateAdd(this, _remountsLost, 0);
29431
+ /** This round's level ask is a containment question (CAP-870): on a refusal, take this path. */
29432
+ __privateAdd(this, _containment);
29433
+ /** The stale bookmark a contained round replaces: its custodian's main holds the local head. */
29434
+ __privateAdd(this, _containedBookmark);
29160
29435
  /** Local intents this round's rebase refused and parked on the refused-offer desk. */
29161
29436
  __privateAdd(this, _parkedLocal, 0);
29162
29437
  /** An application-authorized drop: replace local custody at exactly this head. */
@@ -29173,6 +29448,7 @@
29173
29448
  __privateSet(this, _placementFetched, args.placementFetched);
29174
29449
  __privateSet(this, _probeOnly, args.probeOnly ?? false);
29175
29450
  __privateSet(this, _liveConnected, args.liveConnected === true);
29451
+ __privateSet(this, _liveAdmitted, args.liveAdmitted);
29176
29452
  __privateSet(this, _receiveState, args.receiveState);
29177
29453
  __privateSet(this, _completeHistory, args.completeHistory === true);
29178
29454
  __privateSet(this, _repairMissingCommit, args.repairMissingCommit === true);
@@ -29328,6 +29604,7 @@
29328
29604
  _lastStep2 = new WeakMap();
29329
29605
  _probeOnly = new WeakMap();
29330
29606
  _liveConnected = new WeakMap();
29607
+ _liveAdmitted = new WeakMap();
29331
29608
  _establishedBase = new WeakMap();
29332
29609
  _receiveState = new WeakMap();
29333
29610
  _completeHistory = new WeakMap();
@@ -29340,6 +29617,9 @@
29340
29617
  _offerAfterConverge = new WeakMap();
29341
29618
  _rebaseFrom = new WeakMap();
29342
29619
  _rebases = new WeakMap();
29620
+ _remountsLost = new WeakMap();
29621
+ _containment = new WeakMap();
29622
+ _containedBookmark = new WeakMap();
29343
29623
  _parkedLocal = new WeakMap();
29344
29624
  _replaceLocalHead = new WeakMap();
29345
29625
  _repairMissingCommit = new WeakMap();
@@ -29351,9 +29631,15 @@
29351
29631
  if (__privateGet(this, _receiveState)) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "full");
29352
29632
  if (__privateGet(this, _replaceLocalHead) !== void 0) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, __privateGet(this, _repairMissingCommit) ? "full" : "mount");
29353
29633
  if (!__privateGet(this, _localHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, __privateGet(this, _completeHistory) ? "full" : "mount");
29354
- if (__privateGet(this, _liveConnected) && !__privateGet(this, _probeOnly) && __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _previousHead)) {
29355
- return __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
29634
+ const unadmitted = __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _localHead) !== __privateGet(this, _liveAdmitted);
29635
+ if (__privateGet(this, _liveConnected) && unadmitted && __privateGet(this, _previousHead)) {
29636
+ if (__privateMethod(this, _WorkspaceSyncWork_instances, mayBeContained_fn).call(this)) return __privateMethod(this, _WorkspaceSyncWork_instances, askContainment_fn).call(this, "offer");
29637
+ return __privateMethod(this, _WorkspaceSyncWork_instances, notContained_fn).call(this);
29356
29638
  }
29639
+ 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)) {
29640
+ return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "level");
29641
+ }
29642
+ if (__privateGet(this, _liveConnected) && !__privateGet(this, _probeOnly) && !unadmitted) return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "level");
29357
29643
  const requestId = `${__privateGet(this, _binding).replicaId}:${__privateGet(this, _requestId5)}:${this.workId}:frontier`;
29358
29644
  return __privateMethod(this, _WorkspaceSyncWork_instances, beginOffer_fn).call(this, encodeInlineCustodyOffer({
29359
29645
  session: __privateGet(this, _binding).replicaId,
@@ -29362,6 +29648,60 @@
29362
29648
  intents: []
29363
29649
  }), { case: "awaiting", requestId }, true);
29364
29650
  };
29651
+ /** Whether the custodian's main may hold this copy's head: not already refused in this lifetime. */
29652
+ mayBeContained_fn = function() {
29653
+ return !!__privateGet(this, _localHead) && __privateGet(this, _offerHead) === void 0 && notContainedThisLifetime.get(__privateGet(this, _mount2).workspace) !== __privateGet(this, _localHead);
29654
+ };
29655
+ /** The probe named a custodian main that is not on this copy's own chain, so the copy's head may be
29656
+ * on the custodian's. A main below the local head (the custodian is behind) cannot contain it. A
29657
+ * complete copy answers a main it does not hold after one existence check, and one it holds after
29658
+ * a walk to where the two chains join. A kernel that cannot say keeps the existing path. */
29659
+ custodianMainOffLocalChain_fn = function() {
29660
+ if (!__privateGet(this, _kernel18).historySummary || !__privateGet(this, _desiredHead) || !__privateGet(this, _localHead)) return false;
29661
+ try {
29662
+ return !__privateGet(this, _kernel18).historySummary(__privateGet(this, _mount2), __privateGet(this, _requestId5), __privateGet(this, _desiredHead), __privateGet(this, _localHead)).reachedBase;
29663
+ } catch (error) {
29664
+ return error instanceof KernelHistoryRequired;
29665
+ }
29666
+ };
29667
+ /** Level from the local head (CAP-870). The stream answers with the custodian's commits above it
29668
+ * (or "level") only when its main holds that head; then this round converges onto them, moves the
29669
+ * bookmark, and offers nothing. One custodian lookup, O(commits behind); no local enumeration. */
29670
+ askContainment_fn = function(otherwise) {
29671
+ __privateSet(this, _containment, otherwise);
29672
+ return __privateMethod(this, _WorkspaceSyncWork_instances, acquire_fn).call(this, "level");
29673
+ };
29674
+ /** The stream answered from the local head: it is on the custodian's main. The stale bookmark
29675
+ * stays this round's to replace; the local head is the round's base from here. */
29676
+ contained_fn = function() {
29677
+ __privateSet(this, _containment, void 0);
29678
+ __privateSet(this, _containedBookmark, __privateGet(this, _previousHead));
29679
+ __privateSet(this, _previousHead, __privateGet(this, _localHead));
29680
+ };
29681
+ /** The custodian's main does not hold the local head (or the stream could not say): the copy holds
29682
+ * work of its own. Go straight on to the pull/rebase/offer path. A dependency planner's probe hands
29683
+ * the round back to it to plan the outbound suffix. */
29684
+ notContained_fn = function(code) {
29685
+ const otherwise = __privateGet(this, _containment) ?? "offer";
29686
+ __privateSet(this, _containment, void 0);
29687
+ if (code !== void 0 && NOT_CONTAINED_REFUSALS.has(code) && __privateGet(this, _localHead)) {
29688
+ if (notContainedThisLifetime.size >= MAX_NOT_CONTAINED && !notContainedThisLifetime.has(__privateGet(this, _mount2).workspace)) {
29689
+ notContainedThisLifetime.delete(notContainedThisLifetime.keys().next().value);
29690
+ }
29691
+ notContainedThisLifetime.set(__privateGet(this, _mount2).workspace, __privateGet(this, _localHead));
29692
+ }
29693
+ if (__privateGet(this, _probeOnly)) {
29694
+ __privateSet(this, _needsReconciliation, true);
29695
+ return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
29696
+ workspace: __privateGet(this, _mount2).workspace,
29697
+ currentHead: __privateGet(this, _localHead),
29698
+ previousHead: __privateGet(this, _previousHead),
29699
+ stillAhead: true,
29700
+ offerReceipt: __privateGet(this, _offerReceipt)
29701
+ }));
29702
+ }
29703
+ return otherwise === "pull" ? __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this) : __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
29704
+ };
29365
29705
  offerOrReconcile_fn = function() {
29366
29706
  var _a;
29367
29707
  if (__privateGet(this, _command2).admit && __privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead)) {
@@ -29436,7 +29776,14 @@
29436
29776
  return __privateGet(this, _previousHead) === void 0 && __privateGet(this, _localHead) !== void 0 && __privateGet(this, _replaceLocalHead) === void 0;
29437
29777
  };
29438
29778
  holdsLocalWork_fn = function() {
29439
- return __privateGet(this, _command2).admit && !!__privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead);
29779
+ return __privateGet(this, _command2).admit && __privateMethod(this, _WorkspaceSyncWork_instances, holdsUnsyncedCommits_fn).call(this);
29780
+ };
29781
+ /** Commits on local main the provider has not been seen to admit, whether or not this round may
29782
+ * offer them. Remount replaces local main, so it asks this, never the admit-gated question: a copy
29783
+ * holding unsynced work is offered and rebased, never remounted. A copy without a bookmark cannot
29784
+ * prove it holds nothing of its own. */
29785
+ holdsUnsyncedCommits_fn = function() {
29786
+ return !!__privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead);
29440
29787
  };
29441
29788
  /** Ask only for the custodian's delta; the offer follows once this peer has rebased. */
29442
29789
  pullBeforeOffer_fn = function() {
@@ -29474,13 +29821,13 @@
29474
29821
  }
29475
29822
  if (purpose === "level") {
29476
29823
  __privateSet(this, _state, { phase: WorkspaceSyncPhase.Stream, purpose, startedAt });
29477
- return __privateMethod(this, _WorkspaceSyncWork_instances, streamEffect_fn).call(this, "level", { case: "level", value: create(LiveFrontierSchema, {
29824
+ return __privateMethod(this, _WorkspaceSyncWork_instances, streamEffect_fn).call(this, __privateGet(this, _containment) ? "contain" : "level", { case: "level", value: create(LiveFrontierSchema, {
29478
29825
  head: __privateGet(this, _localHead) ?? "",
29479
29826
  response: false,
29480
29827
  maxOffers: __privateGet(this, _receiveStep)?.offers ?? STREAM_BATCH_OFFERS,
29481
29828
  // Only a copy holding no work above its bookmark may be remounted instead of replaying, and
29482
29829
  // never one whose durable copy must hold the complete history (a head-only mount it cannot keep).
29483
- remountAfterOffers: __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) || __privateGet(this, _completeHistory) ? 0 : REMOUNT_AFTER_OFFERS
29830
+ remountAfterOffers: __privateMethod(this, _WorkspaceSyncWork_instances, holdsUnsyncedCommits_fn).call(this) || __privateGet(this, _completeHistory) ? 0 : REMOUNT_AFTER_OFFERS
29484
29831
  }) });
29485
29832
  }
29486
29833
  const outcomes = new EffectOutcomeTransfer(__privateGet(this, _kernel18), __privateGet(this, _mount2), __privateGet(this, _requestId5));
@@ -29554,6 +29901,7 @@
29554
29901
  }
29555
29902
  if (answer.outcome.case === "refusal") {
29556
29903
  const refusal2 = answer.outcome.value;
29904
+ if (state.purpose === "level" && __privateGet(this, _containment)) return __privateMethod(this, _WorkspaceSyncWork_instances, notContained_fn).call(this, refusal2.code);
29557
29905
  if (state.afterPlacement) return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, state.afterPlacement);
29558
29906
  return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, `${refusal2.code}: ${refusal2.message}`, false);
29559
29907
  }
@@ -29586,6 +29934,11 @@
29586
29934
  for (const boundary of slice.shallow) __privateGet(this, _boundaries).add(boundary);
29587
29935
  return __privateMethod(this, _WorkspaceSyncWork_instances, historyOrMount_fn).call(this, state.candidateHead, state.receivedBytes + Number(answer.receivedBytes), state.startedAt);
29588
29936
  }
29937
+ if (state.purpose === "level" && __privateGet(this, _containment)) {
29938
+ const answeredFromHead = answer.outcome.case === "level" || answer.outcome.case === "pack" && answer.outcome.value.base === __privateGet(this, _localHead);
29939
+ if (!answeredFromHead) return __privateMethod(this, _WorkspaceSyncWork_instances, notContained_fn).call(this);
29940
+ __privateMethod(this, _WorkspaceSyncWork_instances, contained_fn).call(this);
29941
+ }
29589
29942
  if (state.purpose === "level" && answer.outcome.case === "pack" && answer.outcome.value.base) {
29590
29943
  const batch = answer.outcome.value;
29591
29944
  if (batch.base !== __privateGet(this, _previousHead) && batch.base !== __privateGet(this, _kernel18).head(__privateGet(this, _mount2), __privateGet(this, _requestId5))) {
@@ -29724,13 +30077,19 @@
29724
30077
  /**
29725
30078
  * A copy holding no work above its bookmark, too far behind to replay the backlog: mount the
29726
30079
  * peer's checkpoint in place of its exact local main (O(state), the same trust as a cold mount).
29727
- * The kernel keeps the replaced head at refs/heads/custody-preserved/<old>; that head was only a
29728
- * bookmark of the provider's own main, so the preservation is released at once.
30080
+ * The kernel keeps the replaced head at refs/heads/custody-preserved/<old>. That ref is custody the
30081
+ * kernel guards (custody may not delete an effectful branch), so it is left where it is: a remount
30082
+ * that deleted it threw after main had already moved, leaving the bookmark behind main and the
30083
+ * round failed for ever (2026-10-08, estate-5b493d6b).
30084
+ *
30085
+ * The copy may have moved while the checkpoint streamed (a live batch, a local write). Then it is
30086
+ * no longer the copy the remount was asked for: take the round up again from its new head. Local
30087
+ * work is offered first; a copy that is still only behind asks to level again.
29729
30088
  */
29730
30089
  remount_fn = function(candidateHead, receivedBytes, prefetchMillis) {
29731
30090
  const expected = __privateGet(this, _kernel18).head(__privateGet(this, _mount2), __privateGet(this, _requestId5));
29732
- if (expected === void 0 || expected !== __privateGet(this, _localHead) || __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this)) {
29733
- return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, "the copy changed while its remount was streaming", false);
30091
+ if (expected === void 0 || expected !== __privateGet(this, _localHead) || __privateMethod(this, _WorkspaceSyncWork_instances, holdsUnsyncedCommits_fn).call(this)) {
30092
+ return __privateMethod(this, _WorkspaceSyncWork_instances, remountLost_fn).call(this, expected);
29734
30093
  }
29735
30094
  const started = __privateGet(this, _clock14).monotonicNanoseconds();
29736
30095
  if (candidateHead !== expected) {
@@ -29738,7 +30097,6 @@
29738
30097
  if (!restored.accepted || restored.head !== candidateHead) {
29739
30098
  throw new Error(`kernel refused to remount '${__privateGet(this, _mount2).workspace}' at ${candidateHead}`);
29740
30099
  }
29741
- __privateGet(this, _kernel18).deleteRef?.(__privateGet(this, _mount2), __privateGet(this, _requestId5), `refs/heads/custody-preserved/${expected}`);
29742
30100
  __privateMethod(this, _WorkspaceSyncWork_instances, providerCustodyMounted_fn).call(this);
29743
30101
  }
29744
30102
  return __privateMethod(this, _WorkspaceSyncWork_instances, converged_fn).call(this, create(SyncResponseSchema, {
@@ -29748,6 +30106,25 @@
29748
30106
  admittedRemoteHead: candidateHead
29749
30107
  }), candidateHead, receivedBytes, prefetchMillis, started);
29750
30108
  };
30109
+ /** The remount's copy changed under it. Bounded: a copy that keeps moving under live traffic is
30110
+ * levelled by its live link anyway, and the next round starts from wherever it got to. */
30111
+ remountLost_fn = function(head) {
30112
+ if (head === void 0 || ++__privateWrapper(this, _remountsLost)._ > MAX_REMOUNTS_LOST) {
30113
+ return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, "the copy changed while its remount was streaming", false);
30114
+ }
30115
+ __privateSet(this, _localHead, head);
30116
+ __privateSet(this, _previousHead, __privateGet(this, _kernel18).resolveRef(__privateGet(this, _mount2), __privateGet(this, _requestId5), trackedMain));
30117
+ if (__privateGet(this, _desiredHead) === __privateGet(this, _localHead)) {
30118
+ return __privateMethod(this, _WorkspaceSyncWork_instances, converged_fn).call(this, create(SyncResponseSchema, {
30119
+ admitted: true,
30120
+ head,
30121
+ candidateHead: head,
30122
+ admittedRemoteHead: head
30123
+ }), head, 0, 0);
30124
+ }
30125
+ if (__privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _desiredHead) !== __privateGet(this, _previousHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this);
30126
+ return __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
30127
+ };
29751
30128
  beginOffer_fn = function(body, exchange, probe = false) {
29752
30129
  const phase = probe ? WorkspaceSyncPhase.Probe : WorkspaceSyncPhase.Offer;
29753
30130
  __privateSet(this, _state, { phase, exchange });
@@ -29868,6 +30245,10 @@
29868
30245
  offerReceipt: __privateGet(this, _offerReceipt)
29869
30246
  }));
29870
30247
  }
30248
+ const custodianMoved = __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _desiredHead) !== __privateGet(this, _previousHead);
30249
+ if (custodianMoved && __privateMethod(this, _WorkspaceSyncWork_instances, mayBeContained_fn).call(this) && __privateMethod(this, _WorkspaceSyncWork_instances, custodianMainOffLocalChain_fn).call(this)) {
30250
+ return __privateMethod(this, _WorkspaceSyncWork_instances, askContainment_fn).call(this, "pull");
30251
+ }
29871
30252
  if (__privateGet(this, _probeOnly)) {
29872
30253
  __privateSet(this, _needsReconciliation, true);
29873
30254
  return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
@@ -29878,9 +30259,7 @@
29878
30259
  offerReceipt: __privateGet(this, _offerReceipt)
29879
30260
  }));
29880
30261
  }
29881
- if (__privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _desiredHead) !== __privateGet(this, _previousHead)) {
29882
- return __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this);
29883
- }
30262
+ if (custodianMoved) return __privateMethod(this, _WorkspaceSyncWork_instances, pullBeforeOffer_fn).call(this);
29884
30263
  return __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
29885
30264
  }
29886
30265
  __privateSet(this, _admissionSummary, summarizeCustodyAdmission(admission));
@@ -30195,7 +30574,8 @@
30195
30574
  }));
30196
30575
  };
30197
30576
  converged_fn = function(verdict, candidateHead, receivedBytes, prefetchMillis, started = __privateGet(this, _clock14).monotonicNanoseconds(), rebirth) {
30198
- if (verdict.admitted && __privateGet(this, _candidateDurable) && candidateHead !== __privateGet(this, _previousHead) && __privateGet(this, _kernel18).resolveRef(__privateGet(this, _mount2), __privateGet(this, _requestId5), trackedMain) === __privateGet(this, _previousHead)) {
30577
+ const tracked = verdict.admitted && __privateGet(this, _candidateDurable) ? __privateGet(this, _kernel18).resolveRef(__privateGet(this, _mount2), __privateGet(this, _requestId5), trackedMain) : void 0;
30578
+ if (verdict.admitted && __privateGet(this, _candidateDurable) && tracked !== candidateHead && (tracked === __privateGet(this, _previousHead) || __privateGet(this, _containedBookmark) !== void 0 && tracked === __privateGet(this, _containedBookmark))) {
30199
30579
  __privateGet(this, _kernel18).writeRef(
30200
30580
  __privateGet(this, _mount2),
30201
30581
  __privateGet(this, _requestId5),
@@ -30480,10 +30860,16 @@
30480
30860
  __privateSet(this, _plan2, [__privateGet(this, _args).root]);
30481
30861
  return __privateMethod(this, _WorkspaceDependencySyncWork_instances, advance_fn4).call(this);
30482
30862
  }
30483
- if (__privateGet(this, _args).liveConnected && __privateGet(this, _args).kernel.resolveRef(__privateGet(this, _args).root.mount, __privateGet(this, _args).requestId, trackedMain2)) {
30863
+ const { kernel, requestId, root } = __privateGet(this, _args);
30864
+ const tracked = __privateGet(this, _args).liveConnected ? kernel.resolveRef(root.mount, requestId, trackedMain2) : void 0;
30865
+ if (tracked && kernel.head(root.mount, requestId) === tracked) {
30484
30866
  __privateSet(this, _plan2, __privateMethod(this, _WorkspaceDependencySyncWork_instances, planDependencies_fn).call(this));
30485
30867
  return __privateMethod(this, _WorkspaceDependencySyncWork_instances, advance_fn4).call(this);
30486
30868
  }
30869
+ if (tracked) {
30870
+ __privateSet(this, _current4, __privateMethod(this, _WorkspaceDependencySyncWork_instances, work_fn).call(this, root, `${this.workId}:contain`, true));
30871
+ return __privateMethod(this, _WorkspaceDependencySyncWork_instances, accept_fn).call(this, __privateGet(this, _current4).start());
30872
+ }
30487
30873
  __privateSet(this, _current4, __privateMethod(this, _WorkspaceDependencySyncWork_instances, work_fn).call(this, __privateGet(this, _args).root, `${this.workId}:frontier`, true));
30488
30874
  return __privateMethod(this, _WorkspaceDependencySyncWork_instances, accept_fn).call(this, __privateGet(this, _current4).start());
30489
30875
  }
@@ -31527,7 +31913,7 @@
31527
31913
  Letter: 0,
31528
31914
  Correspondent: 1
31529
31915
  });
31530
- 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;
31916
+ 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;
31531
31917
  var RemoteWorkspaceEffectDeliveryWork = class {
31532
31918
  constructor(args) {
31533
31919
  __privateAdd(this, _RemoteWorkspaceEffectDeliveryWork_instances);
@@ -31539,7 +31925,7 @@
31539
31925
  __privateAdd(this, _retention2);
31540
31926
  __privateAdd(this, _admitted);
31541
31927
  __privateAdd(this, _awaitingObservation, false);
31542
- __privateAdd(this, _pending4);
31928
+ __privateAdd(this, _pending3);
31543
31929
  __privateAdd(this, _targetCall);
31544
31930
  __privateAdd(this, _deferredRetryAfterMillis);
31545
31931
  __privateAdd(this, _retryScope, CorrespondenceRetryScope.Letter);
@@ -31564,8 +31950,8 @@
31564
31950
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next());
31565
31951
  }
31566
31952
  resume(receipt) {
31567
- if (__privateGet(this, _pending4)?.effect.case === "retainFrontier") {
31568
- const expected2 = __privateGet(this, _pending4).effect.value;
31953
+ if (__privateGet(this, _pending3)?.effect.case === "retainFrontier") {
31954
+ const expected2 = __privateGet(this, _pending3).effect.value;
31569
31955
  if (receipt.effectId !== expected2.effectId) throw new Error(`receipt '${receipt.effectId}' does not answer '${expected2.effectId}'`);
31570
31956
  const retained = receipt.outcome;
31571
31957
  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)) {
@@ -31580,7 +31966,7 @@
31580
31966
  settled.value.delivered = 0n;
31581
31967
  settled.value.refused = 0n;
31582
31968
  __privateSet(this, _settled2, void 0);
31583
- __privateSet(this, _pending4, void 0);
31969
+ __privateSet(this, _pending3, void 0);
31584
31970
  __privateSet(this, _retaining, void 0);
31585
31971
  return settled;
31586
31972
  }
@@ -31588,7 +31974,7 @@
31588
31974
  }
31589
31975
  const retaining = __privateGet(this, _retaining);
31590
31976
  __privateSet(this, _retaining, void 0);
31591
- __privateSet(this, _pending4, void 0);
31977
+ __privateSet(this, _pending3, void 0);
31592
31978
  if (retaining === WorkspaceEffectRetentionLeg.Source) return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, observeTargetOffer_fn).call(this);
31593
31979
  if (retaining === WorkspaceEffectRetentionLeg.Outcome) {
31594
31980
  const settled = __privateGet(this, _settled2);
@@ -31597,11 +31983,11 @@
31597
31983
  }
31598
31984
  const admitted = __privateGet(this, _admitted);
31599
31985
  __privateSet(this, _admitted, void 0);
31600
- __privateSet(this, _pending4, void 0);
31986
+ __privateSet(this, _pending3, void 0);
31601
31987
  __privateSet(this, _targetCall, void 0);
31602
31988
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(admitted, __privateGet(this, _settlement)));
31603
31989
  }
31604
- const expected = __privateGet(this, _pending4)?.effect.case === "http" ? __privateGet(this, _pending4).effect.value.effectId : void 0;
31990
+ const expected = __privateGet(this, _pending3)?.effect.case === "http" ? __privateGet(this, _pending3).effect.value.effectId : void 0;
31605
31991
  if (!expected || !__privateGet(this, _targetCall)) throw new Error(`correspondence work '${this.workId}' is not awaiting transport`);
31606
31992
  if (receipt.effectId !== expected) throw new Error(`receipt '${receipt.effectId}' does not answer '${expected}'`);
31607
31993
  if (receipt.outcome.case === "failure") {
@@ -31626,7 +32012,7 @@
31626
32012
  requestId: __privateGet(this, _targetCall).request.requestId,
31627
32013
  outcome: { case: "offer", value: status.judgment }
31628
32014
  });
31629
- __privateSet(this, _pending4, void 0);
32015
+ __privateSet(this, _pending3, void 0);
31630
32016
  __privateSet(this, _targetCall, void 0);
31631
32017
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(response2, __privateGet(this, _settlement)));
31632
32018
  }
@@ -31647,7 +32033,7 @@
31647
32033
  }
31648
32034
  }
31649
32035
  });
31650
- __privateSet(this, _pending4, void 0);
32036
+ __privateSet(this, _pending3, void 0);
31651
32037
  __privateSet(this, _targetCall, void 0);
31652
32038
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(held));
31653
32039
  }
@@ -31665,7 +32051,7 @@
31665
32051
  requestId: __privateGet(this, _targetCall).request.requestId,
31666
32052
  outcome: { case: "offer", value: applied }
31667
32053
  });
31668
- __privateSet(this, _pending4, void 0);
32054
+ __privateSet(this, _pending3, void 0);
31669
32055
  __privateSet(this, _targetCall, void 0);
31670
32056
  __privateSet(this, _admitted, void 0);
31671
32057
  __privateSet(this, _awaitingObservation, false);
@@ -31680,7 +32066,7 @@
31680
32066
  _retention2 = new WeakMap();
31681
32067
  _admitted = new WeakMap();
31682
32068
  _awaitingObservation = new WeakMap();
31683
- _pending4 = new WeakMap();
32069
+ _pending3 = new WeakMap();
31684
32070
  _targetCall = new WeakMap();
31685
32071
  _deferredRetryAfterMillis = new WeakMap();
31686
32072
  _retryScope = new WeakMap();
@@ -31691,7 +32077,7 @@
31691
32077
  transportFailed_fn = function(message) {
31692
32078
  const call = __privateGet(this, _targetCall);
31693
32079
  if (!call) throw new Error("failed transport has no target call");
31694
- __privateSet(this, _pending4, void 0);
32080
+ __privateSet(this, _pending3, void 0);
31695
32081
  __privateSet(this, _targetCall, void 0);
31696
32082
  __privateSet(this, _admitted, void 0);
31697
32083
  __privateSet(this, _awaitingObservation, false);
@@ -31721,7 +32107,7 @@
31721
32107
  const head2 = __privateGet(this, _kernel20).head(source2, 0n);
31722
32108
  if (!head2) throw new Error("effect outcome source has no custody frontier");
31723
32109
  __privateSet(this, _retaining, WorkspaceEffectRetentionLeg.Outcome);
31724
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32110
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
31725
32111
  workId: this.workId,
31726
32112
  effect: { case: "retainFrontier", value: create(RetainFrontierEffectSchema, {
31727
32113
  effectId: `${this.workId}:retain-outcome`,
@@ -31731,7 +32117,7 @@
31731
32117
  refs: __privateGet(this, _retention2).refs(source2.workspace)
31732
32118
  }) }
31733
32119
  }));
31734
- return { case: "pending", value: __privateGet(this, _pending4) };
32120
+ return { case: "pending", value: __privateGet(this, _pending3) };
31735
32121
  }
31736
32122
  return settled;
31737
32123
  }
@@ -31757,7 +32143,7 @@
31757
32143
  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");
31758
32144
  __privateSet(this, _admitted, response);
31759
32145
  __privateSet(this, _retaining, WorkspaceEffectRetentionLeg.Target);
31760
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32146
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
31761
32147
  workId: this.workId,
31762
32148
  effect: { case: "retainFrontier", value: create(RetainFrontierEffectSchema, {
31763
32149
  effectId: `${this.workId}:retain:${offer.id}`,
@@ -31767,7 +32153,7 @@
31767
32153
  refs: __privateGet(this, _retention2).refs(step.value.mount.workspace)
31768
32154
  }) }
31769
32155
  }));
31770
- return { case: "pending", value: __privateGet(this, _pending4) };
32156
+ return { case: "pending", value: __privateGet(this, _pending3) };
31771
32157
  }
31772
32158
  __privateSet(this, _targetCall, void 0);
31773
32159
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, advance_fn5).call(this, __privateGet(this, _delivery).next(response, __privateGet(this, _settlement)));
@@ -31776,7 +32162,7 @@
31776
32162
  const head = __privateGet(this, _kernel20).head(source, 0n);
31777
32163
  if (!head) return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, transportFailed_fn).call(this, "effect source has no admitted custody frontier");
31778
32164
  __privateSet(this, _retaining, WorkspaceEffectRetentionLeg.Source);
31779
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32165
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
31780
32166
  workId: this.workId,
31781
32167
  effect: { case: "retainFrontier", value: create(RetainFrontierEffectSchema, {
31782
32168
  effectId: `${this.workId}:retain-source:${offer.id}`,
@@ -31786,14 +32172,14 @@
31786
32172
  refs: __privateGet(this, _retention2).refs(source.workspace)
31787
32173
  }) }
31788
32174
  }));
31789
- return { case: "pending", value: __privateGet(this, _pending4) };
32175
+ return { case: "pending", value: __privateGet(this, _pending3) };
31790
32176
  };
31791
32177
  observeTargetOffer_fn = function() {
31792
32178
  const offer = __privateGet(this, _targetCall)?.offer;
31793
32179
  if (!offer || !__privateGet(this, _mailboxUrl)) throw new Error("mailbox observation has no active offer");
31794
32180
  if (offer.effectDigest && offer.sourceWorkspaceGenesis) {
31795
32181
  __privateSet(this, _awaitingObservation, true);
31796
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, { workId: this.workId, effect: {
32182
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, { workId: this.workId, effect: {
31797
32183
  case: "http",
31798
32184
  value: create(PeerHttpEffectSchema, {
31799
32185
  effectId: `${this.workId}:observe:${offer.id}`,
@@ -31807,7 +32193,7 @@
31807
32193
  }))
31808
32194
  })
31809
32195
  } }));
31810
- return { case: "pending", value: __privateGet(this, _pending4) };
32196
+ return { case: "pending", value: __privateGet(this, _pending3) };
31811
32197
  }
31812
32198
  return __privateMethod(this, _RemoteWorkspaceEffectDeliveryWork_instances, postTargetOffer_fn).call(this);
31813
32199
  };
@@ -31830,11 +32216,11 @@
31830
32216
  accept: CARRIED_OFFER_RESPONSE,
31831
32217
  body: toBinary(OfferRequestSchema, body)
31832
32218
  });
31833
- __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32219
+ __privateSet(this, _pending3, create(CorrespondencePendingSchema, {
31834
32220
  workId: this.workId,
31835
32221
  effect: { case: "http", value: effect }
31836
32222
  }));
31837
- return { case: "pending", value: __privateGet(this, _pending4) };
32223
+ return { case: "pending", value: __privateGet(this, _pending3) };
31838
32224
  };
31839
32225
 
31840
32226
  // ../src/runtime/replica_follow_lane.ts
@@ -31870,6 +32256,11 @@
31870
32256
  const delay = __privateGet(this, _controller).reconnected(workspace);
31871
32257
  if (delay !== void 0) __privateMethod(this, _ReplicaFollowLane_instances, scheduleAt_fn).call(this, workspace, __privateMethod(this, _ReplicaFollowLane_instances, now_fn8).call(this) + delay);
31872
32258
  }
32259
+ /** The upstream announced a new frontier: news even to a follow the kernel refused. */
32260
+ remoteAdvanced(workspace) {
32261
+ const delay = __privateGet(this, _controller).reconnected(workspace, true);
32262
+ if (delay !== void 0) __privateMethod(this, _ReplicaFollowLane_instances, scheduleAt_fn).call(this, workspace, __privateMethod(this, _ReplicaFollowLane_instances, now_fn8).call(this) + delay);
32263
+ }
31873
32264
  /** The upstream rang for a new placement frontier (see ReplicaFollowController). */
31874
32265
  placementAnnounced(workspace) {
31875
32266
  const delay = __privateGet(this, _controller).placementAnnounced(workspace);
@@ -32052,7 +32443,7 @@
32052
32443
  init_shims();
32053
32444
  var PREPARATION_QUANTA_PER_TURN = 64;
32054
32445
  var RETRY_AFTER_MILLIS = 30000n;
32055
- var _command4, _source4, _kernel21, _clock19, _requestId7, _offer, _pending5, _settled3, _HttpObligationDeliveryWork_instances, complete_fn;
32446
+ var _command4, _source4, _kernel21, _clock19, _requestId7, _offer, _pending4, _settled3, _HttpObligationDeliveryWork_instances, complete_fn;
32056
32447
  var HttpObligationDeliveryWork = class {
32057
32448
  constructor(args) {
32058
32449
  __privateAdd(this, _HttpObligationDeliveryWork_instances);
@@ -32063,7 +32454,7 @@
32063
32454
  __privateAdd(this, _clock19);
32064
32455
  __privateAdd(this, _requestId7);
32065
32456
  __privateAdd(this, _offer);
32066
- __privateAdd(this, _pending5);
32457
+ __privateAdd(this, _pending4);
32067
32458
  __privateAdd(this, _settled3);
32068
32459
  this.workId = args.workId;
32069
32460
  __privateSet(this, _command4, args.command);
@@ -32074,7 +32465,7 @@
32074
32465
  }
32075
32466
  start() {
32076
32467
  if (__privateGet(this, _settled3)) return __privateGet(this, _settled3);
32077
- if (__privateGet(this, _pending5)) return { case: "pending", value: __privateGet(this, _pending5) };
32468
+ if (__privateGet(this, _pending4)) return { case: "pending", value: __privateGet(this, _pending4) };
32078
32469
  if (!__privateGet(this, _command4).sourceOfferPath) {
32079
32470
  throw new Error("HTTP obligation delivery requires an exact source offer path");
32080
32471
  }
@@ -32103,7 +32494,7 @@
32103
32494
  throw new Error("prepared HTTP obligation lacks its durable delivery identity");
32104
32495
  }
32105
32496
  __privateSet(this, _offer, offer);
32106
- __privateSet(this, _pending5, create(CorrespondencePendingSchema, {
32497
+ __privateSet(this, _pending4, create(CorrespondencePendingSchema, {
32107
32498
  workId: this.workId,
32108
32499
  effect: {
32109
32500
  case: "http",
@@ -32119,13 +32510,13 @@
32119
32510
  })
32120
32511
  }
32121
32512
  }));
32122
- return { case: "pending", value: __privateGet(this, _pending5) };
32513
+ return { case: "pending", value: __privateGet(this, _pending4) };
32123
32514
  }
32124
32515
  return __privateMethod(this, _HttpObligationDeliveryWork_instances, complete_fn).call(this, false, false, true);
32125
32516
  }
32126
32517
  resume(receipt) {
32127
32518
  if (__privateGet(this, _settled3)) return __privateGet(this, _settled3);
32128
- const pending = __privateGet(this, _pending5);
32519
+ const pending = __privateGet(this, _pending4);
32129
32520
  const offer = __privateGet(this, _offer);
32130
32521
  if (!pending || pending.effect.case !== "http" || !offer) {
32131
32522
  throw new Error(`HTTP obligation work '${this.workId}' is not awaiting transport`);
@@ -32133,7 +32524,7 @@
32133
32524
  if (receipt.effectId !== pending.effect.value.effectId) {
32134
32525
  throw new Error(`receipt '${receipt.effectId}' does not answer '${pending.effect.value.effectId}'`);
32135
32526
  }
32136
- __privateSet(this, _pending5, void 0);
32527
+ __privateSet(this, _pending4, void 0);
32137
32528
  __privateSet(this, _offer, void 0);
32138
32529
  if (receipt.outcome.case === "response" && receipt.outcome.value.status >= 200 && receipt.outcome.value.status < 300) {
32139
32530
  __privateGet(this, _kernel21).writeRef(
@@ -32153,7 +32544,7 @@
32153
32544
  _clock19 = new WeakMap();
32154
32545
  _requestId7 = new WeakMap();
32155
32546
  _offer = new WeakMap();
32156
- _pending5 = new WeakMap();
32547
+ _pending4 = new WeakMap();
32157
32548
  _settled3 = new WeakMap();
32158
32549
  _HttpObligationDeliveryWork_instances = new WeakSet();
32159
32550
  complete_fn = function(attempted, delivered, preparationPending, retryAtMillis) {
@@ -32172,7 +32563,7 @@
32172
32563
  var REFETCH_AWAITS_PROVIDER = "nomos.runtime.refetch_awaits_provider";
32173
32564
  var LOCAL_COPY_REFETCHING = "nomos.runtime.local_copy_refetching";
32174
32565
  var LIVE_ADMISSION_GRACE_MILLIS = 1e4;
32175
- 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;
32566
+ 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;
32176
32567
  var CorrespondenceDesk = class {
32177
32568
  constructor(args) {
32178
32569
  __privateAdd(this, _CorrespondenceDesk_instances);
@@ -32206,6 +32597,7 @@
32206
32597
  __privateAdd(this, _onPlacementFetched);
32207
32598
  __privateAdd(this, _onShallowMount);
32208
32599
  __privateAdd(this, _onOffered);
32600
+ __privateAdd(this, _liveAdmitted2);
32209
32601
  __privateAdd(this, _onOutboxHistoryRequired);
32210
32602
  __privateAdd(this, _backgroundHistory);
32211
32603
  __privateAdd(this, _receiveStep2);
@@ -32263,6 +32655,7 @@
32263
32655
  __privateSet(this, _onPlacementFetched, args.onPlacementFetched);
32264
32656
  __privateSet(this, _onShallowMount, args.onShallowMount);
32265
32657
  __privateSet(this, _onOffered, args.onOffered);
32658
+ __privateSet(this, _liveAdmitted2, args.liveAdmitted);
32266
32659
  __privateSet(this, _onOutboxHistoryRequired, args.onOutboxHistoryRequired);
32267
32660
  __privateSet(this, _backgroundHistory, args.backgroundHistory !== false);
32268
32661
  __privateSet(this, _receiveStep2, args.receiveStep);
@@ -32518,6 +32911,12 @@
32518
32911
  __privateGet(this, _followLane).reconnected(workspace);
32519
32912
  this.reportFollows();
32520
32913
  }
32914
+ /** The upstream announced a new frontier for this workspace over its live link: an event which
32915
+ * re-runs a round the kernel refused (its inputs changed). */
32916
+ replicaRemoteAdvanced(workspace) {
32917
+ __privateGet(this, _followLane).remoteAdvanced(workspace);
32918
+ this.reportFollows();
32919
+ }
32521
32920
  /** The upstream rang for a new placement frontier: the next round re-checks placement even
32522
32921
  * though main has not moved. */
32523
32922
  replicaPlacementAnnounced(workspace) {
@@ -32552,10 +32951,11 @@
32552
32951
  const state = __privateGet(this, _follows2).followForWorkspace(workspace)?.state;
32553
32952
  if (!state) return [];
32554
32953
  const isSettled = state.case === ReplicaFollowPhase.Settled;
32954
+ const refused = state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked === true;
32555
32955
  const isLive = __privateGet(this, _openLinks).has(workspace);
32556
32956
  if (isSettled) settled += 1;
32557
32957
  if (isLive) live += 1;
32558
- const phase = {
32958
+ const phase = refused ? FollowObservationPhase.KERNEL_REFUSED : {
32559
32959
  [ReplicaFollowPhase.Desired]: FollowObservationPhase.DESIRED,
32560
32960
  [ReplicaFollowPhase.Due]: FollowObservationPhase.DUE,
32561
32961
  [ReplicaFollowPhase.Running]: FollowObservationPhase.RUNNING,
@@ -32569,7 +32969,7 @@
32569
32969
  [ReplicaFollowPhase.LocalCopyUnreadable]: FollowObservationPhase.LOCAL_COPY_UNREADABLE
32570
32970
  }[state.case];
32571
32971
  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;
32572
- const retryAt = state.case === ReplicaFollowPhase.Offline || state.case === ReplicaFollowPhase.InvalidCredential || state.case === ReplicaFollowPhase.Backoff ? state.retryAtUnixMillis : void 0;
32972
+ 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;
32573
32973
  const dueAt2 = state.case === ReplicaFollowPhase.Due || state.case === ReplicaFollowPhase.ReplacingLocal ? state.dueAtUnixMillis : void 0;
32574
32974
  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;
32575
32975
  const activeEffect = state.case === ReplicaFollowPhase.Running ? __privateMethod(this, _CorrespondenceDesk_instances, activeSyncEffect_fn).call(this, workspace) : void 0;
@@ -33007,6 +33407,7 @@
33007
33407
  const active = /* @__PURE__ */ new Set([mount.workspace]);
33008
33408
  let roundPlacementFrontier;
33009
33409
  const work = (target3, id, probeOnly = false, beforeConverge) => {
33410
+ var _a;
33010
33411
  active.add(target3.mount.workspace);
33011
33412
  const isRoot = target3.mount.workspace === mount.workspace;
33012
33413
  const targetRoute = isRoot ? route : __privateGet(this, _placement3).syncRoute(request, target3.mount);
@@ -33022,13 +33423,13 @@
33022
33423
  lawProductsImported: __privateGet(this, _lawProductsImported2),
33023
33424
  lawProductsInFlight: __privateGet(this, _lawProductsInFlight2),
33024
33425
  shallowMounted: (credentialCapability) => {
33025
- var _a;
33026
- return (_a = __privateGet(this, _onShallowMount)) == null ? void 0 : _a.call(this, target3.mount.workspace, credentialCapability);
33426
+ var _a2;
33427
+ return (_a2 = __privateGet(this, _onShallowMount)) == null ? void 0 : _a2.call(this, target3.mount.workspace, credentialCapability);
33027
33428
  },
33028
33429
  ...__privateGet(this, _receiveStep2) ? { receiveStep: __privateGet(this, _receiveStep2) } : {},
33029
33430
  ...__privateGet(this, _onOffered) ? { offered: (oids) => {
33030
- var _a;
33031
- return (_a = __privateGet(this, _onOffered)) == null ? void 0 : _a.call(this, target3.mount.workspace, oids);
33431
+ var _a2;
33432
+ return (_a2 = __privateGet(this, _onOffered)) == null ? void 0 : _a2.call(this, target3.mount.workspace, oids);
33032
33433
  } } : {},
33033
33434
  // A dropped copy's refetch authorization names the root workspace alone.
33034
33435
  command: target3.mount.workspace === mount.workspace || command.replaceLocalHead === void 0 ? command : create(SyncWorkspaceRequestSchema, { workspace: command.workspace, admit: command.admit }),
@@ -33036,6 +33437,7 @@
33036
33437
  workId: id,
33037
33438
  probeOnly,
33038
33439
  liveConnected: __privateGet(this, _openLinks).has(target3.mount.workspace),
33440
+ ...__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) } : {},
33039
33441
  ...beforeConverge === void 0 ? {} : { beforeConverge },
33040
33442
  ...target3.receiveState === void 0 ? {} : { receiveState: target3.receiveState },
33041
33443
  ...target3.offerHead === void 0 ? {} : { offerHead: target3.offerHead },
@@ -33050,8 +33452,8 @@
33050
33452
  ...isRoot ? {
33051
33453
  directoryAnswered: () => __privateGet(this, _follows2).placementRechecked(mount.workspace),
33052
33454
  placementFetched: () => {
33053
- var _a;
33054
- return (_a = __privateGet(this, _onPlacementFetched)) == null ? void 0 : _a.call(this, mount.workspace);
33455
+ var _a2;
33456
+ return (_a2 = __privateGet(this, _onPlacementFetched)) == null ? void 0 : _a2.call(this, mount.workspace);
33055
33457
  }
33056
33458
  } : {}
33057
33459
  });
@@ -33235,6 +33637,7 @@
33235
33637
  _onPlacementFetched = new WeakMap();
33236
33638
  _onShallowMount = new WeakMap();
33237
33639
  _onOffered = new WeakMap();
33640
+ _liveAdmitted2 = new WeakMap();
33238
33641
  _onOutboxHistoryRequired = new WeakMap();
33239
33642
  _backgroundHistory = new WeakMap();
33240
33643
  _receiveStep2 = new WeakMap();
@@ -33507,17 +33910,17 @@
33507
33910
  // ../src/runtime/birth_custody_desk.ts
33508
33911
  init_define_NOMOS_KERNEL_RELEASE();
33509
33912
  init_shims();
33510
- var _finalOutcome, _pending6, _completed7, _lastReceiptEffectId3;
33913
+ var _finalOutcome, _pending5, _completed7, _lastReceiptEffectId3;
33511
33914
  var BirthCustodyWork = class {
33512
33915
  constructor(args) {
33513
33916
  __publicField(this, "workId");
33514
33917
  __privateAdd(this, _finalOutcome);
33515
- __privateAdd(this, _pending6);
33918
+ __privateAdd(this, _pending5);
33516
33919
  __privateAdd(this, _completed7);
33517
33920
  __privateAdd(this, _lastReceiptEffectId3);
33518
33921
  this.workId = args.workId;
33519
33922
  __privateSet(this, _finalOutcome, args.finalOutcome);
33520
- __privateSet(this, _pending6, create(CorrespondencePendingSchema, {
33923
+ __privateSet(this, _pending5, create(CorrespondencePendingSchema, {
33521
33924
  workId: this.workId,
33522
33925
  effect: {
33523
33926
  case: "persistBornCustody",
@@ -33529,13 +33932,13 @@
33529
33932
  }));
33530
33933
  }
33531
33934
  start() {
33532
- return __privateGet(this, _completed7) ?? { case: "pending", value: __privateGet(this, _pending6) };
33935
+ return __privateGet(this, _completed7) ?? { case: "pending", value: __privateGet(this, _pending5) };
33533
33936
  }
33534
33937
  resume(receipt) {
33535
33938
  if (receipt.effectId === __privateGet(this, _lastReceiptEffectId3) && __privateGet(this, _completed7)) {
33536
33939
  return __privateGet(this, _completed7);
33537
33940
  }
33538
- const effect = __privateGet(this, _pending6).effect;
33941
+ const effect = __privateGet(this, _pending5).effect;
33539
33942
  if (effect.case !== "persistBornCustody") {
33540
33943
  throw new Error(`birth custody work '${this.workId}' has no persistence effect`);
33541
33944
  }
@@ -33575,7 +33978,7 @@
33575
33978
  }
33576
33979
  };
33577
33980
  _finalOutcome = new WeakMap();
33578
- _pending6 = new WeakMap();
33981
+ _pending5 = new WeakMap();
33579
33982
  _completed7 = new WeakMap();
33580
33983
  _lastReceiptEffectId3 = new WeakMap();
33581
33984
  var _kernel23, _work3, _publicationRefs, _origins4, _BirthCustodyDesk_instances, begin_fn3;
@@ -34138,13 +34541,13 @@
34138
34541
  init_define_NOMOS_KERNEL_RELEASE();
34139
34542
  init_shims();
34140
34543
  var cloneCall = (call) => fromBinary(CallRequestSchema, toBinary(CallRequestSchema, call));
34141
- var _identity, _application2, _pending7, _completed9, _completedOrder, _completedLimit2, _IdentityRecoveryDesk_instances, rememberCompleted_fn, adoptAndRetry_fn;
34544
+ var _identity, _application2, _pending6, _completed9, _completedOrder, _completedLimit2, _IdentityRecoveryDesk_instances, rememberCompleted_fn, adoptAndRetry_fn;
34142
34545
  var IdentityRecoveryDesk = class {
34143
34546
  constructor(identity, application) {
34144
34547
  __privateAdd(this, _IdentityRecoveryDesk_instances);
34145
34548
  __privateAdd(this, _identity);
34146
34549
  __privateAdd(this, _application2);
34147
- __privateAdd(this, _pending7, /* @__PURE__ */ new Map());
34550
+ __privateAdd(this, _pending6, /* @__PURE__ */ new Map());
34148
34551
  __privateAdd(this, _completed9, /* @__PURE__ */ new Map());
34149
34552
  __privateAdd(this, _completedOrder, []);
34150
34553
  __privateAdd(this, _completedLimit2, 128);
@@ -34175,25 +34578,25 @@
34175
34578
  return __privateMethod(this, _IdentityRecoveryDesk_instances, adoptAndRetry_fn).call(this, runtimeRequest, command, originalCall, requirement, step.value);
34176
34579
  }
34177
34580
  const requestKey = runtimeRequest.requestId.toString();
34178
- const waiters = __privateGet(this, _pending7).get(step.value.workId) ?? /* @__PURE__ */ new Map();
34581
+ const waiters = __privateGet(this, _pending6).get(step.value.workId) ?? /* @__PURE__ */ new Map();
34179
34582
  waiters.set(requestKey, {
34180
34583
  runtimeRequest,
34181
34584
  command,
34182
34585
  originalCall,
34183
34586
  requirement
34184
34587
  });
34185
- __privateGet(this, _pending7).set(step.value.workId, waiters);
34588
+ __privateGet(this, _pending6).set(step.value.workId, waiters);
34186
34589
  return step;
34187
34590
  }
34188
34591
  has(workId2, requestId) {
34189
34592
  const requestKey = requestId.toString();
34190
- return __privateGet(this, _pending7).get(workId2)?.has(requestKey) === true || __privateGet(this, _completed9).get(workId2)?.has(requestKey) === true;
34593
+ return __privateGet(this, _pending6).get(workId2)?.has(requestKey) === true || __privateGet(this, _completed9).get(workId2)?.has(requestKey) === true;
34191
34594
  }
34192
34595
  continue(workId2, receipt, requestId) {
34193
34596
  const requestKey = requestId.toString();
34194
34597
  const completed = __privateGet(this, _completed9).get(workId2)?.get(requestKey);
34195
34598
  if (completed) return completed;
34196
- const waiters = __privateGet(this, _pending7).get(workId2);
34599
+ const waiters = __privateGet(this, _pending6).get(workId2);
34197
34600
  const pending = waiters?.get(requestKey);
34198
34601
  if (!pending) {
34199
34602
  throw new Error(
@@ -34203,20 +34606,20 @@
34203
34606
  const step = __privateGet(this, _identity).continue(workId2, receipt);
34204
34607
  if (step.case === "pending") return step;
34205
34608
  waiters.delete(requestKey);
34206
- if (waiters.size === 0) __privateGet(this, _pending7).delete(workId2);
34609
+ if (waiters.size === 0) __privateGet(this, _pending6).delete(workId2);
34207
34610
  const result = __privateMethod(this, _IdentityRecoveryDesk_instances, adoptAndRetry_fn).call(this, pending.runtimeRequest, pending.command, pending.originalCall, pending.requirement, step.value);
34208
34611
  __privateMethod(this, _IdentityRecoveryDesk_instances, rememberCompleted_fn).call(this, workId2, requestKey, result);
34209
34612
  return result;
34210
34613
  }
34211
34614
  clear() {
34212
- __privateGet(this, _pending7).clear();
34615
+ __privateGet(this, _pending6).clear();
34213
34616
  __privateGet(this, _completed9).clear();
34214
34617
  __privateGet(this, _completedOrder).length = 0;
34215
34618
  }
34216
34619
  };
34217
34620
  _identity = new WeakMap();
34218
34621
  _application2 = new WeakMap();
34219
- _pending7 = new WeakMap();
34622
+ _pending6 = new WeakMap();
34220
34623
  _completed9 = new WeakMap();
34221
34624
  _completedOrder = new WeakMap();
34222
34625
  _completedLimit2 = new WeakMap();
@@ -34922,10 +35325,10 @@
34922
35325
  while (true) {
34923
35326
  __privateGet(this, _ports6).owe(owed.workspace);
34924
35327
  while (__privateGet(this, _ports6).owes(owed.workspace)) {
34925
- const tick = __privateGet(this, _ports6).tick();
35328
+ const { ticked, wake: readiness } = __privateGet(this, _ports6).tick();
34926
35329
  const delayMillis = Math.min(LONGEST_WAKE_MILLIS, Math.max(
34927
35330
  FIRST_WAKE_MILLIS,
34928
- tick.progress !== void 0 ? FIRST_WAKE_MILLIS : tick.nextTickAfterMillis
35331
+ ticked.progress !== void 0 ? FIRST_WAKE_MILLIS : readiness.case === "after" ? readiness.millis : LONGEST_WAKE_MILLIS
34929
35332
  ));
34930
35333
  const receipt = yield { case: "wake", value: create(PeerWakeEffectSchema, {
34931
35334
  effectId: `${workId2}:repay-${++wake}`,
@@ -35067,7 +35470,6 @@
35067
35470
  }
35068
35471
  var INTERACTIVE_PEER_CLASSES = /* @__PURE__ */ new Set(["personal-device", "browser"]);
35069
35472
  var INTERACTION_FIRST_MILLIS = 15e3;
35070
- var READ_READINESS_ONLY = 1n << 62n;
35071
35473
  var PLACEMENT_READ_RETRY_MILLIS = 60000n;
35072
35474
  var STREAM_WAKE_FIRST_MILLIS = 20;
35073
35475
  var HISTORY_STREAM_SLICES = [8, 64, 256];
@@ -35086,7 +35488,6 @@
35086
35488
  "continueLocalRead"
35087
35489
  ]);
35088
35490
  var APPLICATION_WAIT_NANOS = 5000000000n;
35089
- var READ_INDEX_BUILDING = /the read index of .+ is being built|read maintenance continues it/;
35090
35491
  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;
35091
35492
  var PeerOffice = class {
35092
35493
  constructor(kernel, credentials, profile, observations, custodyStorage, peerDeskStore) {
@@ -35270,7 +35671,6 @@
35270
35671
  }
35271
35672
  }, (workspace) => __privateGet(this, _residency5).lastRetainedHead(workspace)));
35272
35673
  if (__privateGet(this, _writeBurst)) __privateGet(this, _live3).writeBurst = __privateGet(this, _writeBurst);
35273
- if (__privateGet(this, _interactivePeer)) __privateGet(this, _live3).receiveStep = __privateGet(this, _receiveStepBudget);
35274
35674
  __privateSet(this, _credentials7, new CredentialSessions(__privateGet(this, _sessions14), credentials, observations));
35275
35675
  __privateSet(this, _readability3, new LocalCopyReadability((workspace, format) => {
35276
35676
  __privateGet(this, _follows3).markLocalCopyUnreadable(workspace, format);
@@ -35288,7 +35688,8 @@
35288
35688
  new ReplicaFollowDesk(seatedStore),
35289
35689
  observations,
35290
35690
  __privateGet(this, _replicaId3),
35291
- new BirthRefusalRegister(seatedStore)
35691
+ new BirthRefusalRegister(seatedStore),
35692
+ PEER_RUNTIME_IDENTITY
35292
35693
  ));
35293
35694
  __privateSet(this, _compatibility2, new CompatibilityDesk(
35294
35695
  __privateGet(this, _queries8),
@@ -35307,13 +35708,20 @@
35307
35708
  __privateGet(this, _trace13),
35308
35709
  observations,
35309
35710
  {
35310
- readReady: (workspace) => __privateGet(this, _subscriptions5).readIndexReady(workspace),
35311
- frontierAdvanced: (workspace) => __privateGet(this, _subscriptions5).readIndexAdvanced(workspace),
35312
- localCopyUnreadable: (workspace, format) => __privateGet(this, _readability3).mark(
35313
- workspace,
35314
- __privateGet(this, _kernel27).head(workspaceMount(workspace), 0n),
35315
- format
35316
- ),
35711
+ // A read waiting on this workspace is released by the readiness event itself, not a timer.
35712
+ readReady: (workspace) => {
35713
+ __privateGet(this, _subscriptions5).readIndexReady(workspace);
35714
+ __privateGet(this, _readResponses)?.readinessChanged(workspace);
35715
+ },
35716
+ frontierAdvanced: (workspace) => {
35717
+ __privateGet(this, _subscriptions5).readIndexAdvanced(workspace);
35718
+ __privateGet(this, _readResponses)?.readinessChanged(workspace);
35719
+ },
35720
+ readinessMayChange: (workspace) => __privateGet(this, _readResponses)?.readinessChanged(workspace),
35721
+ localCopyUnreadable: (workspace, format) => {
35722
+ __privateGet(this, _readability3).mark(workspace, __privateGet(this, _kernel27).head(workspaceMount(workspace), 0n), format);
35723
+ __privateGet(this, _readResponses)?.readinessChanged(workspace);
35724
+ },
35317
35725
  isLocalCopyUnreadable: (workspace) => __privateGet(this, _readability3).decide(workspace) !== void 0
35318
35726
  },
35319
35727
  // The kernel owes this peer's writes to an ordered background flush the desk schedules.
@@ -35375,7 +35783,7 @@
35375
35783
  aggregateIds: new Set([...admitted.affected, ...admitted.created].map((ref) => ref.id)),
35376
35784
  // What the offer changed, typed as reads resolve it: watches it cannot change are not read.
35377
35785
  stateChange: admitted.stateChange
35378
- }, () => __privateGet(this, _readMaintenance).tick(void 0, 0n, READ_READINESS_ONLY, false).progress !== void 0));
35786
+ }, () => __privateGet(this, _readMaintenance).tickReadReadiness().ticked.progress !== void 0));
35379
35787
  noteTimeline("ownOffer", `${delivery.delivered}/${delivery.watches}`);
35380
35788
  noteTimeline("ownOfferSkipped", delivery.skipped);
35381
35789
  });
@@ -35390,7 +35798,12 @@
35390
35798
  observations,
35391
35799
  // A waiting read advances read readiness only: it must never run a background command or
35392
35800
  // closure warm on the foreground's turn.
35393
- () => __privateGet(this, _readMaintenance).tick(void 0, 0n, READ_READINESS_ONLY, false),
35801
+ () => __privateGet(this, _readMaintenance).tickReadReadiness(),
35802
+ // A read the kernel still finds behind, with nothing owing its index, owes it again (as a watch does).
35803
+ (request) => {
35804
+ if (request.command.case !== "kernelCall") throw new Error("local read continuation lost its query");
35805
+ __privateGet(this, _readMaintenance).schedule(request.command.value.session, ReadMaintenanceCause.READ_DEBT);
35806
+ },
35394
35807
  (request) => {
35395
35808
  if (request.command.case !== "kernelCall") throw new Error("local read continuation lost its query");
35396
35809
  return __privateGet(this, _application3).call(request, request.command.value);
@@ -35491,6 +35904,7 @@
35491
35904
  onShallowMount: (workspace, credentialCapability) => __privateGet(this, _historyAcquisition).materialise(workspace, credentialCapability),
35492
35905
  // The edge echoes an HTTP offer batch back over this replica's own live link (CAP-764).
35493
35906
  onOffered: (workspace, commitOids) => __privateGet(this, _live3).offered(workspace, commitOids),
35907
+ liveAdmitted: (workspace) => __privateGet(this, _live3).admittedLocal(workspace),
35494
35908
  onOutboxHistoryRequired: (workspace, credentialCapability) => __privateGet(this, _historyAcquisition).requestFromBackground(workspace, credentialCapability),
35495
35909
  backgroundHistory: profile.backgroundHistory !== false,
35496
35910
  onSyncCompleted: (session, event) => {
@@ -35516,7 +35930,7 @@
35516
35930
  __privateGet(this, _origins5).ignored(workspace, origin, "follow");
35517
35931
  return false;
35518
35932
  };
35519
- __privateGet(this, _live3).remoteAdvanced = (workspace) => __privateGet(this, _correspondence3).replicaLinkOpened(workspace);
35933
+ __privateGet(this, _live3).remoteAdvanced = (workspace) => __privateGet(this, _correspondence3).replicaRemoteAdvanced(workspace);
35520
35934
  __privateGet(this, _live3).declined = (workspace) => __privateGet(this, _correspondence3).liveAdmissionDeclined(workspace);
35521
35935
  __privateGet(this, _live3).acknowledged = (workspace, ack) => __privateGet(this, _correspondence3).liveAdmissionAcknowledged(workspace, ack);
35522
35936
  __privateGet(this, _live3).intentsAdmitted = (workspace, intentIds, local) => __privateGet(this, _correspondence3).liveIntentsAdmitted(workspace, intentIds, local);
@@ -35728,7 +36142,7 @@
35728
36142
  },
35729
36143
  owes: (workspace) => __privateGet(this, _readMaintenance).owesReadReadiness(workspace),
35730
36144
  // Read readiness only, as a waiting read takes: never a background command or pack import (CAP-806).
35731
- tick: () => __privateGet(this, _readMaintenance).tick(void 0, 0n, READ_READINESS_ONLY, false),
36145
+ tick: () => __privateGet(this, _readMaintenance).tickReadReadiness(),
35732
36146
  emit: (session, event) => __privateGet(this, _trace13).emit(session, event)
35733
36147
  }));
35734
36148
  __privateSet(this, _modelAdoption, new ModelAdoptionDesk({
@@ -35945,6 +36359,10 @@
35945
36359
  nextEvent() {
35946
36360
  return __privateGet(this, _trace13).nextEvent();
35947
36361
  }
36362
+ /** In-process shells wait on a held local read here instead of polling `resumeAfterMillis`. */
36363
+ localReadResumable(workId2, notify) {
36364
+ return __privateGet(this, _readResponses).onResumable(workId2, notify);
36365
+ }
35948
36366
  close() {
35949
36367
  if (this.retentionOutstanding() > 0) {
35950
36368
  throw new Error("custody retention pending; retain the acknowledged frontiers before disposing the peer");
@@ -36311,9 +36729,8 @@
36311
36729
  let pendingEffectId;
36312
36730
  try {
36313
36731
  if (request.command.case === "socketReceipt") {
36314
- const admission = __privateGet(this, _live3).receive(request, request.command.value);
36315
- if (!admission) return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, { case: "socketObserved", value: create(PeerSocketObservedSchema) });
36316
- request = admission;
36732
+ __privateGet(this, _live3).receive(request.command.value);
36733
+ return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, { case: "socketObserved", value: create(PeerSocketObservedSchema) });
36317
36734
  }
36318
36735
  const result = timelinePhase("access", () => __privateGet(this, _access).handle(request));
36319
36736
  if (result.outcome.case === "correspondencePending") {
@@ -36322,11 +36739,9 @@
36322
36739
  }
36323
36740
  if (result.outcome.case === "watchStarted") __privateGet(this, _subscriptions5).retainDependencies(result.outcome.value.subscriptionId, scope2);
36324
36741
  __privateGet(this, _subscriptions5).recoverySettled(result);
36325
- __privateGet(this, _live3).settled(request, result);
36326
36742
  __privateGet(this, _correspondence3).observeResponse(result);
36327
36743
  return result;
36328
36744
  } catch (error) {
36329
- __privateGet(this, _live3).failed(request.requestId);
36330
36745
  const failure = __privateMethod(this, _PeerOffice_instances, failure_fn).call(this, request, "nomos.runtime.workspace_access", error instanceof Error ? error.message : String(error));
36331
36746
  __privateGet(this, _subscriptions5).recoverySettled(failure);
36332
36747
  __privateGet(this, _correspondence3).observeResponse(failure);
@@ -36581,11 +36996,7 @@
36581
36996
  try {
36582
36997
  const mount = __privateGet(this, _sessions14).mountForWorkspace(request.target.workspace);
36583
36998
  const previousHead = __privateGet(this, _kernel27).head(mount, request.requestId);
36584
- const admission = __privateGet(this, _custodyAdmission).admit(
36585
- request,
36586
- request.command.value,
36587
- { journal: !__privateGet(this, _live3).relayed(request.requestId) }
36588
- );
36999
+ const admission = __privateGet(this, _custodyAdmission).admit(request, request.command.value);
36589
37000
  admission.sealedMain = __privateGet(this, _residency5).retainedHead(request.target.workspace);
36590
37001
  if (custodyAdmissionNeedsReadMaintenance(admission)) {
36591
37002
  admission.localMaintenance = __privateGet(this, _readMaintenance).scheduleWorkspace(
@@ -36699,16 +37110,17 @@
36699
37110
  });
36700
37111
  case "historicQuery": {
36701
37112
  const answered2 = __privateGet(this, _historicQueries).execute(request, request.command.value);
36702
- if (answered2.outcome.case === "failure" && READ_INDEX_BUILDING.test(answered2.outcome.value.message)) {
37113
+ if (answered2.outcome.case === "query" && answered2.outcome.value.result.case === "readIndexPending") {
36703
37114
  __privateGet(this, _readMaintenance).schedule(request.command.value.session, ReadMaintenanceCause.READ_DEBT);
37115
+ const workspace = answered2.outcome.value.result.value.workspace || (__privateGet(this, _sessions14).bindingIfPresent(request.command.value.session)?.workspace ?? "");
36704
37116
  return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, {
36705
37117
  case: "unavailable",
36706
37118
  value: create(RuntimeUnavailableSchema, {
36707
37119
  reason: RuntimeUnavailableReason.LOCAL_REPLICA_NOT_READY,
36708
- workspace: __privateGet(this, _sessions14).bindingIfPresent(request.command.value.session)?.workspace ?? "",
37120
+ workspace,
36709
37121
  retryable: true,
36710
37122
  retryAfterMillis: 250,
36711
- detail: answered2.outcome.value.message
37123
+ detail: `the read index of ${workspace} is being built on this device; read maintenance continues it`
36712
37124
  })
36713
37125
  });
36714
37126
  }
@@ -37354,6 +37766,23 @@
37354
37766
  lanes?.wake(delayMillis);
37355
37767
  };
37356
37768
  const runner = {
37769
+ localReadResumable(workId2) {
37770
+ let resolve;
37771
+ const resumable = new Promise((done) => {
37772
+ resolve = done;
37773
+ });
37774
+ let timer;
37775
+ const wait = peer2.localReadResumable(workId2, () => {
37776
+ if (timer !== void 0) clearTimeout(timer);
37777
+ resolve();
37778
+ });
37779
+ if (wait === void 0) return void 0;
37780
+ timer = setTimeout(() => {
37781
+ wait.cancel();
37782
+ resolve();
37783
+ }, wait.afterMillis);
37784
+ return resumable;
37785
+ },
37357
37786
  handleFrame(frame2) {
37358
37787
  const response = peer2.invoke(frame2).responseProtobuf;
37359
37788
  drainEvents();
@@ -37583,7 +38012,7 @@
37583
38012
  if (response.outcome.case === "localReadPending") {
37584
38013
  if (yieldLocalReadToCaller) return responseFrame;
37585
38014
  const pending2 = response.outcome.value;
37586
- await new Promise((resolve) => setTimeout(resolve, pending2.resumeAfterMillis));
38015
+ await (runner.localReadResumable?.(pending2.workId) ?? new Promise((resolve) => setTimeout(resolve, pending2.resumeAfterMillis)));
37587
38016
  responseFrame = await turn(() => runner.handleFrame(toBinary(RuntimeRequestSchema, create(RuntimeRequestSchema, {
37588
38017
  protocolVersion: response.protocolVersion,
37589
38018
  requestId: response.requestId,
@@ -43563,11 +43992,30 @@
43563
43992
  const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
43564
43993
  return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
43565
43994
  };
43566
- var okBytes = async (fetchImpl, url) => {
43995
+ var okBytes = async (fetchImpl, url, progress, expectedBytes) => {
43567
43996
  const response = await fetchImpl(url);
43568
43997
  if (!response.ok) throw new Error(`runtime artifact ${url}: HTTP ${response.status}`);
43569
- return new Uint8Array(await response.arrayBuffer());
43998
+ const reader = progress ? response.body?.getReader() : void 0;
43999
+ if (!reader) return new Uint8Array(await response.arrayBuffer());
44000
+ const total = expectedBytes ?? Number(response.headers.get("content-length") ?? 0);
44001
+ const chunks = [];
44002
+ let received = 0;
44003
+ for (; ; ) {
44004
+ const { done, value } = await reader.read();
44005
+ if (done) break;
44006
+ chunks.push(value);
44007
+ received += value.byteLength;
44008
+ progress(received, total);
44009
+ }
44010
+ const bytes = new Uint8Array(received);
44011
+ let offset = 0;
44012
+ for (const chunk of chunks) {
44013
+ bytes.set(chunk, offset);
44014
+ offset += chunk.byteLength;
44015
+ }
44016
+ return bytes;
43570
44017
  };
44018
+ var elapsedSince = (started) => globalThis.performance.now() - started;
43571
44019
  async function selectReleaseKernel(args) {
43572
44020
  const fetchImpl = args.fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
43573
44021
  const base = args.base.replace(/\/+$/, "");
@@ -43595,11 +44043,27 @@
43595
44043
  }
43596
44044
  }
43597
44045
  const url = new URL(relativeUrl, repositoryUrl).toString();
43598
- const bytes = await okBytes(fetchImpl, url);
43599
- if (expected && (bytes.byteLength !== expected.size || await sha256Hex2(bytes) !== expected.sha256)) {
43600
- throw new Error(`runtime artifact ${url} does not match the OSGi resource it was selected by`);
44046
+ const report = (progress) => {
44047
+ try {
44048
+ args.onProgress?.(progress);
44049
+ } catch {
44050
+ }
44051
+ };
44052
+ let started = globalThis.performance.now();
44053
+ const bytes = await okBytes(fetchImpl, url, args.onProgress ? (receivedBytes, totalBytes) => report({ stage: "download", artifact: name, receivedBytes, totalBytes }) : void 0, expected?.size);
44054
+ report({ stage: "fetched", artifact: name, millis: elapsedSince(started) });
44055
+ if (expected) {
44056
+ started = globalThis.performance.now();
44057
+ if (bytes.byteLength !== expected.size || await sha256Hex2(bytes) !== expected.sha256) {
44058
+ throw new Error(`runtime artifact ${url} does not match the OSGi resource it was selected by`);
44059
+ }
44060
+ report({ stage: "verified", artifact: name, millis: elapsedSince(started) });
44061
+ }
44062
+ if (expected && args.cache) {
44063
+ started = globalThis.performance.now();
44064
+ await args.cache.write(resource.contentSha256, name, bytes);
44065
+ report({ stage: "stored", artifact: name, millis: elapsedSince(started) });
43601
44066
  }
43602
- if (expected && args.cache) await args.cache.write(resource.contentSha256, name, bytes);
43603
44067
  return bytes;
43604
44068
  };
43605
44069
  await verifySelectedKernel({
@@ -43685,6 +44149,8 @@
43685
44149
  var refusedGitTransport = (input) => Promise.reject(new Error(
43686
44150
  `refused: a tab moves no Git bytes itself (${String(input instanceof Request ? input.url : input).split("?")[0]}); custody comes from the workspace's stream`
43687
44151
  ));
44152
+ var DOWNLOAD_PROGRESS_BYTES = 1048576;
44153
+ var megabytes = (bytes) => (bytes / 1048576).toFixed(1);
43688
44154
  async function openBrowserPeer(options) {
43689
44155
  const bootStarted = performance.now();
43690
44156
  const progress = (stage) => {
@@ -43695,6 +44161,7 @@
43695
44161
  }
43696
44162
  };
43697
44163
  const fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
44164
+ const reportedBytes = /* @__PURE__ */ new Map();
43698
44165
  progress("opening browser custody and selecting Kernel artifacts");
43699
44166
  const selecting = selectReleaseKernel({
43700
44167
  base: options.base,
@@ -43702,7 +44169,19 @@
43702
44169
  release: options.release,
43703
44170
  fetchImpl: browserRuntimeFetch(options.base, fetchImpl, globalThis.caches, options.kernelRepositoryUrl),
43704
44171
  cache: options.kernelCache,
43705
- ...options.kernelTrustRoots === void 0 ? {} : { trustRoots: options.kernelTrustRoots }
44172
+ ...options.kernelTrustRoots === void 0 ? {} : { trustRoots: options.kernelTrustRoots },
44173
+ // A new kernel downloads (27 MB) and is verified and stored on the boot path: each step is
44174
+ // progress, so the host keeps waiting, and a slow boot's report times each one (CAP-799).
44175
+ onProgress: (step) => {
44176
+ if (step.stage !== "download") {
44177
+ progress(`${step.stage} ${step.artifact} in ${Math.round(step.millis)}ms`);
44178
+ return;
44179
+ }
44180
+ const last = reportedBytes.get(step.artifact) ?? 0;
44181
+ if (step.receivedBytes - last < DOWNLOAD_PROGRESS_BYTES && step.receivedBytes < step.totalBytes) return;
44182
+ reportedBytes.set(step.artifact, step.receivedBytes);
44183
+ progress(`downloading ${step.artifact} ${megabytes(step.receivedBytes)}/${megabytes(step.totalBytes)} MB`);
44184
+ }
43706
44185
  }).then((selected) => {
43707
44186
  progress("selected Kernel artifacts");
43708
44187
  return selected;
@@ -44230,7 +44709,7 @@
44230
44709
  return;
44231
44710
  }
44232
44711
  for (const state of states) {
44233
- const outstanding = state.dirty || state.unansweredAgesMs.length > 0 || state.head !== void 0 && state.head !== state.tracked;
44712
+ const outstanding = state.resident && (state.dirty || state.unansweredAgesMs.length > 0 || state.head !== void 0 && state.head !== state.tracked);
44234
44713
  if (!outstanding) {
44235
44714
  outstandingSince.delete(state.workspace);
44236
44715
  continue;