@origintrail-official/dkg-agent 10.0.12 → 10.0.13

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 (225) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +54 -54
  3. package/dist/ccl-fact-resolution.js +22 -22
  4. package/dist/context-graph-meta-projection.js +58 -58
  5. package/dist/context-graph-private-meta-proof.js +18 -18
  6. package/dist/context-graph-public-meta-proof.js +11 -11
  7. package/dist/context-graph-public-meta-repair.js +33 -33
  8. package/dist/context-graph-subscription-policy.d.ts +31 -0
  9. package/dist/context-graph-subscription-policy.d.ts.map +1 -0
  10. package/dist/context-graph-subscription-policy.js +48 -0
  11. package/dist/context-graph-subscription-policy.js.map +1 -0
  12. package/dist/curator-meta-refresh.js +23 -23
  13. package/dist/discovery.js +52 -52
  14. package/dist/dkg-agent-ccl.js +50 -50
  15. package/dist/dkg-agent-cg-registry.js +5 -5
  16. package/dist/dkg-agent-cg-registry.js.map +1 -1
  17. package/dist/dkg-agent-cg-resolve.js +77 -77
  18. package/dist/dkg-agent-context-graph.d.ts.map +1 -1
  19. package/dist/dkg-agent-context-graph.js +13 -10
  20. package/dist/dkg-agent-context-graph.js.map +1 -1
  21. package/dist/dkg-agent-endorse.js +19 -19
  22. package/dist/dkg-agent-join.js +110 -110
  23. package/dist/dkg-agent-lifecycle.d.ts +6 -3
  24. package/dist/dkg-agent-lifecycle.d.ts.map +1 -1
  25. package/dist/dkg-agent-lifecycle.js +282 -114
  26. package/dist/dkg-agent-lifecycle.js.map +1 -1
  27. package/dist/dkg-agent-ownership.js +17 -17
  28. package/dist/dkg-agent-publish.d.ts +28 -0
  29. package/dist/dkg-agent-publish.d.ts.map +1 -1
  30. package/dist/dkg-agent-publish.js +118 -66
  31. package/dist/dkg-agent-publish.js.map +1 -1
  32. package/dist/dkg-agent-query.js +4 -4
  33. package/dist/dkg-agent-registry.js +32 -32
  34. package/dist/dkg-agent-rfc64-catalog-auto-publish.d.ts +67 -2
  35. package/dist/dkg-agent-rfc64-catalog-auto-publish.d.ts.map +1 -1
  36. package/dist/dkg-agent-rfc64-catalog-auto-publish.js +328 -30
  37. package/dist/dkg-agent-rfc64-catalog-auto-publish.js.map +1 -1
  38. package/dist/dkg-agent-swm-host.d.ts.map +1 -1
  39. package/dist/dkg-agent-swm-host.js +89 -82
  40. package/dist/dkg-agent-swm-host.js.map +1 -1
  41. package/dist/dkg-agent-swm-substrate.d.ts +3 -1
  42. package/dist/dkg-agent-swm-substrate.d.ts.map +1 -1
  43. package/dist/dkg-agent-swm-substrate.js +27 -6
  44. package/dist/dkg-agent-swm-substrate.js.map +1 -1
  45. package/dist/dkg-agent-types.d.ts +168 -4
  46. package/dist/dkg-agent-types.d.ts.map +1 -1
  47. package/dist/dkg-agent-types.js.map +1 -1
  48. package/dist/dkg-agent.d.ts +2 -2
  49. package/dist/dkg-agent.d.ts.map +1 -1
  50. package/dist/dkg-agent.js +153 -118
  51. package/dist/dkg-agent.js.map +1 -1
  52. package/dist/finalization-handler.d.ts.map +1 -1
  53. package/dist/finalization-handler.js +62 -50
  54. package/dist/finalization-handler.js.map +1 -1
  55. package/dist/finalization-recovery-sqlite-codec.d.ts +5 -0
  56. package/dist/finalization-recovery-sqlite-codec.d.ts.map +1 -1
  57. package/dist/finalization-recovery-sqlite-codec.js +10 -5
  58. package/dist/finalization-recovery-sqlite-codec.js.map +1 -1
  59. package/dist/finalization-recovery-sqlite-policy.d.ts +14 -0
  60. package/dist/finalization-recovery-sqlite-policy.d.ts.map +1 -1
  61. package/dist/finalization-recovery-sqlite-policy.js +98 -51
  62. package/dist/finalization-recovery-sqlite-policy.js.map +1 -1
  63. package/dist/finalization-recovery-sqlite-schema.d.ts.map +1 -1
  64. package/dist/finalization-recovery-sqlite-schema.js +161 -84
  65. package/dist/finalization-recovery-sqlite-schema.js.map +1 -1
  66. package/dist/finalization-recovery-sqlite-store.d.ts +4 -0
  67. package/dist/finalization-recovery-sqlite-store.d.ts.map +1 -1
  68. package/dist/finalization-recovery-sqlite-store.js +267 -137
  69. package/dist/finalization-recovery-sqlite-store.js.map +1 -1
  70. package/dist/finalization-recovery-store.d.ts +9 -0
  71. package/dist/finalization-recovery-store.d.ts.map +1 -1
  72. package/dist/finalization-recovery.d.ts +20 -2
  73. package/dist/finalization-recovery.d.ts.map +1 -1
  74. package/dist/finalization-recovery.js +125 -22
  75. package/dist/finalization-recovery.js.map +1 -1
  76. package/dist/finalized-assertion-author.js +6 -6
  77. package/dist/gossip-publish-handler.d.ts.map +1 -1
  78. package/dist/gossip-publish-handler.js +9 -6
  79. package/dist/gossip-publish-handler.js.map +1 -1
  80. package/dist/index.d.ts +6 -2
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +15 -1
  83. package/dist/index.js.map +1 -1
  84. package/dist/join-request-retention.js +36 -36
  85. package/dist/rfc64/author-catalog-producer.d.ts +3 -5
  86. package/dist/rfc64/author-catalog-producer.d.ts.map +1 -1
  87. package/dist/rfc64/author-catalog-producer.js +8 -16
  88. package/dist/rfc64/author-catalog-producer.js.map +1 -1
  89. package/dist/rfc64/control-envelope-signer-v1.d.ts +18 -0
  90. package/dist/rfc64/control-envelope-signer-v1.d.ts.map +1 -0
  91. package/dist/rfc64/control-envelope-signer-v1.js +29 -0
  92. package/dist/rfc64/control-envelope-signer-v1.js.map +1 -0
  93. package/dist/rfc64/finalized-vm-store-materializer-v1.js +6 -6
  94. package/dist/rfc64/inventory-v1/candidate.d.ts +14 -4
  95. package/dist/rfc64/inventory-v1/candidate.d.ts.map +1 -1
  96. package/dist/rfc64/inventory-v1/candidate.js +61 -21
  97. package/dist/rfc64/inventory-v1/candidate.js.map +1 -1
  98. package/dist/rfc64/inventory-v1/exact-record.d.ts +13 -0
  99. package/dist/rfc64/inventory-v1/exact-record.d.ts.map +1 -0
  100. package/dist/rfc64/inventory-v1/exact-record.js +42 -0
  101. package/dist/rfc64/inventory-v1/exact-record.js.map +1 -0
  102. package/dist/rfc64/inventory-v1/index.d.ts +1 -1
  103. package/dist/rfc64/inventory-v1/index.d.ts.map +1 -1
  104. package/dist/rfc64/inventory-v1/index.js +1 -1
  105. package/dist/rfc64/inventory-v1/index.js.map +1 -1
  106. package/dist/rfc64/inventory-v1/open.d.ts.map +1 -1
  107. package/dist/rfc64/inventory-v1/open.js +89 -40
  108. package/dist/rfc64/inventory-v1/open.js.map +1 -1
  109. package/dist/rfc64/inventory-v1/scalars.d.ts +1 -0
  110. package/dist/rfc64/inventory-v1/scalars.d.ts.map +1 -1
  111. package/dist/rfc64/inventory-v1/scalars.js +5 -0
  112. package/dist/rfc64/inventory-v1/scalars.js.map +1 -1
  113. package/dist/rfc64/inventory-v1/sql.d.ts +12 -1
  114. package/dist/rfc64/inventory-v1/sql.d.ts.map +1 -1
  115. package/dist/rfc64/inventory-v1/sql.js +386 -274
  116. package/dist/rfc64/inventory-v1/sql.js.map +1 -1
  117. package/dist/rfc64/inventory-v1/statements.d.ts +14 -2
  118. package/dist/rfc64/inventory-v1/statements.d.ts.map +1 -1
  119. package/dist/rfc64/inventory-v1/statements.js +303 -228
  120. package/dist/rfc64/inventory-v1/statements.js.map +1 -1
  121. package/dist/rfc64/inventory-v1/swm-author-inventory-auth-v1.d.ts +16 -0
  122. package/dist/rfc64/inventory-v1/swm-author-inventory-auth-v1.d.ts.map +1 -0
  123. package/dist/rfc64/inventory-v1/swm-author-inventory-auth-v1.js +52 -0
  124. package/dist/rfc64/inventory-v1/swm-author-inventory-auth-v1.js.map +1 -0
  125. package/dist/rfc64/inventory-v1/swm-author-inventory-commit-plan.d.ts +19 -0
  126. package/dist/rfc64/inventory-v1/swm-author-inventory-commit-plan.d.ts.map +1 -0
  127. package/dist/rfc64/inventory-v1/swm-author-inventory-commit-plan.js +39 -0
  128. package/dist/rfc64/inventory-v1/swm-author-inventory-commit-plan.js.map +1 -0
  129. package/dist/rfc64/inventory-v1/swm-author-inventory-contracts.d.ts +33 -0
  130. package/dist/rfc64/inventory-v1/swm-author-inventory-contracts.d.ts.map +1 -0
  131. package/dist/rfc64/inventory-v1/swm-author-inventory-contracts.js +17 -0
  132. package/dist/rfc64/inventory-v1/swm-author-inventory-contracts.js.map +1 -0
  133. package/dist/rfc64/inventory-v1/swm-author-inventory-mutation.d.ts +17 -0
  134. package/dist/rfc64/inventory-v1/swm-author-inventory-mutation.d.ts.map +1 -0
  135. package/dist/rfc64/inventory-v1/swm-author-inventory-mutation.js +68 -0
  136. package/dist/rfc64/inventory-v1/swm-author-inventory-mutation.js.map +1 -0
  137. package/dist/rfc64/inventory-v1/swm-author-inventory-persistence.d.ts +30 -0
  138. package/dist/rfc64/inventory-v1/swm-author-inventory-persistence.d.ts.map +1 -0
  139. package/dist/rfc64/inventory-v1/swm-author-inventory-persistence.js +228 -0
  140. package/dist/rfc64/inventory-v1/swm-author-inventory-persistence.js.map +1 -0
  141. package/dist/rfc64/inventory-v1/swm-author-inventory-sql-codec.d.ts +11 -0
  142. package/dist/rfc64/inventory-v1/swm-author-inventory-sql-codec.d.ts.map +1 -0
  143. package/dist/rfc64/inventory-v1/swm-author-inventory-sql-codec.js +62 -0
  144. package/dist/rfc64/inventory-v1/swm-author-inventory-sql-codec.js.map +1 -0
  145. package/dist/rfc64/persistence-v1.d.ts +3 -1
  146. package/dist/rfc64/persistence-v1.d.ts.map +1 -1
  147. package/dist/rfc64/persistence-v1.js +3 -1
  148. package/dist/rfc64/persistence-v1.js.map +1 -1
  149. package/dist/rfc64/public-catalog-activation-config-v1.d.ts +84 -0
  150. package/dist/rfc64/public-catalog-activation-config-v1.d.ts.map +1 -0
  151. package/dist/rfc64/public-catalog-activation-config-v1.js +223 -0
  152. package/dist/rfc64/public-catalog-activation-config-v1.js.map +1 -0
  153. package/dist/rfc64/public-catalog-native-receiver-v1.d.ts.map +1 -1
  154. package/dist/rfc64/public-catalog-native-receiver-v1.js +19 -1
  155. package/dist/rfc64/public-catalog-native-receiver-v1.js.map +1 -1
  156. package/dist/rfc64/secure-filesystem-policy-v1.js +91 -91
  157. package/dist/rfc64/swm-author-inventory-producer-v1.d.ts +47 -0
  158. package/dist/rfc64/swm-author-inventory-producer-v1.d.ts.map +1 -0
  159. package/dist/rfc64/swm-author-inventory-producer-v1.js +276 -0
  160. package/dist/rfc64/swm-author-inventory-producer-v1.js.map +1 -0
  161. package/dist/rfc64/swm-inventory-shadow-runtime-v1.d.ts +39 -0
  162. package/dist/rfc64/swm-inventory-shadow-runtime-v1.d.ts.map +1 -0
  163. package/dist/rfc64/swm-inventory-shadow-runtime-v1.js +137 -0
  164. package/dist/rfc64/swm-inventory-shadow-runtime-v1.js.map +1 -0
  165. package/dist/storage-ack-lifecycle-identity.js +6 -6
  166. package/dist/sync/catchup-pass-policy.d.ts +172 -0
  167. package/dist/sync/catchup-pass-policy.d.ts.map +1 -0
  168. package/dist/sync/catchup-pass-policy.js +239 -0
  169. package/dist/sync/catchup-pass-policy.js.map +1 -0
  170. package/dist/sync/catchup-policy.d.ts +8 -0
  171. package/dist/sync/catchup-policy.d.ts.map +1 -1
  172. package/dist/sync/catchup-policy.js +1 -1
  173. package/dist/sync/catchup-policy.js.map +1 -1
  174. package/dist/sync/durable-progress.d.ts +12 -0
  175. package/dist/sync/durable-progress.d.ts.map +1 -1
  176. package/dist/sync/durable-progress.js +16 -0
  177. package/dist/sync/durable-progress.js.map +1 -1
  178. package/dist/sync/on-connect/sync-on-connect.d.ts +2 -0
  179. package/dist/sync/on-connect/sync-on-connect.d.ts.map +1 -1
  180. package/dist/sync/on-connect/sync-on-connect.js +58 -19
  181. package/dist/sync/on-connect/sync-on-connect.js.map +1 -1
  182. package/dist/sync/policy.d.ts +20 -0
  183. package/dist/sync/policy.d.ts.map +1 -1
  184. package/dist/sync/policy.js +41 -1
  185. package/dist/sync/policy.js.map +1 -1
  186. package/dist/sync/priority-admission-queue.d.ts.map +1 -1
  187. package/dist/sync/priority-admission-queue.js +15 -0
  188. package/dist/sync/priority-admission-queue.js.map +1 -1
  189. package/dist/sync/requester/durable-sync-budget.d.ts +28 -1
  190. package/dist/sync/requester/durable-sync-budget.d.ts.map +1 -1
  191. package/dist/sync/requester/durable-sync-budget.js +49 -8
  192. package/dist/sync/requester/durable-sync-budget.js.map +1 -1
  193. package/dist/sync/requester/durable-sync.d.ts +1 -1
  194. package/dist/sync/requester/durable-sync.d.ts.map +1 -1
  195. package/dist/sync/requester/durable-sync.js +19 -10
  196. package/dist/sync/requester/durable-sync.js.map +1 -1
  197. package/dist/sync/requester/graph-scoped-materialization.js +12 -12
  198. package/dist/sync/requester/ordered-sync.d.ts +22 -1
  199. package/dist/sync/requester/ordered-sync.d.ts.map +1 -1
  200. package/dist/sync/requester/ordered-sync.js +25 -2
  201. package/dist/sync/requester/ordered-sync.js.map +1 -1
  202. package/dist/sync/requester/shared-memory-sync.d.ts +82 -0
  203. package/dist/sync/requester/shared-memory-sync.d.ts.map +1 -1
  204. package/dist/sync/requester/shared-memory-sync.js +605 -85
  205. package/dist/sync/requester/shared-memory-sync.js.map +1 -1
  206. package/dist/sync/requester/swm-recovery.d.ts.map +1 -1
  207. package/dist/sync/requester/swm-recovery.js +9 -0
  208. package/dist/sync/requester/swm-recovery.js.map +1 -1
  209. package/dist/sync/requester/swm-snapshot-materializer.d.ts.map +1 -1
  210. package/dist/sync/requester/swm-snapshot-materializer.js +89 -1
  211. package/dist/sync/requester/swm-snapshot-materializer.js.map +1 -1
  212. package/dist/sync/responder/durable-meta-admission.js +13 -13
  213. package/dist/sync/responder/graph-plan.d.ts +14 -1
  214. package/dist/sync/responder/graph-plan.d.ts.map +1 -1
  215. package/dist/sync/responder/graph-plan.js +329 -299
  216. package/dist/sync/responder/graph-plan.js.map +1 -1
  217. package/dist/sync/responder/snapshot-cache.d.ts +1 -1
  218. package/dist/sync/responder/snapshot-cache.d.ts.map +1 -1
  219. package/dist/sync/responder/snapshot-cache.js +21 -5
  220. package/dist/sync/responder/snapshot-cache.js.map +1 -1
  221. package/dist/sync/system-context-graph-policy.d.ts +13 -0
  222. package/dist/sync/system-context-graph-policy.d.ts.map +1 -0
  223. package/dist/sync/system-context-graph-policy.js +22 -0
  224. package/dist/sync/system-context-graph-policy.js.map +1 -0
  225. package/package.json +23 -7
@@ -173,13 +173,13 @@ export class ContextGraphMetaProjection {
173
173
  const agentsGraph = contextGraphDataGraphUri(SYSTEM_CONTEXT_GRAPHS.AGENTS);
174
174
  assertSafeIri(ontologyGraph);
175
175
  assertSafeIri(agentsGraph);
176
- const result = await this.store.query(`
177
- SELECT DISTINCT ?ctxGraph WHERE {
178
- VALUES ?sourceGraph { <${ontologyGraph}> <${agentsGraph}> }
179
- GRAPH ?sourceGraph {
180
- ?ctxGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_CONTEXT_GRAPH}> .
181
- }
182
- }
176
+ const result = await this.store.query(`
177
+ SELECT DISTINCT ?ctxGraph WHERE {
178
+ VALUES ?sourceGraph { <${ontologyGraph}> <${agentsGraph}> }
179
+ GRAPH ?sourceGraph {
180
+ ?ctxGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_CONTEXT_GRAPH}> .
181
+ }
182
+ }
183
183
  `, options);
184
184
  const ids = new Set();
185
185
  if (result.type === 'bindings') {
@@ -212,15 +212,15 @@ export class ContextGraphMetaProjection {
212
212
  for (const chunk of chunks(graphUris, 128)) {
213
213
  for (const graphUri of chunk)
214
214
  assertSafeIri(graphUri);
215
- const result = await this.store.query(`
216
- SELECT DISTINCT ?ctxGraph WHERE {
217
- VALUES ?g { ${chunk.map((graphUri) => `<${graphUri}>`).join(' ')} }
218
- GRAPH ?g {
219
- ?ctxGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_CONTEXT_GRAPH}> .
220
- FILTER(STRSTARTS(STR(?ctxGraph), "${CONTEXT_GRAPH_PREFIX}"))
221
- FILTER(STR(?g) = CONCAT(STR(?ctxGraph), "/_meta"))
222
- }
223
- }
215
+ const result = await this.store.query(`
216
+ SELECT DISTINCT ?ctxGraph WHERE {
217
+ VALUES ?g { ${chunk.map((graphUri) => `<${graphUri}>`).join(' ')} }
218
+ GRAPH ?g {
219
+ ?ctxGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_CONTEXT_GRAPH}> .
220
+ FILTER(STRSTARTS(STR(?ctxGraph), "${CONTEXT_GRAPH_PREFIX}"))
221
+ FILTER(STR(?g) = CONCAT(STR(?ctxGraph), "/_meta"))
222
+ }
223
+ }
224
224
  `, options);
225
225
  if (result.type !== 'bindings')
226
226
  continue;
@@ -242,15 +242,15 @@ export class ContextGraphMetaProjection {
242
242
  for (const chunk of chunks(graphUris, 128)) {
243
243
  for (const graphUri of chunk)
244
244
  assertSafeIri(graphUri);
245
- const result = await this.store.query(`
246
- SELECT DISTINCT ?ctxGraph WHERE {
247
- VALUES ?g { ${chunk.map((graphUri) => `<${graphUri}>`).join(' ')} }
248
- GRAPH ?g {
249
- ?ctxGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_PRIVATE_CONTEXT_GRAPH}> .
250
- FILTER(STRSTARTS(STR(?ctxGraph), "${CONTEXT_GRAPH_PREFIX}"))
251
- FILTER(STR(?g) = CONCAT(STR(?ctxGraph), "/_catalog"))
252
- }
253
- }
245
+ const result = await this.store.query(`
246
+ SELECT DISTINCT ?ctxGraph WHERE {
247
+ VALUES ?g { ${chunk.map((graphUri) => `<${graphUri}>`).join(' ')} }
248
+ GRAPH ?g {
249
+ ?ctxGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_PRIVATE_CONTEXT_GRAPH}> .
250
+ FILTER(STRSTARTS(STR(?ctxGraph), "${CONTEXT_GRAPH_PREFIX}"))
251
+ FILTER(STR(?g) = CONCAT(STR(?ctxGraph), "/_catalog"))
252
+ }
253
+ }
254
254
  `, options);
255
255
  if (result.type !== 'bindings')
256
256
  continue;
@@ -341,17 +341,17 @@ export class ContextGraphMetaProjection {
341
341
  }
342
342
  async loadDelegations(contextGraphId, options) {
343
343
  const metaGraph = contextGraphMetaGraphUri(contextGraphId);
344
- const result = await this.store.query(`SELECT ?delegation ?predicate ?object WHERE {
345
- GRAPH <${metaGraph}> {
346
- ?delegation <${DKG_ONTOLOGY.DKG_DELEGATION_AGENT}> ?delegatedAgent .
347
- ?delegation ?predicate ?object .
348
- VALUES ?predicate {
349
- <${DKG_ONTOLOGY.DKG_DELEGATION_AGENT}>
350
- <${DKG_ONTOLOGY.DKG_ALLOWED_DELEGATEE_PEER}>
351
- <${DKG_ONTOLOGY.DKG_ALLOWED_DELEGATEE_KEY}>
352
- <${DKG_ONTOLOGY.DKG_DELEGATION_EXPIRES_AT}>
353
- }
354
- }
344
+ const result = await this.store.query(`SELECT ?delegation ?predicate ?object WHERE {
345
+ GRAPH <${metaGraph}> {
346
+ ?delegation <${DKG_ONTOLOGY.DKG_DELEGATION_AGENT}> ?delegatedAgent .
347
+ ?delegation ?predicate ?object .
348
+ VALUES ?predicate {
349
+ <${DKG_ONTOLOGY.DKG_DELEGATION_AGENT}>
350
+ <${DKG_ONTOLOGY.DKG_ALLOWED_DELEGATEE_PEER}>
351
+ <${DKG_ONTOLOGY.DKG_ALLOWED_DELEGATEE_KEY}>
352
+ <${DKG_ONTOLOGY.DKG_DELEGATION_EXPIRES_AT}>
353
+ }
354
+ }
355
355
  }`, options);
356
356
  if (result.type !== 'bindings')
357
357
  return [];
@@ -390,10 +390,10 @@ export class ContextGraphMetaProjection {
390
390
  return [...byUri.values()];
391
391
  }
392
392
  async loadContextGraphFacts(graphUri, contextGraphUri, record, options, allowedPredicates) {
393
- const result = await this.store.query(`SELECT ?p ?o WHERE {
394
- GRAPH <${graphUri}> {
395
- <${contextGraphUri}> ?p ?o .
396
- }
393
+ const result = await this.store.query(`SELECT ?p ?o WHERE {
394
+ GRAPH <${graphUri}> {
395
+ <${contextGraphUri}> ?p ?o .
396
+ }
397
397
  }`, options);
398
398
  if (result.type !== 'bindings')
399
399
  return;
@@ -476,24 +476,24 @@ export class ContextGraphMetaProjection {
476
476
  }
477
477
  async loadSubGraphs(contextGraphId, options) {
478
478
  const metaGraph = contextGraphMetaGraphUri(contextGraphId);
479
- const result = await this.store.query(`SELECT ?subGraph ?name ?createdBy ?createdAt ?description WHERE {
480
- GRAPH <${metaGraph}> {
481
- ?subGraph ?typePred ?subGraphType ;
482
- ?namePred ?name ;
483
- ?createdByPred ?createdBy .
484
- VALUES ?typePred { <${DKG_ONTOLOGY.RDF_TYPE}> }
485
- VALUES ?subGraphType { <${DKG_NS}SubGraph> <${LEGACY_DKG_NS}SubGraph> }
486
- VALUES ?namePred { <${DKG_ONTOLOGY.SCHEMA_NAME}> <${LEGACY_SCHEMA_NS}name> }
487
- VALUES ?createdByPred { <${DKG_NS}createdBy> <${LEGACY_DKG_NS}createdBy> }
488
- OPTIONAL {
489
- ?subGraph ?createdAtPred ?createdAt .
490
- VALUES ?createdAtPred { <${DKG_NS}createdAt> <${LEGACY_DKG_NS}createdAt> }
491
- }
492
- OPTIONAL {
493
- ?subGraph ?descriptionPred ?description .
494
- VALUES ?descriptionPred { <${DKG_ONTOLOGY.SCHEMA_DESCRIPTION}> <${LEGACY_SCHEMA_NS}description> }
495
- }
496
- }
479
+ const result = await this.store.query(`SELECT ?subGraph ?name ?createdBy ?createdAt ?description WHERE {
480
+ GRAPH <${metaGraph}> {
481
+ ?subGraph ?typePred ?subGraphType ;
482
+ ?namePred ?name ;
483
+ ?createdByPred ?createdBy .
484
+ VALUES ?typePred { <${DKG_ONTOLOGY.RDF_TYPE}> }
485
+ VALUES ?subGraphType { <${DKG_NS}SubGraph> <${LEGACY_DKG_NS}SubGraph> }
486
+ VALUES ?namePred { <${DKG_ONTOLOGY.SCHEMA_NAME}> <${LEGACY_SCHEMA_NS}name> }
487
+ VALUES ?createdByPred { <${DKG_NS}createdBy> <${LEGACY_DKG_NS}createdBy> }
488
+ OPTIONAL {
489
+ ?subGraph ?createdAtPred ?createdAt .
490
+ VALUES ?createdAtPred { <${DKG_NS}createdAt> <${LEGACY_DKG_NS}createdAt> }
491
+ }
492
+ OPTIONAL {
493
+ ?subGraph ?descriptionPred ?description .
494
+ VALUES ?descriptionPred { <${DKG_ONTOLOGY.SCHEMA_DESCRIPTION}> <${LEGACY_SCHEMA_NS}description> }
495
+ }
496
+ }
497
497
  }`, options);
498
498
  if (result.type !== 'bindings')
499
499
  return [];
@@ -148,19 +148,19 @@ function renderMemberProof(contextGraphId, contextGraphUri, rawProof) {
148
148
  credentialPatterns.push(`OPTIONAL { <${delegationSubject}> <${DKG_ONTOLOGY.DKG_ALLOWED_DELEGATEE_KEY}> ?approvedDelegateeKey . }`);
149
149
  credentialFilters.push(`(BOUND(?approvedDelegateeKey) && isLiteral(?approvedDelegateeKey) && LCASE(STR(?approvedDelegateeKey)) = ${sparqlString(proof.expectedDelegateeOpKey)})`);
150
150
  }
151
- return ` <${assertSafeIri(contextGraphUri)}> <${DKG_ONTOLOGY.DKG_ALLOWED_AGENT}> ?approvedAgent .
152
- FILTER(isLiteral(?approvedAgent) && LCASE(STR(?approvedAgent)) = ${sparqlString(proof.approvedAgentAddress)})
153
- FILTER NOT EXISTS {
154
- <${assertSafeIri(contextGraphUri)}> <${DKG_ONTOLOGY.DKG_REVOKED_AGENT}> ?revokedApprovedAgent .
155
- FILTER(isLiteral(?revokedApprovedAgent) && LCASE(STR(?revokedApprovedAgent)) = ${sparqlString(proof.approvedAgentAddress)})
156
- }
157
- <${delegationSubject}> <${DKG_ONTOLOGY.DKG_DELEGATION_AGENT}> ?delegatedApprovedAgent ;
158
- <${DKG_ONTOLOGY.DKG_DELEGATION_ISSUED_AT}> ?delegationIssuedAt .
159
- FILTER(isLiteral(?delegatedApprovedAgent) && LCASE(STR(?delegatedApprovedAgent)) = ${sparqlString(proof.approvedAgentAddress)})
160
- FILTER(REGEX(STR(?delegationIssuedAt), "^[0-9]+$") && xsd:integer(STR(?delegationIssuedAt)) <= ${proof.nowMs})
161
- OPTIONAL { <${delegationSubject}> <${DKG_ONTOLOGY.DKG_DELEGATION_EXPIRES_AT}> ?delegationExpiresAt . }
162
- FILTER(!BOUND(?delegationExpiresAt) || (REGEX(STR(?delegationExpiresAt), "^[0-9]+$") && xsd:integer(STR(?delegationExpiresAt)) > ${proof.nowMs}))
163
- ${credentialPatterns.join('\n ')}
151
+ return ` <${assertSafeIri(contextGraphUri)}> <${DKG_ONTOLOGY.DKG_ALLOWED_AGENT}> ?approvedAgent .
152
+ FILTER(isLiteral(?approvedAgent) && LCASE(STR(?approvedAgent)) = ${sparqlString(proof.approvedAgentAddress)})
153
+ FILTER NOT EXISTS {
154
+ <${assertSafeIri(contextGraphUri)}> <${DKG_ONTOLOGY.DKG_REVOKED_AGENT}> ?revokedApprovedAgent .
155
+ FILTER(isLiteral(?revokedApprovedAgent) && LCASE(STR(?revokedApprovedAgent)) = ${sparqlString(proof.approvedAgentAddress)})
156
+ }
157
+ <${delegationSubject}> <${DKG_ONTOLOGY.DKG_DELEGATION_AGENT}> ?delegatedApprovedAgent ;
158
+ <${DKG_ONTOLOGY.DKG_DELEGATION_ISSUED_AT}> ?delegationIssuedAt .
159
+ FILTER(isLiteral(?delegatedApprovedAgent) && LCASE(STR(?delegatedApprovedAgent)) = ${sparqlString(proof.approvedAgentAddress)})
160
+ FILTER(REGEX(STR(?delegationIssuedAt), "^[0-9]+$") && xsd:integer(STR(?delegationIssuedAt)) <= ${proof.nowMs})
161
+ OPTIONAL { <${delegationSubject}> <${DKG_ONTOLOGY.DKG_DELEGATION_EXPIRES_AT}> ?delegationExpiresAt . }
162
+ FILTER(!BOUND(?delegationExpiresAt) || (REGEX(STR(?delegationExpiresAt), "^[0-9]+$") && xsd:integer(STR(?delegationExpiresAt)) > ${proof.nowMs}))
163
+ ${credentialPatterns.join('\n ')}
164
164
  FILTER(${credentialFilters.join(' || ')})`;
165
165
  }
166
166
  /** Build the store-side ASK query from the same canonical proof model. */
@@ -173,11 +173,11 @@ export function buildAuthoritativePrivateMetaAskQuery(contextGraphId, memberProo
173
173
  const memberRequirements = memberProof
174
174
  ? `\n${renderMemberProof(contextGraphId, contextGraphUri, memberProof)}`
175
175
  : '';
176
- return `PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
177
- ASK WHERE {
178
- GRAPH <${assertSafeIri(metaGraph)}> {
179
- ${requirements}${memberRequirements}
180
- }
176
+ return `PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
177
+ ASK WHERE {
178
+ GRAPH <${assertSafeIri(metaGraph)}> {
179
+ ${requirements}${memberRequirements}
180
+ }
181
181
  }`;
182
182
  }
183
183
  //# sourceMappingURL=context-graph-private-meta-proof.js.map
@@ -87,17 +87,17 @@ export function buildAuthoritativePublicMetaAskQuery(contextGraphId) {
87
87
  if (publicPolicy.kind !== 'normalized-literal') {
88
88
  throw new Error('Public access policy proof must use a normalized literal');
89
89
  }
90
- return `ASK WHERE {
91
- GRAPH <${assertSafeIri(metaGraph)}> {
92
- ${requirements}
93
- FILTER NOT EXISTS {
94
- <${assertSafeIri(contextGraphUri)}> <${accessPolicyPredicate}> ?conflictingAccessPolicy .
95
- FILTER(
96
- !isLiteral(?conflictingAccessPolicy) ||
97
- LCASE(REPLACE(STR(?conflictingAccessPolicy), "^\\\\s+|\\\\s+$", "")) != ${sparqlString(publicPolicy.value)}
98
- )
99
- }
100
- }
90
+ return `ASK WHERE {
91
+ GRAPH <${assertSafeIri(metaGraph)}> {
92
+ ${requirements}
93
+ FILTER NOT EXISTS {
94
+ <${assertSafeIri(contextGraphUri)}> <${accessPolicyPredicate}> ?conflictingAccessPolicy .
95
+ FILTER(
96
+ !isLiteral(?conflictingAccessPolicy) ||
97
+ LCASE(REPLACE(STR(?conflictingAccessPolicy), "^\\\\s+|\\\\s+$", "")) != ${sparqlString(publicPolicy.value)}
98
+ )
99
+ }
100
+ }
101
101
  }`;
102
102
  }
103
103
  //# sourceMappingURL=context-graph-public-meta-proof.js.map
@@ -16,29 +16,29 @@ const CONTEXT_GRAPH_URI_PREFIX = 'did:dkg:context-graph:';
16
16
  export async function repairCreatorPublicMetaProjections(store, peerId) {
17
17
  const ontologyGraph = assertSafeIri(contextGraphDataGraphUri(SYSTEM_CONTEXT_GRAPHS.ONTOLOGY));
18
18
  const creatorDid = assertSafeIri(`did:dkg:agent:${peerId}`);
19
- const candidatesResult = await store.query(`
20
- SELECT DISTINCT ?contextGraph WHERE {
21
- GRAPH <${ontologyGraph}> {
22
- ?contextGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_CONTEXT_GRAPH}> ;
23
- <${DKG_ONTOLOGY.DKG_CREATOR}> <${creatorDid}> ;
24
- <${DKG_ONTOLOGY.DKG_ACCESS_POLICY}> ?accessPolicy .
25
- FILTER(
26
- isLiteral(?accessPolicy) &&
27
- LCASE(REPLACE(STR(?accessPolicy), "^\\\\s+|\\\\s+$", "")) = "public"
28
- )
29
- FILTER NOT EXISTS {
30
- ?contextGraph <${DKG_ONTOLOGY.DKG_CREATOR}> ?conflictingCreator .
31
- FILTER(?conflictingCreator != <${creatorDid}>)
32
- }
33
- FILTER NOT EXISTS {
34
- ?contextGraph <${DKG_ONTOLOGY.DKG_ACCESS_POLICY}> ?conflictingAccessPolicy .
35
- FILTER(
36
- !isLiteral(?conflictingAccessPolicy) ||
37
- LCASE(REPLACE(STR(?conflictingAccessPolicy), "^\\\\s+|\\\\s+$", "")) != "public"
38
- )
39
- }
40
- }
41
- }
19
+ const candidatesResult = await store.query(`
20
+ SELECT DISTINCT ?contextGraph WHERE {
21
+ GRAPH <${ontologyGraph}> {
22
+ ?contextGraph <${DKG_ONTOLOGY.RDF_TYPE}> <${DKG_ONTOLOGY.DKG_CONTEXT_GRAPH}> ;
23
+ <${DKG_ONTOLOGY.DKG_CREATOR}> <${creatorDid}> ;
24
+ <${DKG_ONTOLOGY.DKG_ACCESS_POLICY}> ?accessPolicy .
25
+ FILTER(
26
+ isLiteral(?accessPolicy) &&
27
+ LCASE(REPLACE(STR(?accessPolicy), "^\\\\s+|\\\\s+$", "")) = "public"
28
+ )
29
+ FILTER NOT EXISTS {
30
+ ?contextGraph <${DKG_ONTOLOGY.DKG_CREATOR}> ?conflictingCreator .
31
+ FILTER(?conflictingCreator != <${creatorDid}>)
32
+ }
33
+ FILTER NOT EXISTS {
34
+ ?contextGraph <${DKG_ONTOLOGY.DKG_ACCESS_POLICY}> ?conflictingAccessPolicy .
35
+ FILTER(
36
+ !isLiteral(?conflictingAccessPolicy) ||
37
+ LCASE(REPLACE(STR(?conflictingAccessPolicy), "^\\\\s+|\\\\s+$", "")) != "public"
38
+ )
39
+ }
40
+ }
41
+ }
42
42
  `);
43
43
  const candidateSubjects = candidatesResult.type === 'bindings'
44
44
  ? [...new Set(candidatesResult.bindings
@@ -55,16 +55,16 @@ export async function repairCreatorPublicMetaProjections(store, peerId) {
55
55
  if (!contextGraphId || contextGraphDataGraphUri(contextGraphId) !== subject)
56
56
  continue;
57
57
  const metaGraph = assertSafeIri(contextGraphMetaGraphUri(contextGraphId));
58
- const existingResult = await store.query(`
59
- SELECT ?predicate ?object WHERE {
60
- GRAPH <${metaGraph}> {
61
- <${assertSafeIri(subject)}> ?predicate ?object .
62
- FILTER(?predicate IN (
63
- <${DKG_ONTOLOGY.RDF_TYPE}>,
64
- <${DKG_ONTOLOGY.DKG_ACCESS_POLICY}>
65
- ))
66
- }
67
- }
58
+ const existingResult = await store.query(`
59
+ SELECT ?predicate ?object WHERE {
60
+ GRAPH <${metaGraph}> {
61
+ <${assertSafeIri(subject)}> ?predicate ?object .
62
+ FILTER(?predicate IN (
63
+ <${DKG_ONTOLOGY.RDF_TYPE}>,
64
+ <${DKG_ONTOLOGY.DKG_ACCESS_POLICY}>
65
+ ))
66
+ }
67
+ }
68
68
  `);
69
69
  const existing = existingResult.type === 'bindings'
70
70
  ? existingResult.bindings
@@ -0,0 +1,31 @@
1
+ import type { ContextGraphSub, ContextGraphSubInput, ContextGraphSubscriptionRecord, ContextGraphSyncMode } from './dkg-agent-types.js';
2
+ export declare function normalizeContextGraphSubscriptionTransition(previous: ContextGraphSub | undefined, next: ContextGraphSubInput): ContextGraphSub;
3
+ export declare function resolveContextGraphSyncMode(input: {
4
+ existing?: Pick<ContextGraphSub, 'subscribed' | 'syncMode'>;
5
+ requested?: ContextGraphSyncMode;
6
+ hasDormantDurableIntent: boolean;
7
+ }): ContextGraphSyncMode;
8
+ export type ContextGraphSubscriptionPersistenceProjection = {
9
+ action: 'skip';
10
+ persistMemberIntent: false;
11
+ } | {
12
+ action: 'delete';
13
+ persistMemberIntent: true;
14
+ } | {
15
+ action: 'save';
16
+ persistMemberIntent: boolean;
17
+ record: ContextGraphSubscriptionRecord;
18
+ };
19
+ /**
20
+ * Canonical durable projection for live Context Graph subscription state.
21
+ *
22
+ * On-demand member intent remains process-local. A Core hosting obligation is
23
+ * independently durable and therefore projects to a host-only row. Always-on
24
+ * member intent projects the complete live readiness state.
25
+ */
26
+ export declare function projectContextGraphSubscriptionPersistence(input: {
27
+ contextGraphId: string;
28
+ subscription: ContextGraphSub | undefined;
29
+ syncScoped: boolean;
30
+ }): ContextGraphSubscriptionPersistenceProjection;
31
+ //# sourceMappingURL=context-graph-subscription-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-graph-subscription-policy.d.ts","sourceRoot":"","sources":["../src/context-graph-subscription-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,wBAAgB,2CAA2C,CACzD,QAAQ,EAAE,eAAe,GAAG,SAAS,EACrC,IAAI,EAAE,oBAAoB,GACzB,eAAe,CAKjB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,QAAQ,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,UAAU,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,uBAAuB,EAAE,OAAO,CAAC;CAClC,GAAG,oBAAoB,CAQvB;AAED,MAAM,MAAM,6CAA6C,GACrD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,KAAK,CAAA;CAAE,GAC9C;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,mBAAmB,EAAE,IAAI,CAAA;CAAE,GAC/C;IACA,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,8BAA8B,CAAC;CACxC,CAAC;AAEJ;;;;;;GAMG;AACH,wBAAgB,0CAA0C,CAAC,KAAK,EAAE;IAChE,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,eAAe,GAAG,SAAS,CAAC;IAC1C,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,6CAA6C,CA2BhD"}
@@ -0,0 +1,48 @@
1
+ export function normalizeContextGraphSubscriptionTransition(previous, next) {
2
+ return {
3
+ ...next,
4
+ syncMode: next.syncMode ?? previous?.syncMode ?? 'always-on',
5
+ };
6
+ }
7
+ export function resolveContextGraphSyncMode(input) {
8
+ if (input.hasDormantDurableIntent
9
+ || (input.existing?.subscribed === true && input.existing.syncMode === 'always-on')) {
10
+ return 'always-on';
11
+ }
12
+ return input.requested ?? input.existing?.syncMode ?? 'always-on';
13
+ }
14
+ /**
15
+ * Canonical durable projection for live Context Graph subscription state.
16
+ *
17
+ * On-demand member intent remains process-local. A Core hosting obligation is
18
+ * independently durable and therefore projects to a host-only row. Always-on
19
+ * member intent projects the complete live readiness state.
20
+ */
21
+ export function projectContextGraphSubscriptionPersistence(input) {
22
+ const sub = input.subscription;
23
+ if (sub?.syncMode === 'on-demand' && sub.coreHosted !== true) {
24
+ return { action: 'skip', persistMemberIntent: false };
25
+ }
26
+ if (!sub?.subscribed && !sub?.coreHosted) {
27
+ return { action: 'delete', persistMemberIntent: true };
28
+ }
29
+ const persistMemberIntent = sub.syncMode !== 'on-demand';
30
+ return {
31
+ action: 'save',
32
+ persistMemberIntent,
33
+ record: {
34
+ id: input.contextGraphId,
35
+ name: sub.name,
36
+ subscribed: persistMemberIntent && sub.subscribed,
37
+ synced: persistMemberIntent && sub.synced,
38
+ sharedMemorySynced: persistMemberIntent ? sub.sharedMemorySynced : false,
39
+ metaSynced: persistMemberIntent ? sub.metaSynced : false,
40
+ onChainId: sub.onChainId,
41
+ onChainHash: sub.onChainHash,
42
+ lastReconciledOrdinal: sub.lastReconciledOrdinal,
43
+ coreHosted: sub.coreHosted,
44
+ syncScoped: persistMemberIntent && input.syncScoped,
45
+ },
46
+ };
47
+ }
48
+ //# sourceMappingURL=context-graph-subscription-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-graph-subscription-policy.js","sourceRoot":"","sources":["../src/context-graph-subscription-policy.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,2CAA2C,CACzD,QAAqC,EACrC,IAA0B;IAE1B,OAAO;QACL,GAAG,IAAI;QACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,EAAE,QAAQ,IAAI,WAAW;KAC7D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAI3C;IACC,IACE,KAAK,CAAC,uBAAuB;WAC1B,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,KAAK,WAAW,CAAC,EACnF,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,QAAQ,IAAI,WAAW,CAAC;AACpE,CAAC;AAWD;;;;;;GAMG;AACH,MAAM,UAAU,0CAA0C,CAAC,KAI1D;IACC,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC;IAC/B,IAAI,GAAG,EAAE,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;QAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,UAAU,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC;QACzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC;IACzD,CAAC;IAED,MAAM,mBAAmB,GAAG,GAAG,CAAC,QAAQ,KAAK,WAAW,CAAC;IACzD,OAAO;QACL,MAAM,EAAE,MAAM;QACd,mBAAmB;QACnB,MAAM,EAAE;YACN,EAAE,EAAE,KAAK,CAAC,cAAc;YACxB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,UAAU,EAAE,mBAAmB,IAAI,GAAG,CAAC,UAAU;YACjD,MAAM,EAAE,mBAAmB,IAAI,GAAG,CAAC,MAAM;YACzC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK;YACxE,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK;YACxD,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,qBAAqB,EAAE,GAAG,CAAC,qBAAqB;YAChD,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,UAAU,EAAE,mBAAmB,IAAI,KAAK,CAAC,UAAU;SACpD;KACF,CAAC;AACJ,CAAC"}
@@ -233,29 +233,29 @@ function replaceCuratorMetaProjectionSparql(contextGraphId, metaGraph, stagingGr
233
233
  const delegationPrefix = `did:dkg:agent-delegation:${contextGraphId}:`;
234
234
  assertSafeIri(metaGraph);
235
235
  assertSafeIri(stagingGraph);
236
- return `DELETE {
237
- GRAPH <${metaGraph}> { ?staleSubject ?stalePredicate ?staleObject . }
238
- }
239
- INSERT {
240
- GRAPH <${metaGraph}> { ?freshSubject ?freshPredicate ?freshObject . }
241
- }
242
- WHERE {
243
- {
244
- GRAPH <${metaGraph}> {
245
- ?staleSubject ?stalePredicate ?staleObject .
246
- FILTER (
247
- (
248
- ?staleSubject = <${contextGraphUri}> &&
249
- ?stalePredicate != <${DKG_ONTOLOGY.DKG_REVOKED_AGENT}>
250
- ) ||
251
- STRSTARTS(STR(?staleSubject), ${JSON.stringify(delegationPrefix)})
252
- )
253
- }
254
- }
255
- UNION
256
- {
257
- GRAPH <${stagingGraph}> { ?freshSubject ?freshPredicate ?freshObject . }
258
- }
236
+ return `DELETE {
237
+ GRAPH <${metaGraph}> { ?staleSubject ?stalePredicate ?staleObject . }
238
+ }
239
+ INSERT {
240
+ GRAPH <${metaGraph}> { ?freshSubject ?freshPredicate ?freshObject . }
241
+ }
242
+ WHERE {
243
+ {
244
+ GRAPH <${metaGraph}> {
245
+ ?staleSubject ?stalePredicate ?staleObject .
246
+ FILTER (
247
+ (
248
+ ?staleSubject = <${contextGraphUri}> &&
249
+ ?stalePredicate != <${DKG_ONTOLOGY.DKG_REVOKED_AGENT}>
250
+ ) ||
251
+ STRSTARTS(STR(?staleSubject), ${JSON.stringify(delegationPrefix)})
252
+ )
253
+ }
254
+ }
255
+ UNION
256
+ {
257
+ GRAPH <${stagingGraph}> { ?freshSubject ?freshPredicate ?freshObject . }
258
+ }
259
259
  }`;
260
260
  }
261
261
  async function atomicallyReplaceCuratorMetaSnapshot(agent, contextGraphId, snapshot, ctx) {
package/dist/discovery.js CHANGED
@@ -21,17 +21,17 @@ export class DiscoveryClient {
21
21
  filter += `\n ?agent <${DKG}agentAddress> "${escapeSparqlLiteral(options.agentAddress)}" .`;
22
22
  }
23
23
  const limitClause = options.limit ? `LIMIT ${options.limit}` : '';
24
- const sparql = `
25
- SELECT ?agent ?name ?peerId ?framework ?nodeRole ?relayAddress ?agentAddress WHERE {
26
- ?agent a <${DKG}Agent> ;
27
- <${SCHEMA}name> ?name ;
28
- <${DKG}peerId> ?peerId .${filter}
29
- OPTIONAL { ?agent <${SKILL}framework> ?framework }
30
- OPTIONAL { ?agent <${DKG}nodeRole> ?nodeRole }
31
- OPTIONAL { ?agent <${DKG}relayAddress> ?relayAddress }
32
- OPTIONAL { ?agent <${DKG}agentAddress> ?agentAddress }
33
- }
34
- ${limitClause}
24
+ const sparql = `
25
+ SELECT ?agent ?name ?peerId ?framework ?nodeRole ?relayAddress ?agentAddress WHERE {
26
+ ?agent a <${DKG}Agent> ;
27
+ <${SCHEMA}name> ?name ;
28
+ <${DKG}peerId> ?peerId .${filter}
29
+ OPTIONAL { ?agent <${SKILL}framework> ?framework }
30
+ OPTIONAL { ?agent <${DKG}nodeRole> ?nodeRole }
31
+ OPTIONAL { ?agent <${DKG}relayAddress> ?relayAddress }
32
+ OPTIONAL { ?agent <${DKG}agentAddress> ?agentAddress }
33
+ }
34
+ ${limitClause}
35
35
  `;
36
36
  const result = await this.engine.query(sparql, {
37
37
  contextGraphId: AGENT_REGISTRY_CONTEXT_GRAPH,
@@ -55,7 +55,7 @@ export class DiscoveryClient {
55
55
  async findAgentPeerIdsByAddress(agentAddress, options = {}) {
56
56
  const isEvmAddress = /^0x[0-9a-fA-F]{40}$/.test(agentAddress);
57
57
  const addressMatch = isEvmAddress
58
- ? `?agent <${DKG}agentAddress> ?storedAgentAddress .
58
+ ? `?agent <${DKG}agentAddress> ?storedAgentAddress .
59
59
  FILTER(LCASE(STR(?storedAgentAddress)) = "${escapeSparqlLiteral(agentAddress.toLowerCase())}")`
60
60
  : `?agent <${DKG}agentAddress> "${escapeSparqlLiteral(agentAddress)}" .`;
61
61
  const limit = options.limit === undefined
@@ -64,15 +64,15 @@ export class DiscoveryClient {
64
64
  const afterFilter = options.afterPeerId
65
65
  ? `FILTER(STR(?peerId) > "${escapeSparqlLiteral(options.afterPeerId)}")`
66
66
  : '';
67
- const result = await this.engine.query(`
68
- SELECT DISTINCT ?peerId WHERE {
69
- ?agent a <${DKG}Agent> ;
70
- <${DKG}peerId> ?peerId .
71
- ${addressMatch}
72
- ${afterFilter}
73
- }
74
- ORDER BY ASC(STR(?peerId))
75
- ${limit === undefined ? '' : `LIMIT ${limit}`}
67
+ const result = await this.engine.query(`
68
+ SELECT DISTINCT ?peerId WHERE {
69
+ ?agent a <${DKG}Agent> ;
70
+ <${DKG}peerId> ?peerId .
71
+ ${addressMatch}
72
+ ${afterFilter}
73
+ }
74
+ ORDER BY ASC(STR(?peerId))
75
+ ${limit === undefined ? '' : `LIMIT ${limit}`}
76
76
  `, {
77
77
  contextGraphId: AGENT_REGISTRY_CONTEXT_GRAPH,
78
78
  signal: options.signal,
@@ -86,7 +86,7 @@ export class DiscoveryClient {
86
86
  let skillMatch = `?offering <${SKILL}skill> ?skillType .`;
87
87
  if (options.skillType) {
88
88
  const skillUri = assertSafeIri(`${SKILL}${options.skillType}`);
89
- skillMatch = `?offering <${SKILL}skill> <${skillUri}> .
89
+ skillMatch = `?offering <${SKILL}skill> <${skillUri}> .
90
90
  BIND(<${skillUri}> AS ?skillType)`;
91
91
  }
92
92
  if (options.maxPrice !== undefined) {
@@ -100,19 +100,19 @@ export class DiscoveryClient {
100
100
  }
101
101
  const limitClause = options.limit ? `LIMIT ${options.limit}` : '';
102
102
  const filterBlock = filters.join('\n ');
103
- const sparql = `
104
- PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
105
- SELECT ?agent ?agentName ?offering ?skillType ?price ?successRate ?currency WHERE {
106
- ?agent a <${DKG}Agent> ;
107
- <${SCHEMA}name> ?agentName ;
108
- <${SKILL}offersSkill> ?offering .
109
- ${skillMatch}
110
- OPTIONAL { ?offering <${SKILL}pricePerCall> ?price }
111
- OPTIONAL { ?offering <${SKILL}successRate> ?successRate }
112
- OPTIONAL { ?offering <${SKILL}currency> ?currency }
113
- ${filterBlock}
114
- }
115
- ${limitClause}
103
+ const sparql = `
104
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
105
+ SELECT ?agent ?agentName ?offering ?skillType ?price ?successRate ?currency WHERE {
106
+ ?agent a <${DKG}Agent> ;
107
+ <${SCHEMA}name> ?agentName ;
108
+ <${SKILL}offersSkill> ?offering .
109
+ ${skillMatch}
110
+ OPTIONAL { ?offering <${SKILL}pricePerCall> ?price }
111
+ OPTIONAL { ?offering <${SKILL}successRate> ?successRate }
112
+ OPTIONAL { ?offering <${SKILL}currency> ?currency }
113
+ ${filterBlock}
114
+ }
115
+ ${limitClause}
116
116
  `;
117
117
  const result = await this.engine.query(sparql, { contextGraphId: AGENT_REGISTRY_CONTEXT_GRAPH });
118
118
  return result.bindings.map((row) => ({
@@ -140,19 +140,19 @@ export class DiscoveryClient {
140
140
  // contains a `>` / whitespace / control char would still break
141
141
  // the second query's `<${agentUri}>` interpolation. Codex review
142
142
  // of PR #700 round 3 caught the prior unguarded interpolation.
143
- const scalar = `
144
- SELECT ?agent ?name ?framework ?nodeRole ?relayAddress ?agentAddress ?lastSeen WHERE {
145
- ?agent a <${DKG}Agent> ;
146
- <${SCHEMA}name> ?name ;
147
- <${DKG}peerId> "${escapeSparqlLiteral(peerId)}" .
148
- FILTER(isIRI(?agent))
149
- OPTIONAL { ?agent <${SKILL}framework> ?framework }
150
- OPTIONAL { ?agent <${DKG}nodeRole> ?nodeRole }
151
- OPTIONAL { ?agent <${DKG}relayAddress> ?relayAddress }
152
- OPTIONAL { ?agent <${DKG}agentAddress> ?agentAddress }
153
- OPTIONAL { ?agent <${DKG}lastSeen> ?lastSeen }
154
- }
155
- LIMIT 1
143
+ const scalar = `
144
+ SELECT ?agent ?name ?framework ?nodeRole ?relayAddress ?agentAddress ?lastSeen WHERE {
145
+ ?agent a <${DKG}Agent> ;
146
+ <${SCHEMA}name> ?name ;
147
+ <${DKG}peerId> "${escapeSparqlLiteral(peerId)}" .
148
+ FILTER(isIRI(?agent))
149
+ OPTIONAL { ?agent <${SKILL}framework> ?framework }
150
+ OPTIONAL { ?agent <${DKG}nodeRole> ?nodeRole }
151
+ OPTIONAL { ?agent <${DKG}relayAddress> ?relayAddress }
152
+ OPTIONAL { ?agent <${DKG}agentAddress> ?agentAddress }
153
+ OPTIONAL { ?agent <${DKG}lastSeen> ?lastSeen }
154
+ }
155
+ LIMIT 1
156
156
  `;
157
157
  const scalarResult = await this.engine.query(scalar, {
158
158
  contextGraphId: AGENT_REGISTRY_CONTEXT_GRAPH,
@@ -179,10 +179,10 @@ export class DiscoveryClient {
179
179
  catch {
180
180
  return null;
181
181
  }
182
- const multiSparql = `
183
- SELECT ?multiaddr WHERE {
184
- ${sparqlIri(safeAgentIri)} <${DKG}multiaddr> ?multiaddr .
185
- }
182
+ const multiSparql = `
183
+ SELECT ?multiaddr WHERE {
184
+ ${sparqlIri(safeAgentIri)} <${DKG}multiaddr> ?multiaddr .
185
+ }
186
186
  `;
187
187
  const multiResult = await this.engine.query(multiSparql, {
188
188
  contextGraphId: AGENT_REGISTRY_CONTEXT_GRAPH,