Documentation
¶
Overview ¶
Package wire is the message line format, on disk and on the network.
A message is exactly one line:
<seq> <UTC ts> <from>> <one line of text>
Plain text on purpose: the readers are LLMs, so it stays token-lean and greppable. Ordering, cursors, and resume use seq only. The timestamp is there to be read; nothing is ever gated on it.
Index ¶
Constants ¶
const MaxBody = 512
MaxBody caps a message body so that one append is one write, and so a reader never sees half a message except at the tail of a file.
const MaxName = 64
MaxName caps a node or topic name.
Variables ¶
var ErrMalformed = errors.New("malformed line")
ErrMalformed marks a line that is not a message: garbage, or the torn tail of a file that was being appended to as we read it.
Functions ¶
func CheckBody ¶
CheckBody validates a message body: one line, bounded, printable, UTF-8. Rejecting control characters is what keeps one message equal to one line.
func CheckName ¶
CheckName validates a node or topic name. Names become filenames, so the charset is deliberately narrow: no dot, no slash, no separator of any kind, which makes traversal out of the workspace unrepresentable rather than merely checked for. A leading '#' marks a topic.
func Display ¶ added in v0.7.0
Display renders a message for a reader, which is not the same job as Format.
What is stored never changes: a full UTC stamp, greppable by date, so an inbox is its own archive. What a reader sees is a preference -- the timestamp is the widest field on the line and the least load bearing, since order and resume come from seq and nothing is ever gated on time. "hm" keeps the part people actually read; "none" admits that in a live conversation the arrival time is now.
func Escape ¶
Escape folds a multi-line text into the one-line body the wire requires: backslash to `\\`, newline to `\n`, tab to `\t`, nothing else. One message is one line on disk and on the wire -- the newline is the frame, and that is not negotiable -- so multi-line content travels folded, and readers that care unfold it. Like the thread grammar, the escape set is pinned to exactly these three so historical mail never grows dialects.
func ReplyTo ¶
ReplyTo reports the message a body replies to, under the one thread grammar: "re:<seq>" at the very start of the body, one target, followed by a space and the text. Nothing else counts -- not "re: 42", not "Re:42", not a reference mid-body -- because a convention loose enough to have variants makes historical mail unparseable the day someone builds a thread view. The relay never calls this; threads are a client concern, and this function is the grammar's single definition.