ADR-0005 — CloudEvents + AsyncAPI as the event schema and description standard
Forces / Drivers
- Requirement / Constraint:
../context/quality-goals.md— Maintainability (< 2 business days for minor updates); Deployability; developer velocity.../context/requirements.md#fr-2-event-store— FR-2 Event store persists events with schemas that must survive replay and multi-year retention.../context/capacity-model.md#service-targets— Hot 6 mo / cold 1 yr retention means events authored today must still deserialise a year from now.../context/constraints.md#bc-5-vendor-lock-in-mitigation— BC-5 Vendor lock-in mitigation; envelope + schema description should not tie the platform to a single broker vendor.
- Principle(s) embodied:
§ 9 CloudEvents + AsyncAPI,§ 10 Trilateral API. - WAF pillar optimized:
operational-excellence(primary);reliability,performance-efficiency(secondary).
Context
ADR-0003 chose choreography; ADR-0004 chose Event-Carried State Transfer. Both make the event the contract. Two operational questions follow immediately:
- What is the envelope? How does every ION event announce its type, source, ID, timestamp, correlation/subject, and payload content type — so consumers, brokers, and tracing infrastructure can process events uniformly regardless of the producing system?
- How are events described and discovered? How does a new subscriber know what events exist, which channels carry them, what shape the payload has, and how versioning works — without asking the producing team?
Without answers, ECST plus choreography quickly degrade: producers invent per-service envelopes, consumers hard-code field lookups, schemas drift, and adding a new consumer requires tribal knowledge from the producing team. That is precisely the coupling the previous ADRs rejected — moved from runtime to design-time.
Two industry standards address the two questions cleanly:
- CloudEvents (cloudevents.io) — a CNCF specification for a common event envelope. Standardises
specversion,type,source,id,time,subject,datacontenttypeat the envelope level; the payload lives indata. SDKs exist in TypeScript, Python, C#, Java, Go, and Rust. Multiple broker bindings (HTTP, AMQP, Kafka, MQTT) are defined so the same envelope crosses transports. - AsyncAPI (asyncapi.com) — the event-driven analogue of OpenAPI. Describes channels, publish/subscribe operations, message payloads (with JSON Schema), correlation IDs, and versioning per event type. Generates types, documentation, and mocks from a single spec file.
Neither standard alone is enough: CloudEvents standardises the envelope but is silent on where events flow and what their payload shapes are; AsyncAPI describes flows and payloads but is silent on the wire envelope. Together they give ION a complete answer.
A third dimension is serialisation format. Two industry defaults contest: JSON (human-readable, ubiquitous SDK support) and binary (Avro / Protobuf, compact, strong schema-registry semantics). ION chose JSON for the wire — the reasoning is spelled out under Alternatives Option C.
Decision
ION V2 adopts CloudEvents (JSON) as the event envelope standard and AsyncAPI as the event description standard across the platform:
- Every event published on any broker uses the CloudEvents JSON envelope. Envelope fields (
specversion,type,source,id,time,subject,datacontenttype) are mandatory, plus thetenantIdextension attribute; the ECST payload (ADR-0004) lives indata. - Event and command type names follow the dotted convention
<platform>.<type>.<aggregateroot>.<name>.<version>— for exampleion.event.securityincident.statusupdated.v1andion.command.securityincident.updatestatus.v1.platformision;typeiseventorcommand(prefixeddomainevent/domaincommandfor internal/private messages);aggregaterootdrops theionprefix; eventnameis[subject]<pasttenseverb>and commandnameis<verb>[subject];versionis a majorv<#>. The.v<#>suffix is part of the type — a new major version is a new type on a new (or additive) channel, not a mutation of the old. See data-and-events event model. sourceidentifies the producing microservice in URN form —urn:io:ontinue:ion:<service>(for exampleurn:io:ontinue:ion:watchtower).source+idis unique per event.subjectcarries the resource identity (the aggregate id, e.g. the incident id), and thetenantIdextension attribute carries the customer tenant id so brokers can route/partition without inspecting the payload.- Correlation propagates via a CloudEvents extension attribute (
correlationid) and the standardtraceparent(W3C Trace Context) — both must be present on every event. - Every publishing service maintains an AsyncAPI specification that describes its channels, its published events, its subscribed events, and each event’s payload JSON Schema. The AsyncAPI file is versioned in the service repo alongside the code and is the source of truth for its
Trilateral APIpublish + subscribe legs (§ 10). - Schema evolution rules are backward-compatible by default: additive changes only (new optional fields, new event types on the same channel). Breaking changes require a new
.v<#>event type on a new (or additive) channel and a documented consumer-migration path (see../patterns/schema-evolution.md). - CI enforcement. The AsyncAPI spec is validated in CI; consumer type stubs are generated from it; breaking-change detection runs against the previously merged spec.
Alternatives considered
- Option A — Custom envelope + wiki-documented schemas. Rejected. No SDK support means every service reinvents parsing and validation; wiki drift is inevitable; new subscribers must read tribal documentation; no CI enforcement possible. This is the design-time coupling ADR-0003 rejects at runtime.
- Option B — AsyncAPI without CloudEvents (bespoke envelope described in AsyncAPI). Rejected. AsyncAPI describes the flow but a bespoke envelope loses the biggest win: interop across brokers (Event Hubs, Service Bus, and any future broker), across languages, and across observability tooling that already understands CloudEvents. The envelope must be standard for the description to be portable.
- Option C — Avro or Protobuf on a schema registry, binary wire format. Rejected as the default. Binary formats give compact payloads and rigorous schema-registry semantics, but:
- Debuggability suffers — engineers cannot inspect broker messages directly (matters at 3 am for an incident).
- Multi-language SDK coverage in the ION team’s stacks (TypeScript, C#, Python) is more uneven than JSON.
- Storage/bandwidth cost is not the dominant driver at V3 sizing — ~1.9 MB/s peak broker ingress (
../context/capacity-model.md#derived-processing-load) is comfortably absorbed. - CloudEvents JSON + AsyncAPI + JSON Schema gives 80 % of the schema-registry value with 20 % of the operational cost. Kept as a future consideration if storage or bandwidth becomes cost-critical — CloudEvents supports a protobuf binding, so the wire can switch without changing the envelope semantics.
- Option D — Sentinel-shaped events on the wire (adopt Microsoft’s schema as the ION schema). Rejected. Ties the platform to Sentinel’s release cadence and terminology; breaks vendor-lock-in mitigation (
§ 20); bleeds Sentinel volatility across the entire platform. Sentinel-shaped payloads live at the Watchtower ingestion boundary only and are translated into ION domain events at that boundary. - Option E — Kafka-style keyed records with no envelope standard. Rejected. Assumes a Kafka-only future; V3 uses a shared Service Bus namespace as the event backbone (ADR-0008), and Service Bus session-based partitioning is expressed cleanly via CloudEvents
subject. CloudEventssubjectgives portable partition semantics without assuming Kafka.
Rationale
The chosen combination wins on four axes that matter for a choreographed, ECST platform:
- Interop. The CloudEvents envelope means an event published on the shared Service Bus, consumed via a subscription, or replayed from the Cosmos event store looks identical to consumers. It also crosses cleanly through the bounded Event Hubs adapter at the external-integration ingress edge (see ADR-0008). Broker choice becomes a substrate decision, not a per-event schema decision.
- Discoverability. AsyncAPI answers “what events does this service publish? subscribe to? what’s the payload of X?” — from a spec file, not from an engineer’s memory. New subscribers onboard in hours, not weeks.
- Volatility containment (ADR-0002 assist). A service can refactor its internal storage freely as long as its AsyncAPI spec is stable. The spec is the volatility boundary in code form.
- Tooling maturity. CloudEvents SDKs and AsyncAPI code generators exist in ION’s language stacks (TypeScript, Python, C#). Type generation, mock generation, and breaking-change detection are all one CI job away. No custom tooling to maintain.
Choosing JSON as the wire format keeps the debuggability floor high without giving up much: the storage and bandwidth cost at V3 sizing is small; the human-readability payoff at 3 am is large. If cost dominates at a future capacity envelope, CloudEvents’ protobuf binding is the migration path — semantics stay, envelope semantics stay, wire flips.
Consequences
Positive
- Every event on every broker is uniformly parseable — one envelope, one set of tracing headers, one correlation attribute.
- New subscribers discover events from AsyncAPI, not from tribal knowledge.
- Type-safe consumers via generated stubs; less boilerplate; fewer field-lookup bugs.
- Schema-evolution discipline is enforceable in CI (backward-compat check against the last merged spec).
- Broker portability: the shared Service Bus backbone (ADR-0008) plus the bounded Event Hubs adapter at the integration ingress edge both carry the same envelope unchanged.
- Long-term replay safety: an event authored today deserialises a year from now because the envelope is standard and the payload schema is captured in AsyncAPI at that version.
- Aligns directly with
Trilateral API— each service’s AsyncAPI file is the publish + subscribe legs of its contract, next to the OpenAPI file that is the REST leg.
Negative
- JSON is larger than binary alternatives. At ~2 KB per domain event, this is absorbed at V3 sizing but becomes a cost consideration at 10× or beyond (
../context/capacity-model.md#data-volume-and-lifecycle). Reserved as a future optimisation via CloudEvents protobuf binding. - AsyncAPI tooling is younger than OpenAPI. Generators, mock servers, and IDE plugins exist but the ecosystem is thinner. Engineers occasionally need to fix generator quirks.
- Dotted + versioned type names are verbose.
ion.event.securityincident.statusupdated.v1is longer thanIncidentStatusUpdated. Trade-off for uniqueness across systems + explicit versioning. - Sensitive-field policy applies field-by-field within
data. Envelope fields are non-sensitive by construction; payload fields require the sensitive-field discipline flagged in ADR-0004. - AsyncAPI spec drift risk if not CI-enforced. The spec is only as good as the CI check that keeps it in sync with published events. Requires investment in schema-validation gates on the publish path.
Neutral / follow-ups
- Schema-evolution catalogue —
../patterns/schema-evolution.mddocuments the backward-compat + additive rules and the versioning migration path. - CI schema gates — validate that every published event conforms to the AsyncAPI spec at build time; detect breaking changes vs. the last merged spec.
- Sensitive-field policy — cross-cutting to ADR-0004; document field-tagging convention in
../well-architected/security/data-protection/. - AsyncAPI hosting — a single portal aggregating every service’s AsyncAPI spec (analogous to a shared OpenAPI portal) — proposed for API management.
typenaming policy — codified in../standards/as coding-standards content.
WAF Pillar Impact
- Primary pillar:
operational-excellence— makes the event the contract in a discoverable, tooling-supported, CI-enforced way. Every downstream operational property (breaking-change detection, generated types, portal discoverability, contract testing) hangs off this ADR. - Secondary pillars:
reliability— safer schema evolution (backward-compat by default, explicit.vNfor breaking changes) protects consumers from producer changes.performance-efficiency— schema tooling does not gate throughput; broker portability keeps performance optimisation options open (protobuf binding future-lever).
- Trade-offs:
- Sacrifices raw payload compactness for debuggability + tooling maturity (JSON over binary).
- Sacrifices short type names for uniqueness + explicit versioning.
- Adds a CI gate on every service that publishes events.
- Requires investment in AsyncAPI hosting/portal for the discoverability payoff to be actual, not theoretical.
References
../references/Design Pattern- Schema Evolution.md— schema evolution rules that this ADR references and enforces.../references/Event Sourcing- Event Model.md— ION’s event-type inventory; thetypenaming convention originates here.../references/Event Sourcing- Design.md— the event-model design that assumes standardised envelopes.../references/Architecture- Event Sourcing.md— architectural rationale for events-as-contracts.- External: CloudEvents specification (CNCF) — envelope standard, SDKs, broker bindings.
- External: AsyncAPI specification — description standard, generators, tooling.
- External: W3C Trace Context —
traceparentheader standard.
Related ADRs
- Depends on:
- Enables:
- ADR-0006 — Event Sourcing (event log has one envelope for all time; replay-safe).
- ADR-0008 — Event backbone (shared Service Bus): the envelope choice is broker-independent.
- Related:
- ADR-0002 — AsyncAPI file is the codified volatility boundary of a producing service.
- Pattern (pending) — Blob-reference for oversize payloads (envelope stays CloudEvents;
datafield carries the reference).