Event Envelope Schemas

Platform services publish strongly typed events; the JSON Schemas in this directory define those envelopes. File names follow <event-name>@<version>.json so producers and consumers can negotiate contracts explicitly.

Catalog

Orchestrator envelopes (ORCH-SVC-38-101)

Legacy envelopes (Redis-backed)

Additive payload changes (new optional fields) can stay within the same version. Any breaking change (removing a field, tightening validation, altering semantics) must increment the @<version> suffix and update downstream consumers. For full orchestrator guidance see orchestrator-scanner-events.md.

Envelope structure

Orchestrator envelope (version 1)

FieldTypeNotes
eventIduuidGlobally unique per occurrence.
kindstringe.g., scanner.event.report.ready.
versionintegerSchema version (1 for the initial release).
tenantstringMulti‑tenant isolation key; mirror the value recorded in queue/PostgreSQL metadata.
occurredAtdate-timeRFC 3339 UTC timestamp describing when the state transition happened.
recordedAtdate-timeRFC 3339 UTC timestamp for durable persistence (optional but recommended).
sourcestringProducer identifier (scanner.webservice).
idempotencyKeystringDeterministic dedupe key (`scanner.event.*::<report
correlationIdstringTies the event to the originating scan/API request.
traceId / spanIdstringW3C trace context propagated into downstream telemetry.
scopeobjectOptional block with at least repo and digest.
payloadobjectEvent-specific body; schemas embed the canonical report and DSSE envelope.
attributesobjectOptional metadata bag (string keys/values) for downstream correlation.

For Scanner orchestrator events, links include console and API deep links (report.ui, report.api, etc.) plus optional attestation references when a DSSE envelope is present. See orchestrator-scanner-events.mdfor details.

Legacy Redis envelope

FieldTypeNotes
eventIduuidMust be globally unique per occurrence; producers log duplicates as fatal.
kindstringFixed per schema (e.g., scanner.report.ready). Downstream services reject unknown kinds or versions.
tenantstringMulti‑tenant isolation key; mirror the value recorded in queue/PostgreSQL metadata.
tsdate-timeRFC 3339 UTC timestamp. Use monotonic clocks or atomic offsets so ordering survives retries.
scopeobjectOptional block used when the event concerns a specific image or repository. See schema for required fields (e.g., repo, digest).
payloadobjectEvent-specific body. Schemas allow additional properties so producers can add optional hints (e.g., reportId, quietedFindingCount) without breaking consumers. See docs/runtime/SCANNER_RUNTIME_READINESS.md for the runtime consumer checklist covering these hints.
attributesobjectOptional metadata bag (string keys/values) for downstream correlation (e.g., pipeline identifiers). Omit when unused to keep payloads concise.

When adding new optional fields, document the behaviour in the schema’s description block and update the consumer checklist in the next sprint sync.

Canonical samples & validation

Reference payloads live under docs/modules/signals/events/samples/, mirroring the schema version (<event-name>@<version>.sample.json). They illustrate common field combinations, including the optional attributes that downstream teams rely on for UI affordances and audit trails. Scanner samples reuse the exact DSSE envelope checked into docs/samples/api/reports/report-sample.dsse.json, and unit tests (ReportSamplesTests, PlatformEventSchemaValidationTests) guard that payloads stay canonical and continue to satisfy the published schemas.

Run the following loop offline to validate both schemas and samples:

# Validate schemas (same check as CI)
for schema in docs/modules/signals/events/*.json; do
  npx ajv compile -c ajv-formats -s "$schema"
done

# Validate canonical samples against their schemas
for sample in docs/modules/signals/events/samples/*.sample.json; do
  schema="docs/modules/signals/events/$(basename "${sample%.sample.json}").json"
  npx ajv validate -c ajv-formats -s "$schema" -d "$sample"
done

Consumers can copy the samples into integration tests to guarantee backwards compatibility. When emitting new event versions, include a matching sample and update this README so air-gapped operators stay in sync.

CI validation

The Docs CI workflow (.gitea/workflows/docs.yml) installs ajv-cli and compiles every schema on pull requests. Run the same check locally before opening a PR:

for schema in docs/modules/signals/events/*.json; do
  npx ajv compile -c ajv-formats -s "$schema"
done

Tip: run npm install --no-save ajv ajv-cli ajv-formats once per clone so npx can resolve the tooling offline.

If a schema references additional files, include -r flags so CI and local runs stay consistent.

Working with schemas

Contact the Platform Events group in Docs Guild if you need help shaping a new event or version strategy.