@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.
@@ -4722,8 +4722,10 @@ var NomosRuntimeComponent = (() => {
4722
4722
  var SignOfferPreparationRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 37);
4723
4723
  var SigningIdentityRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 39);
4724
4724
  var KernelRefusalSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 55);
4725
+ var QueryResponseSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 56);
4725
4726
  var ApplicationResultDeltaSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 58);
4726
4727
  var InterfaceCompatibilityQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 60);
4728
+ var ReadIndexPendingSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 64);
4727
4729
  var MaintenanceQuantumQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 65);
4728
4730
  var CarriedWorkspaceOfferSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 80);
4729
4731
  var PrepareOutboundOfferSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 84);
@@ -5984,7 +5986,7 @@ var NomosRuntimeComponent = (() => {
5984
5986
  var CustodyBreakPolicy = /* @__PURE__ */ tsEnum(CustodyBreakPolicySchema);
5985
5987
 
5986
5988
  // ../../adapter/proto/nomos/runtime/v2/observability_desk_pb.js
5987
- var file_nomos_runtime_v2_observability_desk = /* @__PURE__ */ fileDesc("Cilub21vcy9ydW50aW1lL3YyL29ic2VydmFiaWxpdHlfZGVzay5wcm90bxIQbm9tb3MucnVudGltZS52MiJCCgxUcmFjZUNvbnRleHQSEAoIdHJhY2VfaWQYASABKAwSDwo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VFJBTlNGRVJfS0lORF9GVUxMEAISFgoSVFJBTlNGRVJfS0lORF9QVVNIEANiBnByb3RvMw", [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]);
5989
+ var file_nomos_runtime_v2_observability_desk = /* @__PURE__ */ fileDesc("Cilub21vcy9ydW50aW1lL3YyL29ic2VydmFiaWxpdHlfZGVzay5wcm90bxIQbm9tb3MucnVudGltZS52MiJCCgxUcmFjZUNvbnRleHQSEAoIdHJhY2VfaWQYASABKAwSDwoHc3Bhbl9pZBgCIAEoDBIPCgdzYW1wbGVkGAMgASgIIp0CCg5SdW50aW1lRmFpbHVyZRIMCgRjb2RlGAEgASgJEg8KB21lc3NhZ2UYAiABKAkSEQoJY29tcG9uZW50GAMgASgJEhYKCXdvcmtzcGFjZRgEIAEoCUgAiAEBEhMKBmRvbWFpbhgFIAEoCUgBiAEBEhYKCWRpcmVjdGl2ZRgGIAEoCUgCiAEBEjkKCmF0dHJpYnV0ZXMYByADKAsyJS5ub21vcy5ydW50aW1lLnYyLkRpYWdub3N0aWNBdHRyaWJ1dGUSMgoEa2luZBgIIAEoDjIkLm5vbW9zLnJ1bnRpbWUudjIuUnVudGltZUZhaWx1cmVLaW5kQgwKCl93b3Jrc3BhY2VCCQoHX2RvbWFpbkIMCgpfZGlyZWN0aXZlIr4BChJSdW50aW1lVW5hdmFpbGFibGUSOgoGcmVhc29uGAEgASgOMioubm9tb3MucnVudGltZS52Mi5SdW50aW1lVW5hdmFpbGFibGVSZWFzb24SEQoJd29ya3NwYWNlGAIgASgJEhEKCXJldHJ5YWJsZRgDIAEoCBIfChJyZXRyeV9hZnRlcl9taWxsaXMYBCABKA1IAIgBARIOCgZkZ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UEhBU0VfQkFDS09GRhAIEiwKKEZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9SRUJPUk5fUkVNT1RFTFkQCRIsCihGT0xMT1dfT0JTRVJWQVRJT05fUEhBU0VfUkVQTEFDSU5HX0xPQ0FMEAoSMgouRk9MTE9XX09CU0VSVkFUSU9OX1BIQVNFX0xPQ0FMX0NPUFlfVU5SRUFEQUJMRRALEisKJ0ZPTExPV19PQlNFUlZBVElPTl9QSEFTRV9LRVJORUxfUkVGVVNFRBAMKlcKCkxpbmtTdGF0dXMSGwoXTElOS19TVEFUVVNfVU5TUEVDSUZJRUQQABIUChBMSU5LX1NUQVRVU19PUEVOEAESFgoSTElOS19TVEFUVVNfQ0xPU0VEEAIqdgoMVHJhbnNmZXJLaW5kEh0KGVRSQU5TRkVSX0tJTkRfVU5TUEVDSUZJRUQQABIXChNUUkFOU0ZFUl9LSU5EX0RFTFRBEAESFgoSVFJBTlNGRVJfS0lORF9GVUxMEAISFgoSVFJBTlNGRVJfS0lORF9QVVNIEANiBnByb3RvMw", [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]);
5988
5990
  var RuntimeFailureSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 1);
5989
5991
  var RuntimeUnavailableSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 2);
5990
5992
  var RuntimeRefusalSchema = /* @__PURE__ */ messageDesc(file_nomos_runtime_v2_observability_desk, 3);
@@ -6176,8 +6178,9 @@ var NomosRuntimeComponent = (() => {
6176
6178
 
6177
6179
  // ../src/runtime/live_inbound_stream.ts
6178
6180
  var LEVEL_BATCH = "level:";
6181
+ var HISTORY_REQUIRED = "nomos.stream.history_required";
6182
+ var CONTAINMENT_ASK_SUFFIX = ":contain";
6179
6183
  var STREAM_WINDOW_CHUNKS = 8;
6180
- var ASK_AGAIN_NANOS = 15000000000n;
6181
6184
  var historySlot = (workspace) => `${workspace}#history`;
6182
6185
  var LiveInboundStream = class {
6183
6186
  #ports;
@@ -6195,7 +6198,10 @@ var NomosRuntimeComponent = (() => {
6195
6198
  }
6196
6199
  return inbound;
6197
6200
  }
6198
- /** When this workspace's stream last delivered anything (a waiting procedure is progressing). */
6201
+ /** When this workspace's stream last delivered data to an ask (a waiting procedure is progressing).
6202
+ * A refusal, a frontier, unrelated traffic on the socket and this copy's own re-asking are not
6203
+ * progress: a procedure whose stream only ever says "ask again" gives up and its round fails over
6204
+ * (CAP-838). */
6199
6205
  lastHeard(workspace) {
6200
6206
  return this.#by.get(workspace)?.lastHeard;
6201
6207
  }
@@ -6218,7 +6224,8 @@ var NomosRuntimeComponent = (() => {
6218
6224
  inbound.wants.level = {
6219
6225
  effectId: effect.effectId,
6220
6226
  maxOffers: Math.max(1, request.value.maxOffers),
6221
- remountAfterOffers: request.value.remountAfterOffers
6227
+ remountAfterOffers: request.value.remountAfterOffers,
6228
+ contain: effect.effectId.endsWith(CONTAINMENT_ASK_SUFFIX)
6222
6229
  };
6223
6230
  this.#askLevel(effect.workspace, inbound);
6224
6231
  }
@@ -6278,7 +6285,7 @@ var NomosRuntimeComponent = (() => {
6278
6285
  const batch = inbound.levelBatch;
6279
6286
  if (batch) {
6280
6287
  inbound.levelBatch = void 0;
6281
- if (batch.base === this.#ports.head(effect.workspace)) {
6288
+ if (batch.base === this.#ports.head(effect.workspace) || batch.base === request.value.head) {
6282
6289
  inbound.wants.level = void 0;
6283
6290
  return create(PeerStreamReceiptSchema, {
6284
6291
  outcome: { case: "pack", value: batch },
@@ -6289,14 +6296,14 @@ var NomosRuntimeComponent = (() => {
6289
6296
  this.#askLevel(effect.workspace, inbound);
6290
6297
  }
6291
6298
  const head = this.#ports.head(effect.workspace);
6292
- if (head && inbound.announced && head === inbound.announced) {
6299
+ if (inbound.announced && (head === inbound.announced || inbound.askedFrom === inbound.announced)) {
6293
6300
  inbound.wants.level = void 0;
6294
6301
  return create(PeerStreamReceiptSchema, {
6295
- outcome: { case: "level", value: head },
6302
+ outcome: { case: "level", value: inbound.announced },
6296
6303
  ...inbound.sealed ? { sealed: inbound.sealed } : {}
6297
6304
  });
6298
6305
  }
6299
- return this.#refusalReceipt(inbound);
6306
+ return this.#refusalReceipt(inbound, inbound.wants.level?.effectId === effect.effectId && inbound.wants.level.contain);
6300
6307
  }
6301
6308
  if (request.case === "history" || request.case === "ref") {
6302
6309
  const want = inbound.wants.packs.get(request.value.requestId);
@@ -6311,10 +6318,16 @@ var NomosRuntimeComponent = (() => {
6311
6318
  return void 0;
6312
6319
  }
6313
6320
  /** A terminal refusal (not one that only says when to ask again) ends the procedure's wait. */
6314
- #refusalReceipt(inbound) {
6321
+ #refusalReceipt(inbound, contain = false) {
6315
6322
  const refused = inbound.refused;
6316
- if (!refused || refused.retryAfterMillis !== void 0) return void 0;
6323
+ if (!refused) return void 0;
6324
+ const answersContainment = contain && refused.code === HISTORY_REQUIRED;
6325
+ if (refused.retryAfterMillis !== void 0 && !answersContainment) return void 0;
6317
6326
  inbound.refused = void 0;
6327
+ if (answersContainment) {
6328
+ inbound.askAgainAt = void 0;
6329
+ inbound.wants.level = void 0;
6330
+ }
6318
6331
  return create(PeerStreamReceiptSchema, { outcome: { case: "refusal", value: refused } });
6319
6332
  }
6320
6333
  /** The procedure gave up (it timed out, or its work ended). */
@@ -6345,7 +6358,9 @@ var NomosRuntimeComponent = (() => {
6345
6358
  /** One frame from the peer. True when it was the stream's (the live desk handles the rest). */
6346
6359
  frame(workspace, message) {
6347
6360
  const inbound = this.#of(workspace);
6348
- inbound.lastHeard = this.#ports.monotonicNanoseconds();
6361
+ if (message.case === "checkpointOffer" || message.case === "checkpointChunk" || message.case === "pack") {
6362
+ inbound.lastHeard = this.#ports.monotonicNanoseconds();
6363
+ }
6349
6364
  switch (message.case) {
6350
6365
  case "frontier":
6351
6366
  if (message.value.response && message.value.head) {
@@ -6400,18 +6415,26 @@ var NomosRuntimeComponent = (() => {
6400
6415
  return false;
6401
6416
  }
6402
6417
  }
6403
- /** Re-ask what is due: a refusal's retry time passed, or an ask heard nothing for too long. */
6418
+ /**
6419
+ * Ask again when a refusal said when to (the peer was opening, or acquiring history). Nothing else
6420
+ * here runs on a timer (CAP-838): the socket is ordered and reliable, every ask is answered on it,
6421
+ * and an ask is re-sent only when its socket re-opens (`opened`) or its refusal's time comes. The
6422
+ * stream used to re-ask whatever had heard nothing for 15 s, and that resend - itself counted as
6423
+ * hearing - hid an ask answered "come back" for ever.
6424
+ */
6404
6425
  drive(workspace) {
6405
6426
  const inbound = this.#by.get(workspace);
6406
- if (!inbound || !this.wanted(workspace)) return void 0;
6427
+ if (!inbound || inbound.askAgainAt === void 0) return void 0;
6428
+ if (!this.wanted(workspace)) {
6429
+ inbound.askAgainAt = void 0;
6430
+ return void 0;
6431
+ }
6407
6432
  const now2 = this.#ports.monotonicNanoseconds();
6408
- const due2 = inbound.askAgainAt ?? inbound.lastHeard + ASK_AGAIN_NANOS;
6409
- if (now2 < due2) return due2 - now2;
6433
+ if (now2 < inbound.askAgainAt) return inbound.askAgainAt - now2;
6410
6434
  inbound.askAgainAt = void 0;
6411
6435
  inbound.refused = void 0;
6412
- inbound.lastHeard = now2;
6413
6436
  this.opened(workspace);
6414
- return ASK_AGAIN_NANOS;
6437
+ return void 0;
6415
6438
  }
6416
6439
  #offered(workspace, inbound, offer) {
6417
6440
  inbound.refused = void 0;
@@ -6454,6 +6477,7 @@ var NomosRuntimeComponent = (() => {
6454
6477
  const held = !taken ? -1 : "pack" in taken ? taken.pack.byteLength : taken.bytes;
6455
6478
  if (held !== transfer.bytes || transfer.received !== transfer.bytes) {
6456
6479
  if (taken && "stagedPackFile" in taken) this.#staging.clear(workspace);
6480
+ if (inbound.wants.checkpoint) this.#askCheckpoint(workspace, inbound);
6457
6481
  return;
6458
6482
  }
6459
6483
  inbound.complete = {
@@ -6571,8 +6595,12 @@ var NomosRuntimeComponent = (() => {
6571
6595
  this.#askCheckpoint(workspace, inbound);
6572
6596
  return;
6573
6597
  }
6598
+ inbound.announced = void 0;
6599
+ inbound.sealed = void 0;
6600
+ const head = this.#ports.head(workspace) ?? "";
6601
+ inbound.askedFrom = head;
6574
6602
  this.#ports.send(workspace, { case: "frontier", value: create(LiveFrontierSchema, {
6575
- head: this.#ports.head(workspace) ?? "",
6603
+ head,
6576
6604
  response: false,
6577
6605
  maxOffers: level.maxOffers,
6578
6606
  remountAfterOffers: level.remountAfterOffers,
@@ -7099,6 +7127,11 @@ var NomosRuntimeComponent = (() => {
7099
7127
  if (!READINESS_DEBT.test(message)) return void 0;
7100
7128
  return new KernelReadinessPending(/source workspace '([^']+)'/.exec(message)?.[1]?.trim(), message);
7101
7129
  };
7130
+ 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/;
7131
+ var kernelReadIndexBuilding = (message) => {
7132
+ const workspace = READ_INDEX_BUILDING.exec(message)?.[1]?.trim();
7133
+ return workspace === void 0 ? void 0 : { workspace };
7134
+ };
7102
7135
  var requiredForeignWorkspace = (message) => {
7103
7136
  const patterns = [
7104
7137
  /workspace '([^']+)' must be resident in the kernel/,
@@ -7122,9 +7155,31 @@ var NomosRuntimeComponent = (() => {
7122
7155
  throw new KernelWorkspaceResidencyRequired(workspace, failure.message);
7123
7156
  }
7124
7157
  }
7158
+ var KernelRefusal = class extends Error {
7159
+ code;
7160
+ failure;
7161
+ constructor(failure) {
7162
+ super(`${failure.code}: ${failure.message}`);
7163
+ this.name = "KernelRefusal";
7164
+ this.code = failure.code;
7165
+ this.failure = failure;
7166
+ }
7167
+ };
7125
7168
  function throwKernelFailure(failure) {
7126
7169
  throwIfKernelControlRequired(failure);
7127
- throw new Error(`${failure.code}: ${failure.message}`);
7170
+ throw new KernelRefusal(failure);
7171
+ }
7172
+ var KERNEL_FAILURE_TEXT = /^(NMS-[A-Z0-9]+(?:-[A-Z0-9]+)*): ([\s\S]*)$/;
7173
+ 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;
7174
+ function deterministicKernelRefusal(error) {
7175
+ if (error instanceof KernelWorkspaceResidencyRequired || error instanceof KernelHistoryRequired || error instanceof KernelReadinessPending) return void 0;
7176
+ if (error instanceof KernelRefusal && (error.failure.historyRequired !== void 0 || error.failure.identityProviderWitnessRequired !== void 0)) return void 0;
7177
+ const text = error instanceof Error ? error.message : typeof error === "string" ? error : "";
7178
+ const match = KERNEL_FAILURE_TEXT.exec(text);
7179
+ if (!match) return void 0;
7180
+ const [, code, message] = match;
7181
+ if (ENVIRONMENTAL.test(text) || READINESS_DEBT.test(message) || requiredForeignWorkspace(message) !== void 0) return void 0;
7182
+ return { code, message };
7128
7183
  }
7129
7184
  function rethrowTypedKernelFailure(error) {
7130
7185
  if (error instanceof KernelWorkspaceResidencyRequired || error instanceof KernelHistoryRequired) throw error;
@@ -7151,6 +7206,24 @@ var NomosRuntimeComponent = (() => {
7151
7206
  return void 0;
7152
7207
  }
7153
7208
  var PLACEMENT_REFERENCE = "refs/nomos/placement";
7209
+ function readIndexPendingAnswer(request, message) {
7210
+ if (request.operation.case !== "query" || request.operation.value.query.case === "maintenanceQuantum") return void 0;
7211
+ const building = kernelReadIndexBuilding(message);
7212
+ if (building === void 0) return void 0;
7213
+ const target3 = request.operation.value.target;
7214
+ return create(CallResponseSchema, {
7215
+ protocolVersion: request.protocolVersion,
7216
+ requestId: request.requestId,
7217
+ outcome: { case: "query", value: create(QueryResponseSchema, {
7218
+ result: { case: "readIndexPending", value: create(ReadIndexPendingSchema, {
7219
+ workspace: target3?.workspace || building.workspace,
7220
+ branch: target3?.branch ?? "",
7221
+ // The sliced build names no frontier: it restarts at whatever head main holds when it continues.
7222
+ requestedFrontier: ""
7223
+ }) }
7224
+ }) }
7225
+ });
7226
+ }
7154
7227
  var KernelPort = class {
7155
7228
  #kernel;
7156
7229
  #activeOperation;
@@ -8175,6 +8248,8 @@ var NomosRuntimeComponent = (() => {
8175
8248
  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" : "";
8176
8249
  error.message = `kernel-operation=${top}/${nested}: ${error.message}`;
8177
8250
  }
8251
+ const pending = readIndexPendingAnswer(request, error instanceof Error ? error.message : String(error));
8252
+ if (pending !== void 0) return pending;
8178
8253
  rethrowTypedKernelFailure(error);
8179
8254
  }
8180
8255
  if (response.requestId !== request.requestId) {
@@ -8185,6 +8260,9 @@ var NomosRuntimeComponent = (() => {
8185
8260
  this.#residency.after(request, response);
8186
8261
  const placementMoved = placementMovedBy(request, response);
8187
8262
  if (placementMoved !== void 0) this.#onPlacementMoved(placementMoved);
8263
+ if (response.outcome.case === "failure") {
8264
+ return readIndexPendingAnswer(request, response.outcome.value.message) ?? response;
8265
+ }
8188
8266
  return response;
8189
8267
  }
8190
8268
  /** [#call] with the opt-in timeline trace: encode, kernel and decode timed separately. */
@@ -14697,6 +14775,7 @@ var NomosRuntimeComponent = (() => {
14697
14775
  for (const [key, value] of entries.filter(([key2]) => key2 !== workspace)) this.#pending.set(key, value);
14698
14776
  }
14699
14777
  this.#revision += 1;
14778
+ if (read && (!existing?.read || isReadDemand)) this.#observer.readinessMayChange?.(workspace);
14700
14779
  if (!existing || existing.read?.cause !== read?.cause || existing.background?.cause !== background?.cause) {
14701
14780
  this.#trace.emit(session ?? existing?.session, {
14702
14781
  case: "maintenanceProgress",
@@ -14713,32 +14792,65 @@ var NomosRuntimeComponent = (() => {
14713
14792
  * (a waiting read's own turn advances read readiness only).
14714
14793
  */
14715
14794
  tick(request, sessionlessNotBeforeNanoseconds = 0n, backgroundNotBeforeNanoseconds = 0n, durability = true) {
14795
+ const turn = this.#turn(
14796
+ request,
14797
+ sessionlessNotBeforeNanoseconds,
14798
+ { case: "until", atNanoseconds: backgroundNotBeforeNanoseconds },
14799
+ durability
14800
+ );
14801
+ return turn.case === "ran" ? turn.ticked : create(MaintenanceTickedSchema, {
14802
+ pending: turn.pending,
14803
+ nextTickAfterMillis: turn.nextDelayMillis ?? 0
14804
+ });
14805
+ }
14806
+ /**
14807
+ * A waiting read's turn: advance read readiness only. It never runs a background command, closure
14808
+ * warm, pack import or durability flush on the foreground's turn, and never reports a wake for
14809
+ * that background work: with only background work owed its wake is `none`.
14810
+ */
14811
+ tickReadReadiness() {
14812
+ const turn = this.#turn(void 0, 0n, { case: "readReadinessOnly" }, false);
14813
+ if (turn.case === "ran") {
14814
+ return { ticked: turn.ticked, wake: { case: "after", millis: turn.ticked.nextTickAfterMillis } };
14815
+ }
14816
+ return {
14817
+ ticked: create(MaintenanceTickedSchema, { pending: turn.pending, nextTickAfterMillis: turn.nextDelayMillis ?? 0 }),
14818
+ wake: turn.nextDelayMillis === void 0 ? { case: "none" } : { case: "after", millis: turn.nextDelayMillis }
14819
+ };
14820
+ }
14821
+ #turn(request, sessionlessNotBeforeNanoseconds, backgroundHold, durability) {
14716
14822
  const now2 = this.#clock.monotonicNanoseconds();
14823
+ const backgroundNotBeforeNanoseconds = backgroundHold.case === "until" ? backgroundHold.atNanoseconds : void 0;
14717
14824
  const custodySlice = (workspace2) => this.#custodyBurstSlice(now2, workspace2);
14718
14825
  const due2 = (demand2) => {
14719
14826
  const held = demand2.session || demand2.awaited || demand2.retryNotBeforeNanoseconds > sessionlessNotBeforeNanoseconds ? demand2.retryNotBeforeNanoseconds : sessionlessNotBeforeNanoseconds;
14720
- const ordinary = demand2.read || demand2.awaited || held > backgroundNotBeforeNanoseconds ? held : backgroundNotBeforeNanoseconds;
14827
+ if (!demand2.read && !demand2.awaited && backgroundNotBeforeNanoseconds === void 0) return void 0;
14828
+ const ordinary = demand2.read || demand2.awaited || backgroundNotBeforeNanoseconds === void 0 || held > backgroundNotBeforeNanoseconds ? held : backgroundNotBeforeNanoseconds;
14721
14829
  const hold = demand2.read || demand2.awaited || !demand2.background?.maintainGitCustody ? void 0 : custodySlice(demand2.workspace);
14722
14830
  if (!hold) return ordinary;
14723
14831
  if (hold.slice && durability) return held > hold.at ? held : hold.at;
14724
14832
  return ordinary > hold.at ? ordinary : hold.at;
14725
14833
  };
14726
- const entry = [...this.#pending.entries()].find(([, demand2]) => due2(demand2) <= now2);
14834
+ const entry = [...this.#pending.entries()].find(([, demand2]) => {
14835
+ const at = due2(demand2);
14836
+ return at !== void 0 && at <= now2;
14837
+ });
14727
14838
  const flush = this.#flush;
14728
14839
  if (durability && flush && this.#flushDueAt(flush) <= now2 && !entry?.[1].read && (flush.local || !entry || flush.owedSinceNanoseconds + DURABILITY_FLUSH_MAX_DELAY_NANOSECONDS <= now2)) {
14729
- return this.#tickFlush(flush, request);
14840
+ return { case: "ran", ticked: this.#tickFlush(flush, request) };
14730
14841
  }
14731
14842
  const pinDue = (pin) => {
14843
+ if (backgroundNotBeforeNanoseconds === void 0) return void 0;
14732
14844
  const held = pin.session ? 0n : sessionlessNotBeforeNanoseconds;
14733
14845
  return [pin.notBeforeNanoseconds, held, backgroundNotBeforeNanoseconds].reduce((latest, at) => at > latest ? at : latest, 0n);
14734
14846
  };
14735
14847
  if (!entry) {
14736
- const pin = [...this.#pins.entries()].find(([, idle]) => pinDue(idle) <= now2);
14737
- if (pin) return this.#tickPin(pin[0], pin[1], request);
14738
- return create(MaintenanceTickedSchema, {
14739
- pending: this.hasPending(),
14740
- nextTickAfterMillis: this.#nextDelay(now2, due2, pinDue)
14848
+ const pin = [...this.#pins.entries()].find(([, idle]) => {
14849
+ const at = pinDue(idle);
14850
+ return at !== void 0 && at <= now2;
14741
14851
  });
14852
+ if (pin) return { case: "ran", ticked: this.#tickPin(pin[0], pin[1], request) };
14853
+ return { case: "idle", pending: this.hasPending(), nextDelayMillis: this.#nextDelay(now2, due2, pinDue, durability) };
14742
14854
  }
14743
14855
  const [workspace, demand] = entry;
14744
14856
  const mount = demand.session ? this.#sessions.mountForSession(demand.session) : this.#sessions.mountForWorkspace(workspace);
@@ -14787,7 +14899,7 @@ var NomosRuntimeComponent = (() => {
14787
14899
  read: read !== void 0,
14788
14900
  awaited: demand.awaited === true,
14789
14901
  session: demand.session !== void 0,
14790
- backgroundHoldMs: Number((backgroundNotBeforeNanoseconds - now2) / 1000000n),
14902
+ backgroundHoldMs: backgroundNotBeforeNanoseconds === void 0 ? "read-readiness-only" : Number((backgroundNotBeforeNanoseconds - now2) / 1000000n),
14791
14903
  sessionlessHoldMs: Number((sessionlessNotBeforeNanoseconds - now2) / 1000000n),
14792
14904
  caller: (new Error().stack ?? "").split("\n").slice(2, 6).map((frame2) => frame2.trim()).join(" < ")
14793
14905
  })}`);
@@ -14836,12 +14948,13 @@ var NomosRuntimeComponent = (() => {
14836
14948
  this.#observer.frontierAdvanced?.(workspace);
14837
14949
  }
14838
14950
  }
14839
- return create(MaintenanceTickedSchema, {
14951
+ this.#observer.readinessMayChange?.(workspace);
14952
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
14840
14953
  pending: this.#pending.size > 0,
14841
14954
  progress: observed,
14842
14955
  // With no debt left, an armed idle pin names when the host should wake next.
14843
- nextTickAfterMillis: progress.maintenancePending ? 20 : this.#pending.size === 0 && this.hasIdleWork() ? this.#nextDelay(this.#clock.monotonicNanoseconds()) : 0
14844
- });
14956
+ nextTickAfterMillis: progress.maintenancePending ? 20 : this.#pending.size === 0 && this.hasIdleWork() ? this.#nextDelay(this.#clock.monotonicNanoseconds()) ?? 0 : 0
14957
+ }) };
14845
14958
  } catch (error) {
14846
14959
  const format = localCopyFormatRefusal(error);
14847
14960
  if (format !== void 0) {
@@ -14857,10 +14970,10 @@ var NomosRuntimeComponent = (() => {
14857
14970
  stopped: true
14858
14971
  })
14859
14972
  });
14860
- return create(MaintenanceTickedSchema, {
14973
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
14861
14974
  pending: this.#pending.size > 0,
14862
- nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds())
14863
- });
14975
+ nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds()) ?? 0
14976
+ }) };
14864
14977
  }
14865
14978
  const failures = demand.failures + 1;
14866
14979
  this.#pending.delete(workspace);
@@ -14888,12 +15001,12 @@ var NomosRuntimeComponent = (() => {
14888
15001
  retryAfterMillis: retryMillis
14889
15002
  })
14890
15003
  });
14891
- return create(MaintenanceTickedSchema, {
15004
+ return { case: "ran", ticked: create(MaintenanceTickedSchema, {
14892
15005
  pending: true,
14893
15006
  // Backoff belongs to the failed workspace. Another workspace's ready
14894
15007
  // index or changed watches must not wait for this retry deadline.
14895
- nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds())
14896
- });
15008
+ nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds()) ?? 0
15009
+ }) };
14897
15010
  }
14898
15011
  }
14899
15012
  /** Owe the kernel its ordered flush. The first write it covers fixes `owedSince`; the shared
@@ -14958,7 +15071,7 @@ var NomosRuntimeComponent = (() => {
14958
15071
  }
14959
15072
  return create(MaintenanceTickedSchema, {
14960
15073
  pending: this.hasPending(),
14961
- nextTickAfterMillis: progress.maintenancePending ? 20 : this.#nextDelay(this.#clock.monotonicNanoseconds())
15074
+ nextTickAfterMillis: progress.maintenancePending ? 20 : this.#nextDelay(this.#clock.monotonicNanoseconds()) ?? 0
14962
15075
  });
14963
15076
  } catch (error) {
14964
15077
  const failures = flush.failures + 1;
@@ -14982,7 +15095,7 @@ var NomosRuntimeComponent = (() => {
14982
15095
  };
14983
15096
  return create(MaintenanceTickedSchema, {
14984
15097
  pending: this.hasPending(),
14985
- nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds())
15098
+ nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds()) ?? 0
14986
15099
  });
14987
15100
  }
14988
15101
  }
@@ -15013,7 +15126,7 @@ var NomosRuntimeComponent = (() => {
15013
15126
  }
15014
15127
  return create(MaintenanceTickedSchema, {
15015
15128
  pending: this.hasPending(),
15016
- nextTickAfterMillis: progress.maintenancePending ? 20 : this.#nextDelay(this.#clock.monotonicNanoseconds())
15129
+ nextTickAfterMillis: progress.maintenancePending ? 20 : this.#nextDelay(this.#clock.monotonicNanoseconds()) ?? 0
15017
15130
  });
15018
15131
  } catch (error) {
15019
15132
  slowQuantumObserver?.(`[nomos-kernel-perf] ${JSON.stringify({
@@ -15025,28 +15138,31 @@ var NomosRuntimeComponent = (() => {
15025
15138
  })}`);
15026
15139
  return create(MaintenanceTickedSchema, {
15027
15140
  pending: this.hasPending(),
15028
- nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds())
15141
+ nextTickAfterMillis: this.#nextDelay(this.#clock.monotonicNanoseconds()) ?? 0
15029
15142
  });
15030
15143
  }
15031
15144
  }
15032
- #nextDelay(now2, due2 = (demand) => demand.retryNotBeforeNanoseconds, pinDue = (pin) => pin.notBeforeNanoseconds) {
15145
+ /** Milliseconds until the earliest owed work this turn serves; `undefined` when none is owed. */
15146
+ #nextDelay(now2, due2 = (demand) => demand.retryNotBeforeNanoseconds, pinDue = (pin) => pin.notBeforeNanoseconds, flushes = true) {
15033
15147
  let earliest;
15034
15148
  for (const demand of this.#pending.values()) {
15035
15149
  const at = due2(demand);
15150
+ if (at === void 0) continue;
15036
15151
  if (at <= now2) return 0;
15037
15152
  if (earliest === void 0 || at < earliest) earliest = at;
15038
15153
  }
15039
15154
  for (const pin of this.#pins.values()) {
15040
15155
  const at = pinDue(pin);
15156
+ if (at === void 0) continue;
15041
15157
  if (at <= now2) return 0;
15042
15158
  if (earliest === void 0 || at < earliest) earliest = at;
15043
15159
  }
15044
- if (this.#flush) {
15160
+ if (flushes && this.#flush) {
15045
15161
  const at = this.#flushDueAt(this.#flush);
15046
15162
  if (at <= now2) return 0;
15047
15163
  if (earliest === void 0 || at < earliest) earliest = at;
15048
15164
  }
15049
- return earliest === void 0 ? 0 : Number((earliest - now2 + 999999n) / 1000000n);
15165
+ return earliest === void 0 ? void 0 : Number((earliest - now2 + 999999n) / 1000000n);
15050
15166
  }
15051
15167
  /** Drop any demand for a workspace no maintenance can serve (an unreadable copy). */
15052
15168
  forget(workspace) {
@@ -15086,15 +15202,19 @@ var NomosRuntimeComponent = (() => {
15086
15202
  };
15087
15203
 
15088
15204
  // ../src/runtime/read_response_desk.ts
15205
+ var READ_RETENTION_MILLIS = 12e4;
15206
+ var READ_RESUME_MAX_MILLIS = 1e3;
15089
15207
  var ReadResponseDesk = class {
15090
15208
  #waiting = /* @__PURE__ */ new Map();
15091
15209
  #clock;
15092
15210
  #tick;
15211
+ #owe;
15093
15212
  #read;
15094
15213
  #sequence = 0;
15095
- constructor(clock2, tick, read) {
15214
+ constructor(clock2, tick, owe, read) {
15096
15215
  this.#clock = clock2;
15097
15216
  this.#tick = tick;
15217
+ this.#owe = owe;
15098
15218
  this.#read = read;
15099
15219
  }
15100
15220
  #now() {
@@ -15107,18 +15227,27 @@ var NomosRuntimeComponent = (() => {
15107
15227
  const now2 = this.#now();
15108
15228
  for (const [id, work] of this.#waiting) if (work.deadline <= now2) this.#waiting.delete(id);
15109
15229
  const workId2 = `local-read-${++this.#sequence}`;
15110
- this.#waiting.set(workId2, { request, dependency, deadline: now2 + 12e4, notBefore: now2 });
15230
+ this.#waiting.set(workId2, {
15231
+ request,
15232
+ dependency,
15233
+ deadline: now2 + READ_RETENTION_MILLIS,
15234
+ notBefore: now2,
15235
+ idle: false,
15236
+ // The office owed this frontier's debt when the kernel first answered pending.
15237
+ owedFor: dependency.requestedFrontier,
15238
+ waiters: /* @__PURE__ */ new Set()
15239
+ });
15111
15240
  return create(LocalReadPendingSchema, { workId: workId2 });
15112
15241
  }
15113
15242
  resume(workId2, requestId) {
15114
15243
  const work = this.#waiting.get(workId2);
15115
15244
  if (!work || work.request.requestId !== requestId) throw new Error(`unknown local read continuation '${workId2}'`);
15116
15245
  const now2 = this.#now();
15246
+ work.waiters.clear();
15117
15247
  if (now2 >= work.deadline) {
15118
15248
  this.#waiting.delete(workId2);
15119
15249
  throw new Error(`Local read index for '${work.dependency.workspace}' did not catch up to ${work.dependency.requestedFrontier} within its retained maintenance window`);
15120
15250
  }
15121
- if (now2 < work.notBefore) return this.#pending(workId2, work, now2);
15122
15251
  try {
15123
15252
  const response = this.#read(work.request);
15124
15253
  if (response.outcome.case !== "query" || response.outcome.value.result.case !== "readIndexPending") {
@@ -15126,24 +15255,65 @@ var NomosRuntimeComponent = (() => {
15126
15255
  return { case: "ready", request: work.request, response };
15127
15256
  }
15128
15257
  work.dependency = response.outcome.value.result.value;
15129
- const tick = this.#tick();
15258
+ if (now2 < work.notBefore) return this.#pending(workId2, work, now2);
15259
+ let { ticked, wake } = this.#tick();
15260
+ if (wake.case === "none" && ticked.progress === void 0 && work.owedFor !== work.dependency.requestedFrontier) {
15261
+ work.owedFor = work.dependency.requestedFrontier;
15262
+ this.#owe(work.request);
15263
+ ({ ticked, wake } = this.#tick());
15264
+ }
15130
15265
  const afterTick = this.#now();
15131
- work.notBefore = afterTick + tick.nextTickAfterMillis;
15132
- work.deadline = afterTick + Math.max(12e4, tick.nextTickAfterMillis + 6e4);
15266
+ work.idle = wake.case === "none";
15267
+ const backoff = wake.case === "after" ? wake.millis : 0;
15268
+ work.notBefore = afterTick + backoff;
15269
+ work.deadline = afterTick + Math.max(READ_RETENTION_MILLIS, backoff + 6e4);
15133
15270
  return this.#pending(workId2, work, afterTick);
15134
15271
  } catch (error) {
15135
15272
  this.#waiting.delete(workId2);
15136
15273
  throw error;
15137
15274
  }
15138
15275
  }
15276
+ /**
15277
+ * Wait in process for a held read to become worth continuing. `notify` is called once, when read
15278
+ * readiness for its workspace changes (a slice or binding finished, a frontier advanced, readiness
15279
+ * newly owed). `afterMillis` is the only timer the shell needs: the read's own scheduled quantum
15280
+ * when it has one, otherwise its deadline. Undefined for an unknown or finished read.
15281
+ */
15282
+ onResumable(workId2, notify) {
15283
+ const work = this.#waiting.get(workId2);
15284
+ if (!work) return void 0;
15285
+ const now2 = this.#now();
15286
+ const due2 = work.idle ? work.deadline : Math.min(work.notBefore, work.deadline);
15287
+ work.waiters.add(notify);
15288
+ return { afterMillis: Math.max(0, due2 - now2), cancel: () => {
15289
+ work.waiters.delete(notify);
15290
+ } };
15291
+ }
15292
+ /** Read readiness for `workspace` changed: every read waiting on it may continue now. */
15293
+ readinessChanged(workspace) {
15294
+ const now2 = this.#now();
15295
+ for (const work of this.#waiting.values()) {
15296
+ if (work.dependency.workspace !== workspace) continue;
15297
+ work.idle = false;
15298
+ if (work.notBefore > now2) work.notBefore = now2;
15299
+ const waiters = [...work.waiters];
15300
+ work.waiters.clear();
15301
+ for (const notify of waiters) notify();
15302
+ }
15303
+ }
15304
+ /** The protocol wake is a bounded re-poll inside the read's retention deadline, never the raw backoff. */
15139
15305
  #pending(workId2, work, now2) {
15306
+ const due2 = work.idle ? READ_RESUME_MAX_MILLIS : work.notBefore - now2;
15307
+ const resumeAfterMillis = Math.max(0, Math.min(due2, work.deadline - now2, READ_RESUME_MAX_MILLIS));
15140
15308
  return { case: "pending", value: create(LocalReadPendingSchema, {
15141
15309
  workId: workId2,
15142
- resumeAfterMillis: Math.max(0, work.notBefore - now2)
15310
+ resumeAfterMillis: Number.isFinite(resumeAfterMillis) ? Math.ceil(resumeAfterMillis) : READ_RESUME_MAX_MILLIS
15143
15311
  }) };
15144
15312
  }
15145
15313
  clear() {
15314
+ const waiters = [...this.#waiting.values()].flatMap((work) => [...work.waiters]);
15146
15315
  this.#waiting.clear();
15316
+ for (const notify of waiters) notify();
15147
15317
  }
15148
15318
  };
15149
15319
 
@@ -16055,13 +16225,15 @@ var NomosRuntimeComponent = (() => {
16055
16225
  DependencyAdvanced: "dependency_advanced",
16056
16226
  RebornRemotely: "reborn_remotely",
16057
16227
  LocalCopyDropAuthorized: "local_copy_drop_authorized",
16058
- LocalCopyUnreadable: "local_copy_unreadable"
16228
+ LocalCopyUnreadable: "local_copy_unreadable",
16229
+ RuntimeStarted: "runtime_started"
16059
16230
  });
16060
16231
  var ReplicaFollowEffectKind = Object.freeze({
16061
16232
  ScheduleWake: "schedule_wake",
16062
16233
  RunSync: "run_sync",
16063
16234
  RefreshCredential: "refresh_credential"
16064
16235
  });
16236
+ var KERNEL_REFUSAL_EVENT_FLOOR_MILLIS = 1e4;
16065
16237
  var boundedRetry = (policy, attempt) => Math.min(policy.fallbackMillis, Math.max(250, policy.debounceMillis) * 2 ** Math.min(attempt - 1, 20));
16066
16238
  var attempts = (state) => {
16067
16239
  switch (state.case) {
@@ -16088,13 +16260,14 @@ var NomosRuntimeComponent = (() => {
16088
16260
  state: { case: ReplicaFollowPhase.Due, dueAtUnixMillis: atUnixMillis },
16089
16261
  effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis }]
16090
16262
  });
16091
- var run = (attempt, replaceLocalHead, warmingSinceUnixMillis) => ({
16263
+ var run = (attempt, replaceLocalHead, warmingSinceUnixMillis, refused) => ({
16092
16264
  state: {
16093
16265
  case: ReplicaFollowPhase.Running,
16094
16266
  attempt,
16095
16267
  observed: false,
16096
16268
  ...replaceLocalHead === void 0 ? {} : { replaceLocalHead },
16097
- ...warmingSinceUnixMillis === void 0 ? {} : { warmingSinceUnixMillis }
16269
+ ...warmingSinceUnixMillis === void 0 ? {} : { warmingSinceUnixMillis },
16270
+ ...refused === void 0 ? {} : { refused }
16098
16271
  },
16099
16272
  effects: [{ case: ReplicaFollowEffectKind.RunSync }]
16100
16273
  });
@@ -16103,6 +16276,16 @@ var NomosRuntimeComponent = (() => {
16103
16276
  effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis }]
16104
16277
  });
16105
16278
  var quiet = (state) => ({ state, effects: [] });
16279
+ var blockedRefusal = (state) => state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked ? state.refusal : void 0;
16280
+ var refusedEvent = (state, refusal2, nowUnixMillis) => {
16281
+ const earliest = Math.max(nowUnixMillis, refusal2.atUnixMillis + KERNEL_REFUSAL_EVENT_FLOOR_MILLIS);
16282
+ const rerunAtUnixMillis = refusal2.rerunAtUnixMillis === void 0 ? earliest : Math.min(refusal2.rerunAtUnixMillis, earliest);
16283
+ return {
16284
+ state: { ...state, refusal: { ...refusal2, rerunAtUnixMillis } },
16285
+ effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: rerunAtUnixMillis }]
16286
+ };
16287
+ };
16288
+ var refusedByKernel = (state) => state.case === ReplicaFollowPhase.Backoff && (state.refusal !== void 0 || deterministicKernelRefusal(state.failure) !== void 0);
16106
16289
  function reduceReplicaFollow(state, event, policy) {
16107
16290
  switch (event.case) {
16108
16291
  case ReplicaFollowEventKind.Activate:
@@ -16115,6 +16298,9 @@ var NomosRuntimeComponent = (() => {
16115
16298
  if (state.case === ReplicaFollowPhase.Running) {
16116
16299
  return { state: { ...state, observed: true }, effects: [] };
16117
16300
  }
16301
+ if (state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked) {
16302
+ return refusedEvent(state, state.refusal, event.nowUnixMillis);
16303
+ }
16118
16304
  if (state.case === ReplicaFollowPhase.RebornRemotely || state.case === ReplicaFollowPhase.LocalCopyUnreadable) return quiet(state);
16119
16305
  if (state.case === ReplicaFollowPhase.InvalidCredential) {
16120
16306
  return {
@@ -16124,6 +16310,9 @@ var NomosRuntimeComponent = (() => {
16124
16310
  }
16125
16311
  return due(event.nowUnixMillis);
16126
16312
  case ReplicaFollowEventKind.Reconnected:
16313
+ if (state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked) {
16314
+ return refusedEvent(state, state.refusal, event.nowUnixMillis);
16315
+ }
16127
16316
  switch (state.case) {
16128
16317
  case ReplicaFollowPhase.Running:
16129
16318
  return { state: { ...state, observed: true }, effects: [] };
@@ -16169,15 +16358,25 @@ var NomosRuntimeComponent = (() => {
16169
16358
  }
16170
16359
  return run(state.attempt + 1, state.expectedLocalHead);
16171
16360
  case ReplicaFollowPhase.Offline:
16172
- case ReplicaFollowPhase.Backoff:
16361
+ case ReplicaFollowPhase.Backoff: {
16362
+ const blocked = blockedRefusal(state);
16363
+ if (blocked) {
16364
+ if (blocked.rerunAtUnixMillis === void 0) return quiet(state);
16365
+ if (event.nowUnixMillis < blocked.rerunAtUnixMillis) {
16366
+ return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: blocked.rerunAtUnixMillis }] };
16367
+ }
16368
+ return run(state.attempt + 1, void 0, void 0, state.failure);
16369
+ }
16173
16370
  if (event.nowUnixMillis < state.retryAtUnixMillis) {
16174
16371
  return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: state.retryAtUnixMillis }] };
16175
16372
  }
16176
16373
  return run(
16177
16374
  state.attempt + 1,
16178
16375
  void 0,
16179
- state.case === ReplicaFollowPhase.Backoff ? state.warming?.sinceUnixMillis : void 0
16376
+ state.case === ReplicaFollowPhase.Backoff ? state.warming?.sinceUnixMillis : void 0,
16377
+ state.case === ReplicaFollowPhase.Backoff && state.refusal ? state.failure : void 0
16180
16378
  );
16379
+ }
16181
16380
  case ReplicaFollowPhase.InvalidCredential:
16182
16381
  if (!state.refreshDue && event.nowUnixMillis < state.retryAtUnixMillis) {
16183
16382
  return { state, effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: state.retryAtUnixMillis }] };
@@ -16254,6 +16453,31 @@ var NomosRuntimeComponent = (() => {
16254
16453
  };
16255
16454
  }
16256
16455
  case ReplicaFollowEventKind.Failed: {
16456
+ if (event.refusal && !(state.case === ReplicaFollowPhase.Running && state.replaceLocalHead !== void 0)) {
16457
+ const attempt2 = Math.max(1, attempts(state));
16458
+ const blocked = state.case === ReplicaFollowPhase.Running && state.refused === event.failure || state.case === ReplicaFollowPhase.Backoff && state.refusal !== void 0 && state.failure === event.failure;
16459
+ const refusal2 = {
16460
+ code: event.refusal.code,
16461
+ blocked,
16462
+ runtime: event.refusal.runtime,
16463
+ atUnixMillis: event.nowUnixMillis
16464
+ };
16465
+ if (!blocked) {
16466
+ const retryAtUnixMillis2 = event.nowUnixMillis + boundedRetry(policy, attempt2);
16467
+ return {
16468
+ state: { case: ReplicaFollowPhase.Backoff, attempt: attempt2, retryAtUnixMillis: retryAtUnixMillis2, failure: event.failure, refusal: refusal2 },
16469
+ effects: [{ case: ReplicaFollowEffectKind.ScheduleWake, atUnixMillis: retryAtUnixMillis2 }]
16470
+ };
16471
+ }
16472
+ const waiting = {
16473
+ case: ReplicaFollowPhase.Backoff,
16474
+ attempt: attempt2,
16475
+ retryAtUnixMillis: event.nowUnixMillis,
16476
+ failure: event.failure,
16477
+ refusal: refusal2
16478
+ };
16479
+ return state.case === ReplicaFollowPhase.Running && state.observed ? refusedEvent(waiting, refusal2, event.nowUnixMillis) : quiet(waiting);
16480
+ }
16257
16481
  if (state.case === ReplicaFollowPhase.Running && state.observed) {
16258
16482
  return due(event.nowUnixMillis);
16259
16483
  }
@@ -16291,6 +16515,11 @@ var NomosRuntimeComponent = (() => {
16291
16515
  return quiet({ case: ReplicaFollowPhase.RebornRemotely, rebirth: event.rebirth });
16292
16516
  case ReplicaFollowEventKind.LocalCopyUnreadable:
16293
16517
  return quiet({ case: ReplicaFollowPhase.LocalCopyUnreadable, format: event.format });
16518
+ case ReplicaFollowEventKind.RuntimeStarted:
16519
+ if (state.case === ReplicaFollowPhase.Backoff && refusedByKernel(state) && state.refusal?.runtime !== event.runtime) {
16520
+ return due(event.nowUnixMillis);
16521
+ }
16522
+ return quiet(state);
16294
16523
  case ReplicaFollowEventKind.LocalCopyDropAuthorized:
16295
16524
  if (state.case === ReplicaFollowPhase.Running) return invalid(state, event);
16296
16525
  return replacing(event.expectedLocalHead, 0, event.nowUnixMillis);
@@ -16337,11 +16566,15 @@ var NomosRuntimeComponent = (() => {
16337
16566
  #replicaId;
16338
16567
  /** Local children whose births custody refused (CAP-804): quarantined, never followed. */
16339
16568
  #birthRefusals;
16340
- constructor(desk, clock2, replicaId, birthRefusals) {
16569
+ /** The kernel/runtime identity this process runs: a refusal is recorded under it, and a refusal
16570
+ * drawn under another identity is retried once when this process starts. */
16571
+ #runtime;
16572
+ constructor(desk, clock2, replicaId, birthRefusals, runtime = "unidentified") {
16341
16573
  this.#desk = desk;
16342
16574
  this.#clock = clock2;
16343
16575
  this.#replicaId = replicaId;
16344
16576
  this.#birthRefusals = birthRefusals ?? new BirthRefusalRegister(new MemoryPeerDeskStore());
16577
+ this.#runtime = runtime;
16345
16578
  }
16346
16579
  /** The durable quarantine of a local child whose birth custody refused; undefined otherwise. */
16347
16580
  birthRefusal(workspace) {
@@ -16440,6 +16673,13 @@ var NomosRuntimeComponent = (() => {
16440
16673
  recover() {
16441
16674
  const now2 = this.#now();
16442
16675
  if (!this.#recovered) {
16676
+ for (const follow of this.#desk.all()) {
16677
+ this.#desk.transition(follow.spec.workspace, {
16678
+ case: ReplicaFollowEventKind.RuntimeStarted,
16679
+ nowUnixMillis: now2,
16680
+ runtime: this.#runtime
16681
+ });
16682
+ }
16443
16683
  for (const follow of this.#desk.all()) {
16444
16684
  if (follow.state.case === ReplicaFollowPhase.Settled || follow.state.case === ReplicaFollowPhase.AwaitingDependency) {
16445
16685
  this.#placementRecheck.add(follow.spec.workspace);
@@ -16528,11 +16768,12 @@ var NomosRuntimeComponent = (() => {
16528
16768
  placementAnnounced(workspace) {
16529
16769
  if (!this.followForWorkspace(workspace)) return void 0;
16530
16770
  this.#placementRecheck.add(workspace);
16531
- return this.reconnected(workspace);
16771
+ return this.reconnected(workspace, true);
16532
16772
  }
16533
- /** The upstream live link opened or reopened: reconcile once for missed pushes. */
16534
- reconnected(workspace) {
16535
- return this.#event(workspace, ReplicaFollowEventKind.Reconnected);
16773
+ /** The upstream live link opened or reopened: reconcile once for missed pushes. With
16774
+ * `remoteAdvanced`, the upstream announced a new frontier. Either re-runs a blocked refusal. */
16775
+ reconnected(workspace, remoteAdvanced = false) {
16776
+ return this.#event(workspace, ReplicaFollowEventKind.Reconnected, remoteAdvanced);
16536
16777
  }
16537
16778
  /** Another workspace advanced or settled; every held dependency gets one retry. */
16538
16779
  dependencyAdvanced(except) {
@@ -16545,11 +16786,11 @@ var NomosRuntimeComponent = (() => {
16545
16786
  }
16546
16787
  return woken;
16547
16788
  }
16548
- #event(workspace, kind) {
16789
+ #event(workspace, kind, remoteAdvanced = false) {
16549
16790
  const follow = this.#recovered ? this.#desk.get(workspace) : void 0;
16550
16791
  if (!follow) return void 0;
16551
16792
  const nowUnixMillis = this.#now();
16552
- this.#desk.transition(workspace, { case: kind, nowUnixMillis });
16793
+ this.#desk.transition(workspace, kind === ReplicaFollowEventKind.Reconnected && remoteAdvanced ? { case: kind, nowUnixMillis, remoteAdvanced } : { case: kind, nowUnixMillis });
16553
16794
  const nextDueAt = dueAt(this.#desk.get(workspace));
16554
16795
  return nextDueAt === void 0 ? void 0 : Math.max(0, nextDueAt - nowUnixMillis);
16555
16796
  }
@@ -16696,7 +16937,9 @@ var NomosRuntimeComponent = (() => {
16696
16937
  * still opening the workspace and named when to ask again. */
16697
16938
  failed(workspace, error, custodianRetryAfterMillis) {
16698
16939
  if (!this.#recovered) this.recover();
16699
- custodianRetryAfterMillis ??= warmingFromFailureMessage(error instanceof Error ? error.message : String(error));
16940
+ const refusal2 = deterministicKernelRefusal(error);
16941
+ if (refusal2 !== void 0) custodianRetryAfterMillis = void 0;
16942
+ else custodianRetryAfterMillis ??= warmingFromFailureMessage(error instanceof Error ? error.message : String(error));
16700
16943
  if (!this.#desk.get(workspace)) return;
16701
16944
  const format = localCopyFormatRefusal(error);
16702
16945
  if (format !== void 0) {
@@ -16711,9 +16954,15 @@ var NomosRuntimeComponent = (() => {
16711
16954
  case: ReplicaFollowEventKind.Failed,
16712
16955
  nowUnixMillis: this.#now(),
16713
16956
  failure: error instanceof Error ? error.message : String(error),
16714
- ...custodianRetryAfterMillis === void 0 ? {} : { custodianRetryAfterMillis }
16957
+ ...custodianRetryAfterMillis === void 0 ? {} : { custodianRetryAfterMillis },
16958
+ ...refusal2 === void 0 ? {} : { refusal: { code: refusal2.code, runtime: this.#runtime } }
16715
16959
  });
16716
16960
  }
16961
+ /** The kernel refusal behind this follow's backoff (`blocked` once the kernel repeated it). */
16962
+ refusal(workspace) {
16963
+ const state = this.followForWorkspace(workspace)?.state;
16964
+ return state?.case === ReplicaFollowPhase.Backoff ? state.refusal : void 0;
16965
+ }
16717
16966
  /** Closing an interaction realm must not erase a peer-owned follow. */
16718
16967
  closeInteractionRealm() {
16719
16968
  }
@@ -16746,9 +16995,12 @@ var NomosRuntimeComponent = (() => {
16746
16995
  case ReplicaFollowPhase.RebornRemotely:
16747
16996
  case ReplicaFollowPhase.LocalCopyUnreadable:
16748
16997
  return void 0;
16998
+ case ReplicaFollowPhase.Backoff: {
16999
+ const blocked = blockedRefusal(follow.state);
17000
+ return blocked ? blocked.rerunAtUnixMillis : follow.state.retryAtUnixMillis;
17001
+ }
16749
17002
  case ReplicaFollowPhase.Offline:
16750
17003
  case ReplicaFollowPhase.InvalidCredential:
16751
- case ReplicaFollowPhase.Backoff:
16752
17004
  return follow.state.retryAtUnixMillis;
16753
17005
  default: {
16754
17006
  const exhaustive = follow.state;
@@ -16764,6 +17016,9 @@ var NomosRuntimeComponent = (() => {
16764
17016
  return nextDueAt === void 0 ? void 0 : Math.max(0, nextDueAt - nowUnixMillis);
16765
17017
  }
16766
17018
 
17019
+ // ../src/runtime/runtime_identity.ts
17020
+ var PEER_RUNTIME_IDENTITY = "0.116.4" ? `@githolon/runtime@${"0.116.4"}` : "@githolon/runtime@unbundled";
17021
+
16767
17022
  // ../src/runtime/replica_follow_desk.ts
16768
17023
  var REPLICA_FOLLOW_NAMESPACE = "nomos.peer-desk.replica-follow/v2";
16769
17024
  var textEncoder = new TextEncoder();
@@ -16791,6 +17046,16 @@ var NomosRuntimeComponent = (() => {
16791
17046
  ...Number.isFinite(warming.hintMillis) ? { hintMillis: warming.hintMillis } : {}
16792
17047
  } } : {};
16793
17048
  };
17049
+ var decodeRefusal = (value) => {
17050
+ const refusal2 = value;
17051
+ return refusal2 && typeof refusal2.code === "string" && typeof refusal2.runtime === "string" && Number.isFinite(refusal2.atUnixMillis) ? { refusal: {
17052
+ code: refusal2.code,
17053
+ blocked: refusal2.blocked === true,
17054
+ runtime: refusal2.runtime,
17055
+ atUnixMillis: refusal2.atUnixMillis,
17056
+ ...Number.isFinite(refusal2.rerunAtUnixMillis) ? { rerunAtUnixMillis: refusal2.rerunAtUnixMillis } : {}
17057
+ } } : {};
17058
+ };
16794
17059
  var decodeState = (record, value) => {
16795
17060
  if (!value || typeof value !== "object") throw corrupt(record, "state is not an object");
16796
17061
  const state = value;
@@ -16805,7 +17070,8 @@ var NomosRuntimeComponent = (() => {
16805
17070
  attempt: state.attempt,
16806
17071
  observed: state.observed === true,
16807
17072
  ...state.replaceLocalHead === void 0 ? {} : { replaceLocalHead: state.replaceLocalHead },
16808
- ...Number.isFinite(state.warmingSinceUnixMillis) ? { warmingSinceUnixMillis: state.warmingSinceUnixMillis } : {}
17073
+ ...Number.isFinite(state.warmingSinceUnixMillis) ? { warmingSinceUnixMillis: state.warmingSinceUnixMillis } : {},
17074
+ ...typeof state.refused === "string" ? { refused: state.refused } : {}
16809
17075
  };
16810
17076
  case ReplicaFollowPhase.Settled:
16811
17077
  return {
@@ -16837,7 +17103,8 @@ var NomosRuntimeComponent = (() => {
16837
17103
  attempt: state.attempt,
16838
17104
  retryAtUnixMillis: state.retryAtUnixMillis,
16839
17105
  failure: state.failure,
16840
- ...decodeWarming(state.warming)
17106
+ ...decodeWarming(state.warming),
17107
+ ...decodeRefusal(state.refusal)
16841
17108
  };
16842
17109
  case ReplicaFollowPhase.RebornRemotely: {
16843
17110
  const rebirth = state.rebirth ?? {};
@@ -17027,9 +17294,15 @@ var NomosRuntimeComponent = (() => {
17027
17294
  break;
17028
17295
  }
17029
17296
  case ReplicaFollowPhase.Offline:
17030
- case ReplicaFollowPhase.Backoff:
17031
- wakes.push({ workspace: follow.spec.workspace, atUnixMillis: follow.state.retryAtUnixMillis });
17297
+ case ReplicaFollowPhase.Backoff: {
17298
+ const blocked = blockedRefusal(follow.state);
17299
+ if (blocked && blocked.rerunAtUnixMillis === void 0) break;
17300
+ wakes.push({
17301
+ workspace: follow.spec.workspace,
17302
+ atUnixMillis: blocked?.rerunAtUnixMillis ?? follow.state.retryAtUnixMillis
17303
+ });
17032
17304
  break;
17305
+ }
17033
17306
  case ReplicaFollowPhase.InvalidCredential:
17034
17307
  wakes.push({
17035
17308
  workspace: follow.spec.workspace,
@@ -17654,6 +17927,8 @@ var NomosRuntimeComponent = (() => {
17654
17927
  message,
17655
17928
  ...retryAfterMillis === void 0 ? {} : { retryAfterMillis }
17656
17929
  }) });
17930
+ var OFF_MAIN_AFTER_MILLIS = 6e4;
17931
+ var MAX_UNFOUND_HEADS = 1024;
17657
17932
  var LiveStreamServer = class {
17658
17933
  #kernel;
17659
17934
  #now;
@@ -17667,6 +17942,10 @@ var NomosRuntimeComponent = (() => {
17667
17942
  /** By workspace: the history slices copies are fetching (a few, newest last). */
17668
17943
  #slices = /* @__PURE__ */ new Map();
17669
17944
  #cachedBytes = 0;
17945
+ /** By workspace and asked head: when this peer first answered "acquiring its own history" to a level
17946
+ * ask from a head it could not find. A shallow custody can never prove the head is off its main (its
17947
+ * walk is never `complete`), so after OFF_MAIN_AFTER_MILLIS of the same answer it says so anyway. */
17948
+ #unfound = /* @__PURE__ */ new Map();
17670
17949
  constructor(kernel, now2 = Date.now, historyWanted = () => {
17671
17950
  }, sealed = () => void 0) {
17672
17951
  this.#kernel = kernel;
@@ -17714,9 +17993,12 @@ var NomosRuntimeComponent = (() => {
17714
17993
  if (!head) return [...answer, ...this.#checkpoint(workspace, requestId, create(LiveCheckpointRequestSchema))];
17715
17994
  if (head === main) return answer;
17716
17995
  let behind;
17996
+ let offMain = false;
17717
17997
  try {
17718
17998
  const summary = this.#kernel.historySummary(mount, requestId, head, main);
17719
17999
  behind = summary.reachedBase ? summary.commitCount : void 0;
18000
+ offMain = !summary.reachedBase && (summary.complete || !this.#shallow(mount, requestId));
18001
+ if (summary.reachedBase) this.#unfound.delete(`${workspace}\0${head}`);
17720
18002
  } catch {
17721
18003
  behind = void 0;
17722
18004
  }
@@ -17725,6 +18007,22 @@ var NomosRuntimeComponent = (() => {
17725
18007
  if (remountAfter > 0) {
17726
18008
  return [...answer, ...this.#checkpoint(workspace, requestId, create(LiveCheckpointRequestSchema), behind ?? 0n)];
17727
18009
  }
18010
+ const key = `${workspace}\0${head}`;
18011
+ const firstUnfound = this.#unfound.get(key);
18012
+ if (!offMain && firstUnfound === void 0) {
18013
+ if (this.#unfound.size >= MAX_UNFOUND_HEADS) this.#unfound.delete(this.#unfound.keys().next().value);
18014
+ this.#unfound.set(key, this.#now());
18015
+ } else if (!offMain && this.#now() - firstUnfound >= OFF_MAIN_AFTER_MILLIS) {
18016
+ offMain = true;
18017
+ }
18018
+ if (offMain) {
18019
+ this.#unfound.delete(key);
18020
+ return [...answer, refusal(
18021
+ "",
18022
+ "nomos.stream.off_main",
18023
+ "the copy's head is not on this peer's main; it must converge its own work, not level from it"
18024
+ )];
18025
+ }
17728
18026
  this.#historyWanted(workspace);
17729
18027
  return [...answer, refusal(
17730
18028
  "",
@@ -17736,6 +18034,17 @@ var NomosRuntimeComponent = (() => {
17736
18034
  const maxOffers = Math.min(Math.max(1, frontier.maxOffers || MAX_STREAM_BATCH_OFFERS), MAX_STREAM_BATCH_OFFERS);
17737
18035
  return [...answer, this.#batch(workspace, requestId, head, main, maxOffers)];
17738
18036
  }
18037
+ /** Whether this peer's custody of the workspace is shallow. Unknown counts as shallow: it keeps the
18038
+ * existing wait for history rather than calling a head off main. */
18039
+ #shallow(mount, requestId) {
18040
+ const boundaries = this.#kernel.shallowBoundaries;
18041
+ if (!boundaries) return true;
18042
+ try {
18043
+ return boundaries.call(this.#kernel, mount, requestId).length > 0;
18044
+ } catch {
18045
+ return true;
18046
+ }
18047
+ }
17739
18048
  /**
17740
18049
  * The `maxOffers` offers directly above `base`, as the commits this peer admitted them in: one
17741
18050
  * bounded walk and one bounded pack (O(batch)). The copy's kernel adopts exactly these commits on
@@ -18102,7 +18411,6 @@ var NomosRuntimeComponent = (() => {
18102
18411
  };
18103
18412
  var LiveCorrespondenceDesk = class {
18104
18413
  #links = /* @__PURE__ */ new Map();
18105
- #pending = /* @__PURE__ */ new Map();
18106
18414
  /** What procedures asked of each workspace's stream, and what it delivered (peer_catchup.md). */
18107
18415
  inbound;
18108
18416
  #own = new OwnOffers();
@@ -18138,13 +18446,6 @@ var NomosRuntimeComponent = (() => {
18138
18446
  * never held. Absent (a custodian, a relay, a test), every write goes out on the next drive.
18139
18447
  */
18140
18448
  writeBurst;
18141
- /**
18142
- * An application peer's receive step (CAP-757; sized by time, CAP-762). A received batch of other
18143
- * senders' offers larger than one step is not admitted on the socket, in one kernel-thread hold:
18144
- * the follow receives it instead, in yielding steps of the policy's current size. Absent (a
18145
- * custodian, a relay, a test), every received batch is admitted as it arrives.
18146
- */
18147
- receiveStep;
18148
18449
  /** The last progress counted per workspace, served while a burst holds recounting back. */
18149
18450
  #progress = /* @__PURE__ */ new Map();
18150
18451
  /** When a held-back progress recount became owed; it reports at the burst's next due point. */
@@ -18234,10 +18535,12 @@ var NomosRuntimeComponent = (() => {
18234
18535
  sent: link.stream?.sent,
18235
18536
  unansweredAgesMs: (link.stream?.unanswered ?? []).map((entry) => Number((now2 - (entry.due - LIVE_ANSWER_WINDOW)) / 1000000n)),
18236
18537
  custodianLocal: link.custodian?.local,
18237
- convergeDue: link.convergeDue !== void 0
18538
+ convergeDue: link.convergeDue !== void 0,
18539
+ resident: false
18238
18540
  };
18239
18541
  try {
18240
18542
  if (this.kernel.isResident(link.binding.workspace) !== false) {
18543
+ state.resident = true;
18241
18544
  const mount = workspaceMount(link.binding.workspace);
18242
18545
  state.head = this.kernel.head(mount, ++this.#requestId);
18243
18546
  state.tracked = this.kernel.resolveRef(mount, ++this.#requestId, TRACKED_MAIN2);
@@ -18306,7 +18609,7 @@ var NomosRuntimeComponent = (() => {
18306
18609
  }
18307
18610
  #count(link, mount) {
18308
18611
  const head = this.kernel.head(mount, ++this.#requestId);
18309
- const acknowledged = this.#cursor(link, mount)?.local ?? this.kernel.resolveRef(mount, ++this.#requestId, TRACKED_MAIN2);
18612
+ const acknowledged = this.#cursor(link, mount)?.local ?? this.#heldPeerMain(link, mount, head) ?? this.kernel.resolveRef(mount, ++this.#requestId, TRACKED_MAIN2);
18310
18613
  if (!head || !acknowledged) return void 0;
18311
18614
  const count = (base, tip) => {
18312
18615
  if (base === tip) return 0;
@@ -18340,6 +18643,14 @@ var NomosRuntimeComponent = (() => {
18340
18643
  #holds(mount, base, tip) {
18341
18644
  return this.#chain(mount, base, tip)?.reachedBase === true;
18342
18645
  }
18646
+ /** The custodian's main as last heard, when this copy holds it on its own head's chain above the
18647
+ * sealed bookmark: the commits up to it came from the stream and are the custodian's (CAP-838). */
18648
+ #heldPeerMain(link, mount, head, tracked = this.kernel.resolveRef(mount, ++this.#requestId, TRACKED_MAIN2)) {
18649
+ const main = link.peerMain;
18650
+ if (!main || !head || main === tracked) return void 0;
18651
+ if (tracked && !this.#holds(mount, tracked, main)) return void 0;
18652
+ return this.#holds(mount, main, head) ? main : void 0;
18653
+ }
18343
18654
  /** This connection's admission cursor, while it still leads the saved bookmark. A cursor on local
18344
18655
  * history (admitted, not yet sealed) remembers the bookmark it was set above; once anything else
18345
18656
  * moves the bookmark (a follow round adopting the custodian's main) the bookmark rules again, so
@@ -18416,7 +18727,7 @@ var NomosRuntimeComponent = (() => {
18416
18727
  evidencePack: options.carryCommits || intents.some((intent) => intent.transportRequirement === IntentTransportRequirement.COMMIT_TREE) ? this.kernel.packDelta(mount, requestId, batchHead, base) : new Uint8Array()
18417
18728
  });
18418
18729
  }
18419
- receive(request, receipt) {
18730
+ receive(receipt) {
18420
18731
  const link = [...this.#links.values()].find((item) => item.id === receipt.connectionId);
18421
18732
  if (!link) return;
18422
18733
  if (receipt.observation.case === "closed" || receipt.observation.case === "closure") {
@@ -18430,6 +18741,7 @@ var NomosRuntimeComponent = (() => {
18430
18741
  link.ownMains = [];
18431
18742
  delete link.lastAnnounced;
18432
18743
  delete link.lastPlacementAnnounced;
18744
+ link.peerMain = void 0;
18433
18745
  link.dirty = true;
18434
18746
  link.due = this.clock.monotonicNanoseconds() + BigInt(Math.min(3e4, 250 * 2 ** Math.min(link.failures++, 7))) * 1000000n;
18435
18747
  return;
@@ -18439,7 +18751,6 @@ var NomosRuntimeComponent = (() => {
18439
18751
  link.openedAt = this.clock.monotonicNanoseconds();
18440
18752
  link.failures = 0;
18441
18753
  link.unheard = void 0;
18442
- if (!link.publisher) this.#hello(link);
18443
18754
  if (!link.publisher) this.inbound.opened(link.binding.workspace);
18444
18755
  this.linkOpened?.(link.binding.workspace);
18445
18756
  return;
@@ -18473,18 +18784,6 @@ var NomosRuntimeComponent = (() => {
18473
18784
  if (this.inbound.frame(link.binding.workspace, frame2.message)) return;
18474
18785
  if (frame2.message.case === "frontier") {
18475
18786
  this.#announced(link, frame2.message.value.head);
18476
- if (this.kernel.isResident(link.binding.workspace) === false) return;
18477
- if (!frame2.message.value.response) {
18478
- this.#send(link, { case: "frontier", value: {
18479
- head: this.kernel.head(workspaceMount(link.binding.workspace), ++this.#requestId) ?? "",
18480
- response: true
18481
- } });
18482
- }
18483
- try {
18484
- const batch2 = this.export(link.binding, frame2.message.value.head, ++this.#requestId);
18485
- if (batch2.source.case === "inline" && batch2.source.value.offers.length) this.#send(link, { case: "offers", value: batch2 });
18486
- } catch {
18487
- }
18488
18787
  return;
18489
18788
  }
18490
18789
  if (frame2.message.case === "admission") {
@@ -18492,48 +18791,18 @@ var NomosRuntimeComponent = (() => {
18492
18791
  this.progressChanged?.(link.binding.workspace);
18493
18792
  return;
18494
18793
  }
18495
- if (frame2.message.case !== "offers") return;
18496
- const batch = frame2.message.value;
18497
- if (batch.protocolVersion !== 2 || !batch.requestId || batch.source.case !== "inline" || !batch.source.value.offers.length) return;
18498
- const offers = batch.source.value.offers.filter((offer) => !this.#own.hasCommit(link.binding.workspace, offer.commitOid));
18499
- if (!offers.length) return;
18500
- if (this.kernel.isResident(link.binding.workspace) === false && !this.inbound.wanted(link.binding.workspace)) {
18501
- this.remoteAdvanced?.(link.binding.workspace);
18502
- return;
18503
- }
18504
- if (this.receiveStep !== void 0 && offers.length > this.receiveStep.offers) {
18505
- this.remoteAdvanced?.(link.binding.workspace);
18506
- return;
18507
- }
18508
- if ([...this.#pending.values()].some((pending) => pending.link === link && pending.bytes.length === bytes.length && pending.bytes.every((byte, index) => byte === bytes[index]))) return;
18509
- if (this.#pending.size >= 32) return;
18510
- this.#pending.set(request.requestId, { link, bytes });
18511
- return create(RuntimeRequestSchema, {
18512
- protocolVersion: 2,
18513
- requestId: request.requestId,
18514
- target: { workspace: link.binding.workspace, session: link.binding.replicaId },
18515
- // HTTP sender reconciliation controls are not part of a live proposal.
18516
- // Keeping fastForwardOnly while removing baseHead silently skips every
18517
- // offer against a nonempty local head. The Kernel judges sealed causality;
18518
- // live receivers neither ask for a return archive nor confirm the sender.
18519
- command: { case: "admitCustodyOffers", value: create(CustodyOfferBatchRequestSchema, {
18520
- ...batch,
18521
- baseHead: void 0,
18522
- observedHead: void 0,
18523
- fastForwardOnly: false,
18524
- ...offers.length === batch.source.value.offers.length ? {} : { source: { case: "inline", value: { ...batch.source.value, offers } } }
18525
- }) }
18526
- });
18794
+ }
18795
+ /** The newest local commit the custodian admitted unchanged over this workspace's open link: its
18796
+ * main holds that commit, sealed or not, so it is no work to offer (CAP-838). */
18797
+ admittedLocal(workspace) {
18798
+ const link = this.#links.get(workspace);
18799
+ const cursor = link?.state === "open" && !link.publisher ? link.custodian : void 0;
18800
+ return cursor && cursor.main === cursor.local ? cursor.local : void 0;
18527
18801
  }
18528
18802
  /** Offers this replica sent another way (the HTTP lane): their echo on the live link is its own. */
18529
18803
  offered(workspace, commitOids) {
18530
18804
  this.#own.commits(workspace, commitOids);
18531
18805
  }
18532
- /** Whether this request is the admission of a batch relayed to this follower over its live link.
18533
- * Such an admission is never answered to a sender, so it keeps no custody receipts (CAP-759). */
18534
- relayed(requestId) {
18535
- return this.#pending.has(requestId);
18536
- }
18537
18806
  /**
18538
18807
  * The custodian judged a live batch. Admission acknowledges the batch at once; its admitted main
18539
18808
  * becomes this connection's cursor when it is already in local verified history. The saved
@@ -18553,9 +18822,10 @@ var NomosRuntimeComponent = (() => {
18553
18822
  ...admission.sealedMain ? { sealed: admission.sealedMain } : {}
18554
18823
  };
18555
18824
  }
18556
- if (!admission?.main || this.kernel.isResident(workspace) === false) return;
18825
+ if (!admission?.main) return;
18557
18826
  const ownBatchHead = this.#own.batchHead(workspace, live.requestId);
18558
18827
  const ours = ownBatchHead !== void 0;
18828
+ if (this.kernel.isResident(workspace) === false) return;
18559
18829
  let stale = false;
18560
18830
  if (ours) link.unheard = void 0;
18561
18831
  if (ours && link.stream) {
@@ -18643,6 +18913,7 @@ var NomosRuntimeComponent = (() => {
18643
18913
  * upstream head it already recorded. Re-announcing a known frontier - which is all an
18644
18914
  * upstream can do while this replica is ahead or held on a dependency - is not an event. */
18645
18915
  #announced(link, head) {
18916
+ if (head) link.peerMain = head;
18646
18917
  if (!head || link.lastAnnounced === head) return;
18647
18918
  link.lastAnnounced = head;
18648
18919
  if (this.kernel.isResident(link.binding.workspace) === false) {
@@ -18667,15 +18938,6 @@ var NomosRuntimeComponent = (() => {
18667
18938
  if (frontier === this.kernel.resolveRef(mount, ++this.#requestId, PLACEMENT_REF3)) return;
18668
18939
  this.placementAdvanced?.(link.binding.workspace);
18669
18940
  }
18670
- settled(request, response) {
18671
- if (response.outcome.case === "correspondencePending" || response.outcome.case === "localReadPending") return;
18672
- this.#pending.delete(request.requestId);
18673
- }
18674
- failed(requestId) {
18675
- const pending = this.#pending.get(requestId);
18676
- this.#pending.delete(requestId);
18677
- if (pending) this.remoteAdvanced?.(pending.link.binding.workspace);
18678
- }
18679
18941
  disconnect(workspace) {
18680
18942
  const link = this.#links.get(workspace);
18681
18943
  if (!link) return;
@@ -18683,7 +18945,6 @@ var NomosRuntimeComponent = (() => {
18683
18945
  if (link.state === "open") this.linkClosed?.(workspace, closure);
18684
18946
  this.#links.delete(workspace);
18685
18947
  this.#progress.delete(workspace);
18686
- for (const [id, pending] of this.#pending) if (pending.link === link) this.#pending.delete(id);
18687
18948
  }
18688
18949
  /** The digest of the settled-letter outcomes this copy holds; empty when it cannot tell. */
18689
18950
  #outcomesDigest(workspace) {
@@ -18721,14 +18982,6 @@ var NomosRuntimeComponent = (() => {
18721
18982
  transfer.retain(create(PeerGitRefsFetchedSchema, { refs: [...wanted.refs], pack }));
18722
18983
  this.progressChanged?.(link.binding.workspace);
18723
18984
  }
18724
- #hello(link) {
18725
- if (this.kernel.isResident(link.binding.workspace) === false) return;
18726
- const head = this.kernel.head(workspaceMount(link.binding.workspace), ++this.#requestId);
18727
- this.#send(link, { case: "frontier", value: {
18728
- head: head ?? "",
18729
- outcomesDigest: this.#outcomesDigest(link.binding.workspace)
18730
- } });
18731
- }
18732
18985
  drive() {
18733
18986
  const now2 = this.clock.monotonicNanoseconds();
18734
18987
  let wake;
@@ -18777,7 +19030,8 @@ var NomosRuntimeComponent = (() => {
18777
19030
  link.custodian = void 0;
18778
19031
  }
18779
19032
  this.#cursor(link, mount);
18780
- const answered2 = link.publisher ? link.published ??= head ?? "" : link.custodian?.local ?? this.kernel.resolveRef(mount, ++this.#requestId, TRACKED_MAIN2) ?? "";
19033
+ let answered2 = link.publisher ? link.published ??= head ?? "" : link.custodian?.local ?? this.kernel.resolveRef(mount, ++this.#requestId, TRACKED_MAIN2) ?? "";
19034
+ if (!link.publisher && !link.custodian) answered2 = this.#heldPeerMain(link, mount, head, answered2) ?? answered2;
18781
19035
  const fence = link.custodian?.main ?? answered2;
18782
19036
  if (link.stream && !(head && this.#holds(mount, link.stream.sent, head))) {
18783
19037
  link.stream = void 0;
@@ -18878,7 +19132,6 @@ var NomosRuntimeComponent = (() => {
18878
19132
  }
18879
19133
  close() {
18880
19134
  for (const workspace of [...this.#links.keys()]) this.disconnect(workspace);
18881
- this.#pending.clear();
18882
19135
  }
18883
19136
  };
18884
19137
 
@@ -19821,6 +20074,7 @@ var NomosRuntimeComponent = (() => {
19821
20074
  var RECEIVED_PLACEMENT_REF = "refs/remotes/nomos/placement";
19822
20075
  var STREAM_BATCH_OFFERS = 64;
19823
20076
  var REMOUNT_AFTER_OFFERS = 128;
20077
+ var MAX_REMOUNTS_LOST = 2;
19824
20078
  var HISTORY_SLICES = [8, 64, 256, 256];
19825
20079
  var WorkspaceSyncPhase = Object.freeze({
19826
20080
  Idle: "idle",
@@ -19841,7 +20095,11 @@ var NomosRuntimeComponent = (() => {
19841
20095
  var judgedThisLifetime = /* @__PURE__ */ new Map();
19842
20096
  function releaseSyncJudgment(workspace) {
19843
20097
  judgedThisLifetime.delete(workspace);
20098
+ notContainedThisLifetime.delete(workspace);
19844
20099
  }
20100
+ var notContainedThisLifetime = /* @__PURE__ */ new Map();
20101
+ var MAX_NOT_CONTAINED = 1024;
20102
+ var NOT_CONTAINED_REFUSALS = /* @__PURE__ */ new Set(["nomos.stream.off_main", "nomos.stream.history_required"]);
19845
20103
  var MAX_REBASES_PER_ROUND = 2;
19846
20104
  var elapsedMillis = (clock2, started) => {
19847
20105
  const finished = clock2.monotonicNanoseconds();
@@ -19897,6 +20155,7 @@ var NomosRuntimeComponent = (() => {
19897
20155
  #lastStep;
19898
20156
  #probeOnly;
19899
20157
  #liveConnected;
20158
+ #liveAdmitted;
19900
20159
  /** Set when this round adopted the upstream's own head as its base (see #establishBase). */
19901
20160
  #establishedBase;
19902
20161
  #receiveState;
@@ -19913,6 +20172,11 @@ var NomosRuntimeComponent = (() => {
19913
20172
  /** The custodian head this round last offered or pulled from. */
19914
20173
  #rebaseFrom;
19915
20174
  #rebases = 0;
20175
+ #remountsLost = 0;
20176
+ /** This round's level ask is a containment question (CAP-870): on a refusal, take this path. */
20177
+ #containment;
20178
+ /** The stale bookmark a contained round replaces: its custodian's main holds the local head. */
20179
+ #containedBookmark;
19916
20180
  /** Local intents this round's rebase refused and parked on the refused-offer desk. */
19917
20181
  #parkedLocal = 0;
19918
20182
  /** An application-authorized drop: replace local custody at exactly this head. */
@@ -19934,6 +20198,7 @@ var NomosRuntimeComponent = (() => {
19934
20198
  this.#placementFetched = args.placementFetched;
19935
20199
  this.#probeOnly = args.probeOnly ?? false;
19936
20200
  this.#liveConnected = args.liveConnected === true;
20201
+ this.#liveAdmitted = args.liveAdmitted;
19937
20202
  this.#receiveState = args.receiveState;
19938
20203
  this.#completeHistory = args.completeHistory === true;
19939
20204
  this.#repairMissingCommit = args.repairMissingCommit === true;
@@ -20008,9 +20273,15 @@ var NomosRuntimeComponent = (() => {
20008
20273
  if (this.#receiveState) return this.#acquire("full");
20009
20274
  if (this.#replaceLocalHead !== void 0) return this.#acquire(this.#repairMissingCommit ? "full" : "mount");
20010
20275
  if (!this.#localHead) return this.#acquire(this.#completeHistory ? "full" : "mount");
20011
- if (this.#liveConnected && !this.#probeOnly && this.#holdsLocalWork() && this.#previousHead) {
20012
- return this.#offerOrReconcile();
20276
+ const unadmitted = this.#holdsLocalWork() && this.#localHead !== this.#liveAdmitted;
20277
+ if (this.#liveConnected && unadmitted && this.#previousHead) {
20278
+ if (this.#mayBeContained()) return this.#askContainment("offer");
20279
+ return this.#notContained();
20013
20280
  }
20281
+ if (this.#liveConnected && this.#probeOnly && this.#previousHead && this.#holdsUnsyncedCommits() && this.#command.admit && this.#localHead === this.#liveAdmitted) {
20282
+ return this.#acquire("level");
20283
+ }
20284
+ if (this.#liveConnected && !this.#probeOnly && !unadmitted) return this.#acquire("level");
20014
20285
  const requestId = `${this.#binding.replicaId}:${this.#requestId}:${this.workId}:frontier`;
20015
20286
  return this.#beginOffer(encodeInlineCustodyOffer({
20016
20287
  session: this.#binding.replicaId,
@@ -20019,6 +20290,60 @@ var NomosRuntimeComponent = (() => {
20019
20290
  intents: []
20020
20291
  }), { case: "awaiting", requestId }, true);
20021
20292
  }
20293
+ /** Whether the custodian's main may hold this copy's head: not already refused in this lifetime. */
20294
+ #mayBeContained() {
20295
+ return !!this.#localHead && this.#offerHead === void 0 && notContainedThisLifetime.get(this.#mount.workspace) !== this.#localHead;
20296
+ }
20297
+ /** The probe named a custodian main that is not on this copy's own chain, so the copy's head may be
20298
+ * on the custodian's. A main below the local head (the custodian is behind) cannot contain it. A
20299
+ * complete copy answers a main it does not hold after one existence check, and one it holds after
20300
+ * a walk to where the two chains join. A kernel that cannot say keeps the existing path. */
20301
+ #custodianMainOffLocalChain() {
20302
+ if (!this.#kernel.historySummary || !this.#desiredHead || !this.#localHead) return false;
20303
+ try {
20304
+ return !this.#kernel.historySummary(this.#mount, this.#requestId, this.#desiredHead, this.#localHead).reachedBase;
20305
+ } catch (error) {
20306
+ return error instanceof KernelHistoryRequired;
20307
+ }
20308
+ }
20309
+ /** Level from the local head (CAP-870). The stream answers with the custodian's commits above it
20310
+ * (or "level") only when its main holds that head; then this round converges onto them, moves the
20311
+ * bookmark, and offers nothing. One custodian lookup, O(commits behind); no local enumeration. */
20312
+ #askContainment(otherwise) {
20313
+ this.#containment = otherwise;
20314
+ return this.#acquire("level");
20315
+ }
20316
+ /** The stream answered from the local head: it is on the custodian's main. The stale bookmark
20317
+ * stays this round's to replace; the local head is the round's base from here. */
20318
+ #contained() {
20319
+ this.#containment = void 0;
20320
+ this.#containedBookmark = this.#previousHead;
20321
+ this.#previousHead = this.#localHead;
20322
+ }
20323
+ /** The custodian's main does not hold the local head (or the stream could not say): the copy holds
20324
+ * work of its own. Go straight on to the pull/rebase/offer path. A dependency planner's probe hands
20325
+ * the round back to it to plan the outbound suffix. */
20326
+ #notContained(code) {
20327
+ const otherwise = this.#containment ?? "offer";
20328
+ this.#containment = void 0;
20329
+ if (code !== void 0 && NOT_CONTAINED_REFUSALS.has(code) && this.#localHead) {
20330
+ if (notContainedThisLifetime.size >= MAX_NOT_CONTAINED && !notContainedThisLifetime.has(this.#mount.workspace)) {
20331
+ notContainedThisLifetime.delete(notContainedThisLifetime.keys().next().value);
20332
+ }
20333
+ notContainedThisLifetime.set(this.#mount.workspace, this.#localHead);
20334
+ }
20335
+ if (this.#probeOnly) {
20336
+ this.#needsReconciliation = true;
20337
+ return this.#finish(create(SyncWorkspaceResponseSchema, {
20338
+ workspace: this.#mount.workspace,
20339
+ currentHead: this.#localHead,
20340
+ previousHead: this.#previousHead,
20341
+ stillAhead: true,
20342
+ offerReceipt: this.#offerReceipt
20343
+ }));
20344
+ }
20345
+ return otherwise === "pull" ? this.#pullBeforeOffer() : this.#offerOrReconcile();
20346
+ }
20022
20347
  #offerOrReconcile() {
20023
20348
  if (this.#command.admit && this.#localHead && this.#localHead !== this.#previousHead) {
20024
20349
  const suffix = this.#kernel.transportIntentsAbove(
@@ -20097,7 +20422,14 @@ var NomosRuntimeComponent = (() => {
20097
20422
  return this.#previousHead === void 0 && this.#localHead !== void 0 && this.#replaceLocalHead === void 0;
20098
20423
  }
20099
20424
  #holdsLocalWork() {
20100
- return this.#command.admit && !!this.#localHead && this.#localHead !== this.#previousHead;
20425
+ return this.#command.admit && this.#holdsUnsyncedCommits();
20426
+ }
20427
+ /** Commits on local main the provider has not been seen to admit, whether or not this round may
20428
+ * offer them. Remount replaces local main, so it asks this, never the admit-gated question: a copy
20429
+ * holding unsynced work is offered and rebased, never remounted. A copy without a bookmark cannot
20430
+ * prove it holds nothing of its own. */
20431
+ #holdsUnsyncedCommits() {
20432
+ return !!this.#localHead && this.#localHead !== this.#previousHead;
20101
20433
  }
20102
20434
  /** Ask only for the custodian's delta; the offer follows once this peer has rebased. */
20103
20435
  #pullBeforeOffer() {
@@ -20135,13 +20467,13 @@ var NomosRuntimeComponent = (() => {
20135
20467
  }
20136
20468
  if (purpose === "level") {
20137
20469
  this.#state = { phase: WorkspaceSyncPhase.Stream, purpose, startedAt };
20138
- return this.#streamEffect("level", { case: "level", value: create(LiveFrontierSchema, {
20470
+ return this.#streamEffect(this.#containment ? "contain" : "level", { case: "level", value: create(LiveFrontierSchema, {
20139
20471
  head: this.#localHead ?? "",
20140
20472
  response: false,
20141
20473
  maxOffers: this.#receiveStep?.offers ?? STREAM_BATCH_OFFERS,
20142
20474
  // Only a copy holding no work above its bookmark may be remounted instead of replaying, and
20143
20475
  // never one whose durable copy must hold the complete history (a head-only mount it cannot keep).
20144
- remountAfterOffers: this.#holdsLocalWork() || this.#completeHistory ? 0 : REMOUNT_AFTER_OFFERS
20476
+ remountAfterOffers: this.#holdsUnsyncedCommits() || this.#completeHistory ? 0 : REMOUNT_AFTER_OFFERS
20145
20477
  }) });
20146
20478
  }
20147
20479
  const outcomes = new EffectOutcomeTransfer(this.#kernel, this.#mount, this.#requestId);
@@ -20218,6 +20550,7 @@ var NomosRuntimeComponent = (() => {
20218
20550
  }
20219
20551
  if (answer.outcome.case === "refusal") {
20220
20552
  const refusal2 = answer.outcome.value;
20553
+ if (state.purpose === "level" && this.#containment) return this.#notContained(refusal2.code);
20221
20554
  if (state.afterPlacement) return this.#finish(state.afterPlacement);
20222
20555
  return this.#transportFailure(`${refusal2.code}: ${refusal2.message}`, false);
20223
20556
  }
@@ -20254,6 +20587,11 @@ var NomosRuntimeComponent = (() => {
20254
20587
  state.startedAt
20255
20588
  );
20256
20589
  }
20590
+ if (state.purpose === "level" && this.#containment) {
20591
+ const answeredFromHead = answer.outcome.case === "level" || answer.outcome.case === "pack" && answer.outcome.value.base === this.#localHead;
20592
+ if (!answeredFromHead) return this.#notContained();
20593
+ this.#contained();
20594
+ }
20257
20595
  if (state.purpose === "level" && answer.outcome.case === "pack" && answer.outcome.value.base) {
20258
20596
  const batch = answer.outcome.value;
20259
20597
  if (batch.base !== this.#previousHead && batch.base !== this.#kernel.head(this.#mount, this.#requestId)) {
@@ -20392,13 +20730,19 @@ var NomosRuntimeComponent = (() => {
20392
20730
  /**
20393
20731
  * A copy holding no work above its bookmark, too far behind to replay the backlog: mount the
20394
20732
  * peer's checkpoint in place of its exact local main (O(state), the same trust as a cold mount).
20395
- * The kernel keeps the replaced head at refs/heads/custody-preserved/<old>; that head was only a
20396
- * bookmark of the provider's own main, so the preservation is released at once.
20733
+ * The kernel keeps the replaced head at refs/heads/custody-preserved/<old>. That ref is custody the
20734
+ * kernel guards (custody may not delete an effectful branch), so it is left where it is: a remount
20735
+ * that deleted it threw after main had already moved, leaving the bookmark behind main and the
20736
+ * round failed for ever (2026-10-08, estate-5b493d6b).
20737
+ *
20738
+ * The copy may have moved while the checkpoint streamed (a live batch, a local write). Then it is
20739
+ * no longer the copy the remount was asked for: take the round up again from its new head. Local
20740
+ * work is offered first; a copy that is still only behind asks to level again.
20397
20741
  */
20398
20742
  #remount(candidateHead, receivedBytes, prefetchMillis) {
20399
20743
  const expected = this.#kernel.head(this.#mount, this.#requestId);
20400
- if (expected === void 0 || expected !== this.#localHead || this.#holdsLocalWork()) {
20401
- return this.#transportFailure("the copy changed while its remount was streaming", false);
20744
+ if (expected === void 0 || expected !== this.#localHead || this.#holdsUnsyncedCommits()) {
20745
+ return this.#remountLost(expected);
20402
20746
  }
20403
20747
  const started = this.#clock.monotonicNanoseconds();
20404
20748
  if (candidateHead !== expected) {
@@ -20406,7 +20750,6 @@ var NomosRuntimeComponent = (() => {
20406
20750
  if (!restored.accepted || restored.head !== candidateHead) {
20407
20751
  throw new Error(`kernel refused to remount '${this.#mount.workspace}' at ${candidateHead}`);
20408
20752
  }
20409
- this.#kernel.deleteRef?.(this.#mount, this.#requestId, `refs/heads/custody-preserved/${expected}`);
20410
20753
  this.#providerCustodyMounted();
20411
20754
  }
20412
20755
  return this.#converged(create(SyncResponseSchema, {
@@ -20416,6 +20759,25 @@ var NomosRuntimeComponent = (() => {
20416
20759
  admittedRemoteHead: candidateHead
20417
20760
  }), candidateHead, receivedBytes, prefetchMillis, started);
20418
20761
  }
20762
+ /** The remount's copy changed under it. Bounded: a copy that keeps moving under live traffic is
20763
+ * levelled by its live link anyway, and the next round starts from wherever it got to. */
20764
+ #remountLost(head) {
20765
+ if (head === void 0 || ++this.#remountsLost > MAX_REMOUNTS_LOST) {
20766
+ return this.#transportFailure("the copy changed while its remount was streaming", false);
20767
+ }
20768
+ this.#localHead = head;
20769
+ this.#previousHead = this.#kernel.resolveRef(this.#mount, this.#requestId, trackedMain);
20770
+ if (this.#desiredHead === this.#localHead) {
20771
+ return this.#converged(create(SyncResponseSchema, {
20772
+ admitted: true,
20773
+ head,
20774
+ candidateHead: head,
20775
+ admittedRemoteHead: head
20776
+ }), head, 0, 0);
20777
+ }
20778
+ if (this.#holdsLocalWork() && this.#desiredHead !== this.#previousHead) return this.#pullBeforeOffer();
20779
+ return this.#offerOrReconcile();
20780
+ }
20419
20781
  resume(receipt) {
20420
20782
  if (receipt.effectId === this.#lastReceiptEffectId && this.#lastStep) {
20421
20783
  return this.#lastStep;
@@ -20580,6 +20942,10 @@ var NomosRuntimeComponent = (() => {
20580
20942
  offerReceipt: this.#offerReceipt
20581
20943
  }));
20582
20944
  }
20945
+ const custodianMoved = this.#holdsLocalWork() && this.#desiredHead !== this.#previousHead;
20946
+ if (custodianMoved && this.#mayBeContained() && this.#custodianMainOffLocalChain()) {
20947
+ return this.#askContainment("pull");
20948
+ }
20583
20949
  if (this.#probeOnly) {
20584
20950
  this.#needsReconciliation = true;
20585
20951
  return this.#finish(create(SyncWorkspaceResponseSchema, {
@@ -20590,9 +20956,7 @@ var NomosRuntimeComponent = (() => {
20590
20956
  offerReceipt: this.#offerReceipt
20591
20957
  }));
20592
20958
  }
20593
- if (this.#holdsLocalWork() && this.#desiredHead !== this.#previousHead) {
20594
- return this.#pullBeforeOffer();
20595
- }
20959
+ if (custodianMoved) return this.#pullBeforeOffer();
20596
20960
  return this.#offerOrReconcile();
20597
20961
  }
20598
20962
  this.#admissionSummary = summarizeCustodyAdmission(admission);
@@ -20926,7 +21290,8 @@ var NomosRuntimeComponent = (() => {
20926
21290
  }));
20927
21291
  }
20928
21292
  #converged(verdict, candidateHead, receivedBytes, prefetchMillis, started = this.#clock.monotonicNanoseconds(), rebirth) {
20929
- if (verdict.admitted && this.#candidateDurable && candidateHead !== this.#previousHead && this.#kernel.resolveRef(this.#mount, this.#requestId, trackedMain) === this.#previousHead) {
21293
+ const tracked = verdict.admitted && this.#candidateDurable ? this.#kernel.resolveRef(this.#mount, this.#requestId, trackedMain) : void 0;
21294
+ if (verdict.admitted && this.#candidateDurable && tracked !== candidateHead && (tracked === this.#previousHead || this.#containedBookmark !== void 0 && tracked === this.#containedBookmark)) {
20930
21295
  this.#kernel.writeRef(
20931
21296
  this.#mount,
20932
21297
  this.#requestId,
@@ -21214,10 +21579,16 @@ var NomosRuntimeComponent = (() => {
21214
21579
  this.#plan = [this.#args.root];
21215
21580
  return this.#advance();
21216
21581
  }
21217
- if (this.#args.liveConnected && this.#args.kernel.resolveRef(this.#args.root.mount, this.#args.requestId, trackedMain2)) {
21582
+ const { kernel, requestId, root } = this.#args;
21583
+ const tracked = this.#args.liveConnected ? kernel.resolveRef(root.mount, requestId, trackedMain2) : void 0;
21584
+ if (tracked && kernel.head(root.mount, requestId) === tracked) {
21218
21585
  this.#plan = this.#planDependencies();
21219
21586
  return this.#advance();
21220
21587
  }
21588
+ if (tracked) {
21589
+ this.#current = this.#work(root, `${this.workId}:contain`, true);
21590
+ return this.#accept(this.#current.start());
21591
+ }
21221
21592
  this.#current = this.#work(this.#args.root, `${this.workId}:frontier`, true);
21222
21593
  return this.#accept(this.#current.start());
21223
21594
  }
@@ -22529,6 +22900,11 @@ var NomosRuntimeComponent = (() => {
22529
22900
  const delay = this.#controller.reconnected(workspace);
22530
22901
  if (delay !== void 0) this.#scheduleAt(workspace, this.#now() + delay);
22531
22902
  }
22903
+ /** The upstream announced a new frontier: news even to a follow the kernel refused. */
22904
+ remoteAdvanced(workspace) {
22905
+ const delay = this.#controller.reconnected(workspace, true);
22906
+ if (delay !== void 0) this.#scheduleAt(workspace, this.#now() + delay);
22907
+ }
22532
22908
  /** The upstream rang for a new placement frontier (see ReplicaFollowController). */
22533
22909
  placementAnnounced(workspace) {
22534
22910
  const delay = this.#controller.placementAnnounced(workspace);
@@ -22842,6 +23218,7 @@ var NomosRuntimeComponent = (() => {
22842
23218
  #onPlacementFetched;
22843
23219
  #onShallowMount;
22844
23220
  #onOffered;
23221
+ #liveAdmitted;
22845
23222
  #onOutboxHistoryRequired;
22846
23223
  #backgroundHistory;
22847
23224
  #receiveStep;
@@ -22898,6 +23275,7 @@ var NomosRuntimeComponent = (() => {
22898
23275
  this.#onPlacementFetched = args.onPlacementFetched;
22899
23276
  this.#onShallowMount = args.onShallowMount;
22900
23277
  this.#onOffered = args.onOffered;
23278
+ this.#liveAdmitted = args.liveAdmitted;
22901
23279
  this.#onOutboxHistoryRequired = args.onOutboxHistoryRequired;
22902
23280
  this.#backgroundHistory = args.backgroundHistory !== false;
22903
23281
  this.#receiveStep = args.receiveStep;
@@ -23224,6 +23602,12 @@ var NomosRuntimeComponent = (() => {
23224
23602
  this.#followLane.reconnected(workspace);
23225
23603
  this.reportFollows();
23226
23604
  }
23605
+ /** The upstream announced a new frontier for this workspace over its live link: an event which
23606
+ * re-runs a round the kernel refused (its inputs changed). */
23607
+ replicaRemoteAdvanced(workspace) {
23608
+ this.#followLane.remoteAdvanced(workspace);
23609
+ this.reportFollows();
23610
+ }
23227
23611
  /** The upstream rang for a new placement frontier: the next round re-checks placement even
23228
23612
  * though main has not moved. */
23229
23613
  replicaPlacementAnnounced(workspace) {
@@ -23260,10 +23644,11 @@ var NomosRuntimeComponent = (() => {
23260
23644
  const state = this.#follows.followForWorkspace(workspace)?.state;
23261
23645
  if (!state) return [];
23262
23646
  const isSettled = state.case === ReplicaFollowPhase.Settled;
23647
+ const refused = state.case === ReplicaFollowPhase.Backoff && state.refusal?.blocked === true;
23263
23648
  const isLive = this.#openLinks.has(workspace);
23264
23649
  if (isSettled) settled += 1;
23265
23650
  if (isLive) live += 1;
23266
- const phase = {
23651
+ const phase = refused ? FollowObservationPhase.KERNEL_REFUSED : {
23267
23652
  [ReplicaFollowPhase.Desired]: FollowObservationPhase.DESIRED,
23268
23653
  [ReplicaFollowPhase.Due]: FollowObservationPhase.DUE,
23269
23654
  [ReplicaFollowPhase.Running]: FollowObservationPhase.RUNNING,
@@ -23277,7 +23662,7 @@ var NomosRuntimeComponent = (() => {
23277
23662
  [ReplicaFollowPhase.LocalCopyUnreadable]: FollowObservationPhase.LOCAL_COPY_UNREADABLE
23278
23663
  }[state.case];
23279
23664
  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;
23280
- const retryAt = state.case === ReplicaFollowPhase.Offline || state.case === ReplicaFollowPhase.InvalidCredential || state.case === ReplicaFollowPhase.Backoff ? state.retryAtUnixMillis : void 0;
23665
+ 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;
23281
23666
  const dueAt2 = state.case === ReplicaFollowPhase.Due || state.case === ReplicaFollowPhase.ReplacingLocal ? state.dueAtUnixMillis : void 0;
23282
23667
  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;
23283
23668
  const activeEffect = state.case === ReplicaFollowPhase.Running ? this.#activeSyncEffect(workspace) : void 0;
@@ -23775,6 +24160,7 @@ var NomosRuntimeComponent = (() => {
23775
24160
  workId: id,
23776
24161
  probeOnly,
23777
24162
  liveConnected: this.#openLinks.has(target3.mount.workspace),
24163
+ ...this.#openLinks.has(target3.mount.workspace) && this.#liveAdmitted?.(target3.mount.workspace) ? { liveAdmitted: this.#liveAdmitted(target3.mount.workspace) } : {},
23778
24164
  ...beforeConverge === void 0 ? {} : { beforeConverge },
23779
24165
  ...target3.receiveState === void 0 ? {} : { receiveState: target3.receiveState },
23780
24166
  ...target3.offerHead === void 0 ? {} : { offerHead: target3.offerHead },
@@ -25385,10 +25771,10 @@ var NomosRuntimeComponent = (() => {
25385
25771
  while (true) {
25386
25772
  this.#ports.owe(owed.workspace);
25387
25773
  while (this.#ports.owes(owed.workspace)) {
25388
- const tick = this.#ports.tick();
25774
+ const { ticked, wake: readiness } = this.#ports.tick();
25389
25775
  const delayMillis = Math.min(LONGEST_WAKE_MILLIS, Math.max(
25390
25776
  FIRST_WAKE_MILLIS,
25391
- tick.progress !== void 0 ? FIRST_WAKE_MILLIS : tick.nextTickAfterMillis
25777
+ ticked.progress !== void 0 ? FIRST_WAKE_MILLIS : readiness.case === "after" ? readiness.millis : LONGEST_WAKE_MILLIS
25392
25778
  ));
25393
25779
  const receipt = yield { case: "wake", value: create(PeerWakeEffectSchema, {
25394
25780
  effectId: `${workId2}:repay-${++wake}`,
@@ -25540,7 +25926,6 @@ var NomosRuntimeComponent = (() => {
25540
25926
  }
25541
25927
  var INTERACTIVE_PEER_CLASSES = /* @__PURE__ */ new Set(["personal-device", "browser"]);
25542
25928
  var INTERACTION_FIRST_MILLIS = 15e3;
25543
- var READ_READINESS_ONLY = 1n << 62n;
25544
25929
  var PLACEMENT_READ_RETRY_MILLIS = 60000n;
25545
25930
  var STREAM_WAKE_FIRST_MILLIS = 20;
25546
25931
  var HISTORY_STREAM_SLICES = [8, 64, 256];
@@ -25559,7 +25944,6 @@ var NomosRuntimeComponent = (() => {
25559
25944
  "continueLocalRead"
25560
25945
  ]);
25561
25946
  var APPLICATION_WAIT_NANOS = 5000000000n;
25562
- var READ_INDEX_BUILDING = /the read index of .+ is being built|read maintenance continues it/;
25563
25947
  var PeerOffice = class {
25564
25948
  #kernel;
25565
25949
  #sessions = new SessionDirectory();
@@ -25754,7 +26138,6 @@ var NomosRuntimeComponent = (() => {
25754
26138
  }
25755
26139
  }, (workspace) => this.#residency.lastRetainedHead(workspace));
25756
26140
  if (this.#writeBurst) this.#live.writeBurst = this.#writeBurst;
25757
- if (this.#interactivePeer) this.#live.receiveStep = this.#receiveStepBudget;
25758
26141
  this.#credentials = new CredentialSessions(this.#sessions, credentials, observations);
25759
26142
  this.#readability = new LocalCopyReadability((workspace, format) => {
25760
26143
  this.#follows.markLocalCopyUnreadable(workspace, format);
@@ -25772,7 +26155,8 @@ var NomosRuntimeComponent = (() => {
25772
26155
  new ReplicaFollowDesk(seatedStore),
25773
26156
  observations,
25774
26157
  this.#replicaId,
25775
- new BirthRefusalRegister(seatedStore)
26158
+ new BirthRefusalRegister(seatedStore),
26159
+ PEER_RUNTIME_IDENTITY
25776
26160
  );
25777
26161
  this.#compatibility = new CompatibilityDesk(
25778
26162
  this.#queries,
@@ -25791,13 +26175,20 @@ var NomosRuntimeComponent = (() => {
25791
26175
  this.#trace,
25792
26176
  observations,
25793
26177
  {
25794
- readReady: (workspace) => this.#subscriptions.readIndexReady(workspace),
25795
- frontierAdvanced: (workspace) => this.#subscriptions.readIndexAdvanced(workspace),
25796
- localCopyUnreadable: (workspace, format) => this.#readability.mark(
25797
- workspace,
25798
- this.#kernel.head(workspaceMount(workspace), 0n),
25799
- format
25800
- ),
26178
+ // A read waiting on this workspace is released by the readiness event itself, not a timer.
26179
+ readReady: (workspace) => {
26180
+ this.#subscriptions.readIndexReady(workspace);
26181
+ this.#readResponses?.readinessChanged(workspace);
26182
+ },
26183
+ frontierAdvanced: (workspace) => {
26184
+ this.#subscriptions.readIndexAdvanced(workspace);
26185
+ this.#readResponses?.readinessChanged(workspace);
26186
+ },
26187
+ readinessMayChange: (workspace) => this.#readResponses?.readinessChanged(workspace),
26188
+ localCopyUnreadable: (workspace, format) => {
26189
+ this.#readability.mark(workspace, this.#kernel.head(workspaceMount(workspace), 0n), format);
26190
+ this.#readResponses?.readinessChanged(workspace);
26191
+ },
25801
26192
  isLocalCopyUnreadable: (workspace) => this.#readability.decide(workspace) !== void 0
25802
26193
  },
25803
26194
  // The kernel owes this peer's writes to an ordered background flush the desk schedules.
@@ -25859,7 +26250,7 @@ var NomosRuntimeComponent = (() => {
25859
26250
  aggregateIds: new Set([...admitted.affected, ...admitted.created].map((ref) => ref.id)),
25860
26251
  // What the offer changed, typed as reads resolve it: watches it cannot change are not read.
25861
26252
  stateChange: admitted.stateChange
25862
- }, () => this.#readMaintenance.tick(void 0, 0n, READ_READINESS_ONLY, false).progress !== void 0));
26253
+ }, () => this.#readMaintenance.tickReadReadiness().ticked.progress !== void 0));
25863
26254
  noteTimeline("ownOffer", `${delivery.delivered}/${delivery.watches}`);
25864
26255
  noteTimeline("ownOfferSkipped", delivery.skipped);
25865
26256
  });
@@ -25874,7 +26265,12 @@ var NomosRuntimeComponent = (() => {
25874
26265
  observations,
25875
26266
  // A waiting read advances read readiness only: it must never run a background command or
25876
26267
  // closure warm on the foreground's turn.
25877
- () => this.#readMaintenance.tick(void 0, 0n, READ_READINESS_ONLY, false),
26268
+ () => this.#readMaintenance.tickReadReadiness(),
26269
+ // A read the kernel still finds behind, with nothing owing its index, owes it again (as a watch does).
26270
+ (request) => {
26271
+ if (request.command.case !== "kernelCall") throw new Error("local read continuation lost its query");
26272
+ this.#readMaintenance.schedule(request.command.value.session, ReadMaintenanceCause.READ_DEBT);
26273
+ },
25878
26274
  (request) => {
25879
26275
  if (request.command.case !== "kernelCall") throw new Error("local read continuation lost its query");
25880
26276
  return this.#application.call(request, request.command.value);
@@ -25975,6 +26371,7 @@ var NomosRuntimeComponent = (() => {
25975
26371
  onShallowMount: (workspace, credentialCapability) => this.#historyAcquisition.materialise(workspace, credentialCapability),
25976
26372
  // The edge echoes an HTTP offer batch back over this replica's own live link (CAP-764).
25977
26373
  onOffered: (workspace, commitOids) => this.#live.offered(workspace, commitOids),
26374
+ liveAdmitted: (workspace) => this.#live.admittedLocal(workspace),
25978
26375
  onOutboxHistoryRequired: (workspace, credentialCapability) => this.#historyAcquisition.requestFromBackground(workspace, credentialCapability),
25979
26376
  backgroundHistory: profile.backgroundHistory !== false,
25980
26377
  onSyncCompleted: (session, event) => {
@@ -26000,7 +26397,7 @@ var NomosRuntimeComponent = (() => {
26000
26397
  this.#origins.ignored(workspace, origin, "follow");
26001
26398
  return false;
26002
26399
  };
26003
- this.#live.remoteAdvanced = (workspace) => this.#correspondence.replicaLinkOpened(workspace);
26400
+ this.#live.remoteAdvanced = (workspace) => this.#correspondence.replicaRemoteAdvanced(workspace);
26004
26401
  this.#live.declined = (workspace) => this.#correspondence.liveAdmissionDeclined(workspace);
26005
26402
  this.#live.acknowledged = (workspace, ack) => this.#correspondence.liveAdmissionAcknowledged(workspace, ack);
26006
26403
  this.#live.intentsAdmitted = (workspace, intentIds, local) => this.#correspondence.liveIntentsAdmitted(workspace, intentIds, local);
@@ -26212,7 +26609,7 @@ var NomosRuntimeComponent = (() => {
26212
26609
  },
26213
26610
  owes: (workspace) => this.#readMaintenance.owesReadReadiness(workspace),
26214
26611
  // Read readiness only, as a waiting read takes: never a background command or pack import (CAP-806).
26215
- tick: () => this.#readMaintenance.tick(void 0, 0n, READ_READINESS_ONLY, false),
26612
+ tick: () => this.#readMaintenance.tickReadReadiness(),
26216
26613
  emit: (session, event) => this.#trace.emit(session, event)
26217
26614
  });
26218
26615
  this.#modelAdoption = new ModelAdoptionDesk({
@@ -26610,9 +27007,8 @@ var NomosRuntimeComponent = (() => {
26610
27007
  let pendingEffectId;
26611
27008
  try {
26612
27009
  if (request.command.case === "socketReceipt") {
26613
- const admission = this.#live.receive(request, request.command.value);
26614
- if (!admission) return this.#response(request, { case: "socketObserved", value: create(PeerSocketObservedSchema) });
26615
- request = admission;
27010
+ this.#live.receive(request.command.value);
27011
+ return this.#response(request, { case: "socketObserved", value: create(PeerSocketObservedSchema) });
26616
27012
  }
26617
27013
  const result = timelinePhase("access", () => this.#access.handle(request));
26618
27014
  if (result.outcome.case === "correspondencePending") {
@@ -26621,11 +27017,9 @@ var NomosRuntimeComponent = (() => {
26621
27017
  }
26622
27018
  if (result.outcome.case === "watchStarted") this.#subscriptions.retainDependencies(result.outcome.value.subscriptionId, scope);
26623
27019
  this.#subscriptions.recoverySettled(result);
26624
- this.#live.settled(request, result);
26625
27020
  this.#correspondence.observeResponse(result);
26626
27021
  return result;
26627
27022
  } catch (error) {
26628
- this.#live.failed(request.requestId);
26629
27023
  const failure = this.#failure(request, "nomos.runtime.workspace_access", error instanceof Error ? error.message : String(error));
26630
27024
  this.#subscriptions.recoverySettled(failure);
26631
27025
  this.#correspondence.observeResponse(failure);
@@ -26892,11 +27286,7 @@ var NomosRuntimeComponent = (() => {
26892
27286
  try {
26893
27287
  const mount = this.#sessions.mountForWorkspace(request.target.workspace);
26894
27288
  const previousHead = this.#kernel.head(mount, request.requestId);
26895
- const admission = this.#custodyAdmission.admit(
26896
- request,
26897
- request.command.value,
26898
- { journal: !this.#live.relayed(request.requestId) }
26899
- );
27289
+ const admission = this.#custodyAdmission.admit(request, request.command.value);
26900
27290
  admission.sealedMain = this.#residency.retainedHead(request.target.workspace);
26901
27291
  if (custodyAdmissionNeedsReadMaintenance(admission)) {
26902
27292
  admission.localMaintenance = this.#readMaintenance.scheduleWorkspace(
@@ -27013,16 +27403,17 @@ var NomosRuntimeComponent = (() => {
27013
27403
  });
27014
27404
  case "historicQuery": {
27015
27405
  const answered2 = this.#historicQueries.execute(request, request.command.value);
27016
- if (answered2.outcome.case === "failure" && READ_INDEX_BUILDING.test(answered2.outcome.value.message)) {
27406
+ if (answered2.outcome.case === "query" && answered2.outcome.value.result.case === "readIndexPending") {
27017
27407
  this.#readMaintenance.schedule(request.command.value.session, ReadMaintenanceCause.READ_DEBT);
27408
+ const workspace = answered2.outcome.value.result.value.workspace || (this.#sessions.bindingIfPresent(request.command.value.session)?.workspace ?? "");
27018
27409
  return this.#response(request, {
27019
27410
  case: "unavailable",
27020
27411
  value: create(RuntimeUnavailableSchema, {
27021
27412
  reason: RuntimeUnavailableReason.LOCAL_REPLICA_NOT_READY,
27022
- workspace: this.#sessions.bindingIfPresent(request.command.value.session)?.workspace ?? "",
27413
+ workspace,
27023
27414
  retryable: true,
27024
27415
  retryAfterMillis: 250,
27025
- detail: answered2.outcome.value.message
27416
+ detail: `the read index of ${workspace} is being built on this device; read maintenance continues it`
27026
27417
  })
27027
27418
  });
27028
27419
  }
@@ -27442,6 +27833,10 @@ var NomosRuntimeComponent = (() => {
27442
27833
  nextEvent() {
27443
27834
  return this.#trace.nextEvent();
27444
27835
  }
27836
+ /** In-process shells wait on a held local read here instead of polling `resumeAfterMillis`. */
27837
+ localReadResumable(workId2, notify) {
27838
+ return this.#readResponses.onResumable(workId2, notify);
27839
+ }
27445
27840
  close() {
27446
27841
  if (this.retentionOutstanding() > 0) {
27447
27842
  throw new Error("custody retention pending; retain the acknowledged frontiers before disposing the peer");