Problem
Some points about subject.source and subject.id trouble me (in the usage):
- The
source of a subject is optional, and if not set, it should default to the context.source. But context (source+id) references an event, not a subject
- Sometimes a reference to a subject in another subject's predicate use:
xxx.source + xxx.id (eg change in artifact.packaged, service and environment in incident.reported), in this case source is also optional (but no default)
xxxId (eg artifactId in service.deployed)
- Sometimes a predicate could reference a subject that may not "exist" via a cdevents (or is not managed by the emitter of the current event, emitter of event related to service reference artifact, environment for which no event may have been emitted, and if they have event referencing should be "compatible", I can details more about "compatibility").
(Personal usage) I also used subject.id to name the subject (eg service), but as the name could not be unique enough in a global/organization/environment context, the id is completed with some namespace group.
Proposal
-
merge subject.source into subject.id: subject.id becomes a URI-reference
migration: subject.id = {subject.source}/{subject.id} (no defaulting to context.source, concatenation if subject.source is not empty)
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"source": {
"type": "string",
"minLength": 1,
"format": "uri-reference"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"id"
]
}
becomes
"properties": {
"id": {
"type": "string",
"minLength": 1
"format": "uri-reference"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"id"
]
}
-
For references, fixing the inconsistency by
- changing every
xxxId into xxx.id (URI to struct)
- OR changing every
xxx.id (+ xxx.source merged) into xxxId (struct to URI)
-
Maybe rename id to uri, which should allow replacing/merging some id and uri defined in some subject like ticket
Pros
- better consistency between identifications and references
- clarification that
subject.id (subject.uri) is the absolute reference to the subject (doesn't mean it should be an absolute URI, but some convention could emerge like p-url)
- no more confusion about the
subject.source and the split between source and id to have uniqueness and meaningful info
- Simplifications of reference, and subject's definition
- Simpler to manage one field than a tuple
Cons
id (subject)
- Type: [
String][typesystem]
- Description: Identifier for a subject.
Subsequent events associated to the same subject MUST use the same subject
id.
source (subject)
-
Type: [URI-Reference][typesystem]
-
Description: defines the context in which the subject originated. In most
cases the source of the subject matches the
source of the event. This field should be used only in
cases where the source of the subject is different from
the source of the event.
The format and semantic of the subject source are the
same of those of the context source.
source (context)
-
Type: [URI-Reference][typesystem]
-
Description: defines the context in which an event happened. The main purpose
of the source is to provide global uniqueness for source +
id.
The source MAY identify a single producer or a group of producer that belong
to the same application.
When selecting the format for the source, it may be useful to think about how
clients may use it. Using the root use cases as
reference:
- A client may want to react only to events sent by a specific service, like
the instance of Tekton that runs in a specific cluster or the instance of
Jenkins managed by team X
- A client may want to collate all events coming from a specific source for
monitoring, observability or visualization purposes
Problem
Some points about
subject.sourceandsubject.idtrouble me (in the usage):sourceof a subject is optional, and if not set, it should default to thecontext.source. But context (source+id) references an event, not a subjectxxx.source+xxx.id(egchangeinartifact.packaged,serviceandenvironmentinincident.reported), in this casesourceis also optional (but no default)xxxId(egartifactIdinservice.deployed)(Personal usage) I also used
subject.idto name the subject (egservice), but as the name could not be unique enough in a global/organization/environment context, the id is completed with some namespace group.Proposal
merge
subject.sourceintosubject.id:subject.idbecomes a URI-referencemigration:
subject.id={subject.source}/{subject.id}(no defaulting tocontext.source, concatenation ifsubject.sourceis not empty)becomes
For references, fixing the inconsistency by
xxxIdintoxxx.id(URI to struct)xxx.id(+xxx.sourcemerged) intoxxxId(struct to URI)Maybe rename
idtouri, which should allow replacing/merging someidanduridefined in some subject liketicketPros
subject.id(subject.uri) is the absolute reference to thesubject(doesn't mean it should be an absolute URI, but some convention could emerge like p-url)subject.sourceand the split betweensourceandidto have uniqueness and meaningful infoCons
Edits: partial copy/paste from https://github.com/cdevents/spec/blob/main/spec.md as reminder
id (subject)
String][typesystem]Subsequent events associated to the same subject MUST use the same subject
id.source (subject)
Type: [
URI-Reference][typesystem]Description: defines the context in which the subject originated. In most
cases the
sourceof the subject matches thesourceof the event. This field should be used only incases where the
sourceof the subject is different fromthe
sourceof the event.The format and semantic of the subject
sourceare thesame of those of the context
source.source (context)
Type: [
URI-Reference][typesystem]Description: defines the context in which an event happened. The main purpose
of the source is to provide global uniqueness for
source+id.The source MAY identify a single producer or a group of producer that belong
to the same application.
When selecting the format for the source, it may be useful to think about how
clients may use it. Using the root use cases as
reference:
the instance of Tekton that runs in a specific cluster or the instance of
Jenkins managed by team X
monitoring, observability or visualization purposes