Person (Kafka topic)
Kafka topic for the Person aggregate of CNA One - the civil identity of a person, the access CNA One grants them in astro, per franchise, and the students they answer for as a guardian. Carries PersonCreated and PersonUpdated, owned by ONE, published by cna-one after the commit of a write that changes the civil data, the access or the guardian links of a person, and meant for astro to keep its users in sync. Keyed by the person id. cna-one publishes in production since v0.4.0; astro has no consumer.
cna-one publishes on this topic in production since v0.4.0 (cna-br/cna-one#1102). astro has no consumer yet, and the contract is not yet agreed with the Astro team. Comment on the pull request or in the "squad e catálogo de eventos" channel.
Overview
Person is the static aggregateRoot of the person event classes owned by OneOneDomainv1.0.0Franchise operating system bounded context. Owns the ONE message contracts for employees, persons, product lines and the...Ownercna-platformMapView docs. 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 publishes to it after every committed write that changes the civil data of a person, the access cna-one grants them or the students they answer for, and CNA AstroCNA AstroServicev1.0.0Learning management system (LMS) for students and teachers, a Django backend with a TypeScript frontend. Not on the Kafk...SubscribesPersonCreated, PersonUpdatedOwnercna-platformMapRepoView docs would consume it to create, update and deactivate its users. The students a guardian answers for travel here, franchise by franchise, in the guardianOf of each access entry, because they are what a guardian’s access is about, and only there: the student’s snapshot carries no guardians (RN-AST-032); what belongs to an enrollment or a classroom (the classroom, the status) travels in the contract and enrollment events. The two events share the topic and are told apart by metadata.event.
Why a topic per person and not per role. In CNA One the same person can be an employee in one school, a student and a guardian at the same time, and the civil data (name, document, e-mail, phone) is shared by all those roles. One topic per role (Student, Guardian, Employee) would give astro two or three ids for the same human, and spread the same name over several topics with no order between them. Keyed by the person, every change to one human lands on the same partition and keeps its order.
Message key
Messages are keyed on payload.id, the CNA One person id (common.persons.id), so the creation and every later update of one person stay in order. The key is never the document: a student under 18 enrolled without a CPF carries a code cna-one generates (CNA_CODE) until the CPF is informed, and a foreign student would use a passport.
Delivery
Publication here is fire-and-forget, like on Audit (Kafka topic)Audit (Kafka topic)Channelv1.0.0Kafka topic for the audit trail of CNA One. Carries EntityAudited, one message per audited insert, update or delete, key...Ownercna-platformView docs, but driven by the service that made the write rather than by a database hook:
- After the commit, only what changed. The flow reads the snapshots of the persons it is about to touch, writes, and once the write is committed calls
publishPersonSnapshots(api/app/domains/common/person/services/publishPersonSnapshots.ts). It reads them again and publishes the persons the flow created as Person CreatedPerson CreatedEventv1.0.0A person was registered in CNA One: the civil data, the access cna-one grants them in astro, per franchise, and the stud...Ownercna-platformSchemaMapView docs and the others as Person UpdatedPerson UpdatedEventv1.0.0The civil data of a person, the access cna-one grants them in astro or the students they answer for changed, including l...Ownercna-platformSchemaMapView docs, only when the payload,snapshotAtleft out, differs from the one read before. A person with no previous snapshot is published whatever the comparison says. - A read that fails publishes nothing. The read after the commit is logged and reported when it fails, and nothing is published: the write already happened, so the flow does not fail for it (
readPersonSnapshots.ts). - Two sends per flow. The created ones go out first and the updated ones after, one producer call each (
publishPersonSnapshots.ts:66-67). The key keeps one person on one partition, but two flows that touch the same person publish independently, so their messages can arrive in either order; a consumer orders the snapshots of a person bypayload.snapshotAt, the moment the database was read. - 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 flow never sends the message again. - No outbox. A message is also lost when the process stops between the commit and the send.
- 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 send with many persons can be lost in part: the slices before the failure are on the topic, the failed one and those after it are not. The case in point isfranchisorUpdateJobRole: a job role belongs to the whole network, and changing its functions publishes every person with anACTIVEemployment contract in it. - Republish by hand. Nothing publishes a lost snapshot again on its own. The job
jobs/republishPersonSnapshotsof RN-AST-033 (cna-br/cna-one#1261, not in production yet; cna-br/cna-one#1121 was closed unmerged) announces a set of persons, or every guardian, as Person UpdatedPerson UpdatedEventv1.0.0The civil data of a person, the access cna-one grants them in astro or the students they answer for changed, including l...Ownercna-platformSchemaMapView docs when someone runs it. Until it runs, a lost message is made good only by the next write that changes the person, which publishes their full snapshot.
In short, a PersonCreated or PersonUpdated is lost when its send fails or when the process stops between the commit and the send, and the loss can be partial. deliveryGuarantee stays at-least-once, the convention for every topic in this catalog, although every cna-one topic goes through this same producer.
Envelope
Every message on every CNA topic uses the same envelope. schema.json on each message page describes payload only.
{ "payload": { "...": "see the schema on each message page" }, "metadata": { "event": "PersonUpdated", "producedAt": "2026-10-09T12:00:00.000Z", "owner": "ONE", "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). metadata.producedAt is the send time; the payload carries its own snapshotAt, the moment the snapshot was read, which is what a consumer compares to discard an older snapshot that arrives late.
Channel information
Person- kafka
Custom properties
| Property | Value |
|---|---|
| Message Keyx-message-key | id |
| Aggregate Rootx-aggregate-root | Person |
| Driftx-drift | astro has no consumer. cna-one publishes in production since v0.4.0 (cna-br/cna-one#1102); of its schoolOps flows, the guardians card publishes from cna-br/cna-one#1261, not in production yet, and the enrollment publishes nothing yet. |