Table of Contents

Stored email schema

stored_emails holds the normalized metadata a mailbox timeline is read from. Its raw MIME lives in a separate one-to-one table, email_message_contents, and the text derived from that MIME lives in a third, email_search_documents, so nothing that lists or filters mail ever loads a bytea value, a body's worth of text, or a search vector — let alone tracks one in the change tracker.

This page describes the table as the EF Core model declares it and as the reviewed baseline migration creates it. PostgreSQL has had its say about that migration, so the types, constraints, and indexes below are the ones a schema dump reports rather than the ones a model was hoped to produce. How the schema reaches a database is at the end of this page.

Where a raw-MIME row keeps its payload

Four tables hold raw MIME — email_message_contents here, and outgoing_email_contents, recurring_send_drafts, and mail_draft_contents further down — and all four carry the same four columns beside whatever else they record, because a payload is in one of two places and the row is what says which.

Column Type What it holds
Backend character varying(64) Database or ObjectStorage. Text rather than an integer for the reason content_availability is, and NOT NULL with a stored default of Database — which is what makes every row written before the column existed read as the thing it is, and what keeps an ordinary database-backed insert from stating anything
ObjectLocator character varying(1024) The whole key an object was written under, and null for a database-backed row. Stored verbatim and never recomputed: the key is minted before the row that points at it exists, which is what lets the object be written outside the transaction that writes the row
ObjectVerifiedAt timestamp with time zone, nullable When the move read the object back and vouched for it against this row's own length and digest. Null for a database-backed row, and set on an object-backed one for as long as the database is still holding a copy beside the object
the payload column bytea, nullable RawMime, or DraftMime on the recurring-send draft. It holds the bytes for a database-backed row, and for an object-backed one it holds the copy the move left behind until an operator releases it

A CHECK constraint per table pairs all four, named ck_<table>_backend_payload: a Database row carries a payload, no locator, and no verification instant; an ObjectStorage row carries a locator, and either no payload or a payload with the instant its object was vouched for beside it. It is what makes the arrangement a property of the schema rather than of whichever writer got there — a backfill, a hand-written migration, or a new caller that left a payload beside a locator nothing verified is refused rather than stored as a duplicate nobody can date.

The retained payload is a duplicate by design, and it is the one place the schema permits one. The move copies and never removes, so a row it has carried holds its mail twice: the object it is now read from, and the bytes the database always had. That is what lets a read fall back while a deployment is trusting its bucket for the first time, and ObjectVerifiedAt is what the release measures its safety interval from. Freeing the payload leaves the length and the digest where they are, so the object stays checkable once the bytes it could have been compared against are gone. Moving stored content into the bucket holds the operator's half of it.

Each table also carries ix_<table>_object_locator, a unique partial index on ObjectLocator filtered to Backend = 'ObjectStorage'. Two readers share it. The readiness census asks whether this deployment holds mail in an endpoint it can still reach, and partial is what makes that census cheap: the stored default names the database, so on a deployment that configured no endpoint all four indexes are empty and the census reads four empty indexes instead of sequentially scanning four tables of mail on every scrape. Reclaiming an object nothing points at asks the other question, of one listed page of keys at a time — which of these does a row still name — and it is the reader the index is keyed on ObjectLocator for, because a probe by key against an index over Backend would read every object-backed row in the table. Nothing else reads either column: a payload is reached through the row that owns it, never through its backend or its key.

The index is unique because a locator names one row. Every placement mints a fresh key rather than deriving one from the row that will point at it, so two rows sharing a locator would be two messages the reclamation cannot tell apart and one object two deletions would race over — and the constraint is the schema saying that content addressing was refused rather than a property somebody has to keep.

The byte length and the SHA-256 digest stay on the row under both backends, so the integrity check a read performs is one check rather than two. Under the object backend the digest is also what the endpoint was asked to verify the upload against.

Nothing here is a per-account or per-user decision. Which backend a deployment writes to next is one process-wide setting, and this column is the same fact asked about a payload already stored. ADR 0017 is the decision, and email content is what a reader of the behaviour reads.

What a row records

The columns fall into groups, each answering a different question.

Identity and occurrence. id is the local UUIDv7 that identifies the stored message for its whole life, and it is what every other table references, what the client HTTP API and the MCP tools name a message by, and what a queued classification names. mail_folder_id is the folder the message is in, and uid_validity with uid is where a mail server holds it: the remote occurrence, unique per folder. The occurrence is an attribute rather than the identity — both columns are nullable, ck_stored_emails_occurrence_complete holds them present together or absent together, and a row carrying neither is a message no server holds any longer, which every read, derivation, and erasure reaches through id exactly as it reaches any other. Nothing but reconciliation, the refill of deferred content, a change carried to the server, and a spam classification an earlier build queued by occurrence selects on the occurrence, and each of them passes over a row that has none: a change a person, a rule, or a spam verdict asks for against such a row is refused rather than recorded, since there is no UID to issue it against. ADR 0034 records why. mailbox_account_id is a copy of the owning folder's account: every timeline index leads with it, and an index cannot span a join. Nothing repoints a folder at another account, so it is written with the row and never revised. No user is stored beside it, because a message belongs to the mailbox rather than to a person: which people read it is the assignment relation, read at the moment the read runs.

Two folders holding the same message — because the user copied it, or because MailFathom did — are two rows, each with its own raw MIME, search document, chunks, and vectors, and no stored identity joins them; ADR 0008 records that decision and what it costs, and what a message MailFathom copied becomes locally states it as behavior. The cascade below is what makes that safe rather than merely duplicated: each row erases its own derived data, so removing one copy reaches everything derived from it and touches nothing of the other.

What the server reported. internet_message_id, subject, sent_at, size_octets, and content_availability come from the envelope the IMAP server returned. For a message whose raw MIME was never fetched these are the only fields the row carries, and content_availability says which of the two reasons applies. ExceededSizeLimit is permanent — the message is above the configured per-message limit and will be on every later run — while AwaitingStorageHeadroom is a queue: content storage was at its configured ceiling when the message was discovered, and a later run with room fetches it and fills the rest of the row in. The column is text rather than an integer so that reason stays readable in an ad-hoc audit query and survives any reordering of the enum.

What the stored MIME said. received_at, the sender columns, the recipient arrays, the thread columns, and the attachment summary are read out of the raw MIME that this deployment actually stored. When that read succeeds it also replaces subject and sent_at, so one row stays consistent with one set of bytes rather than mixing two parsers' answers. internet_message_id is the exception: a message that carried no Message-ID keeps the identifier the envelope reported instead of losing it.

The remote flag snapshot. remote_flags_observed_at and the five boolean markers record what the server last said about \Seen, \Answered, \Flagged, \Draft, and \Deleted. The reconciliation pass writes them one bounded window per run, so a row nobody has reached yet still carries the never-observed value. The timestamp exists because no combination of the booleans can distinguish "the server reports none of these" from "nobody has looked yet", and it doubles as the reconciliation queue: ix_stored_emails_reconciliation_queue is (mail_folder_id, remote_flags_observed_at, uid) over the rows that are not tombstoned, which is what lets the pass advance without a cursor of its own. It states no null sort order on purpose — a window is read as two queries, one per group, so neither orders a null against a value and both take PostgreSQL's default.

The keywords beside them. RemoteKeywords is a text[] on the same row, holding the flags the protocol leaves to whoever set them — $Junk, $Forwarded, a label a mail client wrote — rather than the five it names. The reconciliation pass writes it with the booleans, from the same FLAGS answer, so an empty array means either that the server reported no keyword or that nobody has looked, and remote_flags_observed_at is what tells those apart here too. Flag names are compared without regard to case, so the values are held upper-cased, deduplicated, and ordered: two observations that found the same keywords write the same array whatever order the server listed them in. What one row keeps is bounded at 64 keywords of at most 64 characters each, and a server reporting more has the excess discarded rather than failing the window. The column sits here rather than in a table of its own so that every tombstone, retention, erasure, and export path already carrying this row carries the keywords with it.

These columns are an observation and never an instruction. Reading mail cannot reach any of them, because no read path holds a session able to issue a STORE at all. \Seen, \Flagged, and the keywords are what MailFathom can ask a server to move, and only as a change the mailbox user authored — that request is written to mailbox_mutations and issued against the server, and it writes nothing here. A column changes when the reconciliation pass next reads the folder and finds the flag standing somewhere new, which is the same way it would change had the user moved the flag in their own mail client. So each of them has exactly one writer whoever moved the flag, and a row read between the command and the next window still reports the last value the server was seen to hold. \Answered and \Draft are never written under any instruction, and \Deleted is written only by a delete — as a step of removing the message, or as all of it where the account's deletes only flag one — rather than as a flag anything else asks for. ADR 0007 records why the permitted set stops there.

The tombstone. remote_expunge_observed_at records when reconciliation found the message gone from its remote folder, and is null while the server still holds it. It is a different statement from is_remotely_deleted, which is the server reporting the \Deleted flag for a message the folder still holds and still serves; conflating the two would hide mail that is merely marked for deletion. An account configured to erase local copies has no tombstone at all, because its row is removed instead — and the three tables that reference this one all cascade, so the raw MIME, the search document, and any outstanding repair request go with it. IMAP synchronization describes when each happens.

The local copy kept without a remote occurrence. is_retained_after_authored_delete is what separates a row the server no longer holds from a row a reader may no longer see, and only a change MailFathom itself performed under RetainLocalCopy sets it — a delete, or a relocation into a folder nothing mirrors, which is the same loss of the occurrence and is answered by the same setting. Such a row carries the tombstone timestamp as well, because the server genuinely no longer holds the message and the reconciliation queue has to stop selecting it; the flag is what keeps it inside the mailbox queries the timestamp would otherwise take it out of. So a row is excluded from every mailbox query when remote_expunge_observed_at is set and this flag is false, while ix_stored_emails_reconciliation_queue filters on the timestamp alone. Nothing else sets it: a relocation between mirrored folders carries the row into the destination instead, a disappearance somebody else caused is answered by RemotelyDeletedEmailDisposition, which has no value that keeps the mail readable, and carrying the row onto a new occurrence clears the flag along with the timestamp. What becomes of a message MailFathom deleted states which disposition produces which of the three outcomes. One read is stricter than that rule and says so where it is written: resolving the occurrence a caller's flag change is recorded against refuses such a row outright, because the mail is readable while the UID names a message the server expunged, and a change recorded against it could only be attempted and fail.

What the rules have seen. rules_evaluated_at records when a rule pass last evaluated this message, and is null while none has. It is not only a record: its absence is the queue a pass reads, so writing it is what takes a message out of the mail rules apply to on arrival, and ix_stored_emails_awaiting_rule_evaluation is what makes reading that queue proportionate to it rather than to the mailbox. The migration that adds the column stamps every row already stored, which is the same statement made about mail that existed before rules ran at all — an upgrade must not hand a deployment's first rule set an entire mailbox's history as though it had just arrived. Re-evaluating mail that already carries a value is the whole-mailbox run below, and never something an edit sets off; mail rules states both halves as behaviour.

When this deployment first held the message. StoredAt is written once, when the row is inserted, and is never revised. It is deliberately neither sent_at nor received_at: both of those are facts about the message that a sender or a mail server decided, and can be years old on a mailbox being synchronized for the first time. This is a fact about this deployment, and it is what spam classification's ordering is measured against — how long a message has waited for a verdict before everything derived from it is released anyway, which junk is kept out of what a deployment derives from mail states as behaviour. The migration that adds the column backfills every existing row with -infinity rather than with the instant of the upgrade: a message stored before the column existed has by definition waited longer than any wait a deployment can configure, so it is eligible immediately, while stamping it with the upgrade would hold a whole mailbox out of the index for one more wait apiece.

When the stored bytes were last read back and matched. ContentVerifiedAt is null until the drain of a held account has read this message's payload out of the content store and matched it against the length and SHA-256 digest recorded for it, and carries the instant of that reading afterwards. It exists so that emptying a mailbox of years does not read every payload again on every pass: a row that carries it has already been proved, and the gate then turns on the row and the folder alone. It is written by nothing else and read by nothing else, and ix_stored_emails_awaiting_drain — (MailboxAccountId, ReceivedAt, Id) over the rows that still carry a UidValidity — is what makes selecting the next batch proportionate to the batch rather than to the mailbox. A mirrored account never has one, because nothing drains it.

Concurrency. ConcurrencyVersion maps onto the PostgreSQL xmin system column rather than a column of its own, so PostgreSQL maintains the token and no writer has to.

Sender and recipients

The sender is stored as three columns: the display name and address as the message wrote them, and the upper-cased comparison form that every filter and index matches on. The From header supplies it. Sender is the fallback and only stands in for a message that named no author at all, because it names whoever submitted a message written on someone else's behalf and therefore answers a different question.

Recipients are PostgreSQL text[] columns — to_addresses, cc_addresses, reply_to_addresses — rather than a join table, because every planned query tests containment rather than joining to recipient rows. They hold the comparison form only. A recipient's display name is mail content that no planned query filters or sorts on, and a second copy of it would widen the access, export, and erasure surface for nothing; a reader that needs the names re-derives them from the stored raw MIME, which the email content read model parses anyway.

The sender-authentication verdict

Ten columns record what was established about who actually sent the message: SenderAuthenticationOutcome, SenderAuthenticationMethod, AuthenticatedSenderDomain, DkimSignerDomain, SpfMailFromDomain, DmarcOutcome, AuthorAuthenticationOutcome, AuthenticatedAuthorDomain, DisplayedAuthorDomain, and SenderAuthenticationSource. The five enums are text for the reason content_availability is, and the five domains are character varying(253) — the length a resolver accepts, which the domain value already refuses to exceed, so no value ever reaches a column that would reject it.

SenderAuthenticationSource is what makes the rest of the group readable, and it is the one column that is not about the message: it names who reached the verdict. ReceivingServer says it was read back out of the header that server wrote, which is also what a row carrying nothing established holds; LocalVerification says MailFathom verified the message's own DKIM signatures, which it does only where no trusted header was found. The difference cannot be recovered from anything else on the row, and it cannot be inferred from the account's configuration either, because that may have changed since. On a LocalVerification row SpfMailFromDomain is empty and DmarcOutcome is NotReported by construction rather than by outcome: after delivery there is no envelope to authenticate and no published policy is resolved.

Three of them — AuthorAuthenticationOutcome, AuthenticatedAuthorDomain, and DisplayedAuthorDomain — are about the author the message displays, which is a different question from the six naming the identity that handed the message over: a relay, a mailing list, or a delivery provider authenticates as itself while carrying somebody else's From. AuthenticatedAuthorDomain is present exactly when the author authenticated, and it is the domain a reader was shown rather than whichever identity established it.

DisplayedAuthorDomain is the domain the From header wrote, recorded whether or not anything held it, so the two halves of the comparison exist on the row where they are most needed — the messages whose author was not established, where AuthenticatedAuthorDomain is empty by construction. It overlaps that column and does not replace it: one says what a trusted server stood behind, and this says what the message claimed. It is not derivable from the sender columns either, because those fall back to Sender for a message that named no author while this is From's alone. A message stored before the column existed holds null in it and nothing fills that in by itself, because neither synchronization pass re-reads mail that stayed where it was; mfctl mailbox rederive is the pass that does, from the raw MIME the deployment already holds.

They are columns on the row rather than a table hanging off it, unlike what classification concluded. The rows would not be sparse: every message whose MIME was read carries a verdict, including the not-established one that a deployment whose provider publishes no results sees on all of its mail. What reads the verdict is the arriving message's own presentation, one row at a time down a timeline, so a join per row would buy a nullable association nothing is ever without.

Every enum column carries a database default naming what was true of a row written before it existed — NotEstablished, None, NotReported, NotEstablished again for the author, and ReceivingServer for the source, since every row written before this deployment verified anything itself came from the trusted-header reading whatever it found — so the migration that adds a column fills every stored message in rather than leaving a value nothing wrote. A domain column takes no default and is simply absent on a row written before it existed, which reads the same as a message that wrote no such domain at all: the two are indistinguishable from the row, and re-reading the message is what tells them apart. The whole group is written together on every extraction, so re-reading a message after its account gained a trusted identifier replaces the verdict rather than leaving one column of the previous reading behind. The domains are stored in the upper-cased comparison form, which is what a later reader matches on; sender authentication states how the verdict is reached and which header it is allowed to come from.

What this deployment made of that author

Three more columns record what this deployment made of that author: SenderTrustLevel, SenderTrustGrantedBy, and SenderTrustPolicyRevision. The two enums are text for the reason the four above are, each defaulting to the value that recognizes nobody — Unknown and None — so the migration that adds them fills every stored message in with what was true of it. The revision is character varying(32) and nullable on purpose: its absence is what separates a row no policy ever judged, including one recorded from an envelope whose payload was never stored, from one a policy judged and left unknown.

They are columns beside the authentication verdict rather than a group of their own because they are read together and written together — a re-derivation replaces both, so an answer can never sit beside an identity a different list judged. SenderTrustLevel has two values and nothing more, because the difference between an author nobody named and an author nothing established is the authentication columns' to state. What the revision buys is that a change to a trusted-sender list is legible rather than silent: a stored verdict keeps the answer it was given, and the revision says which list gave it. Sender authentication states the rule the verdict follows.

The machine-authorship reading

Four columns record how much the message's own text read as machine written: MachineAuthorshipBand, MachineAuthorshipLikelihood, MachineAuthorshipSignals, and MachineAuthorshipProfileRevision. They sit on the email rather than in a table of their own for the reason the group above does — every message extraction reached carries an answer, including the not-assessed one every message of a deployment that turned the reading off carries, so a join per row would buy a nullable association nothing is ever without.

MachineAuthorshipBand is text like every other enum here and defaults to NotAssessed, so the migration that adds the columns fills every stored message in with what was true of it. MachineAuthorshipLikelihood is double precision defaulting to 0, which is deliberately indistinguishable from a text that was read and carried nothing: the band is what separates the two, and a second column saying the same thing would be a second place to keep right. MachineAuthorshipProfileRevision is character varying(32) and nullable on purpose, for the reason the trust revision is — its absence is what says nothing assessed this row, whether because the reading was off, because the body yielded no words, or because the row predates the columns.

MachineAuthorshipSignals is the one enum here stored numerically rather than as text, because it is a flag set rather than a single value. A set written as text is a formatted list: no query can ask which rows carry one member of it, and reading one back depends on the separator that wrote it. Its members are explicit powers of two that are never reordered or reused, which is what makes the numeric form safe.

The whole group is written by extraction from the stored raw MIME and is re-derivable from it, and it is written whole on every extraction so a re-derivation never leaves a likelihood beside signals a different profile found. Machine authorship states what each value means and what the reading deliberately does not claim.

Bounds on what a header may contribute

Nothing between the mail server and a row bounds a header's length or how many addresses it names. The MIME reader bounds a message's structure — part count and nesting depth — but not the width of a single header, so the persistence mapping applies its own ceilings: 320 octets per address, 998 per message identifier, 256 addresses per recipient array, and 64 thread ancestors.

A value over a ceiling is dropped, not truncated, and the row keeps the rest. Both halves of that are deliberate.

Letting the value through would be worse than losing it. The column would reject the write, the retry budget would run out, the folder checkpoint would never advance past the message, and every later run would stop on the same one — one malformed header would halt synchronization of the folder behind it.

Truncating would be worse still. A prefix of a message identifier is an identifier another message may legitimately carry, so a truncated one would assemble a thread out of unrelated conversations, and a truncated address would name a mailbox nobody wrote. The columns are a filter index over what a message said, not a second copy of it; the complete headers stay in the raw MIME the content read model parses.

Where a bound cuts a sequence, it keeps the end that answers the question. Recipients keep header order from the first, because that is the order a reader sees them in. Thread references keep the ancestors nearest to this message, because that is the end of the path a thread view walks first.

Attachment summary

The row keeps the indexable part of what the MIME reader found and only that: attachment_count, attachment_total_size_octets, inline_resource_count, and the is_encrypted, carries_unverified_signature, and contains_unexpanded_tnef_part markers.

The per-attachment list of file names, media types, and sizes is deliberately not persisted. The same reasoning as for recipient display names applies, and one more: a second representation of the attachment list can drift from the raw MIME it was derived from, and re-deriving it costs nothing in a pass a body reader is already making. Email content is the read that makes it. The signature marker is named for presence rather than verification because nothing here verifies anything; a column called "signed" would be read as an authenticity result by every query that later touched it.

The deployment's persisted configuration

settings_root holds exactly one row, and that row is the configuration layer the host composes between the files a deployment provisioned and the overrides an operator supplies. The singleton is enforced by the schema — the primary key carries a check constraint admitting only the identifier 1 — because "the effective configuration" would otherwise be a question about row ordering that no reader could answer or report on. The migration that creates the table provisions the row with an empty document, so the layer exists on every database this build runs against.

Column of settings_root What it records
Id The singleton key, always 1, stated rather than generated
Document The persisted settings, as one sparse jsonb document. It is flattened into ordinary colon-delimited .NET configuration keys by the host, so nothing here queries into it and its shape is whatever the sections it carries define. A key it does not carry is inherited from the source beneath rather than read as an empty value, and an array element is written as an object keyed by its index — { "Rules": { "1": … } } — because the parser renumbers a JSON array's elements from 0
Version The version a write is accepted against, for the reason the user record's is: a rejected write reports the version it was refused against, which a token the database generates behind the write cannot be quoted back
CreatedAt, UpdatedAt When the row was provisioned, and when the document last changed — which is the provisioning instant until it does

Nothing keys onto this row and nothing cascades from it. It describes the deployment rather than any person's mail, so erasing a user leaves it exactly where it was. Configuration sources states where the layer sits and which settings are read before it and therefore never from it.

The users a mailbox serves

settings_accounts holds one row per user, and mail_account_assignments says which mailboxes each of them is served. The mail graph hangs on the mailbox rather than on a person: a folder cascades from the account, a message from the folder, and everything derived from a message from the message, so one mailbox is one copy of the mail however many people read it. ADR 0014 is the decision. The contact book follows the same division in one pair of tables: a contact somebody wrote down is an assembled record rather than mail an account brought in, so it keys onto its user and cascades from that row, while a contact an account collected keys onto the account exactly as the mail it came from does and is read by every user assigned it. contact_addresses repeats the holder despite hanging on contacts through (ContactId, BookHolderId), because the reads it answers lead with the holder in an index and an index cannot reach through the contact to find one.

Column of settings_accounts What it records
Id The stable user identity, and the primary key. MailFathom mints it, for every user: mfctl user add mints every user an administrator records, and the migration that adds this table mints the one row it writes where it upgrades a database already holding mail from a release before users were recorded — a fresh database gets none. No file states one — nothing in a file could derive a value that is the same across restarts and across replicas, and one invented per start would attach stored mail to a person who existed for one process. It is opaque, so nothing downstream can come to depend on a well-known value. mfctl user add mints a version 7 identifier, like every identifier MailFathom mints under ADR 0036; the one row the upgrade migration writes carries a version 4 value instead, because PostgreSQL's gen_random_uuid() mints it, and it keeps that value. A user identifier reaches administrative APIs, audit records, and logs, so it says there when each user was provisioned and in what order relative to the others — a fact about people that the ADR accepts in exchange for a rule with no exceptions
DisplayName The label an operator tells this user apart by, unique across the deployment and at most 128 characters. It is a label rather than an identity: nothing resolves a user by it, every reference to a user is the identifier above, and the uniqueness exists so that a list of users can be read rather than so that a name can be looked up. It is exact rather than case-folded, because a comparison rule is owed by a value something resolves by. The migration that adds it labels user the row the earlier one wrote on an upgraded database, which is the label that user carries until mfctl user rename changes it
Document The user's configurable record, as one jsonb document — their user-level settings, and no mail account. Nothing queries into it, which is what makes it a document rather than a schema: the configuration layer that writes it is what reads it back
McpEndpointEnabled, ClientEndpointEnabled Whether the user is served on the MCP endpoint and on the client endpoint, boolean NOT NULL DEFAULT TRUE. The default is what a row recorded before the columns existed reads, and what a provisioning insert naming neither writes. The user's record states them under EndpointAccess, and the columns carry the switches in force: the record's own, except where a settings policy governing the user forces one or supplies one the record leaves out. Every commit that can move that answer writes both in its own transaction — a write of the record, a write of a policy governing the user, and a move of the user into or out of an organization — so the row never serves a user on an endpoint their record and the policies over it keep them off. Every credential resolution and every session read joins them in the statement it already runs, so a switch turned off refuses that user's next request on every replica with no cache to expire
EndpointSwitchesVersion, EndpointSwitchesOrganizationId The stamp on the two switches above: the Version of the record they were derived from, bigint NOT NULL DEFAULT 0, and the organization whose policy they were derived under, a nullable uuid. The second carries no foreign key on purpose — it is compared with OrganizationId and never followed, and a key that cleared it when an organization was removed would make a row derived under that organization read as one derived under none. A write that derives the switches from the record as its policies resolve it sets both to what the row then holds: a write of the record, and a move of the user into or out of an organization — which leaves the stamp behind where it could not resolve the record under the policies it moved to, so the row is read again rather than marked as derived. A write that raises Version and leaves the switches as they are — an account created for the user, assigned to them, unassigned, saved, erased, or moved between organizations — raises EndpointSwitchesVersion with it, so a stamp that matched still matches. A write of a policy rewrites the switches and leaves the stamp alone, because it moves neither a version nor an organization. A build that does not know settings policies writes neither column, so a record it wrote, or a user it moved, is a row whose stamp no longer matches it: EndpointSwitchesVersion differs from Version, or EndpointSwitchesOrganizationId from OrganizationId. The insert that records a user names no stamp either and no record version is zero, so a row just recorded reads the same way until the commit of its first record stamps it. Every replica reads a hundred such rows on each convergence interval, derives the switches of each again from its record and the policies governing it, and stamps it; which endpoints one user is served on states what that repairs and within what bound. The migration that adds the stamp fills it as current on every row it finds
Version The version a write is accepted against. It is a number the writer states rather than the xmin token the rest of this page uses, because a rejected write has to be able to report which version it was refused against, and a token the database generates behind the write cannot be quoted back. A move of the user into or out of an organization raises it as a write of the record does, because which policy governs somebody is part of what they are served and a replica recomposes a user when this moves
CreatedAt, UpdatedAt When the user was provisioned, and when their document last changed — which is the provisioning instant until it does
OrganizationId The organization the user belongs to, or null for none, as an indexed foreign key onto organizations that restricts deletion — so an organization is removed only once nobody belongs to it and it holds no mail account

organizations holds one row per organization: Id, a version 7 identifier minted by the administrative act that records it, from the moment it records it; DisplayName, at most 128 characters; ShortName, at most 32 characters, stored upper-cased and unique across the deployment under its own index, because it is half of a login and what a sign-in resolves the organization by; and when it was recorded.

settings_policies holds the settings policy each scope states: at most one row for the deployment and one per organization. A scope that has stored none has no row, and reads as a policy stating nothing at version 0.

Column of settings_policies What it records
Id A version 7 identifier minted when the scope's first policy is written
OrganizationId The organization whose policy this is, or null for the deployment's own, as a foreign key onto organizations (fk_settings_policies_organization) with ON DELETE CASCADE, so an organization that is removed takes its policy with it
Document The policy as jsonb: a Users section, a MailAccounts section, or both, each stating defaults, forced values, and an editing restriction. It carries no secret and no identity of anybody it governs
Version The version a write is accepted against, a concurrency token the writer states. A first policy is written as version 1
CreatedAt, UpdatedAt When the scope's first policy was written, and when it last changed

One scope holds one policy, and the index is the guarantee: ix_settings_policies_scope is unique over OrganizationId with nulls not distinct, so the deployment's row — the one naming no organization — is one row rather than as many as were inserted. A first policy is an insert that does nothing on a conflict and every later one an update matching the version it was composed over, each a single statement, so of two writers on any two replicas the one that commits second writes nothing.

The document has a typed record to bind to, and the envelope beside it never depends on reading one. What the column holds is one user's configurable record — the settings that are their own rather than the deployment's. A replica composes it with every mail account assigned to that user, as a MailAccounts collection each entry of which carries the account's generated identifier and display name, the first time something acts for that user and again whenever the row's Version moves, no configuration source reaching any of them. What the binding does is bind strictly — a property nothing binds is a refusal rather than a value quietly dropped — and then judge the record by every rule a mail account is stated under, holding back what it refuses and naming the user; the published name is unique within the user's assigned set, which is the naming space this binder applies. An account holding no address is left out of the composition and reported at Warning. Neither the record nor an account may carry secret material at all — a mailbox password is a reference naming where the material is kept, and a value carrying the material itself is refused. Nothing in it shadows a deployment setting, because there is no user configuration layer: a user-level setting is a property of this record, or it is a deployment setting somebody put in the wrong document. The label, the version, and the marker stay relational for the reason the identifier does — authenticating a request and joining a user's mail must never wait on a document being parsed.

settings_mail_accounts holds one row per mail account, apart from every user it serves, and mail_account_assignments says which users each one serves. An account is a record of its own because one mailbox is one account however many people read it: its address is compared across the whole deployment, which a declaration inside each user's document could not be.

Column of settings_mail_accounts What it records
Id The account's identity and the primary key, a UUID minted by whoever creates the account rather than generated by the model: version 7 when an administrator or a user adds it, and version 4 for an account the migration that moved accounts into records of their own carried over, since gen_random_uuid() minted those. Its text form is what every stored row, tool argument, and log line names the account by
EmailAddress The mailbox's address as it was declared, trimmed, at most 320 characters. Nullable: an account the upgrade could derive no address for is held without one, is not served, and is reported whenever its user is composed until an administrator states it
NormalizedEmailAddress The address in the form it is compared in — trimmed and upper-cased — which the unique index below reads
DisplayName The name the account is told apart by among one user's accounts, required and at most 128 characters. It is unique within each assigned user's set, which the composed record's binding judges, rather than by an index
OrganizationId The organization the account belongs to, or null for none, as a foreign key onto organizations that restricts deletion, under the index ix_settings_mail_accounts_organization — which serves the listing's per-organization count, the checks a move makes, and the count that refuses removing an organization still holding accounts. An account is assigned only to users carrying the same value, null included. That rule is not a constraint: a composite foreign key through mail_account_assignments would leave every row carrying a null unchecked under MATCH SIMPLE, which is exactly the "no organization" half of it, so each write that can break it — an assignment, and a move of either side — checks it under the rows' locks in its own transaction. The same two writes of an account uphold the other thing a null decides, the same way: an account in no organization is assigned to at most one user, so an assignment counts the account's users under its lock and a move out of every organization does too
Document Every other setting the mailbox is read with, as one jsonb object carrying neither the address nor the name nor an identifier
Version The version a write is accepted against, a concurrency token the writer states for the reason settings_accounts states its own
CreatedAt, UpdatedAt When the account was created, and when its declaration last changed
HasReadableSettings Whether the document binds. An account whose document does not is answered as taking part in nothing by every question below
SynchronizationMode The mode the document asks for, 0 polling and 1 push
ClassifiesSpam Whether the document switches spam classification on for this mailbox
ScansFor The sensitive-content scanners the document switches on, as integer[]: 0 secrets, 1 personal data
ScreensOutgoingMailFor The scanners whose findings stop this mailbox's outgoing mail, in the same encoding
SettingsVersion The Version of the document the five columns above and the account's folder rows were read out of, 0 where nothing has read them yet
Column of mail_account_assignments What it records
UserId The user served, a foreign key onto settings_accounts (fk_mail_account_assignments_settings_accounts) with ON DELETE CASCADE
MailAccountId The account they are served, a foreign key onto settings_mail_accounts (fk_mail_account_assignments_settings_mail_accounts) with ON DELETE CASCADE, under the index ix_mail_account_assignments_mail_account_id. It is not unique: an account of an organization is assigned to as many of its members as an administrator assigns it to, and the mail graph is keyed by the account alone, so one mailbox stays one mailbox — synchronized once, ruled once, and read by each of them. What the index is for is the reverse read, which users an account serves, which a signal fan-out and an erasure both ask
AssignedAt When the assignment was made

The primary key is (UserId, MailAccountId), so one user is assigned one account once. One address is one account, and the index is the guarantee: ix_settings_mail_accounts_normalized_email_address is unique over NormalizedEmailAddress where it is not null, so two writers claiming one address at once are separated by PostgreSQL rather than by a read either of them made first. Both foreign keys cascade, so erasing a user ends what they were assigned and erasing an account ends every assignment to it; what becomes of an account left with nobody is the erasure's decision rather than a cascade's, and ending the last assignment erases the account and its mail in the same transaction. Ending an assignment that is not the last one leaves the mailbox and everything stored for it exactly where it was, and takes only what the departing user authored in it — their drafts and their recurring sends. Every account write moves the Version of each assigned user's settings_accounts row, which is the version a client composes its own changes against.

What every account is asked about at once

Some questions are about every mailbox the deployment serves rather than one: which folders a tool may read, which are junk, which accounts classify spam and which of their folders that covers, whether any mailbox is scanned, and the strictest posture across one user's mailboxes. Those are answered by a query rather than by binding every account's document, so the settings they filter on are held relationally beside the document — the five columns above, and one row per mapped folder in mail_account_folder_settings. The account write reads them out of the document it is committing, binding it exactly as a mailbox run binds it, and writes them in the same transaction with SettingsVersion set to the version it committed. A row whose SettingsVersion differs from its Version is one a build older than these columns wrote the document of alone, or one the migration that added them filled. Every replica reads a hundred such rows again from their documents on each convergence interval, in identifier order, writing them only where the account still stands at the version it read and stepping over one whose reading fails. So the columns trail such a write by one interval while no more than a hundred rows trail, and a larger backlog drains at that rate.

What the columns and the folder rows hold is the account as it is served, not as its document states it. A settings policy of the deployment or of the account's organization may force a mode or a list of folders over the document's, or supply one the document leaves out, and the document is never rewritten to say so. Each reading above is therefore of the document resolved through the two policies the writing transaction reads, and three commits rewrite the columns: a write of the account, a write of a policy that moves what the account is served, and a move of the account into or out of an organization. Where a policy governing the account is one the writing build does not read, the columns are left as they stand rather than written from the document alone.

Column of mail_account_folder_settings What it records
MailAccountId The account, a foreign key onto settings_mail_accounts (fk_mail_account_folder_settings_settings_mail_accounts) with ON DELETE CASCADE
Alias The folder's alias, trimmed and upper-cased as every alias is compared, at most 128 characters
SpecialUse The role the mapping names, 0 inbox through 9 outbox in MailFolderSpecialUse's order, or null where it names a path
IsSynchronized, IsVisibleToTools, GeneratesEmbeddings The folder's three participation switches, each true where the document leaves it unset
IsClassifiedForSpam Whether the account's classification covers the folder: the folders it names, or its inbox where it names none. Read together with ClassifiesSpam, so a folder is classified only where the account classifies at all

The primary key is (MailAccountId, Alias). A document mapping no folder has one row, the inbox, which is the folder a mailbox run reads it as mapping. An account is served where it holds an address, HasReadableSettings is true, and somebody is assigned it; every one of these questions is asked over the served accounts alone.

stored_secrets holds the material a user document or a mail account refers to through database:<uuid>. The document carries only the reference; a database reader therefore sees no mailbox password in the JSONB record. The material is sealed under the ADR 0005 key ring before PostgreSQL sees it, and the authenticated binding contains the user, the row identifier, the declared secret name, the stored-secret purpose, and the key identifier. Moving any one of them makes the value fail to open rather than opening under another meaning.

Column of stored_secrets What it records
Id The version 7 UUID after database: and the primary key. It tells whoever reads a document or an administrative response carrying the reference when the secret was stored, and nothing about the sealed value
UserId The user whose record may carry the reference, a required foreign key onto settings_accounts with ON DELETE CASCADE
Name The bounded declared ConfiguredSecret.Name, unique within the user and safe for rotation and audit records
SealedMaterial The AES-256-GCM envelope as bytea, constrained to a non-empty value no larger than the 1 MiB secret-material ceiling plus the envelope header
DataEncryptionKeyId The key that sealed the row. Its index is the retirement query: a key remains configured while this query returns any row
CreatedAt, UpdatedAt When the row was created and when its material was last written. A write always seals under the current ActiveKeyId, so rewriting is also re-sealing

The store joins the persistence session of the document write that carries the reference. A commit therefore makes both durable or neither, and removing a reference can remove its row in the same transaction. Resolution is deliberately outside that writer port and goes through the same ISecretReferenceResolver every other scheme uses, once per use and within the same 1 MiB bound. Persistence and DataEncryption reject this scheme because each is needed before the table can be reached or opened, and a deployment without the key ring refuses to create a row.

An account reference is the identifier, and nothing beside it. Every table that names a mail account names it by MailboxAccountId alone, and every index that led with a user and the identifier together now leads with the identifier. The identifier is the text form of the account's generated settings_mail_accounts.Id, which is unique across the deployment — so it disambiguates without a user beside it, and one mailbox two people are assigned is one set of rows rather than a copy each. Reads follow the same shape: a mail-reading or mail-writing query narrows on the accounts the caller is assigned, and it is given those by the resolution rather than by a join back to mailbox_accounts. mailbox_accounts is keyed by the identifier as well, which is what makes that scope a guarantee the schema gives rather than a convention every reader has to keep.

Three tables keep a user column, and none of them is an account reference: mail_drafts, recurring_sends, and outgoing_emails record who wrote the thing beside the account it belongs to. A draft is read by its author alone among the account's assigned users, a recurring send keeps the author it was declared by, and an outgoing email belongs to the account once submitted while keeping its author in the identity an idempotent enqueue is judged on. That is authorship rather than ownership, which is why the column survives where every other one went.

mailbox_accounts is keyed by Id alone. Beside it the table carries the three columns the folders MailFathom keeps for a held account need: RequestedCustody, CustodyPhase, and the LocalMailFoldersRevision those folders are written against. The mailbox identifier is the account's generated identifier as text. It is a relational column rather than a value in a document, which is the point: lookup, uniqueness, and cascade erasure are then guarantees PostgreSQL gives rather than predicates somebody remembered to write. The table holds one row per account however many users are assigned it, and it needs no index of its own: every read of it is by the key, and the read that asks which mailboxes one user reaches is mail_account_assignments.

A mailbox is bound before anybody is assigned it, and that is an ordinary state. The account row is created by whichever synchronization run first binds one of the account's folders, and that run names no user at all: whose mail it is is the assignment relation, written by an administrator, and a mailbox configured and not yet assigned is one the deployment holds for nobody rather than an orphan. Nothing records a user but mfctl user add and, on a database upgraded from a release before users were recorded, the migration that provisions the user its stored mail belongs to.

Erasing a user is two removals rather than one. The user's own record goes with the user, by the cascade: their credentials, their own half of the contact book, their preferences, their sessions, and — by statements of their own — the drafts and recurring sends they authored in any account. A mailbox goes only where this user was the last one assigned it, because an account somebody else still reads is that person's mail rather than this one's; the cascade from mailbox_accounts then takes its folders, its mail, and everything derived from that mail. What neither cascade reaches is the tables that record a mail account as a plain identifier with nothing keying it onto one — mail_answering_audit_entries, mail_drafts, mail_rederivation_positions, mail_rederivation_runs, mail_rule_evaluation_runs, mailbox_mutation_audit_entries, mailbox_refresh_tokens, outgoing_emails, recurring_sends, spam_classification_runs, and stored_content_claims — and those are taken by statements of their own, in the same transaction. The list is derived from the model rather than maintained by hand, so a table added later that records an account without keying onto one is discharged the day it appears; a table that hangs off one of those, such as outgoing_email_filings, is left to its own cascade. Each of those statements narrows on the account, which is what the account-keyed graph bought: a row recorded against an account that was authorized and has never synchronized — a sealed refresh token being the one that occurs — carries the account it was written for and is reached by the same statement.

On a deployment storing payloads in a bucket the erasure reaches that store as well. The locators are read at the start of the same transaction, before any row goes, because the cascade is what takes the content rows and the locator on one is the only thing naming its object; the objects are then removed once the transaction has committed. An object nothing points at is reclaimed states what happens where the endpoint refuses.

The folders MailFathom keeps for a held account

ADR 0034 gives an account whose mailbox MailFathom holds a folder hierarchy of its own, and three places record it.

Column of mailbox_accounts What it records
RequestedCustody MirrorSource or HoldMailbox, as text, MirrorSource by default and on every account a migration found. What an administrator last asked for, written only by the custody switch and never by a configuration file
CustodyPhase Mirrored, Held, or Restoring, as text, Mirrored by default and on every account a migration found. How far the work of granting the requested custody has got. Only Held has local folders, and only Mirrored applies the account's RemotelyDeletedEmailDisposition to a message the source stopped reporting
LocalMailFoldersRevision An optimistic concurrency token every write to the account's local folders increments, whether it is an edit, an arrival being placed, or an erasure pass. Two writes decided against the same hierarchy therefore cannot both commit, so a cycle, a duplicate sibling name, or a message placed in a folder erased meanwhile is refused at commit and decided again from what the winner wrote
Column of local_mail_folders What it records
Id The folder's identity, a version 7 UUID MailFathom mints, and the primary key. Every client route names a folder by it, so a rename or a move changes nothing that refers to one
MailboxAccountId The account, a foreign key onto mailbox_accounts that cascades, which is what takes the whole hierarchy with the account
ParentId The folder it sits beneath, or null at the top, a foreign key onto this table with no action: an account's erasure removes the whole hierarchy in one statement, and nothing else removes a parent before its children
Name, NameKey The name as written, and its upper-cased comparison key. The unique index ix_local_mail_folders_account_parent_name over the account, the parent — with nulls not distinct, so the top is one set of siblings — and the key, filtered to live folders, is what refuses two siblings one name however many writers reach it at once
Role Inbox, Drafts, Sent, Junk, or Trash on the five protected folders, null on every other; ix_local_mail_folders_account_role keeps one live folder per role
SourceFolderAlias The alias of the source folder whose arrivals this folder receives, or null on a folder a person made. It is the correspondence, so a rename or move of the local folder keeps it
ErasedAt When the folder was erased out of the trash, or null while it is live. An erased folder leaves every listing and both unique indexes at once; its mail is erased afterwards in bounded job passes, and once none remains a folder with a source alias is kept, detached and named after the alias, so later arrivals from that source go to the inbox rather than recreating it, while any other is removed

stored_emails.LocalMailFolderId is the local folder a message on a held account is in, a foreign key onto local_mail_folders with no action and an index filtered to non-null values, and null on every message of a mirrored account. It is set once, when synchronization stores the message or when MailFathom files one of its own, and a message met again is not moved back.

A message MailFathom files itself on a held account — a draft revision, the sent copy of a delivery where Delivery:FileSentCopy holds, or the second stored message a copy produces — is a stored_emails row with no occurrence: UidValidity and Uid are null, its content row is written in the same transaction, and its MailFolderId is the current binding of the source folder mapped to the role it is filed under, because a stored message always names a binding and that is where the source keeps the same kind of message. A copy is the one of the three that names a binding of its own rather than a role's: it takes the binding the message it was made from names, because it is that same message from that same source folder, and it carries that message's IsRemotelySeen, IsRemotelyFlagged, and RemoteKeywords with it. A draft is written with rules_evaluated_at already stamped, since nothing arrived, and so is a copy, so that a rule copying into a folder it also matches on does not meet its own copy; a sent copy is left unstamped and carries FiledFromOutgoingEmailId, which is how the rule queue and the derivations recognise it. The draft names the message it filed in mail_drafts.FiledStoredEmailId and the revision it shows in mail_drafts.FiledRevision. When synchronization meets the provider's own copy of a filed send, the occurrence is carried onto that row rather than a second one being stored; ix_stored_emails_filed_sent_copy is how the question is answered.

What a held account's source still has to be emptied of

Erasing a message on a held account removes the stored_emails row, which is the only record of where that message was on the source — so the erasing transaction writes one row here instead, and the drain expunges from it afterwards. That is what keeps a person's delete, a rule's delete, and a retention pass from waiting on a mail server, or failing because one is unreachable. It is written only while the account holds its own mailbox, and only for a folder the source keeps messages in: a mirrored account's source holds the mail rather than a copy of it, and a folder playing a virtual role presents occurrences of messages that live in other folders, so a record written for either would name a UID the drain should never have expunged.

Column of mailbox_source_removals What it records
Id The record's identity, a version 7 UUID MailFathom mints, and the primary key
MailboxAccountId The account the removal belongs to, as text, so the queue is read per account exactly as every other pass is
MailFolderId The folder binding the occurrence was in, a foreign key onto mail_folders that cascades: a folder this deployment stops mirroring takes its outstanding removals with it, because the alias they were expressed against is gone
UidValidity, Uid The occurrence to expunge. ix_mailbox_source_removals_occurrence is unique over the folder and the two, so two erasures of one occurrence leave one record however many writers reach it at once
RecordedAt When the erasure wrote it. ix_mailbox_source_removals_queue is (MailboxAccountId, RecordedAt), which is the queue the drain reads oldest first

The row carries nothing from the message: no subject, no address, no folder path, and no identifier of the message that was erased. What it is for is a UID to name in a UID EXPUNGE, and the record is deleted in the same transaction that records the expunge as done. A record whose folder reports another UIDVALIDITY is abandoned without a command reaching the source, on the same reasoning the drain's own batches are.

What an append the source never answered leaves behind

Switching a held account back to mirroring appends its mailbox onto the source again, and APPEND is the one command of that mode that may never be issued twice: a second one is a second message in somebody's folder rather than a repeat of the first. So a row is written here and committed before the command goes out, and deleted once the occurrence the source named has been written onto the message. Nothing appends that message again while the row stands, whatever state it is in.

The answer comes from a mail server and the occurrence is written to PostgreSQL, so the two cannot commit together, and the row therefore has two standing states. One carries the placement the source named: the append is fully answered and the next pass writes the occurrence and deletes the row. One carries no placement: the outcome is genuinely unknown, and only a person looking in the folder can settle it. Only the second is reported to an operator.

Column of mailbox_restore_appends What it records
Id The record's identity, a version 7 UUID MailFathom mints, and what an operator settles the record by
MailboxAccountId The account the append belongs to, as text, so the reading is per account exactly as every other pass is
StoredEmailId The message the append carried, a foreign key onto stored_emails that cascades. ix_mailbox_restore_appends_email is unique over it, so one message has one such record however many passes reach it at once — which is the constraint the whole safety rests on rather than a reading somebody remembered to take
FolderAlias MailFathom's own name for the folder the copy was appended into, which is what an operator is told to look in
IssuedAt When the command went out. ix_mailbox_restore_appends_unanswered is (MailboxAccountId, IssuedAt) filtered on SettledAt IS NULL, which is the reading an operator's view answers from, oldest first
AppendedUidValidity The UIDVALIDITY the source named for the folder it put the copy in, and null until it answers. Written on its own, by an update on the primary key, between a fully answered APPEND and the occurrence that answer justifies — which is what turns a process that ended between the two into work the next pass finishes
AppendedUid The UID the source named inside that folder, absent exactly where AppendedUidValidity is
SettledAt When the copy's fate stopped being open, and null while it still is. An operator stamps it by declaring the copy to be on the source, which keeps the row for good because the message has no occurrence to write and the row is the only thing stopping a second copy; a verdict of not there deletes it instead, and the next pass appends the message as it would any other. MailFathom stamps it itself in one case — a message whose stored payload cannot be served, which has no bytes to append and never will — so that it stops being counted as outstanding rather than holding the phase open for ever

The row carries nothing from the message but where its copy went: a stored identity, a folder alias, a placement, and two instants. Beside it mailbox_accounts.RestoreStatePosition is the account-level cursor the other half of the restore walks — the messages the drain never reached, whose held state has still to be written onto the occurrence they keep. It is one nullable uuid on the account rather than a stamp per message, because a per-message column would need a filtered index on the largest table in the schema and every mirrored deployment would carry it for nothing.

mailbox_accounts.RestoreGeneration names which restore of that account is the current one. Every entry into Restoring advances it, in the same conditional statement that writes the phase, and nothing ever clears it. It is what the mutation records written by the other half of the restore are asked for by: a record's identity is the occurrence, the requester and the mutation together, a completed record is kept for good, and a message nobody moved has the same occurrence one hold-and-restore cycle later — so a requester naming only the mechanism would let the first cycle's finished records answer the second, which would then carry none of the second hold's read, star, label, or move state and end the phase saying it had.

Where a delete left a message flagged

mailbox_flagged_deletes holds one row per occurrence a FlagDeleted delete left on its server, written in the transaction that settles the delete. It exists beside the delete's own record because neither of the other two rows survives every outcome: an erased local copy takes its stored row with it, and the mutation record cascades from that row. Reconciliation reads it until the server expunges the message or removes the flag, and removes it then.

Column of mailbox_flagged_deletes What it records
Id The row's own identity
MailboxAccountId, MailFolderId The account and the folder binding. The binding's foreign key cascades, so a folder that is gone takes its rows with it
UidValidity, Uid The occurrence still on the server. ix_mailbox_flagged_deletes_occurrence is unique over the folder and the two, so a settlement replayed after a commit conflict writes one row
StoredEmailId The local row the disposition kept, and null when it erased the copy. The foreign key cascades
LastObservedAt When a run last asked about the occurrence. ix_mailbox_flagged_deletes_queue is (MailFolderId, UidValidity, LastObservedAt), the order a bounded run reads them in, longest unread first

A row holds no part of the message: a position in a mailbox and MailFathom's own identity for a row.

On stored_emails, authored_delete_flagged_at marks a kept row whose message still carries the \Deleted a FlagDeleted delete set. Every mailbox query excludes such a row unless is_retained_after_authored_delete keeps it readable, and the reconciliation window skips it; the marker is cleared when the server removes \Deleted.

What a person set about their own client

client_preferences holds one row per user, carrying what that person set about their own client so that it follows them between machines rather than staying in the browser profile or the desktop install they set it in. There are three of them today: whether this deployment may be told what their client is doing, what the client is painted in, and whether opening a message opens a tab.

Column of client_preferences What it records
UserId The user whose preferences these are, and the primary key. It is also the foreign key onto settings_accounts with ON DELETE CASCADE: one person has one set of preferences and nothing else identifies them, so the key a caller already holds is the key the row is written under
Document The preferences, as one sparse jsonb document. Nothing queries into it. A key the document does not carry reads as that preference's own default rather than as an empty value, which is what lets a build publishing one more preference read a document written before it existed
CreatedAt, UpdatedAt When the person first set anything about their client, and when they last changed it — which is the first instant until they do

It is a table of its own rather than a second column on settings_accounts, because what it holds is not configuration. Nothing binds it against a deployment's files, nothing about it decides which mailboxes are read, and a person whose mail accounts an administrator still maintains writes here freely while the record above goes on refusing them.

There is no version column, and that is the contract. A write is an upsert on the key and the last one wins, because the only writers are one person's own devices: two of them disagreeing about a switch they both set is not a loss, and a superseded refusal would be a conflict screen over a checkbox. The write is one statement — an INSERT … SELECT from the user row with ON CONFLICT … DO UPDATE — so a user this deployment no longer holds affects no row rather than raising a constraint violation, and two devices arriving at once cannot both read nothing and then collide on the key.

Erasing a user takes it with the cascade, like the user's own half of the contact book and unlike the tables the erasure names by hand: it keys onto the user row and records no mail account, so nothing has to know this table exists.

stored_files holds binary files a user supplied and a record links to rather than holds — today the picture the client draws them by on the portrait routes. The user record carries the link as Portrait, the file's identifier; the octets are held the way a mail payload's are, so a megabyte of image never rides along with a read of the record.

Column of stored_files What it records
Id The identifier the deployment minted when the file was written, and the primary key. It is what the record's link names
UserId The user the file belongs to: the foreign key onto settings_accounts with ON DELETE CASCADE. Every read and removal names it, so a file of somebody else's reads as absent, and a record write naming a file this column does not assign to that user is refused
MediaType The media type the file is served under, which the write proved from the octets' signature before the row existed
ByteLength, Sha256Hash The length and SHA-256 digest of the octets
Backend, Content, ObjectLocator, ObjectVerifiedAt Where the octets are held, under the same check constraint and the same partial unique index on the locator as every content table: in Content when the database holds them, in the object ObjectLocator names when the object backend does. The move of stored content carries a file like a mail payload, and a release frees its retained copy the same way
CreatedAt When the file was written, which the sweep's age floor is measured from

A file is written once and removed, never rewritten. Replacing a portrait writes a new file, links it, and then removes the file it displaced, so a failure between any two steps leaves at most a file nothing links to. A sweep removes those once they are an hour old, at most a hundred a run, on whichever replica holds its lease; a file its owner's record links to is left alone however it was found. Erasing a user reads the object keys of their files before the cascade takes the rows, so the objects go with them.

What happened while nobody was looking

notifications holds what a person is told about — a synchronization run that brought them mail, and the system conditions that run distinguishes. It belongs to the deployment rather than to a device, because the read state has to be the same in both heads and on a second machine, and because most of what produces a row is visible only to the service.

Column of notifications What it records
Id What addresses the notification, a UUIDv7 minted from the instant it describes
UserId The user it happened to. It is the foreign key onto settings_accounts with ON DELETE CASCADE, for the reason client_preferences keys the same way
Kind Which part of MailFathom it is about — Mail, Calendar, Case, Task, or System — stored as text
Title, Body The two lines a row is drawn with in English, derived when the notification was produced rather than by re-reading mail when it is displayed
Cause The condition the row was raised for — MailArrived, SynchronizationIncomplete, CredentialRefused, CalendarReminderDue, or TaskReminderDue — stored as text. It is what lets a client say the row in its reader's own language, the two lines above being that same condition written out. Absent on a row written before the column existed, which is what an upgrade over existing data leaves until retention has taken those rows
Counted, OutOf The numbers the cause is stated with, whose meaning is the cause's: mail counts the messages that arrived, an unfinished run counts the folders that did not finish out of the folders it scheduled, a due reminder counts the minutes between now and what it is about — the event for CalendarReminderDue, nine in the morning on the due day for TaskReminderDue — and a refused credential counts neither
Source What the source line names beyond the kind, which is an account identifier today, and absent where the kind is the whole of it
TargetKind Which of the five shapes opening it leads to — Nothing, Message, Screen, CalendarEvent, or PersonalTask — stored as text
TargetStoredEmailId The message a Message target names, and the foreign key onto stored_emails with ON DELETE CASCADE. Absent for every other shape
TargetScreen The screen a Screen target names — Mail or Settings — stored as text. Absent for every other shape
TargetCalendarEventId The event a CalendarEvent target names, and the foreign key onto calendar_events with ON DELETE CASCADE, so a deleted event takes the reminders it raised. Absent for every other shape
TargetPersonalTaskId The task a PersonalTask target names, and the foreign key onto tasks with ON DELETE CASCADE, for the same reason: a reminder about work nobody owes any more is not a row to keep. Absent for every other shape
DeduplicationKey MailFathom's own name for the condition the notification was raised for
OccurredAt When the thing it describes happened
IsRead Whether the person has read it, which is also what frees the condition to be said again

A row carries no mail. The one exception is a reminder's title, which is what the person called their own event and is theirs rather than a third party's; everything else is MailFathom's own sentences about a count or a condition, the cause and its two numbers are that same condition as a name and two counts, the source is an account identifier, and the key is a condition's name — so no subject, address, body fragment, filename, or credential material reaches the table. What still makes it derived personal data is that it says something reached this person's mailbox and when, which is what the two cascades and the retention bound answer for.

Two cascades reach it, and they answer different obligations. The user's row takes their notifications with them, so an erasure request never has to name this table — which matters here because the table records no mail account and the erasure walk enumerates the tables that do. And a stored message takes the notifications that lead to it, so nothing can leave a row pointing at mail that is gone. That second cascade is why the message is an association here where mailbox_mutation_audit_entries deliberately keeps its own as a plain value: a trail records an act and has to outlive what it acted on, while a notification only offers to open something.

Saying one condition twice is refused by the schema rather than checked for before the insert. ix_notifications_user_unread_condition is unique over (UserId, DeduplicationKey) and filtered to NOT "IsRead", so a condition already standing unread cannot be raised again and one the person has read is free to be said again when it recurs. Being partial is also what makes it the index an unread count is answered from, since that count is one user's rows in it. ix_notifications_user_occurred covers (UserId, OccurredAt, Id), which is the centre's own page order and the order the retention sweep erases in.

The key is composed from MailFathom's own word for the condition and the account it is about, and it is bounded at 256 characters while nothing bounds a configured account identifier. An identifier too long to fit is therefore replaced by a digest of itself rather than truncated, because two accounts sharing a long prefix would otherwise share one condition and silence each other's statements; the same identifier is left off the row's source line entirely, since a label that cannot be shown is better absent than shown as an account nobody configured.

A notification is kept for thirty days after the thing it describes happened. The bound is the record's own rather than an operator's setting, because a notification is the client's working state rather than a history a deployment undertakes to hold, and the sweep rides each account's own synchronization run beside the audit-trail retention passes. A month is what a working set is: long enough that somebody back from leave still finds what happened while they were away, and short enough that the table never becomes the thing the bound exists to prevent — three months of a person's arrivals is their mailbox in miniature.

What a person owes

tasks holds a personal list: what somebody entered for themselves, and what MailFathom read out of their mail and is offering them. It is native to this deployment in the strong sense — no external task-management protocol is spoken, chosen, or synchronized against — so the list a person sees is the rows below and nothing else. It belongs to the deployment rather than to a device, for the reason notifications does, and it is a personal list rather than a shared board: no column assigns work to anybody but the person whose list it is.

Column of tasks What it records
Id What addresses the task
UserId The person whose list it is on. It is the foreign key onto settings_accounts with ON DELETE CASCADE, for the reason notifications keys the same way
Title The line the list is drawn with, bounded at 200 characters
DueOn The day it is due on, as a date, and absent where nobody has said when. A day rather than an instant, because what a person owes is owed on a date; a reminder against that date is what carries a time, and it is a separate record
DueDayOffsetMinutes The whole-minute UTC offset the due day runs in, as the client that wrote the reminders stated it, and null on a task announcing nothing. A column rather than a deployment setting because this deployment keeps no timezone for a person, and nullable because a task with no reminder has no hour to place — a row carrying leads and no offset is one an older build wrote, and it reads back as a task announcing nothing rather than as reminders measured from an hour nobody chose
Origin Where the task came from — Asserted for one the person entered or accepted, Proposed for one read out of mail and not yet committed to — stored as text
IsCompleted Whether the person has done it
SourceStoredEmailId The message the task was read out of, as a plain value carrying no foreign key. Absent where the task cites none, which most do

Accepting a proposal moves Origin and writes no second row. That is what keeps a commitment and the suggestion it came from one task: whatever already points at the row — a reminder, a citation — still points at it afterwards, and a list cannot show the same commitment twice because it was agreed to. Reading the two apart is an equality on that column rather than two tables.

The citation is a value rather than an association, and that is what lets a task outlive the mail it came from. Every association to a stored message's identity cascades but for a reply's own parent, so a task that named one would be erased with the message — and a commitment read out of a thread is still a commitment once the thread is gone, so a cascade here would quietly delete work somebody still owes. mailbox_mutation_audit_entries keeps its own message the same way and for the same shape of reason, and the payload of a jobs row names a message the same way too. The cost is the one those two already carry: nothing constrains the column, so a reader resolving a citation whose message has been erased finds nothing under that identity and says so. That is the answer a task wants — the mail this came from is no longer here — where notifications, which only offers to open something, is erased outright by the cascade it does carry.

Completing a task and erasing one are each a single state change. Completion moves one column, and an erasure takes the row rather than marking it gone: a task nobody owes any more is not a record anything is owed about, and keeping one would leave every reader of the list having to remember to exclude it. Both are idempotent — asking for a state a task already stands in writes nothing, and erasing something already erased is the act the caller wanted.

What announces a task

task_reminders holds the leads one task's due date is announced at, one row per lead, keyed on the task and the lead together — the same shape calendar_event_reminders carries and read by the same pass, which reminders describes.

Column What it records
PersonalTaskId, MinutesBefore The task and how long before its due hour, together the primary key — so one task states each lead once
DueAt The instant that lead currently falls at, derived when the row is written: nine in the morning on DueOn, read in the offset DueDayOffsetMinutes states, less the lead. Written rather than computed on read so the pass asks the database which reminders have come due instead of reading every list to find out, and rewritten whenever the due date moves
RaisedForDueAt The instant this reminder was last announced for, and null while it stands unannounced. The claim is made against the instant for the reason the calendar's is: a due date moved forward is due again at its new time, and one moved back onto an announced time stays quiet

The foreign key onto tasks cascades, so deleting a task takes what would have announced it with it. Whether the task is completed is not a column here, and deliberately: the pass reads it through the association, so finishing a task early silences its reminders without writing to any of them, and reopening one restores them the same way. A reminder already announced is left announced, because what was said was true when it was said.

ix_tasks_user_due covers (UserId, DueOn, Id), which is the order the list is both read and drawn in: one person's tasks soonest due first, with PostgreSQL's own NULLS LAST putting the undated ones at the end and the identifier keeping two tasks due on one day in a stable order across reads. That pair is also the keyset a page continues from, so a list longer than one page is walked by position rather than by offset — which matters on a list somebody edits while they read it, since dating or completing a task between two pages would shift an offset window and repeat or skip a row on every page after it. Continuing from a boundary with no day walks the undated block alone, because nothing in this order comes after it. The groupings a screen shows — today, this week, later — are derived from DueOn against the reader's own day rather than stored, so nothing can say one thing in the column and another in the group.

What a user signs in with

user_credentials holds every credential a user authenticates to the client, the MCP endpoint, and the administrative endpoint with. Those are records rather than settings, which is why they are a table at all: a credential belongs to one person and is provisioned, rotated, suspended, and removed while the deployment runs. The administrative endpoint is the surface these rows are administered through.

Column What it records
Id The credential's identity, and the primary key. It is what an audit record, a rate-limiting partition, and a diagnostic name — so each of those names a credential without naming a way to sign in
UserId The user this credential authenticates, a uuid foreign key onto settings_accounts that cascades. It is what an admitted request acts for: a credential that resolves no user admits nobody, and is refused exactly as an unknown one is
Method Which of the four ways in this credential is — password, api-key, public-key, or oauth-subject — as the published name rather than an ordinal. It is half of what a presented credential is resolved by, so one value may be held once under each method without either shadowing the other
Lookup The one indexed value that method resolves a credential by, at most 512 characters: the username folded to lower case for a password, a digest of the key for an API key, the fingerprint of the registered public key for a key pair, and the issuer and subject together for a mapped subject. Unique with Method and OrganizationId rather than within the user, because it is what a presented credential is resolved by and nothing else in the request says whose it is — so a username is unique within one organization or among the credentials in none, and every other method's value is unique across the deployment. A colon cannot appear in a username, since that is where RFC 7617 splits the header, and neither can a /, since that is where a login separates the short name from it
OrganizationId The organization a password credential is scoped to, nullable, and a foreign key onto organizations that restricts deletion. It is null for somebody in no organization and for every other method, which a check constraint holds: only a password is scoped to one. It names the organization by identifier rather than by short name, so changing a short name moves every member's login and rewrites no credential, and moving a user between organizations rewrites it for their passwords in the same transaction
Material What a presented secret is verified against, and nothing a client could present. For a password that is the versioned hash record — the format version, the algorithm, the work parameters, the salt, and the derived key, as one string, so a later release moves to another algorithm without rewriting anything; for a key pair it is the registered public half. An API key has none, because the digest in Lookup is the whole verifier, and neither does a mapped subject, which states whose token this is rather than holding anything to check
Permissions The names this credential keeps of its user's grant, as published permission names, or null where it names none and holds exactly what its user's roles grant. An empty set keeps nothing and reaches no tool. A name the user's roles do not grant is kept and grants nothing
Surfaces The endpoints the credential may be presented on, as a text[] of published names — mcp, client, admin — defaulting to mcp and client, so a credential reaches the administrative endpoint only where it was provisioned to. A request presenting it anywhere else is refused as an unknown credential is
AllowedSourceNetworks The networks a request presenting it must arrive from, as a text[] of addresses and CIDR networks, at most 32, and empty — the default — for anywhere. Compared with the client address the forwarded-headers policy resolved, an IPv4-mapped address in its IPv4 form
Enabled Whether it still authenticates requests. A disabled credential keeps everything about it, so the value it is resolved by stays claimed and the decision is one command away from being reversed
Version A counter every write to the row increments. It is what a listing reports so an administrator can see that a credential changed since they last read it; nothing reads it back to decide whether a write may proceed, so it orders the writes to one row rather than excluding any of them
CreatedAt When the credential was provisioned
MaterialChangedAt When what the client presents was last replaced. A rotation moves it; the rehash the deployment performs on its own when a password record falls behind the current work parameters does not, because nothing about the password changed

Three indexes and no more: the unique one on (Method, OrganizationId, Lookup), with nulls not distinct so the credentials scoped to no organization stay unique among themselves, which is the read every authentication performs; IX_user_credentials_OrganizationId on OrganizationId, which the restricting foreign key to organizations reads when an organization is removed; and one on (UserId, CreatedAt), which is the listing an administrator reads. That listing is bounded at 100 credentials per user, which is a ceiling rather than a number anybody reaches — and it is the same ceiling provisioning enforces, in the insert itself rather than in a count read beforehand. Two administrators provisioning at the same instant cannot leave a user above it either: the insert runs in a transaction that first takes a row lock on the user's settings_accounts row, so the second one counts what the first committed rather than what it had read before. A row past the bound would authenticate where nothing lists it, and therefore where nothing could be revoked from; the hundred-and-first credential is refused with 409 instead.

No secret appears here or anywhere else. A password is stored as a derivation and an API key as a digest, each read within the call that reduces it and retained nowhere; a public key and a mapped subject are not secrets to begin with. No answer, log line, metric, audit record, command argument, or refusal carries a presented value — a refusal names the rule the password broke rather than the value, and a minted key is printed once by the command that minted it and never again. Verification is constant-time, and a request naming a username or an organization this deployment does not hold is verified against a decoy record so that an unknown login and a wrong password cost the same and are refused identically.

Removing a user removes these with the rest. The cascade from settings_accounts takes them, which is what the foreign key is for: a person erased from the deployment leaves nothing behind that could still be signed in as.

The roles, groups, and assignments a grant is read from

Five tables hold what a user's grant is computed from under ADR 0012: a role is a name and a list of permissions written as names and patterns, a group is a set of users, and an assignment gives one role to one user or one group at one scope. They are rows rather than settings so a change to any of them is the same on every replica from the moment it commits. A caller on a mail surface holds what they grant its user, kept to what its credential names — how a caller's grant is computed.

roles holds one row per role: Id, a version 7 identifier; Name, at most 128 characters and unique across the deployment under ix_roles_name, compared exactly; and CreatedAt. role_permissions holds the role's list, one row per entry keyed by (RoleId, Permission), so a role lists an entry once, and cascading from its role. An entry is a published permission name or a pattern, and Permission holds either exactly as it was written. A pattern is resolved against the set the reading build publishes whenever a grant is computed, so no row changes when a release publishes a name within one's reach, and two builds serving one database each grant what their own publishes there. An entry is written only when it grants something in this build: a name it publishes, or a pattern reaching at least one. One stored entry that comes to grant nothing — a name a later build no longer publishes, a pattern left reaching nothing — is read back beside the role as unpublished, rather than making the whole role unreadable.

The migrations seed three roles, as ordinary rows an operator may rename, edit, or delete:

Role What it lists
Mail user Every name the user-facing half published when it was seeded, carried to the names those are published under now
Organization administrator mailfathom.admin.read, mailfathom.admin.audit.read, mailfathom.admin.operate, mailfathom.admin.credentials.write, mailfathom.admin.configuration.write, mailfathom.admin.erase, and mailfathom.admin.roles.write
Administrator The pattern * alone, which reaches every name both halves publish, a name a later release adds included

RewriteAdministratorRoleAsAPattern is the migration that wrote that pattern, in place of the names the seeding migration listed, and only where the role still listed exactly those names. A seeded Administrator an operator had narrowed, emptied, or deleted was left as it stood, because rewriting it would have handed its holders every permission they were deliberately denied. It changes no table: whether an entry is a name or a pattern is decided when a grant is computed. No migration widens either of the other two.

SplitUserFacingPermissionsByDomain is the migration that carried every stored list — each role's, each credential's narrowing, and each session's — to the names the user-facing half is published under, and it changes no table either. A renamed name is rewritten where it stands; a list that reached mailfathom.mail.read holds the names of the task list, the calendar, the notification centre, and the profile beside it; and one that reached mailfathom.mail.accounts.write holds mailfathom.profile.write. A role's pattern is carried by what it reached, so the names a role held through one are written out wherever its list no longer reaches them, and a role listing * alone gained no row. It treats every role alike, seeded or not, because what it carries is the reach of a name rather than anybody's decision about a role. It carries what was stored when it ran and nothing written afterwards, so a list a replica of the build before it wrote during a rolling upgrade — a session signed in there, above all — holds the names that build knew until it is replaced.

The migration that moved mail grants from credentials onto users, HoldMailGrantsOnUsers, gave every user who held no assignment one at their own scope reproducing the union of what their credentials listed: Mail user where that union was the whole user-facing half — and for a user holding no credential, whom only an endpoint requiring none could have served — and otherwise a role of its own, Carried-over mail grant <n>, one per distinct union and numbered in the order of the names it lists. A user whose credentials all listed nothing was given nothing. The same migration recorded no narrowing on every credential whose list held the whole user-facing half, so it holds what its user holds. Those roles are ordinary rows like the seeded ones.

user_groups holds one row per group: Id; Name, at most 128 characters and unique across the deployment under ix_user_groups_name; OrganizationId, the organization the group belongs to or null for none, as a foreign key onto organizations that cascades; and CreatedAt. user_group_members keys one membership by (GroupId, UserId) with the instant it was added, cascading from the group and from settings_accounts. A group in an organization holds only that organization's members, which the write adding a member checks under share locks on the group and the user rather than a constraint, for the reason the account's own organization rule is not one: a null on either side would leave a composite key unchecked.

role_assignments holds one row per assignment:

Column What it records
Id The assignment's identity, which a revocation names
RoleId The role given, a foreign key onto roles that restricts deletion: removing a role still assigned would take the grant from everybody holding it as a side effect, so it is refused naming how many assignments stand in the way
PrincipalUserId The user the role is given to, when the principal is a user, as a foreign key onto settings_accounts that cascades
PrincipalGroupId The group the role is given to, when the principal is a group, as a foreign key onto user_groups that cascades. Removing a group that is still assigned is refused by the write that removes it, under the group's row lock, naming how many assignments stand in the way; the cascade is what an organization's removal takes with its groups
ScopeOrganizationId The organization the assignment reaches, when its scope is one, as a foreign key onto organizations that cascades
ScopeUserId The user the assignment reaches, when its scope is one, as a foreign key onto settings_accounts that cascades
AssignedAt When the role was given

Two check constraints hold the shape: ck_role_assignments_one_principal sets exactly one principal column, and ck_role_assignments_at_most_one_scope at most one scope column, neither meaning the deployment. The unique index ix_role_assignments_role_principal_scope over the role and all four columns has nulls not distinct, because every row leaves three of the four null and an index treating each null as distinct would admit the same assignment twice — the one at the deployment scope above all. It leads with RoleId, so it is also what the count refusing a role's deletion reads; each of the other four foreign keys has an index of its own, which its cascade and the group's refusal read.

Removing a user or an organization takes every membership and assignment naming it with it, in the statement that removes it: an organization is removed only once nobody belongs to it, so its groups are empty and leave with it.

The default administrator

default_administrator records that this deployment created its default administrator and whether the password setting was ever applied to it. It holds one row at most, which ck_default_administrator_single_row keeps by allowing Id to be 1 alone, so every replica starting at once contends for the same key: the one whose insert wins records the user, its endpoint switches turned off, and its Administrator assignment at deployment scope in the same transaction, and every other reads what it wrote.

Column What it records
Id A smallint primary key, always 1
UserId The default administrator, a nullable uuid foreign key onto settings_accounts with ON DELETE SET NULL. Null means the user was removed, which is final: the row stays, so no later start records the user again
RecordedAt When the first start recorded it
PasswordSettingAppliedAt When a start applied MAILFATHOM_ADMIN_PASSWORD, or found the user already holding a password credential and recorded the setting as applied instead; null until then. Once set, every later start ignores the setting

IX_default_administrator_UserId indexes UserId, which the foreign key reads when a user is removed.

Clearing PasswordSettingAppliedAt and deleting the user's password credential row is the recovery an operator locked out of every administrative account performs by hand, and deliberately the only one: no route reaches either column.

The assertions this deployment has already served

spent_client_assertions is what makes a captured client assertion unusable a second time. A valid signature is not by itself a reason to serve a request — an assertion travels over the wire like any other bearer credential — so an identifier already served is refused, which is the one thing a short lifetime alone cannot do.

It is a table rather than a field in a process because the property is the deployment's. An identifier spendable once per replica is not spendable once at all: the replica that refuses a replay is not the replica the next presentation reaches, so raising replicaCount would otherwise reopen the window without anything saying so. ADR 0031 records that, and records why session affinity is not an answer to it — affinity is honoured by the client, and the client here is whoever captured the assertion.

Column What it records
CredentialKey What identifies the credential that verified the assertion, at most 64 characters, and the leading half of the primary key. A user's registered key is named by its 43-character fingerprint and a configured one by the name an operator gave it; the two vocabularies cannot collide, and the scoping is what stops one client from spending an identifier another was going to choose
Identifier The assertion's own jti, as the client minted it, at most 128 characters — the bound both authenticators already refuse past. It is the second half of the primary key, and that pair being unique is the anti-replay rule itself: the spend is an insert that either happens or conflicts, and which of the two it was is the whole answer
ExpiresAt When the assertion stops being accepted, which is when the row stops being needed. It is the one indexed column beside the key, and the index is what makes the removal proportional to what has expired rather than to everything ever spent

Nothing here is mail, and nothing an unauthenticated caller sends reaches it. Only an assertion whose signature already verified is recorded, so a row is a credential's own name, a value a client minted for one request, and an instant — no message, no header, no request, and no key material. There is no foreign key onto the user record either, because the credential column holds a configured key's name as readily as a registered key's fingerprint and belongs to neither.

It cannot grow without bound. An assertion lives at most five minutes, and the removal is what keeps the table proportional to the traffic of the last few of them. The surface's rate limit is not part of that bound on the MCP surface: authentication runs ahead of the limiter there, so a client presenting freshly signed assertions above its permitted rate writes a row per request and is refused afterwards — the limiter bounds what is served rather than what is inserted. On the administrative and client surfaces the credential is judged behind the limiter, where it does bound both. A row is dropped by the first sweep after the point past which its assertion can no longer be presented, which is its recorded expiry plus the skew the validator tolerates, so a row outlives that point by up to one more permitted lifetime rather than ending with it. Each replica issues its own removal, once per that lifetime, from its own interval — there is no deployment-wide sweep, and two replicas each issuing a bounded delete every few minutes is cheaper than anything that would have to coordinate them. The sweep runs on the authentication path rather than on a timer, so a deployment whose assertion traffic stops keeps whatever rows it held at that moment until the next assertion arrives. A cap with an eviction policy would be worse than none: evicting a row that has not expired is precisely the replay this exists to refuse.

The unspent signal connection tickets

client_signal_tickets holds the single-use tickets a client's live signal connection is opened against. A browser cannot put a header on a WebSocket, so the connection carries a ticket instead: an authenticated route mints one, the client hands it to the connection, and the hub spends it.

It is a table rather than a dictionary in a process because a load balancer places the mint and the connection independently — the connection skips negotiation precisely so that nothing has to route the two together — so a ticket held in the process that minted it would be redeemable about one time in the replica count, silently. ADR 0032 records that, and records why the ticket is not kept in the optional signal backplane instead: an authentication path must not depend on a component a deployment may not run.

Column What it records
Identifier The public half of the ticket, as the minting replica drew it — the base64url of sixteen random bytes — at most 64 characters, and the primary key. It is what a presentation is looked up by, and the row being removed by the presentation that finds it is the single-use rule itself: the spend is one DELETE ... RETURNING and the returned row is the whole answer
UserId Whose connection the ticket opens. It is the foreign key onto settings_accounts with ON DELETE CASCADE, for the reason client_preferences keys the same way: a ticket is minted for one person and names nobody else
SecretDigest The SHA-256 digest of the ticket's secret half, 32 bytes. The secret itself is never stored, so a row read out of the database or out of a backup opens no connection; the presented secret is hashed and the two digests compared in constant time
ExpiresAt When presenting the ticket stops working, thirty seconds after it was minted. It is the one index beside the key and the foreign key's own, and the index is what makes the removal proportional to what has expired rather than to everything the deployment holds

Nothing here is mail, and only an authenticated request writes a row. A request that already authenticated against a credential holding mailfathom.mail.read is the only thing that produces one, so a row is a generated user identity, a digest, and an instant — no message, no header, no address, and no credential. A value an unauthenticated caller presents reaches this table in one place only: as the identifier the spend is parameterized by, once the connection it arrived on has been refused for anything without a ticket's shape and admitted under the replica's bound on redemptions in flight. It is read back rather than stored.

It cannot grow without bound, and two things hold it. A ticket lives thirty seconds, and the removal keeps the table proportional to the connections opened since the last one. Beside that is a ceiling on how many unspent tickets the deployment holds at once, counted in the same statement that writes the ticket — so it is the deployment's number rather than one each replica finds room under separately, and a mint past it answers 503 rather than growing the table. Reaching it is a refusal rather than an eviction, because evicting somebody else's live ticket would turn one caller's noise into another caller's failed connection. The sweep runs on the minting path rather than on a timer, at most once per ticket lifetime per replica, so a deployment whose clients stop connecting keeps whatever rows it held at that moment until the next mint arrives.

The signed-in client sessions

client_sessions holds the sessions a client signed in with, one row per live token. The exchange mints one when a credential authenticates, every authenticated request on the client surface is judged against it by one indexed read, and a renewal replaces the row with another carrying the same grant.

It is a table rather than a dictionary in a process for the reason the tickets above are one, and for a second reason they are not. A load balancer places every request independently, so a session held by the replica that minted it would be refused on roughly one request in the replica count, which a client meets as being signed out. And an operator disabling a credential would end its sessions on the replica that received the administrative request and leave them working on every other one, so an operator told that somebody's access is gone would be told something false. ADR 0033 records both halves of that, and records why nothing caches what this table answers.

Column What it records
Identifier The public half of the token, as the minting replica drew it — the base64url of sixteen random bytes — at most 64 characters, and the primary key. It is the only half a statement looks a session up by
UserId Whose session it is. It is the foreign key onto settings_accounts with ON DELETE CASCADE, which is what an erasure reaches a session by even where no credential stands behind one
CredentialId Which credential admitted the sign-in, nullable, and the foreign key onto user_credentials with ON DELETE CASCADE. It is null for a session minted on an endpoint requiring no credential, because such a sign-in names no row an operator could act on and a foreign key cannot take a sentinel
Permissions The narrowing the credential applied at the exchange — every name the user-facing half published where it named none — carried forward unchanged by every renewal. It is never the grant itself, which is computed from the user's roles on every request, so a role assigned or revoked reaches the session at its next request
SecretDigest The SHA-256 digest of the token's secret half, 32 bytes. The secret itself is never stored, so a row read out of the database or out of a backup authenticates nothing. Verifying a request reads the row and compares the two digests in fixed time; a renewal and a revocation instead carry the digest in the removing statement's own condition, which is what makes the removal and the judgement one act rather than two a second request could arrive between
ExpiresAt When the token stops working, thirty days after it was minted. It is the one index beside the key and the two foreign keys' own, and the index is what makes the removal proportional to what has expired rather than to everything the deployment holds

Nothing here is mail, and a row is written by a sign-in or by a renewal and by nothing else. A session names a generated user identity, a credential identifier, the permissions that credential held, a digest, and an instant — no message, no address, no device, and no credential material. A value a client presents reaches this table in one place only: as the identifier the read and the two removals are parameterized by.

An operator's act and a sign-in are ordered rather than raced, and the lock order is what orders them. A mint and a renewal each take the user row and then the enabled credential row before they write the session, holding both until they commit; disabling a credential clears the flag and removes that credential's sessions in one transaction. So a disable arriving first leaves the sign-in matching no enabled credential, and one arriving second waits for the sign-in and then removes what it wrote. The two cascades carry the rest: deleting a credential takes its sessions, and erasing a person takes every session of theirs including the ones no credential stands behind.

It cannot grow without bound, and two things hold it. The removal of what has expired keeps the table proportional to the sessions signed in over the last thirty days rather than to every sign-in ever made, and it runs on the reading path as well as the minting one, at most once a day per replica, because abandoned sessions accumulate where nobody is signing in. Beside that is a ceiling of ten thousand live sessions, counted in the same statement that writes one — so it is the deployment's number rather than one each replica finds room under, and raising the replica count does not multiply it. A mint that meets it sweeps and tries once more, and answers 503 rather than growing the table. Reaching it is a refusal rather than an eviction, because evicting somebody else's live session would turn one caller's noise into another person being signed out.

The derived search document

email_search_documents is one-to-one with stored_emails and holds what lexical search reads: subject_text, participant_addresses, body_text, body_text_before_trimming, text_source, extracted_at, and the generated search_vector. Body text and the lexical index describes how each of them is derived. Every stored email has one, including a message whose body was never read: that row carries the envelope's subject alone and records its text source as not extracted, so an oversized or unparseable message is still findable rather than absent from search entirely.

It is a table of its own for the reason raw MIME is. The text is large, and a timeline query that materialized a stored-email row would otherwise carry a body and its search vector through the change tracker on the way to a view that shows neither. Two reads reach it and both cut it in PostgreSQL rather than materializing a column: lexical search, for the snippets it highlights, and the preview a list row shows, which asks for the opening of body_text for the rows one page returned and finds them by identity. Deleting a message cascades to it, so everything derived from a message is erased with the message.

subject_text and participant_addresses are bounded copies rather than references to the columns of the same name on stored_emails. A PostgreSQL generated column must be immutable and can only read its own row, and the array-to-text functions that would flatten the recipient arrays are merely stable — they call element output functions that need not be immutable. Copying the two values into this row at write time keeps the column's expression trivially immutable instead of requiring a custom SQL function, which no migration exists to create.

SensitiveContentStamp is character(64) and records the sensitive-content configuration this row's text was derived under: a digest of the scanners that ran, their corpus and profile revisions, the categories switched on, the rules suppressed, and the analyzed ceiling, which is the one input that belongs to no scanner and decides how much of a message was inspected at all. It stands for everything below the message as well as the row it sits on — the chunks cut from this text and the vectors built from those chunks descend from it, so one value answers for the whole derived tree and no write has to stamp a row whose content did not otherwise change. Null is the ordinary value: it means the text was derived while no scanner was on, and it is what every row holds on a deployment that scans nothing. Derived data states what moves the value and what re-derives a row that no longer matches; backfill_positions carries a column of the same name for the same reason, so a walk resumes only within the configuration it was walking under.

It carries no index, deliberately. Both readers ask which rows are not stamped with the current configuration, and a B-tree operator class holds no inequality operator, so an index over the column could serve neither: the staleness count and the rebuilding walk both scan. That is a figure read once per start and a walk that reads whole rows anyway, against an index every synchronized and every re-derived message would otherwise maintain.

The copies are bounded more tightly than the columns they come from: 2000 characters of subject and 64 participant addresses in total. A tsvector cannot exceed one megabyte, and the whole document — subject, addresses, and up to MaxExtractedTextCharacters of body — shares that budget. Exceeding it would not degrade search; it would make the row unwritable, because the generated column is computed on every insert.

Message chunks

email_chunks holds the passages a message's extracted text was cut into, many rows per stored email. Each carries its Ordinal in reading order, the StartOffset the passage begins at in the extracted text, the Text itself, a ContentHash of character(64), the RuleSetVersion it was cut to, whether it IsDerivedFromLossyHtml, and when it was DerivedAt. Message chunks describes the boundary rules and what the hash covers.

The key is a surrogate UUIDv7 rather than the email and the ordinal together, because a vector row will hang on one chunk and a composite key would put a re-cut message's ordinals into every table that references it. The pair is ix_email_chunks_email_ordinal instead, unique, which is what a reader of one message's passages orders by and what stops a re-cut from writing an ordinal twice.

AttachmentPosition is the one column that says which text a passage is a span of: null for a passage cut from the message's own body, and the attachment's zero-based walk position for one cut from a file. It is a nullable column rather than a second table because ADR 0029 keeps both one kind of passage in one vector space, so a single search over a message and its attachment is one ranking rather than two fused. The media type and the page a passage sits on are deliberately absent from this row: the first is on the attachment's own row and already inside the digest, and the second is resolved at read time from the passage's offset against the boundaries that row stores.

The uniqueness above is therefore two filtered indexes rather than one. PostgreSQL treats two nulls as distinct, so extending ix_email_chunks_email_ordinal to include AttachmentPosition would enforce nothing at all for a body passage — every one of which carries none. The pair is instead ix_email_chunks_email_ordinal, unique over the email and the ordinal WHERE "AttachmentPosition" IS NULL, and ix_email_chunks_email_attachment_ordinal, unique over the email, the attachment, and the ordinal WHERE "AttachmentPosition" IS NOT NULL. Each kind of passage numbers its ordinals from zero within its own text, and neither can be written twice.

Splitting them costs a third index, ix_email_chunks_email, unfiltered over StoredEmailId alone. PostgreSQL uses a partial index only where a statement's predicate implies the index predicate, so once both indexes over the pair carry a filter neither covers a statement that names the message and nothing else — which is what a cascade from stored_emails, a user erasure, and the discard behind a junk verdict all issue. Before the split the unique pair covered the foreign key and EF Core's convention created no index of its own; this restores that cover explicitly.

Reconciling a re-cut is per source for the same reason: a reading of an attachment that arrives after the body was already embedded replaces the passages of the attachment it read and touches nothing else, so no vector a mailbox already paid for is re-derived because a file was opened later.

Text is the one column here that no bound applies to. Its length is decided by the chunking rules rather than by a sender, and extraction has already bounded the text all of one message's chunks are cut from, so a column bound would add nothing except a write failure the first time those rules are tuned upwards. ContentHash is fixed-length text rather than bytea, unlike the raw MIME digest: this one is compared and read — re-chunking decides what to write by comparing digests — while the MIME digest only ever round-trips between one writer and one reader.

Only a message that yielded text has rows here, and deleting a message cascades to them.

stored_emails.ChunkedTextTruncatedFromCharacterCount is where the cut records what it left out: the length the extracted text had when the per-message ceiling stopped the cut short of its end, and null when no ceiling reached that message. It lives on the message rather than on a chunk because it is a fact about the message, and it is stored rather than inferred because a message cut whole and one cut to a ceiling are indistinguishable from their passages alone. Message chunks records what the ceiling is for.

What a message's attachments were read as

email_attachment_texts holds one row per attachment of a message whose attachments have been read, keyed on ("StoredEmailId", "AttachmentPosition") — the same zero-based walk position the download route is addressed with and the same one a citation resolves through. A row exists whichever way the reading went, so a file that was skipped says so rather than being absent: Outcome carries the word the port that read it published — one of the extractor's outcomes, Described or one of the describer's refusals, or MessageBudgetExhausted where the message's own octet ceiling stopped it before anything was opened. The count ceiling leaves no row at all, because it bounds the walk itself: a message declaring more parts than the deployment reads has the rest neither opened nor recorded, and the count on the message beside the rows stored is what says how many that was. Kind says whether the words are the file's own or a description of a picture, DeclaredMediaType and FileName what the part declared, Text the words themselves or null, PageCount how many places the document was read as, and DerivedAt when. Attachment text extraction records what each outcome means.

Segments is a jsonb document listing where each page, slide, or sheet begins in Text, each entry naming its kind, its one-based number, the label the format recorded if any, and its start offset. That list is what turns a passage's offset into a place a citation can name, and it is written here rather than re-derived because re-cutting a mailbox after a boundary-rule change then reads stored text and stored boundaries and opens no document again. It is null rather than an empty array where the attachment yielded no words. A redaction does not empty it: every boundary is carried across by the net length difference the placeholders before it applied, so a redacted contract keeps its pages, and the only boundary dropped is one past the point the scanner's analysis ceiling stopped reading — which names a place in text that was never examined and could not be published as anything but a guess.

SearchVector is a stored generated tsvector, and it is conditional: CASE WHEN "Kind" = 'Document' THEN to_tsvector(...) END, built from the file name and the text together. Two decisions are in that one expression. A document attachment joins the lexical index as a document of its own rather than as more text on email_search_documents, which is what keeps a message's own ts_headline snippet quoting only what the message said. And an image description reaches the vector index alone, which ADR 0030 decides — enforced by the column rather than by a writer, so a word a model chose can never be matched as though somebody had written it whatever a later writer does with the row. ix_email_attachment_texts_search_vector is the GIN index over it.

SensitiveContentStamp records the configuration these words were derived under, exactly as the search document's does, because a description and an extracted text are derived mail content like any other. It is judged against its own account's posture rather than against the message's document, since the body and the attachments are read by different stages: the startup report counts the rows whose stamp is not the current one, and a rebuild discards them, removes the passages cut from them, and clears AttachmentTextDerivedAt so the attachment stage reads the message again. Deleting a message cascades to these rows, so nothing read out of a file outlives the message it arrived on.

stored_emails.AttachmentTextDerivedAt is what takes a message out of the walk that reads attachments. It is written in the same statement as the rows above and the passages cut from them: a message stamped without its readings would never be offered to a parser again, and readings without the stamp would be taken a second time on the next run — and, for a picture, paid for again.

Where a conversation stands

email_thread_states holds one row per conversation a derivation has settled, keyed on the surviving thread — one state per conversation, so the key is the thread. Beside DerivedAt and the xmin row version it carries Coverage, one of WholeThread or ThreadTooLarge as text of at most 64 characters, and the pair DerivedFromMessageCount and DerivedFromLatestArrival describing the shape of the conversation the derivation was made from.

That pair is what stops a state going stale silently. A conversation has no row of its own that changes when a message joins it — a thread is the relation its messages declare — so the count and the newest arrival are compared against the conversation as it stands to decide whether the stored state still describes it. A conversation whose shape has moved is owed a derivation again; writing the new state takes it out of the selection. A conversation's state records what each half catches and the one membership change the pair does not.

The row existing is what takes the conversation out of the pass's selection, which is why nothing is written for a derivation that was withheld: a spent period allowance or an unreachable provider would otherwise remove a conversation from the queue for a condition that lasts an hour. A ThreadTooLarge row is a settled record rather than a withholding, so a conversation past the bound leaves the queue instead of heading every pass forever.

email_thread_state_entries holds the statements, a row each rather than four sets of columns on the state: the four aspects are the same shape and a conversation carries any number of each, so columns would have fixed a count per aspect in advance and a fifth aspect would have been a schema change rather than a value. Aspect is one of Agreement, OpenQuestion, Commitment, or VersionDifference, stored as text of at most 64 characters rather than as an ordinal. Text is bounded at 240 characters and OwedBy at 120, and both were shortened before they reached here rather than refused. OwedBy and DueAt are null on every aspect but a commitment, and on a commitment the conversation named nobody or no date for.

Ordinal is stored rather than derived, because the order is the producer's own — it names what matters most first — and a row order is not a property a table has. It is per aspect, and the index over the conversation, the aspect and the ordinal is what reads the statements of one aspect back in the order they were written.

Sources is a uuid[] of the messages a statement rests on, in the order the producer named them, rather than a table of its own: a statement's sources are read whole with it and never joined to, so a row per citation would have bought a join and a second ordinal to preserve an order the array already carries. What a query still does with it is ask which statements cite a message, which = ANY answers. A statement with no source is refused by the application before it reaches here, which is the one thing the block exists to rule out.

Both tables cascade from the conversation, so erasing a correspondence removes the block with it.

What a derivation concluded about a message

email_enrichments holds one row per message a derivation has settled, keyed on StoredEmailId alone — one derivation per message, so the key is the message. It carries only DerivedAt and the xmin row version, because everything the derivation concluded is in the rows beneath it and a message it concluded nothing about is a real answer rather than a missing row.

The row existing is what takes the message out of the enrichment pass's selection, which is why nothing is written for a derivation that was withheld: a spent period allowance or an unreachable provider would otherwise remove a message from the queue permanently for a condition that lasts an hour. Message enrichment records which conditions withhold and which settle.

email_enrichment_marks holds what it concluded, at most one row per aspect. Aspect is one of Sense, Significance, or Commitment, stored as text of at most 64 characters rather than as an ordinal, and ix_email_enrichment_marks_enrichment_aspect is unique over the message and the aspect — which is what makes "one reading of each kind" a constraint the database holds rather than a rule a writer follows. Text and Reason are each bounded at 240 characters, about two lines of a list row, and the mark that produced a longer one was shortened before it reached here rather than refused. DueAt is null on every aspect but a commitment, and on a commitment that named no date.

Source and Origin are the pair that makes a rule's verdict and a model's distinguishable in the data: the first says which kind of producer wrote the mark, and the second names it — a rule identity, or the name the agent was composed under. Both are text, and both are on every row rather than on the enrichment above them, because one message's marks may come from different producers and a record naming only the derivation would leave a reader unable to say which of them a particular mark rests on.

Evidence is a uuid[] of the passage identifiers the reading rests on, in the order the producer named them and at most four. It is an array column rather than a join table because nothing queries by it: it is read with the mark it belongs to and resolved through the same reader a Discover run's citations use, so a table would buy a join and an index nobody would use. There is no foreign key to email_chunks for the same reason a citation carries none — a passage a re-cut replaced resolves to nothing, which is a mark whose message was re-cut rather than a broken row.

Deleting a message cascades to the enrichment, and the enrichment to its marks, so a reading never outlives the mail it was derived from.

Embedding profiles

embedding_profiles holds one row per vector space this deployment has embedded into. The row is written by the activation that takes a declared model up and starts spending against it, and its columns are what a stored vector's attribution points at.

A profile is the geometry of a vector space and nothing else: Provider, ModelIdentifier, ModelVersion where the provider exposes one, Dimension, DistanceMetric, and the three columns that make up the input preparation — InputCharacterLimit, PassageInstruction, and NormalizesVector. Those are exactly the properties that decide whether two vectors can be compared. ADR 0006 is where each of them was argued.

Three things about that list are decisions rather than defaults.

The chunk boundary rules are not part of it. They belong to the chunk's own content hash, so a vector is attributable to both halves of what produced it — the chunk row says what text was embedded and under which rules, this row says what embedded it. Folding the rules in here would price a boundary change, which reaches no network, as a full paid re-embed of the mailbox. Message chunks describes the half this table does not carry.

Provider names the vendor whose model defines the space, not the endpoint it is reached through. That is what lets one profile be served by a chain of endpoints offering the same model, where the endpoint can fail over without the vector space changing underneath vectors already stored. It is a vendor-supplied name stored verbatim, like ModelIdentifier, because neither set is MailFathom's to close.

Dimension is the width the stored vectors actually have, never the model's nominal one. Where a model is narrowed to what the database can index, the narrowed number is what belongs here; a profile claiming the nominal width would be describing vectors that do not exist.

IdentityFingerprint is a SHA-256 digest over every column above, written as sixty-four lowercase hexadecimal characters, and ix_embedding_profiles_identity_fingerprint is unique over it. That index is what makes activation idempotent: re-declaring a geometry that is already registered resolves to the row that exists rather than inserting a second one whose vectors would be produced from scratch for nothing, so returning to a previous model is a switch rather than a duplicate. Every field of the digest is length-prefixed and every number is big-endian, and an absent optional value is written as a presence marker rather than skipped, so the encoding is one-to-one.

What stays mutable is the lifecycle: LifecycleState — building, active, or superseded — with RegisteredAt, and ActivatedAt and SupersededAt, each null until its event has happened. There is no generation counter. The profile is the generation, so two generations coexisting while a new one is built are two rows, and no read path has a second field it must remember to consult.

ix_embedding_profiles_lifecycle_state is unique over LifecycleState and partial to the two states that admit one row each, which is how one index expresses both halves of that: at most one generation being built, and at most one being read. Superseded rows are outside its predicate, because a deployment accumulates one for every model it has ever used. It is enforced by the database rather than by the code that writes, for the same reason the vector's width is: two rows claiming to serve would leave retrieval reading whichever one a query returned, with half the vectors in the table unreachable and nothing about the answers saying so. The one consequence for a writer is that the switch has to supersede the old row before it promotes the new one, which is why those two statements are issued in order rather than staged together. Changing the embedding model is the operator's view of that transition.

Nothing operational reaches this table. The endpoint address, the credential, the batch size, the request rate, the concurrency, and the spending ceilings are configuration, which is what makes rotating a key or raising a rate limit an edit rather than a re-embed — and what means no column here can be edited into disagreeing with the vectors it describes.

Stored vectors

email_embeddings holds one vector per chunk per profile. Its key is (EmailChunkId, EmbeddingProfileId), named pk_email_embeddings, because that pair is what a vector is: re-embedding a passage under the profile already serving it replaces the row rather than adding one, and the constraint is what an idempotent upsert conflicts on. Nothing references a vector row, so unlike a chunk it needs no identifier of its own.

Embedding is pgvector's dimensionless vector rather than vector(N). That is what lets two profiles of different widths share one table; declaring a width on the column would fix the whole table to one profile's geometry. Every read of it casts to the profile's own width, and the search over it is exact — the vector index that is not there is why nothing indexes the column.

Dropping the width from the column does not drop it from the schema, and the pair of constraints that replaces it is the point of the table's shape:

Constraint What it refuses
ck_email_embeddings_dimension A vector whose actual length disagrees with the Dimension column beside it
fk_email_embeddings_embedding_profiles on (EmbeddingProfileId, Dimension) → ak_embedding_profiles_id_dimension A Dimension the named profile never declared

Neither half works alone. PostgreSQL evaluates a check constraint against one row, so without the foreign key the check would only prove that a vector agrees with a number nobody constrained; without the check, the foreign key would only prove that a number matches a profile. Together they mean a provider returning a vector of an unexpected width fails at the write instead of corrupting a search. That is deliberately enforced by the database rather than by the code that writes, because a wrong-length vector is a defect no query would report — it would return a plausible-looking distance rather than an error.

The two references behave differently on delete, and that is the whole erasure story. The chunk cascades: a vector hangs on a chunk, a chunk hangs on a stored email, so deleting a message reaches every vector derived from it without a rule anybody has to remember. The profile restricts: a profile is what a stored vector's attribution points at, so the schema refuses to remove one while a vector still names it. ix_email_embeddings_profile is what a whole generation is read by when a superseded one is removed in bounded batches; without it that read would scan every vector in the table.

GeneratedAt records when the vector was produced, which tells a re-embed from an original one apart.

What a budget period has spent

embedding_spend_periods holds one row per budget period and user, keyed by PeriodStartsAt and UserId in that order — the instant that period began, which every process derives from the configured period length and the Unix epoch rather than reading from anywhere, and the user the spend was made for. The order is what lets one key answer both questions the ceilings ask: an exact lookup gives what one user spent, and a range over the leading column alone gives what the deployment spent. ConsumedInputCharacterCount is a bigint because a period of a mailbox's initial embedding passes a billion characters without difficulty. Nothing allocates a period: the first spend inside one inserts its row and every later spend adds to it.

The table exists rather than the count being derived from the stored vectors, which would need no table at all. A superseded generation has its vectors removed in bounded batches, so a count taken over them would erase the record of a spend that genuinely happened — and the period in which a model change is paid for is exactly the period an operator is watching. It is durable rather than held in memory for the reason the ceiling exists: a process crashing and restarting in a loop would otherwise begin every period again from zero and spend the whole ceiling on each attempt.

The one write is an increment issued as an upsert, in the same transaction as the vectors it paid for. That makes the charge and the vectors one durable fact, and it means two workers spending inside one period add to each other rather than each overwriting a total that was already stale when it was read — which is why the row carries no concurrency token. Nothing hangs off it and nothing cascades into it — not even from the user record, which is deliberate: a character count, an instant, and a generated user identifier name no message, passage, or vector, so the record of a cost outlives every vector that cost paid for and outlives the erasure of the user it was incurred for.

What reading a mailbox's attachments has spent

attachment_derivation_spend_periods holds one row per budget period, step, and user, keyed by PeriodStartsAt, UserId, and Step in that order. It is embedding_spend_periods beside it with one column added, and everything that page says about the shape holds here for the same reasons: the period start is derived from the configured period length and the Unix epoch rather than read from anywhere, the leading column lets one key answer both the deployment's question and one user's, ConsumedUnitCount is a bigint because a period of an initial reading passes a billion octets without difficulty, and nothing allocates a period — the first spend inside one inserts its row and every later spend adds to it, as one composed INSERT … ON CONFLICT DO UPDATE issued inside the transaction that stores the readings it paid for.

Step is what makes it a column rather than a second table. Two steps of attachment reading are bounded, and they are counted in units that do not convert: Extraction counts the octets opened out of attachments, and Description counts the calls a chat provider answered about a picture. Summing the two would add a megabyte to a phone call, so the step is part of the key and every read names one. It is stored as text rather than as a number, so a row read straight out of the database says which step it is.

Embedding is deliberately not a step here, and neither is chunking. What may be sent to an embedding provider is already bounded by embedding_spend_periods, which counts attachment characters exactly as it counts a message's own — ADR 0029 decides that there is no second ceiling on it. Chunking and the lexical index reach no provider at all, so what they cost is storage, reported as the characters the index grew by rather than charged to a period.

Nothing hangs off the table and nothing cascades into it, for the reason embedding_spend_periods has none: an octet count, a call count, an instant, a step name, and a generated user identifier name no message, no attachment, and no filename, so the record of a cost outlives every reading that cost paid for and outlives the erasure of the user it was incurred for.

What one mailbox's stored content holds

account_stored_content holds one row per mail account, keyed by MailboxAccountId, with a bigint StoredContentByteCount. It is the only figure on this page that duplicates something derivable from the rows beneath it, and the duplication is the point: the derivation is a sum over a whole mailbox, and the per-user storage ceiling it serves is consulted before every message. What it counts is the payload bytes, which is what a re-derivation produces — not what the table occupies on disk, an answer that exists only for the table as a whole and is what the deployment-wide ceiling reads instead.

The counter is the account's, and a user's figure is the sum over the accounts assigned to them. That is what ADR 0014 requires of a shared mailbox: it counts in full against every user assigned to it, work proceeds only while every one of them is under the ceiling, and an assignment moves what a person is counted as holding without rewriting a row. Counting per user instead would have meant one copy of the mail with two figures to keep in step.

Every movement is issued inside the transaction that stores or removes the payload, as a composed INSERT … ON CONFLICT DO UPDATE that adds a difference rather than writing a total, so a crash cannot leave a message stored and uncounted and two runs storing at once add to each other. Each statement resolves the account from the message itself, which carries MailboxAccountId, so no caller passes one. An account with no row has never had one written — a deployment upgraded before its first message, or a mailbox configured since — and its first read derives the figure once and adopts it. That derivation is the one operation here that writes a total rather than a difference, so it is also the only one that takes a transaction of its own: it claims the account's row before it measures and holds it until it has written, and a store committing meanwhile is either counted by it or applied on top of it.

Unlike embedding_spend_periods beside it, this cascades from mailbox_accounts: it describes mail that mailbox holds rather than money this deployment spent, so erasing the account takes it with everything else derived from its mail.

What a replica has reserved of that storage

stored_content_claims holds one row per payload a run has room reserved for and has not yet stored: Id, MailboxAccountId, a bigint ClaimedByteCount, and an ExpiresAt instant. It exists because the two storage ceilings are the deployment's rather than each replica's, and the gap between deciding there is room and having written the payload is the only part of that decision a process could otherwise keep to itself — several folder runs, in one process and in several, would each measure the same room and each take it.

A claim is written by the same statement that decides it. That statement sweeps what has expired, measures what the content table occupies plus what every unexpired claim reserves, tests both ceilings against one reading, and inserts the row only where both admit — reporting which ceiling refused where one did not. It serializes on a transaction-level advisory lock, because a claim is an insert and an insert takes no lock a second insert would wait behind; ADR 0031 is where a short database-only critical section is the case an advisory lock is right for. Every instant in it is the database's now(), so replicas with drifting clocks agree on what is still reserved.

The row is deleted once the payload has reached storage or been abandoned, and the expiry is what bounds the failure the deletion cannot cover: a replica that stopped answering while holding room releases it five minutes later rather than never. The lifetime is a constant rather than a setting, because what it bounds is a failure rather than a tuning decision, and IX_stored_content_claims_ExpiresAt is what the sweep reads.

Nothing cascades into it or out of it, and it holds no personal data: a generated identifier, a generated account identifier, a byte count, and an instant say that somebody's payload is about to be written and how large it is, and none of them names a message. A deployment that configures neither ceiling never writes a row here at all.

Where a paced workload's next slot is

provider_pace_markers holds one row per paced workload, keyed by a Workload name of at most 64 characters, with a NextSlotAt instant. There are two names today — the embedding workload's and the attachment image description's — because each is a bulk workload against its own declared endpoint with its own published quota, and one marker shared between them would let either workload's burst spend the other's slots.

A caller takes its slot in one INSERT … ON CONFLICT DO UPDATE that moves the marker to one interval past whichever is later, the marker's own value or now(), and returns the wait the caller owes rather than the instant it may send at — so nothing subtracts a database instant from a process clock. That is what makes the configured rate the deployment's: three replicas queue on one row rather than each pacing itself to the whole rate. A marker left behind by an idle stretch owes nobody the slots nobody took, because the GREATEST is against now().

It holds no personal data — a workload name MailFathom chose and an instant — and nothing cascades into it. A deployment pacing nothing never writes a row here.

What answering has spent this period

mail_answering_spend_periods holds one row per period, keyed by PeriodStartsAt, with an AdmittedRunCount and a bigint ConsumedTokenCount. It is embedding_spend_periods in the shape a ceiling with no per-user half needs: the period's start is derived by every process from the configured period length and the Unix epoch rather than read from anywhere, so nothing has to be stored to say where a window begins and an instance idle for a day is not owed the windows that passed.

A run is admitted by one conditional INSERT … ON CONFLICT DO UPDATE that increments the run count only where both ceilings still have room, and answers with the count it became — a refusal answering with no row at all, which is what a caller tells the two apart by. A spend adds unconditionally, because what a call cost is not knowable until it is answered. Both are one statement, so two replicas admitting at once cannot both be admitted against the same reading.

Nothing cascades into it, for the reason embedding_spend_periods has none: a run count, a token count, and an instant say what a deployment spent and when, and none of them names a message, a question, or a person. So it outlives the mail those runs read, and erasing a user leaves the record that the period was paid for.

Outstanding content repair requests

email_content_repair_requests is one-to-one with stored_emails and exists only while a read has found an email's stored content unusable. It records the Defect — missing content, a byte length or SHA-256 digest that disagrees with what was written, or a payload nothing can parse — together with when the defect was first and last seen and how many reads have hit it. Email content describes what produces each value.

It is a table rather than four columns on stored_emails because the rows are sparse, they are read as a work list, and a repair that succeeds deletes a row instead of nulling columns on a row it must not otherwise touch. The write is a single INSERT ... ON CONFLICT ("StoredEmailId") DO UPDATE, so the idempotency the read path needs is the primary key's rather than a retry's: two readers meeting the same damaged message concurrently leave one row and one accurate count. Nothing drains the table yet — performing the repair belongs to the synchronizer — and the cascade from stored_emails removes a request with the email it is about.

What classification concluded about a message

email_spam_classifications is one-to-one with stored_emails and holds what spam classification concluded: the Verdict, the stage that DecidedBy, the Score and the Threshold it was judged against, the CorpusRevision the deciding stage ran under, the Profile it was reached under, and when it was EvaluatedAt. Spam classification describes what produces each value.

Profile is a twelve-character digest of the settings the verdict rests on — whether a scanner was consulted and the threshold its score was judged by — and it is nullable because a row written before the column existed names terms nothing can compare. That is what it is for: a run over a whole mailbox reads it to decide whether a message has already been decided under the settings now in force, and a row carrying none is scored again rather than skipped.

Keyed by the email rather than carrying an identity of its own, which is what makes one classification per message a property of the schema instead of a rule somebody has to remember: classifying the same message twice reaches the same row, so two runs asking together resolve to one record rather than to a history nobody asked for. The row carries xmin as its concurrency token, because those two runs do exist — an arrival classifies a message while an operator's reclassification replaces it — and the conflict is retried from a fresh read rather than resolved by whichever writer was last.

The score and the threshold are two columns that are present or absent together: the same number is spam under one configuration and ordinary mail under another, so a score whose threshold is missing cannot be read at all. Nothing in the schema enforces the pairing; the domain value that builds them refuses to carry one without the other, and a row holding half of one is read back as carrying no assessment.

It is a table rather than columns on stored_emails for the reason the repair request is: the rows are sparse — a deployment with classification off has none — and a second table hangs off them.

email_spam_classification_signals is that table, one row per fact the verdict rests on: its Kind, its Name, what was Observation-ed, and the Source and Origin it came from, numbered by Ordinal. A row per signal rather than one opaque column, because the whole point of the record is that the facts stay separable — an operator diagnosing a wrong verdict asks which authentication method failed and what the provider header said, and a serialized blob answers neither without being parsed by hand. The ordinal is unique per classification and carries meaning: the deterministic stage's facts are numbered first, so a record truncated at its bound kept the ones the verdict rests on rather than an arbitrary subset.

Both cascades point one way. A classification is deleted with the email it describes, and its signals with the classification, so whatever erasure and retention already reach a message reach everything derived from it — there is no pass of its own to remember.

Recorded mailbox mutations

mailbox_mutations holds one row per change MailFathom has been asked to make to a remote mailbox, written before the first IMAP command is issued and advanced as the sequence proceeds. A move over IMAP without the MOVE extension is three commands — copy, flag deleted, expunge — and a process can die between any two of them; retrying from the beginning would put a second copy in the destination folder, and skipping the retry would leave the message in both. Neither state is recoverable by looking at the mailbox afterwards, because both are indistinguishable from a move somebody made by hand. Writing the intent down first is what makes the sequence resumable.

Each row carries the local email, the source occurrence it was aimed at — the folder binding with its UidValidity and Uid — the Mutation by name, the requester, the parameters that mutation takes, and how far it has got. The source occurrence is stored beside the StoredEmailId rather than read back through it, because the email moves: the command that was issued was aimed at one folder and one UID, and a record that followed the email would stop describing it.

LocalDisposition is one of those parameters, and a delete takes it with one other: it names what becomes of the local copy once the server no longer holds the message, and is null for every mutation but a delete and a relocation out of the mirrored mailbox. It is stored rather than read where the delete finishes because those are different runs — the deletion is issued now and the local copy is disposed of by the synchronization run that later sees the message gone — so reading the account's configuration there would apply whatever an operator had changed it to in the meantime. Writing it with the row is what makes a setting changed mid-flight govern the deletes authored after the change and leave one already begun exactly as it was. A row this column is missing from is refused on the way back rather than read as some fallback, because every value destroys something a different one keeps.

ServerDisposition is the other, and only a delete carries it: Expunge or FlagDeleted, stored by name and written with the row for the same reason LocalDisposition is. Every delete recorded before the column existed was written as Expunge, which is what each of them did, and a delete row without it is read as Expunge: only a build that knows no other value writes one. DeleteFlagSettledAt is when a run first read \Deleted on the occurrence of a FlagDeleted delete, which is what settles that delete, since the server goes on holding the message. ix_mailbox_mutations_flagged_delete is (MailFolderId, UidValidity, RecordedAt), filtered to completed FlagDeleted deletes that are neither settled nor seen removed, so it holds only what the next run of each folder is about to settle.

LocalChange says what the row was opened to do to MailFathom's own copy rather than what it asks of a server, and it names one of three things. None is every row a mirrored account writes, and the row a restoring account writes for a message the drain has already taken off the source: nothing local happens, now or later. Erasure is the delete of a message already in the local trash on an account holding or restoring its own mailbox, which erases MailFathom's copy once the person's withdrawal window has passed and reaches no server at all. AlreadyCommitted is the row a restoring account opens beside a change it has just made to the stored message, which exists only to carry that change to the source. It is written down rather than worked out from the account's phase, because the phase moves while a row waits — once an account is held again all three kinds are deletes against a trashed message. A convergence pass erases the rows marked Erasure and leaves the rest, so a delete whose LocalDisposition asked for the copy to be kept is carried or deferred rather than destroying it; and a withdrawal cancels neither an AlreadyCommitted row nor anything past Recorded, because the change it names has happened and taking the row back would leave nothing to tell the source with.

DesiredSeenState, DesiredFlaggedState, and Keywords are the other parameters, and each belongs to the mutations that take it: the two booleans carry the direction a flag change asked for, and Keywords is a text[] carrying the keywords an addition, a removal, or a replacement named. A row carries exactly the parameter its mutation takes and null for the rest, which is what makes a resumed attempt ask for what was originally asked for rather than for whatever a rule now says. The distinction between a null Keywords and an empty one is deliberate and load-bearing: null is a mutation that takes no keywords at all, while an empty array is a replacement asking for every keyword to be cleared.

Stage is the sequence's own vocabulary rather than a generic pending and done, because it is what a retry resumes from:

Stage What it says Which mutations reach it
Recorded The intent is durable and nothing has reached the server every mutation
PlacementIssued The command that would place the email has gone out and its answer was never read relocate, copy
PlacementConfirmed The server acknowledged the placement, and named it where it supplied COPYUID relocate, copy
SourceFlaggedDeleted The source carries \Deleted, and only the expunge remains unless the delete only flags relocate over the fallback, delete
Completed The change is made, and asking again performs nothing every mutation
Abandoned Nothing will attempt it again, and LastFailureCode says what ended it every mutation
Cancelled The person who asked for it took it back before anything reached the server every mutation

Cancelled is reachable from Recorded and from nowhere else, which is what makes it a withdrawal rather than an abandonment: a STORE already issued cannot be recalled, and a placement whose answer never came back has to be re-established rather than declared void, so a record past Recorded is reported where it stands instead of being withdrawn. It is terminal like Completed and Abandoned, and unlike Abandoned it says nothing failed — which is why it is a stage of its own rather than a reuse of the one that means stuck, and a person should look. The stage is stored by name, so it needed no migration.

HeldUntil is the one way a record at Recorded is kept from the account's pass. It is null on every record but a delete a person asked for through the client endpoint, where it is the instant their own notification time and a ten-second grace run out: until then the pass does not take the record in hand, and a withdrawal can still reach Cancelled because nothing has been issued. It is written with the row rather than computed from the person's current preference, so the window a delete opened under is the window it keeps whatever that preference is changed to while it waits. A client that stops offering the way back clears it to null, which ends the wait at once; a client that never does leaves it to elapse, and the record is taken in hand exactly as if it had. A null is the ordinary record, taken in hand on the next pass as it always was.

PlacementIssued is the one stage a retry may not act on. A COPY issued twice is a second message rather than a repeat of the first, so a mutation found there is reported as an unknown outcome, has MailboxMutationOutcomeUnknown (25002) written to LastFailureCode so an operator reading the row sees why it is stuck, and is left for a person to resolve. Every other stage resumes: a relocation found at PlacementConfirmed removes its source without copying again, and a delete found at SourceFlaggedDeleted reissues only the expunge, or nothing when its server disposition is FlagDeleted. A \Seen change never leaves Recorded until it completes — the store is idempotent on the wire, and its record exists for provenance rather than for retry safety. A \Flagged change and every keyword change behave the same way, for the same reason: STORE +FLAGS and STORE -FLAGS say what a message should carry rather than what to do to it, so issuing one twice leaves the mailbox where issuing it once did.

RequiresSourceRemoval is what makes that resumption safe, and it is written together with PlacementIssued rather than worked out later. MOVE removes the source as part of the same command and a copy does not, so PlacementConfirmed means opposite things depending on which ran — and the connection a retry lands on is not required to be the one that answered the first. A fallback relocation resumed against a server that now advertises MOVE would otherwise be read as already finished, leaving the email in both folders permanently with nothing left to surface it. That is the duplication the record exists to prevent, so the answer is durable rather than inferred. It is a fact about the sequence rather than a name for the operation: which protocol path carried a relocation still reaches no log above Debug, no span, and no metric dimension, exactly as ADR 0007 requires.

AttemptCount is written before each attempt rather than after it, which is what makes an attempt that kills the process count against MailSynchronization:MaxMutationAttempts. Spending that bound moves the row to Abandoned, and a row that is not Completed stays in the answer an operator reads — being given up on is what stops a change being retried, and it would be worth nothing if it also stopped the change being seen. Two other things reach Abandoned without spending the bound: a refusal the server has already given once and will give again, and an unacknowledged placement that outlasts MailSynchronization:UnknownMutationOutcomeGrace without the mailbox settling it.

Every row that is neither Completed nor Cancelled is read once per account run, oldest first and bounded by MailSynchronization:MaxMutationsPerConvergencePass, and each is carried further or given up on. The same rows are counted by stage in one grouped query per run, which is what the outstanding-mutation gauges report; the partial index below is what makes both cheap, because it holds what is outstanding rather than the mailbox's whole mutation history. A withdrawn row is still in that index — the index filter names Completed alone, so admitting Cancelled to it would be a migration for rows nothing waits on — and every query over it excludes the stage instead.

PlacementObservedAt and SourceRemovalObservedAt are what synchronization has since seen come back, and they are separate facts from Stage because they answer a different question and are written by a different run. The stage says what the server acknowledged when the command went out; these say that an ordinary synchronization run has met the occurrences the change moved and recognized them as this record's own. A relocation reaching Completed still arrives in the destination folder later as a discovery something has to join to the email already stored, and its source occurrence still vanishes from the folder it left — and left alone, that pair is a new message and a deleted one.

Both are written once and never moved afterwards, and that is what scopes an arrival's provenance to the one change the record describes: a record whose placement has been met answers for no later discovery at the same UID.

A \Seen store carries no such column and needs none, because it moves no occurrence for a run to come back and meet. Its provenance is settled against the stored email's own remote_flags_observed_at instead: a store accounts for a flag reading only while that column still predates the moment the store completed. Every window advances it for every occurrence it asked about, so the first reading after the store is the whole of what the record can answer for. A column here would answer only for the readings that happened to differ — and a user who reverted the flag before the first reading would leave it unwritten and have their own later change silenced by it.

The join is the server's own COPYUID answer for the placement and the record's own source occurrence for the disappearance. A relocation whose server named no placement matches no discovery at all, and PlacementObservedAt stays null instead: finding the message by searching the destination folder for something that looks like it would replace a fact with a guess, and a header a provider rewrote on copy or a Message-ID that legitimately appears twice is wrong in both directions. The disappearance needs no COPYUID, because the source occurrence was written down before the first command was issued.

The source half is settled by carrying the row across where nothing has settled it already, because that is what takes the email out of the source folder locally: no later reconciliation window can select it there, so no later run could observe the disappearance the record would otherwise keep waiting for. A row whose halves are both accounted for leaves the candidates a later discovery is matched against; a relocation still owing one is where an operator looks when a message moved and the local mailbox has not caught up.

No mail content is here. A folder path, a UID, a mutation name, and a requester identity are the server's own or MailFathom's own names for things, and a failure is kept as its five-digit code rather than as the message text assembled at the failure site.

AuditTrailEnabled is the one column on this row that is about something other than performing the change: it is the account's audit-trail setting as it stood when the intent was written down, and it decides whether the ending of this mutation is kept in the table below. It is stored for the reason LocalDisposition is — a mutation ends in a later run, and reading the setting there would apply whatever an operator had changed it to in the meantime, producing a history whose gaps look like changes nobody made.

The audit trail of finished mutations

mailbox_mutation_audit_entries holds one row per change MailFathom finished making to a remote mailbox, written once when the mutation reaches Completed or Abandoned. It is a separate table from mailbox_mutations because the two answer different questions with different lifetimes: that one is operational state a retry reads, and its useful life ends when the change does; this one is written once, read by nothing the mechanism depends on, and its whole value is that it is still there months later when somebody asks what happened to a message. One table for both would decide two retention policies with one answer — operational state that is never pruned grows without bound, and history pruned on completion answers nothing.

Every identity on the row is a value rather than an association, and no foreign key leaves it. That is the design rather than an omission. If the trail inherited the deletion path of the email it describes, then erasing that message would erase the record that MailFathom deleted it — which removes exactly the entry an audit of deletions exists to hold. So StoredEmailId, MailboxAccountId, and both folder paths are stored as values, and the entry outlives every one of them.

Column What it records
MutationRecordId, unique Which mutation this was, while that record still exists; the uniqueness is what makes a repeated append leave one entry
MailboxAccountId, StoredEmailId Which mailbox and which local email, as values that survive both being removed. The account is named by its generated identifier alone, so an entry that outlives the account row still says which mailbox it was
Mutation The change, by the name a log line and a metric already use
SourceFolderPath, SourceHierarchyDelimiter, SourceUidValidity, SourceUid The occurrence the IMAP command was aimed at, with the folder written as its remote path rather than as a key into a binding a later rebinding replaces
DestinationFolderPath, DestinationHierarchyDelimiter Where a relocation or a copy was aimed, and null for every other mutation
PlacementUidValidity, PlacementUid Where the server said it put the message, where it supplied COPYUID
DesiredSeenState Which way a \Seen change was asked for, and null for every other mutation
RequesterOrigin, RequesterIdentity Who asked — a rule together with the revision that matched, one invocation, or the profile a spam verdict was decided under
RequestedAt, CompletedAt When it was asked for and when it ended
Outcome, FailureCode Performed, or Abandoned with the five-digit code it was given up on for

Nothing amends a row. An entry states an ending that has already happened, so the table only ever grows and shrinks and carries no concurrency token; the two writes it takes are the append and the erasure that retention or a data-subject request calls for.

No mail content is here either, and the omission is the same one the mutation record makes for the same reason: no subject, no address, no body fragment, no filename. What makes this table's version of that promise worth stating separately is that this one outlives the mail, so an entry that carried content would be content kept past the erasure of the message it came from.

The record of what a question read

mail_answering_audit_entries holds one row per account per ask_mail run, written once when the run has ended and its answer has already been produced. It is the same artifact as the trail above for a different act — that one answers "why is this message in this folder", this one answers "which of my messages did that answer come from" — and it is kept for the same reason: an answer produced by a model is not reproducible, so the only way to explain one later is to have recorded what produced it.

Column What it records
RunId, MailboxAccountId, unique together Which question this was and which mailbox it reached, the account named by its identifier alone; the uniqueness is what makes a repeated append leave one entry, and the run identifier is what joins the entries a multi-account question left
ChatEndpointAlias, InstructionsVersion The profile and the policy the answer was produced under, as MailFathom's own names for both
StartedAt, CompletedAt When the run began and when it ended
Outcome How it ended: answered, or one of the endings that published no answer
Degradation Which ways it read less of the mailbox than an undegraded run of the same question would, as a set of names

mail_answering_audited_emails holds one row per message an entry names, keyed by the entry and the message together — one run names one message once, however many of its lookups found it. Beside that pair it carries Position, the order the run first reached the message in, and WasCited, whether the published answer named it as a source. The difference between the two is the point: retrieval is what the run read, a citation is what the response published, and a response bounded to fewer citations than the run retrieved messages is exactly where the two diverge.

This is the one place a record follows the mail it names rather than outliving it. The row cascades from stored_emails, so erasing a message erases it from every run that read it, and it cascades from the entry, so retention erasing an entry takes its messages with it. That is the deliberate opposite of the mutation trail above, where the act recorded may have been the deletion; nothing of the sort applies to reading a message, so a message nobody may hold any more is not one this record goes on naming. The account stays a value rather than an association for the reason it does there: a deployment that stopped serving an account still answered questions from it.

No mail content is here, and the omission is stronger than elsewhere on this page: no extract, no subject, no address, and no query. A record that stored the retrieved passages would be a second copy of the mailbox with its own retention, access, export, and erasure obligations — for the sake of a debugging convenience. What the identifier buys instead is that the message can be fetched and read whole through the reads that already serve it.

A Discover run and what it composed

discovery_runs holds one row per Discover run somebody asked for, and discovery_run_events holds what that run wrote, one row per event. Together they are the answer a client reads: the run is opened before the question is dispatched, each event is written as it is produced, and the client reads back from the sequence it already holds.

They are tables rather than a buffer in a process because a load balancer places the request that asks the question, the requests that read the answer, and the request that stops the run independently, so a run held by the replica composing it is readable about one time in the replica count. ADR 0035 records that, and records why the answer is not carried over the optional signal backplane instead: what crosses it is a statement that something changed, never the thing itself.

discovery_runs column What it records
Id The identifier the run is addressed by, which a client is handed and presents back, and the primary key
UserId Whose question it is, which is who may read the run. It is the foreign key onto settings_accounts with ON DELETE CASCADE, for the reason client_preferences keys the same way, and it is indexed because the concurrency bound below is counted over it
StartedAt When the run was opened. It is what the wider of the two retention ceilings is measured from, which is what closes a run whose replica went away without reporting anything
LastUsedAt When anything last read or wrote the run. It is what the retention window of an ended run is measured from, so a client that is still reading is never forgotten out from under itself
EndedAt When the run wrote its ending, and null while it is still executing. It is what the read reports as running, what refuses a second ending, and what decides which of the two retention windows the row is held on
StopRequestedAt When somebody asked the run to stop, and null where nobody did. It is recorded rather than acted on by the replica that takes the DELETE, because what a run spent is the executing replica's ledger to report: that replica meets this column as the next ordinary write the store refuses, and the ending it then writes carries the true counts
discovery_run_events column What it records
RunId, Sequence, together the primary key Which run this belongs to and the place it holds in it, counted from one. The sequence is derived inside the insert, from the greatest one the run already holds, so the composite key is what makes a gap and a repeat both impossible rather than a number any replica hands out
Kind The event contract's own published name for this kind of event, at most 64 characters. It is the readable half of the row: an ad-hoc query reports what a run did without deserializing anything
Payload The event itself as json, written by the run's own serialization contract. JSON rather than a column per kind because a rolling upgrade runs two builds against one database, so an older build reads a newer build's row rather than failing on a column it does not know about. json rather than jsonb because only the first of the two stores the document it was given: jsonb reorders the keys of everything it holds, and an event is a polymorphic document whose type discriminator is read nowhere but first
WrittenAt When the event was written

This is mail content, and it is classified as mail content. A composed block and a declared citation are drawn from somebody's correspondence — a subject, an extract, an address — so Payload inherits every obligation the message it came from carries. The other four kinds hold counts and closed values alone. Nothing here is logged, nothing here reaches an instrument, and the row cascades from the user record, so erasing a person takes every run they asked for and everything those runs composed.

It cannot grow without bound, and three things hold it. A run may write a bounded number of events, the last place reserved for the ending. A person may have a bounded number of runs executing at once, counted in the same statement that opens one — so it is the deployment's number rather than one each replica finds room under separately, and a run past it is refused with 429 rather than admitted. And every row is swept on the two retention windows the run's own bounds state: five minutes after an ended run was last read, and ten minutes after any run was opened. The sweep runs on a worker on every replica once per retention window as one conditional statement, and on the path that opens a run as well — the worker rather than the open alone, because storage limitation over mail-derived rows cannot depend on somebody asking another question.

An Agent conversation and what was said in it

agent_conversations holds one row per conversation somebody is having with the Agent, and agent_conversation_entries holds everything said in it, one row per thing said. The pair is the Discover run's pair one step further on, and for the same reason: the same ADR 0035 delivery, where an answer is written as it is composed and a client re-reads from the place it already holds. What differs is that a conversation outlives the run that answered into it: a Discover run is opened for one question and swept minutes later, while a conversation is somebody's history of asking.

An entry is the record and a turn is a reading of it. A question, the opening of an answer, a status line, a citation, a composed block, an offer, an answer's ending, and an answer to an offer are the eight kinds of the visible history, and the turns a screen draws are folded out of them in order rather than stored. The ending of an answer that completed also carries what the agent suggests asking next, as a member of that entry rather than a kind of its own, so a build that predates it reads the ending and passes over the member. Four more kinds make up the technical history beside it: a tool the run called, what the tool returned, what the run's first call sent and was charged, and a compaction — the summary a turn sends in place of everything up to a place, with the proposals still pending carried beside it. Compaction is append-only: a summary is an added entry, the next one folds in the one before it, and nothing it covers is removed, so a person reads every message however many summaries were taken. Both histories share one order. That is what makes the cursor read one query: a client holding a place asks for everything past it and gets exactly the entries it has not seen, whichever turn each belongs to.

agent_conversations column What it records
Id The identifier the conversation is addressed by, and the primary key
UserId Whose conversation it is, which is who may read it. It is the foreign key onto settings_accounts with ON DELETE CASCADE, and it leads the history index below
Title What the conversation is called, at most 120 characters, and null until something composes one. A conversation exists from its first question, which is before anything has read enough of it to name it
StartedAt When the conversation was opened
LastActivityAt When anything was last written into it. It is what a person's history is ordered by, which is why it trails the user in the index rather than sitting in one of its own
Sequence The place the last entry was written at. It is advanced inside the statement that writes the next one, so the number is the database's rather than one a replica counted — and the row lock that advance takes is what serializes the two writers a conversation genuinely has, a person typing while a run composes
VisibleEntryCount How many entries of the visible history the conversation holds. Advanced by the same statement as Sequence, only for a visible entry, so the ceiling a person meets counts what they can read and a run's tool traffic never fills a conversation sooner
ComposingMessageId Which answer is being composed, and null where none is. It is what refuses a second answer opening while one is open, and what refuses a part of an answer arriving after that answer has ended — both as conditions on this row rather than as a check some replica performs and then acts on
Archived Whether the person has put the conversation away, false for every conversation until they do. It decides where the history lists it and nothing else — the entries stay, an answer being composed goes on, and LastActivityAt does not move when it changes
agent_conversation_entries column What it records
ConversationId, Sequence, together the primary key Which conversation this belongs to and the place it holds in it, counted from one. The place comes from the column above, so the composite key makes a gap and a repeat both impossible
Kind The entry contract's own published name for this kind of entry, at most 64 characters, for the reason discovery_run_events carries one
Payload The entry itself as json, written by its own serialization contract. json rather than jsonb for the reason stated there: an entry is a polymorphic document whose discriminator is read nowhere but first, and jsonb reorders the keys of everything it holds
Visible Whether the entry belongs to the visible history. Stored beside the payload rather than derived from Kind, so a read of the visible history filters in the statement — its limit counts only what a person reads — and a build that does not know a newer kind still reads the right history
AnsweredProposalAt Which offer this entry answers, as that offer's own place, and null on every other kind. An offer is addressed by where it was made rather than by the turn it belongs to, which is what lets the same offer be made twice and answered differently each time
ProposalState Where that offer now stands, by name, and null on every other kind. It is a column rather than only a field of the payload so the statement recording an answer can read what the last one said without deserializing anything
WrittenAt When the entry was written
SearchVector What the history search matches words against, as a tsvector PostgreSQL generates and stores from Payload: a message's own text, and every string field of a block or an offer. Every other kind stores null, so a status line, a tool's output, or a summary is never what a search finds. It is compiled with the deployment's text search configuration exactly as the mail's search document is, and indexed by ix_agent_conversation_entries_search_vector, a GIN index

A person's message is written under the conversation's held row. A question and the opening of the answer to it are two rows written in one transaction that first takes the conversation's row FOR UPDATE, so a question is never left in the record with no answer behind it, and one asked while ComposingMessageId is set writes nothing. The message's identifier is the client's and lives in Payload rather than a column, so a post retried over a dropped connection is recognized by reading it back out of this one conversation's rows — a scan bounded by the entry count below — and answered with what the first post wrote instead of a second copy.

This is mail content, and it is classified as mail content. A question is what somebody asked about their own correspondence and a composed block quotes it back, so Payload inherits every obligation the mail it was drawn from carries. Nothing here is logged, nothing here reaches an instrument, and the row cascades twice — an entry from its conversation and a conversation from the user record — so erasing a person takes every conversation they had and everything said in one.

Two indexes and five bounds hold it. ix_agent_conversations_user_last_activity over (UserId, LastActivityAt DESC) is a person's history, which is the only shape that listing takes, and it answers the cascade's own lookup as well. The listing sorts the archived conversations behind the rest, and the index leaves Archived out: one person holds at most a thousand rows, so that order is settled over a set the index has already narrowed to them. ix_agent_conversation_entries_answered over (ConversationId, AnsweredProposalAt) is partial over the rows where that column is not null, because answers to offers are a small minority of what a conversation holds and an index over all of them would be rewritten on every block a run composes to serve a query only a press makes. The bounds are a conversation's entry counts — 5 000 of the visible history and 50 000 of the whole record, both refused in the same statement that would write past either and each keeping its last two places for an answer's ending and the agent's note after a stop — the title's length, how many entries one read returns, how many conversations one listing returns, and how many conversations one person may hold — 1 000, counted in the statement that would start another, over the history index above.

A message's meaning is placed in agent_conversation_embeddings, one row per message and embedding profile. Once an answer ends, the question that opened it and the prose the answer composed are embedded in one call and written here under the active profile, keyed by (ConversationId, Sequence, EmbeddingProfileId) so recording one twice writes nothing. Only a message's text is embedded; a block's other fields reach the search through SearchVector alone.

agent_conversation_embeddings column What it records
ConversationId, Sequence The entry the text was read from. The foreign key onto agent_conversation_entries cascades, so a vector goes with the entry it was placed from — a conversation deleted or a person erased takes them along
EmbeddingProfileId, Dimension The profile the vector was placed under, as the composite foreign key the mail's vectors carry, restricted rather than cascaded. ix_agent_conversation_embeddings_profile is what a superseded generation's vectors are removed by
Embedding The vector, vector with no fixed width, held to Dimension by ck_agent_conversation_embeddings_dimension
GeneratedAt When it was written

The history search reads both halves for one person at a time — the words through SearchVector, the meaning by an exact scan of this table against the active profile, with no approximate index — keeps each conversation's best entry from each, and fuses the two rankings as mail search does. A vector is derived from what somebody said about their own mail and is classified exactly as Payload is.

The whole-mailbox rule run an account has outstanding

mail_rule_evaluation_runs holds the one re-evaluation of an account's whole mailbox that somebody has asked for, and how far the account's synchronization runs have carried it. It is keyed by the account, which is what makes "one outstanding run per account" a property of the schema rather than a check somebody has to remember: two requests arriving together collide on the key, and the loser is recognized as the second caller learning the first got there instead of as a failure.

Column What it records
MailboxAccountId The mailbox whose mail the run walks, and the first half of the primary key
mailbox_account_id The account, and the second half of the key. It follows the user because the key is what makes one outstanding run per account a property of the schema, and an identifier names one account only within its user — keyed alone it would have made one run per name, shared by everyone who chose it
requested_at When the run was asked for
Trigger What put the run there — RequestedRun for one an operator asked for, ScheduledRun for one a rule's schedule asked for. It is what the pass reads the walk's reach from, so a scheduled run reaches the rules declaring a schedule while a requested one reaches every rule; it is also what the run history's own trigger is recorded as. Text for the reason every other bounded value here is
revision The rule set the run is bound to, null until the first pass picks it up. Bound when the run starts rather than when it is requested, because the set may reload between the two and what matters is the one in force when the first message is actually evaluated
position The identity of the last message a batch committed, null while the run has committed none. Committed with the evaluations it accounts for, which is what makes the run resumable rather than merely restartable
evaluated_email_count, matched_email_count, skipped_email_count What the run has done so far, across every account run that has carried it
ended_at, ending When and how the run stopped being outstanding. Completed is the end of the account's mail; Superseded is the rule set having changed while the run was outstanding, which ends it rather than letting one walk apply two rule sets to one mailbox. The ending is text for the reason every other outcome here is: it stays readable in an ad-hoc query and survives a reordering of the enum
ConcurrencyVersion The xmin token again, because a pass committing a position and a request arriving can both reach this row

The row survives the run it describes, holding the last ending until a new request replaces it, and there is no history behind it: one account has one row. Nothing cascades into it and it carries no foreign key onto mailbox_accounts, for the reason mailbox_refresh_tokens carries none — a run may be asked for before any folder of the account has been bound.

One row per account is also what settles the two triggers against each other. An operator's request replaces an outstanding scheduled run, because it reaches every rule and the scheduled one reaches only some of them; a schedule's occasion finding any run outstanding stands down and is counted as skipped rather than starting a second walk of one mailbox.

Nothing in it is personal data. An account alias, a derived rule set identity, a message identifier, three counts, and three instants are MailFathom's own names for things, which is what lets a run be explained without any of the mail it walked being copied.

The whole-mailbox classification run an account has outstanding

spam_classification_runs holds the one classification of an account's whole mailbox that somebody has asked for, and how far the account's synchronization runs have carried it. It is keyed by the account for the reason the rule run above is, and answers the same way when two requests arrive together.

Column What it records
MailboxAccountId The mailbox whose mail the run walks, and the first half of the primary key
mailbox_account_id The account, and the second half of the key, ordered for the reason the rule run's is
requested_at When the run was asked for
folder_aliases, posture, rescores The terms the operator asked for: which folders the walk covers, whether it writes down what its verdicts ask of the mailbox or only works it out, and whether mail already decided under its profile is scored again. Stored rather than read again per pass, because a walk that spans hours has to mean the same thing at its end as at its start
profile The classification settings the run is bound to, null until the first pass picks it up. Bound when the run starts rather than when it is requested, for the reason the rule run's revision is; a profile that moves under an outstanding run ends it rather than being applied to the half of the mailbox that is left
position The identity of the last occurrence a batch committed, null while the run has committed none. Committed with the counts it accounts for, which is what makes the run resumable rather than merely restartable
classified_email_count, spam_email_count, undetermined_email_count, skipped_email_count, unclassifiable_email_count, acted_email_count What the run has found and done so far, across every account run that has carried it. acted is one count for both postures, because it means the same thing under each: this is the mail the switches reach
ended_at, ending When and how the run stopped being outstanding — Completed, Superseded by a moved profile, or Disabled by classification being switched off under it. Text for the reason every other outcome here is
ConcurrencyVersion The xmin token again, because a pass committing a position and a request arriving can both reach this row

The row survives the run it describes and there is no history behind it, exactly as the rule run has none, and it carries no foreign key onto mailbox_accounts for the same reason. Nothing in it is personal data: an account alias, folder aliases, a derived settings identity, an occurrence identifier, six counts, and two instants are MailFathom's own names for things. What each of those counts is about per message is the classification records themselves, which is why no per-run history table exists.

What each rule concluded, and what the conclusion asked for

mail_rule_executions holds one row per rule a pass reached per message it evaluated, and mail_rule_executed_actions holds the changes each of those rules declared and what became of each. The unit is the pair of a rule and a message because those are the two ways the record is arrived at — "what is this rule doing" and "why is this message here" — and a rule the pass never reached leaves no row at all, which is what keeps "did not match" and "was never asked" apart.

Column What it records
Id What addresses the execution, and the primary key. A version-7 identifier, so the tie-breaker that orders two executions recorded in one instant rises with the recording instant and one batch's inserts land together in the index rather than scattering across it
MailboxAccountId, StoredEmailId Which mailbox's mail was evaluated, and which message, the account named by its identifier alone. The message is a foreign key onto stored_emails that cascades, which is the whole erasure story here: what a rule concluded about a message goes when the message does, without a rule anybody has to remember
RuleName, Revision The rule, and the rule set it ran under. Together they are what the condition is retrievable from — the revision identifies the configuration the expression was read from, so the reasoning is reconstructible without the expression being copied here
Trigger What reached the message: Arrival for a rule applied as mail arrived, and RequestedRun or ScheduledRun for one applied by a whole-mailbox walk, according to what asked for the walk. Text for the reason every other outcome here is: it stays readable in an ad-hoc query and survives a reordering of the enum
Outcome, ConditionFailure What the condition concluded, and why it concluded nothing. The failure is present exactly when the outcome is Failed, which is what makes an expression that could not be evaluated distinguishable from one that evaluated to false
ReadFacts The names of the facts the condition read, as text[]. Names and never values — the array holds senderDomain, never a domain — and read rather than referenced, so a fact a short-circuited clause named does not appear
EvaluatedAt, Duration When the message was evaluated, and how long the condition took to answer including resolving the facts it read. The duration is what the evaluation timeout is spent against, so a rule creeping toward its bound is visible before it starts being recorded as timed out
Column of mail_rule_executed_actions What it records
MailRuleExecutionId, Position The execution the change belongs to and where the change sits in the order its own rule declares them, together the primary key. The position is the rule's own rather than the plan's, because a plan reorders across rules and the position is what names which of a rule's declared changes this was
Mutation, Destination The change asked for, and the folder it named — the alias a requested change resolved to, and the text the rule wrote for one that never got that far, which is why the column is not named for an alias. Both are MailFathom's own configured names, which is what lets what a rule did to a mailbox be recorded without the record describing the mailbox
Outcome, FailureReason Requested where a mutation record was opened, Refused with a classification where one could not be, and Withheld where another rule had already settled the message's fate. The three are kept apart because a change that was refused and a change nobody asked for read identically without it
MutationRecordId The record carrying the request, present exactly for a Requested change. Deliberately not a foreign key: it is a pointer into the mutation's own trail, which has its own retention, and a constraint would tie this record's lifetime to one it does not own

The row is never amended. An execution states a reading that has already happened, so the record only grows and shrinks — by the retention window MailRules:HistoryRetention declares, which the account's synchronization run erases against in bounded passes, and by the cascade from the message it names. That inheritance is the point rather than a convenience: the history is derived from mail content and carries the erasure obligations of the mail it describes whatever the window says.

Nothing in either table is personal data. Rule names, folder aliases, mutation names, fact names, a derived revision, two identifiers, an instant, and a duration are the whole of it, and none is derived from what a message said.

The conversation a message belongs to

email_threads holds one row per conversation, and email_thread_identifiers one row per message identifier that conversation answers to. Both are owned by exactly one mailbox account and cascade with it. On stored_emails two nullable uuid columns carry the result: EmailThreadId names the conversation the message was placed in, and ParentStoredEmailId names the stored message it answers.

Column What it records
email_threads.Id The conversation's identity, a version-7 identifier, and the value every tool publishes. Minted when a message reaches no existing conversation
email_threads.MailboxAccountId The account the conversation belongs to. Membership never spans two accounts, because a message identifier is only unique in the sense the sender's own system gave it, and one account's correspondence must not be assembled out of another's
email_threads.AssembledAt When the conversation was started. It is what decides a merge: a message naming two conversations folds the later one into the earlier, so which of them survives is a fact about the mailbox rather than about the order somebody re-derived it in
email_threads.MergedIntoEmailThreadId The conversation this one was folded into, null while it is its own. The row is kept rather than deleted, so an identifier a tool published before the merge still resolves — a read follows the chain to the survivor instead of answering that the conversation is gone
email_threads.ConcurrencyVersion The xmin token, because the column above is amended in place and two arrivals can reach one row at once. Each reads a conversation, decides which of the two survives, and writes the merge; without the token the second write would settle a merge against a survivor that had already been folded into a third, and the chain a read follows would end at a row that is no longer anybody's survivor
email_thread_identifiers.MailboxAccountId, IdentifierHash The primary key, the account named by its identifier alone: it is what two messages binding one identifier collide on, and an identifier is scoped to one account rather than to the name one goes by. The hash is the lower-case hexadecimal SHA-256 digest of the identifier as it was stored, character varying(64)
email_thread_identifiers.EmailThreadId The conversation the identifier belongs to. Repointed rather than duplicated when two conversations merge

The identifier is stored as a digest and never as itself. A header is bounded at the 998 octets RFC 5322 allows, and a B-tree entry that wide is one PostgreSQL refuses at insert time — which would fail the arrival transaction rather than lose a value. SHA-256 is chosen for collision resistance rather than for secrecy: nothing here is a secret and nothing verifies one, and what the digest has to guarantee is that two identifiers never collapse into one conversation. Nothing is folded, trimmed, or normalized before it is hashed, because the mail ecosystem compares an identifier octet for octet. Storing no raw identifier is also the narrower record: the row says that some message named this conversation without carrying the name a sender wrote.

An identifier nobody stored is a row of its own. Membership is decided from internet_message_id, in_reply_to, and the thread references alone, so two replies to a message this deployment never fetched bind the same absent identifier and land in one conversation. That is why the identifiers are a table rather than a lookup over stored_emails: the conversation exists before, and often without, the message at its root.

ParentStoredEmailId is what makes a conversation a tree rather than a set, and it is a self-referencing foreign key on stored_emails with ON DELETE SET NULL — as is the conversation column beside it. A message whose parent is erased becomes a root rather than taking the erasure with it. Nothing stores an order: where a message sits in its conversation is computed on every read, because storing it would mean rewriting every row of a conversation each time one message arrived. The MCP tools describe what a caller sees of all this, and bringing stored mail up to a later release describes the one pass that writes these columns outside the arrival transaction.

Nothing in either table is personal data as stored. An account alias, a UUID, an instant, and a digest of an identifier are MailFathom's own names for things.

The contact book

contacts holds one row per person a book knows, and contact_addresses one row per address that person uses. There are two kinds of book and one pair of tables holds both: a user's own, holding the people somebody wrote down, and a mail account's, holding the addresses its arriving mail picked up. BookHolderId is which, and Origin agrees with it by a check constraint — a row the user wrote down is the one record on this page derived from no message at all, while a row collection recorded is an address that arrived in mail on the account it is filed under, written by the pass that stored the message rather than by a worker of its own. Contacts describes the rules every writer obeys and which books a reader reads together; what the schema itself decides is below.

Column What it records
Id MailFathom's own UUIDv7, minted when the contact is recorded. Never an address, because an address is a thing a person has rather than a thing they are
BookHolderId Which book holds this person, as text, led by the kind of holder: user: and the user's identifier where the book is a user's own, account: and the mail account's where it is an account's. The prefix is what keeps the two namespaces apart — both identifiers are UUIDs minted independently, nothing checks either against the other's table, and a mail account whose identifier equalled some user's would otherwise name that user's own book. It leads the two indexes a read would otherwise walk the table for — the listing and the address uniqueness below — so a read over several books seeks into each of them rather than scanning. It never changes: a contact is written in a book rather than moved between them, which is why promotion copies
UserId The user whose own book this is, keyed onto settings_accounts and cascading from it, or null on a collected row. The cascade is what takes a user's own book with the user
MailboxAccountId The mail account whose collected book this is, or null on an asserted row. Keyed onto mailbox_accounts and cascading from it, beside that account's folders, threads, and jobs, so a collected book goes with the mailbox that assembled it
DisplayName, DisplayNameSortKey The name as the user wrote it, and the upper-cased comparison form the listing is ordered and paginated by. The form is stored rather than derived in the query and its column is pinned to the C collation, so the order is the ordinal one that form was derived to produce instead of whichever collation the database was created with
PreferredNormalizedAddress Which of the person's addresses to use by default, as its comparison form. A column on the person rather than a flag on each address, because changing the choice is then one update instead of two that pass through a state where nobody, or everybody, is preferred
Note What the user wrote about the person, or null
Origin Asserted where somebody wrote the person down, Collected where an address merely appeared in arriving mail. Held as its own name for the reason every bounded value on this page is
RecordedAt, AmendedAt When the contact entered the book, and when it was last changed
ConcurrencyVersion The xmin token, because a contact is amended in place. What it settles is a row that changed or disappeared between the read an amendment is applied to and the commit — above all an amendment racing an erasure, which then writes nothing rather than putting the person back

The three holder columns cannot disagree. A check constraint requires exactly one of UserId and MailboxAccountId to be present, requires BookHolderId to be whichever it is under that kind's prefix, and requires Origin to be Collected on a mailbox's row and Asserted on a user's. A collected contact filed under a user, an asserted one under a mailbox, or a row filed under a key its own holder columns do not produce, is therefore a row the database refuses rather than a state every reader has to reason about.

contact_addresses carries the address as written beside its comparison form, the contact it belongs to, and the book that contact belongs to. It is rows rather than an array column, and that is what makes both rules over it structural. The comparison form is unique within one book rather than across the table, so one address stays in one person's hands however many callers claim it at once — the loser of that race is recognized by the constraint it violated and is answered with which contact holds the address — while a user's own record of somebody stands beside the collected record of the same address their mailbox picked up, and two mailboxes each hold their own. Uniqueness across the table would instead let one book decide what another may contain, which is exactly what a shared mailbox would do to every user assigned it. Which of those records answers a read is the reading order, not the index. And the foreign key cascades, so erasing a person takes every address row with them rather than leaving a second statement to remember.

The book is repeated on the address row rather than read through the contact, because an index cannot reach through a foreign key to a column on the parent and the uniqueness above is over the book and the address. What keeps the repetition honest is the key itself: the foreign key is (ContactId, BookHolderId) onto the alternate key (Id, BookHolderId) on contacts, so an address row can only carry the book of the contact it hangs on — no other pair exists to point at.

The preferred address is deliberately not a foreign key onto the address row. The two tables already point one way, and a key pointing back would make inserting either of them first impossible without deferring the constraint; that the named address is one the contact holds is enforced by the domain when the record is written and again when it is read.

The calendar

calendar_events holds one row per event this deployment knows about. The calendar is a person's rather than a mailbox's, which is the one place it diverges from the contact book above: somebody assigned two accounts has one day, so the row keys onto settings_accounts and cascades from it, and no mail account appears on it at all. Nothing here is synchronized against an external calendar server; calendar events holds what that decision covers and the rules every writer obeys.

Column What it records
Id MailFathom's own UUID, minted when the event is recorded and kept through every acceptance and amendment
UserId Whose calendar holds it, keyed onto settings_accounts and cascading from it, so erasing a person takes the days they had planned. It never changes: accepting a proposal leaves the event on the calendar it was proposed to
Title What the event is called, as whoever wrote it down wrote it
StartsAt, EndsAt When it begins, and when it ends where anything said so. A duration is derived from the pair rather than stored beside it, because an end and a duration are one fact; the domain refuses an end that is not after the start
IsAllDay Whether the event is stated as a day rather than as a clock time. It changes nothing about when the event is — StartsAt is still the instant the day opens at — and what it decides is the instant a reminder is measured back from, which calendar_event_reminders below gives
Origin Asserted where somebody put the event on their calendar, Proposed where a reading of their mail offered it and nobody has agreed. Held as its own name for the reason every bounded value on this page is, and accepting a proposal changes this column rather than writing a second row, which is what keeps the message it cites pointing at the event the person holds
SourceStoredEmailId The message a date was found in, or null. A pointer rather than a copy — nothing of the message is on this row — and an identifier rather than a foreign key, for the reason below
ImportedUid The UID the .ics entry it was imported under named itself by, or null on an event a person typed or a reading proposed. Compared exactly as written, RFC 5545 giving it no property but equality
RecordedAt, AmendedAt When the event was written here, and when it was last amended or accepted
ConcurrencyVersion The xmin token, because an event is amended in place. What it settles above all is an amendment racing a deletion, which then writes nothing rather than putting the event back

The cited message is an identifier rather than a foreign key, which is how the event outlives the mail. Every foreign key onto stored_emails cascades, so that nothing derived from a message survives it, and that rule is kept absolute rather than given exceptions — a table whose rows have to outlive the mail cites it as a plain identifier instead, as mailbox_mutation_audit_entries already does. An event is such a row: it is somebody's own plan rather than a derivation of a message, and a message deleted in the mailbox in the ordinary way removes the same row an erasure would. Deleting mail is not something anybody expects to change what their day holds. What the shape costs is that nothing constrains the value, so a citation whose message is gone resolves to nothing — which is the answer a reader is meant to get, the thread simply no longer being there to open.

Deleting an event removes the row. There is no state a deleted event is in and nothing restores one, which is also how a proposal nobody wanted is dismissed.

What announces an event

calendar_event_reminders holds the leads one event is announced at, one row per lead, keyed on the event and the lead together. A row rather than a column on the event because a person sets several, and a lead rather than an instant because what they chose is a quarter of an hour beforehand — an event moved carries its reminders to the new time without anything rewriting what they asked for. An event carrying no row announces nothing, which is a statement somebody made rather than a field they left.

Column What it records
CalendarEventId, MinutesBefore The event and how long before it, together the primary key — so one event states each lead once, and the pair is what a reminder is identified by wherever one is named
DueAt The instant that lead currently falls at, derived from the event when the row is written: StartsAt for an event naming a clock time, and nine in the morning on the day for one stated as IsAllDay, both read in the offset the event itself carries. Written rather than computed on read so the pass announcing reminders asks the database which have come due instead of reading every calendar to find out, and rewritten whenever the event moves
RaisedForDueAt The instant this reminder was last announced for, and null while it stands unannounced. The claim is made against the instant rather than as a flag, which is what makes a reminder on a moved event due again at its new time and one moved back onto an announced time stay quiet — a flag would have to be cleared by whoever moved the event, and a writer that forgot would silence the reminder for good

The foreign key onto calendar_events cascades, so deleting an event takes what would have announced it with it and a reminder for an event nobody holds cannot be read. Nothing here points at mail, and the rows carry no text: what a reminder is about is the event, and the notification the pass writes is what carries the title.

Durable background work

jobs holds work that is enqueued now and done later: what it is, what it points at, who is holding it, and until when. A rule's schedule is what enqueues into it today, and the handler that runs one records a whole-mailbox rule run for an account; this is the record every consumer of durable background work is written against, and ADR 0009 is the decision it implements. What paces the worker over it is the Jobs configuration section.

Column What it records
Id What addresses the job, and the primary key. A version-7 identifier, so one batch's inserts land together in the index rather than scattering across it
JobType The kind of work, held as the closed enumeration's own name. The name is the identity — the word in a log line, the name of a span, the dimension a counter is broken down by — and it names exactly one payload contract, which is what lets the document beside it be read back as the shape it was written as. A name the running build does not declare is left alone rather than failed, because a type an older replica has never heard of is a fact about the deployment and not about the work
IdempotencyKey The identity of one execution, composed by whoever knows what the work is and opaque here. It is unique with the type across the whole table, which is the idempotency guarantee itself rather than a support for one
Payload The references the work is described by, as one jsonb document. Nothing queries into it — the key, the type, the account, and the available instant are all columns — so it is a document rather than a schema, and it is bounded at the enqueue boundary so a payload that copied content into it is refused instead of stored
MailboxAccountId The account the work belongs to, null when it belongs to none, and the only account reference in the schema that is nullable — work belonging to no mailbox belongs to no account either. A foreign key onto mailbox_accounts that cascades, so removing an account takes its queued work with it. It is also what the turn below is read over, and the subquery answering null for an accountless row is what keeps such a row claimable rather than stranded
State Pending while the job is claimable, Claimed while an attempt holds it, Succeeded once it is done, DeadLettered once nothing will attempt it again, and Dropped once an operator has decided it never will. Text for the reason every other bounded value here is: it stays readable in an ad-hoc query and survives a reordering of the enum
AvailableAt, EnqueuedAt, StateChangedAt When the job becomes claimable, when it was written, and when its state last moved. The first is a column rather than a schedule elsewhere, because it is what the claim selects on, and it is where a retry's backoff is expressed
TurnAt When this job's turn comes once its mailbox's queue is shared with every other mailbox's, and what the claim orders by. A virtual instant rather than a real one: the enqueue reads how far that account's waiting work has already reached, adds a second, and takes the later of that and the instant the job becomes available — so an account with nothing waiting lands on the moment its work is due, and an account queueing a thousand jobs at once holds turns spread over the next thousand seconds instead of a thousand turns at one instant. The fairness is between mailboxes rather than between people, because a job names the account it is for and no user at all, and an account two users share is one queue rather than two. That is the whole of what stops one mailbox's backlog postponing another's due work, and it is decided here rather than in the claim so the claim stays one indexed statement. Never null, and never earlier than AvailableAt as written: the enqueue floors it there, and a retry and a returned dead letter each carry it forward to the instant they name, so no write leaves a job holding a turn it could not take. The two do diverge afterwards, and a release is where — it moves AvailableAt to now and leaves the turn alone, because the attempt gave the work back rather than failing at it, so a released job resumes the place it already had rather than going to the end of its account's queue. Nothing reading a row may assume TurnAt >= AvailableAt. Rows written before the column existed carry the available instant they already held, which is the order the claim had been draining them in
AttemptCount How many attempts have been handed out. Counted by the claim rather than by whatever runs the work, because a process that dies mid-execution never reaches a line that would have counted it and a crash loop would otherwise be invisible. A release gives one back, because a shutdown is not something the work did
LastFailureClassification, LastFailureReason What the last failed attempt was classified as — Transient or Permanent — and the operator-safe name of what failed, both null until one has. The reason is a type name and a stable error code and never an exception message: a handler works on mail, and a library's message may quote a subject, an address, or a header into a column that outlives the run
EnqueuedTraceParent, EnqueuedTraceState The W3C trace context of whatever was running at the enqueue, both null when nothing was being traced and on every row written before the columns existed. The one pair here that describes neither the work nor its state: a worker claims a job long after the span that caused it ended, so the attempt cannot be that span's child, and what these make possible instead is a link from the attempt's span back to the trace — a cause hours earlier reached in one step. Nothing queries by either, and a value the reader cannot use is treated as absent rather than failing the attempt. A trace identifier is a random number this process minted, which is what makes it safe to keep beside work that points at mail
LeaseOwner, LeaseExpiresAt The attempt holding the job and the instant after which it is claimable again, both null while nothing holds it

A payload names an account and never a user. The mail graph is keyed by the account's generated identifier alone, so the reference a payload carries is that identifier, and there is nothing beside it for a handler to resolve a person from. Stored mail is discarded and resynchronized across the migration that keyed the graph that way, and the queue is drained with it, so no document written against the earlier shape survives to be parsed.

Enqueuing asks the table one question before it writes to it: whether this job type already has as many rows Pending as Jobs:MaxQueueDepthPerType allows. That runs on every enqueue rather than occasionally, which makes it the second query this table runs at any volume — and it is bounded rather than counted, because the read stops at the depth it is comparing against instead of totalling the backlog. A queue at its depth refuses the enqueue and says so, so the caller slows down, asks again later, or stops producing; a request whose work is already queued is still answered with that job rather than turned away. Two enqueuers meeting the bound together can both pass it and the depth overshoots by as many as raced, because this is backpressure rather than an invariant.

A claim is one statement: it selects the due rows of a type the asking process runs whose turn has come first, under FOR UPDATE SKIP LOCKED, and stamps them with a lease owner and an expiry in the same statement. Two things follow. Two workers claiming at the same moment take different jobs instead of waiting on each other, which is what makes the queue drainable by more than one process. And a job is due either because it is pending and its available instant has passed or because it is claimed under a lease that has run out — so work in flight when a process died is picked up without an operator doing anything, and nothing has to be told the process is gone. Both of those instants are judged against PostgreSQL's now(), and every write that decides one — the lease the claim stamps and each renewal of it, the available instant an enqueue that names none takes, a retry's backoff, a release, and a returned dead letter — stamps it from now() too, with a duration passed as an interval. Replicas decide whether one job's lease has run out by comparing its expiry with the present, so a present each read from its own clock would let a replica running fast take a job its holder is still executing; one clock for the deployment is what makes the exclusion independent of drift between replicas. EnqueuedAt and StateChangedAt record history rather than decide anything, and stay on the writing process's clock.

The order is TurnAt rather than the instant a job became available, and that is what makes the claim fair across users rather than first-in-first-out. Under one user the two orders are the same, because a user with nothing waiting takes the instant its work is due. Under several they are not: a person whose mailbox produced a large backlog holds turns stretching ahead of the clock, so somebody else's job — whose turn is the moment it arrived — is claimed between them instead of behind the whole backlog. Work belonging to no account is its own participant and is claimed on the instant it is due, so nothing that no caller requested is starved by the rule. Nothing ranks anything at claim time: the order is one column of one index, because a claim that had to rank a backlog could not also be one statement under FOR UPDATE SKIP LOCKED — PostgreSQL refuses to combine that clause with a window function. ADR 0014 is the decision this implements, and it fixes the property rather than the algorithm: no user's backlog may postpone another user's due work indefinitely.

Renewal, completion, a scheduled retry, a dead letter, and release are each a single update conditional on the lease owner still matching. An attempt that lost its lease, finished late, and tried to write its result finds the row owned by the attempt that replaced it and writes nothing. That compare-and-set is why the table carries no xmin token: the fact that decides whether a writer still owns the work is the lease, and a row version beside it would report a conflict for a renewal that changed nothing an attempt cares about.

Which of them a worker writes is decided by how the attempt ended, and they are deliberately not one. A handler that finished completes the job. A handler stopped because the host is shutting down releases it, so the job is claimable again at once, the attempt the claim counted is given back, and the deployment costs it nothing.

Anything else is a failure, and the failure is classified before the attempt budget is consulted. A failure that could clear on its own — a dependency whose resilience pipeline declined the work, a provider that said its answer was worth repeating, a connection that dropped, an execution that ran out of time — schedules another attempt: the row goes back to Pending with an available instant a jittered exponential delay ahead of PostgreSQL's now(), so the backoff is the column rather than a timer anywhere. A failure that could not — a rejected credential, a refused request, anything whose meaning is unrecognized — ends the job on its first attempt, because repeating it could only reach the same answer, and so does a transient failure that has used up Jobs:MaxAttempts. Either way the row becomes a DeadLettered one that keeps its attempt count, its key, and the classification and reason it ended on. A dead letter is inert: the claim's predicate names the two claimable states, so nothing takes it again, one job that cannot succeed consumes no further attempts, and the jobs behind it are unaffected.

A dead letter is terminal but not permanent, because the two things that could resolve one are both an operator's. Returning it to the queue is a conditional update from DeadLettered back to Pending that hands the attempts back and makes the row due now — the same row, so the work runs under the identity it was already enqueued with rather than as a second job, and a retry of a job something else already dealt with changes nothing and says so. Writing it off is a conditional update to Dropped, which is a fifth state rather than a deletion: the row stays, keeps the failure that ended it, and goes on holding the key that refuses the same execution. Both are reached through the administrative endpoint and neither reads the payload.

A terminal row keeps its key. That is what stops a repeating trigger enqueuing work that has already been done, and it is why a finished job stays in this table rather than moving to another one. It also makes pruning a correctness setting rather than housekeeping: erasing terminal rows is what ends the deduplication, so whichever change adds pruning inherits a retention floor of the longest window in which one trigger can legitimately fire again.

What the store delivers is at-least-once execution and nothing stronger. Uniqueness stops the same work being enqueued twice; only a handler can stop a re-run after a crash from having a second effect.

What each recurring dispatch has already done

job_schedules holds one row per declared schedule: where its occasions are counted from, and which of them it has already turned into a job. It is what makes "a due time that passed is skipped rather than replayed" a property of the schema — the state says which occasion was last acted on, and everything before that is simply never asked about again.

Column What it records
ScheduleId The schedule's identity, and the primary key. Composed of MailFathom's own names — for a rule's schedule, the account identifier and the rule name — so it survives a restart, means the same thing on every replica reading one configuration, and carries nothing out of a message. An identity that changed would be seeded afresh and would forget the occasion it last dispatched
ObservedFrom When this instance first saw the schedule declared. The first pass to meet a schedule records this instead of dispatching, so a declaration added today does not owe every occasion since the epoch
LastOccurrenceAt The occasion the dispatch last acted on, null until it has acted on one. Occasions are counted from this when it is set and from ObservedFrom when it is not, and it advances even where the occasion was passed over — which is exactly what makes a missed one skipped rather than owed
LastDispatchedJobId The job the last dispatched occasion enqueued, null until one was, kept so an operator can follow a schedule to the work it produced

There is no xmin token, because one writer decides about one schedule: the pass reads a state, decides, and writes the decision back, and a second instance reaching the same occasion is answered by the queue's own uniqueness rather than by this row — the job's idempotency key is the schedule's identity and the occasion's instant, so two instances dispatching one occasion produce one job.

The row carries no foreign key onto anything. A schedule is declared in configuration rather than stored, so there is no row for a constraint to point at, and a declaration withdrawn from the configuration leaves its state behind harmlessly: nothing reads a state whose schedule is no longer declared.

Nothing in it is personal data. An account alias, a rule name, two instants and a job identifier are MailFathom's own names for things.

Who is holding work that must not run twice

work_leases is how a deployment running more than one replica decides which of them does a piece of work nothing enqueued: a mailbox supervisor, a deployment-wide sweep, an operator's re-derivation, the stored-content move. ADR 0031 is the decision it implements, and it is jobs' lease in a second shape: the same stamped row with a holder and an expiry, the same compare-and-set on every write, and none of the queue's machinery, because a job is an occasion something asked for and a lease is a role a replica holds for as long as it keeps renewing.

Column What it records
Scope The primary key, and the unit of work being held. It is composed by the caller out of the key its own progress row already carries — a mail account, the name of a walk, the deployment — so nothing decides what one unit of the work is twice. MailFathom's own names, never a subject, an address, or anything else out of a message
Holder Which hold has the scope, as a generated identity rather than a process name. Every write is conditional on it, so a replica whose lease was taken over and which then renews or releases late finds the row naming somebody else and writes nothing — the same reasoning jobs keeps its lease owner per attempt for
Replica Which replica the hold is running on, as the machine name and process identifier of a MailFathom process. It is descriptive and nothing compares it: every write stays conditional on Holder, because a hold is what a lease identifies and a process may hold several. It is what lets a status surface answer about the deployment — an account held elsewhere is reported as supervised and by whom, rather than as an account the answering replica has never run. A row written before this column existed reads as unknown
HeldSince When the current holder took the scope. A renewal leaves it where it is, so it says how long this hold has been running rather than when it last wrote
ExpiresAt When the scope becomes takeable again whatever its holder is doing. It is the only column a renewal moves, and the comparison a claim is decided by

There is one row per held scope and none for a scope nothing holds, because a release deletes the row rather than clearing it. So the table is the set of holds the deployment currently has, which is what an operator asking who holds what reads, and it is bounded by how much singleton work the deployment configures rather than by how long it has been running. Nothing cascades into it and nothing points at it: the scope is a composed name rather than a reference, so a lease whose subject is gone is a row the expiry frees rather than one a constraint has to reach.

A claim is one statement. It inserts the scope, and where a row is already there it takes it only when the recorded lease has run out — the conflict resolved against the existing row's expiry inside the same statement. Two things follow. Two replicas claiming one scope at the same moment leave one holder, because the primary key decides it rather than a check either of them could have made first. And a replica that stopped answering releases everything it held without anything having to notice: an expired lease is indistinguishable from one whose holder is gone, which is the same crash recovery jobs gets from its own expiry.

Every instant in the row is PostgreSQL's own rather than a reading from the replica that wrote it, and the caller is told the expiry the row ended up with rather than one it computed. A deployment therefore holds one clock: a replica running minutes fast finds a live lease live, where a comparison against its own clock would have found it expired and handed it a scope somebody else is working under.

What a holder is promised is one writer, and never one runner. The compare-and-set takes back a write; it does not take back an IMAP connection, an SMTP send, or a provider call already in flight. So MailFathom's own state has exactly one writer, while a mail server may briefly see two connections for one account — "briefly" being the margin between a holder failing to renew and the expiry it last read, which is why a holder stops its work on the first failed renewal rather than when the clock says the lease is over.

Nothing in it is personal data. A composed scope name, a generated hold identity, and two instants are MailFathom's own names for its own work, and the same three are what the telemetry beside it publishes: which scopes a replica holds, how often a scope changed hands, and when a holder lost one. The hold identity stays off every measurement, because it is fresh per lease and would make a new time series of every takeover; an operator who needs it reads this table.

Where an operator's re-derivation has got to

mail_rederivation_positions holds one row per unfinished re-read of stored MIME — the walk mfctl mailbox rederive drives when a release starts recording something the payload already carried. It is what makes an interrupted invocation resume rather than restart.

Column What it records
MailboxAccountId The mailbox whose mail is being walked, and the first of the three columns the primary key is over
MailboxAccountId The account, and the second, following the user because an identifier names one account only within it
FolderAlias The one folder the walk was narrowed to, and the third. The empty string is the whole-account walk: a primary key holds no null, and no folder can collide with it because an alias is validated non-blank wherever one is created
LastProcessedStoredEmailId The last stored email a committed batch read. The walk is ordered by that identity, which is total, stable, and already indexed, so the next batch continues past this value
UpdatedAt When the position last moved, which is what says whether a walk somebody abandoned is worth finishing
ConcurrencyVersion The xmin token again. The insert of a scope's first position is settled by the key; the updates after it are the same race one row later, and without the token a slower walk's earlier position would be written over a faster one's later one and re-read the difference on every pass afterwards

It is a table of its own rather than a row in backfill_positions because that walk is one per deployment and named by a constant, while this one is one per scope an operator names — keying it by the scope is what lets two accounts be refreshed independently. There is no foreign key onto the account: the row is a cursor over rows that are already keyed to one, and requiring the account row would make the walk depend on a table it never reads.

A row exists only while a walk is unfinished. The segment that reaches the end of its scope removes it, so the same scope asked for again after a later release starts at the beginning rather than behind where the last refresh stopped.

Nothing in it is personal data. An account alias, a folder alias, a local identifier and an instant are MailFathom's own names for things.

mail_rederivation_runs holds the operator's half of the same walk, and it is a second table because the two answer different questions and outlive each other differently. The position above is a cursor the walk consumes and deletes; this is what an operator asked for and what has come of it, and it stays after the walk has finished so that mfctl mailbox rederive-status can say how the last run ended rather than that there was none.

Column What it records
MailboxAccountId The mailbox whose mail the run walks, and the first of the three columns the primary key is over
MailboxAccountId The account, and the second, ordered as the position row's is
FolderAlias The one folder it was narrowed to, and the third, under the same empty-string convention the positions table uses. Two scopes are two runs, so a folder being re-derived says nothing about the account's own run
RunId The run's own identity, a UUIDv7 generated from the instant it was asked for. It is in the job's idempotency key, which is what makes a run started after an earlier one finished a new piece of work rather than one the queue answers with a terminal row it already holds
RequestedAt When the run was asked for
SegmentCount How many attempts the walk has been handed to. It rises when an attempt hands the rest of the scope on, and it is in the idempotency key beside the run so the next segment is a job of its own rather than the one that just ended
RederivedEmailCount, UnreadableEmailCount, MissingContentEmailCount What the run's passes have committed so far. Every pass adds its own figures to what the row holds rather than writing a total, because two attempts of one run can overlap and a total computed outside the transaction would lose whichever committed first
EndedAt When the run reached the end of its scope, null while it has not. That is what "a run is outstanding" means, and it is what a second request for the same scope is answered with
ConcurrencyVersion The xmin token, for the same reason the position row carries one: the counts are read, added to, and written back, and without the token the slower of two passes would write its own reading over the faster one's

There is no foreign key onto the account, and none onto the position row either. The run is a record of something an operator asked for, and the position is a cursor the walk keeps: erasing the mail behind a run leaves counts describing work that was really done, and a run whose position row is gone is a finished run rather than a broken one.

Nothing in it is personal data. An account alias, a folder alias, an identifier this deployment generated, counts, and two instants are MailFathom's own names for things and for its own work.

Where the move of stored content has got to

content_move_runs holds the one move of database-held raw MIME into the object backend a deployment may have — the walk mfctl content move drives after an operator selects ContentStorage:ObjectStorage on a deployment whose mail is already stored. It is what makes the move resume rather than restart across a restart, and what an operator reads its progress off.

Column What it records
Name The primary key, and always stored-content. A check constraint pins it to that one value, which is how the table holds at most one row: a move is a decision about the whole deployment rather than about a scope somebody names, so there is nothing to key it by and a second row would be a second walk over the same payloads
RequestedAt When the move was asked for. It is also the identity a pass commits against — a pass that finds a different instant on the row is writing into a move somebody replaced, and records nothing
State Running, Paused, or Completed, written as its own name rather than an ordinal. Only the first is carried; the other two are what make a pass idle without cancelling anything
Kind Which of the four raw-MIME tables the walk is on, written as its own name for the same reason. The walk moves to the next kind when a kind runs out, and past the last one it is finished
ResumeAfter The payload identity the last committed pass reached inside that kind, null at the start of one. The walk is keyset-ordered by that identity, so the next pass continues past this value and re-copies nothing it verified
CopiedPayloadCount, FailedPayloadCount, MovedByteCount What the move's passes have committed so far. Every pass adds its own figures to what the row holds rather than writing a total, for the reason the re-derivation run does
EndedAt When the walk reached the end of the content, null while it has not
ConcurrencyVersion The xmin token again. A pass reads the row, adds to it, and writes it back while an operator may be pausing it from a request, and without the token one of the two would be written over

There is no foreign key onto anything, and no row per payload. What the move is doing to a payload is on the payload's own row — the backend it names and the locator it carries — so this table holds the walk and nothing else, and a payload repointed by a move that was later replaced is simply an object-backed payload.

A row survives the move it describes. Completed is what lets mfctl content move-status say how the last move ended rather than that there was none, and asking for another move writes a fresh row over it, starting again at the first kind — which is how payloads a move left in the database are reached once the reason has been repaired.

Nothing in it is personal data. A constant, two instants, a state, a payload kind, one local identifier, and three counts are MailFathom's own names for its own work. The resume position is the one value that names a row holding mail, which is why it is not served by the endpoint that reports the rest.

The exports a mailbox has been asked for

mailbox_exports holds one row per export of one account's stored mail, keyed by a generated Id an operator follows, cancels, downloads, and deletes the export by. The row outlives the job that writes the archive, which is why it exists at all: a job is claimed, retried, and eventually forgotten, while an archive has to be findable by somebody holding nothing but the export's identity for as long as MailboxExport:Retention allows. Carrying a mailbox out is the operation.

Column What it records
MailboxAccountId The account whose mail the export carries. Every read is scoped by it, and the foreign key onto mailbox_accounts cascades, because an erased account must leave no record pointing at an archive of it
FolderPath The one folder the export covers, or null for the whole mailbox. It is the deployment's own local path rather than any server's, and it is what a second request is compared against to decide whether it names the same scope
State Queued, Running, Completed, Failed, Cancelled, Expired, or Deleted, written as its own name rather than an ordinal, so an operator reading the row sees what the export is doing
RequestedAt When it was asked for, and the order the listing reads in
MessageCount, ByteCount What has reached the archive so far, written about once every hundred messages while it runs and holding the final figures once it is finished
ArchiveByteLength How large the finished archive is, null while there is none
ObjectLocator This deployment's own key for the archive object, null once there is nothing to serve. It never reaches a caller, and it is one of the references the content reclamation asks about, so a live archive is never mistaken for an orphan
CompletedAt, ExpiresAt When the archive was written and when it goes if nobody deletes it first. Both are null until one exists, and both are cleared with the locator when it goes
FailureCode The stable five-digit code of what stopped a failed export, null for every other state

No xmin token, for the reason jobs carries none. An operator cancelling and the writing job completing do reach this row at the same moment, and what settles that is already a compare-and-set: every write states the state it expects to find and is applied as one conditional statement, so the loser changes nothing and is told so. A row version beside that would be read by neither writer, because neither goes through the change tracker.

Two indexes, and each serves exactly one read. ix_mailbox_exports_account_requested over the account and RequestedAt descending is the listing an operator asks for. ix_mailbox_exports_expires_at is the expiry pass, and it is partial on ExpiresAt IS NOT NULL, because the pass asks only about archives that exist: an export that failed, was cancelled, or has already gone carries no expiry.

The record is written before the object is removed, in both the deletion path and the expiry sweep, which is the ordering every deletion here uses: a row saying the archive is gone while the object is still there leaves an orphan the reclamation removes, and the opposite order would leave a row offering a download of bytes that are not there.

The folder path is the only column holding anything a person chose, and it is here rather than in a log for exactly that reason — a durable store holds it beside the mail it names, and the audit record of an export reports whether the whole mailbox was covered rather than which folder was.

The outgoing messages waiting to be sent

outgoing_emails holds one row per message MailFathom has been asked to send, written before the first SMTP command is issued and advanced as the attempt proceeds. It is mailbox_mutations again in a second protocol, with the consequence raised: a submission is the MIME being built, an intent being recorded, a connection being opened, each recipient being offered, the body being transmitted, and the server answering — and a process can die between any two of those. One of those windows is genuinely undecidable from outside. A crash immediately after the body went out and immediately before the acknowledgement was recorded leaves an outbox that cannot say whether the message was delivered; retrying sends it twice, and not retrying loses it. Unlike a duplicated local copy, a duplicated delivery cannot be withdrawn from the mailbox it reached.

Column What it records
Id The record's identity, and what the stored message and the recipients hang on. A UUIDv7 generated from the instant the intent was written, so the outbox's own order is the identifier's
MailboxAccountId, UserId The account the message is submitted through and sent as, and the user who authored it. The account is the owner and the user is the author, which is why both are here where every other reference to an account carries the identifier alone. Plain columns rather than a foreign key: the account row is created by the first folder binding synchronization writes, and an account configured only to send need never have synchronized anything
RequesterOrigin, RequesterIdentity The authored act that asked, by kind and by the text two requests are compared by. A rule answers with its name, the revision it was evaluated at, and the email it acted on; somebody present answers with a key of their own
PrincipalFingerprint A fixed-width digest of the identity the caller was admitted under, written by the outbox rather than stated by a caller. It is what confines a read or a withdrawal of a send to the caller that queued it, and a digest rather than the identity so the comparison is possible without a second copy of whatever a token asserted living at rest. A send a rule asked for carries the process identity's digest and is additionally excluded by its origin, so no caller reaches one; a row written before the column existed carries null and therefore matches nobody
Stage How far the submission has durably got, in the vocabulary below
MimeByteLength How many bytes of MIME were stored. Kept beside the record as well as on the message, so the size bound a submission server advertised can be compared against it — and the outbox listed — without reading a single queued message's bytea
AttemptCount Counted by the claim itself rather than after the attempt, so an attempt that kills the process still counted
AvailableAt The instant the record may next be claimed. It is the backoff written down: a transient failure moves it forward by the delay that attempt earned, a send nothing has deferred carries the instant it was recorded, and a send written to leave at a named time carries that time — which is the whole of what holding one costs, since the claim below already refuses a row whose availability has not arrived
DueAt, DueZoneId The time the message was written to leave at and the zone whoever named it was thinking in, both null for a send that named none. Kept beside AvailableAt rather than derived from it, because a retry moves availability and lateness has to be measured from the authored time; the zone is kept because nine in the morning is nine in the morning on both sides of a daylight-saving transition and the offset alone would not say which nine was meant
LeaseOwner, LeaseExpiresAt Who is attempting it and until when, both null while nobody is. The pair is what makes a crash recoverable without anything being told the process died
RecordedAt, StageChangedAt When the intent was written, and when the record last moved. The second is what says how long a stuck send has been stuck
LastFailureCode The code of the failure the last attempt ended in, null while none has. The code is kept and the message is not, because a failure message is assembled at the failure site and may repeat what a remote server wrote
LastReplyCode The reply code the server last answered the transmission with, null while it has answered none. A different fact from the per-recipient codes: a server accepts or refuses each address separately and then answers once for the body

Stage is the submission's own vocabulary rather than a generic queued and sent, because it is what a later attempt reads:

Stage What it says
Recorded The intent and the message are durable, and nothing has reached a submission server. It is also where a failed attempt that provably transmitted nothing is rewound to, so a deferred send waits here rather than in a stage of its own
TransmissionBegun The body has begun to go out and the server's answer to it was never read
Sent The server accepted the message for every recipient it had accepted
Refused Nothing will offer it again, and LastFailureCode says what ended it
Cancelled The send was withdrawn before anything was transmitted for it, which is what a message held until a named time is withdrawable for the whole of

TransmissionBegun is written before the transmission rather than after it, which is the whole point: announcing it afterwards would announce it only in the case where the crash it exists for did not happen. A record found there is not re-sent. Two of the terminal stages are reachable from one stage only, which is that same window read from either end — Sent follows only TransmissionBegun, so no row claims a delivery nothing could have produced, and Cancelled follows only Recorded, so no row claims a withdrawal after bytes that may already have reached somebody.

A withdrawal is one conditional statement rather than a read followed by a write. It moves a row to Cancelled and clears the lease columns only where the row is still at Recorded and no unexpired lease is held on it, which is the same predicate the claim below applies — so a send an attempt is holding is left alone, an expired lease counts as free in both, and the statement writing nothing is how a caller learns the send can no longer be withdrawn. Applied a second time it matches nothing, because the row is no longer at the stage it names, which is what makes withdrawing twice one withdrawal rather than two writes with the same result.

A send stopped mid-transmission stays at TransmissionBegun and is never advanced by anything automatic. Moving it to Refused would be this system stating that nothing reached anybody, which is the one thing nobody can establish about that window; moving it back would send it twice. So the stage is left where it is and LastFailureCode is stamped with 28011, which is what makes the row say unknown rather than stuck. It is claimed by nothing afterwards — the claim below takes Recorded rows alone — so the only thing that moves it is a person deciding what happened.

That is also why the rewind exists. An attempt that failed before any recipient was accepted has provably transmitted no body, so its record goes back to Recorded and is attempted again; an attempt that failed after one was accepted may have, so it stays where the paragraph above leaves it. Which of the two applies is decided from the replies the server actually gave during that attempt rather than from the exception, because a body is only ever offered after at least one RCPT TO was accepted.

A send that has not reached a terminal stage is what a restart reads, oldest first and bounded like every other public query. A refused row stays in that answer for the reason an abandoned mutation does: being given up on is what stops a send being attempted, and it would be worth nothing if it also stopped the send being seen.

outgoing_email_recipients holds one row per person the message is addressed to, keyed by the record and the position in its recipient list. A message is offered per address and answered per address, so a mistyped address among five must not stop the other four, and the four the message reached must not be offered it again when the fifth is retried. Each row carries the Address, the Role the composed message names them in — To, Cc, or Bcc, which reach RCPT TO identically — the Status, and the LastReplyCode and AnsweredAt of the last answer about them. It also carries a nullable ContactId where the address came out of the contact book rather than from an author's own typing, which the AddOutgoingRecipientContact migration adds. Both are kept because they answer different questions: the address is what a resumed attempt offers, and the contact is which person the message was addressed by naming — a record holding only the person would answer the wrong question a year later, since a message sent to somebody whose address changed afterwards was sent to the address they had. It carries no foreign key onto contacts and no index, deliberately in both cases: a contact amended, promoted, or erased later must not rewrite what was sent, and nothing ever looks a send up by contact. It carries an xmin token of its own rather than relying on the record's, because an attempt answers about one address without touching the record above it: without one, two attempts settling the same recipient would be a last writer winning silently, and settling a recipient is what decides whether anybody is offered the message again.

Status has exactly three values, and it answers exactly one question: is this recipient offered on the next attempt. Accepted means an acknowledged transmission covered them, so nothing offers them again; Refused means a server permanently refused them, so nothing offers them again and nothing reaches them; Pending is everybody else, which includes a recipient a server temporarily rejected — the reply that deferred them is recorded beside the status rather than encoded in it. A recipient already settled keeps the answer it has, so a late transient reply cannot undo a delivery that already happened.

The ordinal keys the row rather than the address, for two reasons. An address is personal data and a key is repeated into every index over a table; and the ordinal keeps the recipients in the order the request named them, which is the order a composed message writes its headers in. The comparison form of the address is deliberately not stored beside it, unlike a received message's participants: those are filtered and grouped by address in queries the database answers, while these are read back with their record and compared in memory against the handful of answers one attempt produced.

outgoing_email_contents is the message itself, in the same one-to-one arrangement email_message_contents has with stored_emails and for the same reason: keeping the bytea out of the record means listing what is queued never loads a single message's bytes. It is written once and read back for every attempt rather than recomposed, which is not an optimization — a message rebuilt between attempts carries a different Message-ID and would thread as a second message in every recipient's client. A second enqueue of the same identity therefore leaves the stored payload exactly as it is.

The copies of an outgoing message that are in the mailbox

outgoing_email_filings holds one row per place a copy of an outgoing message has been put, keyed by the record and the filing — draft, held, or sent — so an account's own Sent folder and its outbox folder are two rows of one send rather than two records. It exists because an APPEND cannot be corrected by repeating it: every mutation elsewhere in this schema names a message the server already holds, while an append creates one, so a second attempt is a second copy in somebody's folder that nothing afterwards can tell from the first.

That key is named pk_outgoing_email_filings for the reason pk_email_embeddings is: it is what two passes reaching one send at once collide on, and a lost race is only recognized as one where the constraint has a name to recognize it by. The loser retries from a fresh read, finds the row the winner issued, and appends nothing.

Column What it records
OutgoingEmailId, Filing The send and which of its places this row is, which together are the key. A cascade from the record removes them with it
MailboxAccountId The account whose mailbox holds the copy, carried here so the read that recognizes a copy coming back is answered without joining the record
FolderAlias, FolderPath The folder the copy was appended to, as the alias an operator wrote and the path that alias named at the time. Both are kept because the alias is what a failure is reported by and the path is what a discovery is matched against
Stage Issued before the command went out, Confirmed once the server answered, Withdrawn once the copy was taken back or given up on
PlacementUidValidity, PlacementUid Where the server said it put the copy, both null on a server that advertises no RFC 4315 UIDPLUS and therefore said nothing
InternetMessageId The identity read back off the appended bytes, which is what recognizes the copy where the server named no placement
AppendedAt, ObservedAt, WithdrawnAt When the append was issued, when the copy was first seen coming back through synchronization, and when it was removed. The first is what bounds the window a duplicate the provider filed is still acted on within; the second is a record of the meeting rather than a bound on the read, because one message can occur twice in one folder and both occurrences are recognized
xmin The concurrency token, as everywhere else

A row at Issued is the undecidable window, and it is left undecided. The row is written before the command goes out precisely so a process that died in between leaves something behind; nothing appends again on the strength of it, and nothing moves it forward either, because either choice would be this system claiming to know something about somebody's folder that it cannot. outgoing_emails.LastFilingFailureCode carries the reason beside the send, which is where an operator reads why a message they sent is not in their Sent folder. It is a column on the record rather than on this table because a failure may have to be recorded where no row exists at all — a destination that resolves to nothing is the ordinary case — and because it must never be mistaken for something about the delivery, which is untouched by any of it.

stored_emails.FiledFromOutgoingEmailId is the other half of the same fact, written when a synchronization recognizes a discovery as one of these copies. It is a plain column rather than a foreign key: the two rows have different lifetimes, and a send whose record is erased must not take the message in somebody's folder with it. Everything reacting to newly arrived mail filters on it — the rule queue both in its predicate and in its own partial index — so a copy of what the user just sent never reads as mail that arrived.

The claim a delivery attempt holds

An attempt takes a batch of an account's outbox with a single statement: the rows are selected FOR UPDATE SKIP LOCKED under the claimable index, oldest AvailableAt first, and the same statement stamps LeaseOwner, LeaseExpiresAt, and the incremented AttemptCount onto them. Skipping locked rows rather than waiting is what makes two passes over one account claim disjoint sets instead of queueing behind each other, and doing the selection and the stamp in one statement is what leaves no instant in which a row is chosen but unheld.

What a row has to satisfy to be claimed is stated in the predicate rather than in the code around it: the stage is Recorded, AvailableAt has passed, and either nothing holds it or what held it has expired. Every subsequent write about that record carries the lease it was claimed under and is refused when the row no longer names that user, which is what stops an attempt whose lease ran out from recording an outcome over the attempt that took the message from it. AttemptTimeout is configured below LeaseDuration precisely so that case stays rare rather than routine.

A lease is released by the attempt that ends: a settled send has no need of one, a deferred send gives it back with AvailableAt moved forward, and a send the host stopped before it transmitted anything gives it back together with the attempt it had counted. A send whose transmission had begun is the one case nothing releases.

What a user asked to be sent again

recurring_sends holds one row per message a user wrote once and asked to be sent again on every occasion a schedule names. It is a declaration rather than a queue: nothing in it is due and nothing in it is transmitted. Each occasion the schedule reaches produces an ordinary outgoing_emails row with its own identity, its own attempts, and its own ending, so one Monday's provider outage is not the next Monday's and a message refused for good stops one occurrence rather than the declaration behind it.

It is a table rather than a section of the deployment's configuration for the reason the deployment's configuration is the operator's own: what repeats is a message somebody wrote, at a moment they chose, and it is stopped by them.

Column What it records
Id The declaration's identity, which every occurrence and every later act names it by. A cascade from it removes the recipients and the draft with it
MailboxAccountId, UserId The account every occurrence is submitted through and sent as, and the user who declared the repetition — a recurring send keeps its author, which is why the user stays beside the account here. Plain columns for the reason the outgoing record's are
RequesterOrigin, RequesterIdentity The authored act that asked, in the same vocabulary an outgoing record uses. It is the idempotency identity, so a retried command reads back the declaration it already made instead of doubling what a mailbox sends
Schedule The repetition as it was written, in the syntax a mail rule declares one in. It is kept as text and parsed above this table, because the syntax belongs to the dispatch mechanism rather than to the mail domain — and a schedule that does not parse is refused where the declaration is made, so nothing durable states an occasion nothing can resolve
DraftByteLength How many bytes of MIME were stored as the draft, kept beside the declaration so listing what repeats never loads a single draft's bytea
DeclaredAt When the declaration was written down
LastOccurrenceAt, LastOccurrenceEmailId The occasion this declaration last produced a message for and the message it produced, both null while it has produced none. The first is the occasion's own instant rather than the moment a dispatch noticed it, so a run that was late does not move the declaration off the schedule it declared; the second is what makes one occurrence at a time enforceable rather than assumed — the next occasion asks what became of that message and stands down while it is still queued
CancelledAt When the declaration was stopped, null while it still produces occurrences. An instant rather than a flag, because stopping a repetition is an act somebody took and a mailbox that used to send something every week is worth reading in the order it happened
xmin The concurrency token, as everywhere else

A stopped declaration keeps its row. Deleting it would make a repetition somebody ran for a year indistinguishable from one nobody ever declared, and the row is what an operator reads to see that it stopped and when.

recurring_send_recipients holds one row per person every occurrence is offered to, keyed by the declaration and the position in its list, and carrying the Address, the Role, and the ContactId where the author named a contact. It is the outgoing recipient table minus the state, and for a reason: a declaration transmits nothing, so nothing is ever answered about one of its recipients. What the rows hold is the envelope every occasion is built from, in the order the declaration named them.

recurring_send_drafts is the message itself, in the same one-to-one arrangement outgoing_email_contents has with outgoing_emails and with the same DraftMime, DraftByteLength, Sha256Hash, and StoredAt columns. Every occasion composes its own message from these bytes rather than reusing them: a repeated Message-ID would thread a year of Mondays as one message in every recipient's client, so each occurrence is re-stamped with an identity and a date of its own before it reaches the outbox.

The drafts nothing will send

mail_drafts holds one row per message somebody is still writing — a message, rather than the reusable draft a recurring send is declared with above, which is composed from once per occasion and sent every time. It is a table of its own rather than a stage on outgoing_emails, because the two records answer opposite questions: an outgoing record is an intent that a delivery pass is claiming, retrying, and settling, and a draft is a message that has been offered to nobody and may be edited for a week before it is offered to anybody. Giving a draft a stage on that table would put rows nothing may transmit into the claim's own predicate, and would make the idempotency identity that stops one authored request being sent twice mean something for a record that is not being sent at all.

Column What it records
Id The draft's identity, and what the message, the recipients, and the copies hang on. A UUIDv7 again, so the order drafts were written in is the identifier's
MailboxAccountId, UserId The account the draft belongs to and whose drafts folder holds its copy, and the user who wrote it — a draft is read by its author alone among the account's assigned users, which is why the user stays beside the account here. Plain columns for the reason an outgoing record's are: an account configured only to send need never have synchronized anything
RequesterOrigin, RequesterIdentity The authored act that wrote it down, by kind and by text, exactly as an outgoing record carries them. There is no unique index over the pair here: a draft is not idempotent, because saving the same draft twice is what editing it is
Revision Which version of the draft the row currently describes, counted from one. It is what a copy row is keyed by, so the record and the folder cannot disagree about which version is the standing one
Subject The subject line the current revision carries, empty where the author wrote none. The one thing the message says that the row repeats, and it is here for the reason the recipients are: a person's drafts are listed by what each is about, and reading that out of the stored MIME would load every draft's message to draw a list. Added by the AddDraftSubjectAndStagedAttachments migration, defaulting to the empty string, which is what a row written before the column existed reads as until its next revision
MimeByteLength How many bytes the current revision's MIME is, kept beside the record so a promotion can be refused against the deployment's size bound without reading the message
ComposedAt, RevisedAt When the draft was first written and when it last changed. The second is the order an account's drafts are read in
DiscardedAt When the draft was given up, null while it stands. It is written before anything is issued against the folder, which is what makes the removal resumable rather than a message nothing can name
PromotedToOutgoingEmailId The send this draft became, null until it becomes one. A plain column rather than a foreign key, deliberately: the send outlives the draft, and erasing an outgoing record must not take a draft with it
FiledStoredEmailId The stored message a held account filed the current revision as, in its local drafts folder, null while none is filed and on every mirrored account. A revision replaces it and a give-up erases what it names, both in the transaction that writes the change. A plain column rather than a foreign key, for the reason PromotedToOutgoingEmailId is one: the person may delete that message like any other, and neither erasure may refuse or take the other. A draft that names one showing its current revision is settled, so the pass does not read it again
FiledRevision The revision the message FiledStoredEmailId names shows, null exactly when that column is. A revision written while its drafts folder could not be reached leaves it behind Revision, which makes the draft outstanding again, and the pass files the current revision and erases the earlier message in one commit
DivergenceReason, DivergenceObservedAt Why the tracked copy stopped being provably this deployment's own, and when that was seen. Both null while the record and the folder still follow each other
LastFailureCode The code the last attempt to settle the folder ended in, null while none has. The code and not the message, for the reason an outgoing record keeps only the code
xmin The concurrency token, as everywhere else

A draft has no stage column, and that is the point. What stage it is at is read from its copies — nothing appended yet, an append issued and unanswered, the current revision standing, a replacement owed, a removal owed, given up — so there is no second place for the answer to be written and no window in which a column and the rows beneath it disagree. The pass that finishes what a stopped process left owing asks that same question in SQL rather than reading a denormalized flag.

mail_draft_recipients holds one row per person the draft names, keyed by the draft and the position in its list, and carrying the Address, the Role, and the nullable ContactId an outgoing recipient carries for the same reason. It carries no status and no reply code, because a draft has been offered to nobody. What it carries and an outgoing recipient does not is Provenance — NamedByCaller, ResolvedFromContactBook, or DerivedFromAnsweredEmail — added by the AddMailDraftRecipientProvenance migration and defaulting to NamedByCaller, which is the strict reading a row written before the column existed gets. A send meets the caller-facing governance before its row is written, so nothing about it has to survive; a draft meets that governance at the promotion, which has only this column to judge whether the caller chose the address itself. A revision replaces the whole list rather than amending it, so the row set is the composed message's own rather than everybody the draft was ever addressed to — and a draft addressed to nobody at all is an empty set here rather than an invalid record, which is what saving an unfinished message means.

mail_draft_attachments holds one row per file staged against a draft, keyed by its own UUID and carrying the draft it belongs to, the FileName and MediaType the author declared, the ByteLength stored for it, and the StagedAt that orders the files a composition attaches. The identity is a surrogate rather than the name, because a name is the author's and two files an author attached may share one, so a removal names the row and takes off the file the author meant rather than whichever the ordering put first. mail_draft_attachment_contents holds the octets beside it, one row per file, split for the reason every other content table is split from its description: listing a draft says what is attached to it, and a listing that carried the octets would load every file of every draft to answer what they are called. Both cascade from the draft, so giving one up destroys the files with the message. A file is uploaded once and composed into every later revision, which is what keeps editing a message with a large attachment from re-sending that attachment on each edit.

mail_draft_copies holds one row per revision that has reached the user's drafts folder, keyed by the draft and the revision. The key is what makes a replacement expressible. IMAP has no command that changes a stored message, so a new version is a new message beside the old one and the old one is removed afterwards — and between those two commands the folder holds two copies that both belong to this draft. Keying by revision is also what makes the append idempotent without a read-then-write: appending one revision twice is refused by the key rather than by a check two passes can both pass.

Column What it records
MailDraftId, Revision The draft and which of its versions this copy is, which together are the key. A cascade from the draft removes them with it
FolderAlias, FolderPath The folder the copy was appended to, as the alias an operator wrote and the path that alias named at the time. The path is what a later removal compares against, so a role repointed since the append names another folder and is left alone
Stage Issued before the command went out, Standing once the server answered, Withdrawn once the copy was taken back out, Abandoned where it is one nothing will touch again
PlacementUidValidity, PlacementUid Where the server said it put the copy, both null on a server that advertises no RFC 4315 UIDPLUS. The only occurrence a removal ever names is one of these, which is what makes a draft the user wrote in their own mail client unreachable by construction rather than refused by a check
InternetMessageId The identity the appended bytes carry, minted per revision because two messages sharing one is what a client reads as one message it has seen twice
AppendedAt, SettledAt When the append was issued, and when the copy stopped being one anything acts on
xmin A token of its own rather than the draft's, because a copy is confirmed and withdrawn without the draft above it changing — and what that decides is whether a message is left in somebody's folder

A row at Issued is the same undecidable window an outgoing filing has, and it is left undecided for the same reason. Nothing appends that revision again on the strength of it, and nothing moves it forward either. Abandoned is the other half of that discipline read from the folder's side: where the tracked copy stops being provably this deployment's own — the role resolves elsewhere, the folder was recreated, the server named no placement, an append was never answered — the message is left exactly where it is, the row says nothing will touch it again, and the reason is written onto the draft. A draft this system did not create is never among them, because nothing here reaches a UID any way but through a copy row an append of its own wrote.

mail_draft_contents is the message itself, in the same one-to-one arrangement the two other content tables have with their records. It is the one raw-MIME row in this schema that is rewritten rather than written once: a send's payload is fixed because a retry has to transmit the bytes an earlier attempt may already have begun transmitting, while a draft's payload is what its author is still editing, and keeping a row per revision would hold a message per keystroke for as long as the draft lives. The cascade is the erasure obligation — deleting the draft destroys the message, the recipients, and the copy rows with it, so nothing about a draft can outlive the record that says whose it is.

A draft is derived personal data and carries the classification of the mail it was written from. It is a message addressed to people, composed in part from mail this deployment holds, and the retention and erasure that reach an account reach these four tables through the same cascade every other table is reached by.

Indexes

Index Columns Purpose
ix_stored_emails_folder_uidvalidity_uid (mail_folder_id, uid_validity, uid), unique Remote occurrence identity, which is what makes synchronization idempotent
ix_stored_emails_account_timeline (mailbox_account_id, received_at DESC NULLS LAST, id DESC) The timeline of one account, which is the only shape a timeline read takes. ADR 0014 names a user-led index beside it as the candidate for all of my mail, on the reading that a request naming no account would otherwise be planned as a scan followed by a top-N sort. No such read exists, and no mail row carries a user to lead such an index with: a timeline over several accounts is walked one account at a time and the walks are merged, for the reason the ordering contract gives, so every timeline query carries an equality on the account
ix_stored_emails_folder_timeline (mail_folder_id, received_at DESC NULLS LAST, id DESC) The per-folder timeline
ix_stored_emails_awaiting_content (mail_folder_id, uid_validity, uid) over the rows whose content_availability is AwaitingStorageHeadroom The queue of occurrences stored without their payload, which every folder run reads once. The filter is what keeps the index proportionate to that queue rather than to the mailbox: on a deployment that has never reached its storage ceiling the index is empty, and the read costs nothing instead of walking a folder's whole occurrence index to discover that no row qualifies
ix_stored_emails_account_identity (mailbox_account_id, id) The order a whole-mailbox rule run walks an account's mail in. The identity rather than the timeline, because a walk that has to resume needs a total order no later write disturbs and a position that is one column rather than a nullable timestamp paired with a tie-breaker
ix_stored_emails_filed_sent_copy (mailbox_account_id, internet_message_id) over the rows whose FiledFromOutgoingEmailId is not null and uid_validity is null Whether a message synchronization meets in a held account's sent folder is the provider's copy of a send already filed locally. The filter keeps it to the filed copies no server has returned yet, which is a handful at most, so the probe made for every message in that folder costs an empty lookup rather than a walk of the account
ix_stored_emails_awaiting_rule_evaluation (mailbox_account_id, id) over the rows whose rules_evaluated_at and FiledFromOutgoingEmailId are both null The queue of mail no rule pass has evaluated, read once per account run. The filter is the point: in steady state almost every row of an account has been evaluated, so without it the read would walk the account's whole index to find the handful that qualify, on every run of every account. The second clause is what keeps a copy of this deployment's own outgoing mail out of that queue permanently — such a row is never stamped as evaluated, because it never was, so excluding it anywhere else would leave it at the head of the queue for good
ix_stored_emails_awaiting_attachment_text (mailbox_account_id, id) over the rows whose AttachmentTextDerivedAt is null and whose AttachmentCount is above zero The queue of mail whose attachments no pass has read, in the same identity order the rule queue walks and for the same reason. Both clauses of the filter earn their place: the timestamp is what takes a message out of the queue once its attachments have been settled, and the count is what keeps the mail carrying no attachment at all — most of a mailbox — out of an index that would otherwise be as large as the account
ix_stored_emails_thread (EmailThreadId, Id) One conversation's messages, in the total order a read assembles them from. The identity is in the key because the order a conversation is published in is computed rather than stored, and the read needs a stable one to bound and page the raw set by
IX_stored_emails_ParentStoredEmailId (ParentStoredEmailId) The self-referencing key back to the message a reply answers, which is what erasing a message reaches its replies by rather than scanning
pk_email_thread_identifiers (MailboxAccountId, IdentifierHash), unique Which conversation an identifier belongs to, which is the question every arriving message asks once per identifier it names. Uniqueness is also the race: two messages binding one identifier at once leave one writer to retry against what the other wrote
ix_email_thread_identifiers_thread (EmailThreadId) The identifiers a merge has to repoint at the surviving conversation
PK_mailbox_accounts (Id), unique Which mailbox an identifier names. The identifier is the account's own generated one and is unique across the deployment, so nothing has to be added beside it to tell two mailboxes apart; which mailboxes one person reaches is mail_account_assignments rather than a range of this key
IX_email_threads_MailboxAccountId (MailboxAccountId) The key back to the owning account, which is what erasing one reaches its conversations by
IX_email_threads_MergedIntoEmailThreadId (MergedIntoEmailThreadId) The foreign key from a folded conversation to its survivor. EF Core indexes it because the constraint is checked from the other side too: erasing an account cascades to its conversations, and each delete asks whether any row still names the one going
ix_stored_emails_sender (sender_normalized_address) Filtering by who sent a message
ix_stored_emails_to_addresses (to_addresses), GIN Containment tests over the To recipients
ix_stored_emails_cc_addresses (cc_addresses), GIN Containment tests over the Cc recipients
ix_stored_emails_reply_to_addresses (reply_to_addresses), GIN Containment tests over the Reply-To addresses
ix_stored_emails_remote_keywords (RemoteKeywords), GIN Containment tests over the keywords a server reported
ix_email_search_documents_search_vector (search_vector), GIN Lexical search over subject, participants, and body text
ix_email_attachment_texts_search_vector (SearchVector), GIN Lexical search over what a document attachment said and what it was called. It holds no row for an image description, the generated column producing nothing for one
ix_email_chunks_email (StoredEmailId) Every passage of one message, whichever text it was cut from. Unfiltered because the two below are not, and PostgreSQL uses a partial index only for a statement whose own predicate implies the index predicate — so a cascade, a user erasure, and a junk verdict's discard, none of which says anything about the attachment position, would otherwise scan the table
ix_email_chunks_email_ordinal (StoredEmailId, Ordinal), unique, where AttachmentPosition is null One message's body passages in reading order, and the constraint a re-cut cannot write an ordinal twice past. The filter is what makes it an index over body passages alone, PostgreSQL treating two nulls as distinct
ix_email_chunks_email_attachment_ordinal (StoredEmailId, AttachmentPosition, Ordinal), unique, where AttachmentPosition is not null The same constraint for a passage cut from an attachment, whose ordinals number from zero within their own file rather than within the message
ix_embedding_profiles_identity_fingerprint (IdentityFingerprint), unique One row per vector space, which is what makes activation idempotent
ix_embedding_profiles_lifecycle_state (LifecycleState), unique, where the state is building or active At most one generation being built and at most one being read
ix_email_embeddings_profile (EmbeddingProfileId, Dimension) Reading a whole generation, which is how a superseded one is removed
ix_mailbox_mutations_identity (MailFolderId, UidValidity, Uid, RequesterOrigin, RequesterIdentity, Mutation), unique A mutation's idempotency identity, which is what makes the same request twice perform one change
ix_mailbox_mutations_outstanding (MailboxAccountId, RecordedAt) where the stage is not Completed The changes an operator asks about: those in flight and those given up on
ix_mailbox_mutations_placement (MailboxAccountId, DestinationFolderPath, PlacementUidValidity, PlacementUid) where PlacementObservedAt is null The question the forward pass asks of every batch it discovers: is one of these UIDs where a relocation or a copy put an email
ix_mailbox_mutation_audit_entries_mutation (MutationRecordId), unique One audit entry per mutation ending, whatever a repeated append attempts
ix_outgoing_emails_identity (MailboxAccountId, UserId, RequesterOrigin, RequesterIdentity), unique An outgoing message's idempotency identity, which is what makes the same authored request twice one delivery. The account leads it because the message belongs to the mailbox; the author stays in the key behind it, which is what ADR 0014 means by an outgoing email keeping its author in its identity — two people writing from one shared mailbox under the same requester identity are two sends rather than one. It spans terminal rows deliberately: a row that was sent is what stops the same request asking again
ix_outgoing_emails_claimable (MailboxAccountId, AvailableAt, Id) where the stage is Recorded The batch a delivery pass claims, oldest first. The filter is what keeps it proportionate to the outbox rather than to everything the deployment has ever sent: a claim reads only rows nothing has transmitted for, and in steady state that is almost none of the table. The identity is in the key because two sends recorded in one instant need a total order for the claim to be deterministic
ix_outgoing_email_filings_placement (MailboxAccountId, FolderPath, PlacementUidValidity, PlacementUid) where the stage is Confirmed The question every synchronized batch asks: is one of these UIDs a copy this deployment filed. The stage is the whole filter, so the index is the size of the copies still standing rather than of everything ever sent — a mirror withdrawn before any run saw it, and an append the server never answered, are rows nothing will ever match again. Having been met is deliberately not part of it, because a provider that files the sent copy itself puts a second occurrence of the same message in the same folder and both have to be recognized
ix_outgoing_email_filings_message_id (MailboxAccountId, InternetMessageId) where the stage is Confirmed The same question on a server that advertises no UIDPLUS and therefore named no placement, answered by the identity in the appended bytes, and bounded the same way
ix_outgoing_email_filings_recent_by_filing (MailboxAccountId, Filing, AppendedAt, OutgoingEmailId) where the stage is Confirmed The same rows read the other way round, which is what the sweep for a copy the provider duplicated asks: which of this account's standing copies of one kind were appended recently enough to still be acted on. The two above lead with what a discovery is recognized by and answer nothing about when a copy was filed, so without this one that sweep reads every confirmed filing the account has ever kept — on every outbox pass — to find the few inside a fifteen-minute window. The identity is behind the instant for the reason the claim's is, and it is what lets the ordering be read rather than sorted. The provider's own copy is in none of these three: it has no row in this table at all, and is found by a correlated match against stored_emails on the folder, the UID space, and the identity the append carried, at a UID the placement does not name
ix_outgoing_emails_outstanding (MailboxAccountId, RecordedAt) where the stage is none of Sent, Refused, or Cancelled The outbox a restart reads and an operator asks about: what is queued, what is in flight, and what has stopped. The filter names the three terminal stages rather than the successful one alone, so a refused send stays visible while the deployment's whole sending history does not
ix_outgoing_emails_period_usage (RecordedAt, MailboxAccountId) What a send ceiling counts: the messages one period was asked for, for one account and for the whole deployment. It carries no filter, because a period counts every message it was asked for whatever became of it, and the account is behind the instant rather than in front of it so one index answers both questions — the deployment's count reads a range of it and an account's count reads the same range narrowed. Neither half names a user: a deployment ceiling bounds what the process puts on the network, which is one budget however many users it serves, and a per-account one counts a shared mailbox's sends once rather than once per person assigned it
ix_recurring_sends_identity (MailboxAccountId, UserId, RequesterOrigin, RequesterIdentity), unique A declaration's idempotency identity, which is what makes the same authored act twice one declaration. The account leads it because the declaration belongs to the mailbox, and the author stays behind it because a recurring send keeps whoever declared it: two people declaring from one shared mailbox under the same requester identity are two declarations rather than one. It spans stopped rows deliberately: a declaration that was stopped is what keeps the act that made it from quietly declaring a second one
ix_recurring_sends_active (DeclaredAt) where CancelledAt is null The declarations a dispatch pass reads, oldest first. The filter is what keeps that read proportionate to what still repeats rather than to every repetition the deployment has ever declared
ix_mail_drafts_user_account_revised (UserId, MailboxAccountId, RevisedAt) One person's drafts in the order the pass settles them, oldest change first. The author leads it rather than the account because a draft is read by its author alone among the mailbox's assigned users, so the listing is entered by whose it is; it is the one index in the mail graph a user leads, for that reason. No filter, because the read that uses it is already narrowed by the copy predicates beneath it and a deployment's whole set of held drafts is what a user is editing rather than a history that accumulates
ix_mail_drafts_promoted (PromotedToOutgoingEmailId) where it is not null Two questions with one answer: which draft, if any, a finished delivery came from, and which promoted drafts a pass still has to give up. Both read the same rows, and the filter is what keeps the index the size of the drafts that have been promoted rather than of every draft ever written, since a draft that was never promoted can never answer either
ix_mail_draft_attachments_draft_staged (MailDraftId, StagedAt) One draft's staged files in the order a composition attaches them, which is the only way this table is ever read: a file is never looked up except through the draft it belongs to
ix_mail_rule_executions_account_evaluated (MailboxAccountId, EvaluatedAt, Id) An account's rule history newest first, and the retention pass that erases what has outlived its window. The identifier is in the key because two executions of one batch share an instant and a keyset page needs a total order to continue from
ix_mail_rule_executions_account_rule_evaluated (MailboxAccountId, RuleName, EvaluatedAt, Id) What one rule has been concluding, which is the question a rule that never seems to fire is investigated with
ix_mail_rule_executions_email_evaluated (StoredEmailId, EvaluatedAt, Id) Why one message is where it is, and the rows the cascade removes when that message is erased
ix_mailbox_mutation_audit_entries_account_completed (MailboxAccountId, CompletedAt, Id) The two ways the trail is worked: a keyset-paginated page of an account's history, and the retention pass that erases what ended before a cutoff
ix_mail_answering_audit_entries_run_account (RunId, MailboxAccountId), unique One entry per run per account, whatever a repeated append attempts
ix_mail_answering_audit_entries_account_completed (MailboxAccountId, CompletedAt, Id) The same two readers the trail above has: a keyset-paginated page of an account's runs, and the retention pass beside it
IX_mail_answering_audited_emails_StoredEmailId (StoredEmailId) The foreign key back to the message, which is what makes erasing one reach the runs that read it without scanning the table
ix_email_spam_classification_signals_classification_ordinal (StoredEmailId, Ordinal), unique One classification's signals in the order the stages produced them, and the constraint a replaced record cannot write an ordinal twice past
ix_contacts_book_holder_display_name_sort_key_id (BookHolderId, DisplayNameSortKey, Id) The one order a contact book is listed in and the one a keyset page continues from. The holder leads it because a page is read over a handful of named books, so each is reached by a seek rather than the table scanned and narrowed, and the identity settles two people whose names compare equal, which is what makes the order total within a book and the walk terminate
ix_contact_addresses_book_holder_normalized_address (BookHolderId, NormalizedAddress), unique One address in one person's hands within one book. It is also what the lookup from an address to a person is served from, rather than a scan, and leading with the holder is what lets that lookup seek into each of the books a reader holds
IX_contact_addresses_ContactId_BookHolderId (ContactId, BookHolderId) The foreign key back to the person, which is what erasing one reaches their addresses by. It carries the book because the key does
ix_calendar_events_user_starts_at_id (UserId, StartsAt, Id) The window every view over a calendar is read as. The owner leads it because a read is always one person's, the start follows because a window is a range over it, and the identity settles two events beginning at the same instant, which is what makes the order total and a window answer the same way twice
ix_task_reminders_due_at (DueAt), over the rows carrying no RaisedForDueAt The other half of what the pass announcing reminders reads, on the same shape and for the same reason as the calendar's below: every task's reminders that have fallen and stand unannounced, across the deployment, with the filter keeping the index the size of what is still to be said. Whether the task is completed is read through the association rather than held here, so completing one takes its reminders out of what the pass announces without writing a row
ix_calendar_event_reminders_due_at (DueAt), over the rows carrying no RaisedForDueAt What the pass announcing reminders reads: every calendar's reminders that have fallen and stand unannounced, across the deployment, which is why the owner is absent from it — the pass is one run for the whole deployment rather than one person's read. The filter is the whole economy of it, an announced reminder leaving the index until the event moves and nulls the claim again, so the index stays the size of what is still to be said rather than of every reminder ever set
ix_calendar_events_user_imported_uid (UserId, ImportedUid), unique, over the rows carrying one One calendar holds an imported entry once, which is the whole of what makes importing a file twice create nothing the second time — two imports running together both read nothing, so only the constraint closes that window. The filter is what keeps the index the size of what was imported rather than of the calendar, nearly every event carrying no such identifier. Two calendars holding one identifier is ordinary rather than a conflict, which is why the owner leads it
ix_jobs_identity (JobType, IdempotencyKey), unique A job's idempotency identity, which is what makes the same execution enqueued twice one job. It spans terminal rows deliberately: a row that succeeded is what stops the same trigger asking again
ix_jobs_claimable (JobType, TurnAt) where the state is Pending or Claimed Both of the queries this table runs at any volume: the claim, and the queue-depth check every enqueue makes. The second column is the order the claim drains the queue in, which is what the fairness across users is. The filter keeps the index the size of the backlog rather than of the queue's whole history, and the claim repeats that same membership in its own predicate so PostgreSQL can prove the index applies to it rather than having to derive it through a disjunction. It names the two claimable states rather than excluding the terminal ones, so a job that reaches a terminal state leaves the index whichever one it reaches. The depth check reads the same leading column and rechecks Pending against the heap, because the index carries both claimable states rather than that one; what keeps that cheap is the bound on the read rather than the index
ix_jobs_account (MailboxAccountId, EnqueuedAt) An account's queued work, which is what erasure and any per-account bound reach a job by
ix_jobs_account_turn (MailboxAccountId, TurnAt) where the state is Pending or Claimed How far one mailbox's waiting work has reached, which is what every enqueue asks before it stamps a turn. The fairness the turn spaces out is between mailboxes rather than between people, because a job names the account it is for and no user at all. Beside ix_jobs_account rather than folded into it because the two are proportional to different things: that one spans everything the queue has ever done, and this one only what is still claimable, which is what keeps the read a backward walk of a few index entries on a queue holding a backlog of any size
ix_jobs_dead_lettered (StateChangedAt, Id) where the state is DeadLettered The operator's reading of what has stopped, newest first, keyed on the pair it pages by. The filter keeps the index the size of what is waiting for a person rather than of the table, and a row leaves it the moment the decision about it is taken
ix_notifications_user_unread_condition (UserId, DeduplicationKey), unique, where NOT "IsRead" The deduplication rule itself: one unread statement per condition, and no bound at all on conditions the person has already read. Being partial is also what makes it the index an unread count is answered from, since that count is one user's rows in it — and what keeps a repeated raise a lost race a retry resolves rather than a check the application could win between the read and the write
PK_spent_client_assertions (CredentialKey, Identifier), unique The anti-replay rule itself. The spend is one INSERT ... ON CONFLICT DO NOTHING and whether a row was written is the whole answer, so two replicas presenting one identifier at the same instant are settled here rather than by a check either of them makes between two statements
ix_spent_client_assertions_expires_at (ExpiresAt) The order the served assertions are aged out through. Nothing reads a spent assertion, so the column is indexed for the removal alone — which is what keeps that removal proportional to what has expired since the last one rather than to everything ever spent
PK_client_signal_tickets (Identifier), unique The single-use rule itself. The spend is one DELETE ... RETURNING reaching exactly one row, so two connections presenting one ticket at the same instant are settled here rather than by a check either replica makes between two statements
ix_client_signal_tickets_expires_at (ExpiresAt) The order the unspent tickets are aged out through, indexed for the removal alone for the reason the assertions' expiry is: nothing reads a ticket by its age
IX_client_signal_tickets_UserId (UserId) The foreign key onto the user record, which is what erasing a person reaches their unspent tickets by rather than scanning
PK_client_sessions (Identifier), unique The one read every authenticated request on the client surface makes, and what both removals reach a row by. A renewal's removal and a revocation's carry the digest in the same statement, so two requests presenting one token leave exactly one live session whichever replica each of them reached
ix_client_sessions_expires_at (ExpiresAt) The order the expired sessions are aged out through, indexed for the removal alone for the reason the tickets' expiry is: nothing reads a session by its age
IX_client_sessions_UserId (UserId) The foreign key onto the user record, which is what erasing a person reaches their sessions by — including the ones naming no credential at all
IX_client_sessions_CredentialId (CredentialId) The foreign key onto the credential, which is what disabling or deleting one reaches its sessions by rather than scanning
ix_notifications_user_occurred (UserId, OccurredAt, Id) The two ways the notification centre is worked: a page of one person's notifications newest first, and the retention sweep that erases the same person's oldest. The identifier is in the key because two notifications raised in one instant need a total order for a keyset page to continue from
IX_notifications_TargetStoredEmailId (TargetStoredEmailId) The foreign key back to the message a notification leads to, which is what erasing that message reaches its notifications by rather than scanning
IX_notifications_TargetCalendarEventId (TargetCalendarEventId) The same for the event a reminder leads to, which is what deleting an event reaches the rows that announced it by
IX_notifications_TargetPersonalTaskId (TargetPersonalTaskId) The same again for the task a due reminder leads to, which is what erasing a task reaches the rows that announced it by
ix_tasks_user_due (UserId, DueOn, Id) The one order a personal task list is read and drawn in: one person's tasks soonest due first, with PostgreSQL's own NULLS LAST leaving the undated ones at the end and the identifier keeping two tasks due on one day in a stable order across reads. Reading the proposals apart from the commitments is an equality on Origin within one person's rows, which is a handful of them, so that column earns no place in the key
ix_mailbox_exports_account_requested (MailboxAccountId, RequestedAt DESC) One account's exports newest first, which is the listing an operator asks for and the only order this table is read in
ix_mailbox_exports_expires_at (ExpiresAt) where it is not null The archives the expiry pass has to delete. The filter is what keeps the index the size of the archives that exist rather than of every export the deployment has ever written: one that failed, was cancelled, or has already gone carries no expiry
IX_stored_content_claims_ExpiresAt (ExpiresAt) The sweep every claim statement opens with, which is what keeps the table the size of the payloads currently in flight rather than of every claim a replica ever died holding. Unfiltered, because what an expiry divides the table into changes with the clock rather than with a row

The recipient, keyword, and search-vector indexes are GIN rather than B-tree because all of them serve containment tests. A B-tree over an array column serves only equality against a whole array, and over a tsvector it serves nothing search asks for; a GIN index is what turns either into an index scan.

No partial index over remotely deleted messages exists, and its absence is deliberate; one waits for the remote-expunge reconciliation that introduces the state it would filter on. The absence of any index over Embedding is deliberate in a stronger sense, and permanent.

The vector index that is not there

Nothing indexes Embedding. A semantic search measures every eligible message's nearest passage against the query, which is exact and linear in the number of vectors it reads; there is no approximate path beside it, and a profile's activation builds nothing in the database.

That is a measured decision rather than an omission. An approximate index over Embedding covers one width and one generation, so it could only ever have been a partial index per profile, built and dropped as a profile's lifecycle asked — and on a hundred-thousand-message mailbox at 1536 dimensions the ranking query never chose one, an approximate window kept a median of four of its fifty results once the caller's own folder and date filters were applied and none once they named a sender, while the index cost 3073 MB beside a 3137 MB table, three quarters of an hour of blocked writes to build, and a hundredfold on every embedding insert. What a semantic search costs holds the measurement and what it decided.

Two things follow for this table. ix_email_embeddings_profile is the only index it carries beyond its keys, and it earns that on a different query — reading a whole generation in bounded batches when a superseded one is removed. And MailFathom now changes the schema nowhere outside the artifact an operator applies, which is what Applying the database schema states for a deployment that separates its migrating role from its serving one.

The timeline ordering contract

Keyset pagination needs a total order, not merely a sort: two pages are contiguous only when every row falls on exactly one side of the key the previous page ended on. EmailTimelinePosition in Domain is the single statement of that order, and the two timeline indexes reproduce it column for column. A change to either is a change to both.

The order is: received timestamp descending, with an unknown timestamp last, then the local identifier descending.

Two parts of that are decisions rather than defaults.

A message can carry no usable received timestamp, and PostgreSQL orders nulls first under DESC. Inheriting that default would float every message nobody could date above the newest mail, on every page, forever — so both indexes spell out NULLS LAST and the in-memory comparer treats an unknown timestamp as older than every known one.

A timeline over several accounts is walked one account at a time and the walks are merged, rather than issued as one query naming the account list. An index leading with the account serves one account as an ordered walk, and PostgreSQL derives an ordered path from appended paths rather than from = ANY, so a single predicate over the list would be planned as a scan of everything that matched followed by a top-N sort — and the keyset walk would stop being bounded on exactly the mailbox that is large enough for it to matter. Each walk is bounded to the page size and the walks are ordered together, so what the outer ordering sorts is at most one page per account rather than the whole mailbox. Every timeline query therefore carries an equality on the account, which is why the index table above holds no user-led timeline index.

The tiebreaker compares identifiers as the sixteen big-endian octets PostgreSQL orders a uuid column by, written out rather than delegated to Guid.CompareTo. That method agrees with the octet order on the current runtime, but it documents only that its result is suitable for sorting — not that it is the order a uuid column uses. A page boundary computed in memory is resumed from by a query the index plans, so the tiebreaker has to be the index's order by construction.

Unit tests pin the contract, including where an undated message lands. That the server then returns rows in the same order, and plans a timeline query against the index rather than sorting the table, is verified against real PostgreSQL — see What the integration suite proves below.

Privacy classification

Participants, subject, and thread identifiers are personal data. They are stored because a timeline and a filter cannot work without them, and the columns above are the minimum that supports the planned queries — which is why display names other than the sender's, and the attachment list, are not among them. No projection introduced here selects raw MIME, and the content relationship stays unloaded by default so a mailbox query cannot pull a bytea value into the change tracker by accident.

The derived search document is not a lesser classification of the same data. Body text, the copied subject and addresses, and the search vector built from them are mail content, and none of them is anonymous merely because it was derived; they inherit the retention, access, export, and erasure obligations of the message they came from. The cascade from stored_emails is what makes that structural rather than a rule somebody has to remember.

mailbox_mutations is derived personal data too, and for a reason worth stating plainly: a mutation history says where a person's mail has been and what was done to it. It therefore inherits the retention and deletion obligations of the email it describes rather than outliving it, and the cascade from stored_emails is what makes that structural — including where the recorded mutation was the deletion itself.

mailbox_mutation_audit_entries is one of the two tables on this page that deliberately do not inherit those obligations — tasks below is the other, for a different reason. It is derived personal data by the same reading — where a person's mail has been, when, and at whose instruction — and the reason it outlives the mail is that an audit of deletions whose entries are erased by the deletions they record holds nothing. What replaces the cascade is a bound of its own: the trail is off unless an account turns it on, each account states how long its entries are kept, and every account run erases what has outlived that window. A data-subject erasure reaches it separately for the same reason, and Administrative endpoint states that path.

mail_answering_audit_entries and mail_answering_audited_emails are the other table that needs an operator's decision before either holds anything, and the comparison between the two is the whole design. The entry is derived personal data of a different kind — what a person's mail was read for, and when — and it is bounded the same way: off unless an account turns it on, with a stated retention every account run erases against. Where it differs is the cascade, which it keeps: the messages an entry names hang on stored_emails and go with them, because recording that mail was read survives that mail's erasure no better than the extract itself would. Retention and the cascade therefore both reach it, and neither replaces the other.

The same holds for email_chunks, and one thing about it is deliberate: a chunk records the message it came from and the span inside it, and nothing else. The account, folder, sender, recipients, date, and subject a retrieval will want to cite are reached through that message rather than copied onto the passage, so cutting mail into chunks widens no access, export, or erasure surface — it only adds rows the same cascade erases.

email_embeddings is the same again, one step further out. A vector is derived from mail content and inherits the source message's classification, retention, access, export, and erasure obligations whole; nothing about being a list of numbers makes it a lesser copy of the words it stands for, and it is not anonymous because it cannot be read back by eye. It carries no text and no coordinates of its own — the chunk it hangs on answers both — and the cascade from that chunk is what makes erasure structural rather than a rule somebody has to remember. No vector, no chunk text, and no digest reaches a log, a metric, a trace, or an error message.

email_attachment_texts is the most content-bearing derived table on this page, and it is read exactly as the search document is. A whole document's extracted text, a model's description of a picture, and the file name a sender chose are mail content, and none of them is a lesser copy for having been read out of an attachment rather than out of a body — the tsvector built over them is derived from the same words and carries the same classification. All of it inherits the source message's retention, access, export, and erasure obligations, and the cascade from stored_emails is what makes that structural. Two things bound it further. The row records the sensitive-content configuration it was written under, so text written under an older posture is answerable rather than silently unredacted, and a scanner switched on afterwards is the case Sensitive-content scanning qualifies. And nothing in the table reaches a log, a metric, a trace, or an error message: the walk position, the declared media type, the outcome, and the page count are what a failure is allowed to name, and the text and the file name are not.

embedding_spend_periods holds no personal data either, and its shape is what makes that true rather than a claim about it: a character count, an instant, and a generated user identifier say how much a deployment spent, for whom, and when, and none of them names a message, a passage, or a vector. That is also why it outlives what it recorded — nothing cascades into it, not even from the user record, and erasing the mail a period paid to embed leaves the record that the period was paid for.

account_stored_content is read the other way round, and the difference is what its cascade records. A byte count against a mailbox names no message either, but what it describes is how much mail that mailbox holds rather than what this deployment spent, so it carries the classification of the mail it counts: it cascades from mailbox_accounts, and erasing an account takes the figure with everything else derived from its mail. Nothing in it reaches a log, a metric, a trace, or an exception message beyond the account's own generated identifier.

email_spam_classifications and email_spam_classification_signals are derived personal data of the same kind as a chunk or a vector: what was concluded about somebody's mail, and from which of its headers. They inherit the source message's classification, retention, access, export, and erasure obligations whole, and the cascade from stored_emails is what makes that structural rather than a pass somebody has to remember. A signal names a header field, an authentication outcome, or a rule — never the value of a header — and nothing in either table reaches a log, a metric, a trace, or an error message.

jobs is derived personal data by the same reading as a chunk or a classification: a row says that something is to be done about somebody's message, and it points at that message by its stored identity. What keeps it a pointer rather than a copy is the payload contract — a document of references with no property a subject, an address, or a body could go in, bounded in size at the enqueue boundary so a payload that grew into a copy is refused instead of stored. The account column and the cascade from mailbox_accounts are what erasure reaches queued work by. The message the payload names is not a foreign key, because it is a value inside a jsonb document rather than a column a constraint can reach: a job whose message was erased before it ran finds nothing under that identity and ends without acting.

attachment_derivation_spend_periods holds no personal data for exactly the reason embedding_spend_periods does not, and it is a stronger claim there because what it counts is reading rather than sending: a unit count, an instant, a step name, and a generated user identifier say how much a deployment opened, of which kind, for whom, and when, and none of them names a message, an attachment, or a filename. Nothing cascades into it either, so erasing the mail a period paid to read leaves the record that the period was paid for.

job_schedules holds no personal data either, for the reason embedding_spend_periods does not: an identity composed of MailFathom's own configured names, two instants, and the identifier of a job say when a recurring dispatch last acted and on which occasion, and none of them names a message. That is also why nothing cascades into it — erasing an account's mail says nothing about when its rules are due to run again.

mail_rederivation_positions and mail_rederivation_runs hold no personal data either, and for the same reason job_schedules does not: an account alias, a folder alias, the local identifier of the last message a batch read, counts, and instants say how far an operator's refresh has come, and none of them is anything a message supplied. Nothing cascades into either, which is deliberate rather than an omission — a walk's position is about work an operator started, and erasing the mail behind that position leaves a cursor that the next batch simply steps past and counts that still describe work that was really done.

contacts and contact_addresses are the most concentrated personal data on this page: a name, the addresses somebody uses, and a note about them are an assembled record about an identified third party rather than mail that arrived. An asserted row is derived from nothing at all; a collected one is derived from a message, and still nothing cascades into either, because what a collected row holds is a claim that the mailbox corresponds with somebody rather than a copy of the message that named them — erasing that message says nothing about whether it still does. That is also why neither has a retention window: a contact is held until somebody erases it, and erasing one removes the person and every address row through the cascade above rather than marking either. What the collected half adds is an erasure of its own, and it is per mail account: it takes every row of that account's book and leaves what any user asserted, and what any other account collected, exactly where it was. Each half leaves with its own holder. Erasing the user takes their own book, because contacts keys onto settings_accounts on the asserted half and contact_addresses keys onto contacts, so the addresses are reached through the person holding them; what their mailboxes collected stays, for whoever else is assigned those mailboxes, until the last user of one is erased and the account goes with them. Nothing in either table reaches a log, a metric, a trace, or an error message; the contact identifier and the book holder's are what a failure names, and they are the two columns that are not personal data.

calendar_events is personal data about the person whose calendar it is rather than about a third party: a title says who somebody is meeting and the two instants say when they are not somewhere else. Every column but the identity, the owner, and the origin is therefore sensitive, and none of them reaches a log, a metric, a trace, or an error message — the event's identifier is what a failure names. It has no retention window: an event is held until somebody deletes it, and a deletion removes the row rather than marking it. Erasing the user takes the whole calendar through the cascade onto settings_accounts, and erasing a message leaves the event with a citation that resolves to nothing, for the reason the calendar gives.

outgoing_emails, outgoing_email_recipients, and outgoing_email_contents are derived personal data of a kind nothing else on this page holds: an outgoing record says who this mailbox's user wrote to and when, and the recipients it names are people other than the user. They are stored because a send cannot be resumed without knowing who is still owed it, and the columns above are the minimum that supports that — which is why a recipient's display name is not among them, and why the record carries no subject, no body, and no header of its own. The message stays in outgoing_email_contents and is reached by identifier, so listing the outbox, advancing a stage, or answering about a recipient never loads it. The two cascades from outgoing_emails are what make erasure structural: deleting the record destroys the recipients and the stored message with it, so an outgoing message cannot outlive the record that says who it was for. A recipient's ContactId does not widen any of that: it is the one column of the three that is not personal data, it is the same identifier a failure is allowed to name, and it points at contacts without a constraint so erasing a contact leaves the send saying who it went to rather than rewriting it. Nothing in any of the three reaches a log, a metric, a trace, or an exception message — an exception about a recipient names the record, and the position where the row it was reading has one, rather than the address.

recurring_sends, recurring_send_recipients, and recurring_send_drafts inherit every word of that and add one fact of their own: a declaration says not only who this mailbox's user writes to but how often, which is a statement about a relationship rather than about a message. They are classified, retained, exported, and erased exactly as the three above are, and the same two cascades make erasure structural — deleting a declaration destroys its recipients and its draft with it. Nothing in any of them reaches a log, a metric, a trace, or an exception message either; a failure about a declaration names the declaration, and the schedule it carries is an operator's own phrase rather than anybody's data.

mail_drafts, mail_draft_recipients, mail_draft_copies, mail_draft_attachments, mail_draft_attachment_contents, and mail_draft_contents are read exactly as the three tables above are, and for a stronger reason: a draft is a message the user is writing to somebody, and one drafted as an answer to stored mail is composed in part from that mail. It is derived personal data of the same classification as the message it came from and carries the same retention, access, export, and erasure obligations, which the cascades from mail_drafts make structural — erasing the draft destroys the recipients, the copy rows, the staged files with their octets, and the stored message in one statement, and erasing the account reaches every draft of it. The copy rows are the one part that says anything about a mailbox rather than about a message, and what they hold is a folder alias, a path, a UID, and an identity MailFathom minted. The staged files are the other part that is the author's own rather than the message's, and what they hold is a name that person typed, a media type they declared, and the octets they uploaded. Nothing in any of the six reaches a log, a metric, a trace, or an exception message: a failure names the draft's identifier and the folder alias, never a subject, an address, a file name, or a line of what was written.

settings_accounts is personal data of a kind nothing else on this page holds: it is the record of a person rather than of their mail, and its document is what they configured MailFathom to do on their behalf. It is therefore the row a data-subject erasure is aimed at, and the cascade beneath it is what discharges the rest — which is also why the tables that record a mail account without keying onto one are taken by the same operation rather than left for somebody to remember. The contact book is reached by a cascade rather than by that derived list, and by the one belonging to whichever holder each half has: contacts keys onto the user directly on the asserted half and onto mailbox_accounts on the collected one, and contact_addresses keys onto contacts through (ContactId, BookHolderId), so erasing the user takes their own book with them in two hops — which is what an erasure request owes about an assembled record of third parties this user wrote down — while what their mailboxes collected goes with a mailbox rather than with them. stored_secrets keys onto the user directly as well, so the sealed material behind every reference in their document leaves through that cascade. The refresh token of an account that was authorized but never synchronized is reached by the explicit account predicate over mailbox_refresh_tokens, over the accounts this user was the last one assigned; it no longer survives for lack of a mailbox_accounts row. Nothing in the user row reaches a log, a metric, a trace, or an exception message: a failure names the user's identifier, which is a value MailFathom generated, and never the document beside it.

notifications is derived personal data by the same reading as a chunk or a classification, and by a weaker one than a mutation history: a row says that something reached this person's mailbox and when, without saying what. It therefore inherits the source message's obligations wherever it names one, and the cascade from stored_emails is what makes that structural — a notification offering to open a message that has been erased is exactly the row that must not survive. What the rows naming no message carry instead is a bound of the record's own: thirty days from the instant described, swept on each account's own run. Nothing in the table reaches a log, a metric, a trace, or an exception message; the user's generated identifier and the account alias are what a failure names, and they are the two values that are not personal data.

tasks is derived personal data of a kind nothing else on this page holds, and the difference decides its cascade. A title may be a sentence read out of a body, so a row is read as mail content wherever MailFathom composed it — but what the row is is a commitment, and a commitment is not undone by the mail naming it being erased. So it is the second of the two tables here that deliberately do not inherit the source message's erasure obligation: the message is cited by a value rather than by a foreign key, so erasing it leaves the task standing and holding a sentence derived from mail that no longer exists. That is a narrower survival than mailbox_mutation_audit_entries takes and is justified differently — an audit outlives the mail because a trail erased by what it records holds nothing, while a task outlives it because the person still owes the thing. The obligation that does reach every row is the person's own: tasks cascades from settings_accounts, so a data-subject erasure takes the whole list without having to name this table, which matters here for the reason it matters for notifications — the table records no mail account, and the erasure walk enumerates the tables that do. There is no retention bound, and that is the list's nature rather than an omission: a task is held until somebody completes and erases it, and a deployment sweeping away what a person still owes would be losing their work rather than minimizing anything. Nothing in the table reaches a log, a metric, a trace, or an exception message; the task's own identifier and the user's generated one are what a failure names, and they are the two values that are not personal data.

spent_client_assertions is the one table on this page whose classification depends on which credential a row was written under. For a configured key pair the CredentialKey column holds the name an operator gave the key, which is MailFathom's own configuration and nobody's data; for a user's registered key it holds that key's 43-character fingerprint, which is a pseudonymous identifier for an identified person and is read as their data. The other two columns are neither in both cases — a value the client minted for one request, and an instant. Nothing cascades into the table, and that is deliberate rather than an omission: the column holds a configured name as readily as a fingerprint and belongs to neither record, so there is nothing for a constraint to point at. What replaces the cascade is the row's own lifetime, which is minutes rather than a retention window somebody has to sweep against — a data-subject erasure is therefore not owed a statement here, because whatever a fingerprint could still identify is gone on its own before such a request could be answered. Neither the fingerprint nor the identifier reaches a log, a metric, a trace, or an error message — a refusal on the user path names the credential's own generated identifier. The configured key name does reach one, in the warnings that say which key presented a replayed or overlong assertion, and it is the column value there as well as in the row; it is MailFathom's own configuration rather than anybody's data, which is why that is the one part of the table a log carries.

client_signal_tickets holds a generated user identity, which is a pseudonymous identifier for an identified person and is read as their data; the digest and the instant beside it are neither. It does cascade from the user record, so a data-subject erasure takes whatever it holds without having to know the table exists — and the row's own lifetime of thirty seconds means there is almost never anything for that cascade to reach. The digest is not a credential: it opens nothing, because what a connection presents is the secret it was derived from. Nothing here reaches a log, a metric, a trace, or an error message — a refused connection is counted rather than described, and the one refusal that names anything names the deployment's own inability to reach its database.

client_sessions holds a generated user identity and a credential identifier, both pseudonymous identifiers for an identified person and read as their data; the grant, the digest, and the instant beside them are neither. It cascades from the user record and from the credential, so a data-subject erasure takes every session of theirs whether or not a credential stands behind one, and an operator ending a credential takes its sessions in the same transaction. The digest is not a credential: it authenticates nothing, because what a request presents is the secret it was derived from. Nothing about the device is in the row — no address, no user agent, and no name a person gave a session — because a session is not a device register and nothing in MailFathom reads one. Nothing here reaches a log, a metric, a trace, or an error message: a refused request is answered rather than described, and the one refusal that names anything names the deployment's own inability to reach its database.

embedding_profiles is the exception on this page: it holds no personal data at all. It describes a model, and the credential that reaches that model is configuration rather than a column here, so nothing in this table is a secret or is derived from anybody's mail.

How this schema reaches a database

One reviewed migration, Initial, creates all of it, and the migrations appended since add to it. One of them writes a row as well as tables: AddUserAccounts provisions the user every mailbox is bound to, carries the mailboxes an upgraded deployment already holds onto that user, and does neither again on a second apply. There is no bootstrap that builds the schema from the model at startup any more: the host reads the migration history, and refuses to start when the database has not applied every migration the running build defines.

Locally the AppHost's mailfathom-migrations resource applies it before the host starts. Elsewhere applying it is an explicit deployment step. Local development documents both. Every migration is permanent: a model change appends one and never regenerates this baseline, and the add-migration skill is that workflow.

Not everything in this database is mail. mailbox_refresh_tokens holds one sealed OAuth refresh token per account, added by the AddMailboxRefreshTokens migration, and it is documented where the credential it holds is — mailbox OAuth. It is named here so a reader of a schema dump knows which page owns it, and because nothing on this page cascades into it: it carries no foreign key onto mailbox_accounts, since a token has to be able to exist for an account that has never synchronized. It is one of the eleven tables in that position, which is why erasing a user takes each of them by a statement of its own — and it is the table that used to show what such a statement could not reach. It names the account alone now, like every other table in the mail graph, so the delete narrows on that column over the accounts the departing user was the last one assigned rather than over the ones holding a mailbox_accounts row: a token stored for an account that was authorized and has never synchronized still holds no account row, and goes with that account anyway.

stored_secrets is not mail either. The AddStoredSecrets migration adds it as the sealed store behind the database: scheme, with its user cascade, ciphertext bound, user-and-name uniqueness, and key-retirement index. The deployment's data-encryption key stays outside the database; a copy of this table therefore discloses no material without the separately provisioned ring.

uid_validity and uid are modelled as CLR uint because that is the IMAP wire type, and PostgreSQL has no native unsigned 32-bit integer. The generated migration maps both to bigint, which represents the whole unsigned 32-bit range exactly, so the unique index on (mail_folder_id, uid_validity, uid) and the checkpoint comparisons order the same way the IMAP values do.

Table names are the snake_case ones above. Column names are not: the model renames tables and leaves columns as it names the properties, so the physical columns are "UidValidity", "ReceivedAt", and so on, and hand-written SQL against them has to quote that casing. The names in this page are the schema's concepts rather than a transcription of the DDL; the migration is the transcription.

What the integration suite proves

Every claim on this page that is a claim about PostgreSQL rather than about the model is verified by backend/tests/IntegrationTests against the orchestrated server, because a unit test cannot reach any of them. The classes involved carry [RequiresIntegrationCoverage] for exactly that reason, and local development describes how the suite runs.

  • A database-backed secret is stored and rewritten as one ciphertext row under the active key, resolves only to the newest material through the registered scheme, appears in the bounded key-retirement inventory, and contains neither plaintext version. Changing the bound name makes it refuse to open, and deleting its user removes the row so the reference resolves to nothing.
  • Erasing a user leaves no row naming a mailbox nobody else is left assigned, including the refresh token of an account that has only ever been authorized and therefore holds no account row at all — that row is arranged by the test deliberately, because it is the case a subquery over the account table would have left behind. The claim is made against every table the model says records a mail account rather than against a list written beside it, so a table added later is counted by the same assertion, and the count taken before the erasure is asserted to hold no zero — a table nothing seeded would otherwise let the test pass while proving nothing about it. What survives is asserted the same way: a second mailbox is assigned to another user, with rows on both sides of the erasure — three tables the cascade reaches and three it does not — and every count beneath it is unchanged afterwards, down to the raw MIME of its message. Both users are given a contact as well, which is the one part of the record that names no mail account at all and is therefore invisible to every count above: the erased user's person and address row are gone, and the other user's are where they were.
  • The account row a first folder binding creates, and the folder row beside it, name the generated identifier and no user: a mailbox is one mailbox however many people are assigned it, so the write path carries no user to get wrong. Which users a configured account is assigned to, and the refusals a deployment holding none or several meets, are settled once while the host starts and are asserted there instead.
  • Mail of an account the caller is not assigned hangs on that account on all three tables one binding and one upsert touch, and no read of theirs reaches it. The narrowing is stated as two account identifiers, so the account column is the only thing separating the two answers, and the caller's own timeline read over the same folder alias reports a message of an account they are assigned beside none of the other's — the presence is what makes the absence an absence rather than an empty folder. The corpus is six hundred messages split over two of the assigned accounts, which is what leaves the planner a choice to make, and a timeline naming one of them is asserted to be served from ix_stored_emails_account_timeline.
  • A mailbox stored before the user axis existed is carried onto the user the same script provisions. The chain is applied in two parts against a database of its own — up to the migration before AddUserAccounts, then the whole artifact — with the mailbox row written between them, which is the state an installation of the previous release is in on the day it takes this one and the only state that exercises the filling step at all.
  • The baseline migration applies to an empty database and leaves no migration pending, and the text search configuration the generated column was built with is read back out of PostgreSQL's own catalogue rather than from the model — which is what lets the startup gate refuse a database whose lexical index disagrees with the running host.
  • The unique index refuses a duplicate occurrence that neither writer could have seen, which is the PostgreSQL-side half of idempotent synchronization: two overlapping runs each stage an insert, and the database rather than the application decides that only one lands.
  • The same holds for an outgoing message's identity, where losing the race is the mechanism rather than an accident: two callers asking for one send each stage an insert, the index refuses the second, and enqueuing the same authored request twice leaves one record carrying the message the first enqueue stored rather than a recomposed one. A send left at TransmissionBegun is found by a later scope reading the account's outbox and reads as undecidable there, a recipient the message reached is never offered again after a partial acceptance, and deleting the record erases the stored message and the recipients with it.
  • An occurrence identified by the largest UID IMAP can hand out round-trips through its bigint columns unchanged.
  • Raw MIME round-trips through bytea with its recorded length and SHA-256 intact, including a payload large enough that PostgreSQL stores it out of line, and re-storing an occurrence replaces the one existing row rather than reading its payload back into memory.
  • The transaction a persistence session opens covers SQL the provider had already executed: a set-based update issued and then abandoned without a commit leaves the earlier payload in place.
  • A losing writer is reported rather than raised where the constraint says a race happened — a second binding of the same alias generation, and a stored email whose xmin token another committed transaction made stale — and is raised where it says the data is already there.
  • The timeline indexes return rows in the order EmailTimelinePosition.NewestFirst describes, over data with shared and absent timestamps, and a keyset walk over that order visits every row exactly once. The uuid tiebreaker is the part only a server can settle.
  • The mailbox listing read model issues that walk over the same data in both directions and gets the same order back, every one of its filters translates to SQL — including the array containment a recipient filter needs and the escaped pattern a subject fragment needs — and its projection leaves the change tracker empty. A predicate that does not translate is a runtime failure rather than a compiler error, which is why the read model's queries belong here as well as in the unit suite.
  • The generated search vector is computed by PostgreSQL from the subject, participants, and body beside it; the GIN index serves the query shape search issues; and query text carrying SQL statements and tsquery operators is read as words, matching documents whose text holds those words and leaving the table intact.
  • A stored vector cannot disagree with its profile: a vector whose length differs from the Dimension beside it, and a Dimension the named profile never declared, are both refused at the write, while the matching width is stored. Two profiles of different widths coexist in the one dimensionless column, re-registering a geometry already present is refused by the fingerprint index, and deleting a message erases the vectors derived from it while the profile they named survives.
  • The search read model composes that vector, websearch_to_tsquery, ts_rank, ts_rank_cd, and ts_headline into commands PostgreSQL accepts — a malformed headline option list is a runtime failure rather than a compiler error — ranks the window it returns, cuts snippets inside the configured bounds, and leaves the change tracker empty across every query it issues.
  • Both guarantees the job store gets from PostgreSQL rather than from its own code: two callers racing to enqueue one execution produce one job, because the unique index refuses the second insert; and two workers claiming at the same moment take different jobs, because the claim selects and stamps under FOR UPDATE SKIP LOCKED in one statement. A lease that has run out is reclaimed with a second attempt counted, the attempt it was taken from writes nothing afterwards, a completed job keeps the key that refuses the same execution again, and a row whose type this build does not declare is left where it is. A dead letter is claimed by nothing and keeps the key and the recorded failure that ended it, a scheduled retry holds the job back until the instant it named, and a release hands the attempt back with the job. And the claim is fair across users: against one user's backlog beside another user's single due job, a claim bounded to two hands back one of each rather than two of the backlog.
  • The one guarantee the work lease gets from PostgreSQL rather than from its own code: eight replicas claiming one scope at the same moment leave exactly one holder, because the claim inserts on the primary key and resolves the conflict against the recorded expiry in one statement. A lease whose holder stopped renewing is taken by the next replica that asks, a live one is refused whoever asks, and a renewal and a release from a hold another replica already took over both write nothing — which is what stops a late shutdown handing away a scope somebody is working under.
  • The anti-replay rule is the key rather than anything either replica does: an identifier one host served is refused by a second host against the same database, eight replicas presenting one identifier at the same moment leave exactly one of them served, one identifier under two credentials serves both because the key is the pair, and the removal drops the records whose assertions can no longer be presented and leaves the rest refused. Only a real insert against the real index settles the concurrent case, which is the whole reason the record left the process.
  • A schedule's durable state is written by one statement whether the row is there or not: a schedule seeded and then advanced leaves one row carrying the latest occasion, and a schedule nothing has written is absent from the read rather than answered with an empty state — which is the difference between seeding once and seeding on every pass.
  • The contact book's fourteen claims about PostgreSQL rather than about the model: erasing a person removes every address row through the cascade and frees those addresses for somebody else, promotion writes the caller's own copy and leaves the mailbox's record where the account's other users still read it, two overlapping writers claiming one address leave the loser with a conflict rather than a provider failure, a keyset walk of the book serves every contact exactly once in the order the index is built in — which is also the only place the comparison translates to SQL at all — a search selects the people whose stored name key or whose address key contains the text, which is the one contact predicate that reaches both tables at once and the one no index above answers, a name one person carries and a name several do answer with the people and with the counts, an amendment that stops naming an address deletes its row and releases it, two books each holding the same address both succeed because the unique index is over the book and the address rather than over the address, a person only another user wrote down is answered for by none of the four reads answered in batches — not by name, not by address, and not by identity — while the same four under the holder answer with them, giving up on collection takes only the account's book it was asked of and the other account's collected person and the address row beneath them survive it, an account two users share serves its one collected record once to each of them while a user's own asserted contact hides it for that user alone — the precedence being a correlated read over the scope's ordered books that translates to array_position, so it is the planner rather than the application that applies it — a page is planned through the holder-leading index rather than scanned, at a volume where a sequential scan was the alternative, the threshold collection is held to counts what one address wrote out of the stored mail in a query whose two halves read a message stored in several folders as one message, and erasing the collected origin removes every collected record of a book and every address row hanging off one, leaving the asserted records, in two set-based statements no change tracker ever sees.
  • A draft's whole life runs against the real database and the real mail server at once: it is written, appended to the folder playing the drafts role, revised, promoted, and given up when the send it became is delivered. What only PostgreSQL settles there is that the record and its message cross one transaction, that a revision rewrites the one payload row rather than adding a second, that the copy rows keyed by revision are what an edit's append and removal are read from, and that removing the draft takes its recipients, its copies, and its message with it.
  • The same read model's vector half ranks the eligible mail by a correlated minimum over each message's own embedded passages, measured by the operator the active profile's metric names. Mail carrying no vector under that profile is absent from the ranking rather than distant, and the ordering is the part only a server can settle: whether the distance operator, the aggregate, and the caller's filters compose into one statement at all is a translation question rather than a compile-time one.