Expand description
Cross-process session mailbox for peer Q&A. Cross-process session mailbox: peer Q&A between concurrent CLI sessions.
Layout inside a session directory:
mailbox/<message-id>.json— unread messages, one atomic file each, so concurrent senders never interleave.mailbox/read/<message-id>.json— acknowledged or expired messages, kept briefly for audit and reaped by age on every drain.
Delivery is at-least-once: the receiver drains, injects into its turn,
then acknowledges. A crash between inject and ack redelivers on the next
drain. Only live sessions (see retention::session_dir_is_live) accept
mail; sending to an unknown or dead session fails closed instead of
piling up questions nobody will read.
Structs§
- Inbox
Drain - Result of draining an inbox: live messages to inject, ids of expired messages moved aside, and a count of quarantined malformed files.
- Mail
Message - A persisted mailbox message as read from disk.
- Mail
Option - One suggested choice for a structured question.
- Mail
Question - One structured question inside a question message.
- Mail
Receipt - Receipt for an accepted message.
- NewMail
- A validated, sendable mailbox message under construction.
Enums§
- Mail
Kind - Kind of a mailbox message.
Constants§
- DEFAULT_
TTL_ SECS - Default message time-to-live in seconds.
- MAILBOX_
DIR - Inbox directory inside a session directory.
- MAILBOX_
SCHEMA_ VERSION - Schema version for mailbox envelopes.
- MAX_
INBOX_ DEPTH - Maximum unread messages per inbox; sends beyond this fail closed.
- MAX_
MAIL_ BYTES - Maximum serialized envelope size in bytes.
- MAX_
OPTIONS - Maximum options per question (mirrors
request_user_input). - MAX_
OPTION_ DESCRIPTION_ CHARS - Maximum option description in characters.
- MAX_
OPTION_ LABEL_ CHARS - Maximum option label in characters.
- MAX_
QUESTIONS - Maximum structured questions per question message (mirrors
request_user_input). - MAX_
QUESTION_ CHARS - Maximum question text in characters.
- MAX_
QUESTION_ ID_ CHARS - Maximum question id in characters.
- MAX_
TEXT_ CHARS - Maximum body/answer text in characters.
- MAX_
TTL_ SECS - Maximum message time-to-live in seconds.
- MIN_
TTL_ SECS - Minimum message time-to-live in seconds.
- READ_
RETENTION_ SECS - How long acknowledged/expired messages are kept for audit, in seconds.
Functions§
- ack_
mail - Acknowledge a delivered message, moving it to the read archive.
Returns
falsewhen the message was already gone (double-ack is safe). - drain_
inbox - Drain an inbox: return live messages oldest-first, move expired and malformed files to the read archive, and reap aged read messages.
- find_
mail - Find a message by id in the live inbox or the read archive.
- read_
mail - Fetch one unread message by id without acknowledging it.
- send_
mail - Send a validated message to a live session’s inbox.