Message History
ferrixd keeps server-side message history for channels and direct messages, replayable through the IRCv3 draft/chathistory extension, with optional SQLite persistence so history — and its message IDs — survive restarts.
How it works
Every PRIVMSG/NOTICE to a channel or user is recorded in an in-memory ring buffer per target (a channel, or a normalized DM pair). Channel events (joins, parts, quits, nick and topic changes, kicks, mode changes) and lasting TAGMSGs (reactions, +draft/persist) are recorded too, and replayed to clients that negotiate draft/event-playback. Kept TAGMSGs are recorded only on the server where they were sent: a reaction from a user on another linked server is delivered live but is missing from this server's playback. Each message gets:
- a
msgid— a monotonically increasing, server-assigned ID, attached as a message tag to clients withmessage-tags, identical live and in replay; - a
timetimestamp (server-timeformat, millisecond UTC).
Clients fetch history with CHATHISTORY:
CHATHISTORY LATEST #forge * 50
CHATHISTORY BEFORE #forge timestamp=2026-07-13T20:00:00.000Z 100
CHATHISTORY AFTER #forge msgid=00000000000004cf 50
CHATHISTORY AROUND #forge msgid=00000000000004cf 30
CHATHISTORY BETWEEN #forge msgid=00000000000004cf timestamp=2026-07-13T21:00:00.000Z 100
CHATHISTORY TARGETS timestamp=2026-07-13T00:00:00.000Z timestamp=2026-07-13T23:59:59.000Z 20Replies arrive inside a batch of type chathistory (when the client has the batch cap), so clients can render them as backlog rather than live traffic. Requests are capped at 100 messages each (CHATHISTORY=100 in ISUPPORT, default 50 when no limit is given). The full grammar: CHATHISTORY reference.
Access control: channel history requires current membership — non-members get FAIL CHATHISTORY INVALID_TARGET. DM history is only visible to the two participants (the target is the symmetric pair), and it is filed by identity: a logged-in user's conversations belong to the account (so every device sees them, see multiclient), a guest's to its nick.
Read markers: with draft/read-marker, a client records how far the user has read (MARKREAD); the marker is kept per account (in memory — it starts over after a restart) and pushed to the user's other connections, so unread counts agree across devices. The web client uses it.
Sizing the in-memory store
Two [limits] knobs bound memory no matter how busy the network gets:
[limits]
history_len = 500 # messages kept per target (ring buffer)
history_max_targets = 50000 # distinct targets kept in memoryhistory_len— per-channel/per-DM-pair retention.0disables replay usefully (only the current run's messages).history_max_targets— a global cap on distinct targets. Past it, the least-recently-active targets are evicted in batches. This means an attacker opening DMs to thousands of nicks cannot grow memory unboundedly.
Persistence
Without persistence, history lives exactly as long as the process. To make it durable:
[persistence]
path = "/var/lib/ferrixd/ferrixd.db"
load_limit = 5000 # most-recent rows loaded into RAM at startupWhat you get:
- History survives restarts. At startup, the most recent
load_limitmessages are loaded back into the in-memory rings. msgidcontinuity. The msgid counter reseeds past the highest persisted ID, so IDs never repeat or go backwards across restarts — clients' "what did I miss" logic keeps working.- The same file also stores registered channels and self-registered accounts.
Write path (and what a crash can cost)
Writes are write-behind: messages are appended to an unbounded queue drained by a dedicated writer thread, batching up to 256 inserts per transaction into SQLite (WAL mode). This keeps the hot path free of disk I/O — a slow disk slows history durability, never message delivery.
The trade-off: an unclean crash can lose the last instants of unflushed history. On graceful shutdown (Ctrl-C / SIGTERM) the queue is drained with a 2-second grace period.
Retention on disk
The on-disk table is pruned at startup to the most recent 100,000 rows; within a run it grows with traffic. The in-memory rings are what serve requests — disk exists to survive restarts, not as an unbounded archive. If you need long-term archival, scrape it from SQLite directly (schema in the reference) — it's a normal database file, safe to read with WAL mode.
Searching history
With persistence on, ferrixd also offers server-side full-text search through the soju.im/search extension — supported by soju-aware clients, and easy to drive by hand:
CAP REQ :soju.im/search batch
SEARCH text=borrow checker
SEARCH in=#rust;from=alice;after=2026-11-01T00:00:00.000Z;limit=20The attribute list uses message-tag syntax: in (a channel, or a nick for your conversation with them), from (sender nick), after / before (server-time timestamps), text (every word must occur; the last one also matches as a prefix) and limit (capped by search_max_results, default 100). Results arrive oldest-first in a soju.im/search batch, rendered like history playback (@time, @msgid, @account as negotiated).
A search only ever covers the channels you are in right now and your own direct-message conversations — the scope is applied inside the query, not afterwards — and membership events are never returned. Words are matched as quoted FTS5 terms, so search text can never be interpreted as query syntax.
The index is an SQLite FTS5 table over the stored history, maintained by triggers, so redactions, pruning and channel renames keep it exact without extra work. A database from an earlier release is indexed once on first start. Because storage is write-behind, a message becomes searchable within moments of being sent rather than instantly. Disable search with search = false in [persistence].
Interaction with other features
| Feature | Interaction |
|---|---|
echo-message | your own messages come back with their msgid, so your client can correlate |
draft/multiline | multiline batches are recorded and replayed as their parts |
draft/message-redaction | REDACT removes the message from memory, disk and the search index |
draft/channel-rename | a renamed channel keeps its history (and search results) |
| Plugins | a message vetoed by a plugin is never recorded |
| Federation | messages relayed from linked servers are recorded on each server hosting members, so history works network-wide |
TARGETS | lists the targets (channels + DM partners) with activity in a time window — lets clients discover missed conversations |
Operational notes
- Put the database on the persistent volume in Docker (
/var/lib/ferrixd) — see Installation. - The write queue is unbounded by design (history must not drop under burst); if the disk is dramatically slower than traffic, memory holds the difference. ferrixd exports no memory metric itself: watch the process's RSS with your usual host monitoring (node_exporter, cAdvisor,
systemctl status). - Back the database up online with
ferrixd ctl backup <file>— see Deployment → Backup. - Deleting the file while stopped resets history and registrations; ferrixd recreates the schema on next start.