githolon 0.108.3 → 0.108.6

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.
@@ -394,6 +394,16 @@ function prepareManagedPromotion(report, candidateHash, domain, opts = {}) {
394
394
  error: `the package-wide report does not cover the generated business area '${domain}'`
395
395
  };
396
396
  }
397
+ const dispositions = report.dispositions;
398
+ const changesStableIdentity = dispositions !== void 0 && (dispositions.retired.length > 0 || Object.keys(dispositions.retyped).length > 0 || Object.keys(dispositions.rebinds).length > 0);
399
+ if (changesStableIdentity && !acceptanceReason) {
400
+ return {
401
+ ok: false,
402
+ stage: "acceptance",
403
+ report,
404
+ error: "the current-frontier transition changes stable business identities and needs an attributed acceptance reason"
405
+ };
406
+ }
397
407
  const preflight = {
398
408
  candidateHash,
399
409
  // A package may be reached through any one of its generated domain clients. The
@@ -1548,7 +1558,7 @@ var init_lifecycle_calls = __esm({
1548
1558
 
1549
1559
  // vendor/engine/proto/nomos/kernel/v1/kernel_pb.js
1550
1560
  import { enumDesc, fileDesc, messageDesc, serviceDesc, tsEnum } from "@bufbuild/protobuf/codegenv2";
1551
- var file_nomos_kernel_v1_kernel, CallRequestSchema, CallResponseSchema, PrepareRemoteOfferRequestSchema, PrepareRemoteOfferResponseSchema, ApplyWorkspaceEffectRequestSchema, ApplyWorkspaceEffectResponseSchema, WorkspaceTargetSchema, InitializeWorkspaceRequestSchema, DirectiveCallSchema, AuthoringOptionsSchema, CapturedClockSchema, BirthCertificateSchema, SignBirthCertificateRequestSchema, OfferRequestSchema, QueryRequestSchema, QueryAuthoritySchema, InjectedKeySchema, RowsQuerySchema, PageQuerySchema, ByIdQuerySchema, ByTypeQuerySchema, TallyQuerySchema, SpatialQuerySchema, PendingConflictsQuerySchema, PendingConflictSummaryQuerySchema, NamedQuerySchema, FrontierTransitionRequestSchema, AuthorizationObjectSchema, AuthorizationSubjectSchema, AuthorizationConsistencySchema, AuthorizationCheckRequestSchema, AuthorizationExpandRequestSchema, OutboxRequestSchema, SyncRequestSchema, TestRequestSchema, SetTestRootRequestSchema, CustodyRequestSchema, ResidentFootprintRequestSchema, PackDeltaRequestSchema, ApplyPackRequestSchema, RepoStatsRequestSchema, IntentsAboveRequestSchema, InspectChangeRequestSchema, RefusalVerdictSchema, EncodeRefusalVerdictRequestSchema, InspectRefusalVerdictRequestSchema, ProveCompactionEquivalenceRequestSchema, ReadBlobRequestSchema, ResolveRefRequestSchema, ListRefsRequestSchema, WriteRefRequestSchema, DeleteRefRequestSchema, WriteMetaCommitRequestSchema, LawClosureInfoRequestSchema, CheckpointExportRequestSchema, VerifiedFrontierReceiptSchema, StoredCheckpointManifestSchema, CheckpointImportRequestSchema, CapacityReserveRequestSchema, RestoreMainRequestSchema, ResolveStatePositionRequestSchema, NomosValueSchema, NomosStructSchema, BirthOutcomeStatusSchema, BirthOutcomeStatus, QueryResultFormatSchema, QueryResultFormat, QueryOperationSchema, QueryOperation, KernelLawCapabilitySchema, KernelLawCapability, CheckpointCompressionSchema, CheckpointCompression, CheckpointVerificationPolicySchema, CheckpointVerificationPolicy, CheckpointAssuranceSchema, CheckpointAssurance, IntentTransportRequirementSchema, IntentTransportRequirement, LifecycleInstallPhaseSchema, LifecycleInstallPhase;
1561
+ var file_nomos_kernel_v1_kernel, CallRequestSchema, CallResponseSchema, PrepareRemoteOfferRequestSchema, PrepareRemoteOfferResponseSchema, ApplyWorkspaceEffectRequestSchema, ApplyWorkspaceEffectResponseSchema, WorkspaceTargetSchema, InitializeWorkspaceRequestSchema, DirectiveCallSchema, AuthoringOptionsSchema, CapturedClockSchema, BirthCertificateSchema, SignBirthCertificateRequestSchema, ModelLifecycleIntentSchema, OfferRequestSchema, QueryRequestSchema, QueryAuthoritySchema, InjectedKeySchema, RowsQuerySchema, PageQuerySchema, ByIdQuerySchema, ByTypeQuerySchema, TallyQuerySchema, SpatialQuerySchema, PendingConflictsQuerySchema, PendingConflictSummaryQuerySchema, NamedQuerySchema, FrontierTransitionRequestSchema, FrontierTransitionDispositionMapEntrySchema, FrontierTransitionDispositionsSchema, FrontierTransitionViolationSchema, FrontierTransitionResponseSchema, AuthorizationObjectSchema, AuthorizationSubjectSchema, AuthorizationConsistencySchema, AuthorizationCheckRequestSchema, AuthorizationExpandRequestSchema, OutboxRequestSchema, SyncRequestSchema, TestRequestSchema, SetTestRootRequestSchema, CustodyRequestSchema, ResidentFootprintRequestSchema, PackDeltaRequestSchema, ApplyPackRequestSchema, RepoStatsRequestSchema, IntentsAboveRequestSchema, InspectChangeRequestSchema, RefusalVerdictSchema, EncodeRefusalVerdictRequestSchema, InspectRefusalVerdictRequestSchema, ProveCompactionEquivalenceRequestSchema, ReadBlobRequestSchema, ResolveRefRequestSchema, ListRefsRequestSchema, WriteRefRequestSchema, DeleteRefRequestSchema, WriteMetaCommitRequestSchema, LawClosureInfoRequestSchema, CheckpointExportRequestSchema, VerifiedFrontierReceiptSchema, StoredCheckpointManifestSchema, CheckpointImportRequestSchema, CapacityReserveRequestSchema, RestoreMainRequestSchema, ResolveStatePositionRequestSchema, NomosValueSchema, NomosStructSchema, BirthOutcomeStatusSchema, BirthOutcomeStatus, ModelLifecycleOperationSchema, ModelLifecycleOperation, QueryResultFormatSchema, QueryResultFormat, QueryOperationSchema, QueryOperation, KernelLawCapabilitySchema, KernelLawCapability, CheckpointCompressionSchema, CheckpointCompression, CheckpointVerificationPolicySchema, CheckpointVerificationPolicy, CheckpointAssuranceSchema, CheckpointAssurance, IntentTransportRequirementSchema, IntentTransportRequirement, LifecycleInstallPhaseSchema, LifecycleInstallPhase;
1552
1562
  var init_kernel_pb = __esm({
1553
1563
  "vendor/engine/proto/nomos/kernel/v1/kernel_pb.js"() {
1554
1564
  "use strict";
@@ -1566,6 +1576,7 @@ var init_kernel_pb = __esm({
1566
1576
  CapturedClockSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 49);
1567
1577
  BirthCertificateSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 50);
1568
1578
  SignBirthCertificateRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 51);
1579
+ ModelLifecycleIntentSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 53);
1569
1580
  OfferRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 54);
1570
1581
  QueryRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 57);
1571
1582
  QueryAuthoritySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 64);
@@ -1580,6 +1591,10 @@ var init_kernel_pb = __esm({
1580
1591
  PendingConflictSummaryQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 77);
1581
1592
  NamedQuerySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 78);
1582
1593
  FrontierTransitionRequestSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 79);
1594
+ FrontierTransitionDispositionMapEntrySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 80);
1595
+ FrontierTransitionDispositionsSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 81);
1596
+ FrontierTransitionViolationSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 82);
1597
+ FrontierTransitionResponseSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 83);
1583
1598
  AuthorizationObjectSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 84);
1584
1599
  AuthorizationSubjectSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 85);
1585
1600
  AuthorizationConsistencySchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 87);
@@ -1618,6 +1633,8 @@ var init_kernel_pb = __esm({
1618
1633
  NomosStructSchema = /* @__PURE__ */ messageDesc(file_nomos_kernel_v1_kernel, 166);
1619
1634
  BirthOutcomeStatusSchema = /* @__PURE__ */ enumDesc(file_nomos_kernel_v1_kernel, 0);
1620
1635
  BirthOutcomeStatus = /* @__PURE__ */ tsEnum(BirthOutcomeStatusSchema);
1636
+ ModelLifecycleOperationSchema = /* @__PURE__ */ enumDesc(file_nomos_kernel_v1_kernel, 3);
1637
+ ModelLifecycleOperation = /* @__PURE__ */ tsEnum(ModelLifecycleOperationSchema);
1621
1638
  QueryResultFormatSchema = /* @__PURE__ */ enumDesc(file_nomos_kernel_v1_kernel, 5);
1622
1639
  QueryResultFormat = /* @__PURE__ */ tsEnum(QueryResultFormatSchema);
1623
1640
  QueryOperationSchema = /* @__PURE__ */ enumDesc(file_nomos_kernel_v1_kernel, 6);
@@ -1712,6 +1729,17 @@ var init_offer_result = __esm({
1712
1729
  }
1713
1730
  });
1714
1731
 
1732
+ // vendor/engine/proto/nomos/custody/v1/snapshot_pb.js
1733
+ import { fileDesc as fileDesc2, messageDesc as messageDesc2 } from "@bufbuild/protobuf/codegenv2";
1734
+ var file_nomos_custody_v1_snapshot, LocalCustodySnapshotSchema;
1735
+ var init_snapshot_pb = __esm({
1736
+ "vendor/engine/proto/nomos/custody/v1/snapshot_pb.js"() {
1737
+ "use strict";
1738
+ file_nomos_custody_v1_snapshot = /* @__PURE__ */ fileDesc2("Ch9ub21vcy9jdXN0b2R5L3YxL3NuYXBzaG90LnByb3RvEhBub21vcy5jdXN0b2R5LnYxIqACChRMb2NhbEN1c3RvZHlTbmFwc2hvdBIWCg5mb3JtYXRfdmVyc2lvbhgBIAEoDRIWCgl3b3Jrc3BhY2UYAiABKAlIAIgBARIMCgR0cmVlGAMgASgMEhcKCmNoZWNrcG9pbnQYBCABKAxIAYgBARIVCghmcm9udGllchgFIAEoDEgCiAEBEhMKBmN1cnNvchgGIAEoCUgDiAEBEhcKCnN0YXRlX3Jvb3QYByABKAlIBIgBARIYCgtzeW5jZWRfYmFzZRgIIAEoCUgFiAEBQgwKCl93b3Jrc3BhY2VCDQoLX2NoZWNrcG9pbnRCCwoJX2Zyb250aWVyQgkKB19jdXJzb3JCDQoLX3N0YXRlX3Jvb3RCDgoMX3N5bmNlZF9iYXNlYgZwcm90bzM");
1739
+ LocalCustodySnapshotSchema = /* @__PURE__ */ messageDesc2(file_nomos_custody_v1_snapshot, 0);
1740
+ }
1741
+ });
1742
+
1715
1743
  // vendor/engine/engine.ts
1716
1744
  var engine_exports = {};
1717
1745
  __export(engine_exports, {
@@ -1727,6 +1755,8 @@ __export(engine_exports, {
1727
1755
  author: () => author,
1728
1756
  authorEphemeral: () => authorEphemeral,
1729
1757
  authorKeygen: () => authorKeygen,
1758
+ authorModelLifecyclePromotion: () => authorModelLifecyclePromotion,
1759
+ authorModelLifecycleStage: () => authorModelLifecycleStage,
1730
1760
  authorOn: () => authorOn,
1731
1761
  authorOperatorCall: () => authorOperatorCall,
1732
1762
  backupHead: () => backupHead,
@@ -1799,6 +1829,7 @@ __export(engine_exports, {
1799
1829
  lawParity: () => lawParity,
1800
1830
  ledgerStats: () => ledgerStats,
1801
1831
  listRefusedRefs: () => listRefusedRefs,
1832
+ localCustodySnapshot: () => localCustodySnapshot,
1802
1833
  materializeRefused: () => materializeRefused,
1803
1834
  memoryDropProbe: () => memoryDropProbe,
1804
1835
  migrateHomes: () => migrateHomes,
@@ -2179,6 +2210,100 @@ function workspaceGenesis(eng, ws) {
2179
2210
  function authorOperatorCall(eng, ws, call, controllerHash, opts = {}) {
2180
2211
  return author(eng, ws, call.domain, call.directive, call.canonicalUsda, controllerHash, opts);
2181
2212
  }
2213
+ function authorModelLifecycleStage(eng, ws, lawUsdz, installedBy, supersedes, opts = {}) {
2214
+ const sequence = eng.seq++;
2215
+ const captured = {
2216
+ physical: Date.now(),
2217
+ logical: 0,
2218
+ replica: eng.replica
2219
+ };
2220
+ const response = offerRequestResponse(eng, create(OfferRequestSchema, {
2221
+ target: protoTarget(ws),
2222
+ intent: {
2223
+ case: "modelLifecycle",
2224
+ value: create(ModelLifecycleIntentSchema, {
2225
+ operation: ModelLifecycleOperation.STAGE,
2226
+ installedBy,
2227
+ supersedes
2228
+ })
2229
+ },
2230
+ authoring: create(AuthoringOptionsSchema, {
2231
+ actor: opts.actor ?? "",
2232
+ authToken: opts.authToken ? enc3.encode(opts.authToken) : new Uint8Array(),
2233
+ authorSecret: opts.authorSecret ? bytesFromB64(opts.authorSecret) : new Uint8Array(),
2234
+ validFromEpoch: opts.validFromEpoch === void 0 ? void 0 : BigInt(opts.validFromEpoch),
2235
+ rng: osEntropyBuffer(opts.rngDraws ?? 64),
2236
+ deferProjection: opts.deferProjection !== false,
2237
+ spans: opts.spans ?? false,
2238
+ sequence: BigInt(sequence),
2239
+ clock: create(CapturedClockSchema, {
2240
+ physicalMillis: BigInt(captured.physical),
2241
+ logical: captured.logical,
2242
+ replica: BigInt(captured.replica)
2243
+ })
2244
+ }),
2245
+ lawUsdz
2246
+ }));
2247
+ return offerResult(response);
2248
+ }
2249
+ function authorModelLifecyclePromotion(eng, ws, transition, replaces, acceptanceReason, opts = {}) {
2250
+ const sequence = eng.seq++;
2251
+ const captured = {
2252
+ physical: Date.now(),
2253
+ logical: 0,
2254
+ replica: eng.replica
2255
+ };
2256
+ const dispositions = transition.dispositions === void 0 ? void 0 : create(FrontierTransitionDispositionsSchema, {
2257
+ retired: [...transition.dispositions.retired],
2258
+ retyped: Object.entries(transition.dispositions.retyped).map(
2259
+ ([sourceStableId, acknowledgement]) => create(FrontierTransitionDispositionMapEntrySchema, { sourceStableId, acknowledgement })
2260
+ ),
2261
+ rebinds: Object.entries(transition.dispositions.rebinds).map(
2262
+ ([sourceStableId, acknowledgement]) => create(FrontierTransitionDispositionMapEntrySchema, { sourceStableId, acknowledgement })
2263
+ ),
2264
+ acknowledgedBy: transition.dispositions.ackBy
2265
+ });
2266
+ const response = offerRequestResponse(eng, create(OfferRequestSchema, {
2267
+ target: protoTarget(ws),
2268
+ intent: {
2269
+ case: "modelLifecycle",
2270
+ value: create(ModelLifecycleIntentSchema, {
2271
+ operation: ModelLifecycleOperation.PROMOTE,
2272
+ replaces,
2273
+ acceptanceReason,
2274
+ transition: create(FrontierTransitionResponseSchema, {
2275
+ atHash: transition.atHash,
2276
+ currentHash: transition.currentHash,
2277
+ atStateRoot: transition.atStateRoot ?? "",
2278
+ candidateHash: transition.candidateHash,
2279
+ domain: transition.domain,
2280
+ domains: [...transition.domains ?? []],
2281
+ ready: transition.ready,
2282
+ violations: transition.evolve.violations.map(
2283
+ ({ domain, detail }) => create(FrontierTransitionViolationSchema, { domain, detail })
2284
+ ),
2285
+ dispositions
2286
+ })
2287
+ })
2288
+ },
2289
+ authoring: create(AuthoringOptionsSchema, {
2290
+ actor: opts.actor ?? "",
2291
+ authToken: opts.authToken ? enc3.encode(opts.authToken) : new Uint8Array(),
2292
+ authorSecret: opts.authorSecret ? bytesFromB64(opts.authorSecret) : new Uint8Array(),
2293
+ validFromEpoch: opts.validFromEpoch === void 0 ? void 0 : BigInt(opts.validFromEpoch),
2294
+ rng: osEntropyBuffer(opts.rngDraws ?? 64),
2295
+ deferProjection: opts.deferProjection !== false,
2296
+ spans: opts.spans ?? false,
2297
+ sequence: BigInt(sequence),
2298
+ clock: create(CapturedClockSchema, {
2299
+ physicalMillis: BigInt(captured.physical),
2300
+ logical: captured.logical,
2301
+ replica: BigInt(captured.replica)
2302
+ })
2303
+ })
2304
+ }));
2305
+ return offerResult(response);
2306
+ }
2182
2307
  function initializeWorkspace(eng, ws, installedBy = eng.installedBy) {
2183
2308
  const sequence = eng.seq++;
2184
2309
  const captured = {
@@ -3279,8 +3404,11 @@ async function reconcileRequiredCustodyHead(eng, ws, ledger, requiredCustodyHead
3279
3404
  if (!/^[0-9a-f]{40}$/.test(requiredCustodyHead)) {
3280
3405
  throw new Error("required custody head must be a lowercase 40-hex git object id");
3281
3406
  }
3282
- const current = eng.mounted.has(ws) ? kgit.resolveRef(eng, gitdirOf(ws), BRANCH) : "";
3283
- if (current === requiredCustodyHead) return eng.mounted.get(ws);
3407
+ const resident = eng.mounted.get(ws);
3408
+ const current = resident ? kgit.resolveRef(eng, gitdirOf(ws), BRANCH) : "";
3409
+ if (current === requiredCustodyHead && resident?.remoteMain === requiredCustodyHead && !resident.restoreError) {
3410
+ return resident;
3411
+ }
3284
3412
  if (current && isDirty(eng, ws)) {
3285
3413
  throw new Error(
3286
3414
  `workspace '${ws}' has verified but unsealed resident work; refusing to discard it while reconciling custody`
@@ -3293,6 +3421,12 @@ async function reconcileRequiredCustodyHead(eng, ws, ledger, requiredCustodyHead
3293
3421
  `workspace '${ws}' could not reconcile required custody ${requiredCustodyHead}: ${mounted.restoreError || "custody has no verified main"}`
3294
3422
  );
3295
3423
  }
3424
+ const reconciled = kgit.resolveRef(eng, gitdirOf(ws), BRANCH);
3425
+ if (reconciled !== requiredCustodyHead || mounted.remoteMain !== requiredCustodyHead) {
3426
+ throw new Error(
3427
+ `workspace '${ws}' restored custody ${mounted.remoteMain || reconciled || "none"}, not required custody ${requiredCustodyHead}`
3428
+ );
3429
+ }
3296
3430
  return mounted;
3297
3431
  }
3298
3432
  function assertAuthored(res, what) {
@@ -3430,7 +3564,10 @@ async function applyWorkspaceEffect(eng, ws, ledger, requestBytes, admissionChec
3430
3564
  const result = response.outcome.value.result;
3431
3565
  if (!result || result.outcome.case !== "admitted") {
3432
3566
  const outcome = result?.outcome.case || "empty";
3433
- throw new Error(`target kernel ${outcome} the workspace effect`);
3567
+ const detail = result?.outcome.case === "refused" ? result.outcome.value.refusal?.message : void 0;
3568
+ throw new Error(
3569
+ `target kernel ${outcome} the workspace effect${detail ? `: ${detail}` : ""}`
3570
+ );
3434
3571
  }
3435
3572
  await custodyPush(eng, ws, ledger, { remoteRef: "refs/heads/main", ffOnly: true });
3436
3573
  return toBinary(ApplyWorkspaceEffectResponseSchema, response.outcome.value);
@@ -3541,8 +3678,8 @@ function prepareRemoteOffer(eng, ws, requestBytes) {
3541
3678
  if (authoring.authorSecret.byteLength !== 0) {
3542
3679
  throw new Error("remote offer preparation refuses client signing secrets");
3543
3680
  }
3544
- if (request.intent.case !== "call") {
3545
- throw new Error("remote offer preparation requires a typed directive call");
3681
+ if (request.intent.case !== "call" && request.intent.case !== "modelLifecycle") {
3682
+ throw new Error("remote offer preparation requires a typed directive or model-lifecycle call");
3546
3683
  }
3547
3684
  const response = callProto(eng.ex, {
3548
3685
  case: "prepareRemoteOffer",
@@ -4008,7 +4145,13 @@ function packDelta(eng, ws, base, head) {
4008
4145
  case: "packDelta",
4009
4146
  value: create(PackDeltaRequestSchema, { repo: repoArgOf(ws), base: base || void 0, head })
4010
4147
  }, "packDelta").pack;
4011
- } catch {
4148
+ } catch (error) {
4149
+ console.error("[nomos-custody-pack] packDelta refused", {
4150
+ workspace: ws,
4151
+ base: base || "<full>",
4152
+ head,
4153
+ error: String(error)
4154
+ });
4012
4155
  return null;
4013
4156
  }
4014
4157
  }
@@ -4690,11 +4833,12 @@ function promotePreflighted(eng, ws, domain, candidateHash, opts = {}) {
4690
4833
  acceptanceReason: _acceptance,
4691
4834
  ...authorOpts
4692
4835
  } = opts;
4693
- const result = authorOperatorCall(
4836
+ const result = authorModelLifecyclePromotion(
4694
4837
  eng,
4695
4838
  ws,
4696
- promoteDomainCall(ws, prepared.payload),
4697
- requireCurrentControllerLawHash(eng, ws),
4839
+ report,
4840
+ prepared.payload.replaces,
4841
+ prepared.payload.preflight.acceptanceReason,
4698
4842
  {
4699
4843
  ...authorOpts,
4700
4844
  ...actingPrincipal ? { actor: actingPrincipal } : {}
@@ -5184,7 +5328,10 @@ async function emitOutbox(eng, ws, ledger, workspaceEffectBase = "", admissionCh
5184
5328
  const targetResult = response.result;
5185
5329
  if (!targetResult || targetResult.outcome.case !== "admitted") {
5186
5330
  const outcome = targetResult?.outcome.case || "empty";
5187
- throw new Error(`target kernel ${outcome} the workspace effect`);
5331
+ const detail = targetResult?.outcome.case === "refused" ? targetResult.outcome.value.refusal?.message : void 0;
5332
+ throw new Error(
5333
+ `target kernel ${outcome} the workspace effect${detail ? `: ${detail}` : ""}`
5334
+ );
5188
5335
  }
5189
5336
  break;
5190
5337
  }
@@ -5216,7 +5363,7 @@ async function emitOutbox(eng, ws, ledger, workspaceEffectBase = "", admissionCh
5216
5363
  } catch (e) {
5217
5364
  errors++;
5218
5365
  const destination = offer.route.case === "httpsRoute" ? offer.route.value.url : offer.route.case === "workspaceRoute" ? offer.route.value.workspace : offer.destination;
5219
- log("outbox-deliver-failed", { ws, offerId: offer.id, destination, error: String(e).slice(0, 200) });
5366
+ log("outbox-deliver-failed", { ws, offerId: offer.id, destination, error: String(e).slice(0, 2e3) });
5220
5367
  }
5221
5368
  }
5222
5369
  if (delivered.length || errors) log("outbox", { ws, delivered: delivered.length, errors });
@@ -5247,6 +5394,26 @@ function snapshot(eng, ws) {
5247
5394
  const wsDir = dirOf(eng.preopen.dir.contents.get("ws")).contents.get(ws);
5248
5395
  return serializeTree(wsDir);
5249
5396
  }
5397
+ function localCustodySnapshot(eng, ws) {
5398
+ const checkpoint = exportCheckpoint(eng, ws);
5399
+ const tree = snapshot(eng, ws);
5400
+ const head = headOf(eng, ws);
5401
+ const body = toBinary(LocalCustodySnapshotSchema, create(LocalCustodySnapshotSchema, {
5402
+ formatVersion: 3,
5403
+ workspace: ws,
5404
+ tree,
5405
+ checkpoint: checkpoint.blob ? bytesFromB64(checkpoint.blob) : void 0,
5406
+ frontier: checkpoint.frontier ? bytesFromB64(checkpoint.frontier) : void 0,
5407
+ cursor: checkpoint.cursor === void 0 ? void 0 : String(checkpoint.cursor),
5408
+ stateRoot: checkpoint.stateRoot,
5409
+ syncedBase: head || void 0
5410
+ }));
5411
+ const prefix = enc3.encode("NOMOS-CUSTODY-PB3\n");
5412
+ const framed = new Uint8Array(prefix.byteLength + body.byteLength);
5413
+ framed.set(prefix);
5414
+ framed.set(body, prefix.byteLength);
5415
+ return framed;
5416
+ }
5250
5417
  function stats(eng) {
5251
5418
  return {
5252
5419
  mounted: eng.mounted.size,
@@ -5323,6 +5490,7 @@ var init_engine = __esm({
5323
5490
  init_lifecycle_calls();
5324
5491
  init_offer_result();
5325
5492
  init_kernel_pb();
5493
+ init_snapshot_pb();
5326
5494
  enc3 = new TextEncoder();
5327
5495
  dec3 = new TextDecoder();
5328
5496
  BRANCH = "main";