[DACP] Define the context/metadata invariant in getCurrentContextResponse
- Dominant language
- TypeScript
- Stars
- 270
- Forks
- 193
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 36
Description
## Problem
The DACP [`GetCurrentContextSuccessResponsePayload`](https://github.com/finos/FDC3/blob/main/packages/fdc3-schema/schemas/api/getCurrentContextResponse.schema.json) requires `context`, but permits `metadata` to be omitted or set to `null` even when a non-null context is returned.
The same `getCurrentContextRequest` and `getCurrentContextResponse` exchange is used to implement both:
```ts
channel.getCurrentContext(contextType?)
channel.getCurrentContextWithMetadata(contextType?)
```
The request does not identify which public method initiated it. Therefore, the Desktop Agent cannot know that it is safe to omit metadata for a particular request. To support `getCurrentContextWithMetadata()`, it must provide the associated metadata whenever it returns a context.
This also conflicts with the Channel compliance requirement to retain each current context together with its associated `ContextMetadata`. The reference proxy currently compensates for missing response metadata by fabricating fallback values such as an unknown source and the response timestamp, which loses the actual provenance of the retained context.
## Proposed resolution
Define and enforce this response invariant:
- When `payload.context` is non-null, `payload.metadata` MUST contain the complete `ContextMetadata` associated with that context.
- When `payload.context` is null, `payload.metadata` MUST be null or omitted, with one canonical representation documented.
Update the JSON Schema with an appropriate conditional constraint and clarify the behavior in the DACP documentation.
## Acceptance criteria
- The relationship between `context` and `metadata` is normative and schema-enforced.
- `getCurrentContextWithMetadata()` never requires fabricated metadata.
- The reference proxy and Desktop Agent implementation follow the invariant.
- Tests cover both non-null and null context responses.
### Area of issue
- API
- FDC3 for Web Browsers
- Desktop Agent Communication Protocol
Contributor guide
Research direction
Start with packages/fdc3-schema/schemas/api/getCurrentContextResponse.schema.json and the DACP documentation, then trace the reference proxy and Desktop Agent handling of getCurrentContextResponse. Check existing tests covering current-context responses. Done means the context/metadata relationship is normative and schema-enforced, implementations preserve associated metadata, and tests cover both non-null and null contexts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, typescript
- Domain
- api, documentation, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100