@twin.org/dataspace-data-plane-service 0.0.3-next.42 → 0.0.3-next.44

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.
@@ -1,3 +1,6 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { HttpUrlHelper } from "@twin.org/api-models";
1
4
  import { TaskStatus } from "@twin.org/background-task-models";
2
5
  import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
3
6
  import { ArrayHelper, BaseError, ComponentFactory, ConflictError, Converter, GeneralError, GuardError, Guards, Is, JsonHelper, NotFoundError, RandomHelper, UnauthorizedError, UnprocessableError, Validation, ValidationError } from "@twin.org/core";
@@ -135,11 +138,6 @@ export class DataspaceDataPlaneService {
135
138
  * @internal
136
139
  */
137
140
  _taskScheduler;
138
- /**
139
- * The keys to use from the context ids to create partitions.
140
- * @internal
141
- */
142
- _partitionContextIds;
143
141
  /**
144
142
  * The trust component.
145
143
  * @internal
@@ -151,15 +149,10 @@ export class DataspaceDataPlaneService {
151
149
  */
152
150
  _policyEnforcementPoint;
153
151
  /**
154
- * The tenant component.
155
- * @internal
156
- */
157
- _tenantComponent;
158
- /**
159
- * The component type name for the hosting component.
152
+ * The platform component.
160
153
  * @internal
161
154
  */
162
- _urlTransformerComponent;
155
+ _platformComponent;
163
156
  /**
164
157
  * Entity storage for Transfer Process entities.
165
158
  * Used to read transfer state from shared storage (written by Control Plane).
@@ -182,7 +175,7 @@ export class DataspaceDataPlaneService {
182
175
  * @param options The options for the data plane.
183
176
  */
184
177
  constructor(options) {
185
- this._loggingComponentType = options?.loggingComponentType ?? "logging";
178
+ this._loggingComponentType = options?.loggingComponentType;
186
179
  this._logging = ComponentFactory.getIfExists(this._loggingComponentType);
187
180
  this._entityStorageActivityLogs = EntityStorageConnectorFactory.get(options?.activityLogEntityStorageType ?? "activity-log-details");
188
181
  this._entityStorageActivityTasks = EntityStorageConnectorFactory.get(options?.activityTaskEntityStorageType ?? "activity-task");
@@ -190,8 +183,7 @@ export class DataspaceDataPlaneService {
190
183
  this._taskScheduler = ComponentFactory.get(options?.taskSchedulerComponentType ?? "task-scheduler");
191
184
  this._trustComponent = ComponentFactory.get(options?.trustComponentType ?? "trust");
192
185
  this._policyEnforcementPoint = ComponentFactory.get(options?.pepComponentType ?? "policy-enforcement-point-service");
193
- this._tenantComponent = ComponentFactory.getIfExists(options?.tenantComponentType ?? "tenant");
194
- this._urlTransformerComponent = ComponentFactory.get(options?.urlTransformerComponentType ?? "url-transformer");
186
+ this._platformComponent = ComponentFactory.get(options?.platformComponentType ?? "platform");
195
187
  // Entity storage for Transfer Process state lookup
196
188
  // Used to read transfer state from shared storage (written by Control Plane)
197
189
  this._transferProcessStorage = EntityStorageConnectorFactory.get(options?.transferProcessEntityStorageType ?? "transfer-process");
@@ -208,7 +200,6 @@ export class DataspaceDataPlaneService {
208
200
  DataspaceProtocolDataTypes.registerTypes();
209
201
  this._activityLogStatusCallbacks = {};
210
202
  this._registeredTaskTypes = [];
211
- this._partitionContextIds = options?.partitionContextIds;
212
203
  this._retainTasksFor =
213
204
  DataspaceDataPlaneService._DEFAULT_RETAIN_INTERVAL * DataspaceDataPlaneService._MS_PER_MINUTE;
214
205
  this._retainActivityLogsFor =
@@ -313,63 +304,57 @@ export class DataspaceDataPlaneService {
313
304
  /**
314
305
  * Notify an Activity.
315
306
  * @param activity The Activity notified.
316
- * @param trustPayload Optional trust payload to verify the requester's identity.
307
+ * @param trustPayload Trust payload to verify the requesters identity.
317
308
  * @returns The activity's id or entry.
318
309
  */
319
310
  async notifyActivity(activity, trustPayload) {
320
311
  Guards.object(DataspaceDataPlaneService.CLASS_NAME, "activity", activity);
321
- // For cross-node push deliveries the caller presents a JWT. Verify it,
322
- // confirm the referenced transfer is still in STARTED state, and assert
323
- // the verified identity is one of the two parties on that transfer.
324
- if (Is.stringValue(trustPayload)) {
325
- const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "notifyActivity");
326
- const generatorPid = this.calculateActivityGeneratorIdentity(activity);
327
- // Primary lookup: by consumerPid (the entity's primary key). If this hits, the
328
- // generator's PID equals consumerPid — the generator is the consumer side.
329
- let transferProcess = await this._transferProcessStorage.get(generatorPid);
330
- const generatorIsConsumer = Boolean(transferProcess);
331
- if (!transferProcess) {
332
- // Fallback: generatorPid === providerPid. providerPid is a UUIDv7 so it's
333
- // unique per transfer, but defensively reject any case where the secondary
334
- // index returns more than one match — silent first-match would risk
335
- // authorising the wrong transfer if the invariant ever breaks.
336
- const result = await this._transferProcessStorage.query({
337
- conditions: [
338
- {
339
- property: "providerPid",
340
- value: generatorPid,
341
- comparison: ComparisonOperator.Equals
342
- }
343
- ]
344
- });
345
- if (result.entities.length > 1) {
346
- throw new UnauthorizedError(DataspaceDataPlaneService.CLASS_NAME, "pushActivityNotAuthorized");
347
- }
348
- transferProcess = result.entities[0];
349
- // generatorIsConsumer stays false → generator is the provider side.
350
- }
351
- if (transferProcess?.state !== DataspaceProtocolTransferProcessStateType.STARTED) {
352
- throw new UnauthorizedError(DataspaceDataPlaneService.CLASS_NAME, "pushActivityNotAuthorized");
353
- }
354
- // Bind the verified identity to the side of the transfer matching the claimed
355
- // generator. Without this, a party with a valid token for transfer X can post
356
- // an activity claiming to be the other party on the same transfer.
357
- // Stored consumer/provider identities are composites
358
- // (`nodeDid:hash(tenantId)`)
359
- const expectedIdentity = generatorIsConsumer
360
- ? transferProcess.consumerIdentity
361
- : transferProcess.providerIdentity;
362
- const callerComposite = Is.stringValue(trustInfo.tenantId)
363
- ? `${trustInfo.identity}:${trustInfo.tenantId}`
364
- : trustInfo.identity;
365
- if (!Is.stringValue(expectedIdentity) || callerComposite !== expectedIdentity) {
312
+ // Every caller must present a trust payload internal calls have no bypass,
313
+ // a missing payload fails verification. Verify it, confirm the referenced
314
+ // transfer is still in STARTED state, and assert the verified identity is
315
+ // one of the two parties on that transfer.
316
+ const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "notifyActivity");
317
+ const generatorPid = this.calculateActivityGeneratorIdentity(activity);
318
+ // Primary lookup: by consumerPid (the entity's primary key). If this hits, the
319
+ // generator's PID equals consumerPid — the generator is the consumer side.
320
+ let transferProcess = await this._transferProcessStorage.get(generatorPid);
321
+ const generatorIsConsumer = Boolean(transferProcess);
322
+ if (!transferProcess) {
323
+ // Fallback: generatorPid === providerPid. providerPid is a UUIDv7 so it's
324
+ // unique per transfer, but defensively reject any case where the secondary
325
+ // index returns more than one match — silent first-match would risk
326
+ // authorising the wrong transfer if the invariant ever breaks.
327
+ const result = await this._transferProcessStorage.query({
328
+ conditions: [
329
+ {
330
+ property: "providerPid",
331
+ value: generatorPid,
332
+ comparison: ComparisonOperator.Equals
333
+ }
334
+ ]
335
+ });
336
+ if (result.entities.length > 1) {
366
337
  throw new UnauthorizedError(DataspaceDataPlaneService.CLASS_NAME, "pushActivityNotAuthorized");
367
338
  }
368
- // Apply the transfer's agreement to the inbound activity via the PEP, which
369
- // may deny it or manipulate (filter/redact) the payload. Dispatch what the
370
- // PEP returns.
371
- activity = await this.enforceInboxPolicy(transferProcess, activity, generatorIsConsumer);
339
+ transferProcess = result.entities[0];
340
+ // generatorIsConsumer stays false generator is the provider side.
372
341
  }
342
+ if (transferProcess?.state !== DataspaceProtocolTransferProcessStateType.STARTED) {
343
+ throw new UnauthorizedError(DataspaceDataPlaneService.CLASS_NAME, "pushActivityNotAuthorized");
344
+ }
345
+ // Bind the verified identity to the side of the transfer matching the claimed
346
+ // generator. Without this, a party with a valid token for transfer X can post
347
+ // an activity claiming to be the other party on the same transfer.
348
+ const expectedIdentity = generatorIsConsumer
349
+ ? transferProcess.consumerIdentity
350
+ : transferProcess.providerIdentity;
351
+ if (!Is.stringValue(expectedIdentity) || trustInfo.identity !== expectedIdentity) {
352
+ throw new UnauthorizedError(DataspaceDataPlaneService.CLASS_NAME, "pushActivityNotAuthorized");
353
+ }
354
+ // Apply the transfer's agreement to the inbound activity via the PEP, which
355
+ // may deny it or manipulate (filter/redact) the payload. Dispatch what the
356
+ // PEP returns.
357
+ activity = await this.enforceInboxPolicy(transferProcess, activity, generatorIsConsumer);
373
358
  await this._logging?.log({
374
359
  level: "debug",
375
360
  source: DataspaceDataPlaneService.CLASS_NAME,
@@ -695,16 +680,14 @@ export class DataspaceDataPlaneService {
695
680
  consumerPid
696
681
  });
697
682
  }
698
- // On multi-tenant publishers, the consumer must have baked its tenant token into the
683
+ // The consumer must have baked its organization ID into the
699
684
  // callback URL so the consumer's TenantProcessor can route inbound push deliveries.
700
685
  // Reject at setup time rather than silently 401 every push.
701
686
  // Parse as a real URL so we match on the actual query parameter, not a substring
702
687
  // in a path segment / value position.
703
- if (this._partitionContextIds?.includes(ContextIdKeys.Tenant)) {
704
- const tenantId = await this._urlTransformerComponent.getEncryptedFromUrl(transferProcess.dataAddress.endpoint, "tenant");
705
- if (!Is.stringValue(tenantId)) {
706
- throw new GeneralError(DataspaceDataPlaneService.CLASS_NAME, "pushSubscriptionMissingTenantToken", { consumerPid, endpoint: transferProcess.dataAddress.endpoint });
707
- }
688
+ const organizationId = HttpUrlHelper.getQueryStringParam(transferProcess.dataAddress.endpoint, ContextIdKeys.Organization);
689
+ if (!Is.stringValue(organizationId)) {
690
+ throw new GeneralError(DataspaceDataPlaneService.CLASS_NAME, "pushSubscriptionMissingOrganizationId", { consumerPid, endpoint: transferProcess.dataAddress.endpoint });
708
691
  }
709
692
  const followActivityId = `${FOLLOW_ACTIVITY_URN_PREFIX}${RandomHelper.generateUuidV7("compact")}`;
710
693
  const followActivity = {
@@ -1079,15 +1062,9 @@ export class DataspaceDataPlaneService {
1079
1062
  }
1080
1063
  this._cleanUpProcessOngoing = true;
1081
1064
  let numRecordsDeleted = 0;
1082
- if (this._partitionContextIds?.includes(ContextIdKeys.Tenant)) {
1083
- // The cleanup must be done by tenant as the data is partitioned
1084
- await this._tenantComponent?.runPerTenant(async () => {
1085
- numRecordsDeleted += await this.cleanupActivityLogPartition();
1086
- });
1087
- }
1088
- else {
1065
+ await this._platformComponent.execute(async () => {
1089
1066
  numRecordsDeleted += await this.cleanupActivityLogPartition();
1090
- }
1067
+ });
1091
1068
  await this._logging?.log({
1092
1069
  level: "debug",
1093
1070
  message: "activityLogCleanedUp",
@@ -1206,15 +1183,9 @@ export class DataspaceDataPlaneService {
1206
1183
  return;
1207
1184
  }
1208
1185
  let numDeleted = 0;
1209
- if (this._partitionContextIds?.includes(ContextIdKeys.Tenant)) {
1210
- // The cleanup must be done by tenant as the data is partitioned
1211
- await this._tenantComponent?.runPerTenant(async () => {
1212
- numDeleted += await this.cleanupOrphanedPushSubscriptionsPartition();
1213
- });
1214
- }
1215
- else {
1186
+ await this._platformComponent.execute(async () => {
1216
1187
  numDeleted += await this.cleanupOrphanedPushSubscriptionsPartition();
1217
- }
1188
+ });
1218
1189
  await this._logging?.log({
1219
1190
  level: "debug",
1220
1191
  message: "pushSubscriptionsCleanedUp",
@@ -1223,8 +1194,7 @@ export class DataspaceDataPlaneService {
1223
1194
  });
1224
1195
  }
1225
1196
  /**
1226
- * Per-partition cleanup body for orphaned PushSubscriptions. Must run inside the
1227
- * target tenant's context on multi-tenant nodes (caller wraps `ContextIdStore.run`).
1197
+ * Per-partition cleanup body for orphaned PushSubscriptions.
1228
1198
  * @returns The number of subscriptions deleted in this partition.
1229
1199
  * @internal
1230
1200
  */
@@ -1 +1 @@
1
- {"version":3,"file":"dataspaceDataPlaneService.js","sourceRoot":"","sources":["../../src/dataspaceDataPlaneService.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,UAAU,EAIV,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACN,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,EAAE,EACF,UAAU,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB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AC;gCACF,MAAM;4BAEP,KAAK,UAAU,CAAC,MAAM;gCACrB,KAAK,GAAG;oCACP,GAAG,MAAM;oCACT,MAAM,EAAE,kBAAkB,CAAC,MAAM;oCACjC,KAAK,EAAE,WAAW,CAAC,KAAK;iCACxB,CAAC;gCACF,MAAM;4BAEP,KAAK,UAAU,CAAC,SAAS;gCACxB,oCAAoC;gCACpC,MAAM;wBACR,CAAC;oBACF,CAAC;gBACF,CAAC;gBAED,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;oBACtB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;YACF,CAAC;YACD,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtC,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC;YACzC,CAAC;iBAAM,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACjD,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC;YAC3C,CAAC;iBAAM,IAAI,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACP,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC;YAC7C,CAAC;QACF,CAAC;QACD,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITenantComponent, IUrlTransformerComponent } from \"@twin.org/api-models\";\nimport {\n\tTaskStatus,\n\ttype IBackgroundTaskComponent,\n\ttype IScheduledTaskTime,\n\ttype ITaskSchedulerComponent\n} from \"@twin.org/background-task-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tArrayHelper,\n\tBaseError,\n\tComponentFactory,\n\tConflictError,\n\tConverter,\n\tGeneralError,\n\tGuardError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tNotFoundError,\n\tRandomHelper,\n\tUnauthorizedError,\n\tUnprocessableError,\n\tValidation,\n\tValidationError,\n\ttype IValidationFailure\n} from \"@twin.org/core\";\nimport { Blake2b } from \"@twin.org/crypto\";\nimport { DataTypeHelper, JsonSchemaHelper } from \"@twin.org/data-core\";\nimport {\n\tJsonLdDataTypes,\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionElement,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tActivityProcessingStatus,\n\tActivityTaskStatus,\n\tDataRequestType,\n\tDataspaceAppFactory,\n\tDataspaceContexts,\n\tDataspaceDataTypes,\n\tDataspaceTypes,\n\tgetJsonLdType,\n\ttype DataspaceAppDataset,\n\ttype IActivityLogEntry,\n\ttype IActivityLogStatusNotification,\n\ttype IActivityQuery,\n\ttype IActivityTaskEntry,\n\ttype IDataAssetItemListResult,\n\ttype IDataAssetQuery,\n\ttype IDataRequest,\n\ttype IDataspaceActivity,\n\ttype IDataspaceApp,\n\ttype IDataspaceDataPlaneComponent,\n\ttype IEntitySet,\n\ttype IExecutionPayload,\n\ttype IFilteringQuery,\n\ttype IFollowActivity,\n\ttype IPushDeliveryPayload,\n\ttype ITransferContext,\n\ttype IUndoActivity,\n\ttype TransferProcess\n} from \"@twin.org/dataspace-models\";\nimport { EngineCoreFactory } from \"@twin.org/engine-models\";\nimport { ComparisonOperator, LogicalOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\ttype IPolicyEnforcementPointComponent\n} from \"@twin.org/rights-management-models\";\nimport {\n\tDataspaceProtocolDataTypes,\n\tDataspaceProtocolTransferProcessStateType,\n\ttype IDataspaceProtocolAgreement,\n\ttype IDataspaceProtocolDataset\n} from \"@twin.org/standards-dataspace-protocol\";\nimport {\n\tSchemaOrgContexts,\n\tSchemaOrgDataTypes,\n\tSchemaOrgTypes\n} from \"@twin.org/standards-schema-org\";\nimport {\n\tActivityStreamsContexts,\n\tActivityStreamsTypes,\n\ttype IActivityStreamsActivity\n} from \"@twin.org/standards-w3c-activity-streams\";\nimport { OdrlActionType, OdrlContexts, OdrlTypes } from \"@twin.org/standards-w3c-odrl\";\nimport { TrustHelper, type ITrustComponent } from \"@twin.org/trust-models\";\nimport type { ActivityLogDetails } from \"./entities/activityLogDetails.js\";\nimport type { ActivityTask } from \"./entities/activityTask.js\";\nimport type { PushSubscription } from \"./entities/pushSubscription.js\";\nimport type { IDataspaceDataPlaneServiceConstructorOptions } from \"./models/IDataspaceDataPlaneServiceConstructorOptions.js\";\n\nconst FOLLOW_ACTIVITY_URN_PREFIX = \"urn:x-follow:\";\nconst TRANSFER_URN_PREFIX = \"urn:x-transfer:\";\nconst UNDO_ACTIVITY_URN_PREFIX = \"urn:x-undo:\";\nconst ACTIVITY_LOG_URN_PREFIX = \"urn:x-activity-log:\";\n\n/**\n * Dataspace Data Plane Service.\n */\nexport class DataspaceDataPlaneService implements IDataspaceDataPlaneComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataspaceDataPlaneService>();\n\n\t/**\n\t * Background task type identifier for push delivery tasks.\n\t */\n\tpublic static readonly PUSH_DELIVERY_TASK_TYPE = \"push-delivery\";\n\n\t/**\n\t * Milliseconds per minute (60 * 1000).\n\t * @internal\n\t */\n\tprivate static readonly _MS_PER_MINUTE: number = 60 * 1000;\n\n\t/**\n\t * Minutes per day (24 * 60 = 1440).\n\t * @internal\n\t */\n\tprivate static readonly _MINUTES_PER_DAY: number = 24 * 60;\n\n\t/**\n\t * The default cleanup interval in minutes. (1 hour)\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_CLEANUP_INTERVAL: number = 60;\n\n\t/**\n\t * The default retain interval in minutes. (10 minutes)\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_RETAIN_INTERVAL: number = 10;\n\n\t/**\n\t * Logging service type.\n\t * @internal\n\t */\n\tprivate readonly _loggingComponentType: string;\n\n\t/**\n\t * Logging service.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Storage service for activity logging.\n\t * @internal\n\t */\n\tprivate readonly _entityStorageActivityLogs: IEntityStorageConnector<ActivityLogDetails>;\n\n\t/**\n\t * Storage service for activity tasks.\n\t * @internal\n\t */\n\tprivate readonly _entityStorageActivityTasks: IEntityStorageConnector<ActivityTask>;\n\n\t/**\n\t * Background Task Component.\n\t * @internal\n\t */\n\tprivate readonly _backgroundTaskComponent: IBackgroundTaskComponent;\n\n\t/**\n\t * Activity Log Status callbacks.\n\t * @internal\n\t */\n\tprivate readonly _activityLogStatusCallbacks: {\n\t\t[key: string]: (notification: IActivityLogStatusNotification) => Promise<void>;\n\t};\n\n\t/**\n\t * Track task handler registrations to avoid resetting worker pools on every task.\n\t * @internal\n\t */\n\tprivate readonly _registeredTaskTypes: string[];\n\n\t/**\n\t * Task retention. -1 retain forever.\n\t * @internal\n\t */\n\tprivate readonly _retainTasksFor: number;\n\n\t/**\n\t * Activity Log Entry retention. -1 retain forever.\n\t * @internal\n\t */\n\tprivate readonly _retainActivityLogsFor: number;\n\n\t/**\n\t * Retry count for failed tasks.\n\t * @internal\n\t */\n\tprivate readonly _retryCount?: number;\n\n\t/**\n\t * Max retry count for push delivery HTTP requests.\n\t * @internal\n\t */\n\tprivate readonly _pushRetryCount: number;\n\n\t/**\n\t * Base retry delay (ms) for push delivery HTTP requests.\n\t * @internal\n\t */\n\tprivate readonly _pushRetryBaseDelayMs: number;\n\n\t/**\n\t * Timeout (ms) for each push delivery HTTP POST request.\n\t * @internal\n\t */\n\tprivate readonly _pushTimeoutMs: number;\n\n\t/**\n\t * Clean up interval for activity logs.\n\t * @internal\n\t */\n\tprivate readonly _activityLogCleanUpInterval: number;\n\n\t/**\n\t * Interval in minutes between orphaned PushSubscription cleanup scans.\n\t * @internal\n\t */\n\tprivate readonly _pushSubscriptionCleanupIntervalMinutes: number;\n\n\t/**\n\t * Whether there is an ongoing clean up process.\n\t * @internal\n\t */\n\tprivate _cleanUpProcessOngoing: boolean;\n\n\t/**\n\t * The task scheduler used to clean up activity logs.\n\t * @internal\n\t */\n\tprivate readonly _taskScheduler: ITaskSchedulerComponent;\n\n\t/**\n\t * The keys to use from the context ids to create partitions.\n\t * @internal\n\t */\n\tprivate readonly _partitionContextIds?: string[];\n\n\t/**\n\t * The trust component.\n\t * @internal\n\t */\n\tprivate readonly _trustComponent: ITrustComponent;\n\n\t/**\n\t * The policy enforcement point for ODRL policy enforcement.\n\t * @internal\n\t */\n\tprivate readonly _policyEnforcementPoint: IPolicyEnforcementPointComponent;\n\n\t/**\n\t * The tenant component.\n\t * @internal\n\t */\n\tprivate readonly _tenantComponent?: ITenantComponent;\n\n\t/**\n\t * The component type name for the hosting component.\n\t * @internal\n\t */\n\tprivate readonly _urlTransformerComponent: IUrlTransformerComponent;\n\n\t/**\n\t * Entity storage for Transfer Process entities.\n\t * Used to read transfer state from shared storage (written by Control Plane).\n\t * @internal\n\t */\n\tprivate readonly _transferProcessStorage: IEntityStorageConnector<TransferProcess>;\n\n\t/**\n\t * Factory key used to look up the push-subscription storage. Resolved lazily at call time\n\t * (not at construction) so the storage may register after the data plane is built.\n\t * @internal\n\t */\n\tprivate readonly _pushSubscriptionStorageType: string;\n\n\t/**\n\t * Entity storage for tenant-supplied Dataspace App Dataset entities.\n\t * @internal\n\t */\n\tprivate readonly _dataspaceAppDatasetStorage: IEntityStorageConnector<DataspaceAppDataset>;\n\n\t/**\n\t * Create a new instance of DataspaceDataPlane.\n\t * @param options The options for the data plane.\n\t */\n\tconstructor(options?: IDataspaceDataPlaneServiceConstructorOptions) {\n\t\tthis._loggingComponentType = options?.loggingComponentType ?? \"logging\";\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(this._loggingComponentType);\n\n\t\tthis._entityStorageActivityLogs = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<ActivityLogDetails>\n\t\t>(options?.activityLogEntityStorageType ?? nameofKebabCase<ActivityLogDetails>());\n\n\t\tthis._entityStorageActivityTasks = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<ActivityTask>\n\t\t>(options?.activityTaskEntityStorageType ?? nameofKebabCase<ActivityTask>());\n\n\t\tthis._backgroundTaskComponent = ComponentFactory.get(\n\t\t\toptions?.backgroundTaskComponentType ?? \"background-task\"\n\t\t);\n\n\t\tthis._taskScheduler = ComponentFactory.get<ITaskSchedulerComponent>(\n\t\t\toptions?.taskSchedulerComponentType ?? \"task-scheduler\"\n\t\t);\n\n\t\tthis._trustComponent = ComponentFactory.get<ITrustComponent>(\n\t\t\toptions?.trustComponentType ?? \"trust\"\n\t\t);\n\n\t\tthis._policyEnforcementPoint = ComponentFactory.get<IPolicyEnforcementPointComponent>(\n\t\t\toptions?.pepComponentType ?? \"policy-enforcement-point-service\"\n\t\t);\n\n\t\tthis._tenantComponent = ComponentFactory.getIfExists<ITenantComponent>(\n\t\t\toptions?.tenantComponentType ?? \"tenant\"\n\t\t);\n\n\t\tthis._urlTransformerComponent = ComponentFactory.get<IUrlTransformerComponent>(\n\t\t\toptions?.urlTransformerComponentType ?? \"url-transformer\"\n\t\t);\n\n\t\t// Entity storage for Transfer Process state lookup\n\t\t// Used to read transfer state from shared storage (written by Control Plane)\n\t\tthis._transferProcessStorage = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<TransferProcess>\n\t\t>(options?.transferProcessEntityStorageType ?? nameofKebabCase<TransferProcess>());\n\n\t\t// Push-subscription storage is optional and resolved lazily. The data plane is typically\n\t\t// constructed before its dependent storages register, so caching the connector here would\n\t\t// permanently miss it. We only need the factory key — every push call site re-resolves.\n\t\tthis._pushSubscriptionStorageType =\n\t\t\toptions?.pushSubscriptionEntityStorageType ?? nameofKebabCase<PushSubscription>();\n\n\t\tthis._dataspaceAppDatasetStorage = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<DataspaceAppDataset>\n\t\t>(options?.dataspaceAppDatasetEntityStorageType ?? nameofKebabCase<DataspaceAppDataset>());\n\n\t\tJsonLdDataTypes.registerTypes();\n\t\tDataspaceDataTypes.registerTypes();\n\t\tSchemaOrgDataTypes.registerRedirects();\n\t\tDataspaceProtocolDataTypes.registerRedirects();\n\t\tDataspaceProtocolDataTypes.registerTypes();\n\n\t\tthis._activityLogStatusCallbacks = {};\n\t\tthis._registeredTaskTypes = [];\n\t\tthis._partitionContextIds = options?.partitionContextIds;\n\n\t\tthis._retainTasksFor =\n\t\t\tDataspaceDataPlaneService._DEFAULT_RETAIN_INTERVAL * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\tthis._retainActivityLogsFor =\n\t\t\tDataspaceDataPlaneService._DEFAULT_RETAIN_INTERVAL * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\tthis._retryCount = options?.config?.retryCount;\n\t\tthis._pushRetryCount = options?.config?.pushRetryCount ?? 3;\n\t\tthis._pushRetryBaseDelayMs = options?.config?.pushRetryBaseDelayMs ?? 1000;\n\t\tthis._pushTimeoutMs = options?.config?.pushTimeoutMs ?? 30000;\n\t\tthis._activityLogCleanUpInterval = DataspaceDataPlaneService._DEFAULT_CLEANUP_INTERVAL;\n\t\tthis._pushSubscriptionCleanupIntervalMinutes = Math.max(\n\t\t\t1,\n\t\t\tMath.round((options?.config?.pushSubscriptionCleanupIntervalMs ?? 3_600_000) / 60_000)\n\t\t);\n\t\tthis._cleanUpProcessOngoing = false;\n\n\t\tconst validationErrors: IValidationFailure[] = [];\n\t\tif (!Is.empty(options?.config?.retainActivityLogsFor)) {\n\t\t\tGuards.integer(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tnameof(options.config.retainActivityLogsFor),\n\t\t\t\toptions.config.retainActivityLogsFor\n\t\t\t);\n\n\t\t\tif (options.config.retainActivityLogsFor === -1) {\n\t\t\t\tthis._retainTasksFor = -1;\n\t\t\t\tthis._retainActivityLogsFor = -1;\n\t\t\t} else {\n\t\t\t\tValidation.integer(\n\t\t\t\t\tnameof(options.config.retainActivityLogsFor),\n\t\t\t\t\toptions.config.retainActivityLogsFor,\n\t\t\t\t\tvalidationErrors,\n\t\t\t\t\tundefined,\n\t\t\t\t\t{ minValue: 1 }\n\t\t\t\t);\n\t\t\t\t// Retention of internal tasks launched\n\t\t\t\t// 5 minutes of margin with respect to the Activity Log Entry to ensure proper removal\n\t\t\t\tthis._retainTasksFor =\n\t\t\t\t\t(options.config.retainActivityLogsFor + 5) * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\t\t\tthis._retainActivityLogsFor =\n\t\t\t\t\toptions.config.retainActivityLogsFor * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\t\t}\n\t\t}\n\n\t\tif (!Is.empty(options?.config?.activityLogsCleanUpInterval)) {\n\t\t\tGuards.integer(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tnameof(options.config.activityLogsCleanUpInterval),\n\t\t\t\toptions.config.activityLogsCleanUpInterval\n\t\t\t);\n\t\t\tValidation.integer(\n\t\t\t\tnameof(options.config.activityLogsCleanUpInterval),\n\t\t\t\toptions.config.activityLogsCleanUpInterval,\n\t\t\t\tvalidationErrors,\n\t\t\t\tundefined,\n\t\t\t\t{ minValue: 1 }\n\t\t\t);\n\t\t\tthis._activityLogCleanUpInterval = options.config.activityLogsCleanUpInterval;\n\t\t}\n\n\t\tif (!Is.empty(options?.config?.pushTimeoutMs)) {\n\t\t\tGuards.integer(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tnameof(options.config.pushTimeoutMs),\n\t\t\t\toptions.config.pushTimeoutMs\n\t\t\t);\n\t\t\tValidation.integer(\n\t\t\t\tnameof(options.config.pushTimeoutMs),\n\t\t\t\toptions.config.pushTimeoutMs,\n\t\t\t\tvalidationErrors,\n\t\t\t\tundefined,\n\t\t\t\t{ minValue: 1 }\n\t\t\t);\n\t\t\tthis._pushTimeoutMs = options.config.pushTimeoutMs;\n\t\t}\n\n\t\tValidation.asValidationError(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(options?.config),\n\t\t\tvalidationErrors\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn DataspaceDataPlaneService.CLASS_NAME;\n\t}\n\n\t/**\n\t * The service needs to be started when the application is initialized.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tawait this._backgroundTaskComponent.registerHandler<IPushDeliveryPayload, unknown>(\n\t\t\tDataspaceDataPlaneService.PUSH_DELIVERY_TASK_TYPE,\n\t\t\t\"@twin.org/dataspace-app-runner\",\n\t\t\t\"pushDeliveryRunner\",\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\tinitialiseMethod: \"pushDeliveryRunnerStart\",\n\t\t\t\tshutdownMethod: \"pushDeliveryRunnerEnd\",\n\t\t\t\tidleShutdownTimeout: -1\n\t\t\t}\n\t\t);\n\n\t\tconst engine = EngineCoreFactory.getIfExists(\"engine\");\n\t\tif (Is.empty(engine) || engine.isClone()) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"engineCloneStart\"\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Only we have a task scheduler if there is a retention different than -1\n\t\tif (this._retainActivityLogsFor !== -1) {\n\t\t\tconst taskTime: IScheduledTaskTime[] = [\n\t\t\t\t{\n\t\t\t\t\tnextTriggerTime: Date.now() + 5000,\n\t\t\t\t\t...this.calculateCleaningTaskSchedule(this._activityLogCleanUpInterval)\n\t\t\t\t}\n\t\t\t];\n\n\t\t\tawait this._taskScheduler.addTask(\"dataspace-cleanup\", taskTime, async () => {\n\t\t\t\tawait this._logging?.log({\n\t\t\t\t\tlevel: \"debug\",\n\t\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\tmessage: \"scheduledCleanUpTask\"\n\t\t\t\t});\n\n\t\t\t\tawait this.cleanupActivityLog();\n\t\t\t});\n\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"taskSchedulerStarted\",\n\t\t\t\tdata: {\n\t\t\t\t\ttaskTime\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tconst pushCleanupTaskTime: IScheduledTaskTime[] = [\n\t\t\t{\n\t\t\t\tnextTriggerTime: Date.now() + 10_000,\n\t\t\t\t...this.calculateCleaningTaskSchedule(this._pushSubscriptionCleanupIntervalMinutes)\n\t\t\t}\n\t\t];\n\n\t\tawait this._taskScheduler.addTask(\n\t\t\t\"dataspace-push-subscription-cleanup\",\n\t\t\tpushCleanupTaskTime,\n\t\t\tasync () => {\n\t\t\t\tawait this.cleanupOrphanedPushSubscriptions();\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Notify an Activity.\n\t * @param activity The Activity notified.\n\t * @param trustPayload Optional trust payload to verify the requester's identity.\n\t * @returns The activity's id or entry.\n\t */\n\tpublic async notifyActivity(\n\t\tactivity: IActivityStreamsActivity,\n\t\ttrustPayload?: unknown\n\t): Promise<string | IActivityLogEntry> {\n\t\tGuards.object<IActivityStreamsActivity>(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tactivity\n\t\t);\n\n\t\t// For cross-node push deliveries the caller presents a JWT. Verify it,\n\t\t// confirm the referenced transfer is still in STARTED state, and assert\n\t\t// the verified identity is one of the two parties on that transfer.\n\t\tif (Is.stringValue(trustPayload)) {\n\t\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\t\tthis._trustComponent,\n\t\t\t\ttrustPayload,\n\t\t\t\t\"notifyActivity\"\n\t\t\t);\n\t\t\tconst generatorPid = this.calculateActivityGeneratorIdentity(activity);\n\t\t\t// Primary lookup: by consumerPid (the entity's primary key). If this hits, the\n\t\t\t// generator's PID equals consumerPid — the generator is the consumer side.\n\t\t\tlet transferProcess = await this._transferProcessStorage.get(generatorPid);\n\t\t\tconst generatorIsConsumer = Boolean(transferProcess);\n\n\t\t\tif (!transferProcess) {\n\t\t\t\t// Fallback: generatorPid === providerPid. providerPid is a UUIDv7 so it's\n\t\t\t\t// unique per transfer, but defensively reject any case where the secondary\n\t\t\t\t// index returns more than one match — silent first-match would risk\n\t\t\t\t// authorising the wrong transfer if the invariant ever breaks.\n\t\t\t\tconst result = await this._transferProcessStorage.query({\n\t\t\t\t\tconditions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tproperty: \"providerPid\",\n\t\t\t\t\t\t\tvalue: generatorPid,\n\t\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t});\n\t\t\t\tif (result.entities.length > 1) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\"pushActivityNotAuthorized\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\ttransferProcess = result.entities[0] as TransferProcess | undefined;\n\t\t\t\t// generatorIsConsumer stays false → generator is the provider side.\n\t\t\t}\n\n\t\t\tif (transferProcess?.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"pushActivityNotAuthorized\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Bind the verified identity to the side of the transfer matching the claimed\n\t\t\t// generator. Without this, a party with a valid token for transfer X can post\n\t\t\t// an activity claiming to be the other party on the same transfer.\n\t\t\t// Stored consumer/provider identities are composites\n\t\t\t// (`nodeDid:hash(tenantId)`)\n\t\t\tconst expectedIdentity = generatorIsConsumer\n\t\t\t\t? transferProcess.consumerIdentity\n\t\t\t\t: transferProcess.providerIdentity;\n\t\t\tconst callerComposite = Is.stringValue(trustInfo.tenantId)\n\t\t\t\t? `${trustInfo.identity}:${trustInfo.tenantId}`\n\t\t\t\t: trustInfo.identity;\n\t\t\tif (!Is.stringValue(expectedIdentity) || callerComposite !== expectedIdentity) {\n\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"pushActivityNotAuthorized\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Apply the transfer's agreement to the inbound activity via the PEP, which\n\t\t\t// may deny it or manipulate (filter/redact) the payload. Dispatch what the\n\t\t\t// PEP returns.\n\t\t\tactivity = await this.enforceInboxPolicy(transferProcess, activity, generatorIsConsumer);\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tmessage: \"newActivity\",\n\t\t\tdata: {\n\t\t\t\tactivityType: activity.type,\n\t\t\t\tgenerator: this.calculateActivityGeneratorIdentity(activity)\n\t\t\t}\n\t\t});\n\n\t\t// We only validate that the activity conforms to Activity Streams Schema without entering into details\n\t\t// about the object, target or actor as they might be subject of custom validation rules\n\t\tconst typeId = `${DataspaceContexts.JsonSchemaNamespace}Dataspace${DataspaceTypes.Activity}`;\n\t\tconst activitySchema = await DataTypeHelper.getSchemaForType(typeId);\n\t\tif (Is.undefined(activitySchema)) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"schemaNotFound\", {\n\t\t\t\tschemaId: typeId\n\t\t\t});\n\t\t}\n\t\tconst validationFailures = await JsonSchemaHelper.validate(activitySchema, activity);\n\t\tValidation.asValidationError(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\t// Calculate Activity Log Entry Id\n\t\tconst canonical = JsonHelper.canonicalize(activity);\n\t\tconst canonicalBytes = Converter.utf8ToBytes(canonical);\n\t\tconst activityLogId = Converter.bytesToHex(Blake2b.sum256(canonicalBytes));\n\t\tconst activityLogEntryId = `${ACTIVITY_LOG_URN_PREFIX}${activityLogId}`;\n\n\t\t// Check if entry already exists\n\t\tlet logEntry = await this._entityStorageActivityLogs.get(activityLogEntryId);\n\t\tlet existingSuccessfulApps: string[] = [];\n\t\tlet isRetry = false;\n\t\tconst now = Date.now();\n\n\t\tif (!Is.undefined(logEntry)) {\n\t\t\t// Check if there are failed tasks that can be retried\n\t\t\tconst existingEntry = await this.getActivityLogEntry(activityLogEntryId);\n\n\t\t\t// If all tasks completed successfully, this is a duplicate\n\t\t\tif (existingEntry.status === ActivityProcessingStatus.Completed) {\n\t\t\t\tthrow new ConflictError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"activityAlreadyNotified\",\n\t\t\t\t\tactivityLogEntryId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// If still processing then reject to avoid race conditions\n\t\t\tif (\n\t\t\t\texistingEntry.status === ActivityProcessingStatus.Pending ||\n\t\t\t\texistingEntry.status === ActivityProcessingStatus.Running ||\n\t\t\t\texistingEntry.status === ActivityProcessingStatus.Registering\n\t\t\t) {\n\t\t\t\tthrow new ConflictError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"activityStillProcessing\",\n\t\t\t\t\tactivityLogEntryId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Status is Error - prepare for retry\n\t\t\texistingSuccessfulApps = await this.prepareForRetry(activityLogEntryId, existingEntry);\n\t\t\tisRetry = true;\n\t\t} else {\n\t\t\tlogEntry = {\n\t\t\t\tid: activityLogEntryId,\n\t\t\t\tactivityId: activity.id,\n\t\t\t\tgenerator: this.calculateActivityGeneratorIdentity(activity),\n\t\t\t\tdateCreated: new Date(now).toISOString(),\n\t\t\t\tdateModified: new Date(now).toISOString()\n\t\t\t};\n\t\t\tawait this._entityStorageActivityLogs.set(logEntry);\n\t\t}\n\n\t\tconst activityQuerySet = await this.calculateActivityQuerySet(activity as IDataspaceActivity);\n\n\t\tconst taskEntries: IActivityTaskEntry[] = [];\n\t\tconst handlerApps: {\n\t\t\t[id: string]: {\n\t\t\t\tapp: IDataspaceApp;\n\t\t\t\tprocessingGroupId?: string;\n\t\t\t};\n\t\t} = {};\n\n\t\tfor (const query of activityQuerySet) {\n\t\t\tconst apps = this.getAppForActivityQuery(query);\n\t\t\tfor (const appId in apps) {\n\t\t\t\t// Only process apps that haven't already completed successfully\n\t\t\t\tif (!handlerApps[appId] && !existingSuccessfulApps.includes(appId)) {\n\t\t\t\t\thandlerApps[appId] = apps[appId];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet inlineCount = 0;\n\t\tfor (const handlerAppId in handlerApps) {\n\t\t\tif (\n\t\t\t\tawait this.processTask(\n\t\t\t\t\tactivityLogEntryId,\n\t\t\t\t\tactivity,\n\t\t\t\t\thandlerApps,\n\t\t\t\t\thandlerAppId,\n\t\t\t\t\ttaskEntries,\n\t\t\t\t\tisRetry\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tinlineCount++;\n\t\t\t}\n\t\t}\n\n\t\tconst existingActivityTasks = isRetry\n\t\t\t? await this._entityStorageActivityTasks.get(activityLogEntryId)\n\t\t\t: undefined;\n\t\tconst existingTasksToKeep =\n\t\t\texistingActivityTasks?.associatedTasks.filter(t =>\n\t\t\t\texistingSuccessfulApps.includes(t.dataspaceAppId)\n\t\t\t) ?? [];\n\n\t\tconst activityTask: ActivityTask = {\n\t\t\tactivityLogEntryId,\n\t\t\tassociatedTasks: [...existingTasksToKeep, ...taskEntries]\n\t\t};\n\n\t\tawait this._entityStorageActivityTasks.set(activityTask);\n\n\t\tif (inlineCount === taskEntries.length) {\n\t\t\treturn this.finaliseActivityLogEntry(activityLogEntryId);\n\t\t}\n\n\t\treturn activityTask.activityLogEntryId;\n\t}\n\n\t/**\n\t * Subscribes to the activity log.\n\t * @param callback The callback to be called when Activity Log is called.\n\t * @param subscriptionId The Subscription Id.\n\t * @returns The subscription Id.\n\t */\n\tpublic async subscribeToActivityLog(\n\t\tcallback: (notification: IActivityLogStatusNotification) => Promise<void>,\n\t\tsubscriptionId?: string\n\t): Promise<string> {\n\t\tGuards.function(DataspaceDataPlaneService.CLASS_NAME, nameof(callback), callback);\n\n\t\tconst theSubscriptionId = Is.stringValue(subscriptionId)\n\t\t\t? subscriptionId\n\t\t\t: Converter.bytesToHex(RandomHelper.generate(16));\n\t\tthis._activityLogStatusCallbacks[theSubscriptionId] = callback;\n\n\t\treturn theSubscriptionId;\n\t}\n\n\t/**\n\t * Subscribes to the activity log.\n\t * @param subscriptionId The Subscription Id.\n\t */\n\tpublic async unSubscribeToActivityLog(subscriptionId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(subscriptionId),\n\t\t\tsubscriptionId\n\t\t);\n\t\tdelete this._activityLogStatusCallbacks[subscriptionId];\n\t}\n\n\t/**\n\t * Returns the activity processing details of an activity.\n\t * @param logEntryId The Id of the Activity Log Entry (a URI).\n\t * @returns the Activity Log Entry with the processing details.\n\t * @throws NotFoundError if activity log entry is not known.\n\t */\n\tpublic async getActivityLogEntry(logEntryId: string): Promise<IActivityLogEntry> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(logEntryId), logEntryId);\n\n\t\tconst activityLog = await this._entityStorageActivityLogs.get(logEntryId);\n\t\tif (Is.undefined(activityLog)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"activityLogEntryNotFound\",\n\t\t\t\tlogEntryId\n\t\t\t);\n\t\t}\n\n\t\tconst activityTasks = await this._entityStorageActivityTasks.get(logEntryId);\n\n\t\treturn this.constructLogEntry(activityLog, activityTasks);\n\t}\n\n\t/**\n\t * Get Data Asset entities. Allows to retrieve entities by their type or id.\n\t * @param entitySet The set of entities to be retrieved.\n\t * @param entitySet.jsonLdContext The JSON-LD Context to be used to expand the referred entityType.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The entities requested as a JSON-LD Document.\n\t */\n\tpublic async getDataAssetEntities(\n\t\tentitySet: IEntitySet & {\n\t\t\tjsonLdContext?: IJsonLdContextDefinitionElement[];\n\t\t},\n\t\tconsumerPid: string,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tGuards.object<IEntitySet>(DataspaceDataPlaneService.CLASS_NAME, nameof(entitySet), entitySet);\n\t\tGuards.string(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(entitySet.entityType),\n\t\t\tentitySet.entityType\n\t\t);\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"getDataAssetEntities\"\n\t\t);\n\n\t\tconst dataConsumerIdentity = trustInfo.identity;\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(dataConsumerIdentity),\n\t\t\tdataConsumerIdentity\n\t\t);\n\n\t\t// Use consumerPid to resolve datasetId via Transfer Process\n\t\t// This validates the transfer token, state, and extracts datasetId\n\t\tconst transferContext = await this.validateTransfer(consumerPid, trustPayload);\n\t\tconst resolvedDatasetId = transferContext.datasetId;\n\n\t\tconst serviceDataset = await this.getDatasetFromApps(resolvedDatasetId);\n\n\t\t// Expand entity type if LD context provided\n\t\tlet finalType: string | undefined = entitySet.entityType;\n\t\tif (!Is.undefined(entitySet.jsonLdContext)) {\n\t\t\tconst auxiliaryObj = {\n\t\t\t\t\"@context\": entitySet.jsonLdContext,\n\t\t\t\t\"@type\": entitySet.entityType\n\t\t\t};\n\t\t\tconst expanded = (await JsonLdProcessor.expand(auxiliaryObj))[0];\n\t\t\tfinalType = expanded[\"@type\"]?.[0];\n\t\t}\n\n\t\tif (Is.undefined(finalType)) {\n\t\t\tthrow new GuardError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"notExpandableType\",\n\t\t\t\tnameof(entitySet.entityType),\n\t\t\t\tentitySet.entityType\n\t\t\t);\n\t\t}\n\n\t\tconst datasetId = serviceDataset[\"@id\"];\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\t\tconst app = await this.getAppForDataAssetQuery({ datasetId });\n\n\t\tconst handleDataRequest = app.handleDataRequest?.bind(app);\n\t\tGuards.function(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(handleDataRequest),\n\t\t\thandleDataRequest\n\t\t);\n\n\t\tconst dataRequest: IDataRequest = {\n\t\t\ttype: DataRequestType.DataAssetEntities,\n\t\t\tdataAsset: serviceDataset,\n\t\t\tentitySet: {\n\t\t\t\tentityType: finalType,\n\t\t\t\tentityId: entitySet.entityId\n\t\t\t}\n\t\t};\n\n\t\tconst { data, cursor: cursorResult } = await handleDataRequest(dataRequest, cursor, limit);\n\n\t\tlet finalData: IJsonLdNodeObject[];\n\t\tif (Is.array(data)) {\n\t\t\tfinalData = data;\n\t\t} else {\n\t\t\tfinalData = [data as IJsonLdNodeObject];\n\t\t}\n\n\t\tconst itemList = {\n\t\t\t\"@context\": SchemaOrgContexts.Context,\n\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\titemListElement: finalData\n\t\t};\n\n\t\tlet result: IDataAssetItemListResult = {\n\t\t\titemList,\n\t\t\tcursor: cursorResult\n\t\t};\n\n\t\t// Apply policy filters from Agreement\n\t\tif (transferContext?.agreement) {\n\t\t\tconst filtered = await this.applyPolicyFilters(result, transferContext.agreement);\n\t\t\tif (filtered.itemList) {\n\t\t\t\tresult = filtered;\n\t\t\t} else {\n\t\t\t\tresult.itemList[SchemaOrgTypes.ItemListElement] = [];\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Queries a data asset controlled by this Dataspace App.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param query The filtering query.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The item list and optional cursor for pagination via Link headers.\n\t */\n\tpublic async queryDataAsset(\n\t\tconsumerPid: string,\n\t\tquery: IFilteringQuery,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\t\tGuards.object(DataspaceDataPlaneService.CLASS_NAME, nameof(query), query);\n\t\tGuards.string(DataspaceDataPlaneService.CLASS_NAME, nameof(query.type), query.type);\n\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"queryDataAsset\"\n\t\t);\n\n\t\tconst dataConsumerIdentity = trustInfo.identity;\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(dataConsumerIdentity),\n\t\t\tdataConsumerIdentity\n\t\t);\n\n\t\t// Use consumerPid to resolve datasetId via Transfer Process\n\t\t// This validates the transfer token, state, and extracts datasetId\n\t\tconst transferContext = await this.validateTransfer(consumerPid, trustPayload);\n\t\tconst resolvedDatasetId = transferContext.datasetId;\n\n\t\tconst serviceDataset = await this.getDatasetFromApps(resolvedDatasetId);\n\n\t\tconst datasetId = serviceDataset[\"@id\"];\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\t\tconst app = await this.getAppForDataAssetQuery({ datasetId });\n\n\t\tif (!app.supportedQueryTypes().includes(query.type)) {\n\t\t\tthrow new UnprocessableError(DataspaceDataPlaneService.CLASS_NAME, \"queryTypeNotSupported\", {\n\t\t\t\tqueryType: query.type\n\t\t\t});\n\t\t}\n\n\t\tconst dataRequest: IDataRequest = {\n\t\t\ttype: DataRequestType.QueryDataAsset,\n\t\t\tdataAsset: serviceDataset,\n\t\t\tquery\n\t\t};\n\n\t\tconst handleDataRequest = app.handleDataRequest?.bind(app);\n\t\tGuards.function(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(handleDataRequest),\n\t\t\thandleDataRequest\n\t\t);\n\n\t\tconst { data, cursor: cursorResult } = await handleDataRequest(dataRequest, cursor, limit);\n\n\t\tlet finalData: IJsonLdNodeObject[];\n\t\tif (Is.array(data)) {\n\t\t\tfinalData = data;\n\t\t} else {\n\t\t\tfinalData = [data as IJsonLdNodeObject];\n\t\t}\n\n\t\tconst itemList = {\n\t\t\t\"@context\": SchemaOrgContexts.Context,\n\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\titemListElement: finalData\n\t\t};\n\n\t\tlet result: IDataAssetItemListResult = {\n\t\t\titemList,\n\t\t\tcursor: cursorResult\n\t\t};\n\n\t\t// Apply policy filters from Agreement if using consumerPid flow\n\t\tif (transferContext?.agreement) {\n\t\t\tconst filtered = await this.applyPolicyFilters(result, transferContext.agreement);\n\t\t\tif (filtered.itemList) {\n\t\t\t\tresult = filtered;\n\t\t\t} else {\n\t\t\t\tresult.itemList[SchemaOrgTypes.ItemListElement] = [];\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Validate transfer authorization for data requests.\n\t * Reads directly from shared TransferProcess entity storage.\n\t * @param consumerPid The consumer process ID from the transfer request.\n\t * @param trustPayload The trust payload for verification (validates signature and expiry).\n\t * @returns The transfer context containing datasetId, agreement, and other transfer details.\n\t * @throws GeneralError if transfer process storage is not configured.\n\t * @throws NotFoundError if transfer process is not found.\n\t * @throws UnauthorizedError if trust verification fails.\n\t * @throws GeneralError if transfer is not in STARTED state.\n\t */\n\tpublic async validateTransfer(\n\t\tconsumerPid: string,\n\t\ttrustPayload: unknown\n\t): Promise<ITransferContext> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\t// Verify trust payload (validates JWT signature, expiry, and returns verification info)\n\t\t// The trust verifier handles all token validation including expiry\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"validateTransfer\");\n\n\t\t// Direct lookup from shared entity storage by consumerPid (which is the primary key)\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\n\t\tif (!transferProcess) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\t// Validate state: must be STARTED\n\t\tif (transferProcess.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferNotInStartedState\", {\n\t\t\t\tcurrentState: transferProcess.state\n\t\t\t});\n\t\t}\n\n\t\t// Validate datasetId is present\n\t\tif (!Is.stringValue(transferProcess.datasetId)) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferMissingDatasetId\");\n\t\t}\n\n\t\treturn this.buildTransferContext(transferProcess);\n\t}\n\n\t/**\n\t * Set up a push subscription after a transfer enters STARTED from REQUESTED.\n\t * Reads the TransferProcess, builds an IFollowActivity, calls the app's\n\t * subscribeToData, and persists a PushSubscription entity.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async setupPushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\t\tif (!transferProcess) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\tif (transferProcess.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferNotInStartedState\", {\n\t\t\t\tcurrentState: transferProcess.state\n\t\t\t});\n\t\t}\n\n\t\tif (!Is.stringValue(transferProcess.dataAddress?.endpoint)) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferMissingDataAddress\", {\n\t\t\t\tconsumerPid\n\t\t\t});\n\t\t}\n\n\t\t// On multi-tenant publishers, the consumer must have baked its tenant token into the\n\t\t// callback URL so the consumer's TenantProcessor can route inbound push deliveries.\n\t\t// Reject at setup time rather than silently 401 every push.\n\t\t// Parse as a real URL so we match on the actual query parameter, not a substring\n\t\t// in a path segment / value position.\n\t\tif (this._partitionContextIds?.includes(ContextIdKeys.Tenant)) {\n\t\t\tconst tenantId = await this._urlTransformerComponent.getEncryptedFromUrl(\n\t\t\t\ttransferProcess.dataAddress.endpoint,\n\t\t\t\t\"tenant\"\n\t\t\t);\n\t\t\tif (!Is.stringValue(tenantId)) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"pushSubscriptionMissingTenantToken\",\n\t\t\t\t\t{ consumerPid, endpoint: transferProcess.dataAddress.endpoint }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst followActivityId = `${FOLLOW_ACTIVITY_URN_PREFIX}${RandomHelper.generateUuidV7(\"compact\")}`;\n\t\tconst followActivity: IFollowActivity = {\n\t\t\t\"@context\": ActivityStreamsContexts.Context,\n\t\t\tid: followActivityId,\n\t\t\ttype: ActivityStreamsTypes.Follow,\n\t\t\tgenerator: transferProcess.consumerPid,\n\t\t\tactor: transferProcess.consumerIdentity ?? \"\",\n\t\t\tobject: { id: `${TRANSFER_URN_PREFIX}${transferProcess.consumerPid}` }\n\t\t};\n\n\t\tlet appForCompensation: IDataspaceApp | undefined;\n\t\tif (Is.stringValue(transferProcess.datasetId)) {\n\t\t\tconst appDataset = await this._dataspaceAppDatasetStorage.get(transferProcess.datasetId);\n\t\t\tif (appDataset) {\n\t\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appDataset.appId);\n\t\t\t\tawait app.subscribeToData?.(followActivity);\n\t\t\t\tappForCompensation = app;\n\t\t\t}\n\t\t}\n\n\t\tconst setupContextIds = await ContextIdStore.getContextIds();\n\t\tconst setupTenantId = setupContextIds?.[ContextIdKeys.Tenant];\n\t\tconst subscription: PushSubscription = {\n\t\t\tconsumerPid: transferProcess.consumerPid,\n\t\t\tproviderPid: transferProcess.providerPid,\n\t\t\tfollowActivityId,\n\t\t\tdatasetId: transferProcess.datasetId,\n\t\t\ttenantId: Is.stringValue(setupTenantId) ? setupTenantId : undefined,\n\t\t\tconsumerEndpoint: transferProcess.dataAddress.endpoint,\n\t\t\tconsumerAuthToken: transferProcess.dataAddress.endpointProperties?.find(\n\t\t\t\tp => p.name === \"authorization\"\n\t\t\t)?.value,\n\t\t\tpaused: false,\n\t\t\tdateCreated: new Date().toISOString(),\n\t\t\tdateModified: new Date().toISOString()\n\t\t};\n\n\t\ttry {\n\t\t\tawait this.requirePushSubscriptionStorage().set(subscription);\n\t\t} catch (storageError) {\n\t\t\t// Compensating Undo: the app's subscribeToData succeeded but the row didn't\n\t\t\t// persist. Without compensation, a retry generates a new followActivityId and\n\t\t\t// registers a second Follow on the app — with no persisted id to drive an Undo.\n\t\t\tif (appForCompensation) {\n\t\t\t\tconst compensatingUndo: IUndoActivity = {\n\t\t\t\t\t\"@context\": ActivityStreamsContexts.Context,\n\t\t\t\t\tid: `${UNDO_ACTIVITY_URN_PREFIX}${RandomHelper.generateUuidV7(\"compact\")}`,\n\t\t\t\t\ttype: ActivityStreamsTypes.Undo,\n\t\t\t\t\tgenerator: transferProcess.consumerPid,\n\t\t\t\t\tactor: transferProcess.consumerIdentity ?? \"\",\n\t\t\t\t\tobject: followActivityId\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tawait appForCompensation.unsubscribeToData?.(compensatingUndo);\n\t\t\t\t} catch (compensationError) {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"pushSubscriptionCompensationFailed\",\n\t\t\t\t\t\tdata: { consumerPid, providerPid: transferProcess.providerPid },\n\t\t\t\t\t\terror: BaseError.fromError(compensationError)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow storageError;\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionCreated\",\n\t\t\tdata: { consumerPid, providerPid: transferProcess.providerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Pause deliveries for a push subscription. The subscription entity stays\n\t * alive with status=Paused. No app unsubscribe call.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async suspendPushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushSubscriptionNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\tif (subscription.paused) {\n\t\t\treturn;\n\t\t}\n\n\t\tsubscription.paused = true;\n\t\tsubscription.dateModified = new Date().toISOString();\n\t\tawait this.requirePushSubscriptionStorage().set(subscription);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionSuspended\",\n\t\t\tdata: { consumerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Resume deliveries after a SUSPENDED → STARTED transition. Flips status\n\t * back to Active. No app subscribeToData call.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async resumePushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushSubscriptionNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\tif (!subscription.paused) {\n\t\t\treturn;\n\t\t}\n\n\t\tsubscription.paused = false;\n\t\tsubscription.dateModified = new Date().toISOString();\n\t\tawait this.requirePushSubscriptionStorage().set(subscription);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionResumed\",\n\t\t\tdata: { consumerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Tear down a push subscription. Builds an IUndoActivity, calls the app's\n\t * unsubscribeToData, and deletes the PushSubscription entity.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async teardownPushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"pushSubscriptionNotFoundOnTeardown\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\n\t\tconst undoActivity: IUndoActivity = {\n\t\t\t\"@context\": ActivityStreamsContexts.Context,\n\t\t\tid: `${UNDO_ACTIVITY_URN_PREFIX}${RandomHelper.generateUuidV7(\"compact\")}`,\n\t\t\ttype: ActivityStreamsTypes.Undo,\n\t\t\tgenerator: subscription.consumerPid,\n\t\t\tactor: transferProcess?.consumerIdentity ?? \"\",\n\t\t\tobject: subscription.followActivityId\n\t\t};\n\n\t\tif (Is.stringValue(subscription.datasetId)) {\n\t\t\tconst appDataset = await this._dataspaceAppDatasetStorage.get(subscription.datasetId);\n\t\t\tif (appDataset) {\n\t\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appDataset.appId);\n\t\t\t\tawait app.unsubscribeToData?.(undoActivity);\n\t\t\t}\n\t\t}\n\n\t\tawait this.requirePushSubscriptionStorage().remove(consumerPid);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionTornDown\",\n\t\t\tdata: { consumerPid, providerPid: subscription.providerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Schedule a push delivery when the app has new outbound data.\n\t * @param activity The outbound activity carrying the data payload.\n\t */\n\tpublic async processOutboxActivity(activity: IActivityStreamsActivity): Promise<void> {\n\t\tGuards.object<IActivityStreamsActivity>(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tactivity\n\t\t);\n\n\t\t// Extract consumerPid from activity.to\n\t\tlet consumerPid: string | undefined;\n\t\tif (Is.stringValue(activity.to)) {\n\t\t\tconsumerPid = activity.to;\n\t\t} else if (Is.array(activity.to)) {\n\t\t\tif (activity.to.length > 1) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"processOutboxActivityMultipleTo\",\n\t\t\t\t\t{ count: activity.to.length }\n\t\t\t\t);\n\t\t\t}\n\t\t\tconsumerPid = activity.to[0] as string | undefined;\n\t\t}\n\n\t\tif (!Is.stringValue(consumerPid)) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushSubscriptionNotFoundForActivity\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Load PushSubscription\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushSubscriptionNotFoundForActivity\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Skip delivery if subscription is paused\n\t\tif (subscription.paused) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushDeliverySkippedPaused\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Load TransferProcess and validate it is STARTED\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\t\tif (transferProcess?.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushSubscriptionNotFoundForActivity\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Build agreement from stored transfer context\n\t\tconst { agreement } = this.buildTransferContext(transferProcess);\n\n\t\t// Extract data object from activity; a string value is an IRI reference — wrap it so the IRI is preserved.\n\t\tlet data: IJsonLdNodeObject;\n\t\tif (Is.object(activity.object)) {\n\t\t\tdata = activity.object;\n\t\t} else if (Is.stringValue(activity.object)) {\n\t\t\tdata = { \"@id\": activity.object };\n\t\t} else {\n\t\t\tdata = {};\n\t\t}\n\t\tconst entityType = Is.object(activity.object) ? (getJsonLdType(activity.object) ?? \"\") : \"\";\n\n\t\t// Capture the subscription's tenantId so the background-task runner can re-enter the\n\t\t// owning tenant's context before any tenant-scoped operation (PEP, trust signing).\n\t\t// Falls back to the current request context if the subscription pre-dates tenantId capture.\n\t\tlet payloadTenantId: string | undefined = subscription.tenantId;\n\t\tif (!Is.stringValue(payloadTenantId)) {\n\t\t\tconst ctxIds = await ContextIdStore.getContextIds();\n\t\t\tconst ctxTenant = ctxIds?.[ContextIdKeys.Tenant];\n\t\t\tpayloadTenantId = Is.stringValue(ctxTenant) ? ctxTenant : undefined;\n\t\t}\n\n\t\tconst payload: IPushDeliveryPayload = {\n\t\t\tconsumerPid,\n\t\t\tproviderPid: transferProcess.providerPid,\n\t\t\tgeneratorPid: transferProcess.providerPid,\n\t\t\tconsumerEndpoint: subscription.consumerEndpoint,\n\t\t\tconsumerAuthToken: subscription.consumerAuthToken,\n\t\t\tagreement,\n\t\t\tdata,\n\t\t\tentityType,\n\t\t\ttenantId: payloadTenantId,\n\t\t\tpushTimeoutMs: this._pushTimeoutMs,\n\t\t\tpushRetryCount: this._pushRetryCount,\n\t\t\tpushRetryBaseDelayMs: this._pushRetryBaseDelayMs\n\t\t};\n\n\t\tconst taskId = await this._backgroundTaskComponent.create<IPushDeliveryPayload>(\n\t\t\tDataspaceDataPlaneService.PUSH_DELIVERY_TASK_TYPE,\n\t\t\tpayload,\n\t\t\t{ retainFor: this._retainTasksFor, retryCount: this._retryCount }\n\t\t);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tmessage: \"pushDeliveryTaskScheduled\",\n\t\t\tdata: { taskId, consumerPid }\n\t\t});\n\t}\n\n\t// ============================================================================\n\t// PRIVATE HELPER METHODS\n\t// ============================================================================\n\n\t/**\n\t * Calculates the activity generator from the generator or actor fields.\n\t * @param activity The activity.\n\t * @returns The generator's identity.\n\t * @throws General Error if no identity is found.\n\t * @internal\n\t */\n\tprivate calculateActivityGeneratorIdentity(activity: IActivityStreamsActivity): string {\n\t\tif (Is.stringValue(activity.generator)) {\n\t\t\treturn activity.generator;\n\t\t}\n\n\t\tif (Is.object<IJsonLdNodeObject>(activity.generator) && Is.stringValue(activity.generator.id)) {\n\t\t\treturn activity.generator.id;\n\t\t}\n\n\t\tif (Is.stringValue(activity.actor)) {\n\t\t\treturn activity.actor;\n\t\t}\n\n\t\tif (Is.object<IJsonLdNodeObject>(activity.actor) && Is.stringValue(activity.actor.id)) {\n\t\t\treturn activity.actor.id;\n\t\t}\n\n\t\tthrow new GuardError(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\"invalidActivityGeneratorIdentity\",\n\t\t\tnameof(activity.generator),\n\t\t\t{\n\t\t\t\tgenerator: activity.generator,\n\t\t\t\tactor: activity.actor\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Process activity task finalization.\n\t * @param taskId The Id of the Activity Log Entry.\n\t * @param status The final status of the task.\n\t * @param payload The execution payload of the task, required to correlate to the Activity Log Entry and update the processing status.\n\t * @internal\n\t */\n\tprivate async finaliseBackgroundTask(\n\t\ttaskId: string,\n\t\tstatus: TaskStatus,\n\t\tpayload?: IExecutionPayload\n\t): Promise<void> {\n\t\tif (Is.empty(payload)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (status === TaskStatus.Success || status === TaskStatus.Failed) {\n\t\t\tawait this.notifyTaskStatusChanged(\n\t\t\t\tpayload.activityLogEntryId,\n\t\t\t\tpayload.activity.id,\n\t\t\t\tpayload.dataspaceAppId,\n\t\t\t\ttaskId,\n\t\t\t\tstatus\n\t\t\t);\n\n\t\t\tawait this.finaliseActivityLogEntry(payload.activityLogEntryId);\n\t\t}\n\t}\n\n\t/**\n\t * Notify registered callbacks about a task status change.\n\t * @param activityLogEntryId The Id of the Activity Log Entry.\n\t * @param activityId The Id of the Activity.\n\t * @param dataspaceAppId The Id of the Dataspace App associated with the task.\n\t * @param taskId The Id of the task.\n\t * @param taskStatus The new status of the task.\n\t * @internal\n\t */\n\tprivate async notifyTaskStatusChanged(\n\t\tactivityLogEntryId: string,\n\t\tactivityId: string | undefined,\n\t\tdataspaceAppId: string,\n\t\ttaskId: string,\n\t\ttaskStatus: TaskStatus\n\t): Promise<void> {\n\t\tfor (const callback of Object.values(this._activityLogStatusCallbacks)) {\n\t\t\tawait callback({\n\t\t\t\tactivityLogEntryId,\n\t\t\t\tactivityId,\n\t\t\t\ttaskProcessingStatus: {\n\t\t\t\t\tdataspaceAppId,\n\t\t\t\t\ttaskId,\n\t\t\t\t\ttaskStatus\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Finalizes the Activity Log Entry by checking if all associated tasks have completed and, if so, updating the entry to be retained for the configured retention period.\n\t * @param activityLogEntryId The Id of the Activity Log Entry to finalize.\n\t * @returns The Activity Log Entry with updated retention details if applicable.\n\t * @internal\n\t */\n\tprivate async finaliseActivityLogEntry(activityLogEntryId: string): Promise<IActivityLogEntry> {\n\t\tconst entry = await this.getActivityLogEntry(activityLogEntryId);\n\t\tif (\n\t\t\tthis._retainActivityLogsFor !== -1 &&\n\t\t\t(entry.status === ActivityProcessingStatus.Completed ||\n\t\t\t\tentry.status === ActivityProcessingStatus.Error)\n\t\t) {\n\t\t\tconst retainUntil = Date.now() + this._retainActivityLogsFor;\n\t\t\tconst updatedEntry: ActivityLogDetails = {\n\t\t\t\tid: entry.id,\n\t\t\t\tactivityId: entry.activityId,\n\t\t\t\tgenerator: entry.generator,\n\t\t\t\tdateCreated: entry.dateCreated,\n\t\t\t\tdateModified: entry.dateModified,\n\t\t\t\tretainUntil\n\t\t\t};\n\t\t\tawait this._entityStorageActivityLogs.set(updatedEntry);\n\t\t}\n\n\t\treturn entry;\n\t}\n\n\t/**\n\t * Cleans up the activity log by deleting those entries that no longer shall be retained.\n\t * @internal\n\t */\n\tprivate async cleanupActivityLog(): Promise<void> {\n\t\tif (this._cleanUpProcessOngoing) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tmessage: \"cleanUpOngoing\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tthis._cleanUpProcessOngoing = true;\n\n\t\tlet numRecordsDeleted = 0;\n\n\t\tif (this._partitionContextIds?.includes(ContextIdKeys.Tenant)) {\n\t\t\t// The cleanup must be done by tenant as the data is partitioned\n\t\t\tawait this._tenantComponent?.runPerTenant(async () => {\n\t\t\t\tnumRecordsDeleted += await this.cleanupActivityLogPartition();\n\t\t\t});\n\t\t} else {\n\t\t\tnumRecordsDeleted += await this.cleanupActivityLogPartition();\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tmessage: \"activityLogCleanedUp\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tdata: {\n\t\t\t\tnumRecordsDeleted\n\t\t\t}\n\t\t});\n\n\t\tthis._cleanUpProcessOngoing = false;\n\t}\n\n\t/**\n\t * Cleans up the activity log partition for the current context ids.\n\t * @returns The number of records deleted in this partition.\n\t * @internal\n\t */\n\tprivate async cleanupActivityLogPartition(): Promise<number> {\n\t\tlet numRecordsDeleted = 0;\n\n\t\ttry {\n\t\t\tlet cursor: string | undefined;\n\t\t\tconst now = Date.now();\n\n\t\t\tdo {\n\t\t\t\tconst result = await this._entityStorageActivityLogs.query({\n\t\t\t\t\tconditions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tproperty: \"retainUntil\",\n\t\t\t\t\t\t\tvalue: 0,\n\t\t\t\t\t\t\tcomparison: ComparisonOperator.GreaterThan\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tproperty: \"retainUntil\",\n\t\t\t\t\t\t\tvalue: now,\n\t\t\t\t\t\t\tcomparison: ComparisonOperator.LessThan\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tlogicalOperator: LogicalOperator.And\n\t\t\t\t});\n\t\t\t\tcursor = result.cursor;\n\n\t\t\t\tfor (const entity of result.entities) {\n\t\t\t\t\tconst logEntryDetails = await this.getActivityLogEntry(entity.id as string);\n\t\t\t\t\tif (\n\t\t\t\t\t\tlogEntryDetails.status === ActivityProcessingStatus.Completed ||\n\t\t\t\t\t\tlogEntryDetails.status === ActivityProcessingStatus.Error\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this._entityStorageActivityLogs.remove(entity.id as string);\n\t\t\t\t\t\tawait this._entityStorageActivityTasks.remove(entity.id as string);\n\t\t\t\t\t\tnumRecordsDeleted++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} while (Is.stringValue(cursor));\n\t\t} catch (error) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"cleanupFailed\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\terror: BaseError.fromError(error)\n\t\t\t});\n\t\t}\n\t\treturn numRecordsDeleted;\n\t}\n\n\t/**\n\t * Calculates the (Activity, Object, Target) query set.\n\t * @param activity The object representing the Activity.\n\t * @returns the (Activity, Object, Target) query set.\n\t * @internal\n\t */\n\tprivate async calculateActivityQuerySet(activity: IDataspaceActivity): Promise<IActivityQuery[]> {\n\t\tconst activityTypes = await JsonLdHelper.getType(activity);\n\t\tlet objectTypes: string[] = [];\n\n\t\tconst objects = ArrayHelper.fromObjectOrArray<IJsonLdNodeObject>(activity.object);\n\t\tfor (const object of objects) {\n\t\t\tobjectTypes = objectTypes.concat(await JsonLdHelper.getType(object));\n\t\t}\n\n\t\tlet targetTypes: string[] = [\"\"];\n\t\tif (Is.object<IJsonLdNodeObject>(activity.target)) {\n\t\t\ttargetTypes = await JsonLdHelper.getType(activity.target);\n\t\t}\n\n\t\tconst result: IActivityQuery[] = [];\n\n\t\tfor (const activityType of activityTypes) {\n\t\t\tfor (const objectType of objectTypes) {\n\t\t\t\tfor (const targetType of targetTypes) {\n\t\t\t\t\tconst query: IActivityQuery = {\n\t\t\t\t\t\tactivityType,\n\t\t\t\t\t\tobjectType,\n\t\t\t\t\t\ttargetType: !Is.stringValue(targetType) ? undefined : targetType\n\t\t\t\t\t};\n\n\t\t\t\t\tresult.push(query);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Resolve the push-subscription storage or throw if it isn't registered. Pull-only\n\t * deployments may run the data plane without it.\n\t * @returns The push-subscription storage connector.\n\t * @throws GeneralError if the storage isn't registered.\n\t * @internal\n\t */\n\tprivate requirePushSubscriptionStorage(): IEntityStorageConnector<PushSubscription> {\n\t\tconst storage = EntityStorageConnectorFactory.getIfExists<\n\t\t\tIEntityStorageConnector<PushSubscription>\n\t\t>(this._pushSubscriptionStorageType);\n\t\tif (!storage) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushSubscriptionStorageNotRegistered\"\n\t\t\t);\n\t\t}\n\t\treturn storage;\n\t}\n\n\t/**\n\t * Deletes PushSubscription entities whose TransferProcess is absent, COMPLETED, or TERMINATED.\n\t * On multi-tenant nodes (`partitionContextIds` includes `Tenant`), iterates each registered tenant\n\t * and runs the cleanup inside that tenant's context so partitioned storage queries scope correctly.\n\t * @internal\n\t */\n\tprivate async cleanupOrphanedPushSubscriptions(): Promise<void> {\n\t\t// Pull-only deployments may run the data plane without push-subscription storage —\n\t\t// the scheduled cleanup task fires regardless, so silent no-op is the right behaviour.\n\t\tconst storage = EntityStorageConnectorFactory.getIfExists<\n\t\t\tIEntityStorageConnector<PushSubscription>\n\t\t>(this._pushSubscriptionStorageType);\n\t\tif (!storage) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet numDeleted = 0;\n\n\t\tif (this._partitionContextIds?.includes(ContextIdKeys.Tenant)) {\n\t\t\t// The cleanup must be done by tenant as the data is partitioned\n\t\t\tawait this._tenantComponent?.runPerTenant(async () => {\n\t\t\t\tnumDeleted += await this.cleanupOrphanedPushSubscriptionsPartition();\n\t\t\t});\n\t\t} else {\n\t\t\tnumDeleted += await this.cleanupOrphanedPushSubscriptionsPartition();\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tmessage: \"pushSubscriptionsCleanedUp\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tdata: { numDeleted }\n\t\t});\n\t}\n\n\t/**\n\t * Per-partition cleanup body for orphaned PushSubscriptions. Must run inside the\n\t * target tenant's context on multi-tenant nodes (caller wraps `ContextIdStore.run`).\n\t * @returns The number of subscriptions deleted in this partition.\n\t * @internal\n\t */\n\tprivate async cleanupOrphanedPushSubscriptionsPartition(): Promise<number> {\n\t\tlet numDeleted = 0;\n\n\t\ttry {\n\t\t\t// First pass: read all pages without modifying storage to avoid cursor drift\n\t\t\tconst toDelete: string[] = [];\n\t\t\tlet cursor: string | undefined;\n\t\t\tdo {\n\t\t\t\tconst result = await this.requirePushSubscriptionStorage().query(\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tcursor\n\t\t\t\t);\n\t\t\t\tcursor = result.cursor;\n\n\t\t\t\tconst pids = (result.entities as PushSubscription[]).map(s => s.consumerPid);\n\n\t\t\t\t// Skip the transfer-process query when the page is empty.\n\t\t\t\tif (pids.length > 0) {\n\t\t\t\t\tconst tpResult = await this._transferProcessStorage.query({\n\t\t\t\t\t\tproperty: \"consumerPid\",\n\t\t\t\t\t\tvalue: pids,\n\t\t\t\t\t\tcomparison: ComparisonOperator.In\n\t\t\t\t\t});\n\t\t\t\t\tconst tpMap = new Map(tpResult.entities.map(tp => [tp.consumerPid, tp.state]));\n\n\t\t\t\t\tfor (const sub of result.entities as PushSubscription[]) {\n\t\t\t\t\t\tconst state = tpMap.get(sub.consumerPid);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!state ||\n\t\t\t\t\t\t\tstate === DataspaceProtocolTransferProcessStateType.COMPLETED ||\n\t\t\t\t\t\t\tstate === DataspaceProtocolTransferProcessStateType.TERMINATED\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ttoDelete.push(sub.consumerPid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} while (Is.stringValue(cursor));\n\n\t\t\t// Second pass: delete after all reads are complete\n\t\t\tfor (const pid of toDelete) {\n\t\t\t\tawait this.teardownPushSubscription(pid);\n\t\t\t\tnumDeleted++;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"cleanupFailed\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\terror: BaseError.fromError(error)\n\t\t\t});\n\t\t}\n\n\t\treturn numDeleted;\n\t}\n\n\t/**\n\t * Calculates the cleaning task schedule.\n\t * @param minutes The period in minutes.\n\t * @returns The cleaning task schedule.\n\t * @internal\n\t */\n\tprivate calculateCleaningTaskSchedule(minutes: number): IScheduledTaskTime {\n\t\tlet minutesRemain = minutes;\n\n\t\tconst days = Math.floor(minutesRemain / DataspaceDataPlaneService._MINUTES_PER_DAY);\n\t\tminutesRemain %= DataspaceDataPlaneService._MINUTES_PER_DAY;\n\n\t\tconst hours = Math.floor(minutesRemain / 60);\n\t\tminutesRemain %= 60;\n\n\t\treturn { intervalDays: days, intervalHours: hours, intervalMinutes: minutesRemain };\n\t}\n\n\t/**\n\t * Returns an App for a (Activity, Object, Target).\n\t * @param activityQuery The (Activity, Object, Target) query specified using a FQN.\n\t * @returns The Dataspace Data Plane Apps or empty list if nothing is registered.\n\t * @internal\n\t */\n\tprivate getAppForActivityQuery(activityQuery: IActivityQuery): {\n\t\t[id: string]: {\n\t\t\tapp: IDataspaceApp;\n\t\t\tprocessingGroupId?: string;\n\t\t};\n\t} {\n\t\tconst matchingElements: {\n\t\t\t[id: string]: {\n\t\t\t\tapp: IDataspaceApp;\n\t\t\t\tprocessingGroupId?: string;\n\t\t\t};\n\t\t} = {};\n\t\tconst appNames = DataspaceAppFactory.names();\n\n\t\tfor (const appId of appNames) {\n\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appId);\n\t\t\tconst appQueries = app.activitiesHandled();\n\n\t\t\tfor (const appQuery of appQueries) {\n\t\t\t\tif (\n\t\t\t\t\tappQuery.objectType === activityQuery.objectType &&\n\t\t\t\t\t(Is.undefined(appQuery.activityType) ||\n\t\t\t\t\t\tappQuery.activityType === activityQuery.activityType) &&\n\t\t\t\t\t(Is.undefined(appQuery.targetType) || appQuery.targetType === activityQuery.targetType)\n\t\t\t\t) {\n\t\t\t\t\tmatchingElements[appId] = {\n\t\t\t\t\t\tapp,\n\t\t\t\t\t\tprocessingGroupId: appQuery.processingGroupId\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn matchingElements;\n\t}\n\n\t/**\n\t * Get a dataset by its ID. Resolves via the tenant-supplied dataspace app\n\t * datasets stored by the Control Plane.\n\t * @param datasetId The dataset identifier (@id)\n\t * @returns The dataset\n\t * @throws NotFoundError if no app handles this dataset\n\t * @internal\n\t */\n\tprivate async getDatasetFromApps(datasetId: string): Promise<IDataspaceProtocolDataset> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\n\t\tconst fromAppDataset = await this._dataspaceAppDatasetStorage.get(datasetId);\n\t\tif (!Is.empty(fromAppDataset)) {\n\t\t\treturn {\n\t\t\t\t...(fromAppDataset.dataset as unknown as IDataspaceProtocolDataset),\n\t\t\t\t\"@id\": datasetId\n\t\t\t};\n\t\t}\n\n\t\tthrow new NotFoundError(DataspaceDataPlaneService.CLASS_NAME, \"noAppRegistered\", datasetId, {\n\t\t\tdatasetId\n\t\t});\n\t}\n\n\t/**\n\t * Returns an App for a Data Asset query (datasetId, ...).\n\t * @param dataAssetQuery The data asset query.\n\t * @returns The Dataspace Data Plane App ID.\n\t * @internal\n\t */\n\tprivate async getAppForDataAssetQuery(dataAssetQuery: IDataAssetQuery): Promise<IDataspaceApp> {\n\t\tconst matchingElements: IDataspaceApp[] = [];\n\t\tconst matchingIds: string[] = [];\n\n\t\t// Storage primary key is the dataset's @id, so a single get() resolves it.\n\t\tconst fromAppDataset = await this._dataspaceAppDatasetStorage.get(dataAssetQuery.datasetId);\n\t\tif (!Is.empty(fromAppDataset)) {\n\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(fromAppDataset.appId);\n\t\t\tmatchingElements.push(app);\n\t\t\tmatchingIds.push(fromAppDataset.appId);\n\t\t}\n\n\t\tif (matchingElements.length > 1) {\n\t\t\tconst error = new ConflictError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"tooManyAppsRegistered\",\n\t\t\t\tdataAssetQuery.datasetId,\n\t\t\t\tmatchingIds,\n\t\t\t\t{\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t);\n\t\t\tawait this._logging?.log({\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"tooManyAppsRegistered\",\n\t\t\t\terror,\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!Is.arrayValue(matchingElements)) {\n\t\t\tconst error = new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"noAppRegistered\",\n\t\t\t\tdataAssetQuery.datasetId,\n\t\t\t\t{\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t);\n\t\t\tawait this._logging?.log({\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"noAppRegistered\",\n\t\t\t\terror,\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn matchingElements[0];\n\t}\n\n\t/**\n\t * Prepare an activity for retry by updating metadata and returning apps to skip.\n\t * @param activityLogEntryId The activity log entry ID.\n\t * @param existingEntry The existing activity log entry with error status.\n\t * @returns Array of app IDs that already succeeded and should be skipped.\n\t * @internal\n\t */\n\tprivate async prepareForRetry(\n\t\tactivityLogEntryId: string,\n\t\texistingEntry: IActivityLogEntry\n\t): Promise<string[]> {\n\t\tconst appsToRetry =\n\t\t\texistingEntry.tasks\n\t\t\t\t?.filter(t => t.status === ActivityTaskStatus.Failed)\n\t\t\t\t.map(t => t.dataspaceAppId) ?? [];\n\n\t\tif (!Is.arrayValue(appsToRetry)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"noFailedTasksToRetry\",\n\t\t\t\tactivityLogEntryId\n\t\t\t);\n\t\t}\n\n\t\tconst successfulApps =\n\t\t\texistingEntry.tasks\n\t\t\t\t?.filter(t => t.status === ActivityTaskStatus.Success)\n\t\t\t\t.map(t => t.dataspaceAppId) ?? [];\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tmessage: \"replacingFailedTasks\",\n\t\t\tdata: {\n\t\t\t\tactivityLogEntryId,\n\t\t\t\tappsToRetry,\n\t\t\t\tsuccessfulApps\n\t\t\t}\n\t\t});\n\n\t\tconst logEntry = await this._entityStorageActivityLogs.get(activityLogEntryId);\n\t\tif (logEntry) {\n\t\t\tlogEntry.dateModified = new Date().toISOString();\n\t\t\t// Extend retention to allow retry to complete\n\t\t\tif (this._retainActivityLogsFor !== -1) {\n\t\t\t\tlogEntry.retainUntil = Date.now() + this._retainActivityLogsFor;\n\t\t\t}\n\t\t\tawait this._entityStorageActivityLogs.set(logEntry);\n\t\t}\n\n\t\treturn successfulApps;\n\t}\n\n\t/**\n\t * Build transfer context from a TransferProcessEntity.\n\t * @param transferProcess The transfer process entity.\n\t * @returns The transfer context for use by data access methods.\n\t * @internal\n\t */\n\tprivate buildTransferContext(transferProcess: TransferProcess): ITransferContext {\n\t\t// Build the IDataspaceProtocolAgreement from stored data\n\t\t// The entity stores agreementId and policies separately\n\t\t//\n\t\t// NOTE: Currently policies are cached in the TransferProcessEntity at transfer start time.\n\t\t// Eventually, this should fetch fresh policies from Rights Management (PAP) using:\n\t\t// const freshAgreement = await this._policyAdministrationPoint.get(transferProcess.agreementId);\n\t\t// This would ensure policies are always up-to-date and support dynamic policy updates.\n\t\tconst agreement: IDataspaceProtocolAgreement = {\n\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\"@type\": OdrlTypes.Agreement,\n\t\t\t\"@id\": transferProcess.agreementId,\n\t\t\ttarget: transferProcess.datasetId,\n\t\t\t// Provider is the assigner, consumer is the assignee\n\t\t\tassigner: transferProcess.providerIdentity ?? \"\",\n\t\t\tassignee: transferProcess.consumerIdentity ?? \"\"\n\t\t};\n\n\t\t// Extract policies from the stored Agreement\n\t\t// Extract permission, prohibition, and obligation\n\t\tif (Is.arrayValue(transferProcess.policies)) {\n\t\t\tconst storedAgreement = transferProcess.policies[0] as\n\t\t\t\t| IDataspaceProtocolAgreement\n\t\t\t\t| undefined;\n\t\t\tif (storedAgreement) {\n\t\t\t\tagreement.permission = storedAgreement.permission;\n\t\t\t\tagreement.prohibition = storedAgreement.prohibition;\n\t\t\t\tagreement.obligation = storedAgreement.obligation;\n\t\t\t}\n\t\t}\n\n\t\tconst state = transferProcess.state;\n\t\tconst dataAddress = transferProcess.dataAddress;\n\n\t\treturn {\n\t\t\tconsumerPid: transferProcess.consumerPid,\n\t\t\tproviderPid: transferProcess.providerPid,\n\t\t\tagreement,\n\t\t\tdatasetId: transferProcess.datasetId,\n\t\t\tofferId: transferProcess.offerId,\n\t\t\tstate,\n\t\t\tconsumerIdentity: transferProcess.consumerIdentity,\n\t\t\tproviderIdentity: transferProcess.providerIdentity,\n\t\t\tdataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Apply ODRL policy enforcement to query results.\n\t * Delegates to the Policy Enforcement Point (PEP) which coordinates\n\t * PDP, arbiters, and enforcement processors.\n\t * @param result The data asset item list result to filter.\n\t * @param agreement The ODRL Agreement containing policies.\n\t * @returns The result with policies applied.\n\t * @internal\n\t */\n\tprivate async applyPolicyFilters(\n\t\tresult: IDataAssetItemListResult,\n\t\tagreement?: IDataspaceProtocolAgreement\n\t): Promise<IDataAssetItemListResult> {\n\t\tif (!agreement) {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst processed =\n\t\t\tawait this._policyEnforcementPoint.interceptWithPolicy<IDataAssetItemListResult>(\n\t\t\t\tagreement,\n\t\t\t\tresult\n\t\t\t);\n\n\t\tif (Is.arrayValue(agreement.obligation)) {\n\t\t\tawait this.logObligations(agreement.obligation, OdrlPolicyHelper.getUid(agreement) ?? \"\");\n\t\t}\n\n\t\treturn processed;\n\t}\n\n\t/**\n\t * Enforce the transfer's ODRL agreement on an inbound inbox activity via the PEP.\n\t * The PEP evaluates the agreement against the activity and either denies it or\n\t * permits it — potentially manipulating (filtering/redacting) the payload — and\n\t * the returned activity is what gets dispatched. The action is derived from the\n\t * transfer direction: provider-generated activities are read deliveries, while\n\t * consumer-generated activities are write contributions whose Activity Streams\n\t * verb maps to its ODRL action. A denied activity comes back empty. Skipped when\n\t * no PEP is wired or the agreement carries no rules, matching the read/push\n\t * lenience for agreements negotiated before this gate existed.\n\t * @param transferProcess The transfer the activity targets.\n\t * @param activity The inbound activity.\n\t * @param generatorIsConsumer True when the generator is the consumer side\n\t * (a write contribution); false when it is the provider side (a read delivery).\n\t * @returns The activity with policy applied, for dispatch.\n\t * @internal\n\t */\n\tprivate async enforceInboxPolicy(\n\t\ttransferProcess: TransferProcess,\n\t\tactivity: IActivityStreamsActivity,\n\t\tgeneratorIsConsumer: boolean\n\t): Promise<IActivityStreamsActivity> {\n\t\tconst { agreement, consumerPid } = this.buildTransferContext(transferProcess);\n\t\tconst hasRules =\n\t\t\tIs.arrayValue(agreement.permission) ||\n\t\t\tIs.arrayValue(agreement.prohibition) ||\n\t\t\tIs.arrayValue(agreement.obligation);\n\t\tif (!hasRules) {\n\t\t\treturn activity;\n\t\t}\n\n\t\tconst agreementId = OdrlPolicyHelper.getUid(agreement);\n\t\tconst action = this.deriveInboxAction(activity, generatorIsConsumer);\n\t\tconst processed = await this._policyEnforcementPoint.interceptWithPolicy<\n\t\t\tIActivityStreamsActivity,\n\t\t\tIActivityStreamsActivity\n\t\t>(agreement, activity, action);\n\n\t\t// The enforcement processor returns the (possibly manipulated) activity when\n\t\t// the action is permitted, and an empty object when it is denied.\n\t\tif (!Is.objectValue<IActivityStreamsActivity>(processed)) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushActivityNotPermittedByPolicy\",\n\t\t\t\t{ agreementId, consumerPid }\n\t\t\t);\n\t\t}\n\n\t\tif (Is.arrayValue(agreement.obligation)) {\n\t\t\tawait this.logObligations(agreement.obligation, agreementId ?? \"\");\n\t\t}\n\n\t\treturn processed;\n\t}\n\n\t/**\n\t * Derive the ODRL action to enforce for an inbound activity from the transfer\n\t * direction and the Activity Streams verb. Provider-generated activities are read\n\t * deliveries; consumer-generated activities are write contributions whose verb\n\t * maps to the corresponding ODRL action.\n\t * @param activity The inbound activity.\n\t * @param generatorIsConsumer True when the generator is the consumer side.\n\t * @returns The ODRL action to evaluate.\n\t * @internal\n\t */\n\tprivate deriveInboxAction(\n\t\tactivity: IActivityStreamsActivity,\n\t\tgeneratorIsConsumer: boolean\n\t): OdrlActionType | string {\n\t\tif (!generatorIsConsumer) {\n\t\t\treturn OdrlActionType.Read;\n\t\t}\n\n\t\tconst verb = Is.arrayValue(activity.type) ? activity.type[0] : activity.type;\n\t\tif (verb === ActivityStreamsTypes.Update) {\n\t\t\treturn OdrlActionType.Modify;\n\t\t}\n\t\tif (verb === ActivityStreamsTypes.Delete || verb === ActivityStreamsTypes.Remove) {\n\t\t\treturn OdrlActionType.Delete;\n\t\t}\n\t\t// Create, Add and any other contribution verb map to write.\n\t\treturn OdrlActionType.Write;\n\t}\n\n\t/**\n\t * Log ODRL obligations for auditing purposes.\n\t * Obligations are duties that must be fulfilled as part of the agreement.\n\t * @param obligations The obligation rules from the Agreement.\n\t * @param agreementId The agreement ID for reference.\n\t * @internal\n\t */\n\tprivate async logObligations(\n\t\tobligations: IDataspaceProtocolAgreement[\"obligation\"],\n\t\tagreementId: string\n\t): Promise<void> {\n\t\tif (!Is.arrayValue(obligations)) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const obligation of obligations) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"policyObligationTriggered\",\n\t\t\t\tdata: {\n\t\t\t\t\tagreementId,\n\t\t\t\t\taction: obligation.action,\n\t\t\t\t\ttarget: obligation.target,\n\t\t\t\t\tassignee: obligation.assignee\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Processes a task for an activity, by creating a background task and registering the handler.\n\t * @param activityLogEntryId The ID of the activity log entry.\n\t * @param activity The activity to be processed.\n\t * @param handlerApps The handler applications for the activity.\n\t * @param dataspaceAppId The ID of the handler application.\n\t * @param taskEntries The list of activity log entries.\n\t * @param isRetry Indicates if this is a retry of a previous task.\n\t * @returns True if the task was processed inline.\n\t * @internal\n\t */\n\tprivate async processTask(\n\t\tactivityLogEntryId: string,\n\t\tactivity: IActivityStreamsActivity,\n\t\thandlerApps: { [id: string]: { app: IDataspaceApp; processingGroupId?: string } },\n\t\tdataspaceAppId: string,\n\t\ttaskEntries: IActivityTaskEntry[],\n\t\tisRetry: boolean\n\t): Promise<boolean> {\n\t\tconst handlerApp = handlerApps[dataspaceAppId].app;\n\t\tconst processingGroupId = handlerApps[dataspaceAppId].processingGroupId;\n\n\t\tconst payload: IExecutionPayload = {\n\t\t\tactivityLogEntryId,\n\t\t\tactivity: activity as IDataspaceActivity,\n\t\t\tdataspaceAppId\n\t\t};\n\n\t\t// If there is no processing group we execute the task inline without creating a background task\n\t\tconst isInlineTask = !Is.stringValue(processingGroupId);\n\t\tif (isInlineTask) {\n\t\t\tconst handleActivity = handlerApp?.handleActivity?.bind(handlerApp);\n\t\t\tif (!Is.function(handleActivity)) {\n\t\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"missingHandleActivity\", {\n\t\t\t\t\tdataspaceAppId\n\t\t\t\t});\n\t\t\t}\n\t\t\tlet taskError;\n\t\t\tlet taskResult;\n\t\t\ttry {\n\t\t\t\ttaskResult = await handleActivity(activity as IDataspaceActivity);\n\t\t\t} catch (error) {\n\t\t\t\tconst baseErr = BaseError.fromError(error);\n\t\t\t\tconst isSemanticError =\n\t\t\t\t\tBaseError.someErrorName(baseErr, ValidationError.CLASS_NAME) ||\n\t\t\t\t\tBaseError.someErrorName(baseErr, GuardError.CLASS_NAME);\n\t\t\t\ttaskError = isSemanticError\n\t\t\t\t\t? new UnprocessableError(\n\t\t\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\t\"activitySemanticError\",\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tbaseErr\n\t\t\t\t\t\t)\n\t\t\t\t\t: baseErr;\n\t\t\t}\n\n\t\t\tconst now = Date.now();\n\t\t\tconst taskEntry: IActivityTaskEntry = {\n\t\t\t\ttaskId: RandomHelper.generateUuidV7(\"compact\"),\n\t\t\t\tdataspaceAppId,\n\t\t\t\tprocessingGroupId,\n\t\t\t\tresult: taskResult,\n\t\t\t\tstartDate: new Date(now).toISOString(),\n\t\t\t\tendDate: new Date(now).toISOString(),\n\t\t\t\tstatus: Is.empty(taskError) ? ActivityTaskStatus.Success : ActivityTaskStatus.Failed,\n\t\t\t\terror: taskError?.toJsonObject()\n\t\t\t};\n\t\t\ttaskEntries.push(taskEntry);\n\n\t\t\tawait this.notifyTaskStatusChanged(\n\t\t\t\tpayload.activityLogEntryId,\n\t\t\t\tpayload.activity.id,\n\t\t\t\tpayload.dataspaceAppId,\n\t\t\t\ttaskEntry.taskId,\n\t\t\t\ttaskEntry.status\n\t\t\t);\n\t\t} else {\n\t\t\tconst processingGroups = handlerApp.processingGroups?.() ?? {};\n\t\t\tif (Is.empty(processingGroups[processingGroupId])) {\n\t\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"invalidProcessingGroupId\", {\n\t\t\t\t\tprocessingGroupId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst processingGroupOptions = processingGroups[processingGroupId];\n\n\t\t\tconst taskType = `${dataspaceAppId}${processingGroupId ? `-${processingGroupId}` : \"\"}`;\n\n\t\t\tconst taskId = await this._backgroundTaskComponent.create<IExecutionPayload>(\n\t\t\t\ttaskType,\n\t\t\t\tpayload,\n\t\t\t\t{\n\t\t\t\t\tretainFor: this._retainTasksFor,\n\t\t\t\t\tretryCount: processingGroupOptions?.retryCount ?? this._retryCount\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (!this._registeredTaskTypes.includes(taskType)) {\n\t\t\t\tthis._registeredTaskTypes.push(taskType);\n\n\t\t\t\tawait this._backgroundTaskComponent.registerHandler<IExecutionPayload, unknown>(\n\t\t\t\t\ttaskType,\n\t\t\t\t\t\"@twin.org/dataspace-app-runner\",\n\t\t\t\t\t\"appRunner\",\n\t\t\t\t\tasync task => {\n\t\t\t\t\t\tawait this.finaliseBackgroundTask(task.id, task.status, task.payload);\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tmaxWorkerCount: processingGroupOptions?.concurrentTasks,\n\t\t\t\t\t\tidleShutdownTimeout: processingGroupOptions?.idleShutdownTimeout,\n\t\t\t\t\t\tinitialiseMethod: \"appRunnerStart\",\n\t\t\t\t\t\tshutdownMethod: \"appRunnerEnd\"\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\ttaskEntries.push({\n\t\t\t\ttaskId,\n\t\t\t\tdataspaceAppId,\n\t\t\t\tprocessingGroupId,\n\t\t\t\tstatus: ActivityTaskStatus.Pending\n\t\t\t});\n\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"scheduledTask\",\n\t\t\t\tdata: {\n\t\t\t\t\ttaskId,\n\t\t\t\t\tdataspaceAppId,\n\t\t\t\t\tisRetry\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn isInlineTask;\n\t}\n\n\t/**\n\t * Constructs the activity log entry with processing status and associated tasks.\n\t * @param activityLog The activity log details retrieved from storage.\n\t * @param activityTasks The activity tasks associated with the log entry, if any.\n\t * @returns The complete activity log entry with status and tasks.\n\t * @internal\n\t */\n\tprivate async constructLogEntry(\n\t\tactivityLog: ActivityLogDetails,\n\t\tactivityTasks: ActivityTask | undefined\n\t): Promise<IActivityLogEntry> {\n\t\tlet tasks: IActivityTaskEntry[] | undefined;\n\n\t\t// For calculating the processing status. `Registering` if we cannot determine the activity tasks yet\n\t\tlet status: ActivityProcessingStatus = ActivityProcessingStatus.Registering;\n\n\t\t// Now query the associated tasks\n\t\t// If activity tasks is undefined it is because the corresponding store has not been persisted yet\n\t\tif (!Is.undefined(activityTasks)) {\n\t\t\ttasks = [];\n\n\t\t\tconst typeCount: {\n\t\t\t\t[status in TaskStatus]: number;\n\t\t\t} = {\n\t\t\t\t[TaskStatus.Pending]: 0,\n\t\t\t\t[TaskStatus.Processing]: 0,\n\t\t\t\t[TaskStatus.Success]: 0,\n\t\t\t\t[TaskStatus.Failed]: 0,\n\t\t\t\t[TaskStatus.Cancelled]: 0\n\t\t\t};\n\n\t\t\tfor (const entity of activityTasks.associatedTasks) {\n\t\t\t\tlet entry: IActivityTaskEntry | undefined;\n\t\t\t\tif (!Is.stringValue(entity.processingGroupId)) {\n\t\t\t\t\t// If there is no process group, the task was processed inline so the task status is already available in the entity\n\t\t\t\t\ttypeCount[entity.status]++;\n\t\t\t\t\tentry = entity;\n\t\t\t\t} else {\n\t\t\t\t\tconst taskDetails = await this._backgroundTaskComponent.get<IExecutionPayload, unknown>(\n\t\t\t\t\t\tentity.taskId\n\t\t\t\t\t);\n\t\t\t\t\tif (!Is.empty(taskDetails)) {\n\t\t\t\t\t\ttypeCount[taskDetails.status]++;\n\n\t\t\t\t\t\tswitch (taskDetails.status) {\n\t\t\t\t\t\t\tcase TaskStatus.Success:\n\t\t\t\t\t\t\t\tentry = {\n\t\t\t\t\t\t\t\t\t...entity,\n\t\t\t\t\t\t\t\t\tstatus: ActivityTaskStatus.Success,\n\t\t\t\t\t\t\t\t\tresult: taskDetails.result,\n\t\t\t\t\t\t\t\t\tstartDate: taskDetails?.dateCreated,\n\t\t\t\t\t\t\t\t\tendDate: taskDetails?.dateCompleted\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Pending:\n\t\t\t\t\t\t\t\tentry = { ...entity, status: ActivityTaskStatus.Pending };\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Processing:\n\t\t\t\t\t\t\t\tentry = {\n\t\t\t\t\t\t\t\t\t...entity,\n\t\t\t\t\t\t\t\t\tstatus: ActivityTaskStatus.Processing,\n\t\t\t\t\t\t\t\t\tstartDate: taskDetails.dateCreated\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Failed:\n\t\t\t\t\t\t\t\tentry = {\n\t\t\t\t\t\t\t\t\t...entity,\n\t\t\t\t\t\t\t\t\tstatus: ActivityTaskStatus.Failed,\n\t\t\t\t\t\t\t\t\terror: taskDetails.error\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Cancelled:\n\t\t\t\t\t\t\t\t// Nothing to do for cancelled tasks\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!Is.empty(entry)) {\n\t\t\t\t\ttasks.push(entry);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeCount[TaskStatus.Failed] > 0) {\n\t\t\t\tstatus = ActivityProcessingStatus.Error;\n\t\t\t} else if (typeCount[TaskStatus.Processing] > 0) {\n\t\t\t\tstatus = ActivityProcessingStatus.Running;\n\t\t\t} else if (typeCount[TaskStatus.Pending] > 0) {\n\t\t\t\tstatus = ActivityProcessingStatus.Pending;\n\t\t\t} else {\n\t\t\t\tstatus = ActivityProcessingStatus.Completed;\n\t\t\t}\n\t\t}\n\t\treturn { ...activityLog, status, tasks };\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataspaceDataPlaneService.js","sourceRoot":"","sources":["../../src/dataspaceDataPlaneService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,aAAa,EAA2B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACN,UAAU,EAIV,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACN,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,EAAE,EACF,UAAU,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,eAAe,EAEf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACN,eAAe,EACf,YAAY,EACZ,eAAe,EAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,aAAa,EAoBb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACN,gBAAgB,EAEhB,MAAM,oCAAoC,CAAC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AC;YACD,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtC,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC;YACzC,CAAC;iBAAM,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACjD,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC;YAC3C,CAAC;iBAAM,IAAI,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACP,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC;YAC7C,CAAC;QACF,CAAC;QACD,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { HttpUrlHelper, type IPlatformComponent } from \"@twin.org/api-models\";\nimport {\n\tTaskStatus,\n\ttype IBackgroundTaskComponent,\n\ttype IScheduledTaskTime,\n\ttype ITaskSchedulerComponent\n} from \"@twin.org/background-task-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tArrayHelper,\n\tBaseError,\n\tComponentFactory,\n\tConflictError,\n\tConverter,\n\tGeneralError,\n\tGuardError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tNotFoundError,\n\tRandomHelper,\n\tUnauthorizedError,\n\tUnprocessableError,\n\tValidation,\n\tValidationError,\n\ttype IValidationFailure\n} from \"@twin.org/core\";\nimport { Blake2b } from \"@twin.org/crypto\";\nimport { DataTypeHelper, JsonSchemaHelper } from \"@twin.org/data-core\";\nimport {\n\tJsonLdDataTypes,\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionElement,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tActivityProcessingStatus,\n\tActivityTaskStatus,\n\tDataRequestType,\n\tDataspaceAppFactory,\n\tDataspaceContexts,\n\tDataspaceDataTypes,\n\tDataspaceTypes,\n\tgetJsonLdType,\n\ttype DataspaceAppDataset,\n\ttype IActivityLogEntry,\n\ttype IActivityLogStatusNotification,\n\ttype IActivityQuery,\n\ttype IActivityTaskEntry,\n\ttype IDataAssetItemListResult,\n\ttype IDataAssetQuery,\n\ttype IDataRequest,\n\ttype IDataspaceActivity,\n\ttype IDataspaceApp,\n\ttype IDataspaceDataPlaneComponent,\n\ttype IEntitySet,\n\ttype IExecutionPayload,\n\ttype IFilteringQuery,\n\ttype IFollowActivity,\n\ttype IPushDeliveryPayload,\n\ttype ITransferContext,\n\ttype IUndoActivity,\n\ttype TransferProcess\n} from \"@twin.org/dataspace-models\";\nimport { EngineCoreFactory } from \"@twin.org/engine-models\";\nimport { ComparisonOperator, LogicalOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\ttype IPolicyEnforcementPointComponent\n} from \"@twin.org/rights-management-models\";\nimport {\n\tDataspaceProtocolDataTypes,\n\tDataspaceProtocolTransferProcessStateType,\n\ttype IDataspaceProtocolAgreement,\n\ttype IDataspaceProtocolDataset\n} from \"@twin.org/standards-dataspace-protocol\";\nimport {\n\tSchemaOrgContexts,\n\tSchemaOrgDataTypes,\n\tSchemaOrgTypes\n} from \"@twin.org/standards-schema-org\";\nimport {\n\tActivityStreamsContexts,\n\tActivityStreamsTypes,\n\ttype IActivityStreamsActivity\n} from \"@twin.org/standards-w3c-activity-streams\";\nimport { OdrlActionType, OdrlContexts, OdrlTypes } from \"@twin.org/standards-w3c-odrl\";\nimport { TrustHelper, type ITrustComponent } from \"@twin.org/trust-models\";\nimport type { ActivityLogDetails } from \"./entities/activityLogDetails.js\";\nimport type { ActivityTask } from \"./entities/activityTask.js\";\nimport type { PushSubscription } from \"./entities/pushSubscription.js\";\nimport type { IDataspaceDataPlaneServiceConstructorOptions } from \"./models/IDataspaceDataPlaneServiceConstructorOptions.js\";\n\nconst FOLLOW_ACTIVITY_URN_PREFIX = \"urn:x-follow:\";\nconst TRANSFER_URN_PREFIX = \"urn:x-transfer:\";\nconst UNDO_ACTIVITY_URN_PREFIX = \"urn:x-undo:\";\nconst ACTIVITY_LOG_URN_PREFIX = \"urn:x-activity-log:\";\n\n/**\n * Dataspace Data Plane Service.\n */\nexport class DataspaceDataPlaneService implements IDataspaceDataPlaneComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataspaceDataPlaneService>();\n\n\t/**\n\t * Background task type identifier for push delivery tasks.\n\t */\n\tpublic static readonly PUSH_DELIVERY_TASK_TYPE = \"push-delivery\";\n\n\t/**\n\t * Milliseconds per minute (60 * 1000).\n\t * @internal\n\t */\n\tprivate static readonly _MS_PER_MINUTE: number = 60 * 1000;\n\n\t/**\n\t * Minutes per day (24 * 60 = 1440).\n\t * @internal\n\t */\n\tprivate static readonly _MINUTES_PER_DAY: number = 24 * 60;\n\n\t/**\n\t * The default cleanup interval in minutes. (1 hour)\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_CLEANUP_INTERVAL: number = 60;\n\n\t/**\n\t * The default retain interval in minutes. (10 minutes)\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_RETAIN_INTERVAL: number = 10;\n\n\t/**\n\t * Logging service type.\n\t * @internal\n\t */\n\tprivate readonly _loggingComponentType?: string;\n\n\t/**\n\t * Logging service.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Storage service for activity logging.\n\t * @internal\n\t */\n\tprivate readonly _entityStorageActivityLogs: IEntityStorageConnector<ActivityLogDetails>;\n\n\t/**\n\t * Storage service for activity tasks.\n\t * @internal\n\t */\n\tprivate readonly _entityStorageActivityTasks: IEntityStorageConnector<ActivityTask>;\n\n\t/**\n\t * Background Task Component.\n\t * @internal\n\t */\n\tprivate readonly _backgroundTaskComponent: IBackgroundTaskComponent;\n\n\t/**\n\t * Activity Log Status callbacks.\n\t * @internal\n\t */\n\tprivate readonly _activityLogStatusCallbacks: {\n\t\t[key: string]: (notification: IActivityLogStatusNotification) => Promise<void>;\n\t};\n\n\t/**\n\t * Track task handler registrations to avoid resetting worker pools on every task.\n\t * @internal\n\t */\n\tprivate readonly _registeredTaskTypes: string[];\n\n\t/**\n\t * Task retention. -1 retain forever.\n\t * @internal\n\t */\n\tprivate readonly _retainTasksFor: number;\n\n\t/**\n\t * Activity Log Entry retention. -1 retain forever.\n\t * @internal\n\t */\n\tprivate readonly _retainActivityLogsFor: number;\n\n\t/**\n\t * Retry count for failed tasks.\n\t * @internal\n\t */\n\tprivate readonly _retryCount?: number;\n\n\t/**\n\t * Max retry count for push delivery HTTP requests.\n\t * @internal\n\t */\n\tprivate readonly _pushRetryCount: number;\n\n\t/**\n\t * Base retry delay (ms) for push delivery HTTP requests.\n\t * @internal\n\t */\n\tprivate readonly _pushRetryBaseDelayMs: number;\n\n\t/**\n\t * Timeout (ms) for each push delivery HTTP POST request.\n\t * @internal\n\t */\n\tprivate readonly _pushTimeoutMs: number;\n\n\t/**\n\t * Clean up interval for activity logs.\n\t * @internal\n\t */\n\tprivate readonly _activityLogCleanUpInterval: number;\n\n\t/**\n\t * Interval in minutes between orphaned PushSubscription cleanup scans.\n\t * @internal\n\t */\n\tprivate readonly _pushSubscriptionCleanupIntervalMinutes: number;\n\n\t/**\n\t * Whether there is an ongoing clean up process.\n\t * @internal\n\t */\n\tprivate _cleanUpProcessOngoing: boolean;\n\n\t/**\n\t * The task scheduler used to clean up activity logs.\n\t * @internal\n\t */\n\tprivate readonly _taskScheduler: ITaskSchedulerComponent;\n\n\t/**\n\t * The trust component.\n\t * @internal\n\t */\n\tprivate readonly _trustComponent: ITrustComponent;\n\n\t/**\n\t * The policy enforcement point for ODRL policy enforcement.\n\t * @internal\n\t */\n\tprivate readonly _policyEnforcementPoint: IPolicyEnforcementPointComponent;\n\n\t/**\n\t * The platform component.\n\t * @internal\n\t */\n\tprivate readonly _platformComponent: IPlatformComponent;\n\n\t/**\n\t * Entity storage for Transfer Process entities.\n\t * Used to read transfer state from shared storage (written by Control Plane).\n\t * @internal\n\t */\n\tprivate readonly _transferProcessStorage: IEntityStorageConnector<TransferProcess>;\n\n\t/**\n\t * Factory key used to look up the push-subscription storage. Resolved lazily at call time\n\t * (not at construction) so the storage may register after the data plane is built.\n\t * @internal\n\t */\n\tprivate readonly _pushSubscriptionStorageType: string;\n\n\t/**\n\t * Entity storage for tenant-supplied Dataspace App Dataset entities.\n\t * @internal\n\t */\n\tprivate readonly _dataspaceAppDatasetStorage: IEntityStorageConnector<DataspaceAppDataset>;\n\n\t/**\n\t * Create a new instance of DataspaceDataPlane.\n\t * @param options The options for the data plane.\n\t */\n\tconstructor(options?: IDataspaceDataPlaneServiceConstructorOptions) {\n\t\tthis._loggingComponentType = options?.loggingComponentType;\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(this._loggingComponentType);\n\n\t\tthis._entityStorageActivityLogs = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<ActivityLogDetails>\n\t\t>(options?.activityLogEntityStorageType ?? nameofKebabCase<ActivityLogDetails>());\n\n\t\tthis._entityStorageActivityTasks = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<ActivityTask>\n\t\t>(options?.activityTaskEntityStorageType ?? nameofKebabCase<ActivityTask>());\n\n\t\tthis._backgroundTaskComponent = ComponentFactory.get(\n\t\t\toptions?.backgroundTaskComponentType ?? \"background-task\"\n\t\t);\n\n\t\tthis._taskScheduler = ComponentFactory.get<ITaskSchedulerComponent>(\n\t\t\toptions?.taskSchedulerComponentType ?? \"task-scheduler\"\n\t\t);\n\n\t\tthis._trustComponent = ComponentFactory.get<ITrustComponent>(\n\t\t\toptions?.trustComponentType ?? \"trust\"\n\t\t);\n\n\t\tthis._policyEnforcementPoint = ComponentFactory.get<IPolicyEnforcementPointComponent>(\n\t\t\toptions?.pepComponentType ?? \"policy-enforcement-point-service\"\n\t\t);\n\n\t\tthis._platformComponent = ComponentFactory.get<IPlatformComponent>(\n\t\t\toptions?.platformComponentType ?? \"platform\"\n\t\t);\n\n\t\t// Entity storage for Transfer Process state lookup\n\t\t// Used to read transfer state from shared storage (written by Control Plane)\n\t\tthis._transferProcessStorage = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<TransferProcess>\n\t\t>(options?.transferProcessEntityStorageType ?? nameofKebabCase<TransferProcess>());\n\n\t\t// Push-subscription storage is optional and resolved lazily. The data plane is typically\n\t\t// constructed before its dependent storages register, so caching the connector here would\n\t\t// permanently miss it. We only need the factory key — every push call site re-resolves.\n\t\tthis._pushSubscriptionStorageType =\n\t\t\toptions?.pushSubscriptionEntityStorageType ?? nameofKebabCase<PushSubscription>();\n\n\t\tthis._dataspaceAppDatasetStorage = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<DataspaceAppDataset>\n\t\t>(options?.dataspaceAppDatasetEntityStorageType ?? nameofKebabCase<DataspaceAppDataset>());\n\n\t\tJsonLdDataTypes.registerTypes();\n\t\tDataspaceDataTypes.registerTypes();\n\t\tSchemaOrgDataTypes.registerRedirects();\n\t\tDataspaceProtocolDataTypes.registerRedirects();\n\t\tDataspaceProtocolDataTypes.registerTypes();\n\n\t\tthis._activityLogStatusCallbacks = {};\n\t\tthis._registeredTaskTypes = [];\n\n\t\tthis._retainTasksFor =\n\t\t\tDataspaceDataPlaneService._DEFAULT_RETAIN_INTERVAL * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\tthis._retainActivityLogsFor =\n\t\t\tDataspaceDataPlaneService._DEFAULT_RETAIN_INTERVAL * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\tthis._retryCount = options?.config?.retryCount;\n\t\tthis._pushRetryCount = options?.config?.pushRetryCount ?? 3;\n\t\tthis._pushRetryBaseDelayMs = options?.config?.pushRetryBaseDelayMs ?? 1000;\n\t\tthis._pushTimeoutMs = options?.config?.pushTimeoutMs ?? 30000;\n\t\tthis._activityLogCleanUpInterval = DataspaceDataPlaneService._DEFAULT_CLEANUP_INTERVAL;\n\t\tthis._pushSubscriptionCleanupIntervalMinutes = Math.max(\n\t\t\t1,\n\t\t\tMath.round((options?.config?.pushSubscriptionCleanupIntervalMs ?? 3_600_000) / 60_000)\n\t\t);\n\t\tthis._cleanUpProcessOngoing = false;\n\n\t\tconst validationErrors: IValidationFailure[] = [];\n\t\tif (!Is.empty(options?.config?.retainActivityLogsFor)) {\n\t\t\tGuards.integer(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tnameof(options.config.retainActivityLogsFor),\n\t\t\t\toptions.config.retainActivityLogsFor\n\t\t\t);\n\n\t\t\tif (options.config.retainActivityLogsFor === -1) {\n\t\t\t\tthis._retainTasksFor = -1;\n\t\t\t\tthis._retainActivityLogsFor = -1;\n\t\t\t} else {\n\t\t\t\tValidation.integer(\n\t\t\t\t\tnameof(options.config.retainActivityLogsFor),\n\t\t\t\t\toptions.config.retainActivityLogsFor,\n\t\t\t\t\tvalidationErrors,\n\t\t\t\t\tundefined,\n\t\t\t\t\t{ minValue: 1 }\n\t\t\t\t);\n\t\t\t\t// Retention of internal tasks launched\n\t\t\t\t// 5 minutes of margin with respect to the Activity Log Entry to ensure proper removal\n\t\t\t\tthis._retainTasksFor =\n\t\t\t\t\t(options.config.retainActivityLogsFor + 5) * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\t\t\tthis._retainActivityLogsFor =\n\t\t\t\t\toptions.config.retainActivityLogsFor * DataspaceDataPlaneService._MS_PER_MINUTE;\n\t\t\t}\n\t\t}\n\n\t\tif (!Is.empty(options?.config?.activityLogsCleanUpInterval)) {\n\t\t\tGuards.integer(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tnameof(options.config.activityLogsCleanUpInterval),\n\t\t\t\toptions.config.activityLogsCleanUpInterval\n\t\t\t);\n\t\t\tValidation.integer(\n\t\t\t\tnameof(options.config.activityLogsCleanUpInterval),\n\t\t\t\toptions.config.activityLogsCleanUpInterval,\n\t\t\t\tvalidationErrors,\n\t\t\t\tundefined,\n\t\t\t\t{ minValue: 1 }\n\t\t\t);\n\t\t\tthis._activityLogCleanUpInterval = options.config.activityLogsCleanUpInterval;\n\t\t}\n\n\t\tif (!Is.empty(options?.config?.pushTimeoutMs)) {\n\t\t\tGuards.integer(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tnameof(options.config.pushTimeoutMs),\n\t\t\t\toptions.config.pushTimeoutMs\n\t\t\t);\n\t\t\tValidation.integer(\n\t\t\t\tnameof(options.config.pushTimeoutMs),\n\t\t\t\toptions.config.pushTimeoutMs,\n\t\t\t\tvalidationErrors,\n\t\t\t\tundefined,\n\t\t\t\t{ minValue: 1 }\n\t\t\t);\n\t\t\tthis._pushTimeoutMs = options.config.pushTimeoutMs;\n\t\t}\n\n\t\tValidation.asValidationError(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(options?.config),\n\t\t\tvalidationErrors\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn DataspaceDataPlaneService.CLASS_NAME;\n\t}\n\n\t/**\n\t * The service needs to be started when the application is initialized.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tawait this._backgroundTaskComponent.registerHandler<IPushDeliveryPayload, unknown>(\n\t\t\tDataspaceDataPlaneService.PUSH_DELIVERY_TASK_TYPE,\n\t\t\t\"@twin.org/dataspace-app-runner\",\n\t\t\t\"pushDeliveryRunner\",\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\tinitialiseMethod: \"pushDeliveryRunnerStart\",\n\t\t\t\tshutdownMethod: \"pushDeliveryRunnerEnd\",\n\t\t\t\tidleShutdownTimeout: -1\n\t\t\t}\n\t\t);\n\n\t\tconst engine = EngineCoreFactory.getIfExists(\"engine\");\n\t\tif (Is.empty(engine) || engine.isClone()) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"engineCloneStart\"\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Only we have a task scheduler if there is a retention different than -1\n\t\tif (this._retainActivityLogsFor !== -1) {\n\t\t\tconst taskTime: IScheduledTaskTime[] = [\n\t\t\t\t{\n\t\t\t\t\tnextTriggerTime: Date.now() + 5000,\n\t\t\t\t\t...this.calculateCleaningTaskSchedule(this._activityLogCleanUpInterval)\n\t\t\t\t}\n\t\t\t];\n\n\t\t\tawait this._taskScheduler.addTask(\"dataspace-cleanup\", taskTime, async () => {\n\t\t\t\tawait this._logging?.log({\n\t\t\t\t\tlevel: \"debug\",\n\t\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\tmessage: \"scheduledCleanUpTask\"\n\t\t\t\t});\n\n\t\t\t\tawait this.cleanupActivityLog();\n\t\t\t});\n\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"taskSchedulerStarted\",\n\t\t\t\tdata: {\n\t\t\t\t\ttaskTime\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tconst pushCleanupTaskTime: IScheduledTaskTime[] = [\n\t\t\t{\n\t\t\t\tnextTriggerTime: Date.now() + 10_000,\n\t\t\t\t...this.calculateCleaningTaskSchedule(this._pushSubscriptionCleanupIntervalMinutes)\n\t\t\t}\n\t\t];\n\n\t\tawait this._taskScheduler.addTask(\n\t\t\t\"dataspace-push-subscription-cleanup\",\n\t\t\tpushCleanupTaskTime,\n\t\t\tasync () => {\n\t\t\t\tawait this.cleanupOrphanedPushSubscriptions();\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Notify an Activity.\n\t * @param activity The Activity notified.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The activity's id or entry.\n\t */\n\tpublic async notifyActivity(\n\t\tactivity: IActivityStreamsActivity,\n\t\ttrustPayload?: unknown\n\t): Promise<string | IActivityLogEntry> {\n\t\tGuards.object<IActivityStreamsActivity>(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tactivity\n\t\t);\n\n\t\t// Every caller must present a trust payload — internal calls have no bypass,\n\t\t// a missing payload fails verification. Verify it, confirm the referenced\n\t\t// transfer is still in STARTED state, and assert the verified identity is\n\t\t// one of the two parties on that transfer.\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"notifyActivity\"\n\t\t);\n\t\tconst generatorPid = this.calculateActivityGeneratorIdentity(activity);\n\t\t// Primary lookup: by consumerPid (the entity's primary key). If this hits, the\n\t\t// generator's PID equals consumerPid — the generator is the consumer side.\n\t\tlet transferProcess = await this._transferProcessStorage.get(generatorPid);\n\t\tconst generatorIsConsumer = Boolean(transferProcess);\n\n\t\tif (!transferProcess) {\n\t\t\t// Fallback: generatorPid === providerPid. providerPid is a UUIDv7 so it's\n\t\t\t// unique per transfer, but defensively reject any case where the secondary\n\t\t\t// index returns more than one match — silent first-match would risk\n\t\t\t// authorising the wrong transfer if the invariant ever breaks.\n\t\t\tconst result = await this._transferProcessStorage.query({\n\t\t\t\tconditions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tproperty: \"providerPid\",\n\t\t\t\t\t\tvalue: generatorPid,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t});\n\t\t\tif (result.entities.length > 1) {\n\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"pushActivityNotAuthorized\"\n\t\t\t\t);\n\t\t\t}\n\t\t\ttransferProcess = result.entities[0] as TransferProcess | undefined;\n\t\t\t// generatorIsConsumer stays false → generator is the provider side.\n\t\t}\n\n\t\tif (transferProcess?.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushActivityNotAuthorized\"\n\t\t\t);\n\t\t}\n\n\t\t// Bind the verified identity to the side of the transfer matching the claimed\n\t\t// generator. Without this, a party with a valid token for transfer X can post\n\t\t// an activity claiming to be the other party on the same transfer.\n\t\tconst expectedIdentity = generatorIsConsumer\n\t\t\t? transferProcess.consumerIdentity\n\t\t\t: transferProcess.providerIdentity;\n\t\tif (!Is.stringValue(expectedIdentity) || trustInfo.identity !== expectedIdentity) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushActivityNotAuthorized\"\n\t\t\t);\n\t\t}\n\n\t\t// Apply the transfer's agreement to the inbound activity via the PEP, which\n\t\t// may deny it or manipulate (filter/redact) the payload. Dispatch what the\n\t\t// PEP returns.\n\t\tactivity = await this.enforceInboxPolicy(transferProcess, activity, generatorIsConsumer);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tmessage: \"newActivity\",\n\t\t\tdata: {\n\t\t\t\tactivityType: activity.type,\n\t\t\t\tgenerator: this.calculateActivityGeneratorIdentity(activity)\n\t\t\t}\n\t\t});\n\n\t\t// We only validate that the activity conforms to Activity Streams Schema without entering into details\n\t\t// about the object, target or actor as they might be subject of custom validation rules\n\t\tconst typeId = `${DataspaceContexts.JsonSchemaNamespace}Dataspace${DataspaceTypes.Activity}`;\n\t\tconst activitySchema = await DataTypeHelper.getSchemaForType(typeId);\n\t\tif (Is.undefined(activitySchema)) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"schemaNotFound\", {\n\t\t\t\tschemaId: typeId\n\t\t\t});\n\t\t}\n\t\tconst validationFailures = await JsonSchemaHelper.validate(activitySchema, activity);\n\t\tValidation.asValidationError(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\t// Calculate Activity Log Entry Id\n\t\tconst canonical = JsonHelper.canonicalize(activity);\n\t\tconst canonicalBytes = Converter.utf8ToBytes(canonical);\n\t\tconst activityLogId = Converter.bytesToHex(Blake2b.sum256(canonicalBytes));\n\t\tconst activityLogEntryId = `${ACTIVITY_LOG_URN_PREFIX}${activityLogId}`;\n\n\t\t// Check if entry already exists\n\t\tlet logEntry = await this._entityStorageActivityLogs.get(activityLogEntryId);\n\t\tlet existingSuccessfulApps: string[] = [];\n\t\tlet isRetry = false;\n\t\tconst now = Date.now();\n\n\t\tif (!Is.undefined(logEntry)) {\n\t\t\t// Check if there are failed tasks that can be retried\n\t\t\tconst existingEntry = await this.getActivityLogEntry(activityLogEntryId);\n\n\t\t\t// If all tasks completed successfully, this is a duplicate\n\t\t\tif (existingEntry.status === ActivityProcessingStatus.Completed) {\n\t\t\t\tthrow new ConflictError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"activityAlreadyNotified\",\n\t\t\t\t\tactivityLogEntryId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// If still processing then reject to avoid race conditions\n\t\t\tif (\n\t\t\t\texistingEntry.status === ActivityProcessingStatus.Pending ||\n\t\t\t\texistingEntry.status === ActivityProcessingStatus.Running ||\n\t\t\t\texistingEntry.status === ActivityProcessingStatus.Registering\n\t\t\t) {\n\t\t\t\tthrow new ConflictError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"activityStillProcessing\",\n\t\t\t\t\tactivityLogEntryId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Status is Error - prepare for retry\n\t\t\texistingSuccessfulApps = await this.prepareForRetry(activityLogEntryId, existingEntry);\n\t\t\tisRetry = true;\n\t\t} else {\n\t\t\tlogEntry = {\n\t\t\t\tid: activityLogEntryId,\n\t\t\t\tactivityId: activity.id,\n\t\t\t\tgenerator: this.calculateActivityGeneratorIdentity(activity),\n\t\t\t\tdateCreated: new Date(now).toISOString(),\n\t\t\t\tdateModified: new Date(now).toISOString()\n\t\t\t};\n\t\t\tawait this._entityStorageActivityLogs.set(logEntry);\n\t\t}\n\n\t\tconst activityQuerySet = await this.calculateActivityQuerySet(activity as IDataspaceActivity);\n\n\t\tconst taskEntries: IActivityTaskEntry[] = [];\n\t\tconst handlerApps: {\n\t\t\t[id: string]: {\n\t\t\t\tapp: IDataspaceApp;\n\t\t\t\tprocessingGroupId?: string;\n\t\t\t};\n\t\t} = {};\n\n\t\tfor (const query of activityQuerySet) {\n\t\t\tconst apps = this.getAppForActivityQuery(query);\n\t\t\tfor (const appId in apps) {\n\t\t\t\t// Only process apps that haven't already completed successfully\n\t\t\t\tif (!handlerApps[appId] && !existingSuccessfulApps.includes(appId)) {\n\t\t\t\t\thandlerApps[appId] = apps[appId];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet inlineCount = 0;\n\t\tfor (const handlerAppId in handlerApps) {\n\t\t\tif (\n\t\t\t\tawait this.processTask(\n\t\t\t\t\tactivityLogEntryId,\n\t\t\t\t\tactivity,\n\t\t\t\t\thandlerApps,\n\t\t\t\t\thandlerAppId,\n\t\t\t\t\ttaskEntries,\n\t\t\t\t\tisRetry\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tinlineCount++;\n\t\t\t}\n\t\t}\n\n\t\tconst existingActivityTasks = isRetry\n\t\t\t? await this._entityStorageActivityTasks.get(activityLogEntryId)\n\t\t\t: undefined;\n\t\tconst existingTasksToKeep =\n\t\t\texistingActivityTasks?.associatedTasks.filter(t =>\n\t\t\t\texistingSuccessfulApps.includes(t.dataspaceAppId)\n\t\t\t) ?? [];\n\n\t\tconst activityTask: ActivityTask = {\n\t\t\tactivityLogEntryId,\n\t\t\tassociatedTasks: [...existingTasksToKeep, ...taskEntries]\n\t\t};\n\n\t\tawait this._entityStorageActivityTasks.set(activityTask);\n\n\t\tif (inlineCount === taskEntries.length) {\n\t\t\treturn this.finaliseActivityLogEntry(activityLogEntryId);\n\t\t}\n\n\t\treturn activityTask.activityLogEntryId;\n\t}\n\n\t/**\n\t * Subscribes to the activity log.\n\t * @param callback The callback to be called when Activity Log is called.\n\t * @param subscriptionId The Subscription Id.\n\t * @returns The subscription Id.\n\t */\n\tpublic async subscribeToActivityLog(\n\t\tcallback: (notification: IActivityLogStatusNotification) => Promise<void>,\n\t\tsubscriptionId?: string\n\t): Promise<string> {\n\t\tGuards.function(DataspaceDataPlaneService.CLASS_NAME, nameof(callback), callback);\n\n\t\tconst theSubscriptionId = Is.stringValue(subscriptionId)\n\t\t\t? subscriptionId\n\t\t\t: Converter.bytesToHex(RandomHelper.generate(16));\n\t\tthis._activityLogStatusCallbacks[theSubscriptionId] = callback;\n\n\t\treturn theSubscriptionId;\n\t}\n\n\t/**\n\t * Subscribes to the activity log.\n\t * @param subscriptionId The Subscription Id.\n\t */\n\tpublic async unSubscribeToActivityLog(subscriptionId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(subscriptionId),\n\t\t\tsubscriptionId\n\t\t);\n\t\tdelete this._activityLogStatusCallbacks[subscriptionId];\n\t}\n\n\t/**\n\t * Returns the activity processing details of an activity.\n\t * @param logEntryId The Id of the Activity Log Entry (a URI).\n\t * @returns the Activity Log Entry with the processing details.\n\t * @throws NotFoundError if activity log entry is not known.\n\t */\n\tpublic async getActivityLogEntry(logEntryId: string): Promise<IActivityLogEntry> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(logEntryId), logEntryId);\n\n\t\tconst activityLog = await this._entityStorageActivityLogs.get(logEntryId);\n\t\tif (Is.undefined(activityLog)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"activityLogEntryNotFound\",\n\t\t\t\tlogEntryId\n\t\t\t);\n\t\t}\n\n\t\tconst activityTasks = await this._entityStorageActivityTasks.get(logEntryId);\n\n\t\treturn this.constructLogEntry(activityLog, activityTasks);\n\t}\n\n\t/**\n\t * Get Data Asset entities. Allows to retrieve entities by their type or id.\n\t * @param entitySet The set of entities to be retrieved.\n\t * @param entitySet.jsonLdContext The JSON-LD Context to be used to expand the referred entityType.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The entities requested as a JSON-LD Document.\n\t */\n\tpublic async getDataAssetEntities(\n\t\tentitySet: IEntitySet & {\n\t\t\tjsonLdContext?: IJsonLdContextDefinitionElement[];\n\t\t},\n\t\tconsumerPid: string,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tGuards.object<IEntitySet>(DataspaceDataPlaneService.CLASS_NAME, nameof(entitySet), entitySet);\n\t\tGuards.string(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(entitySet.entityType),\n\t\t\tentitySet.entityType\n\t\t);\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"getDataAssetEntities\"\n\t\t);\n\n\t\tconst dataConsumerIdentity = trustInfo.identity;\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(dataConsumerIdentity),\n\t\t\tdataConsumerIdentity\n\t\t);\n\n\t\t// Use consumerPid to resolve datasetId via Transfer Process\n\t\t// This validates the transfer token, state, and extracts datasetId\n\t\tconst transferContext = await this.validateTransfer(consumerPid, trustPayload);\n\t\tconst resolvedDatasetId = transferContext.datasetId;\n\n\t\tconst serviceDataset = await this.getDatasetFromApps(resolvedDatasetId);\n\n\t\t// Expand entity type if LD context provided\n\t\tlet finalType: string | undefined = entitySet.entityType;\n\t\tif (!Is.undefined(entitySet.jsonLdContext)) {\n\t\t\tconst auxiliaryObj = {\n\t\t\t\t\"@context\": entitySet.jsonLdContext,\n\t\t\t\t\"@type\": entitySet.entityType\n\t\t\t};\n\t\t\tconst expanded = (await JsonLdProcessor.expand(auxiliaryObj))[0];\n\t\t\tfinalType = expanded[\"@type\"]?.[0];\n\t\t}\n\n\t\tif (Is.undefined(finalType)) {\n\t\t\tthrow new GuardError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"notExpandableType\",\n\t\t\t\tnameof(entitySet.entityType),\n\t\t\t\tentitySet.entityType\n\t\t\t);\n\t\t}\n\n\t\tconst datasetId = serviceDataset[\"@id\"];\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\t\tconst app = await this.getAppForDataAssetQuery({ datasetId });\n\n\t\tconst handleDataRequest = app.handleDataRequest?.bind(app);\n\t\tGuards.function(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(handleDataRequest),\n\t\t\thandleDataRequest\n\t\t);\n\n\t\tconst dataRequest: IDataRequest = {\n\t\t\ttype: DataRequestType.DataAssetEntities,\n\t\t\tdataAsset: serviceDataset,\n\t\t\tentitySet: {\n\t\t\t\tentityType: finalType,\n\t\t\t\tentityId: entitySet.entityId\n\t\t\t}\n\t\t};\n\n\t\tconst { data, cursor: cursorResult } = await handleDataRequest(dataRequest, cursor, limit);\n\n\t\tlet finalData: IJsonLdNodeObject[];\n\t\tif (Is.array(data)) {\n\t\t\tfinalData = data;\n\t\t} else {\n\t\t\tfinalData = [data as IJsonLdNodeObject];\n\t\t}\n\n\t\tconst itemList = {\n\t\t\t\"@context\": SchemaOrgContexts.Context,\n\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\titemListElement: finalData\n\t\t};\n\n\t\tlet result: IDataAssetItemListResult = {\n\t\t\titemList,\n\t\t\tcursor: cursorResult\n\t\t};\n\n\t\t// Apply policy filters from Agreement\n\t\tif (transferContext?.agreement) {\n\t\t\tconst filtered = await this.applyPolicyFilters(result, transferContext.agreement);\n\t\t\tif (filtered.itemList) {\n\t\t\t\tresult = filtered;\n\t\t\t} else {\n\t\t\t\tresult.itemList[SchemaOrgTypes.ItemListElement] = [];\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Queries a data asset controlled by this Dataspace App.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param query The filtering query.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The item list and optional cursor for pagination via Link headers.\n\t */\n\tpublic async queryDataAsset(\n\t\tconsumerPid: string,\n\t\tquery: IFilteringQuery,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\t\tGuards.object(DataspaceDataPlaneService.CLASS_NAME, nameof(query), query);\n\t\tGuards.string(DataspaceDataPlaneService.CLASS_NAME, nameof(query.type), query.type);\n\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"queryDataAsset\"\n\t\t);\n\n\t\tconst dataConsumerIdentity = trustInfo.identity;\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(dataConsumerIdentity),\n\t\t\tdataConsumerIdentity\n\t\t);\n\n\t\t// Use consumerPid to resolve datasetId via Transfer Process\n\t\t// This validates the transfer token, state, and extracts datasetId\n\t\tconst transferContext = await this.validateTransfer(consumerPid, trustPayload);\n\t\tconst resolvedDatasetId = transferContext.datasetId;\n\n\t\tconst serviceDataset = await this.getDatasetFromApps(resolvedDatasetId);\n\n\t\tconst datasetId = serviceDataset[\"@id\"];\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\t\tconst app = await this.getAppForDataAssetQuery({ datasetId });\n\n\t\tif (!app.supportedQueryTypes().includes(query.type)) {\n\t\t\tthrow new UnprocessableError(DataspaceDataPlaneService.CLASS_NAME, \"queryTypeNotSupported\", {\n\t\t\t\tqueryType: query.type\n\t\t\t});\n\t\t}\n\n\t\tconst dataRequest: IDataRequest = {\n\t\t\ttype: DataRequestType.QueryDataAsset,\n\t\t\tdataAsset: serviceDataset,\n\t\t\tquery\n\t\t};\n\n\t\tconst handleDataRequest = app.handleDataRequest?.bind(app);\n\t\tGuards.function(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(handleDataRequest),\n\t\t\thandleDataRequest\n\t\t);\n\n\t\tconst { data, cursor: cursorResult } = await handleDataRequest(dataRequest, cursor, limit);\n\n\t\tlet finalData: IJsonLdNodeObject[];\n\t\tif (Is.array(data)) {\n\t\t\tfinalData = data;\n\t\t} else {\n\t\t\tfinalData = [data as IJsonLdNodeObject];\n\t\t}\n\n\t\tconst itemList = {\n\t\t\t\"@context\": SchemaOrgContexts.Context,\n\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\titemListElement: finalData\n\t\t};\n\n\t\tlet result: IDataAssetItemListResult = {\n\t\t\titemList,\n\t\t\tcursor: cursorResult\n\t\t};\n\n\t\t// Apply policy filters from Agreement if using consumerPid flow\n\t\tif (transferContext?.agreement) {\n\t\t\tconst filtered = await this.applyPolicyFilters(result, transferContext.agreement);\n\t\t\tif (filtered.itemList) {\n\t\t\t\tresult = filtered;\n\t\t\t} else {\n\t\t\t\tresult.itemList[SchemaOrgTypes.ItemListElement] = [];\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Validate transfer authorization for data requests.\n\t * Reads directly from shared TransferProcess entity storage.\n\t * @param consumerPid The consumer process ID from the transfer request.\n\t * @param trustPayload The trust payload for verification (validates signature and expiry).\n\t * @returns The transfer context containing datasetId, agreement, and other transfer details.\n\t * @throws GeneralError if transfer process storage is not configured.\n\t * @throws NotFoundError if transfer process is not found.\n\t * @throws UnauthorizedError if trust verification fails.\n\t * @throws GeneralError if transfer is not in STARTED state.\n\t */\n\tpublic async validateTransfer(\n\t\tconsumerPid: string,\n\t\ttrustPayload: unknown\n\t): Promise<ITransferContext> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\t// Verify trust payload (validates JWT signature, expiry, and returns verification info)\n\t\t// The trust verifier handles all token validation including expiry\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"validateTransfer\");\n\n\t\t// Direct lookup from shared entity storage by consumerPid (which is the primary key)\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\n\t\tif (!transferProcess) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\t// Validate state: must be STARTED\n\t\tif (transferProcess.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferNotInStartedState\", {\n\t\t\t\tcurrentState: transferProcess.state\n\t\t\t});\n\t\t}\n\n\t\t// Validate datasetId is present\n\t\tif (!Is.stringValue(transferProcess.datasetId)) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferMissingDatasetId\");\n\t\t}\n\n\t\treturn this.buildTransferContext(transferProcess);\n\t}\n\n\t/**\n\t * Set up a push subscription after a transfer enters STARTED from REQUESTED.\n\t * Reads the TransferProcess, builds an IFollowActivity, calls the app's\n\t * subscribeToData, and persists a PushSubscription entity.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async setupPushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\t\tif (!transferProcess) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\tif (transferProcess.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferNotInStartedState\", {\n\t\t\t\tcurrentState: transferProcess.state\n\t\t\t});\n\t\t}\n\n\t\tif (!Is.stringValue(transferProcess.dataAddress?.endpoint)) {\n\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"transferMissingDataAddress\", {\n\t\t\t\tconsumerPid\n\t\t\t});\n\t\t}\n\n\t\t// The consumer must have baked its organization ID into the\n\t\t// callback URL so the consumer's TenantProcessor can route inbound push deliveries.\n\t\t// Reject at setup time rather than silently 401 every push.\n\t\t// Parse as a real URL so we match on the actual query parameter, not a substring\n\t\t// in a path segment / value position.\n\n\t\tconst organizationId = HttpUrlHelper.getQueryStringParam(\n\t\t\ttransferProcess.dataAddress.endpoint,\n\t\t\tContextIdKeys.Organization\n\t\t);\n\t\tif (!Is.stringValue(organizationId)) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushSubscriptionMissingOrganizationId\",\n\t\t\t\t{ consumerPid, endpoint: transferProcess.dataAddress.endpoint }\n\t\t\t);\n\t\t}\n\n\t\tconst followActivityId = `${FOLLOW_ACTIVITY_URN_PREFIX}${RandomHelper.generateUuidV7(\"compact\")}`;\n\t\tconst followActivity: IFollowActivity = {\n\t\t\t\"@context\": ActivityStreamsContexts.Context,\n\t\t\tid: followActivityId,\n\t\t\ttype: ActivityStreamsTypes.Follow,\n\t\t\tgenerator: transferProcess.consumerPid,\n\t\t\tactor: transferProcess.consumerIdentity ?? \"\",\n\t\t\tobject: { id: `${TRANSFER_URN_PREFIX}${transferProcess.consumerPid}` }\n\t\t};\n\n\t\tlet appForCompensation: IDataspaceApp | undefined;\n\t\tif (Is.stringValue(transferProcess.datasetId)) {\n\t\t\tconst appDataset = await this._dataspaceAppDatasetStorage.get(transferProcess.datasetId);\n\t\t\tif (appDataset) {\n\t\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appDataset.appId);\n\t\t\t\tawait app.subscribeToData?.(followActivity);\n\t\t\t\tappForCompensation = app;\n\t\t\t}\n\t\t}\n\n\t\tconst setupContextIds = await ContextIdStore.getContextIds();\n\t\tconst setupTenantId = setupContextIds?.[ContextIdKeys.Tenant];\n\t\tconst subscription: PushSubscription = {\n\t\t\tconsumerPid: transferProcess.consumerPid,\n\t\t\tproviderPid: transferProcess.providerPid,\n\t\t\tfollowActivityId,\n\t\t\tdatasetId: transferProcess.datasetId,\n\t\t\ttenantId: Is.stringValue(setupTenantId) ? setupTenantId : undefined,\n\t\t\tconsumerEndpoint: transferProcess.dataAddress.endpoint,\n\t\t\tconsumerAuthToken: transferProcess.dataAddress.endpointProperties?.find(\n\t\t\t\tp => p.name === \"authorization\"\n\t\t\t)?.value,\n\t\t\tpaused: false,\n\t\t\tdateCreated: new Date().toISOString(),\n\t\t\tdateModified: new Date().toISOString()\n\t\t};\n\n\t\ttry {\n\t\t\tawait this.requirePushSubscriptionStorage().set(subscription);\n\t\t} catch (storageError) {\n\t\t\t// Compensating Undo: the app's subscribeToData succeeded but the row didn't\n\t\t\t// persist. Without compensation, a retry generates a new followActivityId and\n\t\t\t// registers a second Follow on the app — with no persisted id to drive an Undo.\n\t\t\tif (appForCompensation) {\n\t\t\t\tconst compensatingUndo: IUndoActivity = {\n\t\t\t\t\t\"@context\": ActivityStreamsContexts.Context,\n\t\t\t\t\tid: `${UNDO_ACTIVITY_URN_PREFIX}${RandomHelper.generateUuidV7(\"compact\")}`,\n\t\t\t\t\ttype: ActivityStreamsTypes.Undo,\n\t\t\t\t\tgenerator: transferProcess.consumerPid,\n\t\t\t\t\tactor: transferProcess.consumerIdentity ?? \"\",\n\t\t\t\t\tobject: followActivityId\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tawait appForCompensation.unsubscribeToData?.(compensatingUndo);\n\t\t\t\t} catch (compensationError) {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"pushSubscriptionCompensationFailed\",\n\t\t\t\t\t\tdata: { consumerPid, providerPid: transferProcess.providerPid },\n\t\t\t\t\t\terror: BaseError.fromError(compensationError)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow storageError;\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionCreated\",\n\t\t\tdata: { consumerPid, providerPid: transferProcess.providerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Pause deliveries for a push subscription. The subscription entity stays\n\t * alive with status=Paused. No app unsubscribe call.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async suspendPushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushSubscriptionNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\tif (subscription.paused) {\n\t\t\treturn;\n\t\t}\n\n\t\tsubscription.paused = true;\n\t\tsubscription.dateModified = new Date().toISOString();\n\t\tawait this.requirePushSubscriptionStorage().set(subscription);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionSuspended\",\n\t\t\tdata: { consumerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Resume deliveries after a SUSPENDED → STARTED transition. Flips status\n\t * back to Active. No app subscribeToData call.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async resumePushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushSubscriptionNotFound\",\n\t\t\t\tconsumerPid\n\t\t\t);\n\t\t}\n\n\t\tif (!subscription.paused) {\n\t\t\treturn;\n\t\t}\n\n\t\tsubscription.paused = false;\n\t\tsubscription.dateModified = new Date().toISOString();\n\t\tawait this.requirePushSubscriptionStorage().set(subscription);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionResumed\",\n\t\t\tdata: { consumerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Tear down a push subscription. Builds an IUndoActivity, calls the app's\n\t * unsubscribeToData, and deletes the PushSubscription entity.\n\t * @param consumerPid The consumer process ID identifying the transfer.\n\t */\n\tpublic async teardownPushSubscription(consumerPid: string): Promise<void> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"pushSubscriptionNotFoundOnTeardown\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\n\t\tconst undoActivity: IUndoActivity = {\n\t\t\t\"@context\": ActivityStreamsContexts.Context,\n\t\t\tid: `${UNDO_ACTIVITY_URN_PREFIX}${RandomHelper.generateUuidV7(\"compact\")}`,\n\t\t\ttype: ActivityStreamsTypes.Undo,\n\t\t\tgenerator: subscription.consumerPid,\n\t\t\tactor: transferProcess?.consumerIdentity ?? \"\",\n\t\t\tobject: subscription.followActivityId\n\t\t};\n\n\t\tif (Is.stringValue(subscription.datasetId)) {\n\t\t\tconst appDataset = await this._dataspaceAppDatasetStorage.get(subscription.datasetId);\n\t\t\tif (appDataset) {\n\t\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appDataset.appId);\n\t\t\t\tawait app.unsubscribeToData?.(undoActivity);\n\t\t\t}\n\t\t}\n\n\t\tawait this.requirePushSubscriptionStorage().remove(consumerPid);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"pushSubscriptionTornDown\",\n\t\t\tdata: { consumerPid, providerPid: subscription.providerPid }\n\t\t});\n\t}\n\n\t/**\n\t * Schedule a push delivery when the app has new outbound data.\n\t * @param activity The outbound activity carrying the data payload.\n\t */\n\tpublic async processOutboxActivity(activity: IActivityStreamsActivity): Promise<void> {\n\t\tGuards.object<IActivityStreamsActivity>(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tactivity\n\t\t);\n\n\t\t// Extract consumerPid from activity.to\n\t\tlet consumerPid: string | undefined;\n\t\tif (Is.stringValue(activity.to)) {\n\t\t\tconsumerPid = activity.to;\n\t\t} else if (Is.array(activity.to)) {\n\t\t\tif (activity.to.length > 1) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\"processOutboxActivityMultipleTo\",\n\t\t\t\t\t{ count: activity.to.length }\n\t\t\t\t);\n\t\t\t}\n\t\t\tconsumerPid = activity.to[0] as string | undefined;\n\t\t}\n\n\t\tif (!Is.stringValue(consumerPid)) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushSubscriptionNotFoundForActivity\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Load PushSubscription\n\t\tconst subscription = await this.requirePushSubscriptionStorage().get(consumerPid);\n\t\tif (!subscription) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushSubscriptionNotFoundForActivity\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Skip delivery if subscription is paused\n\t\tif (subscription.paused) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushDeliverySkippedPaused\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Load TransferProcess and validate it is STARTED\n\t\tconst transferProcess = await this._transferProcessStorage.get(consumerPid);\n\t\tif (transferProcess?.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"pushSubscriptionNotFoundForActivity\",\n\t\t\t\tdata: { consumerPid }\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// Build agreement from stored transfer context\n\t\tconst { agreement } = this.buildTransferContext(transferProcess);\n\n\t\t// Extract data object from activity; a string value is an IRI reference — wrap it so the IRI is preserved.\n\t\tlet data: IJsonLdNodeObject;\n\t\tif (Is.object(activity.object)) {\n\t\t\tdata = activity.object;\n\t\t} else if (Is.stringValue(activity.object)) {\n\t\t\tdata = { \"@id\": activity.object };\n\t\t} else {\n\t\t\tdata = {};\n\t\t}\n\t\tconst entityType = Is.object(activity.object) ? (getJsonLdType(activity.object) ?? \"\") : \"\";\n\n\t\t// Capture the subscription's tenantId so the background-task runner can re-enter the\n\t\t// owning tenant's context before any tenant-scoped operation (PEP, trust signing).\n\t\t// Falls back to the current request context if the subscription pre-dates tenantId capture.\n\t\tlet payloadTenantId: string | undefined = subscription.tenantId;\n\t\tif (!Is.stringValue(payloadTenantId)) {\n\t\t\tconst ctxIds = await ContextIdStore.getContextIds();\n\t\t\tconst ctxTenant = ctxIds?.[ContextIdKeys.Tenant];\n\t\t\tpayloadTenantId = Is.stringValue(ctxTenant) ? ctxTenant : undefined;\n\t\t}\n\n\t\tconst payload: IPushDeliveryPayload = {\n\t\t\tconsumerPid,\n\t\t\tproviderPid: transferProcess.providerPid,\n\t\t\tgeneratorPid: transferProcess.providerPid,\n\t\t\tconsumerEndpoint: subscription.consumerEndpoint,\n\t\t\tconsumerAuthToken: subscription.consumerAuthToken,\n\t\t\tagreement,\n\t\t\tdata,\n\t\t\tentityType,\n\t\t\ttenantId: payloadTenantId,\n\t\t\tpushTimeoutMs: this._pushTimeoutMs,\n\t\t\tpushRetryCount: this._pushRetryCount,\n\t\t\tpushRetryBaseDelayMs: this._pushRetryBaseDelayMs\n\t\t};\n\n\t\tconst taskId = await this._backgroundTaskComponent.create<IPushDeliveryPayload>(\n\t\t\tDataspaceDataPlaneService.PUSH_DELIVERY_TASK_TYPE,\n\t\t\tpayload,\n\t\t\t{ retainFor: this._retainTasksFor, retryCount: this._retryCount }\n\t\t);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tmessage: \"pushDeliveryTaskScheduled\",\n\t\t\tdata: { taskId, consumerPid }\n\t\t});\n\t}\n\n\t// ============================================================================\n\t// PRIVATE HELPER METHODS\n\t// ============================================================================\n\n\t/**\n\t * Calculates the activity generator from the generator or actor fields.\n\t * @param activity The activity.\n\t * @returns The generator's identity.\n\t * @throws General Error if no identity is found.\n\t * @internal\n\t */\n\tprivate calculateActivityGeneratorIdentity(activity: IActivityStreamsActivity): string {\n\t\tif (Is.stringValue(activity.generator)) {\n\t\t\treturn activity.generator;\n\t\t}\n\n\t\tif (Is.object<IJsonLdNodeObject>(activity.generator) && Is.stringValue(activity.generator.id)) {\n\t\t\treturn activity.generator.id;\n\t\t}\n\n\t\tif (Is.stringValue(activity.actor)) {\n\t\t\treturn activity.actor;\n\t\t}\n\n\t\tif (Is.object<IJsonLdNodeObject>(activity.actor) && Is.stringValue(activity.actor.id)) {\n\t\t\treturn activity.actor.id;\n\t\t}\n\n\t\tthrow new GuardError(\n\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\"invalidActivityGeneratorIdentity\",\n\t\t\tnameof(activity.generator),\n\t\t\t{\n\t\t\t\tgenerator: activity.generator,\n\t\t\t\tactor: activity.actor\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Process activity task finalization.\n\t * @param taskId The Id of the Activity Log Entry.\n\t * @param status The final status of the task.\n\t * @param payload The execution payload of the task, required to correlate to the Activity Log Entry and update the processing status.\n\t * @internal\n\t */\n\tprivate async finaliseBackgroundTask(\n\t\ttaskId: string,\n\t\tstatus: TaskStatus,\n\t\tpayload?: IExecutionPayload\n\t): Promise<void> {\n\t\tif (Is.empty(payload)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (status === TaskStatus.Success || status === TaskStatus.Failed) {\n\t\t\tawait this.notifyTaskStatusChanged(\n\t\t\t\tpayload.activityLogEntryId,\n\t\t\t\tpayload.activity.id,\n\t\t\t\tpayload.dataspaceAppId,\n\t\t\t\ttaskId,\n\t\t\t\tstatus\n\t\t\t);\n\n\t\t\tawait this.finaliseActivityLogEntry(payload.activityLogEntryId);\n\t\t}\n\t}\n\n\t/**\n\t * Notify registered callbacks about a task status change.\n\t * @param activityLogEntryId The Id of the Activity Log Entry.\n\t * @param activityId The Id of the Activity.\n\t * @param dataspaceAppId The Id of the Dataspace App associated with the task.\n\t * @param taskId The Id of the task.\n\t * @param taskStatus The new status of the task.\n\t * @internal\n\t */\n\tprivate async notifyTaskStatusChanged(\n\t\tactivityLogEntryId: string,\n\t\tactivityId: string | undefined,\n\t\tdataspaceAppId: string,\n\t\ttaskId: string,\n\t\ttaskStatus: TaskStatus\n\t): Promise<void> {\n\t\tfor (const callback of Object.values(this._activityLogStatusCallbacks)) {\n\t\t\tawait callback({\n\t\t\t\tactivityLogEntryId,\n\t\t\t\tactivityId,\n\t\t\t\ttaskProcessingStatus: {\n\t\t\t\t\tdataspaceAppId,\n\t\t\t\t\ttaskId,\n\t\t\t\t\ttaskStatus\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Finalizes the Activity Log Entry by checking if all associated tasks have completed and, if so, updating the entry to be retained for the configured retention period.\n\t * @param activityLogEntryId The Id of the Activity Log Entry to finalize.\n\t * @returns The Activity Log Entry with updated retention details if applicable.\n\t * @internal\n\t */\n\tprivate async finaliseActivityLogEntry(activityLogEntryId: string): Promise<IActivityLogEntry> {\n\t\tconst entry = await this.getActivityLogEntry(activityLogEntryId);\n\t\tif (\n\t\t\tthis._retainActivityLogsFor !== -1 &&\n\t\t\t(entry.status === ActivityProcessingStatus.Completed ||\n\t\t\t\tentry.status === ActivityProcessingStatus.Error)\n\t\t) {\n\t\t\tconst retainUntil = Date.now() + this._retainActivityLogsFor;\n\t\t\tconst updatedEntry: ActivityLogDetails = {\n\t\t\t\tid: entry.id,\n\t\t\t\tactivityId: entry.activityId,\n\t\t\t\tgenerator: entry.generator,\n\t\t\t\tdateCreated: entry.dateCreated,\n\t\t\t\tdateModified: entry.dateModified,\n\t\t\t\tretainUntil\n\t\t\t};\n\t\t\tawait this._entityStorageActivityLogs.set(updatedEntry);\n\t\t}\n\n\t\treturn entry;\n\t}\n\n\t/**\n\t * Cleans up the activity log by deleting those entries that no longer shall be retained.\n\t * @internal\n\t */\n\tprivate async cleanupActivityLog(): Promise<void> {\n\t\tif (this._cleanUpProcessOngoing) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tmessage: \"cleanUpOngoing\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tthis._cleanUpProcessOngoing = true;\n\n\t\tlet numRecordsDeleted = 0;\n\n\t\tawait this._platformComponent.execute(async () => {\n\t\t\tnumRecordsDeleted += await this.cleanupActivityLogPartition();\n\t\t});\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tmessage: \"activityLogCleanedUp\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tdata: {\n\t\t\t\tnumRecordsDeleted\n\t\t\t}\n\t\t});\n\n\t\tthis._cleanUpProcessOngoing = false;\n\t}\n\n\t/**\n\t * Cleans up the activity log partition for the current context ids.\n\t * @returns The number of records deleted in this partition.\n\t * @internal\n\t */\n\tprivate async cleanupActivityLogPartition(): Promise<number> {\n\t\tlet numRecordsDeleted = 0;\n\n\t\ttry {\n\t\t\tlet cursor: string | undefined;\n\t\t\tconst now = Date.now();\n\n\t\t\tdo {\n\t\t\t\tconst result = await this._entityStorageActivityLogs.query({\n\t\t\t\t\tconditions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tproperty: \"retainUntil\",\n\t\t\t\t\t\t\tvalue: 0,\n\t\t\t\t\t\t\tcomparison: ComparisonOperator.GreaterThan\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tproperty: \"retainUntil\",\n\t\t\t\t\t\t\tvalue: now,\n\t\t\t\t\t\t\tcomparison: ComparisonOperator.LessThan\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tlogicalOperator: LogicalOperator.And\n\t\t\t\t});\n\t\t\t\tcursor = result.cursor;\n\n\t\t\t\tfor (const entity of result.entities) {\n\t\t\t\t\tconst logEntryDetails = await this.getActivityLogEntry(entity.id as string);\n\t\t\t\t\tif (\n\t\t\t\t\t\tlogEntryDetails.status === ActivityProcessingStatus.Completed ||\n\t\t\t\t\t\tlogEntryDetails.status === ActivityProcessingStatus.Error\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this._entityStorageActivityLogs.remove(entity.id as string);\n\t\t\t\t\t\tawait this._entityStorageActivityTasks.remove(entity.id as string);\n\t\t\t\t\t\tnumRecordsDeleted++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} while (Is.stringValue(cursor));\n\t\t} catch (error) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"cleanupFailed\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\terror: BaseError.fromError(error)\n\t\t\t});\n\t\t}\n\t\treturn numRecordsDeleted;\n\t}\n\n\t/**\n\t * Calculates the (Activity, Object, Target) query set.\n\t * @param activity The object representing the Activity.\n\t * @returns the (Activity, Object, Target) query set.\n\t * @internal\n\t */\n\tprivate async calculateActivityQuerySet(activity: IDataspaceActivity): Promise<IActivityQuery[]> {\n\t\tconst activityTypes = await JsonLdHelper.getType(activity);\n\t\tlet objectTypes: string[] = [];\n\n\t\tconst objects = ArrayHelper.fromObjectOrArray<IJsonLdNodeObject>(activity.object);\n\t\tfor (const object of objects) {\n\t\t\tobjectTypes = objectTypes.concat(await JsonLdHelper.getType(object));\n\t\t}\n\n\t\tlet targetTypes: string[] = [\"\"];\n\t\tif (Is.object<IJsonLdNodeObject>(activity.target)) {\n\t\t\ttargetTypes = await JsonLdHelper.getType(activity.target);\n\t\t}\n\n\t\tconst result: IActivityQuery[] = [];\n\n\t\tfor (const activityType of activityTypes) {\n\t\t\tfor (const objectType of objectTypes) {\n\t\t\t\tfor (const targetType of targetTypes) {\n\t\t\t\t\tconst query: IActivityQuery = {\n\t\t\t\t\t\tactivityType,\n\t\t\t\t\t\tobjectType,\n\t\t\t\t\t\ttargetType: !Is.stringValue(targetType) ? undefined : targetType\n\t\t\t\t\t};\n\n\t\t\t\t\tresult.push(query);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Resolve the push-subscription storage or throw if it isn't registered. Pull-only\n\t * deployments may run the data plane without it.\n\t * @returns The push-subscription storage connector.\n\t * @throws GeneralError if the storage isn't registered.\n\t * @internal\n\t */\n\tprivate requirePushSubscriptionStorage(): IEntityStorageConnector<PushSubscription> {\n\t\tconst storage = EntityStorageConnectorFactory.getIfExists<\n\t\t\tIEntityStorageConnector<PushSubscription>\n\t\t>(this._pushSubscriptionStorageType);\n\t\tif (!storage) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushSubscriptionStorageNotRegistered\"\n\t\t\t);\n\t\t}\n\t\treturn storage;\n\t}\n\n\t/**\n\t * Deletes PushSubscription entities whose TransferProcess is absent, COMPLETED, or TERMINATED.\n\t * On multi-tenant nodes (`partitionContextIds` includes `Tenant`), iterates each registered tenant\n\t * and runs the cleanup inside that tenant's context so partitioned storage queries scope correctly.\n\t * @internal\n\t */\n\tprivate async cleanupOrphanedPushSubscriptions(): Promise<void> {\n\t\t// Pull-only deployments may run the data plane without push-subscription storage —\n\t\t// the scheduled cleanup task fires regardless, so silent no-op is the right behaviour.\n\t\tconst storage = EntityStorageConnectorFactory.getIfExists<\n\t\t\tIEntityStorageConnector<PushSubscription>\n\t\t>(this._pushSubscriptionStorageType);\n\t\tif (!storage) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet numDeleted = 0;\n\n\t\tawait this._platformComponent.execute(async () => {\n\t\t\tnumDeleted += await this.cleanupOrphanedPushSubscriptionsPartition();\n\t\t});\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tmessage: \"pushSubscriptionsCleanedUp\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tdata: { numDeleted }\n\t\t});\n\t}\n\n\t/**\n\t * Per-partition cleanup body for orphaned PushSubscriptions.\n\t * @returns The number of subscriptions deleted in this partition.\n\t * @internal\n\t */\n\tprivate async cleanupOrphanedPushSubscriptionsPartition(): Promise<number> {\n\t\tlet numDeleted = 0;\n\n\t\ttry {\n\t\t\t// First pass: read all pages without modifying storage to avoid cursor drift\n\t\t\tconst toDelete: string[] = [];\n\t\t\tlet cursor: string | undefined;\n\t\t\tdo {\n\t\t\t\tconst result = await this.requirePushSubscriptionStorage().query(\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tcursor\n\t\t\t\t);\n\t\t\t\tcursor = result.cursor;\n\n\t\t\t\tconst pids = (result.entities as PushSubscription[]).map(s => s.consumerPid);\n\n\t\t\t\t// Skip the transfer-process query when the page is empty.\n\t\t\t\tif (pids.length > 0) {\n\t\t\t\t\tconst tpResult = await this._transferProcessStorage.query({\n\t\t\t\t\t\tproperty: \"consumerPid\",\n\t\t\t\t\t\tvalue: pids,\n\t\t\t\t\t\tcomparison: ComparisonOperator.In\n\t\t\t\t\t});\n\t\t\t\t\tconst tpMap = new Map(tpResult.entities.map(tp => [tp.consumerPid, tp.state]));\n\n\t\t\t\t\tfor (const sub of result.entities as PushSubscription[]) {\n\t\t\t\t\t\tconst state = tpMap.get(sub.consumerPid);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!state ||\n\t\t\t\t\t\t\tstate === DataspaceProtocolTransferProcessStateType.COMPLETED ||\n\t\t\t\t\t\t\tstate === DataspaceProtocolTransferProcessStateType.TERMINATED\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ttoDelete.push(sub.consumerPid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} while (Is.stringValue(cursor));\n\n\t\t\t// Second pass: delete after all reads are complete\n\t\t\tfor (const pid of toDelete) {\n\t\t\t\tawait this.teardownPushSubscription(pid);\n\t\t\t\tnumDeleted++;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"cleanupFailed\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\terror: BaseError.fromError(error)\n\t\t\t});\n\t\t}\n\n\t\treturn numDeleted;\n\t}\n\n\t/**\n\t * Calculates the cleaning task schedule.\n\t * @param minutes The period in minutes.\n\t * @returns The cleaning task schedule.\n\t * @internal\n\t */\n\tprivate calculateCleaningTaskSchedule(minutes: number): IScheduledTaskTime {\n\t\tlet minutesRemain = minutes;\n\n\t\tconst days = Math.floor(minutesRemain / DataspaceDataPlaneService._MINUTES_PER_DAY);\n\t\tminutesRemain %= DataspaceDataPlaneService._MINUTES_PER_DAY;\n\n\t\tconst hours = Math.floor(minutesRemain / 60);\n\t\tminutesRemain %= 60;\n\n\t\treturn { intervalDays: days, intervalHours: hours, intervalMinutes: minutesRemain };\n\t}\n\n\t/**\n\t * Returns an App for a (Activity, Object, Target).\n\t * @param activityQuery The (Activity, Object, Target) query specified using a FQN.\n\t * @returns The Dataspace Data Plane Apps or empty list if nothing is registered.\n\t * @internal\n\t */\n\tprivate getAppForActivityQuery(activityQuery: IActivityQuery): {\n\t\t[id: string]: {\n\t\t\tapp: IDataspaceApp;\n\t\t\tprocessingGroupId?: string;\n\t\t};\n\t} {\n\t\tconst matchingElements: {\n\t\t\t[id: string]: {\n\t\t\t\tapp: IDataspaceApp;\n\t\t\t\tprocessingGroupId?: string;\n\t\t\t};\n\t\t} = {};\n\t\tconst appNames = DataspaceAppFactory.names();\n\n\t\tfor (const appId of appNames) {\n\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appId);\n\t\t\tconst appQueries = app.activitiesHandled();\n\n\t\t\tfor (const appQuery of appQueries) {\n\t\t\t\tif (\n\t\t\t\t\tappQuery.objectType === activityQuery.objectType &&\n\t\t\t\t\t(Is.undefined(appQuery.activityType) ||\n\t\t\t\t\t\tappQuery.activityType === activityQuery.activityType) &&\n\t\t\t\t\t(Is.undefined(appQuery.targetType) || appQuery.targetType === activityQuery.targetType)\n\t\t\t\t) {\n\t\t\t\t\tmatchingElements[appId] = {\n\t\t\t\t\t\tapp,\n\t\t\t\t\t\tprocessingGroupId: appQuery.processingGroupId\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn matchingElements;\n\t}\n\n\t/**\n\t * Get a dataset by its ID. Resolves via the tenant-supplied dataspace app\n\t * datasets stored by the Control Plane.\n\t * @param datasetId The dataset identifier (@id)\n\t * @returns The dataset\n\t * @throws NotFoundError if no app handles this dataset\n\t * @internal\n\t */\n\tprivate async getDatasetFromApps(datasetId: string): Promise<IDataspaceProtocolDataset> {\n\t\tGuards.stringValue(DataspaceDataPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\n\t\tconst fromAppDataset = await this._dataspaceAppDatasetStorage.get(datasetId);\n\t\tif (!Is.empty(fromAppDataset)) {\n\t\t\treturn {\n\t\t\t\t...(fromAppDataset.dataset as unknown as IDataspaceProtocolDataset),\n\t\t\t\t\"@id\": datasetId\n\t\t\t};\n\t\t}\n\n\t\tthrow new NotFoundError(DataspaceDataPlaneService.CLASS_NAME, \"noAppRegistered\", datasetId, {\n\t\t\tdatasetId\n\t\t});\n\t}\n\n\t/**\n\t * Returns an App for a Data Asset query (datasetId, ...).\n\t * @param dataAssetQuery The data asset query.\n\t * @returns The Dataspace Data Plane App ID.\n\t * @internal\n\t */\n\tprivate async getAppForDataAssetQuery(dataAssetQuery: IDataAssetQuery): Promise<IDataspaceApp> {\n\t\tconst matchingElements: IDataspaceApp[] = [];\n\t\tconst matchingIds: string[] = [];\n\n\t\t// Storage primary key is the dataset's @id, so a single get() resolves it.\n\t\tconst fromAppDataset = await this._dataspaceAppDatasetStorage.get(dataAssetQuery.datasetId);\n\t\tif (!Is.empty(fromAppDataset)) {\n\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(fromAppDataset.appId);\n\t\t\tmatchingElements.push(app);\n\t\t\tmatchingIds.push(fromAppDataset.appId);\n\t\t}\n\n\t\tif (matchingElements.length > 1) {\n\t\t\tconst error = new ConflictError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"tooManyAppsRegistered\",\n\t\t\t\tdataAssetQuery.datasetId,\n\t\t\t\tmatchingIds,\n\t\t\t\t{\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t);\n\t\t\tawait this._logging?.log({\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"tooManyAppsRegistered\",\n\t\t\t\terror,\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!Is.arrayValue(matchingElements)) {\n\t\t\tconst error = new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"noAppRegistered\",\n\t\t\t\tdataAssetQuery.datasetId,\n\t\t\t\t{\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t);\n\t\t\tawait this._logging?.log({\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"noAppRegistered\",\n\t\t\t\terror,\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: dataAssetQuery.datasetId\n\t\t\t\t}\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn matchingElements[0];\n\t}\n\n\t/**\n\t * Prepare an activity for retry by updating metadata and returning apps to skip.\n\t * @param activityLogEntryId The activity log entry ID.\n\t * @param existingEntry The existing activity log entry with error status.\n\t * @returns Array of app IDs that already succeeded and should be skipped.\n\t * @internal\n\t */\n\tprivate async prepareForRetry(\n\t\tactivityLogEntryId: string,\n\t\texistingEntry: IActivityLogEntry\n\t): Promise<string[]> {\n\t\tconst appsToRetry =\n\t\t\texistingEntry.tasks\n\t\t\t\t?.filter(t => t.status === ActivityTaskStatus.Failed)\n\t\t\t\t.map(t => t.dataspaceAppId) ?? [];\n\n\t\tif (!Is.arrayValue(appsToRetry)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"noFailedTasksToRetry\",\n\t\t\t\tactivityLogEntryId\n\t\t\t);\n\t\t}\n\n\t\tconst successfulApps =\n\t\t\texistingEntry.tasks\n\t\t\t\t?.filter(t => t.status === ActivityTaskStatus.Success)\n\t\t\t\t.map(t => t.dataspaceAppId) ?? [];\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\tmessage: \"replacingFailedTasks\",\n\t\t\tdata: {\n\t\t\t\tactivityLogEntryId,\n\t\t\t\tappsToRetry,\n\t\t\t\tsuccessfulApps\n\t\t\t}\n\t\t});\n\n\t\tconst logEntry = await this._entityStorageActivityLogs.get(activityLogEntryId);\n\t\tif (logEntry) {\n\t\t\tlogEntry.dateModified = new Date().toISOString();\n\t\t\t// Extend retention to allow retry to complete\n\t\t\tif (this._retainActivityLogsFor !== -1) {\n\t\t\t\tlogEntry.retainUntil = Date.now() + this._retainActivityLogsFor;\n\t\t\t}\n\t\t\tawait this._entityStorageActivityLogs.set(logEntry);\n\t\t}\n\n\t\treturn successfulApps;\n\t}\n\n\t/**\n\t * Build transfer context from a TransferProcessEntity.\n\t * @param transferProcess The transfer process entity.\n\t * @returns The transfer context for use by data access methods.\n\t * @internal\n\t */\n\tprivate buildTransferContext(transferProcess: TransferProcess): ITransferContext {\n\t\t// Build the IDataspaceProtocolAgreement from stored data\n\t\t// The entity stores agreementId and policies separately\n\t\t//\n\t\t// NOTE: Currently policies are cached in the TransferProcessEntity at transfer start time.\n\t\t// Eventually, this should fetch fresh policies from Rights Management (PAP) using:\n\t\t// const freshAgreement = await this._policyAdministrationPoint.get(transferProcess.agreementId);\n\t\t// This would ensure policies are always up-to-date and support dynamic policy updates.\n\t\tconst agreement: IDataspaceProtocolAgreement = {\n\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\"@type\": OdrlTypes.Agreement,\n\t\t\t\"@id\": transferProcess.agreementId,\n\t\t\ttarget: transferProcess.datasetId,\n\t\t\t// Provider is the assigner, consumer is the assignee\n\t\t\tassigner: transferProcess.providerIdentity ?? \"\",\n\t\t\tassignee: transferProcess.consumerIdentity ?? \"\"\n\t\t};\n\n\t\t// Extract policies from the stored Agreement\n\t\t// Extract permission, prohibition, and obligation\n\t\tif (Is.arrayValue(transferProcess.policies)) {\n\t\t\tconst storedAgreement = transferProcess.policies[0] as\n\t\t\t\t| IDataspaceProtocolAgreement\n\t\t\t\t| undefined;\n\t\t\tif (storedAgreement) {\n\t\t\t\tagreement.permission = storedAgreement.permission;\n\t\t\t\tagreement.prohibition = storedAgreement.prohibition;\n\t\t\t\tagreement.obligation = storedAgreement.obligation;\n\t\t\t}\n\t\t}\n\n\t\tconst state = transferProcess.state;\n\t\tconst dataAddress = transferProcess.dataAddress;\n\n\t\treturn {\n\t\t\tconsumerPid: transferProcess.consumerPid,\n\t\t\tproviderPid: transferProcess.providerPid,\n\t\t\tagreement,\n\t\t\tdatasetId: transferProcess.datasetId,\n\t\t\tofferId: transferProcess.offerId,\n\t\t\tstate,\n\t\t\tconsumerIdentity: transferProcess.consumerIdentity,\n\t\t\tproviderIdentity: transferProcess.providerIdentity,\n\t\t\tdataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Apply ODRL policy enforcement to query results.\n\t * Delegates to the Policy Enforcement Point (PEP) which coordinates\n\t * PDP, arbiters, and enforcement processors.\n\t * @param result The data asset item list result to filter.\n\t * @param agreement The ODRL Agreement containing policies.\n\t * @returns The result with policies applied.\n\t * @internal\n\t */\n\tprivate async applyPolicyFilters(\n\t\tresult: IDataAssetItemListResult,\n\t\tagreement?: IDataspaceProtocolAgreement\n\t): Promise<IDataAssetItemListResult> {\n\t\tif (!agreement) {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst processed =\n\t\t\tawait this._policyEnforcementPoint.interceptWithPolicy<IDataAssetItemListResult>(\n\t\t\t\tagreement,\n\t\t\t\tresult\n\t\t\t);\n\n\t\tif (Is.arrayValue(agreement.obligation)) {\n\t\t\tawait this.logObligations(agreement.obligation, OdrlPolicyHelper.getUid(agreement) ?? \"\");\n\t\t}\n\n\t\treturn processed;\n\t}\n\n\t/**\n\t * Enforce the transfer's ODRL agreement on an inbound inbox activity via the PEP.\n\t * The PEP evaluates the agreement against the activity and either denies it or\n\t * permits it — potentially manipulating (filtering/redacting) the payload — and\n\t * the returned activity is what gets dispatched. The action is derived from the\n\t * transfer direction: provider-generated activities are read deliveries, while\n\t * consumer-generated activities are write contributions whose Activity Streams\n\t * verb maps to its ODRL action. A denied activity comes back empty. Skipped when\n\t * no PEP is wired or the agreement carries no rules, matching the read/push\n\t * lenience for agreements negotiated before this gate existed.\n\t * @param transferProcess The transfer the activity targets.\n\t * @param activity The inbound activity.\n\t * @param generatorIsConsumer True when the generator is the consumer side\n\t * (a write contribution); false when it is the provider side (a read delivery).\n\t * @returns The activity with policy applied, for dispatch.\n\t * @internal\n\t */\n\tprivate async enforceInboxPolicy(\n\t\ttransferProcess: TransferProcess,\n\t\tactivity: IActivityStreamsActivity,\n\t\tgeneratorIsConsumer: boolean\n\t): Promise<IActivityStreamsActivity> {\n\t\tconst { agreement, consumerPid } = this.buildTransferContext(transferProcess);\n\t\tconst hasRules =\n\t\t\tIs.arrayValue(agreement.permission) ||\n\t\t\tIs.arrayValue(agreement.prohibition) ||\n\t\t\tIs.arrayValue(agreement.obligation);\n\t\tif (!hasRules) {\n\t\t\treturn activity;\n\t\t}\n\n\t\tconst agreementId = OdrlPolicyHelper.getUid(agreement);\n\t\tconst action = this.deriveInboxAction(activity, generatorIsConsumer);\n\t\tconst processed = await this._policyEnforcementPoint.interceptWithPolicy<\n\t\t\tIActivityStreamsActivity,\n\t\t\tIActivityStreamsActivity\n\t\t>(agreement, activity, action);\n\n\t\t// The enforcement processor returns the (possibly manipulated) activity when\n\t\t// the action is permitted, and an empty object when it is denied.\n\t\tif (!Is.objectValue<IActivityStreamsActivity>(processed)) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\"pushActivityNotPermittedByPolicy\",\n\t\t\t\t{ agreementId, consumerPid }\n\t\t\t);\n\t\t}\n\n\t\tif (Is.arrayValue(agreement.obligation)) {\n\t\t\tawait this.logObligations(agreement.obligation, agreementId ?? \"\");\n\t\t}\n\n\t\treturn processed;\n\t}\n\n\t/**\n\t * Derive the ODRL action to enforce for an inbound activity from the transfer\n\t * direction and the Activity Streams verb. Provider-generated activities are read\n\t * deliveries; consumer-generated activities are write contributions whose verb\n\t * maps to the corresponding ODRL action.\n\t * @param activity The inbound activity.\n\t * @param generatorIsConsumer True when the generator is the consumer side.\n\t * @returns The ODRL action to evaluate.\n\t * @internal\n\t */\n\tprivate deriveInboxAction(\n\t\tactivity: IActivityStreamsActivity,\n\t\tgeneratorIsConsumer: boolean\n\t): OdrlActionType | string {\n\t\tif (!generatorIsConsumer) {\n\t\t\treturn OdrlActionType.Read;\n\t\t}\n\n\t\tconst verb = Is.arrayValue(activity.type) ? activity.type[0] : activity.type;\n\t\tif (verb === ActivityStreamsTypes.Update) {\n\t\t\treturn OdrlActionType.Modify;\n\t\t}\n\t\tif (verb === ActivityStreamsTypes.Delete || verb === ActivityStreamsTypes.Remove) {\n\t\t\treturn OdrlActionType.Delete;\n\t\t}\n\t\t// Create, Add and any other contribution verb map to write.\n\t\treturn OdrlActionType.Write;\n\t}\n\n\t/**\n\t * Log ODRL obligations for auditing purposes.\n\t * Obligations are duties that must be fulfilled as part of the agreement.\n\t * @param obligations The obligation rules from the Agreement.\n\t * @param agreementId The agreement ID for reference.\n\t * @internal\n\t */\n\tprivate async logObligations(\n\t\tobligations: IDataspaceProtocolAgreement[\"obligation\"],\n\t\tagreementId: string\n\t): Promise<void> {\n\t\tif (!Is.arrayValue(obligations)) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const obligation of obligations) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"policyObligationTriggered\",\n\t\t\t\tdata: {\n\t\t\t\t\tagreementId,\n\t\t\t\t\taction: obligation.action,\n\t\t\t\t\ttarget: obligation.target,\n\t\t\t\t\tassignee: obligation.assignee\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Processes a task for an activity, by creating a background task and registering the handler.\n\t * @param activityLogEntryId The ID of the activity log entry.\n\t * @param activity The activity to be processed.\n\t * @param handlerApps The handler applications for the activity.\n\t * @param dataspaceAppId The ID of the handler application.\n\t * @param taskEntries The list of activity log entries.\n\t * @param isRetry Indicates if this is a retry of a previous task.\n\t * @returns True if the task was processed inline.\n\t * @internal\n\t */\n\tprivate async processTask(\n\t\tactivityLogEntryId: string,\n\t\tactivity: IActivityStreamsActivity,\n\t\thandlerApps: { [id: string]: { app: IDataspaceApp; processingGroupId?: string } },\n\t\tdataspaceAppId: string,\n\t\ttaskEntries: IActivityTaskEntry[],\n\t\tisRetry: boolean\n\t): Promise<boolean> {\n\t\tconst handlerApp = handlerApps[dataspaceAppId].app;\n\t\tconst processingGroupId = handlerApps[dataspaceAppId].processingGroupId;\n\n\t\tconst payload: IExecutionPayload = {\n\t\t\tactivityLogEntryId,\n\t\t\tactivity: activity as IDataspaceActivity,\n\t\t\tdataspaceAppId\n\t\t};\n\n\t\t// If there is no processing group we execute the task inline without creating a background task\n\t\tconst isInlineTask = !Is.stringValue(processingGroupId);\n\t\tif (isInlineTask) {\n\t\t\tconst handleActivity = handlerApp?.handleActivity?.bind(handlerApp);\n\t\t\tif (!Is.function(handleActivity)) {\n\t\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"missingHandleActivity\", {\n\t\t\t\t\tdataspaceAppId\n\t\t\t\t});\n\t\t\t}\n\t\t\tlet taskError;\n\t\t\tlet taskResult;\n\t\t\ttry {\n\t\t\t\ttaskResult = await handleActivity(activity as IDataspaceActivity);\n\t\t\t} catch (error) {\n\t\t\t\tconst baseErr = BaseError.fromError(error);\n\t\t\t\tconst isSemanticError =\n\t\t\t\t\tBaseError.someErrorName(baseErr, ValidationError.CLASS_NAME) ||\n\t\t\t\t\tBaseError.someErrorName(baseErr, GuardError.CLASS_NAME);\n\t\t\t\ttaskError = isSemanticError\n\t\t\t\t\t? new UnprocessableError(\n\t\t\t\t\t\t\tDataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\t\"activitySemanticError\",\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tbaseErr\n\t\t\t\t\t\t)\n\t\t\t\t\t: baseErr;\n\t\t\t}\n\n\t\t\tconst now = Date.now();\n\t\t\tconst taskEntry: IActivityTaskEntry = {\n\t\t\t\ttaskId: RandomHelper.generateUuidV7(\"compact\"),\n\t\t\t\tdataspaceAppId,\n\t\t\t\tprocessingGroupId,\n\t\t\t\tresult: taskResult,\n\t\t\t\tstartDate: new Date(now).toISOString(),\n\t\t\t\tendDate: new Date(now).toISOString(),\n\t\t\t\tstatus: Is.empty(taskError) ? ActivityTaskStatus.Success : ActivityTaskStatus.Failed,\n\t\t\t\terror: taskError?.toJsonObject()\n\t\t\t};\n\t\t\ttaskEntries.push(taskEntry);\n\n\t\t\tawait this.notifyTaskStatusChanged(\n\t\t\t\tpayload.activityLogEntryId,\n\t\t\t\tpayload.activity.id,\n\t\t\t\tpayload.dataspaceAppId,\n\t\t\t\ttaskEntry.taskId,\n\t\t\t\ttaskEntry.status\n\t\t\t);\n\t\t} else {\n\t\t\tconst processingGroups = handlerApp.processingGroups?.() ?? {};\n\t\t\tif (Is.empty(processingGroups[processingGroupId])) {\n\t\t\t\tthrow new GeneralError(DataspaceDataPlaneService.CLASS_NAME, \"invalidProcessingGroupId\", {\n\t\t\t\t\tprocessingGroupId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst processingGroupOptions = processingGroups[processingGroupId];\n\n\t\t\tconst taskType = `${dataspaceAppId}${processingGroupId ? `-${processingGroupId}` : \"\"}`;\n\n\t\t\tconst taskId = await this._backgroundTaskComponent.create<IExecutionPayload>(\n\t\t\t\ttaskType,\n\t\t\t\tpayload,\n\t\t\t\t{\n\t\t\t\t\tretainFor: this._retainTasksFor,\n\t\t\t\t\tretryCount: processingGroupOptions?.retryCount ?? this._retryCount\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (!this._registeredTaskTypes.includes(taskType)) {\n\t\t\t\tthis._registeredTaskTypes.push(taskType);\n\n\t\t\t\tawait this._backgroundTaskComponent.registerHandler<IExecutionPayload, unknown>(\n\t\t\t\t\ttaskType,\n\t\t\t\t\t\"@twin.org/dataspace-app-runner\",\n\t\t\t\t\t\"appRunner\",\n\t\t\t\t\tasync task => {\n\t\t\t\t\t\tawait this.finaliseBackgroundTask(task.id, task.status, task.payload);\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tmaxWorkerCount: processingGroupOptions?.concurrentTasks,\n\t\t\t\t\t\tidleShutdownTimeout: processingGroupOptions?.idleShutdownTimeout,\n\t\t\t\t\t\tinitialiseMethod: \"appRunnerStart\",\n\t\t\t\t\t\tshutdownMethod: \"appRunnerEnd\"\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\ttaskEntries.push({\n\t\t\t\ttaskId,\n\t\t\t\tdataspaceAppId,\n\t\t\t\tprocessingGroupId,\n\t\t\t\tstatus: ActivityTaskStatus.Pending\n\t\t\t});\n\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceDataPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"scheduledTask\",\n\t\t\t\tdata: {\n\t\t\t\t\ttaskId,\n\t\t\t\t\tdataspaceAppId,\n\t\t\t\t\tisRetry\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn isInlineTask;\n\t}\n\n\t/**\n\t * Constructs the activity log entry with processing status and associated tasks.\n\t * @param activityLog The activity log details retrieved from storage.\n\t * @param activityTasks The activity tasks associated with the log entry, if any.\n\t * @returns The complete activity log entry with status and tasks.\n\t * @internal\n\t */\n\tprivate async constructLogEntry(\n\t\tactivityLog: ActivityLogDetails,\n\t\tactivityTasks: ActivityTask | undefined\n\t): Promise<IActivityLogEntry> {\n\t\tlet tasks: IActivityTaskEntry[] | undefined;\n\n\t\t// For calculating the processing status. `Registering` if we cannot determine the activity tasks yet\n\t\tlet status: ActivityProcessingStatus = ActivityProcessingStatus.Registering;\n\n\t\t// Now query the associated tasks\n\t\t// If activity tasks is undefined it is because the corresponding store has not been persisted yet\n\t\tif (!Is.undefined(activityTasks)) {\n\t\t\ttasks = [];\n\n\t\t\tconst typeCount: {\n\t\t\t\t[status in TaskStatus]: number;\n\t\t\t} = {\n\t\t\t\t[TaskStatus.Pending]: 0,\n\t\t\t\t[TaskStatus.Processing]: 0,\n\t\t\t\t[TaskStatus.Success]: 0,\n\t\t\t\t[TaskStatus.Failed]: 0,\n\t\t\t\t[TaskStatus.Cancelled]: 0\n\t\t\t};\n\n\t\t\tfor (const entity of activityTasks.associatedTasks) {\n\t\t\t\tlet entry: IActivityTaskEntry | undefined;\n\t\t\t\tif (!Is.stringValue(entity.processingGroupId)) {\n\t\t\t\t\t// If there is no process group, the task was processed inline so the task status is already available in the entity\n\t\t\t\t\ttypeCount[entity.status]++;\n\t\t\t\t\tentry = entity;\n\t\t\t\t} else {\n\t\t\t\t\tconst taskDetails = await this._backgroundTaskComponent.get<IExecutionPayload, unknown>(\n\t\t\t\t\t\tentity.taskId\n\t\t\t\t\t);\n\t\t\t\t\tif (!Is.empty(taskDetails)) {\n\t\t\t\t\t\ttypeCount[taskDetails.status]++;\n\n\t\t\t\t\t\tswitch (taskDetails.status) {\n\t\t\t\t\t\t\tcase TaskStatus.Success:\n\t\t\t\t\t\t\t\tentry = {\n\t\t\t\t\t\t\t\t\t...entity,\n\t\t\t\t\t\t\t\t\tstatus: ActivityTaskStatus.Success,\n\t\t\t\t\t\t\t\t\tresult: taskDetails.result,\n\t\t\t\t\t\t\t\t\tstartDate: taskDetails?.dateCreated,\n\t\t\t\t\t\t\t\t\tendDate: taskDetails?.dateCompleted\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Pending:\n\t\t\t\t\t\t\t\tentry = { ...entity, status: ActivityTaskStatus.Pending };\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Processing:\n\t\t\t\t\t\t\t\tentry = {\n\t\t\t\t\t\t\t\t\t...entity,\n\t\t\t\t\t\t\t\t\tstatus: ActivityTaskStatus.Processing,\n\t\t\t\t\t\t\t\t\tstartDate: taskDetails.dateCreated\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Failed:\n\t\t\t\t\t\t\t\tentry = {\n\t\t\t\t\t\t\t\t\t...entity,\n\t\t\t\t\t\t\t\t\tstatus: ActivityTaskStatus.Failed,\n\t\t\t\t\t\t\t\t\terror: taskDetails.error\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase TaskStatus.Cancelled:\n\t\t\t\t\t\t\t\t// Nothing to do for cancelled tasks\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!Is.empty(entry)) {\n\t\t\t\t\ttasks.push(entry);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeCount[TaskStatus.Failed] > 0) {\n\t\t\t\tstatus = ActivityProcessingStatus.Error;\n\t\t\t} else if (typeCount[TaskStatus.Processing] > 0) {\n\t\t\t\tstatus = ActivityProcessingStatus.Running;\n\t\t\t} else if (typeCount[TaskStatus.Pending] > 0) {\n\t\t\t\tstatus = ActivityProcessingStatus.Pending;\n\t\t\t} else {\n\t\t\t\tstatus = ActivityProcessingStatus.Completed;\n\t\t\t}\n\t\t}\n\t\treturn { ...activityLog, status, tasks };\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDataspaceDataPlaneServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IDataspaceDataPlaneServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IDataspaceDataPlaneServiceConfig } from \"./IDataspaceDataPlaneServiceConfig.js\";\n\n/**\n * Dataspace Data Plane service options\n */\nexport interface IDataspaceDataPlaneServiceConstructorOptions {\n\t/**\n\t * Logging component type.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * Background task component.\n\t * @default background-task\n\t */\n\tbackgroundTaskComponentType?: string;\n\n\t/**\n\t * Task Scheduler Component Type.\n\t * @default task-scheduler\n\t */\n\ttaskSchedulerComponentType?: string;\n\n\t/**\n\t * The entity storage for activity log details.\n\t * @default activity-log-details\n\t */\n\tactivityLogEntityStorageType?: string;\n\n\t/**\n\t * The entity storage for the association between Activities and Tasks.\n\t * @default activity-task\n\t */\n\tactivityTaskEntityStorageType?: string;\n\n\t/**\n\t * The entity storage type for Transfer Process entities.\n\t * Used to read Transfer Process state from shared storage.\n\t * @default transfer-process\n\t */\n\ttransferProcessEntityStorageType?: string;\n\n\t/**\n\t * The entity storage type for PushSubscription entities.\n\t * @default push-subscription\n\t */\n\tpushSubscriptionEntityStorageType?: string;\n\n\t/**\n\t * The entity storage type for Dataspace App Dataset entities.\n\t * @default dataspace-app-dataset\n\t */\n\tdataspaceAppDatasetEntityStorageType?: string;\n\n\t/**\n\t * The keys to use from the context ids to cleanup partitions.\n\t */\n\tpartitionContextIds?: string[];\n\n\t/**\n\t * Trust component type.\n\t * @default trust\n\t */\n\ttrustComponentType?: string;\n\n\t/**\n\t * Policy enforcement point component type for ODRL policy enforcement.\n\t * @default policy-enforcement-point-service\n\t */\n\tpepComponentType?: string;\n\n\t/**\n\t * Tenant component type.\n\t * @default tenant\n\t */\n\ttenantComponentType?: string;\n\n\t/**\n\t * URL Transformer component type used to encrypt the tenant token into the data-plane.\n\t * @default url-transformer\n\t */\n\turlTransformerComponentType?: string;\n\n\t/**\n\t * The configuration of the Dataspace Data Plane Service.\n\t */\n\tconfig?: IDataspaceDataPlaneServiceConfig;\n}\n"]}
1
+ {"version":3,"file":"IDataspaceDataPlaneServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IDataspaceDataPlaneServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IDataspaceDataPlaneServiceConfig } from \"./IDataspaceDataPlaneServiceConfig.js\";\n\n/**\n * Dataspace Data Plane service options\n */\nexport interface IDataspaceDataPlaneServiceConstructorOptions {\n\t/**\n\t * Logging component type.\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * Background task component.\n\t * @default background-task\n\t */\n\tbackgroundTaskComponentType?: string;\n\n\t/**\n\t * Task Scheduler Component Type.\n\t * @default task-scheduler\n\t */\n\ttaskSchedulerComponentType?: string;\n\n\t/**\n\t * The entity storage for activity log details.\n\t * @default activity-log-details\n\t */\n\tactivityLogEntityStorageType?: string;\n\n\t/**\n\t * The entity storage for the association between Activities and Tasks.\n\t * @default activity-task\n\t */\n\tactivityTaskEntityStorageType?: string;\n\n\t/**\n\t * The entity storage type for Transfer Process entities.\n\t * Used to read Transfer Process state from shared storage.\n\t * @default transfer-process\n\t */\n\ttransferProcessEntityStorageType?: string;\n\n\t/**\n\t * The entity storage type for PushSubscription entities.\n\t * @default push-subscription\n\t */\n\tpushSubscriptionEntityStorageType?: string;\n\n\t/**\n\t * The entity storage type for Dataspace App Dataset entities.\n\t * @default dataspace-app-dataset\n\t */\n\tdataspaceAppDatasetEntityStorageType?: string;\n\n\t/**\n\t * Trust component type.\n\t * @default trust\n\t */\n\ttrustComponentType?: string;\n\n\t/**\n\t * Policy enforcement point component type for ODRL policy enforcement.\n\t * @default policy-enforcement-point-service\n\t */\n\tpepComponentType?: string;\n\n\t/**\n\t * Platform component type.\n\t * @default platform\n\t */\n\tplatformComponentType?: string;\n\n\t/**\n\t * The configuration of the Dataspace Data Plane Service.\n\t */\n\tconfig?: IDataspaceDataPlaneServiceConfig;\n}\n"]}
@@ -32,7 +32,7 @@ export declare class DataspaceDataPlaneService implements IDataspaceDataPlaneCom
32
32
  /**
33
33
  * Notify an Activity.
34
34
  * @param activity The Activity notified.
35
- * @param trustPayload Optional trust payload to verify the requester's identity.
35
+ * @param trustPayload Trust payload to verify the requesters identity.
36
36
  * @returns The activity's id or entry.
37
37
  */
38
38
  notifyActivity(activity: IActivityStreamsActivity, trustPayload?: unknown): Promise<string | IActivityLogEntry>;
@@ -5,7 +5,6 @@ import type { IDataspaceDataPlaneServiceConfig } from "./IDataspaceDataPlaneServ
5
5
  export interface IDataspaceDataPlaneServiceConstructorOptions {
6
6
  /**
7
7
  * Logging component type.
8
- * @default logging
9
8
  */
10
9
  loggingComponentType?: string;
11
10
  /**
@@ -44,10 +43,6 @@ export interface IDataspaceDataPlaneServiceConstructorOptions {
44
43
  * @default dataspace-app-dataset
45
44
  */
46
45
  dataspaceAppDatasetEntityStorageType?: string;
47
- /**
48
- * The keys to use from the context ids to cleanup partitions.
49
- */
50
- partitionContextIds?: string[];
51
46
  /**
52
47
  * Trust component type.
53
48
  * @default trust
@@ -59,15 +54,10 @@ export interface IDataspaceDataPlaneServiceConstructorOptions {
59
54
  */
60
55
  pepComponentType?: string;
61
56
  /**
62
- * Tenant component type.
63
- * @default tenant
64
- */
65
- tenantComponentType?: string;
66
- /**
67
- * URL Transformer component type used to encrypt the tenant token into the data-plane.
68
- * @default url-transformer
57
+ * Platform component type.
58
+ * @default platform
69
59
  */
70
- urlTransformerComponentType?: string;
60
+ platformComponentType?: string;
71
61
  /**
72
62
  * The configuration of the Dataspace Data Plane Service.
73
63
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.44](https://github.com/iotaledger/twin-dataspace/compare/dataspace-data-plane-service-v0.0.3-next.43...dataspace-data-plane-service-v0.0.3-next.44) (2026-06-12)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * always verify trust in notifyActivity, no internal by ([#192](https://github.com/iotaledger/twin-dataspace/issues/192)) ([2cfc160](https://github.com/iotaledger/twin-dataspace/commit/2cfc16082a7c9d417f0b05f90f123e40f47d1e05))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/dataspace-app-runner bumped from 0.0.3-next.43 to 0.0.3-next.44
16
+ * @twin.org/dataspace-models bumped from 0.0.3-next.43 to 0.0.3-next.44
17
+ * devDependencies
18
+ * @twin.org/dataspace-test-app bumped from 0.0.3-next.43 to 0.0.3-next.44
19
+
20
+ ## [0.0.3-next.43](https://github.com/iotaledger/twin-dataspace/compare/dataspace-data-plane-service-v0.0.3-next.42...dataspace-data-plane-service-v0.0.3-next.43) (2026-06-11)
21
+
22
+
23
+ ### Features
24
+
25
+ * organization identifiers ([#188](https://github.com/iotaledger/twin-dataspace/issues/188)) ([af643d3](https://github.com/iotaledger/twin-dataspace/commit/af643d3bb7f212d6cbb672e362a9e1bbe886d1a5))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @twin.org/dataspace-app-runner bumped from 0.0.3-next.42 to 0.0.3-next.43
33
+ * @twin.org/dataspace-models bumped from 0.0.3-next.42 to 0.0.3-next.43
34
+ * devDependencies
35
+ * @twin.org/dataspace-test-app bumped from 0.0.3-next.42 to 0.0.3-next.43
36
+
3
37
  ## [0.0.3-next.42](https://github.com/iotaledger/twin-dataspace/compare/dataspace-data-plane-service-v0.0.3-next.41...dataspace-data-plane-service-v0.0.3-next.42) (2026-06-10)
4
38
 
5
39
 
@@ -104,7 +104,7 @@ The Activity notified.
104
104
 
105
105
  `unknown`
106
106
 
107
- Optional trust payload to verify the requester's identity.
107
+ Trust payload to verify the requesters identity.
108
108
 
109
109
  #### Returns
110
110
 
@@ -10,12 +10,6 @@ Dataspace Data Plane service options
10
10
 
11
11
  Logging component type.
12
12
 
13
- #### Default
14
-
15
- ```ts
16
- logging
17
- ```
18
-
19
13
  ***
20
14
 
21
15
  ### backgroundTaskComponentType? {#backgroundtaskcomponenttype}
@@ -117,14 +111,6 @@ dataspace-app-dataset
117
111
 
118
112
  ***
119
113
 
120
- ### partitionContextIds? {#partitioncontextids}
121
-
122
- > `optional` **partitionContextIds?**: `string`[]
123
-
124
- The keys to use from the context ids to cleanup partitions.
125
-
126
- ***
127
-
128
114
  ### trustComponentType? {#trustcomponenttype}
129
115
 
130
116
  > `optional` **trustComponentType?**: `string`
@@ -153,30 +139,16 @@ policy-enforcement-point-service
153
139
 
154
140
  ***
155
141
 
156
- ### tenantComponentType? {#tenantcomponenttype}
157
-
158
- > `optional` **tenantComponentType?**: `string`
159
-
160
- Tenant component type.
161
-
162
- #### Default
163
-
164
- ```ts
165
- tenant
166
- ```
167
-
168
- ***
169
-
170
- ### urlTransformerComponentType? {#urltransformercomponenttype}
142
+ ### platformComponentType? {#platformcomponenttype}
171
143
 
172
- > `optional` **urlTransformerComponentType?**: `string`
144
+ > `optional` **platformComponentType?**: `string`
173
145
 
174
- URL Transformer component type used to encrypt the tenant token into the data-plane.
146
+ Platform component type.
175
147
 
176
148
  #### Default
177
149
 
178
150
  ```ts
179
- url-transformer
151
+ platform
180
152
  ```
181
153
 
182
154
  ***
package/locales/en.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "transferNotInStartedState": "Transfer Process is not in STARTED state. Current state: \"{currentState}\"",
15
15
  "transferMissingDatasetId": "Transfer Process is missing datasetId",
16
16
  "transferMissingDataAddress": "Transfer Process is missing a valid push dataAddress endpoint (consumerPid: {consumerPid})",
17
- "pushSubscriptionMissingTenantToken": "Push subscription setup rejected: consumer endpoint does not carry an `x-enc-tenant-token` query parameter (consumerPid: {consumerPid}, endpoint: {endpoint}). On multi-tenant publishers the consumer must bake its tenant token before sending the dataAddress.",
17
+ "pushSubscriptionMissingOrganizationId": "Push subscription setup rejected: consumer endpoint does not carry an `organization` query parameter (consumerPid: {consumerPid}, endpoint: {endpoint}). On multi-tenant publishers the consumer must bake its organization ID before sending the dataAddress.",
18
18
  "pushSubscriptionStorageNotRegistered": "Push-mode transfer requires push-subscription storage to be registered (entity-storage key: \"push-subscription\"). This deployment was configured without it — register the storage to enable push, or use pull-mode transfers only.",
19
19
  "schemaNotFound": "Schema \"{schemaId}\" not found",
20
20
  "cleanupFailed": "Error occurred during cleanup of activity logs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/dataspace-data-plane-service",
3
- "version": "0.0.3-next.42",
3
+ "version": "0.0.3-next.44",
4
4
  "description": "Processes activities and data requests while enforcing transfer and policy constraints in the data plane.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "@twin.org/crypto": "next",
22
22
  "@twin.org/data-core": "next",
23
23
  "@twin.org/data-json-ld": "next",
24
- "@twin.org/dataspace-app-runner": "0.0.3-next.42",
25
- "@twin.org/dataspace-models": "0.0.3-next.42",
24
+ "@twin.org/dataspace-app-runner": "0.0.3-next.44",
25
+ "@twin.org/dataspace-models": "0.0.3-next.44",
26
26
  "@twin.org/engine-models": "next",
27
27
  "@twin.org/entity": "next",
28
28
  "@twin.org/entity-storage-models": "next",