@githolon/runtime 0.112.0 → 0.112.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@githolon/runtime",
3
- "version": "0.112.0",
3
+ "version": "0.112.1",
4
4
  "type": "module",
5
5
  "description": "The portable Nomos application runtime, reception contracts, and Node/browser runners.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -7290,7 +7290,7 @@ function runtimeKernelPort(engine) {
7290
7290
  case: "resolveRef",
7291
7291
  value: create(ResolveRefRequestSchema, {
7292
7292
  repo: workspaceRepositoryPath(workspace),
7293
- reference: `refs/heads/${branch}`
7293
+ reference: branch.startsWith("refs/") ? branch : `refs/heads/${branch}`
7294
7294
  })
7295
7295
  }
7296
7296
  })
@@ -8272,7 +8272,6 @@ function gitCustodyDesk(kernel, fetchImpl = fetch, observe, phaseStarted) {
8272
8272
  return acquired;
8273
8273
  },
8274
8274
  deepenMain(workspace, ledger) {
8275
- if (ledger.operatorCustody !== true) return Promise.resolve({ changed: false, complete: true });
8276
8275
  return acquiring(workspace, ledger, "deepen-main", async () => {
8277
8276
  if (resolveRef(workspace, branchRef("main")) === void 0) {
8278
8277
  const acquired = await acquireMain(workspace, ledger);
@@ -13601,6 +13600,7 @@ var PeerPlatformShell = class {
13601
13600
  // one constitutional genesis offer. WorkspaceAccessDesk decides whether
13602
13601
  // that exact request may proceed against the unborn kernel mount.
13603
13602
  async openCustody(workspace) {
13603
+ if (physical.openLocalCustody) return physical.openLocalCustody(workspace);
13604
13604
  await custody.acquireMain(workspace, await ledgerFor(workspace));
13605
13605
  return {};
13606
13606
  },
@@ -13616,7 +13616,12 @@ var PeerPlatformShell = class {
13616
13616
  },
13617
13617
  persistBornCustody: (effect) => physical.persistBornCustody(effect),
13618
13618
  retainFrontier: (effect) => physical.retainFrontier(effect),
13619
- ...physical.completeHistoryInLocalCustody ? {
13619
+ ...physical.advanceHistory ? {
13620
+ advanceHistory: (workspace, capability) => {
13621
+ const credential = capability ? this.#credentials.authToken(capability) : authToken;
13622
+ return physical.advanceHistory(workspace, credential && new TextDecoder().decode(credential));
13623
+ }
13624
+ } : physical.completeHistoryInLocalCustody ? {
13620
13625
  // The kernel mounts a shallow working copy; the peer's own Git custody is deep.
13621
13626
  // One bounded slice per call; the Peer Office decides whether and when to take the next.
13622
13627
  async advanceHistory(workspace) {
@@ -22969,10 +22974,11 @@ var LiveCorrespondenceDesk = class {
22969
22974
  failures: 0,
22970
22975
  origin: origin2,
22971
22976
  publisher: !binding.cloudBound,
22972
- published: !binding.cloudBound ? head : void 0
22977
+ published: !binding.cloudBound ? head : void 0,
22978
+ wasResident: this.kernel.isResident(binding.workspace) !== false
22973
22979
  };
22974
22980
  this.#links.set(binding.workspace, link);
22975
- this.#open(link);
22981
+ if (link.wasResident) this.#open(link);
22976
22982
  }
22977
22983
  changed(workspace) {
22978
22984
  const link = this.#links.get(workspace);
@@ -23129,9 +23135,11 @@ var LiveCorrespondenceDesk = class {
23129
23135
  let wake;
23130
23136
  for (const link of this.#links.values()) {
23131
23137
  if (this.kernel.isResident(link.binding.workspace) === false) {
23132
- this.disconnect(link.binding.workspace);
23138
+ if (link.wasResident) this.disconnect(link.binding.workspace);
23139
+ else wake = wake === void 0 || wake > 250n ? 250n : wake;
23133
23140
  continue;
23134
23141
  }
23142
+ link.wasResident = true;
23135
23143
  if (link.state === "opening" && now >= link.due) {
23136
23144
  this.#effect(link, { case: "close", value: true });
23137
23145
  link.state = "closed";
@@ -30812,7 +30820,7 @@ var executeGitPushEffect = async (effect, fetchImpl) => {
30812
30820
  });
30813
30821
  }
30814
30822
  };
30815
- async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch, custody, bornCustody, credentialRefresh, yieldWakeToCaller = false, deviceIdentity, lawPackage, yieldLocalReadToCaller = false, yieldHistoryToCaller = false) {
30823
+ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch, custody, bornCustody, credentialRefresh, yieldWakeToCaller = false, deviceIdentity, lawPackage, yieldLocalReadToCaller = false, yieldHistoryToCaller = false, performExternalEffect) {
30816
30824
  const persistBornCustody = bornCustody ?? (custody?.persistBornCustody ? (effect) => custody.persistBornCustody(effect) : void 0);
30817
30825
  let responseFrame = runner.handleFrame(initialFrame);
30818
30826
  const satisfied = /* @__PURE__ */ new Set();
@@ -30948,12 +30956,10 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
30948
30956
  if (pending.effect.case === "historyAcquisition" && (yieldHistoryToCaller || !custody?.advanceHistory)) {
30949
30957
  return responseFrame;
30950
30958
  }
30951
- if (pending.effect.case === "refreshCredential" && credentialRefresh === externalPeerEffect) return responseFrame;
30952
- if (pending.effect.case === "deviceIdentity" && deviceIdentity === externalPeerEffect) return responseFrame;
30953
- if (pending.effect.case === "lawPackage" && lawPackage === externalPeerEffect) return responseFrame;
30954
30959
  if (pending.effect.case === "wake" && yieldWakeToCaller) return responseFrame;
30955
- if (pending.effect.case === "consoleEnrolment") return responseFrame;
30956
- const receipt = pending.effect.case === "http" ? await executeHttpEffect(pending.effect.value, fetchImpl) : pending.effect.case === "gitFetch" ? await executeGitFetchWithAlongside(pending.effect.value, fetchImpl) : pending.effect.case === "gitPush" ? await executeGitPushEffect(pending.effect.value, fetchImpl) : pending.effect.case === "persistBornCustody" ? create(PeerEffectReceiptSchema, {
30960
+ const external = pending.effect.case === "refreshCredential" && credentialRefresh === externalPeerEffect || pending.effect.case === "deviceIdentity" && deviceIdentity === externalPeerEffect || pending.effect.case === "lawPackage" && lawPackage === externalPeerEffect || pending.effect.case === "consoleEnrolment";
30961
+ if (external && !performExternalEffect) return responseFrame;
30962
+ const receipt = external ? await performExternalEffect(pending) : pending.effect.case === "http" ? await executeHttpEffect(pending.effect.value, fetchImpl) : pending.effect.case === "gitFetch" ? await executeGitFetchWithAlongside(pending.effect.value, fetchImpl) : pending.effect.case === "gitPush" ? await executeGitPushEffect(pending.effect.value, fetchImpl) : pending.effect.case === "persistBornCustody" ? create(PeerEffectReceiptSchema, {
30957
30963
  effectId: pending.effect.value.effectId,
30958
30964
  outcome: {
30959
30965
  case: "bornCustodyPersisted",
@@ -30981,7 +30987,7 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
30981
30987
  async function executeHistoryAcquisitionEffect(effect, custody) {
30982
30988
  try {
30983
30989
  if (!custody.advanceHistory) throw new Error("platform shell has no history acquisition capability");
30984
- const progress = await custody.advanceHistory(effect.workspace);
30990
+ const progress = await custody.advanceHistory(effect.workspace, effect.credentialCapability);
30985
30991
  return create(PeerEffectReceiptSchema, {
30986
30992
  effectId: effect.effectId,
30987
30993
  outcome: {
@@ -31212,7 +31218,7 @@ var targetOf = (frame) => {
31212
31218
  };
31213
31219
  };
31214
31220
  function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, maintenanceSettled, postEvent2 = () => {
31215
- }, credentialRefresh, yieldWakeToCaller = false, deviceIdentity, lawPackage) {
31221
+ }, credentialRefresh, yieldWakeToCaller = false, deviceIdentity, lawPackage, performExternalEffect) {
31216
31222
  let runner;
31217
31223
  const configuredOrigins = new Set((shell.providerOrigins?.() ?? []).map((provider) => originOf(provider)).filter((origin2) => origin2 !== void 0));
31218
31224
  const permittedSocket = (url) => {
@@ -31221,10 +31227,10 @@ function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, mainten
31221
31227
  return origin2 !== void 0 && configuredOrigins.has(origin2);
31222
31228
  };
31223
31229
  const sockets = socketEffects(
31224
- (frame) => drivePeerFrame(runner, frame, fetchImpl, shell.custodyPort(), void 0, void 0, false, deviceIdentity, lawPackage),
31230
+ (frame) => drivePeerFrame(runner, frame, fetchImpl, shell.custodyPort(), void 0, void 0, false, deviceIdentity, lawPackage, false, false, performExternalEffect),
31225
31231
  permittedSocket
31226
31232
  );
31227
- const credentials = credentialEffects((frame) => drivePeerFrame(runner, frame, fetchImpl, shell.custodyPort(), void 0, credentialRefresh, false, deviceIdentity, lawPackage), credentialRefresh);
31233
+ const credentials = credentialEffects((frame) => drivePeerFrame(runner, frame, fetchImpl, shell.custodyPort(), void 0, credentialRefresh, false, deviceIdentity, lawPackage, false, false, performExternalEffect), credentialRefresh);
31228
31234
  runner = createPeerOfficeFrameRunner(
31229
31235
  kernel,
31230
31236
  shell.credentials(),
@@ -31249,7 +31255,10 @@ function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, mainten
31249
31255
  credentialRefresh,
31250
31256
  false,
31251
31257
  deviceIdentity,
31252
- lawPackage
31258
+ lawPackage,
31259
+ false,
31260
+ false,
31261
+ performExternalEffect
31253
31262
  );
31254
31263
  },
31255
31264
  shell.peerDeskStore()
@@ -31301,7 +31310,10 @@ function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, mainten
31301
31310
  credentialRefresh,
31302
31311
  yieldWakeToCaller,
31303
31312
  deviceIdentity,
31304
- lawPackage
31313
+ lawPackage,
31314
+ false,
31315
+ false,
31316
+ performExternalEffect
31305
31317
  );
31306
31318
  },
31307
31319
  settleRetention: (withinMillis) => runner.settleRetention(withinMillis),