Skip to main content

Module domains

Module domains 

Source
Expand description

Domains & mail addresses — the foundation of the domain + semantic-mail/address stack (docs/plans/social-network-plan.md §0.5). A domain/subdomain acts as an agent (QDP — Timothy’s draft-webcivics-QDP: a domain publishes an RDF agent profile at /.well-known/QDP). A person runs several context-domains (personal/work/projects), each with its own front-door DID(s); subdomains serve families/children. A domain may be single-owner or (deferred placeholder) group-owned via an M:N agreement — modelled now so group domains slot in later without a refactor.

Addresses on a domain are rule-bearing mailboxespurpose inboxes (frontdoor@/junkmail@/ mygov@/newsletters@) or per-relationship (bob@alice.example), plus optional deliberate catchall@ for fail-closed wild-card intake (quarantine, not open relay). This module owns the data model, presets, resolve_delivery, and onboard_purpose_inboxes. Rules evaluation is crate::mail_rules; SMTP/IMAP is crate::mail_transport; QDP front-door forms are crate::front_door / api::front_door_forms.

Structs§

Domain
A domain (or subdomain) acting as an agent.
MailAddress
A mail address = a rule-bearing mailbox on a domain.
MailRules
Rules governing an address (a mailbox) — procedural + semantic.
PurposePreset
A common purpose-inbox preset (a sensible name + rules a user can accept or tweak).

Enums§

AddressKind
The kind of a mail address on a domain.
AgentType
QDP agent type (draft-webcivics-QDP §1) — what kind of agent a domain represents.
DeliveryResolution
Outcome of semantic delivery resolution for an inbound to address.
DomainOwner
Who owns/controls a domain. Personal today; Group is the deferred placeholder (governed by an M:N agreement) — present so the model does not hard-assume single-owner domains.
ResolutionVia
How a delivery address was matched.

Functions§

address_counts_by_domain
Summary counts for the UI.
is_valid_local_part
A local-part is a lowercase RFC-ish token: alphanumeric + . - _, 1..=64 chars, no leading/trailing separator. (Deliberately stricter than RFC 5321 for legibility + safety.)
list_addresses
list_domains
make_domain
Build a Domain value (does not persist).
make_purpose_address
Build a purpose-inbox address (does not persist).
make_relationship_address
Build a per-relationship (pairwise) address bound to a relationship DID (does not persist).
onboard_purpose_inboxes
Mint every built-in purpose preset for domain that is not already present. Returns the list of newly minted full addresses (empty if already onboarded).
purpose_presets
The built-in purpose inboxes. frontdoor@ is public-but-governed; junkmail@ is the burner; mygov@ is verified-sender-only + high-priority + long retention.
resolve
Resolve a full address (case-insensitive) against a set of addresses.
resolve_delivery
Resolve inbound delivery for to_address against minted mailboxes.
set_address_enabled
Enable/disable an address (the surgical per-relationship revoke).
split_address
Parse local@domain (lowercase). Returns None if not a dotted domain form.
upsert_address
Persist an address (upsert by full address). Errors if the domain is unknown.
upsert_domain
Persist a domain (upsert by name).