event

Person Created

A person was registered in CNA One: the civil data, the access cna-one grants them in astro, per franchise, and the students they answer for as a guardian. Snapshot keyed by the person id. Published by cna-one, in production since v0.4.0; astro has no consumer.

Event Topic: PersonKey: idNo consumer
Under discussion with the Astro team

cna-one publishes this event in production since v0.4.0 (cna-br/cna-one#1102) to send astro the creation, update and cancellation of students, guardians and staff. astro has no consumer yet, and the open points with the Astro team are at the end of this page.

Overview

Fact: a row of common.persons was born in CNA One. The payload is the snapshot of the person at that moment: the civil data, and access: what cna-one grants the person in astro, one entry per franchise with every profile the person holds there at the same time and, for GUARDIAN, the students they answer for there (guardianOf). It is the same payload 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; the two names only say whether the person row was created in the flow that published it. A consumer applies both the same way. access only says where the user is active in astro and as what; the access to course content comes from the access right message of the contract (RN-AST-020), not from here.

Who the person is, where they may do what, and for whom. A profile alone does not say what a guardian may see: a guardian sees only the students they answer for. So the students travel here, in the guardianOf of each access entry, next to the GUARDIAN profile they justify; astro never gets a guardian without students, or students without the profile. The link travels only in the guardian’s snapshot: the student’s snapshot carries no guardians, and astro builds the list of guardians of each student from the snapshots of its guardians (RN-AST-032). They are per franchise because the student is active school by school. The roles belong to the guardian link (school_ops.student_guardians) and hold in every school where the student is active: being the legal, financial or pedagogical guardian is a fact about the student, not about one contract or one enrollment. What belongs to an enrollment or a classroom (the classroom, the status, the course, the classes a teacher teaches) travels in the contract, enrollment and classroom events.

Every person is published, including those with no access (an employee whose job role has nothing to do in astro, a student whose first payment is not confirmed yet). They go out with access: [], and astro creates no user. The user appears with the first 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 that brings a profile.

When it is published. 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, after the transaction commits, re-reads the person, computes access from the database (never from the objects in memory of the flow) and publishes PersonCreated when the flow created the person row (publishPersonSnapshots, api/app/domains/common/person/services/). The flows, in production since cna-one v0.4.0 (cna-br/cna-one#1102):

FlowPerson
createEmployee (franchise), also behind franchisorCreateEmployeeThe employee, when findOrCreatePerson created the row. A new employee goes out with access: []: the staff link is born inactive
Partner sync from Nexus (FranchisePartnerAdded, FranchisePartnerUpdated, partners of FranchiseCreated / Updated)The partner, when no person had the document
InviteUser consumerThe invited person, when no person had the document. A stored person is left as it is and publishes nothing
createContract (enrollment), not published yetEvery person the contract created: the student, the holder, the legal guardian. Written on the cna-one branch of/feature/CWH-52991-publish-person-school-ops, with no pull request yet
createStudentGuardian (guardians card), from cna-br/cna-one#1261, not in production yetThe new guardian, when the CPF was new and the card created the person row
updateStudentGuardian (guardians card), from cna-br/cna-one#1323, not in production yetThe replacement guardian registered with the update to take over a role the link drops, when the CPF was new and the update created the person row

Every other change goes out 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. How a message can be lost, and how it is published again, is under Delivery on Person (Kafka topic)Person (Kafka topic)Channelv1.0.0Kafka topic for the Person aggregate of CNA One - the civil identity of a person, the access CNA One grants them in astr...Ownercna-platformView docs.

What the consumer does (target). 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, keyed by id:

  1. Discards the message when snapshotAt is older than the last snapshot it applied for that person.
  2. Upserts its copy by the CNA One person id. Nothing is matched by name or e-mail.
  3. Applies access declaratively: the user ends up with exactly those franchises and profiles. An empty list deactivates the user (is_active = false, status INACTIVE) and never deletes it; a later snapshot with access reactivates the same user.
  4. Accepts several profiles in one franchise and the same profile in several franchises. A person is often more than one thing at once: a coordinator who teaches is TEACHER and UNIT_ADMIN in the same school. There is no owning school: a student enrolled in two schools is a student of both.
  5. Applies guardianOf declaratively too, franchise by franchise: in each franchise the person ends up the guardian of exactly those students, with those roles. The guardian’s snapshot names a student and a franchise that astro may not have received yet (different keys, and cna-one does not guarantee the order of arrival); what astro does with that link until the student arrives is open on its side (see the open questions).
  6. Treats the civil data as read-only on its side.

How access and guardianOf are decided

cna-one decides who has access; astro and CNA Auth apply it without rules of their own. The decision lives in one place, resolvePersonAccess and resolveGuardianAccess (api/app/domains/common/person/utils/), fed by resolvePersonSnapshots, and lists only what is active now, school by school. Each rule below is checked on its own, so a person gets every profile whose rule holds in that franchise. Entries come ordered by franchise id, profiles in the order of the enum and students by id, so two readings of the same state compare equal: that is how cna-one tells a changed snapshot from an unchanged one. The rules for students and guardians are RN-AST-030 to RN-AST-032 in cna-one-docs (docs/domains/integracao-astro/regras-de-negocio.md), decided on 2026-10-13, refined on 2026-10-14 with the answers to the development team and revised on 2026-11-03 (ADR-0072), when the financial and pedagogical roles moved to the guardian link. The status of the franchise is not an input: a franchise that Nexus marks inactive or suspended keeps its students and guardians active in astro, with their access rights (RN-AST-031); employees follow their own registration (ADR-0065), and the block of a suspended franchise is handled inside cna-one.

"access": [
{ "franchiseId": "A", "profiles": ["TEACHER", "UNIT_ADMIN"], "guardianOf": [] },
{
"franchiseId": "B",
"profiles": ["GUARDIAN"],
"guardianOf": [
{ "studentPersonId": "S", "relationship": "mother", "roles": ["LEGAL", "FINANCIAL", "PEDAGOGICAL"] }
]
},
{ "franchiseId": "C", "profiles": ["STUDENT"], "guardianOf": [] }
]

A coordinator who teaches in school A, has a child (person S) enrolled in school B and studies Spanish in school C. If S also studies in school D under a contract held by a grandparent who is only the financial guardian, the grandparent gets GUARDIAN with FINANCIAL in both B and D, and the mother gets S in D too: every role holds wherever S is active.

ProfileIn profiles of franchise X whenDetail of the link
TEACHERThe person has an active staff link in X with the teaching profile on, and that link stands on an ACTIVE employment contract in X. The contract is matched by employee and franchise, not through the pointer the link stores. The job role does not matter: the teaching profile may be turned on under any job role (cna-br/cna-one#1108)Staff link and employment contract (ADR-0061, ADR-0065)
UNIT_ADMINThe person has an active staff link in X standing on an ACTIVE employment contract in X whose job role is marked FRANCHISEE, COORDINATOR or SECRETARY. The TEACHER mark of a job role grants nothing hereStaff link, employment contract and job role
STUDENTThe person has an ACTIVE contract in X (contracts.franchise_id). What counts is the contract, not an enrollment in course: a locked (LOCKED) enrollment or one waiting for a classroom (PENDING_CLASSROOM) on an ACTIVE contract keeps the student active. A pre-enrollment (PENDING_PAYMENT, WAITING_PAYMENT) activates nobody. RN-MTR-048 also counts a re-enrollment opportunity open in X, until the first payment of the new contract; cna-one has no re-enrollment opportunity yet (see Known drift)Contract status, computed school by school and not read from StudentEvent (RN-AST-031)
GUARDIANThe person has a guardian link to a student who has STUDENT in X, and holds at least one of the roles below in X for that studentGuardian link and the student’s contracts (RN-AST-030); the students are in guardianOf

The roles of a guardian for student S in franchise X:

RoleHolds in X whenSource
LEGALThe guardian link has LEGAL; it holds in every franchise where S has STUDENT, because legal guardianship is a fact about the student, not about a contractschool_ops.student_guardians.roles
FINANCIALThe guardian link has FINANCIAL; it holds in every franchise where S has STUDENT. The enrollment gives it to the holder of a minor’s contract, and the school adds or removes it on the guardians cardschool_ops.student_guardians.roles
PEDAGOGICALThe guardian link has PEDAGOGICAL; it holds in every franchise where S has STUDENT. enrollments.guardian_id is only the pedagogical reference of each enrollment, the person the school addresses about it, and travels with the enrollmentschool_ops.student_guardians.roles
PICKUPThe guardian link has PICKUP and another role holds in X: it travels only beside another role, so a person who is only PICKUP gets no entry at all. Whether PICKUP alone should link a school is still open (see the open questions)school_ops.student_guardians.roles

The guardian link is required in every case: a contract holder with no link gets nothing. The holder of an adult student’s contract who is not the student is meant to get a link with FINANCIAL only, since the adult student answers for themselves (RN-AST-030); the enrollment does not write that link yet (see Known drift), so today that holder gets nothing unless the school adds them on the guardians card. A student who turns 18 keeps their guardians: nothing changes on the birthday, and the roles stay until the school removes them at the student’s request; at the next re-enrollment the student takes the adult path (RN-AST-031). A minor keeps at least one FINANCIAL and one PEDAGOGICAL guardian: the guardians card takes the role from the last one who holds it only by handing it over to a replacement, another guardian of the student or one registered on the spot (cna-br/cna-one#1323). The roles travel because what a guardian sees depends on them, and one person can hold several: cna-one decides who is a guardian of whom and where, astro decides what each role sees.

The re-enrollment window (RN-MTR-048, not in cna-one yet). A concluded contract keeps the student active in that school while its re-enrollment opportunity is open, and with the student every role of their guardians there. The opportunity is resolved as renewed only at the first payment of the re-enrollment contract, which is a pre-enrollment until then, and closes without renewal at the re-enrollment deadline (RN-MTR-048), when the student and the guardians’ entries for that school go away.

A franchise entry disappears only when no profile is left in it: the teacher of school A who stops being the guardian of a student of A stays active there as TEACHER, with an empty guardianOf.

Kafka

Topic (aggregateRoot)Person
Message key (routingKey)payload.id
Contract ownerONE
metadata.eventPersonCreated
Consumer group(to be created)

Payload schema

Source of truth

PersonPayload and its subtypes are exported from this file and shared with 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, as EmployeePayload is. buildPersonPayload (api/app/domains/common/person/producers/payload/) fills document from the person row, with country always null.

api/app/events/one/person/PersonCreated.ts
import Event from 'events/lib/event';
export type PersonAccessProfile =
| 'TEACHER'
| 'UNIT_ADMIN'
| 'STUDENT'
| 'GUARDIAN';
export type PersonGuardianRole =
| 'LEGAL'
| 'FINANCIAL'
| 'PEDAGOGICAL'
| 'PICKUP';
export type PersonGuardianOf = {
studentPersonId: string;
relationship: string | null;
roles: PersonGuardianRole[];
};
export type PersonAccess = {
franchiseId: string;
profiles: PersonAccessProfile[];
guardianOf: PersonGuardianOf[];
};
export type PersonPayload = {
id: string;
snapshotAt: string;
name: string;
surname: string;
document: {
type: 'CPF' | 'CNPJ' | 'RNM' | 'PASSPORT' | 'CNA_CODE';
number: string;
country: string | null;
};
email: string | null;
phone: string | null;
birthdate: string | null;
gender: 'MALE' | 'FEMALE' | 'OTHER' | 'NOT_INFORMED';
access: PersonAccess[];
};
class PersonCreated extends Event<PersonPayload> {
public static owner = 'ONE';
public static aggregateRoot = 'Person';
public static routingKey = 'id';
public static version = '1.0.0';
}
export default PersonCreated;

What astro adapts

The payload says what is true in CNA One, and cna-one sends everything astro needs to decide what a person sees; astro adapts its model to consume it. The gaps on its side, read in cna-br/cna-astro on 2026-10-13:

  • One user_type per user (backend/users/models/users_model.py). The same person can be a teacher and a coordinator in one school, a guardian in another and a student in a third. access lists all of them; astro keeps several profiles per user, or one user per profile under the same CNA Auth account. A single precedence does not work: a coordinator who teaches would lose the classroom, which only accepts TEACHER.
  • A single unit per student. There is no owning school in CNA One, so astro accepts STUDENT in more than one unit.
  • No CNA One id on the user or the unit. astro stores the person id to apply snapshots, and maps franchiseId (the Nexus franchise id) to its unit.
  • The CNA envelope. Its Kafka layer (backend/services/kafka/) validates the whole message body as the payload and keeps its metadata in astro.* headers. A CNA message body is { payload, metadata }, so the handler validates the envelope and tells the two events apart by metadata.event.
  • Guardian links per unit. The Relationship model (student, parent, relation) exists in the backend and has never been used, and it has no unit. It becomes astro’s copy of guardianOf, per unit and with the roles.

Open questions

To settle with the Astro team before astro writes its consumer. They apply to 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 too.

  1. A snapshot per person, or three events per job role in a school. On 2026-09-28 the Astro team planned to consume “added, updated and removed” of a job role in a school and create the user from the link. This proposal carries the result of those links in access, covers students and guardians with the same message, and gives one id per human. The staff link and the employment contract can still become events of their own later.
  2. The PICKUP role. The reach of LEGAL, FINANCIAL and PEDAGOGICAL is settled (RN-AST-030). Whether a person who is only PICKUP links a school, and so becomes a user in astro, is still open with product; this proposal gives them no entry. What each role sees (progress, attendance, and whether the financial data, which belongs to cna-one, shows) is astro’s decision, due at its 2026-10-15 checkpoint for the guardian access.
  3. The enrollment as the strong event. astro expects the student and the enrollment in one message. This proposal keeps person data on this topic; the contract and enrollment events, still to be proposed, carry studentPersonId, the classroom and the status, and are published after the person in the same request. The guardians do not depend on them: they come in guardianOf.
  4. Snapshot or delta. The Astro team proposes that updates carry only what changed. This proposal sends the full snapshot every time, as ADR-0067 and the One → Astro epic ask (“the full record of the moment”).
  5. Who releases the login (future). CNA Auth has no rule of its own: cna-one would ask it to grant or revoke access to astro, as it already does for cna-one with Grant Application AccessGrant Application AccessCommandv1.0.0Asks CNA Auth to give a person access to an application, provisioning the account and user when they are new. Published ...Ownercna-platformSchemaMapView docs and Revoke Application AccessRevoke Application AccessCommandv1.0.0Asks CNA Auth to take a person's access to an application away and drop the sessions it holds. Handled by cna-auth; no a...Ownercna-platformSchemaMapView docs, when access stops or starts being empty.
  6. A guardian snapshot that arrives first. The link lives only in the guardian’s snapshot (RN-AST-032, settled on 2026-10-14: the student is not published when a link changes). That snapshot names a student and a franchise that astro may not have received yet, for instance at the first payment in a new school, and cna-one does not guarantee the order of arrival. How astro treats a link to a student or a franchise it does not know yet (keep it pending, ask for a republish) is its design, open with the Astro team.
  7. Guardians of a student who turned 18 (LGPD). Pending with Legal and the DPO: if an adult student cannot have pedagogical data shown to a guardian without their consent, a review of the roles at 18 comes in, and it publishes 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 for the guardians it removes.

Known drift

Observed on 2026-10-28 against cna-one staging (12e02d89c), and on 2026-11-30 against staging (800187d64) for the guardians card (cna-br/cna-one#1261, cna-br/cna-one#1323) and the republish job; the producer rechecked on 2026-11-17 against production (v0.4.0).

  • No consumer in astro. The producer is in production since cna-one v0.4.0 (cna-br/cna-one#1102).
  • The enrollment publishes nothing yet: createContract publishes only on the branch of/feature/CWH-52991-publish-person-school-ops, with no pull request opened. The guardians card publishes from cna-br/cna-one#1261, not in production yet: createStudentGuardian, which creates the person when the CPF is new, and updateStudentGuardian. Only createContract writes a person with a CNA_CODE document, so no message carries one on staging yet.
  • The enrollment wizard still writes the holder of a minor’s contract without LEGAL when the legal guardian is someone else, and no link for the holder of an adult’s contract, until it follows RN-MTR-095; the correction of the contracts it wrote goes with that change. The backfill backfills/studentGuardianRoles of cna-br/cna-one#1261, run once by hand from its own branch after the deploy and followed by the republish job, only links the holders of minors that had no link and gives the enrollments of minors a pedagogical reference.
  • No flow set a student contract ACTIVE on that commit: it was born PENDING_PAYMENT, with no payment confirmation. From cna-br/cna-one#1322 (not in production yet), the first payment of a TUITION or LEARNING_BOOK installment moves a PENDING_PAYMENT contract to ACTIVE in the payment’s transaction and publishes no PersonUpdated, so STUDENT, GUARDIAN, FINANCIAL and PEDAGOGICAL reach a snapshot only when another flow publishes that person, such as an employee, staff or partner update.
  • The re-enrollment opportunity (RN-MTR-048) does not exist in cna-one yet: only an ACTIVE contract makes a student active, and no concluded contract keeps a student active.
  • PASSPORT is declared in PersonPayload but not in DocumentType (CPF, CNPJ, RNM, CNA_CODE), and country is always null: cna-one has no passport.
  • Guardian links: changing the roles of a link (updateStudentGuardian) and adding a guardian from the card (createStudentGuardian) publish from cna-br/cna-one#1261, not in production yet; removing a guardian does not exist.

Custom properties

PropertyValue
Contract Ownerx-contract-ownerONE
Kafka Topicx-kafka-topicPerson
Message Keyx-message-keyid
Sourcex-sourcecna-one api/app/events/one/person/PersonCreated.ts
Driftx-driftastro has no consumer. cna-one publishes from its franchise flows and the InviteUser consumer, 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.
19 properties
idstring
required

Person id (UUID) in cna-one common.persons. Kafka message key and the only id consumers correlate by; never the document.

snapshotAtstring<date-time>
required

Instant the snapshot was read from the database. Consumers keep the last applied value per person and discard a snapshot older than it, which absorbs redeliveries and concurrent publishes.

namestring
required

First name(s).

surnamestring
required

Surname.

documentobject
required

Identity document, always present. A student under 18 enrolled without a CPF (ADR-0069) carries the code cna-one generates for them, with type CNA_CODE (cna-br/cna-one#1109), never a null document. An object from the start so the passport of a foreign student (RN-ALU-005) does not need a major version.

emailstring | null
required

Contact e-mail of the person, or null. Not the employee login e-mail, which belongs to CNA Auth.

phonestring | null
required

Contact phone, or null.

birthdatestring | null<date>
required

Birth date as YYYY-MM-DD, or null.

genderstring
required

Gender (cna-one Gender).

Allowed values: MALE FEMALE OTHER NOT_INFORMED
accessarray[object]
required

What the person may do in astro right now, decided by cna-one: one entry per franchise where the person has access, with every profile they hold there at the same time (a coordinator who teaches gets TEACHER and UNIT_ADMIN in the same entry) and, for GUARDIAN, the students they answer for there. Only what is active. The same profile can appear in several franchises (a student enrolled in two schools gets STUDENT in both; there is no owning school). A franchise never appears twice. An empty list means no access: astro creates no user, or deactivates the one it has (never deletes).