@origintrail-official/dkg-agent 10.0.21 → 10.0.23

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.
Files changed (207) hide show
  1. package/dist/approved-private-replica-proof-runs.d.ts +40 -0
  2. package/dist/approved-private-replica-proof-runs.d.ts.map +1 -0
  3. package/dist/approved-private-replica-proof-runs.js +49 -0
  4. package/dist/approved-private-replica-proof-runs.js.map +1 -0
  5. package/dist/approved-private-replica.d.ts +18 -1
  6. package/dist/approved-private-replica.d.ts.map +1 -1
  7. package/dist/approved-private-replica.js +9 -3
  8. package/dist/approved-private-replica.js.map +1 -1
  9. package/dist/context-graph-chain-discovery-binding.d.ts +2 -0
  10. package/dist/context-graph-chain-discovery-binding.d.ts.map +1 -1
  11. package/dist/context-graph-chain-discovery-binding.js +7 -0
  12. package/dist/context-graph-chain-discovery-binding.js.map +1 -1
  13. package/dist/context-graph-dormant-identity.d.ts +8 -0
  14. package/dist/context-graph-dormant-identity.d.ts.map +1 -0
  15. package/dist/context-graph-dormant-identity.js +48 -0
  16. package/dist/context-graph-dormant-identity.js.map +1 -0
  17. package/dist/context-graph-meta-projection.d.ts +19 -55
  18. package/dist/context-graph-meta-projection.d.ts.map +1 -1
  19. package/dist/context-graph-meta-projection.js +94 -46
  20. package/dist/context-graph-meta-projection.js.map +1 -1
  21. package/dist/context-graph-name-binding-target.d.ts +21 -0
  22. package/dist/context-graph-name-binding-target.d.ts.map +1 -0
  23. package/dist/context-graph-name-binding-target.js +68 -0
  24. package/dist/context-graph-name-binding-target.js.map +1 -0
  25. package/dist/context-graph-persisted-name-aliases.d.ts +47 -0
  26. package/dist/context-graph-persisted-name-aliases.d.ts.map +1 -0
  27. package/dist/context-graph-persisted-name-aliases.js +173 -0
  28. package/dist/context-graph-persisted-name-aliases.js.map +1 -0
  29. package/dist/context-graph-read-authority.d.ts +26 -11
  30. package/dist/context-graph-read-authority.d.ts.map +1 -1
  31. package/dist/context-graph-read-authority.js +26 -2
  32. package/dist/context-graph-read-authority.js.map +1 -1
  33. package/dist/context-graph-subscription-authority-recovery.d.ts +4 -0
  34. package/dist/context-graph-subscription-authority-recovery.d.ts.map +1 -1
  35. package/dist/context-graph-subscription-authority-recovery.js +8 -2
  36. package/dist/context-graph-subscription-authority-recovery.js.map +1 -1
  37. package/dist/context-graph-subscription-policy.d.ts +34 -1
  38. package/dist/context-graph-subscription-policy.d.ts.map +1 -1
  39. package/dist/context-graph-subscription-policy.js +143 -1
  40. package/dist/context-graph-subscription-policy.js.map +1 -1
  41. package/dist/curator-meta-refresh.d.ts.map +1 -1
  42. package/dist/curator-meta-refresh.js +31 -9
  43. package/dist/curator-meta-refresh.js.map +1 -1
  44. package/dist/dkg-agent-base.d.ts.map +1 -1
  45. package/dist/dkg-agent-base.js +0 -1
  46. package/dist/dkg-agent-base.js.map +1 -1
  47. package/dist/dkg-agent-cg-name-resolution.d.ts +6 -24
  48. package/dist/dkg-agent-cg-name-resolution.d.ts.map +1 -1
  49. package/dist/dkg-agent-cg-name-resolution.js +42 -58
  50. package/dist/dkg-agent-cg-name-resolution.js.map +1 -1
  51. package/dist/dkg-agent-cg-on-chain-id.d.ts +3 -3
  52. package/dist/dkg-agent-cg-on-chain-id.d.ts.map +1 -1
  53. package/dist/dkg-agent-cg-on-chain-id.js +7 -23
  54. package/dist/dkg-agent-cg-on-chain-id.js.map +1 -1
  55. package/dist/dkg-agent-cg-registry.d.ts +7 -3
  56. package/dist/dkg-agent-cg-registry.d.ts.map +1 -1
  57. package/dist/dkg-agent-cg-registry.js +30 -16
  58. package/dist/dkg-agent-cg-registry.js.map +1 -1
  59. package/dist/dkg-agent-cg-resolve.d.ts +10 -6
  60. package/dist/dkg-agent-cg-resolve.d.ts.map +1 -1
  61. package/dist/dkg-agent-cg-resolve.js +16 -19
  62. package/dist/dkg-agent-cg-resolve.js.map +1 -1
  63. package/dist/dkg-agent-context-graph.d.ts.map +1 -1
  64. package/dist/dkg-agent-context-graph.js +0 -4
  65. package/dist/dkg-agent-context-graph.js.map +1 -1
  66. package/dist/dkg-agent-crypto.d.ts.map +1 -1
  67. package/dist/dkg-agent-crypto.js +53 -57
  68. package/dist/dkg-agent-crypto.js.map +1 -1
  69. package/dist/dkg-agent-lifecycle.d.ts +5 -0
  70. package/dist/dkg-agent-lifecycle.d.ts.map +1 -1
  71. package/dist/dkg-agent-lifecycle.js +156 -133
  72. package/dist/dkg-agent-lifecycle.js.map +1 -1
  73. package/dist/dkg-agent-publish.d.ts.map +1 -1
  74. package/dist/dkg-agent-publish.js +2 -3
  75. package/dist/dkg-agent-publish.js.map +1 -1
  76. package/dist/dkg-agent-query.d.ts.map +1 -1
  77. package/dist/dkg-agent-query.js +12 -9
  78. package/dist/dkg-agent-query.js.map +1 -1
  79. package/dist/dkg-agent-registered-private-empty-vm.d.ts +8 -0
  80. package/dist/dkg-agent-registered-private-empty-vm.d.ts.map +1 -1
  81. package/dist/dkg-agent-registered-private-empty-vm.js +15 -0
  82. package/dist/dkg-agent-registered-private-empty-vm.js.map +1 -1
  83. package/dist/dkg-agent-rfc64-catalog-auto-publish.d.ts.map +1 -1
  84. package/dist/dkg-agent-rfc64-catalog-auto-publish.js +4 -0
  85. package/dist/dkg-agent-rfc64-catalog-auto-publish.js.map +1 -1
  86. package/dist/dkg-agent-rfc64-catalog-upsert.d.ts.map +1 -1
  87. package/dist/dkg-agent-rfc64-catalog-upsert.js +7 -0
  88. package/dist/dkg-agent-rfc64-catalog-upsert.js.map +1 -1
  89. package/dist/dkg-agent-rfc64-catalog.d.ts +4 -0
  90. package/dist/dkg-agent-rfc64-catalog.d.ts.map +1 -1
  91. package/dist/dkg-agent-rfc64-catalog.js +12 -2
  92. package/dist/dkg-agent-rfc64-catalog.js.map +1 -1
  93. package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.d.ts +2 -1
  94. package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.d.ts.map +1 -1
  95. package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.js +23 -15
  96. package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.js.map +1 -1
  97. package/dist/dkg-agent-rfc64-swm-catalog-projection.d.ts.map +1 -1
  98. package/dist/dkg-agent-rfc64-swm-catalog-projection.js +3 -0
  99. package/dist/dkg-agent-rfc64-swm-catalog-projection.js.map +1 -1
  100. package/dist/dkg-agent-swm-host.d.ts +13 -22
  101. package/dist/dkg-agent-swm-host.d.ts.map +1 -1
  102. package/dist/dkg-agent-swm-host.js +179 -81
  103. package/dist/dkg-agent-swm-host.js.map +1 -1
  104. package/dist/dkg-agent-swm-substrate.d.ts +2 -0
  105. package/dist/dkg-agent-swm-substrate.d.ts.map +1 -1
  106. package/dist/dkg-agent-swm-substrate.js +5 -9
  107. package/dist/dkg-agent-swm-substrate.js.map +1 -1
  108. package/dist/dkg-agent-types.d.ts +3 -2
  109. package/dist/dkg-agent-types.d.ts.map +1 -1
  110. package/dist/dkg-agent.d.ts +4 -10
  111. package/dist/dkg-agent.d.ts.map +1 -1
  112. package/dist/dkg-agent.js +43 -58
  113. package/dist/dkg-agent.js.map +1 -1
  114. package/dist/index.d.ts +1 -1
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js.map +1 -1
  117. package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.d.ts +6 -1
  118. package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.d.ts.map +1 -1
  119. package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.js +5 -5
  120. package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.js.map +1 -1
  121. package/dist/internal/context-graph-authority/context-graph-authority.d.ts +14 -1
  122. package/dist/internal/context-graph-authority/context-graph-authority.d.ts.map +1 -1
  123. package/dist/internal/context-graph-authority/context-graph-authority.js +19 -0
  124. package/dist/internal/context-graph-authority/context-graph-authority.js.map +1 -1
  125. package/dist/internal/context-graph-cache-invalidating-store.d.ts +10 -2
  126. package/dist/internal/context-graph-cache-invalidating-store.d.ts.map +1 -1
  127. package/dist/internal/context-graph-cache-invalidating-store.js +67 -67
  128. package/dist/internal/context-graph-cache-invalidating-store.js.map +1 -1
  129. package/dist/internal/context-graph-meta-record-copy.d.ts +1 -1
  130. package/dist/internal/context-graph-meta-record-copy.d.ts.map +1 -1
  131. package/dist/internal/context-graph-meta-record.d.ts +40 -0
  132. package/dist/internal/context-graph-meta-record.d.ts.map +1 -0
  133. package/dist/internal/context-graph-meta-record.js +3 -0
  134. package/dist/internal/context-graph-meta-record.js.map +1 -0
  135. package/dist/internal/peer-gate-revision.d.ts +28 -0
  136. package/dist/internal/peer-gate-revision.d.ts.map +1 -0
  137. package/dist/internal/peer-gate-revision.js +46 -0
  138. package/dist/internal/peer-gate-revision.js.map +1 -0
  139. package/dist/internal/projection-mutation-observer.d.ts +5 -0
  140. package/dist/internal/projection-mutation-observer.d.ts.map +1 -0
  141. package/dist/internal/projection-mutation-observer.js +24 -0
  142. package/dist/internal/projection-mutation-observer.js.map +1 -0
  143. package/dist/internal/promote/assertion-promote-precommit.d.ts +8 -6
  144. package/dist/internal/promote/assertion-promote-precommit.d.ts.map +1 -1
  145. package/dist/internal/promote/assertion-promote-precommit.js +8 -6
  146. package/dist/internal/promote/assertion-promote-precommit.js.map +1 -1
  147. package/dist/internal/recipient-key-route-fence.d.ts +57 -0
  148. package/dist/internal/recipient-key-route-fence.d.ts.map +1 -0
  149. package/dist/internal/recipient-key-route-fence.js +169 -0
  150. package/dist/internal/recipient-key-route-fence.js.map +1 -0
  151. package/dist/internal/store-mutation.d.ts +28 -0
  152. package/dist/internal/store-mutation.d.ts.map +1 -0
  153. package/dist/internal/store-mutation.js +3 -0
  154. package/dist/internal/store-mutation.js.map +1 -0
  155. package/dist/main-thread-time-slice.d.ts +19 -0
  156. package/dist/main-thread-time-slice.d.ts.map +1 -0
  157. package/dist/main-thread-time-slice.js +32 -0
  158. package/dist/main-thread-time-slice.js.map +1 -0
  159. package/dist/p2p/storage-ack-registrar.d.ts.map +1 -1
  160. package/dist/p2p/storage-ack-registrar.js +3 -5
  161. package/dist/p2p/storage-ack-registrar.js.map +1 -1
  162. package/dist/registered-context-graph-authority.d.ts +17 -0
  163. package/dist/registered-context-graph-authority.d.ts.map +1 -1
  164. package/dist/registered-private-empty-vm-attempt-v1.d.ts.map +1 -1
  165. package/dist/registered-private-empty-vm-attempt-v1.js +8 -4
  166. package/dist/registered-private-empty-vm-attempt-v1.js.map +1 -1
  167. package/dist/rfc64/catalog-repair-retry-v1.d.ts +9 -3
  168. package/dist/rfc64/catalog-repair-retry-v1.d.ts.map +1 -1
  169. package/dist/rfc64/catalog-repair-retry-v1.js +22 -6
  170. package/dist/rfc64/catalog-repair-retry-v1.js.map +1 -1
  171. package/dist/rfc64/control-envelope-signer-v1.d.ts +8 -0
  172. package/dist/rfc64/control-envelope-signer-v1.d.ts.map +1 -1
  173. package/dist/rfc64/control-envelope-signer-v1.js +20 -0
  174. package/dist/rfc64/control-envelope-signer-v1.js.map +1 -1
  175. package/dist/rfc64/legacy-swm-boundary-fence-v1.d.ts +109 -0
  176. package/dist/rfc64/legacy-swm-boundary-fence-v1.d.ts.map +1 -0
  177. package/dist/rfc64/legacy-swm-boundary-fence-v1.js +236 -0
  178. package/dist/rfc64/legacy-swm-boundary-fence-v1.js.map +1 -0
  179. package/dist/rfc64/legacy-swm-boundary-v1.d.ts +28 -1
  180. package/dist/rfc64/legacy-swm-boundary-v1.d.ts.map +1 -1
  181. package/dist/rfc64/legacy-swm-boundary-v1.js +74 -145
  182. package/dist/rfc64/legacy-swm-boundary-v1.js.map +1 -1
  183. package/dist/rfc64/public-catalog-successor-producer-v1.d.ts +2 -0
  184. package/dist/rfc64/public-catalog-successor-producer-v1.d.ts.map +1 -1
  185. package/dist/rfc64/public-catalog-successor-producer-v1.js +77 -33
  186. package/dist/rfc64/public-catalog-successor-producer-v1.js.map +1 -1
  187. package/dist/rfc64/public-catalog-successor-row-binding-v1.d.ts +16 -0
  188. package/dist/rfc64/public-catalog-successor-row-binding-v1.d.ts.map +1 -0
  189. package/dist/rfc64/public-catalog-successor-row-binding-v1.js +28 -0
  190. package/dist/rfc64/public-catalog-successor-row-binding-v1.js.map +1 -0
  191. package/dist/rfc64/swm-inventory-catalog-reconciler-v1.d.ts +6 -0
  192. package/dist/rfc64/swm-inventory-catalog-reconciler-v1.d.ts.map +1 -1
  193. package/dist/rfc64/swm-inventory-catalog-reconciler-v1.js +9 -3
  194. package/dist/rfc64/swm-inventory-catalog-reconciler-v1.js.map +1 -1
  195. package/dist/rfc64/swm-inventory-settlement-outlook-v1.d.ts +8 -0
  196. package/dist/rfc64/swm-inventory-settlement-outlook-v1.d.ts.map +1 -0
  197. package/dist/rfc64/swm-inventory-settlement-outlook-v1.js +32 -0
  198. package/dist/rfc64/swm-inventory-settlement-outlook-v1.js.map +1 -0
  199. package/dist/sync/requester/swm-recovery-apply.d.ts +1 -1
  200. package/dist/sync/requester/swm-recovery-apply.d.ts.map +1 -1
  201. package/dist/sync/requester/swm-recovery-apply.js +0 -1
  202. package/dist/sync/requester/swm-recovery-apply.js.map +1 -1
  203. package/dist/sync/requester/swm-target-executor.d.ts +2 -2
  204. package/dist/sync/requester/swm-target-executor.d.ts.map +1 -1
  205. package/dist/sync/requester/swm-target-executor.js +1 -2
  206. package/dist/sync/requester/swm-target-executor.js.map +1 -1
  207. package/package.json +11 -8
package/dist/dkg-agent.js CHANGED
@@ -8,7 +8,7 @@ import { DKGNode, TypedEventBus, PROTOCOL_STORAGE_ACK, isStorageACKProtocol, PRO
8
8
  import { GraphManager, createTripleStore } from '@origintrail-official/dkg-storage';
9
9
  import { canonicalRootlessLifecycleGraph } from './rootless-lifecycle-graph.js';
10
10
  import { normalizeContextGraphDiscoveryScan, legacyChainListScanOptions, } from './context-graph-discovery-options.js';
11
- import { prepareRfc64LateLegacySwmBoundaryV1 } from './rfc64/legacy-swm-boundary-v1.js';
11
+ import { awaitRfc64LateLegacySwmBoundaryAdmissionV1, prepareRfc64LateLegacySwmBoundaryV1 } from './rfc64/legacy-swm-boundary-v1.js';
12
12
  import { EVMChainAdapter, NoChainAdapter, isContextGraphChainScanPartialError, withRpcRequestContext } from '@origintrail-official/dkg-chain';
13
13
  import { DKGPublisher, ACKCollector, TripleStoreAsyncPromoteQueue, wrapAsRpcPreconditionIfApplicable, resolveStorageAckTiming,
14
14
  // OT-RFC-43 A2/B3 — per-layer pointers + derived status helper.
@@ -23,7 +23,7 @@ import { deleteSyncPageCheckpoint, } from './sync/requester/page-fetch.js';
23
23
  import { createContextGraphSyncDeadline } from './sync/requester/durable-sync-budget.js';
24
24
  import { createSwmRecoveryMutationRuntimeV1 } from './sync/requester/swm-recovery-apply.js';
25
25
  import { resolveSyncContextGraphPriorities, validateSyncResponderSnapshotLimitsConfig, } from './sync/policy.js';
26
- import { resolveDiscoveredContextGraphBinding } from './context-graph-chain-discovery-binding.js';
26
+ import { conflictsWithOwnedContextGraphBinding, resolveDiscoveredContextGraphBinding, } from './context-graph-chain-discovery-binding.js';
27
27
  import { relocatePrivateContextGraphMetadata, } from './context-graph-metadata-relocation.js';
28
28
  import { replaceContextGraphMetadataFact } from './context-graph-metadata-fact.js';
29
29
  import { stripLiteral, jsonLdToQuads, } from './dkg-agent-utils.js';
@@ -32,6 +32,7 @@ import { ContextGraphNotFoundError, InvalidContentError, } from './dkg-agent-typ
32
32
  import { normalizeAdapterPublisherAddress, adapterAdvertisesPublisherSigner, privateKeyAddress, inferAdapterPublisherAddress, defaultLargeLiteralStorage, createPublicSnapshotStore, applyDefaultLargeLiteralStorage, } from './dkg-agent-helpers.js';
33
33
  import { resolveSyncReconcilerTiming } from './sync/reconciler-timing.js';
34
34
  import { DKGAgentBase, createListContextGraphsCacheInvalidatingStore } from './dkg-agent-base.js';
35
+ import { createProjectionMutationObserver } from './internal/projection-mutation-observer.js';
35
36
  import { mapWithConcurrency } from './map-with-concurrency.js';
36
37
  import { VmReconcileShutdownTimeoutError } from './vm-reconcile-service.js';
37
38
  import { ContextGraphMembershipPersistShutdownTimeoutError } from './context-graph-membership-persist-scheduler.js';
@@ -268,14 +269,10 @@ export class DKGAgent extends DKGAgentBase {
268
269
  },
269
270
  recordDrops: (drops, seam) => this.oversizeTombstoneLog.record(drops, seam),
270
271
  invalidateListContextGraphsCache: () => this.invalidateListContextGraphsCache(),
271
- markMetaProjectionDirty: (quads) => this.contextGraphMetaProjection
272
- .markDirtyFromQuads(quads),
273
272
  recoveryMutation: createSwmRecoveryMutationRuntimeV1({
274
273
  store: this.store,
275
274
  recordDrops: (drops, seam) => this.oversizeTombstoneLog.record(drops, seam),
276
275
  invalidateListContextGraphsCache: () => this.invalidateListContextGraphsCache(),
277
- markMetaProjectionDirty: (quads) => this.contextGraphMetaProjection
278
- .markDirtyFromQuads(quads),
279
276
  }),
280
277
  setCheckpoint: (key, offset) => this.syncCheckpoints.set(key, offset),
281
278
  deleteCheckpoint: (key) => this.syncCheckpoints.delete(key),
@@ -390,7 +387,10 @@ export class DKGAgent extends DKGAgentBase {
390
387
  });
391
388
  const headDigest = this.rfc64PersistenceV1?.swmAuthorInventory
392
389
  .readSwmAuthorInventoryHeadDigestV1(scopeDigest, authorAddress) ?? null;
393
- return JSON.stringify([lane.kind, lane.projectionTargetPolicy, scopeDigest, headDigest]);
390
+ return {
391
+ scopeIdentity: JSON.stringify([lane.kind, lane.projectionTargetPolicy, scopeDigest]),
392
+ headRevision: headDigest,
393
+ };
394
394
  },
395
395
  listFinalizedPrivateRepairs: () => (this.rfc64PersistenceV1?.finalizedPrivatePlacementRepairs.list() ?? []),
396
396
  repairFinalizedPrivatePlacement: async (repair) => {
@@ -761,23 +761,7 @@ export class DKGAgent extends DKGAgentBase {
761
761
  (!configuredPublisherAddress || publisherAddressMatchesLegacyKey));
762
762
  const agentStore = createListContextGraphsCacheInvalidatingStore(store, () => {
763
763
  agentRef?.invalidateListContextGraphsCache();
764
- }, (quads, targetGraph) => {
765
- if (!agentRef)
766
- return;
767
- // #1863 — a single-graph destructive mutation (replaceSubject) passes its
768
- // TARGET GRAPH so deleted facts are fenced, while replacement quads
769
- // cover inserted authority facts.
770
- if (targetGraph !== undefined) {
771
- agentRef.contextGraphMetaProjection.markDirtyForGraph(targetGraph);
772
- if (quads)
773
- agentRef.contextGraphMetaProjection.markDirtyFromQuads(quads);
774
- return;
775
- }
776
- if (quads)
777
- agentRef.contextGraphMetaProjection.markDirtyFromQuads(quads);
778
- else
779
- agentRef.contextGraphMetaProjection.markAllDirty();
780
- });
764
+ }, createProjectionMutationObserver(() => agentRef?.contextGraphMetaProjection));
781
765
  const publicSnapshotStore = config.publicSnapshotStore ?? (config.publicSnapshotStoreFactory
782
766
  ? config.publicSnapshotStoreFactory(agentStore)
783
767
  : createPublicSnapshotStore(config.dataDir, config.sharedMemoryPublicSnapshotStorage, agentStore));
@@ -798,7 +782,7 @@ export class DKGAgent extends DKGAgentBase {
798
782
  kaAllocator: config.kaNumberAllocator,
799
783
  // RFC ka-metadata-trim P3.3 — `metadata.provenanceEvents` (default true).
800
784
  provenanceEvents: config.metadataProvenanceEvents,
801
- resolveDurableRootPromotionAtomicCompanion: (input) => {
785
+ resolveDurableRootPromotionAtomicCompanion: Object.assign((input) => {
802
786
  // Every root graph may exist before its exact catalog head is durable,
803
787
  // including the normal catalog lane. Persist its negative-completeness
804
788
  // witness in the same transaction; exact catalog reconciliation alone
@@ -812,7 +796,14 @@ export class DKGAgent extends DKGAgentBase {
812
796
  // A promote that meets a retirement's fence (its asset's, or the graph's) is
813
797
  // retried by the queue; every other refusal here stays a hard failure.
814
798
  return translateLegacySwmRetirementFence(() => prepareRfc64LateLegacySwmBoundaryV1(owner, input.contextGraphId, input.kaUal, input.shareOperationId, input.assertionVersion));
815
- },
799
+ }, {
800
+ // The promote gives a fence a short time to drop before it prepares.
801
+ awaitAdmission: async (input) => {
802
+ if (resolvedConfig.dataDir === undefined || agentRef === undefined)
803
+ return;
804
+ await awaitRfc64LateLegacySwmBoundaryAdmissionV1(agentRef, input.contextGraphId, input.kaUal);
805
+ },
806
+ }),
816
807
  resolveDurableRootMaterializationAtomicCompanion: (input) => {
817
808
  if (resolvedConfig.dataDir === undefined)
818
809
  return;
@@ -1050,20 +1041,25 @@ export class DKGAgent extends DKGAgentBase {
1050
1041
  return diagnostics.pingPeers({ node: this.node, peerHealth: this.peerHealth, log: this.log });
1051
1042
  }
1052
1043
  /**
1053
- * Record metadata learned through a discovery channel, then apply the
1054
- * temporary role policy required until core host-mode custody is independent
1055
- * from member subscriptions (#1611):
1056
- *
1057
- * - edge: catalogue only; explicit subscribe/create/join owns activation
1058
- * - core: newly discovered graphs auto-subscribe so ACK-capable nodes keep
1059
- * the publish/finalization handlers needed to host network data
1044
+ * Enrich catalogue metadata while preserving an owned numeric slot.
1045
+ * Until core custody is independent (#1611), new core discoveries activate
1046
+ * ACK/finalization hosting; edge discoveries stay passive.
1060
1047
  *
1061
- * Existing unsubscribed rows are never reactivated here. That preserves an
1062
- * operator's explicit unsubscribe while still allowing authoritative
1063
- * metadata (including an on-chain binding) to enrich the catalogue.
1048
+ * Existing unsubscribed rows retain their explicit inactive intent.
1064
1049
  */
1065
1050
  recordDiscoveredContextGraph(contextGraphId, metadata, options = {}) {
1066
1051
  const existing = this.subscribedContextGraphs.get(contextGraphId);
1052
+ const authoritativeOnChainId = isCanonicalAuthoritativeContextGraphId(metadata.onChainId)
1053
+ ? metadata.onChainId
1054
+ : undefined;
1055
+ if (existing
1056
+ && conflictsWithOwnedContextGraphBinding(existing.onChainId, authoritativeOnChainId)) {
1057
+ // Discovery enriches an identity; it cannot replace an owned slot.
1058
+ // Explicit verified rebinds use their own authority boundary.
1059
+ this.log.warn(createOperationContext('system'), `Ignoring discovered Context Graph "${contextGraphId}" slot ${authoritativeOnChainId}: `
1060
+ + `the local identity already owns slot ${existing.onChainId}`);
1061
+ return existing;
1062
+ }
1067
1063
  const next = {
1068
1064
  ...existing,
1069
1065
  syncMode: existing?.syncMode ?? 'always-on',
@@ -1074,9 +1070,6 @@ export class DKGAgent extends DKGAgentBase {
1074
1070
  metaSynced: existing?.metaSynced === true,
1075
1071
  participantAgents: metadata.participantAgents ?? existing?.participantAgents,
1076
1072
  };
1077
- const authoritativeOnChainId = isCanonicalAuthoritativeContextGraphId(metadata.onChainId)
1078
- ? metadata.onChainId
1079
- : undefined;
1080
1073
  const invalidExplicitOnChainId = metadata.onChainId !== undefined
1081
1074
  && authoritativeOnChainId === undefined;
1082
1075
  if (authoritativeOnChainId !== undefined) {
@@ -1090,9 +1083,7 @@ export class DKGAgent extends DKGAgentBase {
1090
1083
  if (!invalidExplicitOnChainId && metadata.onChainHash !== undefined) {
1091
1084
  next.onChainHash = metadata.onChainHash;
1092
1085
  }
1093
- // Discovery-only rows stay in-memory. Metadata learned for an already
1094
- // active member/host row is part of that durable state and must survive a
1095
- // restart (notably a later-discovered onChainId).
1086
+ // Only an admitted member/host's enrichment belongs in durable state.
1096
1087
  const persistEnrichment = options.persist !== false
1097
1088
  && (existing?.subscribed === true || existing?.coreHosted === true);
1098
1089
  this.setContextGraphSubscription(contextGraphId, next, { persist: persistEnrichment });
@@ -1551,10 +1542,7 @@ export class DKGAgent extends DKGAgentBase {
1551
1542
  partialChainScanError = err;
1552
1543
  return err.partialResults;
1553
1544
  };
1554
- // NameRegistry enumeration is keyed by bytes32 name hashes, while all
1555
- // authoritative agent bindings are positive decimal ContextGraphStorage
1556
- // ids. Keep those namespaces separate: the legacy
1557
- // ContextGraphOnChain.contextGraphId field is the former, not the latter.
1545
+ // Enumeration name hashes and authoritative numeric slots are distinct.
1558
1546
  const knownNameHashes = new Set();
1559
1547
  for (const [localId, sub] of this.subscribedContextGraphs) {
1560
1548
  if (sub.onChainHash && ethers.isHexString(sub.onChainHash, 32)) {
@@ -1607,6 +1595,12 @@ export class DKGAgent extends DKGAgentBase {
1607
1595
  }
1608
1596
  }
1609
1597
  const durableOnChainId = await readDurableContextGraphOnChainId(binding.name);
1598
+ const currentOnChainId = this.subscribedContextGraphs.get(binding.name)?.onChainId;
1599
+ if (conflictsWithOwnedContextGraphBinding(currentOnChainId, binding.onChainId)) {
1600
+ this.log.warn(ctx, `Ignoring chain discovery for "${binding.name}" slot ${binding.onChainId}: `
1601
+ + `the local identity already owns slot ${currentOnChainId}`);
1602
+ continue;
1603
+ }
1610
1604
  if (durableOnChainId === binding.onChainId) {
1611
1605
  // A previous attempt may have committed the reconstructible RDF
1612
1606
  // binding but failed the active/core subscription write before page
@@ -1621,18 +1615,9 @@ export class DKGAgent extends DKGAgentBase {
1621
1615
  knownNameHashes.add(registryNameHash);
1622
1616
  continue;
1623
1617
  }
1624
- // Persist the on-chain ID durably so the publisher's VM registration
1625
- // guard can find it via RDF (it has no access to the in-memory
1626
- // subscribedContextGraphs map). Only the metadata home gets it:
1627
- // ontology for a public graph, its own `_meta` for a curated one (only
1628
- // its curator gets here). A graph found on chain isn't held here, and
1629
- // any `_meta` row would make the relocation treat it as held.
1630
- // Single-valued binding guard (RS heal): on-chain id is immutable; clear
1631
- // any prior value so the cgId resolver / heal never read a multi-valued
1632
- // (LIMIT-1-nondeterministic) binding.
1633
- // Keep this durable write before in-memory catalogue mutation: cursor
1634
- // pages are acked after this function returns, and an in-memory onChainId
1635
- // alone must not make a retry skip the RDF binding.
1618
+ // The publisher resolves this reconstructible binding from RDF.
1619
+ // Write its public/private metadata home before catalogue persistence
1620
+ // and page acknowledgement, so a failed durable row can be replayed.
1636
1621
  await replaceContextGraphMetadataFact(this.store, binding.name, {
1637
1622
  predicate: CONTEXT_GRAPH_ON_CHAIN_ID_PREDICATE,
1638
1623
  object: `"${binding.onChainId}"`,