> ## Documentation Index
> Fetch the complete documentation index at: https://internal.softcrum.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Module Spec — customer-core (schema core)

> Owns the contact, its identity, its behavior, its consent, and platform cross-cutting tables. Nobody else owns the contact.

## Entities & invariants

| Table                                                        | Key invariants                                                                                                                                                                                    |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| contacts                                                     | contact\_kind person\|company; national\_id normalized + partial unique (tenant, type, id); base fields + typed custom attributes (attribute\_definitions); company ⇒ legal\_name, no birth\_date |
| contact\_identities                                          | (provider, identifier) unique per tenant; anonymous→known promotion; verified flag                                                                                                                |
| contact\_merges                                              | immutable; survivor keeps all identities/events; merge emits contact.merged                                                                                                                       |
| consents                                                     | one row per (contact, channel, status change) — history, never overwrite; proof + captured\_at mandatory                                                                                          |
| tracked\_events                                              | append-only, partitioned monthly; idempotency\_key unique per tenant; correlation\_id mandatory                                                                                                   |
| segments / segment\_members                                  | DSL v1 (ADR-012); membership history entered\_at/exited\_at; nightly\_only flag                                                                                                                   |
| attribute\_definitions                                       | typed (string,number,date,bool,enum); drives segment builder + Zod validation of custom attrs                                                                                                     |
| event\_taxonomies                                            | vertical templates AS DATA; installable per tenant; first: subscription-services                                                                                                                  |
| national\_id\_types, currencies, notification\_channels      | cross-cutting parametric catalogs                                                                                                                                                                 |
| audit\_log, usage\_snapshots, processed\_jobs, dead\_letters | platform tables (standards data.md/jobs.md)                                                                                                                                                       |

## Events emitted

contact.created|updated|merged · consent.granted|revoked · event.tracked · segment.entered|exited

## Endpoints (permission each — DEC-D5)

* POST /v1/core/track|identify|batch → core.events.write (Runtime, fast-ack 202)
* GET/POST/PATCH /v1/core/contacts\[...] → core.contacts.read|create|update; full national\_id read → core.contacts.read\_national\_id
* POST /v1/core/contacts/\{id}/erasure → core.contacts.erase (ARCO; ≤30 days automated, ledger anonymization)
* GET /v1/core/contacts/\{id}/export → core.contacts.export (ARCO portability)
* CRUD /v1/core/segments → core.segments.\*  · POST /v1/core/auth/token-exchange (per ADR-010)
* Import: POST /v1/core/imports (CSV) → duplicate-DNI rows land in suggested-merge queue (DEC-A6)

## Non-negotiables

Identity resolution and merges ONLY here. Consents checked by messaging, WRITTEN only here. Erasure = delete profile/events, anonymize ledger references (tombstone), export first if requested.
