Open pvoznyuk opened 2 weeks ago
This is an interesting proposal. Someone in my firm raised this same issue to me last year e.g. whether there are standard mechanisms in FDC3 to handle this type of requirement. I've also had similar discussions more recently relating to translation not so much between two different standard identifiers, but between standard and internal/proprietary identifiers. Just to open up the just discussion a bit, here's a few thoughts I had when reading the above:
fdc3.broadcast()
, but to everything responsible for outbound context e.g. fdc3.raiseIntent()
, and fdc3.raiseIntentForContext()
as well?fdc3.broadcast()
, fdc3.raiseIntent()
, fdc3.raiseIntentForContext()
, fdc3.addContextListener()
and fdc3.addIntentListener()
, there's also the issue of IntentResult
i.e. results that an intent handler can return to communicate back to the app that raised the intent (which can also be contexts, and therefore potentially also in scope for transform).type
property could potentially be updated by a function provided to the middleware (which is technically possible in the example above) then this is a whole different thing.broadcasts
or raises
or listensFor
an fdc3.something
context but the middleware caused it to actually send/receive an fdc3.somethingElse
context instead, this would change many assumptions apps routinely make about other apps in their platform/ecosystem.type
property on the fly (as opposed to simply enriching context) as this would be a far bigger change with significant implications to the way FDC3 works e.g. could you still use fdc3.findIntent()
or fdc3.findIntentsByContext()
to reliably look up apps and app instances that are registered to handle a particular context, if you have scenarios where context types could change between source app and target app? There are related implications for Intent Resolvers e.g. when a target app is not specified.getAgent()
invocation (with the contextTransform
quite likely coming from a shared npm package consumed by multiple apps) I think I can see why you're suggesting that transform should be controlled in the DA proxy at app-level. Prior to FDC3 v2.2, such transform would more likely have entailed configuring centrally at DA-level i.e. inside the vendor DA, rather than in a proxy running at app-level. Which of course would be a vendor DA implementation issue (and not covered by the FDC3 specification because it does not mandate things around DA configuration / bootstrapping). But with the advent of FDC3 2.2, configuring and performing the transform at DA-level would have negative implications for how agnostic your app could be to different DA vendors and different DA configurations. For example, at runtime any app using the getAgent()
method might use a DA with expected middleware, but could end up using a DA with unexpected middleware or no middleware. (However, it's worth noting that extending the DA proxy to support for middleware does not prevent any DA vendor providing transform functionality that runs inside their hub/broker. If they wished, an app vendor could configure the DA proxies used by their apps to use no middleware at all, and then utilize a DA vendor's transform functionality if available - and if the app vendor did not care about making their apps DA-agnostic.)getAgent()
level? Should it also be possible to provide sub-agent-specific middleware to a sub-agent at creation time, or does it not make sense to allow this?contextTransform
succeeding for the cross-app workflow to operate properly (if they were not dependent on this why would they even use it?) then this sounds like it needs an addition to multiple different error enums (exactly which enums requires being more specific about the scope of where the middleware would apply e.g. some of the questions raised above). Actually it would likely be multiple additions to the enums, because there could be multiple error conditions e.g. the contextTransform
could throw an exception, or it could just timeout, so it would probably make sense to have something like ContextTransformFailed
and ContextTransformTimeout
at a minimum.[1] Just to be more specific about one of the suggestions above on guardrails and changing the concept of the transform function to instead emit just the additional properties, what I was getting at was something along the lines of:
Original context (pre-middleware execution):
{
type: "fdc3.instrument",
id: {
cusip: "594918104"
}
}
Additional properties (return value from enrichment function provided to middleware executor):
{
id: {
isin: "US5949181045"
}
}
Enriched Context (post-middleware execution):
{
type: "fdc3.instrument",
id: {
cusip: "594918104",
isin: "US5949181045"
}
}
But given that you could not prevent the enrichment function from returning an object also containing existing properties, the deep merge would have to ensure it only added new properties and did not update existing property values. On this basis, the enrichment function would effectively be free to return an extended context (containing both existing and new properties) which would likely be easier to author. But the key point is that the middleware handler would not simply use the value returned from the enrichment function as-is, it would apply this very specific (guarded) deep merge.
Of course, there are downsides to the above approach - hence I think that if there was an intention to make the proposal support guardrails, a number of different approaches and patterns would need to be put on the table, evaluated, and discussed.
Enhancement Request
Use Case:
Suppose there is an existing ecosystem of applications that communicate with each other via
DesktopAgent
. The context for thefdc3.instrument
type includes theid.ISIN
property. One day, a third-party application is to be integrated into the ecosystem and communicate with the existing applications viaDesktopAgent
.The problem is that this application doesn’t support
id.ISIN
but instead supportsid.FIGI
.Refactoring all existing applications to add
id.FIGI
to every context broadcast is expensive, so it would be helpful if the contexts could be converted automatically according to defined rules.Workflow Description
Context Translation Middleware: Middleware within DesktopAgent that automatically converts contexts based on defined rules (e.g., context type) during broadcasting.
Error Handling: If there are any cases where the translation is not feasible,
DesktopAgent
should handle this so developers can log the situation and alert the administrators. This ensures visibility for unsupported context translations and reduces potential issues during runtime.Workflow Examples