channel

Audit (Kafka topic)

Kafka topic for the audit trail of CNA One. Carries EntityAudited, one message per audited insert, update or delete, keyed by the audited row id and published after the commit. Person and Classroom are the audited entities, in production since cna-one v0.4.0. No consumer today.

Channel KafkaNo consumer

Overview

Audit is the verbatim static aggregateRoot of the Entity AuditedEntity AuditedEventv1.0.0A row of an audited table in CNA One was inserted, updated or deleted, with the old and new values, the acting employee ...Ownercna-platformSchemaMapView docs class. It is a process topic, not a business aggregate, so it has no entity in the catalog. Its owner constant is AUDIT, the only owner value that is not an application; the class lives in CNA OneCNA OneServicev1.0.0Franchise operating system (franchises and employees, pricing, products and learning books, school operations, receivabl...PublishesGrantApplicationAccess, EmployeeCreated +19SubscribesInviteUser, FranchiseCreated +17Ownercna-platformMapRepoView docs, so the catalog files it under OneOneDomainv1.0.0Franchise operating system bounded context. Owns the ONE message contracts for employees, persons, product lines and the...Ownercna-platformMapView docs.

The topic carries an audit trail of database changes in cna-one, meant for an external sink. Three facts about its current state:

  • Nothing consumes it. No consumer group subscribes to Audit in any of the four applications.
  • Person and Classroom are audited. The TypeORM subscriber publishes for the entities marked @Auditable(), and those two are the ones that carry the decorator.
  • In production since v0.4.0. The audit of persons (cna-br/cna-one#1109), its publication after the commit (cna-br/cna-one#1114) and the audit of classrooms (cna-br/cna-one#1229) shipped together in cna-one v0.4.0; until then production audited no entity and nothing reached the topic.

Message key

Messages are keyed on payload.entityId, the id of the audited row (static routingKey = 'entityId'), so the history of one row stays in order.

Delivery

Publication here is fire-and-forget. The subscriber publishes once the write is committed, so a rolled-back write leaves nothing on the topic, but it does not await the send:

  • A failure reaches only the log. cna-one’s producer catches the send error and logs it without rethrowing (api/app/events/lib/producer.ts:48-52), so the write flow never sends the message again.
  • No outbox. A message is also lost when the process stops between the commit and the send.
  • Order within a transaction, not between transactions. The writes of one transaction go out in one batch, in the order of the writes, and the key keeps one row on one partition. Two transactions publish independently, each over its own producer connection, so their batches can arrive in either order; a consumer orders the history of a row by payload.timestamp, the moment of the write.
  • Savepoints. Rolling back to a savepoint keeps the messages of the writes it undid; they go out with the outer commit. Nothing in cna-one opens a savepoint today.
  • Large batches go in slices. The shared producer sends the messages of each topic in order, in slices of at most 512 KiB (api/app/events/lib/producer/sendMessages.ts:49), to stay under the broker’s message size limit (1 MiB by default). A failed slice stops the ones after it, so a commit with many writes can be lost in part: the slices before the failure are on the topic, the failed one and those after it are not.

In short, an EntityAudited is lost when its send fails or when the process stops between the commit and the send, and the loss can be partial. Hence at-most-once.

Envelope

{
"payload": { "...": "see the schema on the message page" },
"metadata": {
"event": "EntityAudited",
"producedAt": "2026-09-18T12:00:00.000Z",
"owner": "AUDIT",
"producedBy": "ONE",
"version": "1.0.0"
}
}

owner is the contract owner from the class; producedBy is the application that emitted the message; version is the class static version (see The envelope in docs/modelling/02-mapping.md). cna-one sends all three since cna-br/cna-one#956 (v0.4.0); owner reads AUDIT, the only owner that is not an application.

Channel information

Address: Audit
Protocol:
  • kafka

Custom properties

PropertyValue
Message Keyx-message-keyentityId
Aggregate Rootx-aggregate-rootAudit
Driftx-driftNo application consumes this topic.