Arcana::Mail
Arcana as a machine's mail carrier (the dot-ai spec's Mail, in the
user's dot.ai repository): what dot-ai's local carrier does, through
the same files and locks (the spec's "The carrier's files"), so either
can be the machine's carrier and a change between them moves nothing.
Agents keep using dot-ai mail, which hands the carrier's part to
arcana mail.
Which carrier carries a person's mail is git config's ai.carrier,
read from the person's own config only (person_config): arcana
makes Arcana the carrier; under any other (local, dot-ai itself,
the default) Arcana stays out of mail, and writes no mail files
(carries?). Each run reads it afresh.
What it prints matches dot-ai line for line, so dot.ai's tests
(tests/dot-ai.sh, with CARRIER=arcana) check both carriers. Where it
names a command, it names dot-ai's when dot-ai is installed (dot_ai),
and its own otherwise: Arcana never needs dot-ai.
Where it goes further: a message for an address no project on this
machine has goes over the Arcana bus (bus_sender), to an agent
registered there.
Constants
dot-ai's command, below a version of its Claude Code or Codex plugin, or below their home for a skill installed by hand.
How far below a search root a project may sit.
This carrier's name: ai.carrier's value for it, and what Via:
and Sent: … via say.
The settings that are a person's, not a project's (the dot-ai spec's Config).
A lock older than this is a crashed run's.
Class methods
Sends mail from the project at root over the bus at ARCANA_URL,
as the MCP bridge's arcana_deliver would: from the project's
handle, to be read when the agent gets to it, with the message's id
and Re:, the request signed with the project's key and the
message too, so its recipient can check who sent it. The subject is
the outbound name's topic.
Whether Arcana carries mail, and so writes mail files (inbox files,
sent copies): where it's the carrier, or where there's no dot-ai to
carry it (dot_ai?). Only the carrier writes them.
A project's address: @ plus its config's handle, or its
directory's name folded (AgentConfig). Nil when the config can't
be read or its handle isn't one.
Whether the project at DIR is set up for an agent: its .ai/ has a
config. Without one, whatever folders its .ai/ holds, no agent is
there to read mail, so none is delivered to it (dot-ai's spec, Mail:
Delivery).
Delivers the outbox of the project at root, one line per message
to io: delivered (posted, for a topic), or left in the outbox and
why (the spec's Delivery, under the outbox's lock). A message for an
address no project here has goes to bus.
How an agent runs dot-ai (0.5 or later), for what Arcana tells it:
dot-ai when it's on the PATH (dot-ai install), else the newest
copy the dot-ai plugin installed for Claude Code or Codex, or one
installed by hand as a skill, run with sh. Nil when there's none,
and Arcana names its own commands instead.
Whether dot-ai is installed at all, in any version: dot_ai, or an
older one (dot-ai-mail) installed for Claude Code or Codex. Without
it, nothing but Arcana carries mail between projects.
The topics the project at root follows: mail.follow in its
config.
Files with a name ending in -<id>.md in dir, hidden ones aside.
An inbox file's or post's text: header lines, a blank line, then the message.
An outbound file's header lines, each with its newline, and its message: what follows them and the blank line that ends them.
Takes the lock path, a directory, so making it is atomic; one older
than STALE_LOCK is a crashed run's, and is cleared.
The project with address: {directory, nil}, or {nil, why not}.
A message's id: the first 8 hex digits of the SHA-256 of the sender's address, the outbound file's name and the message.
A per-person setting's values: from the person's own git config
(--global, which takes in $XDG_CONFIG_HOME/git/config), else the
system's, never a repository's, which a plain git config --get
would let win. With path, ~ expanded.
The project at root's place in topic: the last post it read.
The posts in the topic folder dir after number n, oldest first.
The project at or above dir: the nearest directory, dir included,
holding .ai/ (through a link, too). Nil when there's none.
Whether a Re: line names something: a message's id (8 or more hex
digits) or a topic's post (#topic:number).
The receipts for the mail the project at root sent: a line for
each message read, or one that can't be any more, whose line is
dropped. A line whose project doesn't start with / is another
carrier's, for a recipient elsewhere, and is left. Left for next
time while a delivery holds the outbox.
What a repository at or above dir sets of the per-person keys,
which is ignored: a warning line for each.
Every project under the search roots, as {address, directory},
sorted by directory; the address is nil when the project's handle
can't be read. Symbolic links aren't followed, and hidden
directories and node_modules/ aren't searched. A root that doesn't
exist is reported to warn.
Where to look for projects: ai.path, else the outermost project
enclosing root's, else root's parent directory.
Moves the project at root's place in topic to n.
Where this machine's topics are kept: .ai/topics/ of the topic
home, the first ai.path directory, else the outermost project at or
above root. {path, nil}, or {nil, why there's none}.