nx_email_mailbox.nx
buildroot/runtime/nx_email_mailbox.nx
about
nx_email_mailbox.nx -- EMAIL RUNG R3: additive-only mailbox store.
module: nishi-core.email.mailbox
depends: nishi-core.store.seg_store
capability: CORE_EMAIL
Where delivered mail LIVES. Composes the sovereign segment store
(nx_seg_store) rather than inventing persistence -- a message is one
keyed record (kind=1 put, key=Message-ID, value=raw RFC 5322 bytes);
deletion is a kind=2 TOMBSTONE appended in a new segment, never an
erase. This makes the mailbox obey Cardinal 13 (additive-only,
soft-delete via is_current, history is sacred) for free: a deleted
message vanishes from the current view (ss_get returns "tombstoned")
but every version is still walkable via ss_scan -- exactly what an
audit/undelete/IMAP-history needs.
segid is supplied by the caller (a monotonic counter in production);
each deliver/delete commits one new immutable segment, so concurrent
readers never see a torn write (ss_commit renames into place).
license_tier: INDEPENDENT_REDERIVE
genealogy_id: nishi_sovereign_segment_store + maildir_semantics
lineage_id: nishi_email_mailbox_r3
nx_safety_envelope:
intended_use: "Deliver/fetch/soft-delete mail over the
sovereign segment store. Additive mailbox."
sil_target: SIL2 (lost/leaked mail)
evidence: [composes_nx_seg_store, byte-exact_fetch,
tombstone_softdelete, history_retained,
per-key_isolation]
hazard_register: [bug-tape-mail-loss, bug-tape-delete-erases-history]
residual_risk: "Monotonic segid allocation + folder hierarchy
(INBOX/Sent/...) are upstream concerns; this is
the single-mailbox record substrate."
verdict: NOT_YET_EVALUATED
dependencies 2 imports · 4 importers
imports: nx_seg_store.nxnx_syscalls.nx
imported by: nx_email_mailbox_gate.nxnx_email_mta_gate.nxnx_email_mta_io.nxnx_email_webmail.nx
structs
| none |
consts
| 41 | const NX_MBOX_CAP: i64 = 260 |
| 42 | const NX_MBOX_KIND_PUT: i64 = 1 |
| 43 | const NX_MBOX_KIND_TOMB: i64 = 2 |
functions
| 47 | func nx_mbox_deliver(prefix: *u8, msgid: *u8, raw: *u8, rlen: i64, segid: i64) -> i64 |
| 54 | func nx_mbox_delete(prefix: *u8, msgid: *u8, segid: i64) -> i64 |
| 63 | func nx_mbox_fetch(prefix: *u8, msgid: *u8, ptrout: *i64, lenout: *i64) -> i64 |
| 68 | func nx_mbox_exists(prefix: *u8, msgid: *u8) -> i64 |
| 78 | func nx_mbox_history_count(prefix: *u8, msgid: *u8) -> i64 |
| 90 | func mbox_itoa(v: i64, out: *u8) -> i64 |
| 98 | func mbox_atoi(s: *u8, n: i64) -> i64 called by 1: nx_mbox_count |
| 104 | func mbox_key(mailbox: *u8, seq: i64, out: *u8) -> i64 |
| 115 | func nx_mbox_count(prefix: *u8, mailbox: *u8) -> i64 |
| 123 | func nx_mbox_append(prefix: *u8, mailbox: *u8, raw: *u8, rlen: i64, segid: i64) -> i64 called by 4: nx_mta_serve_connepd_deliverepd_handlemain calls 7: nx_mbox_countsys_mmapmbox_keymbox_itoass_beginss_add+1 |
| 137 | func nx_mbox_get_n(prefix: *u8, mailbox: *u8, idx: i64, ptrout: *i64, lenout: *i64) -> i64 |
| 145 | func nx_mbox_delete_n(prefix: *u8, mailbox: *u8, idx: i64, segid: i64) -> i64 |