Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Parity additions

Binding for implementation. This page specifies nine smaller additions found when Pylota Identity was compared with AgentMail on 2026-10-17. Each one extends a design that already exists, so each section names the section it extends and gives its rules, API, storage, errors, events, limits and privacy; the shared pages carry the result (§18). None of them adds a Durable Object class, a queue or a binding: they reuse the IdentityMailbox object and its transactional outbox, the JobRunner erasure machinery, the policy pipeline of Outbound, the quarantine decision of Inbound, the Standard Webhooks delivery of Webhooks and the error envelope of Errors.

RequirementsFR-IN-13, FR-IN-14, FR-IN-15, FR-OUT-17, FR-WH-6, FR-WH-7, FR-PRV-7, FR-DOM-15, FR-API-3 (this page, §13); they extend FR-IN-4, FR-IN-5, FR-IN-10, FR-IN-11, FR-OUT-4, FR-OUT-13, FR-OUT-16, FR-WH-1, FR-WH-2, FR-WH-4, FR-PRV-2, FR-PRV-3, FR-PRV-4, FR-DOM-3, FR-API-2, FR-SRCH-13
Edge casesZ1–Z81 (§14)
CodeBatch: crates/api-types/src/messages/batch.rs, crates/worker/src/handlers/messages_batch.rs, mailbox/read.rs (BatchGet, BatchUpdate). Lists: crates/core/src/lists.rs (precedence, pure), handlers/lists.rs, consumers/inbound.rs (step 12), handlers/send.rs (step 6), consumers/outbound.rs (composition step 1). Label events: webhooks/payloads.rs (labels_changed), mailbox/read.rs, consumers/webhooks.rs (opt-in filter). Authentication detail and ARC: crates/core/src/auth.rs (arc_rescue, trust_detail), crates/core/src/trust.rs, consumers/inbound.rs (steps 7 and 12), mailbox/ingest.rs. Retention: handlers/identities.rs, mailbox/expiry.rs (new), mailbox/erase.rs, mailbox/idempotency.rs, crons/intents.rs. Webhook headers: handlers/webhooks.rs, webhooks/{client.rs, headers.rs} (new), crates/core/src/webhook_headers.rs (name and value rules, pure), crates/core/src/sealed.rs. Zone export: crates/core/src/zonefile.rs (pure), handlers/domains.rs. Docs link: crates/api-types/src/errors.rs, crates/worker/src/errors.rs, xtask/src/docs_check.rs. Console: console/pages/{inboxes.rs, threads.rs, webhooks.rs, domains.rs}. MCP: mcp/tools.rs. CLI: crates/cli/src/commands/{messages.rs, lists.rs, identities.rs, webhooks.rs, domains.rs}
TablesD1: sender_lists gains identity_id (in the primary key); identities gains message_hours; webhook_endpoints gains headers_sealed, header_names_json, headers_version; rpc_intents.op gains set_retention. Mailbox: messages.verdict gains arc_rescued; new meta keys retention_message_hours, retention_version, alarm:expiry, expiry_backoff, expiry:{YYYY-MM-DD}; auth_json gains spf.aligned and arc.{sealer, sealer_trusted, aar, rescue}; idempotency rows of expired messages become stubs, and idempotency.operation gains batch_update (Data model)
ContractsRoutes POST …/messages/batch-get (messages:read), POST …/messages/batch-update (messages:write), GET|PUT|DELETE /v1/identities/{identity_id}/lists/{direction}/{kind}[/{entry}] (suppressions:manage), PATCH /v1/webhooks/{webhook_id}/headers (webhooks:manage), GET /v1/domains/{domain_id}/records?format=bind (domains:read); identity field retention.message_hours; webhook fields headers (write-only) and header_names; message trust fields spf_domain, spf_aligned, dkim_domains, dmarc_domain, dmarc_policy, dmarc_aligned_by, arc_sealer; verdict value arc_rescued; error field docs; event message.labels_changed (opt-in); policy fields inbound.trusted_arc_sealers (platform-only) and events.labels_changed (free); variable PM_DOCS_URL; error codes 422 list_limit_reached, 422 webhook_header_limit_reached, 410 message_expired, and new details.reason values of 400 invalid_request and 400 header_not_allowed; audit actions message.batch_update, identity.retention_update, retention.expire, webhook.headers_update
Limits§2.6, §3.7, §4.5, §7.11, §8.4
Built inM37 (to be added to the build plan, §18.10)

1. The nine additions

§AdditionRequirementGapExtendsWhat a client sees
2Batch message operationsFR-IN-13GAP-12Inbound › Read path and releasebatch-get and batch-update of up to 100 messages, atomic inside one mailbox, with an atomic claim
3Identity-scope allow and block listsFR-OUT-17GAP-13Outbound › Recipient filters, Inbound › Quarantine decisionLists per identity; the most specific scope wins
4Label change eventsFR-WH-6GAP-14Webhooks › Event envelope and payloadsmessage.labels_changed, opt-in, one event per request
5Authentication detail on messagesFR-IN-14GAP-15Inbound › Authentication verdictSPF, DKIM and DMARC domains with alignment, and the ARC sealer, in trust
6Trusted ARC sealersFR-IN-15GAP-16Inbound › Authentication verdictForwarded mail that a trusted forwarder authenticated is arc_rescued, not quarantined
7Per-identity message retentionFR-PRV-7GAP-17Privacy › Retentionretention.message_hours: each message erased that many hours after it is stored
8Webhook delivery headersFR-WH-7GAP-18Webhooks › SigningUp to 10 static, write-only headers on every delivery
9Zone-file exportFR-DOM-15GAP-19REST API › Records?format=bind: the required records as an RFC 1035 zone fragment
10A documentation link in errorsFR-API-3GAP-20Errorsdocs: a link to the error’s row on the published errors page

Rules shared by all nine:

  • Scope and visibility are unchanged. Every route takes its scope from the key (Security § 5.2). An ID the key cannot reach, or a message it may not see (Security § 5.3), is reported exactly as a missing one, and the answer never says which of the two it was.
  • Inbound mail is never refused or dropped by anything on this page (FR-BILL-8, NFR-REL-1). The ARC rule only moves mail out of quarantine; it never moves mail in.
  • States. A route on this page behaves like the route it extends for every tenant and identity state: a suspended partner (403 partner_suspended), a tenant being erased and a deleting identity (the resource’s 404), the read_only switch (503 unavailable for every request that is not a GET from a non-platform key, so batch-get too) and a frozen deployment (503 unavailable) (Security § 5.2, step 4).
  • Test tenants use every addition as live tenants do. Nothing here leaves the deployment.

2. Batch message operations (FR-IN-13)

Extends Inbound › Read path and release (“Labels and read state”), REST API › Threads and messages and the MCP tool mail_update_labels (MCP § 4.3). Today labels and read state change one message or one thread per request; an agent that triages a page of mail makes 25 to 100 requests, and two agents cannot claim a message without a race.

2.1 POST /v1/identities/{identity_id}/messages/batch-get — messages:read

Every key level. x-idempotency: none: it returns mail and changes nothing, so, like search, it is never recorded (REST API › Idempotency).

{ "message_ids": ["msg_01JA4B1G7PW7X2M5N6P8R0T1YC", "msg_01JA4B2K9QW7X2M5N6P8R0T1YD", "msg_01JA4B3M2RW7X2M5N6P8R0T1YE"],
  "extracted_text_bytes": 2048 }
{
  "data": [
    { "id": "msg_01JA4B1G7PW7X2M5N6P8R0T1YC", "thread_id": "thr_01JA…", "direction": "inbound", "status": "received",
      "from": { "address": "jo@example.net", "name": "Jo Rivera" }, "subject": "Change of dates for BK-2291",
      "extracted_text": "Could we move the pick-up to Friday…", "extracted_text_truncated": false,
      "text": null, "html": null, "labels": ["booking"], "trust": { "verdict": "pass", "…": "…" }, "…": "…" }
  ],
  "not_found": ["msg_01JA4B3M2RW7X2M5N6P8R0T1YE"],
  "remaining": [],
  "truncated": false
}
  • data holds Message objects in request order, built as GET …/messages/{message_id} builds them, without text, html and headers (there is no include), and with extracted_text cut at a UTF-8 character boundary to extracted_text_bytes (0–16,384, default 2,048), with extracted_text_truncated: true when it was cut.
  • not_found lists, in request order, every ID that is not a message of this identity that the key may see: missing, erased, of another identity, or quarantined, screening, hidden or throttled without quarantine:review. The answer is the same for each of them.
  • remaining and truncated: the serialised response body never exceeds 1,048,576 bytes. When the next message would pass that budget, it and every later found message are listed in remaining, in request order, and truncated is true; the client asks again for them. The first found message is always in data (one message without text and html is far below the budget).

2.2 POST /v1/identities/{identity_id}/messages/batch-update — messages:write

Every key level. Idempotency-Key optional, as on every other POST.

{ "message_ids": ["msg_01JA4B1G7PW7X2M5N6P8R0T1YC", "msg_01JA4B2K9QW7X2M5N6P8R0T1YD"],
  "labels_add": ["claimed", "claimed-by-bookings"], "labels_remove": ["new"],
  "read": true, "archived": false, "require_absent": ["claimed"] }
{ "updated": ["msg_01JA4B1G7PW7X2M5N6P8R0T1YC"], "unchanged": [],
  "conflicts": ["msg_01JA4B2K9QW7X2M5N6P8R0T1YD"], "not_found": [],
  "threads_archived": 0, "threads_unarchived": 0 }
  • labels_add, labels_remove: labels as in PATCH …/messages/{message_id} (pattern ^[a-z0-9][a-z0-9_:-]{0,63}$), at most 64 each. read sets the read state. archived sets the archived flag of each thread that holds a listed message: archiving is a thread property in this design (Inbound › Read path and release), so FR-IN-10’s per-message archiving is met by archiving the message’s thread, as the single-thread PATCH does.
  • require_absent (at most 10 labels) makes the change conditional per message: a message that carries any of these labels when the transaction runs is not changed and is listed in conflicts. It is the atomic claim that lets several agents share one inbox: require_absent: ["claimed"] with labels_add: ["claimed"] lets exactly one of two racing callers take a message.
  • updated: messages this request changed (a label, the read state, or its thread’s archived flag). unchanged: messages found and allowed whose state already matched. conflicts: messages skipped by require_absent. not_found: as for batch-get. Every listed ID appears in exactly one of the four.
  • threads_archived and threads_unarchived count the threads whose flag this request changed.

2.3 Rules, in order

  1. Scope. Authentication, permission and the identity path are checked once for the whole request (Security § 5.2). An identity outside the key’s scope, or deleting, is 404 identity_not_found and nothing else is read. The system identity is 404 to every key but a platform key, as on every mailbox route.
  2. Body. message_ids holds 1–100 IDs matching ^msg_[0-9A-HJKMNP-TV-Z]{26}$, otherwise 400 invalid_request with details.errors[0].path = "message_ids" or "message_ids[{i}]". A repeated ID is processed once, at its first position. For batch-update: at least one of labels_add, labels_remove, read and archived (else 400 invalid_request, path labels_add); a label in both labels_add and labels_remove is 400 invalid_request (path labels_remove); require_absent needs at least one of labels_add and labels_remove.
  3. Visibility, inside the mailbox: an ID is found when a message with that ID exists in this mailbox, is not in erased_ids, and is visible to the key (status not quarantined, screening, hidden or throttled, or the key holds quarantine:review, passed as review exactly as for UpdateMessage). Everything else goes to not_found.
  4. batch-get reads the found rows, their attachments, labels and refs in one read, builds the objects in request order and applies the byte budget of §2.1.
  5. batch-update runs in one transaction_sync, after the idempotency lookup of §2.4 in the same synchronous step:
    1. for each found message, in request order: when it carries a label of require_absent, it goes to conflicts and nothing else happens to it;
    2. for each other found message, its label set after the change is before ∪ labels_add − labels_remove; if any would exceed 64 labels, the transaction is abandoned and the request gets 400 invalid_request with details.reason = "label_limit" and details.message_ids (the messages that would pass the limit). Nothing changes: the batch is atomic;
    3. labels: INSERT OR IGNORE INTO labels (message_rowid, label) SELECT r.value, l.value FROM json_each(?1) r, json_each(?2) l and DELETE FROM labels WHERE message_rowid IN (SELECT value FROM json_each(?1)) AND label IN (SELECT value FROM json_each(?3)), so no statement binds more than three parameters whatever the counts;
    4. read: UPDATE messages SET read = ? for those rows, then unread_count is recomputed for each affected thread (visible inbound messages with read = 0);
    5. archived: the distinct threads of those messages get threads.archived = ?; a thread already in that state is not counted;
    6. the outbox gets message.labels_changed when the handler passed emit_label_events (§4) and at least one visible message’s labels changed;
    7. with an Idempotency-Key, the idempotency row holding the response (§2.4).
  6. Audit. After the commit, a batch-update that updated at least one message writes one audit row, message.batch_update (target_type: "identity", details: requested, updated, unchanged, conflicts, not_found as counts, labels_add, labels_remove, read, archived), the way the release handler writes quarantine.release after its commit. A batch-get by a platform or partner key writes one mail.read row before the response (target_type: "identity", details.route, details.messages = the count returned), and fails with 503 unavailable if the row cannot be written, as every content read by those keys does (REST API › Audit).

Single-message PATCH …/messages/{message_id} and PATCH …/threads/{thread_id} keep their behaviour. require_absent exists only on batch-update; a claim on one message is a batch of one.

2.4 Concurrency, idempotency and failures

  • Concurrency. A mailbox runs one transaction at a time, and require_absent is evaluated inside the transaction, so two concurrent claims of one message give one updated and one conflicts, never two owners. A batch never sees half of another batch.
  • Idempotency. With an Idempotency-Key, the record lives in the mailbox’s own idempotency table, as for sends and the draft routes (Outbound › Reservation), scoped per identity like every mail route, and is written by the same transaction_sync that applies the change: key_hash, operation batch_update, a fingerprint over the operation, the identity, the canonical body and the review flag, and response_json = the response (IDs and counts only, never mail content), kept 30 days. The lookup runs first, in the same synchronous step as the transaction: the same fingerprint replays response_json with Idempotent-Replayed: true and writes no label, no event and no audit row; another fingerprint (another body, another operation, or a key without the review the first had) is 409 idempotency_conflict; a key held in in_flight by a send or draft operation still running is 409 request_in_progress. Two batches with the same key never run together: the mailbox runs the second after the first commits, and it replays. A request refused before or inside the transaction (400, including label_limit) records nothing. D1 idempotency_records holds no batch-update record. Without a key, a retry after a lost response applies the same set operation again and changes nothing more, but a caller’s own earlier claim then shows as a conflict; agents that claim should send a key.
  • Failures. The mailbox unavailable or the deadline passed before the transaction: 503 unavailable or 504 timeout, and nothing changed. A crash after the commit loses only the response: the record committed with the change, so a retry with the same key replays it and the caller’s own claim reads as updated, never as a conflict. A failed audit write after the commit is logged (audit_write_failed) and the response is still 200, as for quarantine.release.

2.5 Storage

No schema change except the value batch_update of the mailbox idempotency.operation (Data model). ReadRequest (Inbound › Read path and release) gains two variants:

// crates/worker/src/mailbox/read.rs
BatchGet    { message_ids: Vec<String>, extracted_text_bytes: u32, review: bool },
BatchUpdate { message_ids: Vec<String>, labels_add: Vec<String>, labels_remove: Vec<String>,
              read: Option<bool>, archived: Option<bool>, require_absent: Vec<String>, review: bool,
              label_events: Option<LabelEventContext>,     // None when events.labels_changed is off
              idem: Option<BatchIdem> },                   // None without an Idempotency-Key
pub struct LabelEventContext { pub actor: Actor, pub request_id: String, pub source: LabelSource }
pub struct BatchIdem { pub key_hash: String, pub fingerprint: String }   // §2.4

2.6 Limits

LimitValueSource
IDs per batch100Pylota Identity (AgentMail allows 50 per batch_update)
extracted_text_bytes0–16,384, default 2,048Pylota Identity
batch-get response1,048,576 bytes, then remainingPylota Identity
Labels per request64 in labels_add, 64 in labels_remove, 10 in require_absentPylota Identity
Rate limitOne request against the key, tenant and partner buckets (RL_API), whatever the batch sizePylota Identity

2.7 Interfaces and privacy

  • MCP. mail_update_labels gains message_ids (1–100) and require_absent; exactly one of message_id, thread_id and message_ids is required, checked by the handler (the input schema stays a plain object, MCP § 4.3), and require_absent only with message_ids. With message_ids it calls batch-update and returns its response object. There is no batch-get tool: a model reads one or two messages at a time, and 100 messages would exceed the tool’s 96 KB result budget.
  • CLI. idvy messages label <message-id>… --identity <identity> [--add <label>]… [--remove <label>]… [--read | --unread] [--archive | --unarchive] [--require-absent <label>]… calls batch-update when given more than one ID, in requests of 100 (atomic per request, not across requests; it says so when it splits); idvy messages get <message-id>… calls batch-get for more than one ID.
  • Console. No change.
  • Privacy. No new store. A batch-get response carries the same mail as the single GET; an idempotency record of batch-update (in the mailbox, deleted with it) holds IDs and counts only.

3. Identity-scope allow and block lists (FR-OUT-17)

Extends Outbound › Recipient filters (policy step 16), the pm-inbound consumer (step 12), Inbound › Quarantine decision (rules 1, 4a and 6), Inbound › Trust signals (known_sender), Inbound › Inbound volume caps, REST API › Suppressions and lists, Data model (sender_lists) and Privacy § 7.3. Today lists exist only per tenant (FR-OUT-16), so a send-allow entry made for one identity’s first contact makes the address known to every identity of the tenant, and a receive-block made for one inbox hides the sender from all of them.

3.1 Scopes and precedence

An entry belongs to the tenant scope (as today) or to one identity of the tenant. For a message of identity I in tenant T, the decision for one direction and one address is:

 entries that match the address or its @domain: I's (identity scope) and T's (tenant scope)
        │
        ▼ drop every tenant entry that an identity entry overrides: an identity entry for the address
        │ drops T's entries for the address and for its @domain; an identity @domain entry drops T's
        │ @domain entries only (never T's entry for the exact address)
        ▼
 any entry left ── yes ──▶ block if any left is block, else allow   (scope: that of the deciding entry)
        │ none
        ▼
 no entry

core::lists::decide(rows: &[ListRow]) -> Option<ListDecision { kind, scope, entry }> (pure) implements it:

  1. The more specific scope wins, at the same or a finer granularity. An identity entry overrides the tenant’s entries for the same address or domain, and an identity entry for an address also overrides the tenant’s entries for its @domain. An identity allow therefore overrides a tenant block of the same address or domain, and an identity block overrides a tenant allow. An identity @domain entry never overrides a tenant entry for one exact address: a tenant block of jo@example.net still hides Jo from an identity that allows @example.net (no exemption from rules 4a and 6) and still suppresses its sends to Jo, because the tenant named Jo and the identity named only the domain.
  2. Among the entries left, block wins over allow, for address and domain entries and for both scopes alike, as tenant lists do today (consumer step 12: “block wins over allow”). The decision’s scope and entry are those of the deciding entry: for a block, an identity block when one is left, else the tenant’s; for an allow, the same.
  3. Matching is the existing matching of tenant lists, unchanged and shared by both scopes (core::lists::candidates(address): the address itself and @ followed by its domain as the existing inbound and outbound queries form it).

3.2 Where the decision is used

RuleToday readsNow reads
Quarantine rule 1, hidden / blocked_sendera tenant receive-block entrythe effective receive decision is block
Quarantine rules 4a and 6 exemptions; the volume-cap exemption of consumer step 13; the receive-allow part of known_sendera tenant receive-allow entrythe effective receive decision is allow
Recipient filter “send-block”a tenant send-block entrythe effective send decision is block; the delivery’s smtp_response is policy: send_block for a tenant entry, as today, and policy: send_block (identity) for an identity entry
policy.send_allowlist_onlya tenant send-allow entrythe effective send decision is allow
Known recipient, rule 2 (Outbound › Recipient filters)a tenant send-allow entrythe effective send decision is allow
Dry run (?dry_run=true)the rulethe rule, unchanged (reason: "send_block"), and a new recipient field scope (identity or tenant) beside it; 422 recipient_blocked gains details.scope

How it composes with require_known_recipient. The recipient filters run in this order, and the first that applies decides: (1) an unexpired suppression → suppressed (policy: suppression (…)); (2) the effective send decision is block → suppressed (policy: send_block (…)), even for a known recipient and for the authenticated sender being answered; (3) policy.send_allowlist_only and the effective send decision is not allow → suppressed (policy: not_on_allowlist); (4) the identity’s require_known_recipient and the recipient is not known → suppressed (policy: unknown_recipient). A recipient is known by the three rules of Outbound › Recipient filters, rule 2 now meaning “the effective send decision for this identity is allow”. So an identity-scope send-allow entry makes an address known to that identity only, and the tenant’s other identities still suppress it.

3.3 What a list entry never overrides

A list is configuration, not policy, so it has no ceilings, and it can never lift a limit the platform or a partner set or a guarantee the service gives. Whatever its scope, an allow entry never overrides:

  • a suppression (FR-OUT-4; an objection or a bounce must be respected, Privacy § 7.2);
  • test_mode_recipient (FR-OUT-12), the loop guard, the per-identity and tenant daily caps, the new-workspace ramp, the shared-domain breaker, sending_paused, a suspended tenant or partner, or the marketing transport rule;
  • quarantine rules 3 and 3a (authentication), 4 (risky attachments) and 5 (unsolicited codes); only rules 4a and 6 are exempt, as today;
  • the per-sender inbound cap (only the unauthenticated and tenant caps exempt a receive-allowed sender, as today).

3.4 Routes

GET /v1/identities/{identity_id}/lists/{direction}/{kind} lists the identity’s entries, and GET|PUT|DELETE /v1/identities/{identity_id}/lists/{direction}/{kind}/{entry} reads, adds or updates, and removes one, all with suppressions:manage. direction, kind, entry and the bodies are those of the tenant routes. Platform, partner and tenant keys only: identity keys cannot hold suppressions:manage, so an agent can never change its own lists, and an identity key gets 403 permission_denied (details.required: ["suppressions:manage"]).

  • PUT adds the entry, or updates its note when it exists, and answers 200 with it. DELETE answers 204, or 404 list_entry_not_found for an entry that does not exist.
  • The list entry gains scope (tenant or identity) and identity_id (null for tenant scope). The tenant routes are unchanged and read and write tenant-scope entries only.
  • The system identity: 404 identity_not_found for every key but a platform key, which gets 400 invalid_request with details.reason = "system_identity" (its sign-in mail must never be filtered by a list).
{ "scope": "identity", "identity_id": "idn_01JA9K…", "direction": "send", "kind": "allow",
  "entry": "seller.4471@marketplace.example", "note": "operator_approved_seller acq_01JA…",
  "created_at": "2026-10-17T10:05:00Z" }

3.5 Storage

sender_lists gains the identity in its primary key. '' stands for the tenant scope, because SQLite treats NULL values in a composite primary key as distinct, which would let two equal tenant entries in.

CREATE TABLE sender_lists (
  tenant_id   TEXT NOT NULL REFERENCES tenants(id),
  identity_id TEXT NOT NULL DEFAULT '',                    -- '' = tenant scope; else an idn_ of this tenant
  direction   TEXT NOT NULL CHECK (direction IN ('receive','send')),
  kind        TEXT NOT NULL CHECK (kind IN ('allow','block')),
  entry       TEXT NOT NULL,                               -- user@example.com or @example.com
  note        TEXT,
  created_at  INTEGER NOT NULL,
  PRIMARY KEY (tenant_id, identity_id, direction, kind, entry)
);
CREATE INDEX sender_lists_identity ON sender_lists(identity_id, direction) WHERE identity_id <> '';

The two readers bind the identity and read both scopes in one statement:

-- consumer step 12 (receive) and handler step 6 / composition step 1 (send): ?2 the direction,
-- ?3 the identity, ?4 the candidates (address and @domain) of each address as one JSON array
SELECT identity_id, kind, entry FROM sender_lists
WHERE tenant_id = ?1 AND direction = ?2 AND identity_id IN ('', ?3)
  AND entry IN (SELECT value FROM json_each(?4));

PUT runs one D1 batch: an UPDATE … SET note = ? of the existing row, then a guarded insert that runs only when the row does not exist and the scope and tenant are under their limits:

INSERT INTO sender_lists (tenant_id, identity_id, direction, kind, entry, note, created_at)
SELECT ?1, ?2, ?3, ?4, ?5, ?6, ?7
WHERE NOT EXISTS (SELECT 1 FROM sender_lists WHERE tenant_id = ?1 AND identity_id = ?2
                  AND direction = ?3 AND kind = ?4 AND entry = ?5)
  AND (SELECT COUNT(*) FROM sender_lists WHERE tenant_id = ?1 AND identity_id = ?2) < 10000
  AND (SELECT COUNT(*) FROM sender_lists WHERE tenant_id = ?1) < 50000;

When neither statement changed a row, the request gets 422 list_limit_reached with details.limit and details.scope (identity, tenant or total). Two requests racing for the last place both run inside D1’s serialised batches, so only one passes the count.

Races with mail in flight. The inbound decision uses the lists read at consumer step 12; an entry written after that and before the mailbox commits does not apply to that message. The outbound decision is taken at submit and again at composition step 1, which re-reads both scopes, so an identity send-block written after a submit still suppresses that recipient before the transport (as a tenant send-block does today, G4).

3.6 Reply lists: not added

AgentMail has a third direction, reply, whose lists alone are checked for replies, because its receive-allow list, once it has an entry, blocks every other sender, replies included. Pylota Identity does not add a reply direction, because its existing rules already cover replies:

  • a receive-allow entry is an exemption (rules 4a and 6, the unsolicited caps), never an allow-only mode, so no allow list can block a reply;
  • a receive-block entry blocks a sender’s mail whatever it answers, which is what blocking means;
  • for outbound replies, the send lists apply to reply, reply-all and forward like any send, and the reply-target rule of require_known_recipient already lets an identity answer the authenticated sender of a received message;
  • a reply’s authenticity is decided by threading (thread_join_unverified, C9), not by a list.

3.7 Limits

LimitValueSource
Entries per scope (the tenant scope, and each identity)10,000Pylota Identity
Entries per tenant, every scope together50,000Pylota Identity. At about 200 bytes a row, 10 MB of the 10 GB D1 database; the D1 size alerts (Limits › Storage) still apply

The limits also apply to tenant-scope entries, which had none before; 422 list_limit_reached is new.

3.8 Privacy, events and interfaces

  • Privacy. Identity-scope entries hold clear addresses or domains the tenant chose, like tenant entries. Identity-scope erasure and identity deletion delete the identity’s entries (step scrub_control_plane, Privacy § 6.5), tenant erasure deletes every entry (step delete_d1_rows, already listing sender_lists), and both receipts count them in the new field list_entries_deleted. Counterparty erasure leaves entries of both scopes, for the reason of Privacy § 7.3.
  • Events and audit. None, as for tenant lists.
  • Console. The inbox page (/console/inboxes/{idn}) lists the identity’s entries read-only, with the scope, so a person can see why mail is hidden or a recipient suppressed. Entries are managed through the API and the CLI, as tenant entries are.
  • CLI. idvy lists list|add|remove <direction> <kind> [<entry>] --identity <identity>; --tenant keeps the tenant scope.
  • MCP. None: agents never hold suppressions:manage.

4. Label change events (FR-WH-6)

Extends Webhooks › Event envelope and payloads and Endpoint resolution and filters, Webhook events › Messages, and Inbound › Read path and release, whose label changes “emit no event” today. Several agents that share an inbox can coordinate through labels (one claims a message, another escalates it) only if they learn of each other’s changes without polling.

4.1 Opt-in, twice

message.labels_changed is the one opt-in event type of v1, for two reasons: label changes can be as frequent as reads, and every event costs an outbox row in the mailbox and an event_index row in the D1 database that the whole deployment shares (Data model › Notes, “Write volume”).

  1. Emission needs the tenant’s policy field events.labels_changed: true (a free field, default false; Configuration). While it is false no event is written anywhere: not to the outbox, event_index or the event feed (Event feed).
  2. Delivery needs the endpoint to name the type in events. "*" never includes it: * means every type that is not opt-in, including types added later. The list of opt-in types is one constant, OPT_IN_EVENT_TYPES in crates/api-types/src/events/mod.rs, read by the Fanout filter and by replay.

Creating or changing an endpoint that names it needs messages:read, because it is a message.* type (Webhooks › Who may subscribe to mail events).

4.2 Payload

{
  "id": "evt_01JA9Q…", "type": "message.labels_changed", "api_version": "2026-10-01",
  "occurred_at": "2026-10-17T10:05:01.220Z", "tenant_id": "ten_01J9…", "identity_id": "idn_01J9…",
  "sequence": 2210,
  "data": {
    "messages": [ { "message_id": "msg_01JA4B1G7PW7X2M5N6P8R0T1YC", "thread_id": "thr_01JA4B…" } ],
    "added": ["claimed", "claimed-by-bookings"],
    "removed": ["new"],
    "actor": { "kind": "key", "key_id": "key_01J9…", "user_id": null },
    "source": "batch",
    "request_id": "req_01JA9Q…",
    "part": 1, "parts": 1
  }
}
FieldMeaning
messagesThe visible messages whose label set this request changed, at most 100, in request order (for a thread, oldest first)
added, removedThe requested labels, normalised, that changed at least one listed message. After the change every listed message carries every label in added and none in removed
actorkind: "key" with key_id, or kind: "person" with user_id for a change made in the console; the other ID is null
sourcemessage (PATCH …/messages/{id}), thread (PATCH …/threads/{id}) or batch (batch-update); an MCP call has the source of the route it calls
request_idThe request that made the change, so consumers can group the parts of one change
part, parts1 and 1, except for a thread change over more than 100 messages (§4.3)

The payload holds IDs and labels only: no subject, address or text, so it is thinner than every other message.* event (FR-WH-4).

4.3 Rules

  1. The event is appended to the outbox in the transaction that changed the labels, with the identity’s next sequence, so it is ordered with the identity’s other events (C5) and is never emitted for a change that did not commit.
  2. One request emits one event, or ceil(n / 100) events when a thread PATCH changes more than 100 visible messages, each with the same request_id, part from 1 and the same parts.
  3. Nothing is emitted when: the policy field is off; no label changed (only read or archived, or every label already matched); the change was a require_absent conflict; the labels were set when the message was created (the send’s labels, a draft’s labels carried to its message); labels disappeared because a message was erased, expired (§7) or deleted; a release or a re-parse ran. These are system effects, not label changes: state the service sets never emits this event.
  4. A message that is not visible (quarantined, hidden, throttled, or Screening’s screening) is left out of messages, even when a key with quarantine:review changed its labels, so an endpoint never learns of mail it would not receive as message.received. When no visible message is left, no event is emitted.
  5. An idempotent replay of batch-update emits nothing.
  6. The Fanout consumer delivers it only to endpoints that name it (rule 2 of §4.1) and match its identity filter; it is never handed to the Notifier.
  7. Turning the policy field off stops new events; events already in the outbox are still delivered.
  8. Erasure and expiry. EraseRows step 3 (Privacy § 6.2) finds outbox rows by data.message_id or data.message.id, which a label event does not have. It also matches message.labels_changed rows whose data.messages lists the message: the entry is removed with json_remove, the row is deleted when no entry is left, and the count of deleted rows goes to events_deleted. A label event already delivered names only IDs and labels, so no content of the erased message remains in it.

The handler reads the effective policy with the identity in step 4 of the order of checks (one more column of the tenant row it already reads) and passes label_events: Some(LabelEventContext) to the mailbox only when the field is on.

4.4 Consumers

The event is at-least-once like every event; deduplicate on its id, which is also its ID in the event feed (Event feed). It says what changed, not who may act: two agents that both see claimed added should not both act, and the safe way to claim is require_absent (§2.2), whose result says who won. A consumer that writes labels itself should ignore events whose actor.key_id is its own key, so it does not react to its own changes.

4.5 Limits and cost

LimitValue
Messages per event100 (a thread change over more is split into parts)
Labels per event64 in added, 64 in removed
Events per request1, or ceil(n / 100) for a thread

An event is about 70 bytes per listed message plus the labels: at most about 16 KB.

5. Authentication detail on messages (FR-IN-14)

Extends Inbound › Authentication verdict (step 8, auth_json, and its last paragraph, the API summary), the Message object and the trust object of message.received and message.quarantined. Today trust gives one result per method; an integrator that wants to know which domain passed (an invoice signed by the supplier’s own domain or by its mailing provider) has to read the raw headers.

5.1 New trust fields

Every field comes from auth_json, which ingest already writes; nothing is computed again at read time.

FieldTypeFromMeaning
spf_domainstring or nullauth_json.spf.domainThe domain SPF checked: smtp.mailfrom of the trusted Authentication-Results header (or the envelope sender’s domain), or SES’s mail.source for the SES source. null when SPF was not checked (no trusted header)
spf_alignedbooleanauth_json.spf.aligned (new, step 6)SPF passed and spf_domain aligns with the From domain under the record’s aspf
dkim_domainsarray, at most 10auth_json.dkim[]One entry per DKIM-Signature evaluated, in header order: { "domain": d=, "selector": s=, "result", "aligned" }
dmarc_domainstring or nullthe From domainThe domain DMARC was evaluated for (null without a From address)
dmarc_policynone, quarantine, reject or nullauth_json.dmarc.policyThe policy in force (sp for a subdomain when the record came from the organisational domain); null without a record
dmarc_aligned_bydkim, spf or nullauth_json.dmarc.aligned_byWhich method aligned, as recorded today
arc_sealerstring or nullauth_json.arc.sealer (new)The d= of the newest ARC-Seal when the ARC chain validated (arc: "pass"), trusted or not; null otherwise
"trust": {
  "verdict": "pass", "spf": "pass", "dkim": "pass", "dmarc": "pass", "arc": "pass",
  "spf_domain": "mail.brightwell.example", "spf_aligned": true,
  "dkim_domains": [
    { "domain": "brightwell.example", "selector": "s1", "result": "pass", "aligned": true },
    { "domain": "mailer.example", "selector": "k2", "result": "pass", "aligned": false }
  ],
  "dmarc_domain": "brightwell.example", "dmarc_policy": "reject", "dmarc_aligned_by": "dkim",
  "arc_sealer": "google.com",
  "known_sender": true, "quarantined": false, "spam_score": 0.02, "automated": false, "flags": []
}
  • Domains are A-labels in lower case, as auth_json stores them.
  • The fields are present wherever trust is: inbound messages, message.received and message.quarantined. A loopback message (L3) has null domains and an empty dkim_domains, because it was not authenticated over the network. Search hits keep their short trust (verdict, known_sender, quarantined).
  • Messages stored before this change have every field except arc_sealer (null) and spf_aligned, which is then true only when dmarc_aligned_by is spf, the one case the old auth_json records.
  • The service never returns the Authentication-Results or ARC-* headers in trust; they stay in the raw MIME and in include=headers.

5.2 auth_json additions

Step 6 records spf.aligned. Step 4 records, for a chain whose result is pass, arc.sealer (the newest seal’s d=), arc.sealer_trusted (whether it is in inbound.trusted_arc_sealers), and arc.aar (from the newest ARC-Authentication-Results: its authserv-id, its dmarc result and header.from, and its smtp.rcpttodomain when present). §6 adds arc.rescue. Each value is a short ASCII string, so the row budget of Inbound › Storage caps is unaffected.

6. Trusted ARC sealers (FR-IN-15)

Extends Inbound › Authentication verdict (steps 2, 4, 7 and 8), Trust signals, the Quarantine decision (rules 3 and 3a), Inbound volume caps, the verification rules of Inbound and Service sign-up ledger § 5, the known-recipient rule of Outbound › Recipient filters, the citation check of Search, triage rule 13 of Triage, and Configuration › Tenant policy.

Today ARC “is recorded; it does not override DMARC in v1.0” (step 4). A forwarder that changes a message (a footer, a subject tag, a rewritten body) breaks the original DKIM signature, and SPF then names the forwarder, so a message from a domain with p=quarantine or p=reject arrives with verdict fail and is quarantined auth_failed, although the forwarder checked it on arrival and recorded dmarc=pass. This is common for send_only domains, whose inbound mail reaches the identity through a forwarding rule in the customer’s own mailbox (FR-DOM-10), and for SES-receiving domains behind a mailing list.

6.1 Sources read on 2026-10-17

  • RFC 8617 (ARC, Experimental). An ARC set is an ARC-Authentication-Results (AAR), an ARC-Message-Signature (AMS) and an ARC-Seal (AS) with the same instance i=, 1 to 50; the seal’s cv= is none, fail or pass (§4.4). A validator (§5.2) fails a chain with more than 50 sets, a newest seal of cv=fail, a set missing a header, instances that are not a continuous 1..N, a cv that is not none on instance 1 and pass on every later one, a newest AMS that does not verify, or any seal that does not verify; a failed chain “MUST be treated the same as a message with no Authenticated Received Chain”. The AAR records the sealer’s assessment “at message arrival time” (§4.1.1). A validated chain shows that the sealer of instance N emitted the message with this body after that assessment (§9); ARC “does not make any assessment of their trustworthiness” (§9.3), “Recipients are cautioned to treat every Sealer of the ARC Chain with suspicion” (§9.4), and whether to accept a sealer’s assessment for DMARC is local policy (§7.2.1). An intact passing chain can be replayed to other recipients (§9.5). (RFC 8617, read 2026-10-17.)
  • Google seals with d=google.com: a Gmail message quoted on the exim-users list shows two sets with d=google.com; s=arc-20240605 and AAR authserv-id mx.google.com (exim-users, 2024-11-13, read 2026-10-17), and arc-20160816._domainkey.google.com and arc-20240605._domainkey.google.com publish RSA keys (DNS over HTTPS, cloudflare-dns.com, 2026-10-17). Google’s own ARC page does not name the domain (ARC email authentication, last updated 2026-10-13, read 2026-10-17).
  • Microsoft (Exchange Online) seals with d=microsoft.com; s=arcselector10001, AAR authserv-id mx.microsoft.com, and an AMS that signs From, Date, Subject and Message-ID but not To, with smtp.rcpttodomain in the AAR (headers quoted in a Microsoft Q&A thread, 2025-02-27, read 2026-10-17; re-read 2026-10-18: in that sample smtp.rcpttodomain is the domain the message was addressed to when it reached the forwarding tenant, not the domain it was forwarded to, and only that one sample was found, so the rule below must not depend on which of the two a sealer records); arcselector9901._domainkey.microsoft.com and arcselector10001._domainkey.microsoft.com publish keys (DNS over HTTPS, 2026-10-17). Microsoft’s own feature trusts a sealer by the d= of its ARC-Seal, and “ARC overrides DMARC only, not spam filtering” (Configure trusted ARC sealers, updated 2026-08-12, read 2026-10-17).
  • Not verified: outlook.com and icloud.com, which AgentMail trusts. No header sample or document naming them as seal domains was found this run, and arcselector9901._domainkey.outlook.com has no record, so neither is in the default list.
  • Cloudflare Email Routing performs “SPF, DKIM, DMARC, and ARC checks” and rejects “Mail that fails authentication according to the sender’s DMARC policy” before the Worker (Email lifecycle, read 2026-10-17). It does not say whether a valid ARC chain changes that decision. So for the routing inbound source (the platform domain, which carries send_only forwards, and Cloudflare zones), a DMARC-failing forward under p=quarantine or p=reject may be refused by Cloudflare and never reach this rule; the rule certainly applies to the ses source, whose receipt rule refuses nothing for authentication, to p=none failures and to the unverified case. The live test live::arc::cloudflare_forward_behaviour records what Cloudflare does with a DMARC-failing message sealed by google.com, and the result is written here as a “Spike result” note.
  • mail-auth. On the crate’s main branch (read 2026-10-17) ArcOutput::chain() returns the sets oldest first, with Seal { i, d, s, t, cv } (t is 0 when absent) and the AMS Signature { h, d, t, … }. docs.rs documents 0.13.3, the pinned version, without the arc feature’s items, so the build checks that 0.13.3 exposes them; if it does not, core::auth::arc reads the newest ARC-Seal, ARC-Message-Signature and AAR tags itself from the raw headers, after verify_arc has validated the chain.

6.2 The policy field

inbound.trusted_arc_sealers: an array of domains, each an A-label registrable domain in lower case (a public suffix, an IP literal or a name that is not a DNS name is 400 invalid_request with details.errors[].path), unique, at most 20. Built-in default ["google.com", "microsoft.com"], the two sealers verified above. Platform-only: a partner key or a workspace writer gets 403 scope_denied (details.field, and for a workspace writer details.reason = "not_writable"), as for domains.cloudflare_zones. [] turns the rule off. A deployment operator who sees another forwarder’s ARC-Seal: … d=… in real headers (for example a Cloudflare Email Routing customer forwarding through Cloudflare, whose seal domain was not checked this run) adds it in PM_DEFAULT_POLICY or per tenant.

6.3 The rule

core::auth::arc_rescue(input: &RescueInput) -> Rescue (pure). It runs only when step 6 gives DMARC fail (under any policy) or the step-7 unverified condition holds, and multiple_from is false. Every condition must hold; the first that fails is recorded in auth_json.arc.rescue = { "result": "refused", "reason": … }.

#Conditionreason when it fails
1The effective inbound.trusted_arc_sealers is not emptyoff
2The ARC chain validates by RFC 8617 § 5.2 (verify_arc gives pass, with the step-2 DNS rules; a key that could not be fetched fails the chain)chain
3The newest set’s ARC-Seal d= and ARC-Message-Signature d= are equal and are in the list (exact match after A-label lower-casing; a subdomain does not match)untrusted_sealer
4The newest AMS’s h= includes from, so the From header is the one the sealer signedfrom_unsigned
5The newest AAR has a dmarc result of exactly pass whose header.from equals the message’s From domain (bestguesspass, none and every other value fail)no_dmarc_pass
6Freshness. The newest seal’s t=, else the newest AMS’s t=, is within [received_at − 72 hours, received_at + 15 minutes]; when neither has t=, the Date header, if the newest AMS signs it, is in that window; otherwise the condition failsstale
7Recipient binding. An active or retiring address of the receiving identity (its send_only addresses included) is in To when to is in the newest AMS’s h=, or in Cc when cc is, or the newest AAR’s smtp.rcpttodomain, when present, is the domain of such an address and that domain belongs to the receiving tenant (domains.tenant_id is the tenant). The platform domain (tenant_id NULL), which every tenant’s identities share, never binds through smtp.rcpttodomain: a domain binding names no identity, so on a shared domain it would let mail sealed for one tenant be replayed to any otherno_binding

All seven hold → verdict arc_rescued and auth_json.arc.rescue = { "result": "rescued" }. The verdict table of step 7 gains one row, second:

Condition (first match)verdict
loopback setpass
DMARC passpass
DMARC fail, or the unverified condition, and arc_rescue succeededarc_rescued
… the existing rows, unchanged…

Conditions 1–6 run in step 7. Condition 7 needs the identity’s addresses: when 1–6 hold, step 12 adds SELECT a.address, d.tenant_id IS NOT NULL AS own_domain FROM addresses a JOIN domains d ON d.id = a.domain_id WHERE a.identity_id = ?1 AND a.status IN ('active','retiring') to its facts batch (only for such candidates, so ordinary mail reads nothing more), and the verdict is finished before MailboxRequest::Ingest. 72 hours and 15 minutes are Pylota Identity choices: a forward normally arrives within minutes, and a message older than three days that needs rescuing can still be released by a person.

6.4 What a rescue proves, and what it does not

It proves that a sealer the operator trusts received the message addressed to this identity, found that it passed DMARC for its From domain, and has not been changed since that sealer signed it, except by what the sealer itself changed (RFC 8617 § 9). It does not prove that the sealer judged correctly, that the body is the one the original sender wrote (the sealer, or its customer’s rules, may have added a footer), or anything about earlier hops the sealer did not vouch for. A forged chain fails condition 2, a seal from anyone else fails 3, a replay of mail sealed for an address of another tenant or for the platform domain fails 7, an old capture fails 6, and an exact replay of a rescued message is deduplicated by hash or Message-ID (B3, B14). A binding through smtp.rcpttodomain (Microsoft’s form, To unsigned) names a domain, not an identity: a message sealed for one identity of a tenant domain can be replayed to another identity of the same tenant with an address on that domain. Only someone who already holds that tenant’s sealed mail can do it, and it moves mail inside one workspace only. ARC itself does not stop such a replay: RFC 8617 § 9.5 describes resending an intact, passing chain to other recipients (re-read 2026-10-18).

6.5 How each rule treats arc_rescued

arc_rescued is a new verdict value, not pass, so an integrator that requires pass for high-value automation keeps requiring it, and opts in where a rescued message is enough (clients already must handle unknown enum values, REST API › Basics).

Rulearc_rescued counts asWhy
Quarantine rules 3 and 3anot fail or unverified: not quarantined for authenticationThe purpose of the feature. Rules 4–6 apply as to any message
Spam score+0.05 (Pylota Identity choice; pass adds nothing, none adds 0.10)Authenticated by a third party, not at our boundary
known_sendernot through the own-domain rule (that rule needs pass); the contacts and receive-allow rules apply as usualThe own-domain rule trusts every address of a domain at once; it stays tied to a pass at our boundary
Inbound volume capsauthenticated: the per-sender key is the From address, not unauth:, and the message is outside the unauthenticated bucketThe From address is proven
Known recipient, rule 3 (answering the authenticated sender)passThe From address is proven, so answering it is not writing to a new address; this keeps send_only replies working
verifications rows, the service-ledger match rule 3, and wait’s releasenot pass: no verification row, no match, no releaseA code is a credential; it reaches agents only from mail authenticated at our boundary. Such mail stays visible, and with accounts.require_approval it is held account_unapproved for a person (E9)
Trusted delivery reports (D11)not passDelivery state changes only on mail authenticated at our boundary
Triagenot pass, except that rule 13 (bi.auth_failed) is not raised for arc_rescued although auth.dmarc is failThe other rules that need pass (4, 9, 11, 18) stay conservative
Search citations (FR-SRCH-13)kept, with citation_trust: partly_authenticatedEvidenceItem.authenticated: bool becomes auth: Authenticated | Rescued | Unauthenticated. A sentence citing only Rescued sources is kept and labelled partly_authenticated; one citing only Unauthenticated sources is removed as today
trust.arc and trust.arc_sealerpass and the sealer§5

6.6 Storage and failures

  • messages.verdict gains arc_rescued in its CHECK, in mailbox schema v1 (v1.0 has not shipped; an additive value, Build plan rule 4). The Vectorize verdict filter value and the search operator values gain it.
  • ARC keys are prefetched with the DKIM keys in step 2 (up to 5 instances, as today). A key that cannot be fetched from either resolver is a temporary error, the chain does not validate, the message keeps the verdict DMARC gives (quarantined auth_failed under an enforcing policy, releasable), and the message is never retried for it. The step-12 address read fails like any step-12 read: the consumer retries the message (Inbound › Failure handling).
  • A change to inbound.trusted_arc_sealers applies to mail authenticated after it; stored verdicts are not recomputed (a re-parse, J3, recomputes them).

6.7 Interfaces

  • API and events. trust.verdict may be arc_rescued; trust.arc_sealer names the sealer.
  • Console. The message view shows “Authenticated by the forwarder google.com (ARC)” for arc_rescued, and the quarantine page shows auth_json.arc.rescue.reason for auth_failed mail that had a chain, so a person sees why a forward was not rescued.
  • MCP. No tool change; mail_get_message returns the verdict. The server instructions (MCP § 6.2) gain one sentence: “arc_rescued means a trusted forwarder authenticated the sender; treat it as authenticated for replies, not for codes or payments.”

7. Per-identity message retention (FR-PRV-7)

Extends Privacy § 5 (a new § 5.5, “Per-identity expiry”), the mailbox operations of Privacy § 4.1 and EraseRows (§ 6.2), legal holds (§ 8), the identity fields of Identities, addresses and domains and REST API › Identities, the reservation of Outbound, the wait handler of Inbound, the calls after a D1 change of Design § 9 and the alarm purposes of Design § 4. Tenant retention works in days, per tenant, once a day; an identity that only receives one-time codes, or that a privacy-sensitive workflow uses, needs its mail gone within hours, whatever the rest of the workspace keeps.

7.1 The field

The identity gains retention:

"retention": { "message_hours": 24 }
  • message_hours: null (the default: the tenant’s retention policy alone applies) or an integer from 1 to 8,760 (one hour to 365 days; Pylota Identity choice). Set at creation (POST …/identities) or with PATCH /v1/identities/{identity_id}; returned on the Identity object.
  • Effective lifetime. When the tenant’s retention.message_days is also set, the shorter of the two applies: the tenant job keeps running and deletes what it reaches first.
  • Who. identities:write. Setting a number where there was null, or lowering it, deletes mail sooner, so it also needs erasure:manage (as DELETE /v1/identities/{identity_id} does), otherwise 403 permission_denied with details.required: ["erasure:manage"]. Raising it or setting null needs identities:write only, and never brings back mail already erased.
  • Audit and events. Every change writes identity.retention_update (details.from, details.to) and emits identity.updated with changed: ["retention"].
  • Refused: a value outside 1–8,760 or not an integer (400 invalid_request, path retention.message_hours); the system identity, whose retention is fixed at 30 days (Identities › The system identity) (400 invalid_request, details.reason = "system_identity", for the platform key that alone reaches it).

7.2 How the mailbox learns it

D1 keeps identities.message_hours. The handler writes, in the same D1 batch as the change, an rpc_intents row with the new op set_retention, and then sends MailboxRequest::SetRetention { message_hours: Option<u32>, version: i64 } (version = identities.updated_at), exactly as identity.updated reaches the mailbox (Design § 9); the repair cron re-sends a failed call. InitMailbox gains message_hours for an identity created with it. The mailbox stores meta.retention_message_hours and meta.retention_version, ignores a call whose version is older than the stored one, and sets alarm:expiry = now when the value is set or lowered (so existing messages are re-planned) or deletes alarm:expiry when it becomes null. A change therefore applies when the mailbox receives it: normally within a second of the PATCH, and after a failed call at the repair cron’s next attempt (every minute, backing off to 15 minutes).

7.3 What expires

A message expires when received_at + message_hours × 3,600,000 ≤ now (inbound and outbound, every status: received, quarantined, hidden, throttled, Screening’s screening, and every outbound status), except:

  • a message whose thread is under an active legal hold (Privacy § 8): it expires at the first expiry run after the hold ends or is removed (removing a hold sets alarm:expiry = now);
  • an outbound message still queued, or one with a transport claim (meta.claim:{msg}) younger than 5 minutes: it expires at the first run after it leaves queued and its claim has settled. An uncertain message is not exempt: reconciliation needs at most 30 minutes (Outbound), under the 1-hour minimum, and a person who wants to resolve one must do so before it expires.

What expiry deletes for each message is exactly what EraseRows deletes (FTS and trigram rows; the message row, cascading to deliveries, attachments, labels, refs, chunks and verifications; the outbox events that reference it; the thread’s counters, and the thread itself when it is left empty), its R2 objects (raw.eml, out/{msg}.eml, attachments and their extracted text) in BLOBS and, when configured, BACKUP, and its vectors (deleteByIds), with its ID written to erased_ids so that a late index job deletes what it writes (I10). The drafts of Drafts are mail content too: a draft expires message_hours after its last change (updated_at), except a draft under an active legal hold (its thread, source message or sent message in a held thread), a scheduled draft before its fire (Drafts § 13.1) and a sending one. For a draft, expiry deletes what the drafts’ retention purge deletes: the row, its idempotency and outbox rows, its attachment objects, and its draft_sync row, replaced by a delete one so the D1 index follows. The event log’s copies of the message’s events go too: EraseRows leaves the deleted IDs pending in erased_ids, and the mailbox’s log_erase purpose sends them to the tenant’s TenantEvents (Event feed § 11.3), so a message.received with its extracted text is not readable through the feed after the message expired. Expiry keeps, as tenant retention does: contacts, rate_windows, suppressions, event_index rows (IDs and types only, pruned after events_days) and audit rows. The two differences from EraseRows are the idempotency row of an outbound message (§7.6) and its delivery stub (§7.13).

7.4 The expiry alarm

The mailbox does the work itself, with its own alarm, through the same steps tenant retention runs (Privacy § 5.2, step 3) in mailbox/expiry.rs; no JobRunner and no D1 row is created per run.

 ingest / submit commit ──▶ alarm:expiry = min(alarm:expiry, received_at + H)
 draft write commit ──▶ alarm:expiry = min(alarm:expiry, updated_at + H)
 SetRetention set or lowered, hold removed, maintenance finds due rows ──▶ alarm:expiry = now
 alarm, purpose expiry (H = meta.retention_message_hours; nothing to do when it is absent or meta.erased):
   1 plan     ≤ 100 due rows, oldest first, skipping held threads, queued and claimed outbound;
              ≤ 100 due drafts, skipping held, scheduled and sending ones
   2 vectors  deleteByIds(vector IDs from chunks)                ─ error ─▶ back-off, stop
   3 objects  delete every R2 key of the batch, BLOBS then BACKUP ─ error ─▶ back-off, stop
   4 commit   one transaction: re-check each row is still due and not held, EraseRows(mode: Expiry),
              erased_ids (pending for the event log, alarm:log_erase = now), delivery stubs (§ 7.13),
              add the counts to meta['expiry:{YYYY-MM-DD}']
   5 re-arm   100 rows planned → alarm:expiry = now (the next slice);
              else the next due received_at + H or draft updated_at + H, but not before now + 60 s
 back-off: alarm:expiry = now + 30 s × 2^(n − 1), at most 5 minutes (meta.expiry_backoff, cleared by a success)

The plan:

SELECT m.rowid, m.id, m.direction, m.status, m.raw_r2_key FROM messages m
JOIN threads t ON t.seq = m.thread_seq
WHERE m.received_at <= ?1                                  -- ?1 = now − H × 3,600,000
  AND NOT (m.direction = 'outbound' AND m.status = 'queued')
  AND (t.hold_json IS NULL OR NOT <hold active at ?2>)     -- Privacy § 8: until null or later than now
ORDER BY m.received_at, m.rowid LIMIT 100;

with the R2 keys and vector IDs read as ErasurePlan reads them, and rows with a live claim:{msg} dropped in Rust. A slice stops after 20 seconds or 100 messages, as JobRunner slices do. Steps 2 and 3 run before the transaction because R2 and Vectorize calls never run inside one (Design § 4, rule 3), and an object or vector deleted for a row that the re-check in step 4 then keeps (a hold set in between) is the same loss an erasure racing a hold would have: so step 1 also skips threads whose hold changed in the last 60 seconds (hold_json.set_at), and the re-check stays the guarantee for the row itself. The daily alarm:maintenance sets alarm:expiry = now whenever due rows exist, so an alarm lost after Cloudflare’s six retries (Design § 4, rule 5) costs at most a day.

The same slice plans the due drafts, with the same hold test on each thread a draft touches:

SELECT d.rowid, d.id, d.attachments_json FROM drafts d
WHERE d.updated_at <= ?1                                   -- ?1 = now − H × 3,600,000
  AND d.status NOT IN ('scheduled', 'sending')
  AND NOT EXISTS (SELECT 1 FROM threads t
                  WHERE <hold active at ?2>
                    AND (t.seq = d.thread_seq
                         OR t.seq = (SELECT thread_seq FROM messages WHERE id = d.source_message_id)
                         OR t.seq = (SELECT thread_seq FROM messages WHERE id = d.message_id)))
ORDER BY d.updated_at, d.rowid LIMIT 100;

Step 3 deletes the drafts’ attachment objects with the messages’ keys, and step 4 re-checks each draft (still due, not held, not scheduled or sending) and deletes it in the same transaction, with the same 60-second rule for a hold that just changed.

7.5 Timing

A message is erased at most 15 minutes after it is due while R2, Vectorize and the mailbox answer, normally within 60 seconds (Pylota Identity target). retention_expiry_lag_ms (due time to commit) measures it; the retention_expiry_overdue:{identity_id} alert fires when the oldest due row of a mailbox is more than 1 hour overdue (ticket) or 24 hours (page) (§11).

7.6 A retried send never sends twice

EraseRows deletes a message’s idempotency row (Privacy § 6.2, step 4), so a client that retried a send with the same Idempotency-Key after the message expired would send it again, breaking U2. In mode: Expiry the row is kept, without content, until its own expires_at (30 days after the send):

UPDATE idempotency
SET fingerprint = ?2,                                      -- hex(HMAC-SHA256(PM_HASH_KEY, fingerprint))
    response_json = json_object('expired_at', ?3, 'message_id', message_id)
WHERE message_id = ?1;

The reservation (Outbound, step 1) reads such a stub by its expired_at key and compares HMAC-SHA256(PM_HASH_KEY, fingerprint of the new request) with the stored value: equal → 410 message_expired (retryable: false, details.message_id, details.expired_at), and nothing is sent; different → 409 idempotency_conflict. The fingerprint is keyed after expiry so that the kept row cannot be used to test a guess of the expired body without PM_HASH_KEY. An erasure request keeps deleting the row, as § 6.2 says: erasure removes even the fact that the message existed.

7.7 One-time codes

A code’s verifications row is deleted with its message, so a code is available for the shorter of 24 hours and message_hours, at least 1 hour. wait (at most 60 seconds per call) and the verification.received event, whose payload never carries the value, work unchanged inside that time. A wait that starts after the message expired matches nothing and times out; a quarantined code (otp_unsolicited, account_unapproved) expires on the same clock, so a person must release it before then.

7.8 What expiry cannot recall

Copies outside the mailbox are not recalled: webhook payloads already delivered (up to policy.webhook_text_bytes of extracted_text), copies the event feed’s consumers received (Event feed; the log’s own copies of the message’s events are deleted with the message, Event feed § 11.3), exports completed before the message expired (until their own 7-day expiry), the recipients’ copies of outbound mail, Cloudflare’s logs and the 30-day D1 Time Travel and Durable Object recovery windows (Privacy § 11). A delivery of an event whose outbox row expired before it succeeded becomes dead with event_unavailable and is never delivered. An export collecting while messages expire leaves out the messages whose rows or objects are gone, and counts them in jobs.result_json.expired_during_export. This is stated in the privacy guide as plainly as AgentMail states that copies made before its 24-hour expiry remain.

7.9 Receipts

Expiry runs too often for one erasure receipt per run, so its receipt is one audit row per identity per UTC day that expired anything: action = "retention.expire", target_type = "identity", and details with the day and the counts of the erasure receipt (messages_deleted, attachments_deleted, r2_objects_deleted, fts_rows_deleted, refs_deleted, vectors_deleted, events_deleted), plus drafts_deleted, held_skipped, first_expired_at and last_expired_at (FR-PRV-2). The mailbox accumulates them in meta['expiry:{YYYY-MM-DD}']; the daily maintenance alarm writes each completed day’s row to D1 with a deterministic ID (a ULID whose time is the day’s start and whose random part is the first 10 bytes of HMAC-SHA256(PM_HASH_KEY, "expire:" + identity_id + ":" + day)), INSERT OR IGNORE, and then deletes the key, so a repeated flush writes one row. When the identity is erased before a flush, the erasure’s own receipt covers what was left, and the pending day’s counts are lost with the mailbox.

7.10 Interactions

WithBehaviour
Erasure requests, tenant retentionBoth delete through EraseRows; a row deleted by one is absent for the other, and neither counts it twice (counts come from rows deleted in the committed transaction)
BillingStored bytes fall at the next hourly usage roll-up (Billing › Storage)
Threads and tokensA reply whose thread token names an expired thread is filed by its headers, and otherwise starts a new thread; it is never refused
SearchThe message leaves keyword search in the expiry transaction and semantic results once Vectorize applies the delete (seconds); a vector returned before that is dropped because its row is gone
Drafts (Drafts)A draft expires message_hours after its last change; scheduling a draft whose send_at is after that time is refused (400 invalid_request, details.reason = "beyond_retention")
NotificationsA pending new-mail count can include a message that expired before the email went; the email never names it
Suspended tenant, paused identityExpiry continues: it deletes, it never sends
Late bounces and complaintsApplied to the expired message’s delivery stub: the address is still suppressed and the outcome still counted (§7.13)
Event feedThe log’s copies of the expired message’s events, including its entries in label events, are deleted through the mailbox’s log_erase purpose (Event feed § 11.3)

7.11 Limits

LimitValue
message_hours1–8,760; null keeps the tenant policy alone
Erasure after due time≤ 15 minutes while dependencies answer (target); alert at 1 hour overdue
Expiry slice100 messages or 20 seconds; the next slice at once
Kept idempotency stubUntil the original key’s 30 days end
Kept delivery stub30 days after the send

7.12 Interfaces

  • Console. The inbox page shows “Messages are deleted N hours after they arrive” or the tenant’s rule. Owners and admins change it with a re-authenticated POST, and a value that deletes mail sooner needs the second, confirmed POST the policy page uses for such changes (Workspace policy § 6).
  • CLI. idvy identities create|update <identity> --message-hours <n>, and --keep-messages for null.
  • MCP. None: an agent never changes retention.

7.13 Late delivery events

ApplyDeliveryEvent finds an outbound message by provider_message_id (Outbound › Applying an event); when it is missing, the event is retried for 900 seconds and then acked as orphaned, and the consumer’s suppression (step 5) and RecordOutcome (step 6) use only what the mailbox answers. Hard bounces arrive within minutes, but late bounces and complaints arrive hours or days after the send. Without more, a 1-hour message_hours (which any key holding erasure:manage may set), or a 1-day tenant retention.message_days (which any key holding policy:write may set), would turn them into orphans: complainers and hard-bounced addresses never suppressed, the identity, tenant, domain and burst pauses (Outbound › Abuse auto-pause) blind to them, and metric_counts short. On Cloud that harms the shared Cloudflare account.

The stub. In mode: Expiry and mode: Retention (tenant retention, Privacy § 5.2 step 3), EraseRows turns each delivery of an outbound message that has a provider_message_id into one delivery_stubs row, in the same transaction, before the message row goes:

CREATE TABLE IF NOT EXISTS delivery_stubs (     -- mailbox schema v1; Parity additions § 7.13
  provider_message_id TEXT NOT NULL,
  address_hash        TEXT NOT NULL,            -- hex HMAC-SHA256(PM_HASH_KEY, normalised recipient)
  message_id          TEXT NOT NULL,            -- the expired msg_, for source_message_id of a suppression
  recipient_domain    TEXT NOT NULL,            -- lower-case A-label, for metric_counts
  domain_id           TEXT,                     -- the sending domain the delivery used (RecordOutcome)
  status              TEXT NOT NULL,            -- deliveries.status at expiry, then moved by later events
  first_reply         INTEGER NOT NULL,         -- deliveries.first_reply (RecordOutcome counted)
  provider_event_ids_json TEXT NOT NULL DEFAULT '[]',  -- the last 20, as on deliveries
  sent_at             INTEGER NOT NULL,         -- the message's received_at
  expires_at          INTEGER NOT NULL,         -- sent_at + 30 days; deleted by the daily maintenance
  PRIMARY KEY (provider_message_id, address_hash)
);

It holds no subject, body, display name or clear address. Applying an event to a stub. When step 1 of Applying an event finds no message and reconciliation finds none, the mailbox looks up delivery_stubs by provider_message_id and the keyed hash of the event’s recipient; with no row the answer stays NotFound. With a row it applies steps 3 and 4 to the stub (deduplication on provider_event_ids_json, the same transition table), writes metric_counts for bounced or complained with recipient_domain, emits no message.* event (the message is gone, and the event would carry the recipient’s address again), and answers Applied { outcome, suppress } or Duplicate { … } exactly as from the message, with the stub’s first_reply and domain_id. The consumer then suppresses the address (reason hard_bounce or complaint, source_message_id = the stub’s message_id, so suppression.created is still emitted by this mailbox) and calls RecordOutcome, so the abuse windows and pauses see the outcome.

Lifetime. 30 days after the send, the window in which providers report complaints and in which the idempotency stub also lives (§7.6). A message that expired without a provider_message_id (never submitted, or uncertain and never reconciled) leaves no stub: no event can name it. A stub identifies a recipient by keyed hash only, so counterparty erasure deletes every stub whose address_hash matches the target (both target forms of Privacy § 4.1 compare that hash), and identity and tenant erasure remove stubs with the mailbox; a message or thread erasure finds no expired message and leaves its stubs to their 30 days (Z81).

8. Webhook delivery headers (FR-WH-7)

Extends Webhooks › Signing (“Other headers”), Secrets, Delivering an attempt (step 4), Test deliveries, REST API › Webhooks, Security § 6.1 and § 7.2. Some receivers sit behind a gateway or a WAF rule that wants a static token before the request reaches the code that verifies the signature.

8.1 API

At creation, POST /v1/webhooks and POST /v1/tenants/{tenant_id}/webhooks accept:

{ "url": "https://api.example.com/webhooks/mail", "events": ["message.received"],
  "headers": { "X-Ingress-Token": "t0k_8f2k3m9q…", "Authorization": "Bearer 4d1e…" } }

Later, PATCH /v1/webhooks/{webhook_id}/headers (webhooks:manage):

{ "set": { "X-Ingress-Token": "t0k_new…" }, "remove": ["Authorization"] }

Both answer with the webhook endpoint, which gains header_names, the names in their stored casing, sorted case-insensitively. Values are write-only: no response, list, replay, log, export, audit row or idempotency record ever holds one.

{ "id": "whk_01JA9J…", "scope": "tenant", "url": "https://api.example.com/webhooks/mail",
  "events": ["message.received"], "header_names": ["X-Ingress-Token"], "enabled": true, "…": "…" }

8.2 Rules

  1. Permission. webhooks:manage, at the levels that may write the endpoint; an identity key gets 403 scope_denied, as for every webhook write. A partner key sets headers on its partner endpoints and on its tenants’ endpoints.

  2. Names: 1–64 characters matching ^[A-Za-z0-9][A-Za-z0-9-]*$, compared case-insensitively. A name that fails the pattern, or is one of the following, is refused with 400 header_not_allowed (details.reason = "webhook_header", details.name):

    • the forbidden request-header names of the Fetch standard (Accept-Charset, Accept-Encoding, Access-Control-Request-Headers, Access-Control-Request-Method, Connection, Content-Length, Cookie, Cookie2, Date, DNT, Expect, Host, Keep-Alive, Origin, Referer, Set-Cookie, TE, Trailer, Transfer-Encoding, Upgrade, Via) and every name starting Proxy- or Sec- (Fetch, forbidden request-header, last updated 6 October 2026, read 2026-10-17), and X-HTTP-Method, X-HTTP-Method-Override and X-Method-Override;
    • the headers the service sets: Content-Type, Content-Encoding, User-Agent and every name starting webhook- (Standard Webhooks);
    • names a receiver’s proxy may trust as the client’s address: Forwarded, X-Real-IP, True-Client-IP and every name starting X-Forwarded- or CF-, except CF-Access-Client-Id and CF-Access-Client-Secret (below);
    • every name starting X-Pylota-, reserved as on sends.

    Authorization is allowed: a static bearer token is the main use. CF-Access-Client-Id and CF-Access-Client-Secret are allowed: they carry a Cloudflare Access service token, the usual gate for a receiver behind Cloudflare, and say nothing about the client’s address (Service tokens, read 2026-10-18: “add the following to the headers of any HTTP request” names exactly these two; the single-header alternative must be configured per application).

  3. Values: 1–1,024 bytes of 0x20–0x7E, not starting or ending with a space (so no CR, LF or non-ASCII byte can split a header), otherwise 400 invalid_request (path headers.{name} or set.{name}).

  4. Counts: at most 10 headers and 4,096 bytes of values per endpoint, after the change, otherwise 422 webhook_header_limit_reached (details.limit, details.reason: count or bytes).

  5. PATCH …/headers needs at least one entry in set or remove (400 invalid_request); a name in both, in any casing, or twice in set in different casings, is 400 invalid_request; removing a name that is not set changes nothing. set replaces a value atomically: there is no overlap, so a receiver that rotates its token accepts the old and the new for the switch.

  6. A URL change to another host removes every header in the same update (and the audit row lists the removed names), so a token meant for one receiver is never sent to a host someone else chose; a change of path on the same host keeps them.

  7. Audit. Every change writes webhook.headers_update with the names set and removed, never values.

8.3 Delivery and storage

  • On every attempt: first, retries, replays, released held deliveries and POST …/test. Custom headers are added first and the service’s own headers last, so none can be overridden. They are not signed: Standard Webhooks signs {webhook-id}.{webhook-timestamp}.{body} only, so a header is an extra gate in front of the receiver, never a replacement for verifying the signature (Webhook events).

  • Storage. One sealed value per endpoint, so a change is one compare-and-swap statement:

    ALTER TABLE webhook_endpoints ADD COLUMN headers_sealed TEXT;                 -- pm1 envelope of the JSON map, or NULL
    ALTER TABLE webhook_endpoints ADD COLUMN header_names_json TEXT NOT NULL DEFAULT '[]';
    ALTER TABLE webhook_endpoints ADD COLUMN headers_version INTEGER NOT NULL DEFAULT 0;
    -- PATCH …/headers: read headers_sealed and headers_version, unseal, apply set and remove, check the rules,
    -- seal, then
    UPDATE webhook_endpoints SET headers_sealed = ?2, header_names_json = ?3,
           headers_version = headers_version + 1, updated_at = ?4
    WHERE id = ?1 AND headers_version = ?5;
    

    When the update changes no row, another change won: the handler reads again and retries, up to 3 times, then answers 409 request_in_progress (retryable). The value is sealed with AES-256-GCM under PM_MASTER_KEY in the envelope of Security § 7.2, associated data pm1|webhook_endpoints|headers_sealed|{endpoint_id}, and has an entry in crates/core/src/sealed.rs, so the master-key rotation re-seals and counts it.

  • Use. Unsealed per delivery and cached in the isolate for at most 60 seconds, keyed by endpoint ID and a hash of headers_sealed, as the signing secret is. A failure to unseal records the attempt as failed with secret_unavailable and alerts, as for the secret.

  • Idempotency. The fingerprint of a create that carries headers is computed with each value replaced by hex(HMAC-SHA256(PM_HASH_KEY, value)), so idempotency_records never holds a plain hash of a token that may be short enough to guess. PATCH is not recorded (only POST is).

8.4 Limits

LimitValueSource
Headers per endpoint10Pylota Identity (as AgentMail’s limit is not documented, the number is ours)
Name1–64 charactersPylota Identity
Value1–1,024 bytes; 4,096 bytes for all values togetherPylota Identity

8.5 Privacy and interfaces

  • Privacy. A value is a credential of the receiver, not personal data, and is deleted with its endpoint: by DELETE /v1/webhooks/{id}, partner deletion and tenant erasure, which already delete the rows.
  • Console. The webhooks page shows the names; owners and admins add a header (a write-only input) or remove one with a POST.
  • CLI. idvy webhooks create … --header 'Name: value', repeatable, and idvy webhooks headers <webhook-id> [--set 'Name: value']… [--remove <name>]…; a value can be read from standard input (--set-stdin <name>) so it stays out of the shell history.

9. Zone-file export (FR-DOM-15)

Extends REST API › GET /v1/domains/{domain_id}/records, Identities and domains (“Records (FR-DOM-3)”) and Domains on any DNS host § 4.1. Many DNS hosts import a zone file, which saves the customer copying five records by hand.

9.1 Route

GET /v1/domains/{domain_id}/records?format=bind (domains:read, every level that may read the domain). format is json (the default, today’s answer) or bind; any other value is 400 invalid_request (path format). The bind form is computed from the same provider reads and DNS checks as the JSON form, in the same handler, and fails the same way (FR-DOM-3): it is a rendering of that answer, never a template.

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="mail.acmecarhire.example.zone"
; Pylota Identity DNS records for mail.acmecarhire.example (dom_01JA9G6M2WW7X2M5N6P8R0T1YR), method dns_records.
; Read from the provider APIs at 2026-10-17T10:05:00Z. Add these records to the zone of acmecarhire.example.
; Each line ends with the record's purpose, whether it is required, and the last DNS check.
$ORIGIN acmecarhire.example.
$TTL 3600
_pylota-identity.mail                  IN TXT   "pm-verify=8f2k3m9q" ; ownership, required, ok
mail                               IN MX    10 inbound-smtp.eu-west-2.amazonaws.com. ; mx, required, missing
x7k2…._domainkey.mail              IN CNAME x7k2….dkim.eu-west-2.amazonses.com. ; dkim, required, ok
pm-bounce.mail                     IN MX    10 feedback-smtp.eu-west-2.amazonses.com. ; return_path, required, ok
pm-bounce.mail                     IN TXT   "v=spf1 include:amazonses.com ~all" ; spf, required, ok
; Suggested, not required: remove the leading "; " to publish it.
; _dmarc.mail                      IN TXT   "v=DMARC1; p=quarantine" ; dmarc, suggested, missing

9.2 Rules

core::zonefile::render(records: &DomainRecords, domain: &Domain) -> String (pure):

  1. Origin. $ORIGIN is the registrable domain (Public Suffix List) with a trailing dot, and each owner name is the record’s host, which is relative to that same registrable domain (N17); @ when host is the registrable domain itself. RFC 1035 § 5 appends the origin to a name without a trailing dot (RFC 1035, read 2026-10-17).
  2. TTL. $TTL 3600 (RFC 2308 § 4 defines the directive for records without their own TTL, RFC 2308, read 2026-10-17). One hour is a Pylota Identity choice; the records carry no TTL of their own, and a DNS host may override it.
  3. Class and targets. Every record is written with IN. MX, CNAME and NS targets are absolute, with a trailing dot; MX keeps its preference.
  4. TXT. The value is split into character-strings of at most 255 octets (RFC 1035 § 3.3), never inside an escape, each in double quotes, with " and \ escaped by \ and any byte outside 0x20–0x7E written as \DDD (RFC 1035 § 5.1). A DKIM key longer than 255 bytes becomes several strings on one line.
  5. Not records. A record with required: false is written commented out, under one line saying it is suggested. The ns records of a nameservers domain are set at the registrar, not in a zone, so they are written as comments under “Set these nameservers at your registrar”; the ns records of a delegated_subdomain domain belong in the parent zone and are written as records. A record with status: "unexpected" (an extra record that conflicts, such as a second SPF record) is one to remove, never to add: it is written as a comment under “Remove these records”, with its observed value.
  6. cloudflare_zone and nameservers domains, and the platform domain, whose records the deployment writes into a Cloudflare zone itself, get a first comment saying the records are already in that zone and are listed for reference.
  7. Status. Each line ends with ; {purpose}, {required|suggested}, {status} from the JSON form.
  8. ASCII only, \n line endings. The output is at most a few kilobytes.

9.3 Interfaces

  • CLI. idvy domains records <domain> --format bind > mail.acmecarhire.example.zone.
  • Console. The domain page gains “Download zone file”, a link to /console/domains/{dom}/records.zone, which calls the same service with the session’s permissions.
  • MCP. None.

Extends Errors (the envelope), Design § 2 (ApiError), REST API › Errors, MCP § 5, the CLI’s error output (CLI › Output) and Configuration › Variables.

10.1 The field

{
  "error": {
    "code": "idempotency_conflict",
    "message": "This Idempotency-Key was used with a different request body.",
    "retryable": false,
    "fix": "Use a new Idempotency-Key for a different message, or resend the original body.",
    "docs": "https://pylotamail.com/docs/reference/errors#code-idempotency_conflict",
    "request_id": "req_01J9Z4…",
    "details": { "original_message_id": "msg_01J9Z3…" }
  }
}
  • docs is in every error envelope the service sends: REST responses, MCP tool errors (whose text block is the envelope) and the CLI’s --json output. It is not in the empty 405 body of /mcp, which carries no envelope.
  • Built as {PM_DOCS_URL}/reference/errors#code-{code}, by the serialiser in crates/worker/src/errors.rs from ErrorCode::anchor() ("code-" followed by the code) and the docs base read once per isolate, so no call site builds a URL.
  • PM_DOCS_URL: the base URL of the published docs, default https://pylotamail.com/docs, where the landing-page Worker serves the mdBook output (docs/book.toml: site-url = "/docs/"; site/wrangler.jsonc routes pylotamail.com). It must be https, at most 200 bytes, without query or fragment; a trailing / is removed. idvy setup and idvy deploy refuse an invalid value; the Worker, which validates it at isolate start, uses the default instead and logs docs_url_invalid once per isolate. A self-hoster who publishes the docs elsewhere sets it.
  • The path is reference/errors, the extensionless form in which Workers static assets serve reference/errors.html with the default html_handling (“individual files (e.g. foo.html) will be served without a trailing slash”, Static Site Generation, read 2026-10-17). A host that serves only errors.html needs a rewrite of the extensionless path.

10.2 Anchors

Each code’s row in reference/errors.md begins its code cell with <a id="code-{code}"></a> (a cell with several codes, such as the 404 row, carries one anchor per code). The docs already use inline anchors of this kind (Observability § 8.3), which mdBook 0.5.4, the version .github/workflows/site.yml pins, renders as written.

  • cargo xtask docs-check fails when an ErrorCode variant has no anchor in errors.md, or an anchor names no variant, and checks that the built site/public/docs/reference/errors.html has an element with each id. It runs in the CI gate after mdbook build docs.
  • An anchor is never removed. A code retired in a later version keeps its anchor in a “Retired codes” table, so a link in an old log still lands.

10.3 Interfaces

The CLI’s human output prints docs: <url> after fix. The SDK exposes ApiError::docs. The console’s error pages are its own and do not change.

11. Observability

New metrics (Observability § 3.2):

MetricKindLabelsEmitted by
messages_batch_totalcounterop (get, update), result (ok or the error code)fetch
messages_batch_idsobservationopfetch: IDs per request
label_events_totalcountersource (message, thread, batch)mailbox
list_decisions_totalcounterdirection, scope (identity, tenant), kindpm-inbound, fetch (send), pm-outbound
arc_rescue_totalcounterresult (rescued, off, chain, untrusted_sealer, from_unsigned, no_dmarc_pass, stale, no_binding), source (routing, ses)pm-inbound
retention_expired_totalcounterstore (messages, attachments, r2_objects, vectors, events, drafts)mailbox
retention_expiry_lag_msobservation–mailbox: due time → commit
retention_expiry_errors_totalcounterstep (vectors, objects, commit)mailbox
webhook_header_updates_totalcounterresultfetch
zone_exports_totalcountermethodfetch

New alerts (Observability § 5.3):

AlertClassConditionSeverityRunbook
retention_expiry_overdue:{identity_id}BThe oldest due message of a mailbox with retention.message_hours is more than 1 hour past due, reported by its expiry run or its daily maintenanceticket; page at 24 hoursErasure failure (read retention_expiry_errors_total{step}; an R2 or Vectorize outage clears itself)
arc_rescue_refused_spikeAarc_rescue_total{result=no_binding|stale} > 50 in 1 hour: someone may be replaying sealed mailticketAbusive identity

Logs never carry a label name in clear for label_events_total (labels can be agent-written text), a webhook header value, or an ARC header; they carry the IDs, the arc.rescue.reason and the counts.

12. Pylota agentic OS

Pylota reaches Pylota Identity Cloud as a partner (FR-KEY-4) with its partner key K1, a tenant key K2 per operator and identity keys K3 per purpose, as its integration spec (§ 6) defines. What each addition gives it:

AdditionPylota agents and servicesKey and permissionsWhat Pylota storesHow failures surface
Batch labels and label eventsThe inbound worker, the operator coordinator and the specialists that share an operator’s bookings, inquiry, maintenance and compliance inboxes: the worker labels new mail by route (route:maintenance), a specialist claims a message with require_absent: ["claimed"] before it answers, and an escalation adds needs-human, which Pylota shows in the operator’s appK3 identity keys do not hold messages:write, and must not: it also allows resolve, which no Pylota agent may call (spec § 8.3). Label writes therefore go through an API capability route with K2, which accepts only labels with Pylota’s prefixes (route:, claimed, claimed-by-, needs-human) and calls batch-update; events reach the partner endpoint with K1The claim result per message (updated or conflicts) on the agent’s turn record; nothing about labels in Postgres beyond what the inbox screens already showA conflicts result means another specialist owns the message, and the turn stops for that message; 400 label_limit is a bug and pages ops
Identity-scope listsfleet-acquisition sends seller outreach from the operator’s bookings identity (spec § 20.2, row 42 of § 7.7)K2 with suppressions:manage, through allowRecipientmail_send_allow_entries gains the identity ID422 list_limit_reached pages ops (an operator with 10,000 approved recipients on one identity)
Ephemeral retentionThe browser agent’s sign-up identity (W14), which receives one-time codes from third-party services and nothing elseK1 or K2 (they hold erasure:manage) sets retention.message_hoursNothing new: the code is used within the agent’s turn410 message_expired on a retried send from that identity is final; a wait that times out after expiry makes the agent ask the service for a new code
Trusted ARCOperators on send_only whose Google Workspace or Microsoft 365 mailbox forwards to their identitiesNo key change; the platform default list appliestrust.verdict and arc_sealer on mail_inbound_messagesFewer auth_failed items in the Held list; a forward that is still refused shows auth_json.arc.rescue.reason in admin
Webhook headersThe partner endpoint {PYLOTA_IDENTITY_WEBHOOK_BASE_URL}/webhooks/pylota-identity (spec § 8.1)K1, webhooks:manageThe token sealed in mail_platform_secrets (row webhook_ingress_token)A rejected token at the WAF shows as failing deliveries in mail-webhook-health
Batch get, zone export, docs linksThe inbound job (fetching several truncated messages at once, spec § 8.7), the reconcile script (§ 8.5), the operator’s domain screen, and the error mapperK3 for reads, K1 or K2 for recordsNothing newdocs is logged with every mapped error

What Pylota’s integration spec must add (for the spec’s owner):

  1. Label coordination. A capability route for label writes with K2 and a label allow-list, never giving K3 messages:write; the claim convention (claimed, claimed-by-{specialist} with require_absent); the subscription of the partner endpoint to message.labels_changed by name (it is not in *, and the spec’s explicit list must add it); events.labels_changed: true set by K1 on each operator tenant at provisioning (spec § 4.3); and ignoring events whose actor.key_id is K2’s own key.
  2. Identity-scope send-allow entries. allowRecipient writes PUT /v1/identities/{identity_id}/lists/send/allow/{address} for the identity that sends (seller outreach: bookings), not the tenant route, so an approved seller does not become a known recipient of compliance; mail_send_allow_entries records identity_id; renter and seller erasure delete the identity-scope entries.
  3. The sign-up identity. When W14 is unblocked: one identity per operator (or one in a Pylota-owned tenant) for the browser agent, created with retention.message_hours (24 is a reasonable start: codes are used in minutes, and a day leaves time to investigate a failed sign-up), verification.received added to the endpoint’s list, and a decision on the sign-up ledger (OD13), which stays off for Pylota tenants today.
  4. ARC verdicts. Section 20.3’s and W4.3’s “verified” rule (“trust verdict pass and aligned”) must decide on arc_rescued: count it for replies and conversation binding, not for PCN, invoice or payment automations, nor as a seller’s word; and the mobile Held copy for an auth_failed forward that was not rescued.
  5. Ingress token (optional). If the WAF in front of the webhook route wants a static token: generate it, seal it in mail_platform_secrets, set it with PATCH /v1/webhooks/{webhook_id}/headers, rotate it with the secret-rotation job (W3.4), and keep the signature check, which stays mandatory.
  6. Batch reads. The inbound job may use batch-get for several truncated messages of one identity; each call by K1 writes a mail.read audit row, so the job uses K3.

13. Functional requirements

To be added to PRD § 6, each row at the end of the subsection named in brackets (links rewritten relative to prd.md when pasted: (#2-…) becomes (design/parity-additions.md#2-…)). Each takes the next free number of its family in this worktree’s prd.md; re-check the numbers against main after PR #5 has merged.

  • FR-IN-13 (§ 6.4) The service must read and update up to 100 messages of one identity in one request (batch-get, batch-update). An update must be atomic inside the identity’s mailbox, must offer a per-message label precondition (an atomic claim), and must report IDs the key cannot see together with missing ones, without saying which is which (§ 2).
  • FR-IN-14 (§ 6.4) The trust metadata of every inbound message must name the domain SPF checked and whether it aligned, each DKIM signature’s domain, selector, result and alignment, the domain and policy DMARC evaluated and which method aligned, and the ARC sealer when an ARC chain validated (§ 5).
  • FR-IN-15 (§ 6.4) A message that fails DMARC must get the verdict arc_rescued, and must not be quarantined for authentication, only when its ARC chain validates, its newest sealer is on the platform-only list inbound.trusted_arc_sealers, that sealer signed the From header and recorded dmarc=pass for the From domain, the seal is recent, and the sealer saw the message addressed to the receiving identity. Mail with that verdict must never release a verification code (§ 6).
  • FR-OUT-17 (§ 6.5) Allow and block lists must also be settable per identity. For each direction and address, an identity entry that matches must override the tenant’s entries of the same or a coarser granularity, but an identity entry for a domain must not override a tenant entry for the exact address; among the entries left, block must win over allow. No list entry may override a suppression, a test-mode rule, a daily cap, a sending pause or an authentication quarantine (§ 3).
  • FR-WH-6 (§ 6.10) A tenant may opt in to message.labels_changed. The event must be delivered only to endpoints that name it (never through *), must cover a whole request in one event per 100 messages, must never be emitted for state the service sets itself, and must never name a message the endpoint could not receive (§ 4).
  • FR-WH-7 (§ 6.10) A webhook endpoint may carry up to 10 static request headers. Their values must be write-only and sealed at rest; names that would change how the request is framed, routed or attributed must be refused; and a change of the endpoint’s host must remove them (§ 8).
  • FR-PRV-7 (§ 6.12) An identity may set retention.message_hours (1–8,760). Each of its messages, with its attachments, extracted text, index rows, vectors and drafts, must then be erased within 15 minutes of reaching that age, except under a legal hold; a retried send must never be sent again after its message expired; and each day’s expiries must be recorded in the audit log with counts per store (§ 7).
  • FR-DOM-15 (§ 6.3) GET /v1/domains/{domain_id}/records?format=bind must return the domain’s records as an RFC 1035 zone fragment built from the same provider-sourced records as the JSON form (§ 9).
  • FR-API-3 (§ 6.11) Every error envelope must carry docs, an absolute link to the code’s anchor on the deployment’s published errors page, and every error code must have that anchor (§ 10).

14. Edge cases

Section Z · Parity additions of the edge-case register. Every row is owned by the service (S) except where marked.

#CaseRequired behaviourOwnerTest
Z1batch-get or batch-update with a mix of IDs: visible, missing, of another identity or tenant, erased, and quarantined, screening, hidden or throttled while the key lacks quarantine:review200. Visible messages are returned or changed in request order; every other ID is in not_found, in request order, with nothing that tells the kinds apart; no 404 for the requestSit::messages::z1_batch_visibility
Z2The same batches with a key that holds quarantine:reviewquarantined, screening, hidden and throttled messages are found, returned and changed as GET and PATCH allow them; a change to them emits no label event (Z27)Sit::messages::z1_batch_visibility
Z3Malformed batch: 0 or 101 IDs, a malformed ID, a label that fails the pattern, no change field, a label in both labels_add and labels_remove, require_absent without a label change, extracted_text_bytes outside 0–16,384400 invalid_request with the path of the first problem; nothing read or changed. A repeated ID is processed once, at its first position, and listed onceScore::batch::z3_validate_request
Z4batch-get whose response would pass 1,048,576 bytesThe messages that fit are in data; the next found message and every later one are in remaining, truncated: true; the first found message is always returned; remaining never lists an ID of not_foundSit::messages::z4_batch_get_budget
Z5batch-update where one message would pass 64 labels; or where every message already matchesThe first: 400 invalid_request, details.reason = "label_limit", details.message_ids; no message changes, no event, no audit row. The second: 200 with every ID in unchanged, no event, no audit rowSit::messages::z5_batch_update_atomic
Z6Two agents claim the same message at once with require_absent: ["claimed"] and labels_add: ["claimed"]; a third claims it laterExactly one gets it in updated, the other in conflicts; the third gets conflicts; the message never carries two claims from one raceS+Iit::messages::z6_batch_claim_race
Z7batch-update with archived and read over messages of three threads, one already archivedTwo threads change and are counted; the third is not counted; unread_count is recomputed for each thread; a later visible inbound message unarchives its thread as usualSit::messages::z7_batch_archive_and_read
Z8batch-update repeated with the same Idempotency-Key; with another body; while a send with the same key is running; twice at once with the same key; a claim retried with its key after the worker died between the mailbox commit and the responseThe stored body with Idempotent-Replayed: true and no second event or audit row; 409 idempotency_conflict; 409 request_in_progress; the second waits and replays the first; the retry replays the committed result, so the claimed message is in updated, not conflictsSit::messages::z8_batch_idempotency
Z9batch-get by a platform or partner key; the audit write failsOne mail.read row for the request (target_type: "identity", details.messages); a failed write gives 503 unavailable and no mail. Tenant and identity keys write no rowSit::audit::z9_batch_mail_read_row
Z10A batch on a deleting identity, the system identity (non-platform key), a tenant being erased, a suspended partner, the read_only switch, a frozen deploymentAs the single-message routes: 404 identity_not_found for the first three, 403 partner_suspended; under read_only, 503 unavailable (details.reason = "read_only") for both routes from non-platform keys, because both are POST (as search is); 503 unavailable for both while frozenSit::messages::z10_batch_states
Z11MCP mail_update_labels with message_ids: also with message_id or thread_id; with require_absent and no message_ids; with 101 IDsTwo or none of the three → invalid_request naming the path; require_absent alone → invalid_request; 101 → invalid_request; a valid call returns the batch-update response objectSit::mcp::z11_update_labels_batch
Z12idvy messages label with 250 IDsThree requests of 100, 100 and 50, and a notice that the change is atomic per request only; exit code 0 only when all three succeedScli::messages::z12_label_many_chunks
Z13Identity receive-block and tenant receive-allow for the same sender (and the reverse)Identity block: the identity’s copy is stored hidden (blocked_sender) while another identity of the tenant receives it. Identity allow over a tenant block: the identity’s copy is not hidden, skips rules 4a and 6, and is still quarantined when authentication fails (rule 3)Score::lists::z13_precedence, it::lists::z13_receive_scope
Z14One scope holds an allow for jo@example.net and a block for @example.net; the tenant blocks jo@example.net while the identity allows @example.net; the identity allows jo@example.net while the tenant blocks @example.netBlock wins inside the scope, for both directions. The tenant’s address block is not overridden by the identity’s domain allow: Jo’s mail to the identity is hidden (blocked_sender) and its sends to Jo are suppressed (policy: send_block). The identity’s address allow overrides the tenant’s domain block for Jo onlyScore::lists::z13_precedence
Z15An identity-scope send-allow entry for an address the identity has never written to; another identity of the tenant sends to it tooThe first identity’s send is delivered (the address is known to it); the second’s delivery is suppressed with policy: unknown_recipientS+Iit::lists::z15_send_allow_per_identity
Z16An identity-scope send-block for an address that is a known contact, the authenticated sender being answered, and on the tenant’s send-allow list; with policy.send_allowlist_onlysuppressed with policy: send_block (identity) in each case; a dry run reports reason: "send_block" with scope: "identity"; with send_allowlist_only, an identity allow passes and a tenant allow overridden by an identity block does notSit::lists::z16_send_block_scope
Z17An allow entry, of either scope, for a suppressed address, a non-simulator address in a test tenant, an identity over its daily cap, a paused tenant, or a sender whose DMARC failsThe suppression, 403 test_mode_recipient, 429 daily_cap_reached, 409 sending_paused and quarantine rule 3 apply exactly as without the entrySit::lists::z17_allow_never_overrides
Z18Identity list routes with an identity key; with a key of another tenant or partner; on the system identity; the tenant routes after identity entries exist403 permission_denied (details.required: ["suppressions:manage"]); 404 identity_not_found; 404 for non-platform keys and 400 invalid_request (system_identity) for a platform key; tenant routes list and delete tenant entries onlySit::lists::z18_scope_matrix
Z19The 10,001st entry of one identity; the 50,001st of a tenant; two requests racing for the last place; a note update of an existing entry at the limit422 list_limit_reached with details.scope identity, tenant or total; exactly one racer succeeds; the note update succeedsSit::lists::z19_limits
Z20An identity send-block written after a send was accepted and before transportThe recipient’s delivery becomes suppressed (policy: send_block (identity)) at composition; the others go outSit::lists::z20_block_after_submit
Z21A receive entry written while a message is between consumer step 12 and the mailbox commitThe message is decided on the lists read at step 12; the next message uses the new entrySit::lists::z21_inbound_race
Z22Identity erasure, identity deletion, tenant erasure and counterparty erasure with list entries in both scopesIdentity erasure and deletion delete the identity’s entries and count them in list_entries_deleted; tenant erasure deletes every entry; counterparty erasure changes noneSit::erasure::z22_list_entries
Z23Quarantine rule 4a with lists: an identity receive-allow for a service; a tenant allow overridden by an identity blockThe first is exempt from account_unapproved; the second is stored hidden (blocked_sender, rule 1 first)Sit::lists::z23_rule_4a_scope
Z24Label changes while events.labels_changed is false (the default); the field turned off while events are still in the outboxNo outbox row, no event_index row and no feed entry; events already in the outbox are delivered, later changes emit noneSit::label_events::z24_off_by_default
Z25events.labels_changed: true, with one endpoint subscribed to *, one naming the type, and a replay to the * endpoint; a key without messages:read creating an endpoint that names the typeOnly the naming endpoint receives it; replay never sends it to *; 403 permission_denied (details.required: ["messages:read"])Sit::label_events::z25_opt_in_delivery
Z26A batch-update that changes 100 messages; a thread PATCH that changes 250 visible messagesOne event listing 100 messages; three events with the same request_id, part 1–3 and parts: 3, oldest messages firstSit::label_events::z26_batching
Z27A key with quarantine:review changes labels of a quarantined message, alone and together with a visible oneAlone: no event. Together: one event naming only the visible messageSit::label_events::z27_hidden_left_out
Z28Changes of read state or archive only; a no-op; a require_absent conflict; labels given at send time or carried from a draft; labels removed by erasure, expiry or deletion; a release; a re-parseNo message.labels_changed for any of themSit::label_events::z28_system_effects_silent
Z29A label event replayed, retried and read from the event feed; an agent that sees its own changeThe same evt_ ID everywhere, so receivers deduplicate; its sequence orders it after the message’s message.received; a consumer that ignores its own actor.key_id does not loopS+Iit::label_events::z29_replay_and_order
Z30Trust detail for a message with no trusted Authentication-Results (SPF unchecked); for the SES sourcespf_domain: null, spf_aligned: false; for SES, spf_domain is SES’s mail.source and spf_aligned follows aspfScore::auth::z30_trust_detail_fields
Z31A message with 12 DKIM signatures, some aligned, one from an IDN domaindkim_domains holds the first 10 in header order, each with its result and alignment; domains are A-labels in lower caseScore::auth::z30_trust_detail_fields
Z32A message stored before this change; a loopback message; the message.received and message.quarantined payloads; a search hitOld row: every field, arc_sealer: null, spf_aligned true only when dmarc_aligned_by is spf. Loopback: null domains, empty dkim_domains. Both events carry the fields; a search hit keeps its short trustSit::messages::z32_trust_detail_surfaces
Z33A forward sealed by google.com: chain valid, AAR dmarc=pass for the From domain, from and to in the newest AMS h=, To naming the identity’s send_only address, t= 2 minutes old, under p=rejectVerdict arc_rescued, stored received, evented as message.received, trust.arc_sealer: "google.com", auth_json.arc.rescue.result: "rescued"Score::auth::z33_arc_rescue_rules, it::ses::z33_forward_rescued
Z34The newest sealer is not trusted while an older set is; the newest seal’s d= is a subdomain of a trusted domain; AS and AMS d= differNo rescue (untrusted_sealer); quarantined auth_failed under an enforcing policyScore::auth::z33_arc_rescue_rules
Z35A chain whose newest seal has cv=fail; a gap in instances; 51 sets; a newest AMS that does not verify; a seal key neither resolver returnsNo rescue (chain); the verdict DMARC gives; the message is not retried for the DNS failureScore::auth::z33_arc_rescue_rules, conf::arc::z35_chain_corpus
Z36The newest AAR has dmarc=pass for another domain, dmarc=bestguesspass, dmarc=none, or no dmarc resultNo rescue (no_dmarc_pass)Score::auth::z33_arc_rescue_rules
Z37The newest AMS does not sign FromNo rescue (from_unsigned)Score::auth::z33_arc_rescue_rules
Z38The newest seal’s t= is 73 hours before receipt, or 20 minutes after; no t= and an unsigned Date; no t= and a Date 5 minutes old that the newest AMS signsNo rescue (stale) in the first three; rescue in the lastScore::auth::z33_arc_rescue_rules
Z39Someone else’s Gmail-sealed message replayed to the identity (To, signed, names another address); a Microsoft-sealed message (To unsigned) whose AAR smtp.rcpttodomain is the identity’s send_only domain; one whose smtp.rcpttodomain is unrelated; one whose smtp.rcpttodomain is the platform domain, on which the identity has an address; an exact replay of a rescued messageNo rescue (no_binding); rescue; no rescue (no_binding); no rescue (no_binding: the platform domain never binds); the replay is deduplicated (B3, B14)Score::auth::z33_arc_rescue_rules, it::inbound::z39_replay_not_rescued
Z40inbound.trusted_arc_sealers set to []; written by a partner key or a workspace writer; containing co.uk, an IP literal or 21 entriesNo rescue (off); 403 scope_denied (details.field, and not_writable for a workspace writer); 400 invalid_requestSit::policy::z40_trusted_sealers_field
Z41A rescued message that carries a verification code, with and without accounts.require_approval, and a wait(kind=verification) for its domainNo verifications row and no verification.received; with the ledger gate it is held account_unapproved; wait returns the message with verification: nullSit::inbound::z41_rescued_codes_withheld
Z42A reply to the sender of a rescued message under require_known_recipient; a rescued message from the tenant’s own domain; the inbound volume capsThe reply is delivered (rule 3); known_sender is not set by the own-domain rule; the per-sender cap is keyed by the From address and the unauthenticated bucket is not charged; the spam score has +0.05Sit::inbound::z42_rescued_consumers, core::trust::z42_rescued_known_sender
Z43An agentic answer whose sentence cites only rescued mail; triage of a rescued messageThe sentence is kept with citation_trust: partly_authenticated; triage rule 13 (auth_failed) is not raised, and rules 4, 9, 11 and 18 treat it as not passScore::citations::z43_rescued_partly_authenticated, core::triage::z43_rescued_rules
Z44Several From addresses with a trusted chain; p=none failing with a trusted chain; the unverified case (no trusted authserv) with a trusted chainCapped at unaligned, no rescue; arc_rescued instead of unaligned; arc_rescued instead of unverifiedScore::auth::z33_arc_rescue_rules
Z45A DMARC-failing forward sealed by google.com arriving through Cloudflare Email Routing (the platform domain) under p=rejectWhatever Cloudflare does is recorded as the spike result in § 6.1; when it delivers the message, the rule rescues it; when it refuses it, nothing reaches the Worker and the forwarder gets the refusalSlive::arc::cloudflare_forward_behaviour
Z46The step-12 read of the identity’s addresses fails for a rescue candidateThe consumer retries the message (retry(30 s)); it is never stored with a verdict guessed without the binding checkSit::inbound::z46_binding_read_retry
Z47An identity with retention.message_hours: 1 receives and sends mailEach message is erased within 15 minutes after it is an hour old: its row, FTS and trigram rows, refs, labels, attachments, verifications, outbox events, R2 objects in BLOBS and BACKUP, and vectors; keyword and semantic probes find nothing; quarantined, hidden, throttled and screening messages expire on the same clockSit::retention::z47_expiry_erases_all_stores
Z48A held thread with due messages; the hold is removed, or its until passes; a hold set seconds before a sliceHeld messages stay; they expire at the first run after the hold ends; a thread whose hold changed in the last 60 seconds is skipped, and the in-transaction re-check keeps any held rowSit::retention::z48_hold_respected
Z49Due outbound messages that are queued, that have a live transport claim, or that are uncertainThe first two are skipped and expire at the first run after they settle; the uncertain one expires when due (its reconciliation, at most 30 minutes, ends inside the 1-hour minimum)Sit::retention::z49_outbound_in_flight
Z50message_hours lowered from 72 to 1; raised from 1 to 72; set to null; the tenant’s message_days shorter than message_hoursOlder messages are erased at the next run; raising brings nothing back; null stops expiry; the tenant job deletes what it reaches firstSit::retention::z50_change_value
Z51Setting or lowering message_hours without erasure:manage; raising it or null with identities:write only; 0, 8,761 or 1.5; the system identity403 permission_denied (details.required: ["erasure:manage"]); accepted; 400 invalid_request (path retention.message_hours); 400 invalid_request (system_identity). Each accepted change writes identity.retention_update and emits identity.updated with changed: ["retention"]Sit::identities::z51_retention_field_rules
Z52A one-time code on an identity with message_hours: 1: wait within the hour; wait after the message expiredThe code is released; after expiry wait matches nothing and times out, and no verification row remainsS+Iit::retention::z52_codes_within_window
Z53A send retried with the same Idempotency-Key and body after its message expired; with another body; after an erasure request erased it410 message_expired (details.message_id, details.expired_at) and nothing is sent; 409 idempotency_conflict; the erasure deleted the row, as Privacy § 6.2 says. The kept stub holds a keyed fingerprint and no subject or recipientSit::retention::z53_expired_send_never_resent
Z54A webhook delivery still retrying when its message expires; an event delivered before; a replay of the eventThe retrying delivery ends dead with event_unavailable; the delivered copy is the receiver’s; the replay gets event_unavailableS+Iit::retention::z54_events_after_expiry
Z55An export completed before the messages expired; an export collecting while they expireThe completed ZIP stays until its 7-day expiry; the running export leaves out the gone messages and counts them in expired_during_exportSit::retention::z55_exports
Z56Vectorize or R2 fails during an expiry slice; failures go on for more than an hourThe batch’s rows are kept, the alarm backs off (30 s doubling, at most 5 minutes); retention_expiry_errors_total{step} counts; retention_expiry_overdue raises a ticket at 1 hour and pages at 24 hoursSit::retention::z56_dependency_failure
Z57The expiry alarm fails Cloudflare’s six retriesThe daily maintenance alarm sees due rows and re-arms expirySit::retention::z57_alarm_recovered
Z58The set_retention call fails after the PATCH; two PATCHes seconds apart; a call arriving after a newer oneThe repair cron delivers it; the mailbox ends with the newest value; the older version is ignoredSit::intents::z58_set_retention_retried
Z59A day with expiries; the flush repeated; the identity erased before the flushOne retention.expire audit row per identity and UTC day with the counts; a repeated flush writes nothing more; an erased identity’s pending day has no row and its erasure receipt counts what was leftSit::retention::z59_daily_receipt
Z60An erasure request or the tenant retention job running at the same time as expiryNo error and no row counted twice; the receipts count only what each deletedSit::retention::z60_concurrent_erasure
Z61Drafts of an identity with message_hours: 24; a draft scheduled to send after its expiry; a draft in a held thread, a scheduled draft and a sending one when they fall dueA draft is erased 24 hours after its last change by the expiry alarm, with its attachment objects; the schedule is refused with 400 invalid_request (beyond_retention); the held draft is kept until the hold ends, the scheduled one until its fire, and the sending one until its send endsSit::drafts::z61_drafts_expire
Z62A reply whose thread token names an expired threadFiled by its headers when they match a stored message, otherwise a new thread; never refusedSit::retention::z62_reply_to_expired_thread
Z63Storage after expiry; expiry on a paused identity and a suspended tenantStored bytes fall at the next hourly roll-up; expiry continues in both statesSit::retention::z63_storage_and_states
Z64Creating a webhook with headers; reading, listing and replaying the create; the audit row and logsheader_names only; no response, idempotency record, audit row or log line holds a value; the create’s fingerprint uses HMAC-SHA256(PM_HASH_KEY, value)Sit::webhooks::z64_headers_write_only
Z65PATCH …/headers with set and remove; a name in both in different casings; a name twice in set; an empty body; removing a name that is not set; two concurrent PATCHesApplied together; 400 invalid_request; 400; 400; 200 with nothing changed; both apply one after the other through the compare-and-swap, and after 3 lost attempts 409 request_in_progressSit::webhooks::z65_headers_patch
Z66Header names Content-Type, Host, webhook-signature, Proxy-Authorization, Sec-Fetch-Mode, Cookie, X-Forwarded-For, CF-Connecting-IP, X-Pylota-Trace, X-HTTP-Method-Override, Bad Name; and Authorization, CF-Access-Client-Id, cf-access-client-secret400 header_not_allowed (details.reason = "webhook_header", details.name) for each; Authorization and the two Cloudflare Access names, in any casing, are acceptedScore::webhook_headers::z66_name_rules
Z67A value with CR or LF, a non-ASCII byte, a leading space, 1,025 bytes; values totalling 4,097 bytes; an 11th header400 invalid_request for the first four; 422 webhook_header_limit_reached with reason bytes and countScore::webhook_headers::z66_name_rules, it::webhooks::z65_headers_patch
Z68Deliveries of an endpoint with headers: first attempt, retry, replay, a delivery released after a partner suspension, POST …/testEvery attempt carries the headers; Content-Type, User-Agent and the webhook-* headers are the service’s; the signature is computed as beforeSit::webhooks::z68_headers_on_every_attempt
Z69PATCH /v1/webhooks/{id} changes the URL to another host; to another path on the same hostThe headers are removed in the same update, and the audit row lists them; the path change keeps themSit::webhooks::z69_host_change_clears_headers
Z70headers_sealed cannot be unsealed; the master key is rotatedThe attempt fails with secret_unavailable and alerts; the rotation re-seals the column and counts itSit::webhooks::z70_headers_sealed, it::secrets::master_key_rotation
Z71An identity key changes headers; reads the endpoint with webhooks:read; a partner key reaches another partner’s endpoint403 scope_denied; header_names visible, values never; 404 webhook_not_foundSit::webhooks::z71_headers_scope
Z72?format=bind for a dns_records subdomain whose registrable domain differs from the domain$ORIGIN is the registrable domain with a trailing dot, $TTL 3600, owner names are the records’ host, @ for the registrable domain itself, IN on every record, absolute targets with a trailing dotScore::zonefile::z72_render, conf::zonefile::z72_parses
Z73A DKIM TXT value of 410 bytes; a value with ", \ and a byte outside 0x20–0x7ETwo quoted strings of at most 255 octets, never split inside an escape; \", \\ and \DDDScore::zonefile::z72_render
Z74Suggested records; an unexpected record (a second SPF record); the ns records of a nameservers domain and of a delegated_subdomain domain; a cloudflare_zone domainSuggested records commented out; the unexpected record as a comment under “Remove these records”, never as a record; nameservers NS as comments under the registrar heading; delegated_subdomain NS as records; a first comment saying a Cloudflare zone already holds the recordsScore::zonefile::z74_methods
Z75format=xml; the provider API failing; another tenant’s domain; the platform domain400 invalid_request (path format); the same answer as the JSON form gives; 404 domain_not_found; readable by every key with domains:read, with rule 6’s first comment (its records are in the deployment’s own zone)Sit::domains::z75_records_bind_route
Z76The bind output of each method parsed by an independent zone-file parserEvery record parses to the type, owner and data of the JSON formSconf::zonefile::z72_parses
Z77Any error from REST, from an MCP tool and from idvy --json; 404 route_not_found; the empty 405 of /mcpEach envelope carries docs = {PM_DOCS_URL}/reference/errors#code-{code}; route_not_found too; the /mcp 405 has no body and no docsSit::errors::z77_docs_in_every_envelope
Z78An ErrorCode without an anchor in errors.md; an anchor for no code; the built pagecargo xtask docs-check fails for the first two; every anchor is an element id in the built errors.htmlScore::errors::z78_every_code_has_anchor, live::docs::z78_anchor_resolves
Z79PM_DOCS_URL set to http://…, to a URL with a query, or with a trailing slashidvy setup and idvy deploy refuse the first two; the Worker uses the default and logs docs_url_invalid once per isolate; a trailing slash is removedScli::setup::z79_docs_url_validated, it::errors::z77_docs_in_every_envelope
Z80A message erased (any scope) or expired while a message.labels_changed outbox row lists it with two other messages; and while a row lists only itThe first row keeps the two other entries and is delivered without the erased one; the second row is deleted and counted in events_deleted; nothing of the erased message is delivered afterwardsSit::label_events::z80_erasure_trims_events
Z81A complaint arrives 2 hours after a send from an identity with message_hours: 1, after the message expired, and 2 days after a send from a tenant with retention.message_days: 1, after tenant retention removed it; a hard bounce the same way; the same event again; an outbound message that expired without a provider message ID; an event 31 days after the send; a counterparty erasure of the recipientApplyDeliveryEvent answers from the delivery stub: the address is suppressed (complaint, hard_bounce), RecordOutcome counts the outcome (not for a first reply) and metric_counts counts it, with no message.* event; the repeat is Duplicate; with no provider ID, or after 30 days, there is no stub and the event is orphaned as before; the erasure deletes the stubSit::retention::z81_late_delivery_events

15. Tests

TestProvesCovers
core::batch::z3_validate_requestThe batch body rules: counts, ID pattern, repeats collapsed at their first position, label patterns and counts, the change-field and overlap rules, require_absent and extracted_text_bytes bounds, each with its error path§2.3, Z3
it::messages::z1_batch_visibilitynot_found covers missing, erased, other-identity and invisible messages alike, in request order; review finds invisible messages; the response never distinguishes the kinds§2.3, Z1, Z2, NFR-SEC-1
it::messages::z4_batch_get_budgetThe 1 MiB budget, remaining, truncated, the first message always returned, extracted_text_bytes cuts at a character boundary with extracted_text_truncated, no text, html or headers§2.1, Z4
it::messages::z5_batch_update_atomicThe 64-label refusal changes nothing (rows, events, audit); a no-op batch is all unchanged with no event and no audit row; one transaction per batch§2.3, Z5
it::messages::z6_batch_claim_raceConcurrent claims give one updated and one conflicts; a later claim conflicts§2.2, §2.4, Z6
it::messages::z7_batch_archive_and_readThread archiving by message, the counts, unread_count, unarchiving by new mail§2.3, Z7, FR-IN-10
it::messages::z8_batch_idempotencyReplay, conflict and in-progress answers; a replay writes nothing; the record is in the mailbox idempotency table and commits with the change (fault injection after the commit: the retry replays and the claim reads updated); two concurrent requests with one key change once§2.4, Z8
it::audit::z9_batch_mail_read_rowOne mail.read row per platform or partner batch-get; 503 when it cannot be written; none for tenant and identity keys; one message.batch_update row per changing batch-update§2.3, Z9
it::messages::z10_batch_statesThe batch routes in each tenant, partner, identity and deployment state answer as the single routes do; both routes join it::security::cross_tenant_matrix§1, Z10
it::mcp::z11_update_labels_batchmail_update_labels with message_ids: the exactly-one rule, require_absent only with message_ids, the 100 limit, the response object; the input schema is still a plain object (it::mcp::input_schemas_plain_objects)§2.7, Z11
cli::messages::z12_label_many_chunksChunking into requests of 100, the notice, the exit code§2.7, Z12
core::lists::z13_precedencedecide: an identity entry overrides tenant entries of the same or a coarser granularity and never a tenant entry for the exact address; block over allow among the entries left, in each direction; the deciding entry’s scope; address and domain candidates as today§3.1, Z13, Z14
it::lists::z13_receive_scopeIdentity receive-block and receive-allow against tenant entries, for two identities of one tenant; rule 3 still applies§3.2, Z13
it::lists::z15_send_allow_per_identityAn identity send-allow makes an address known to that identity only§3.2, Z15, FR-OUT-13
it::lists::z16_send_block_scopeIdentity send-block over contacts, the reply rule and a tenant allow; the scope in smtp_response and in the dry run; send_allowlist_only with both scopes§3.2, Z16
it::lists::z17_allow_never_overridesSuppressions, test mode, caps, pauses and authentication quarantine apply despite allow entries of either scope§3.3, Z17
it::lists::z18_scope_matrixPermissions and scope of the identity routes, the system identity, and the tenant routes’ tenant-only reach; the routes join it::security::cross_tenant_matrix§3.4, Z18
it::lists::z19_limitsThe scope and tenant limits, the race for the last place, note updates at the limit§3.5, §3.7, Z19
it::lists::z20_block_after_submitComposition step 1 re-reads identity entries§3.5, Z20
it::lists::z21_inbound_raceThe step-12 read decides the message in flight (a fault hook holds the consumer between step 12 and Ingest)§3.5, Z21
it::erasure::z22_list_entriesIdentity, tenant and counterparty erasure on list entries, with list_entries_deleted in the receipts§3.8, Z22
it::lists::z23_rule_4a_scopeRule 4a’s exemption follows the effective receive decision§3.2, Z23
it::label_events::z24_off_by_defaultNo outbox, event_index or feed rows while the policy field is off; switching it off stops new events only§4.1, §4.3, Z24
it::label_events::z25_opt_in_delivery* excludes the type for fan-out and replay; naming it delivers; J29’s messages:read rule; it::webhooks::filters now asserts that * includes new types except those in OPT_IN_EVENT_TYPES§4.1, Z25
it::label_events::z26_batchingOne event per batch; thread changes split into parts with one request_id; the payload’s fields and its golden file§4.2, §4.3, Z26
it::label_events::z27_hidden_left_outInvisible messages never appear in the event§4.3, Z27
it::label_events::z28_system_effects_silentNo event for read state, archive, no-ops, conflicts, creation labels, erasure, expiry, release or re-parse§4.3, Z28
it::label_events::z29_replay_and_orderOne event ID across webhook, replay and feed; sequence ordering; idempotent replays emit nothing§4.3, §4.4, Z29
it::label_events::z80_erasure_trims_eventsEraseRows (erasure and expiry) removes the message from pending label events and deletes emptied rows§4.3, Z80, FR-PRV-3
core::auth::z30_trust_detail_fieldsThe seven fields from auth_json for routing and SES sources, SPF unchecked, 12 DKIM signatures, IDN domains§5.1, Z30, Z31
it::messages::z32_trust_detail_surfacesOld rows, loopback rows, the two event payloads, search hits§5.1, Z32
core::auth::z33_arc_rescue_rulesEvery condition of the rule and its reason, with recorded Gmail and Exchange Online header sets (the d=, s=, h= and AAR forms of § 6.1) and synthetic chains; multiple From, p=none and unverified§6.3, Z33–Z39, Z44
conf::arc::z35_chain_corpusARC chains that RFC 8617 § 5.2 fails (cv, gaps, 51 sets, broken AMS, missing key) all fail through mail-auth 0.13.3 and the prefetch cache§6.3, Z35
it::ses::z33_forward_rescuedA DMARC-failing, google.com-sealed forward through the SES source is stored received with arc_rescued and evented§6.3, Z33
it::inbound::z39_replay_not_rescuedA replayed sealed message without binding is quarantined; a Microsoft-form message (To unsigned) whose smtp.rcpttodomain is the platform domain is quarantined with no_binding although the identity has a platform-domain address; an exact replay of a rescued message is deduplicated§6.3, §6.4, Z39
it::policy::z40_trusted_sealers_fieldThe field’s class, validation and []§6.2, Z40
it::inbound::z41_rescued_codes_withheldNo verification row, event or release for rescued code mail; the ledger gate holds it§6.5, Z41
it::inbound::z42_rescued_consumersThe reply rule, the volume caps and the spam weight for arc_rescued§6.5, Z42
core::trust::z42_rescued_known_senderThe own-domain known_sender rule needs pass§6.5, Z42
core::citations::z43_rescued_partly_authenticatedRescued evidence keeps a sentence with partly_authenticated; Unauthenticated alone still removes it§6.5, Z43, FR-SRCH-13
core::triage::z43_rescued_rulesRule 13 is not raised for arc_rescued; rules 4, 9, 11 and 18 treat it as not pass§6.5, Z43
live::arc::cloudflare_forward_behaviourWhat Cloudflare Email Routing does with a DMARC-failing, google.com-sealed forward under p=reject (a real Google Workspace forwarding rule to the staging platform domain); the result is recorded in § 6.1§6.1, Z45
it::inbound::z46_binding_read_retryA failed binding read retries the message and stores nothing§6.6, Z46
it::retention::z47_expiry_erases_all_storesEvery store of a message is gone within one alarm of its due time (time-controlled harness), in BLOBS and BACKUP; keyword and semantic probes are empty; every inbound status expires§7.3, §7.4, Z47
it::retention::z48_hold_respectedHolds skip rows, release them after they end, and the 60-second rule and in-transaction re-check§7.3, §7.4, Z48, FR-PRV-4
it::retention::z49_outbound_in_flightqueued, claimed and uncertain outbound messages§7.3, Z49
it::retention::z50_change_valueLowering, raising, null, and the shorter of the identity and tenant rules§7.1, §7.2, Z50
it::identities::z51_retention_field_rulesPermissions, bounds, the system identity, the audit row and the event§7.1, Z51
it::retention::z52_codes_within_windowCodes inside and after the window§7.7, Z52
it::retention::z53_expired_send_never_resentThe stub, its keyed fingerprint, 410 message_expired, 409 for another body, erasure deleting the row§7.6, Z53, U2
it::retention::z54_events_after_expiryevent_unavailable for pending deliveries and replays§7.8, Z54
it::retention::z55_exportsCompleted exports kept; running exports leave out and count expired messages§7.8, Z55
it::retention::z56_dependency_failureBack-off, kept rows, the error counter and the overdue alert§7.4, §7.5, Z56
it::retention::z57_alarm_recoveredThe maintenance alarm re-arms expiry§7.4, Z57
it::intents::z58_set_retention_retriedThe set_retention intent, its repair, and version ordering§7.2, Z58
it::retention::z59_daily_receiptThe daily retention.expire row, its counts and its idempotent flush§7.9, Z59, FR-PRV-2
it::retention::z60_concurrent_erasureExpiry, erasure and tenant retention together, with exact receipts§7.10, Z60
it::drafts::z61_drafts_expireDraft expiry and the beyond_retention refusal (runs once M29 has landed)§7.10, Z61
it::retention::z62_reply_to_expired_threadThreading after expiry§7.10, Z62
it::retention::z63_storage_and_statesStorage roll-up after expiry; expiry while paused or suspended§7.10, Z63
it::retention::z81_late_delivery_eventsOn a 1-hour identity, and after a 1-day tenant retention run, a complaint and a hard bounce after the message is gone suppress the address, reach RecordOutcome (an abuse pause fires at its threshold) and metric_counts, and emit no message.* event; a repeat is Duplicate; no stub without a provider ID or after 30 days; the stub holds no clear address or content; counterparty erasure removes it§7.13, Z81, FR-PRV-7
it::webhooks::z64_headers_write_onlyValues never leave the seal; the keyed fingerprint§8.1, §8.3, Z64
it::webhooks::z65_headers_patchPATCH …/headers rules, the compare-and-swap, the limits§8.2, §8.3, Z65, Z67
core::webhook_headers::z66_name_rulesName and value rules, the full refused list, Authorization, CF-Access-Client-Id and CF-Access-Client-Secret allowed while every other CF- name is refused§8.2, Z66, Z67
it::webhooks::z68_headers_on_every_attemptHeaders on every kind of attempt, service headers last, signature unchanged§8.3, Z68
it::webhooks::z69_host_change_clears_headersHost change removes headers; path change keeps them§8.2, Z69
it::webhooks::z70_headers_sealedEnvelope and associated data of headers_sealed; unseal failure handling§8.3, Z70
it::secrets::master_key_rotation (exists, M17 Foundation)Gains the webhook_endpoints.headers_sealed case: the rotation re-seals the column, counts it, and deliveries keep their headers throughout§8.3, Z70
it::webhooks::z71_headers_scopeLevel and scope rules for headers§8.2, Z71
core::zonefile::z72_renderOrigin, TTL, names, targets, TXT splitting and escaping§9.2, Z72, Z73
conf::zonefile::z72_parsesThe output of each method parses with an independent RFC 1035 master-file parser (a native dev-dependency chosen at build time) and matches the JSON form§9.2, Z72, Z76
core::zonefile::z74_methodsSuggested and unexpected records, NS by method, the Cloudflare comment§9.2, Z74
it::domains::z75_records_bind_routeformat values, failures as the JSON form, scope, headers of the response§9.1, Z75
it::errors::z77_docs_in_every_envelopedocs in REST, MCP and CLI envelopes, the URL form, the fallback for an invalid PM_DOCS_URL§10.1, Z77, Z79
core::errors::z78_every_code_has_anchorEvery ErrorCode has exactly one code-… anchor in docs/src/reference/errors.md, and every anchor names a code (the cargo xtask docs-check source check)§10.2, Z78
live::docs::z78_anchor_resolvesOn staging, a docs URL from a real error loads and the page has the element§10.2, Z78
cli::setup::z79_docs_url_validatedidvy setup and idvy deploy refuse an invalid PM_DOCS_URL§10.1, Z79

16. Milestone

To be added to the Build plan after M36, in the build plan’s style (links rewritten relative to build-plan.md when pasted):

M37 · Parity additions (after M7 to M16, M21, M23 and M27)

Goal: the nine additions of this page, each wired end to end, with the register’s section Z green. The nine are independent of each other and can land as separate pull requests in any order, each with its own rows of section Z.

Tasks, in a workable order:

  1. Docs link (§10): docs, ErrorCode::anchor(), PM_DOCS_URL, the anchors in errors.md, cargo xtask docs-check. First, because every later error code needs its anchor.
  2. Trust detail (§5): spf.aligned, arc.{sealer, sealer_trusted, aar} in auth_json; the seven trust fields.
  3. Trusted ARC sealers (§6): the policy field, core::auth::arc_rescue, the step-12 binding read, the verdict value, each consumer of the §6.5 table; the live test on staging.
  4. Batch operations (§2): the two routes, BatchGet and BatchUpdate, the audit rows, MCP and CLI.
  5. Label events (§4), on top of 4: the policy field, OPT_IN_EVENT_TYPES, the outbox append in the three label-changing requests.
  6. Identity-scope lists (§3): the table change, core::lists::decide, the four routes, the inbound and outbound readers, erasure counts.
  7. Webhook headers (§8): the columns and sealed entry, create and PATCH …/headers, delivery, host-change clearing.
  8. Retention (§7): the identity field, the set_retention intent, mailbox/expiry.rs, the idempotency stub, the delivery stub (§7.13), the daily receipt, the alert.
  9. Zone export (§9): core::zonefile::render and the format parameter.

Files: as the page’s Code row. One migration, migrations/d1/00NN_parity_additions.sql only if 0001_init.sql has shipped to a production deployment when M37 lands; otherwise 0001_init.sql and mailbox schema v1 are edited in place (sender_lists, identities.message_hours, the three webhook_endpoints columns, the rpc_intents.op value and the messages.verdict value). Hooks in other milestones’ files, each reviewed by that file’s owner:

FileHook
mailbox/read.rs (M7)BatchGet, BatchUpdate, and the label-event append in UpdateMessage and UpdateThread
consumers/inbound.rs, mailbox/ingest.rs (M7)Identity-scope list rows at step 12; the ARC rescue in steps 7 and 12; arc_rescued in the trust signals, caps and verification rules
crates/core/src/auth.rs, trust.rs (M2, M7)arc_rescue, the trust detail fields, auth_json keys
handlers/wait.rs (M7), accounts gate (M27)arc_rescued is not pass for releases and the ledger match
handlers/send.rs, consumers/outbound.rs, mailbox/idempotency.rs (M9)Identity-scope send entries at step 6 and composition step 1; the expired stub in the reservation
consumers/delivery.rs, ApplyDeliveryEvent in the mailbox (M9)The delivery_stubs lookup after reconciliation, its transitions and metric_counts, and the answer with the stub’s first_reply and domain_id (§7.13)
webhooks/payloads.rs, consumers/webhooks.rs, handlers/webhooks.rs, webhooks/client.rs (M8)The labels_changed builder, OPT_IN_EVENT_TYPES, headers on delivery, PATCH …/headers, host-change clearing
search/citations.rs (M11), triage/rules.rs (M12)The Rescued evidence state; rule 13
handlers/domains.rs (M13, M23)format=bind
mailbox/erase.rs, jobs/erasure.rs (M14)EraseRows { mode: Expiry } and { mode: Retention } (delivery stubs only); list_entries_deleted; the identity-scope list rows of identity erasure
handlers/identities.rs, crons/intents.rs (M6)retention, the set_retention intent
crates/api-types/src/errors.rs (M3), crates/worker/src/errors.rs (M5)docs, ErrorCode::anchor(), PM_DOCS_URL
mcp/tools.rs (M15)mail_update_labels with message_ids and require_absent
crates/cli/src/commands/* (M16)The commands of the page
console/pages/* (M21)Inbox retention and lists, ARC wording, webhook header names, zone download
crates/core/src/sealed.rs (M17 Foundation)webhook_endpoints.headers_sealed, with its case in it::secrets::master_key_rotation
drafts (M29), event feed (M30)Draft expiry and beyond_retention (M29); feed entries of label events and of expired messages through the mailbox’s log_erase purpose (M30, R65 and R66). If M29 or M30 lands after M37, that milestone adds its hook and runs the test named for it (it::drafts::z61_drafts_expire, it::events::retention_and_expiry_reach_log, it::events::label_event_erasure)

Implements: FR-IN-13, FR-IN-14, FR-IN-15, FR-OUT-17, FR-WH-6, FR-WH-7, FR-PRV-7, FR-DOM-15, FR-API-3, and edge rows Z1–Z81.

Acceptance:

  • Every test of §15, by row: Z1–Z12 (batch), Z13–Z23 (lists), Z24–Z29 and Z80 (label events), Z30–Z32 (trust detail), Z33–Z46 (ARC), Z47–Z63 and Z81 (retention), Z64–Z71 (webhook headers), Z72–Z76 (zone export), Z77–Z79 (docs links).
  • The new routes (seven operations) and the changed ones join it::security::cross_tenant_matrix; sdk::coverage::every_operation passes with the new operations; it::mcp::input_schemas_plain_objects passes.
  • it::webhooks::filters asserts that * includes every type except message.labels_changed.
  • live::arc::cloudflare_forward_behaviour has run on staging and its result is recorded in §6.1 as a “Spike result” note, on the first staging candidate that carries M37 (Testing § 10); live::docs::z78_anchor_resolves runs in the same suite.
  • cargo xtask docs-check is in the CI gate and passes; mdbook build docs passes.
  • With every new setting at its default (events.labels_changed: false, no identity lists, retention.message_hours: null, no webhook headers), the M7, M8, M9 and M14 suites pass unchanged, except the trust golden files, which gain the seven fields, and it::webhooks::filters.

17. Compared with AgentMail (read 2026-10-17)

AgentMailPylota Identity
batch_update: one label change to up to 50 messages, atomic for found messages; unknown or invisible IDs skippedbatch-update of up to 100, atomic, labels, read state and thread archive in one request, IDs the key cannot see reported with missing ones; plus require_absent, an atomic claim AgentMail’s docs say labels cannot give (“label-based dedupe not atomic”)Exceed
batch-get returning metadata and a previewbatch-get of up to 100 with extracted_text capped per message and a 1 MiB budgetMatch
Lists at org, pod and inbox scope; the most specific scope checked firstTenant and identity scope, the most specific first; partners have no scope of their own, because a partner never owns mailMatch
reply lists: replies checked against reply lists onlyNo reply direction: receive-allow is an exemption, never an allow-only mode, so nothing blocks a reply that a reply list would have to let through (§3.6)Deliberately different
An allow list with one entry blocks every other address of its directionAllow-only stays the explicit send_allowlist_only switch; adding an entry never silently blocks everyone elseDeliberately different
Inbox events feed: label.added and label.removed, including system labels such as receivedmessage.labels_changed, opt-in, one event per request with the actor, never for system effects, never naming invisible mail, in the same feed and webhooks as every eventExceed
authentication_results: spf, dkim, dmarc and one domain each, arc_sealerThe same, with every DKIM signature (domain, selector, result, alignment), SPF alignment, the DMARC policy in force and which method alignedExceed
DMARC failures under quarantine or reject are dropped without a bounce or an event, unless a trusted ARC seal from google.com, microsoft.com, outlook.com or icloud.com vouches for themNot dropped once it reaches the Worker: quarantined and releasable (Cloudflare Email Routing may reject DMARC failures before that, § 6.1). A rescue needs a valid chain, a trusted newest sealer, a signed From, the sealer’s dmarc=pass for that domain, a recent seal and a recipient binding; the default list holds only the two sealers verified this run; rescued mail never releases codesExceed (and deliberately narrower list)
Optional org-wide message expiry 24 hours after creation; access ends, copies already made remainPer identity, 1 to 8,760 hours; the message, its objects, index rows, vectors and drafts are erased, legal holds respected, a daily audit receipt, and a retried send still never sends twice; copies already delivered remain, and say soExceed
Write-only custom delivery headers; names readable; set and remove in one updateThe same, with a deny list, limits, sealing under the master key, an audit row, and removal when the endpoint’s host changesExceed
BIND zone-file export of a domain’s records?format=bind from the same provider-read records, with each record’s purpose, requirement and DNS status, and NS records placed by methodExceed
Error envelope with docsdocs with an anchor per code, checked in CI, from the deployment’s own docs baseMatch

18. Integration

The shared pages carry this page’s contracts: the PRD, the REST API reference and openapi.yaml, the errors, events, limits and configuration references, the data model, security, workspace policy and the other design pages it extends, the MCP and CLI references, the edge-case register and the build plan (ADR 0017 § Integration, integrated on 2026-10-18). A difference between this page and one of them is a defect: fix both in the same change.