Skip to content

Developer Guide

This document describes the code, the decisions made so far and why, and what is left. Protocol rules belong in the UN-RFCs (rfc/); this file is about the implementation and the reasoning around it.

Principles

  1. The spec is the product. If the code and an UN-RFC disagree, the code is wrong, or the UN-RFC must be changed through the process in UN-RFC 0000. Never let behavior drift silently.
  2. Boring, auditable cryptography. libsodium primitives through PyNaCl. No home-made ciphers. Every hash and signature has its own domain separator.
  3. Portable first. The client must run from a USB stick on a machine we do not control. Few dependencies, nothing written outside the stick.
  4. Text network. No binaries, small articles, bounded storage.
  5. Nobody rules alone. Group owners, node operators and readers each control their own part (UN-RFC 0001 section 4).

Repository Layout

What is where in the repository. The package itself is mapped in The code, and each of its files says at the top what belongs in it.

rfc/                    The UN-RFC series (normative spec)
docs/development.md     This file
src/unseenet/           the package: core, client, node, cli - mapped file by file
                        in docs/developers/code.md ("The code" on the site)
deploy/                 install-node.sh and the systemd unit
tools/announce.py       posts to the project's channels over Tor (announce.yml)
tools/project/          what the maintainer runs with the project key (see docs)
tools/node_request.py   checks and adds "Add my node" issues (node-request.yml)
tests/                  pytest; includes two nodes replicating over ONNTP
assets/                 logo files (generated by tools/make_logo.py)

Getting Started

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest

For a local network without Tor:

unseenet-node --no-tor --data /tmp/a --listen 127.0.0.1:1119
export UNSEENET_PASSPHRASE=test UNSEENET_INSECURE_FAST_KDF=1   # dev only!
unseenet --vault /tmp/me.vault id-new me
unseenet --vault /tmp/me.vault node-add 127.0.0.1:1119

A node config file (TOML):

[node]
name = "mynode"
min_pow = 18
retention_days = 90
new_groups = "accept"          # accept | trusted | manual

[[peer]]
name = "friend"
address = "abcdef...xyz.onion:119"
groups = "dk.*,comp.*"
key = "ed25519:..."            # the friend's node key (UN-RFC 0016)

The site unseenet.org is built by unseenet-docs, which gathers the pages of this repository's docs/ and the UN-RFCs (#547); tools/docs_check.sh previews and checks the pages kept here (pip install mkdocs-material "mkdocstrings[python]"). The screenshots of the terminal client in Using the client are made by tools/docs_screenshots.py in unseenet-tui: it starts a node on your machine without Tor, fills it with made-up people, groups and posts, drives unseenet-tui headless and writes docs/img/client-*.svg. Run it again when the client's look changes, and commit the files.

The recordings on the front page are made the same way, from the same made-up content:

  • tools/docs_recording.py (in unseenet-tui) runs the real client in a pseudo-terminal, types into it and saves docs/img/demo.cast, which the bundled asciinema player plays (pip install pexpect; --gif docs/img/demo.gif also renders the GIF for the README, with agg).
  • unseenet-bootable's tools/image/record.py IMAGE boots a bootable image in QEMU, goes through the menu and makes a vault, and writes docs/img/boot.webm and boot-poster.png (needs QEMU and ffmpeg; KVM is faster but not needed).

Make them again when the client or the boot menu changes noticeably.

Building another client

Every client (the TUI, unseenet-gui, unseenet-mcp, bots) is built on unseenet.client.session.Session, so they all show the same thing. Lay out a group with the session, not with code of your own (#139):

  • Session.threads(group_id) gives (message, depth) rows: threads newest first for a post view, the conversation oldest first for contact:<key>, and replies to you and mentions for for-you:.
  • Session.view_of(group_id) says threads, chat or data: your own choice, else the group owner's, else threads. Session.set_view() changes it (None goes back to the owner's).
  • Session.send_chat(group_id, text) sends a chat line to a group or to contact:<key>. Ask about portals first, as for Session.post().
  • Session.subscribed_groups() lists the groups you follow, in your order, with type, view, what they take and (unless counts=False) unread posts, replies and mentions. Pass what your nodes list to learn which they don't carry (listed=False).
  • Message.to_dict() and GroupInfo.to_dict() give plain JSON-safe data in one documented shape (DICT_VERSION, now 1): dates as ISO 8601, the body also split into text and signature. Send these to a front end, an MCP tool or a bot instead of making your own.
  • Session.on(callback) gives typed events (unseenet.client.events): Status (the old status line), GroupUpdated, GroupsChanged, PowProgress (draw its fraction; postage can take seconds on an old laptop), NodeState and TorState (bootstrap percent). Each has to_dict(). Callbacks run on the event loop; Session.on() returns a function that stops them. The status= callback still works.
  • ClientRuntime(session) (unseenet.client.runtime) does what every client does after unlocking, in the order that matters: starter groups, the offline cache, the inbox once, one push connection per node, the node list, releases, renewals and names in the background, and every group fetched, again each minute as a fallback for push. await rt.start() and await rt.stop() run it on its own (bots, MCP, the graphical client); or call open(), refresh(), maintain() and watch_node() from your own scheduler, as the TUI does. It adds the events InboxReady, Refreshed and ReleaseOffer.

How a row is drawn (icons, colours, indentation) is the client's choice.

Services: gateways, bots, registrars

A service posts through Session too, so key ripening (UN-RFC 0025), postage and retries are the same code everywhere:

  • Session.from_key(identity, state_path) is a session for a key without a vault. The key stays in memory; the state file (nodes, groups, the ripening chain) holds nothing secret.
  • Session.post_article(art) posts an article built and signed elsewhere, such as a gateway's imports with their own headers. It ripens first where the node asks for it, sets Key-Ripening, and sends the key's chain to a node that lacks it. With sign_with=identity it signs the article itself, with the postage that node and group need for the key's level (Session.postage_for()), and once more if the node asks for more. Use that rather than a fixed number of bits.
  • core.poster.Poster, the bots' API, posts through these, keeping the key's chain in state= (default ~/.unseenet/keys/<fp>.state.json, or UNSEENET_STATE_DIR).
  • ClientRuntime(session, ripen_to=SERVICE_RIPEN_TO) ripens on in the background to level 3 (no surcharge), in a low-priority thread, and publishes ripe@ at each level.
  • The same key on another machine (a reinstall, CI, a vault copy) takes over the chain from its own ripe@ group instead of ripening again (Session.adopt_published_ripening(), done before ripening by itself).
  • At setup: unseenet ripen --key-file KEY --to 0 --node HOST --publish (7-11 minutes to level 0). Computing needs only the public key, so it can run on a faster machine; only --publish signs.
  • Ripened on another machine (#784): there unseenet ripen --public-key KEY --to 4 --state FILE; where the secret is, with the service stopped, unseenet ripen --import FILE --key-file KEY --publish (or --vault V --identity NAME for a vault). The chain is checked and taken over only if it is further than the service's own; the rest of a service's state is kept, and --publish lets its other copies take it over too. Run it again as the other machine reaches each level.

A key kept offline (a gateway's group key, the project key) only signs manifests now and then: ripen it to level 0 once; the tool that brings it online for a change publishes ripe@ first.

A front end or a program in another language: the local API

unseenet serve (needs pip install unseenet[api]) offers everything above over HTTP and a WebSocket on 127.0.0.1, as UN-RFC 0046 describes: the groups and their rows, writing as jobs with progress, people, the groups you run, names, profile and settings. A front end never holds a key.

$ unseenet --vault me.vault serve              # a person's client: unlock through it
UNSEENET-API 1 http://127.0.0.1:41817/ 3q2-...

$ unseenet serve --key-file bot.key --node xyz.onion    # a bot: unlocked at once

The first line gives the address and the token; send the token in X-Unseenet-Token (or, for /api/events, as the subprotocol unseenet-token.<token>). For a vault the same line is in <vault>.api, readable only by you, while it runs. A service posts what it builds with POST /api/articles, adding its own X- or Gateway-* headers; postage and ripening are done for it.

In Python, unseenet.client.localapi.LocalAPI is the same without the web server, and server.make_app(api, token, page=..., extensions=...) lets a graphical client serve its own page and add routes under /x/<name>/, as unseenet-gui does.

Design Decisions (so far)

Each decision lists where it is specified and the reasoning. Changing one means writing a new UN-RFC.

Python

The maintainer is most productive in Python. The workload is I/O-bound (Tor latency dominates), so asyncio is more than fast enough. The only CPU-heavy part, postage, is deliberately expensive anyway.

Tor via the control port, not stem

stem no longer builds on current Python versions. We need four control commands (AUTHENTICATE, GETINFO, ADD_ONION, and bootstrap status), so core/tor.py speaks the control protocol directly. Bonus: one fewer dependency, and ADD_ONION lets us keep the onion key in our own encrypted file instead of in Tor's directory (UN-RFC 0007 §3).

Arti (Tor in Rust) could later be embedded for a single-binary build.

NNTP as the wire protocol (UN-RFC 0005)

Decades of newsreaders, tools and understanding come for free. We use a strict profile and add capabilities rather than inventing a protocol. Tor replaces TLS.

Signed articles, content-derived Message-IDs (UN-RFC 0002)

Usenet's worst problems were forgery: forged posts, forged cancels, forged newgroups. Signing everything and deriving the Message-ID from the signed content removes that whole class of problems, and makes duplicate suppression trustworthy.

No Path header (UN-RFC 0002 §2.4, 0005 §5.4)

Path recorded every server an article passed through, which tells an observer where it entered the network. History of Message-IDs is enough to prevent loops. Readers get a synthetic Path: not-for-mail for compatibility.

Group IDs include the owner fingerprint (UN-RFC 0004 §1)

There is no registry to prevent two dk.snak groups. Instead of fighting that, the owner's fingerprint is part of the name. The UI shows a short form and warns about look-alikes.

Four group types chosen by the owner (UN-RFC 0004 §2)

"Like old Usenet" (open), moderated groups (as Usenet had), channels (announcements), and closed groups. This covers both public discussion and private circles on the same network.

Closed groups: epochs and member keys (UN-RFC 0004 §6)

  • Content is encrypted with a key derived from a per-epoch group secret.
  • Nodes must be able to reject posts from non-members without being able to read anything. Solution: a member key derived from the same secret. Only holders of the secret can produce Member-Signature, and nodes can verify it with the public member key.
  • Removing a member starts a new epoch. A removed member keeps what they already received — this is unavoidable and documented.
  • MLS (RFC 9420) would add forward secrecy but is far more complex. It is a candidate for a later revision.

Postage instead of accounts (UN-RFC 0006)

Anonymous identities are free, so we make posting cost a little CPU. SHA-256 is simple and good enough to start; the header names the algorithm so a memory-hard one (Argon2id) can be added.

Data at rest (UN-RFC 0007)

  • Client: one vault file, Argon2id + XSalsa20-Poly1305, kept decrypted only in memory, saved atomically.
  • Node: LUKS for the disk; onion key encrypted and handed to Tor over the control port; closed groups only ever stored as ciphertext.
  • Known limit: Python cannot reliably wipe secrets from memory. For strong adversaries, recommend running from Tails.

Text by default, 64 KiB

Keeps storage bounded, nodes cheap, and operators away from the legal problems binary groups brought to Usenet. Small files (UN-RFC 0027) are stored apart from the text as blobs, which a node carries only when its operator turns them on.

Open Questions

These are not decided. Discussion welcome — ideally as Draft UN-RFCs.

  1. Co-owners for groups. (Transferring ownership is UN-RFC 0015.)
  2. Hiding the reading pattern from the node (cover traffic, reading from several nodes).
  3. Author-Key visibility in closed groups. Could be hidden by signing only with the member key, at the cost of in-group accountability.
  4. Post-quantum signatures and key exchange.
  5. Abuse handling for node operators — a clear, documented way to drop groups and peers, and what to tell operators about their responsibilities.

Settled since this list was first written: chat and low latency (UN-RFC 0008), the moderation queue and private messages (UN-RFC 0009), node discovery (UN-RFC 0010), ownership transfer (UN-RFC 0015), authority over group names (UN-RFC 0018) and names for identities (UN-RFC 0019).

Code Status

Working:

  • Full article lifecycle: build, sign, postage, Message-ID, validate.
  • Manifests, all four group types, approvals, cancels.
  • Closed groups end to end, including invitations via key-grant.
  • Node acceptance pipeline and ONNTP reader/peering commands.
  • Push replication to peers (tested with two nodes over local TCP).
  • Own Tor process, onion service, SOCKS connections (not yet covered by automated tests, as CI has no Tor).
  • Encrypted client vault, a command-line client and a TUI client.
  • Tested for real: two nodes in Proxmox LXCs peering over Tor onion services; an article posted on one is readable on the other about a minute later (most of it the deliberate random forwarding delay).

Missing / rough:

  • Feeds are not pipelined; one CHECK at a time.
  • The command line (cli/) goes through Session for groups, manifests and withdrawing (#389); posting and reading follow with the 0.5.0 commands (#387).
  • Argon2id "moderate" needs ~256 MiB RAM while unlocking; fine on a PC, worth tuning for small nodes.
  • Portable builds are not code-signed (Windows SmartScreen, macOS Gatekeeper warn on first start).

Versioning

There are three independent version numbers. Keeping them apart means the software can evolve quickly while the network stays compatible.

What Where Rules
Software unseenet.__version__, tags vX.Y.Z Semantic versioning (below)
Protocol PROTOCOL_VERSION, the Unseenet-Version header Changes only through a new UN-RFC (UN-RFC 0000)
File formats magic bytes (UNSVAULT1, UNSSIDE1) and "v" fields A new format gets a new magic or v; old files must still open

Software versions

Semantic versioning: MAJOR.MINOR.PATCH.

  • Before 1.0 (now): anything may change. MINOR is raised for new features and for breaking changes; PATCH for fixes only. A stable release (vX.Y.Z) is GitHub's "latest" release even before 1.0: the stable update channel of Portable and Bootable fetches releases/latest, which never points at a pre-release. Test releases (a, b, rc) and development builds are pre-releases.
  • From 1.0: MAJOR for breaking changes (command line, node.toml, vault format, dropping a protocol version), MINOR for new features, PATCH for fixes.

What counts as breaking: anything that makes an existing node.toml, vault or script stop working, or that stops a node from talking to nodes running the previous MINOR release.

Compatibility promise: a release always interoperates with nodes and clients from the previous MINOR release, so a network can be upgraded one node at a time.

Making a release

  1. Move the entries under ## [Unreleased] in CHANGELOG.md to a new ## [X.Y.Z] - YYYY-MM-DD section, and add the compare link at the bottom.
  2. Set __version__ = "X.Y.Z" in src/unseenet/__init__.py. Run tools/check_rfc_headers.py --release X.Y.Z: the UN-RFCs whose Implemented: line says unseenet main (unreleased) now name X.Y.Z (UN-RFC 0000 section 3.4).
  3. Commit, then tag and push:
    git tag -a vX.Y.Z -m "Unseenet X.Y.Z" && git push origin vX.Y.Z
    
  4. .github/workflows/release.yml checks that the tag, __version__ and the changelog agree, runs the tests, builds, publishes to PyPI with trusted publishing (no API tokens stored anywhere) and creates the GitHub release with the changelog section as notes.
  5. The portable zips and the bootable images are built in their own repositories, unseenet-portable and unseenet-bootable (#549, #550): bump the core in unseenet-portable's versions.toml, merge and tag there. They build on Linux, Windows and macOS (Apple silicon and Intel), unpack and self-test each one, boot the images in QEMU, and make that repository's release with SHA256SUMS.txt; then sign it with tools/project/sign_release.py. The other services (the gateway, the entrance, the watchman, the bots, the help bot) are released from their own repositories with their own versions; each release carries SHA256SUMS.txt and <package>-<version>-server-requirements.txt, and servers running that service update to it once it is signed: tools/project/sign_release.py --repo unseenet-gateway v0.6.0 (#827). Server releases are posted in unseenet.releases too, which servers read before they ask GitHub (#901); --post posts a release that was signed before.

The project has a key list (UN-RFC 0062, #822; pinned in PROJECT_FIRST in src/unseenet/release_keys.py since 3 Nov 2026): the project key and two reserve keys, each kept offline on its own removable medium. A stable release needs two signatures of the three: run sign_release.py <tag> with the vault, then sign_release.py --seed-file <reserve key> <tag> with a reserve key; it is posted once both are on. Development builds need one. A later list (release_keys.py make --seq 2 --prev keys-1.json > keys-2.json) counts once two of the three keys voted for it: release_keys.py post keys-2.json (the vault's vote), then release_keys.py post keys-2.signed --seed-file <reserve key>. The votes are signatures inside the post (UN-RFC 0062 section 3.1), so they count whoever carries them. Once it counts, put release_keys.py chain in PROJECT_CHAIN in src/unseenet/release_keys.py by pull request: clients count it without the channel, and the announce workflow posts it every month and with each release, so it never expires on the nodes (3.2).

Where releases are fetched from is set in the network too (#902): tools/project/release_sources.py post sources.json signs and posts a list of release sources (file addresses and package indexes). Servers and clients use the newest list and keep it, so post a new one before a source goes away when you can. It grants nothing over what is installed: every file must still match the signed checksums. Once the key list is pinned, the list needs two signatures as a release does: post writes sources.post after the vault's, and release_sources.py sign sources.post --seed-file <reserve key> adds the second and posts it. When the list council keeps the sources (UN-RFC 0020 section 6.8), post --moved-to <council> sources.json is the project's last list. 6. .github/workflows/announce.yml posts the release notes to unseenet.announce on Unseenet itself, over Tor, once the release workflow has succeeded.

Release branches and fixes

main is where the next minor version is developed. A released minor version gets a branch only when it needs a fix:

  1. Fix it on main first, with its test, as usual.
  2. If release/X.Y does not exist yet, create it from the release tag: git switch -c release/X.Y vX.Y.0 && git push origin release/X.Y.
  3. Carry the fix over with git cherry-pick -x <commit> on a branch off release/X.Y, open a pull request against release/X.Y, and let the tests run.
  4. On release/X.Y, move the fix's changelog line into a new ## [X.Y.Z] section, set __version__, and tag vX.Y.Z there. The release workflow builds from the tag, whatever branch it is on.
  5. Add the same ## [X.Y.Z] section to CHANGELOG.md on main, so the history is complete there too.

A release branch takes only fixes: no new features, no protocol changes. It is supported until the next minor release (see SECURITY.md). Development builds are made from main only.

Test releases and development builds

An alpha (or beta, or release candidate) is a release for testing, with a PEP 440 version: 0.2.1a1, 0.2.1b1, 0.2.1rc1. Make it like a release, but leave the changelog entries under ## [Unreleased] - they become its notes:

# __version__ = "0.2.1a1" in src/unseenet/__init__.py, commit, then:
git tag -a v0.2.1a1 -m "Unseenet 0.2.1a1" && git push origin v0.2.1a1

It is published to PyPI and GitHub as a pre-release (pip takes it only with --pre) and announced as a test release.

Development builds need nothing: each night (03:17 UTC) unseenet-portable checks whether main of the core, the terminal or the graphical client changed since its last dev build, and if so builds the zips - the core's version from tools/dev_version.py (0.2.1.dev3: three commits after v0.2.0; written into the build only, never committed) - and replaces its pre-release dev; unseenet-bootable makes the images from them two hours later. They are not published to PyPI.

Merging to main builds nothing (#544); only the tests run. To get a build sooner, run the build workflow of unseenet-portable by hand (Actions, "Run workflow"): publish dev replaces the development build, artifact only leaves the builds in the run's artifacts. force builds even when nothing changed. The portable builds' tools - and the Tor version they pin, checked daily by its tor-update workflow - are in unseenet-portable; the bootable images' in unseenet-bootable, whose releases follow unseenet-portable's.

Between releases, every change that users or node operators would notice gets a line under ## [Unreleased].

Issues, Labels and the Changelog

Every change that users or node operators would notice has an issue, so the release notes can say what changed and link to the discussion:

  1. Open an issue (or use the existing one). The forms add a type label (bug, enhancement, documentation), an area label and triage.
  2. Remove triage once you have looked at it; fix the labels if needed.
  3. Mention the issue in the commit: Fixes #12 closes it when the commit reaches main, Refs #12 only links it.
  4. End the changelog line with the issue number: - ... (#12). The release notes are made from CHANGELOG.md, so the number becomes a link there.
  5. Update the docs the change touches. If it changes how something works, also the chapter of How it works (docs/guide/) that describes it - those pages explain the design in prose and go stale quietly. The pull request template has the checklist.
Label Meaning
bug, enhancement, documentation, question What kind of issue it is
area: client, area: node, area: protocol, area: portable, area: bootable, area: docker, area: docs, area: infra Which part it is about
security Affects the safety, privacy or anonymity of users (report weaknesses privately, see SECURITY.md)
breaking Breaks compatibility: protocol, file formats, command line or node.toml
triage New, not looked at yet
good first issue, help wanted For contributors
node-request, accepted Requests to join the known-node list (UN-RFC 0010)
hierarchy-request Requests for a hierarchy in the project's root list (UN-RFC 0018)

Milestones

What is planned for which release is kept as milestones on GitHub, so anyone can see what comes next and how far it is:

  • one milestone per release (0.3.0, 0.4.0, ...), with a line saying what the release is about, and every issue and the release pull request in it;
  • Later for what is wanted but not planned for a release yet - a good place to look for something to work on.

Give an issue a milestone when it is planned; a milestone is closed when its release is out. Issues without one are not planned yet.

Coding Conventions

  • Python 3.11+, type hints, from __future__ import annotations.
  • Reference the UN-RFC section in docstrings where code implements one.
  • Every protocol rule gets a test. Security-relevant rejections get a negative test (see tests/test_protocol.py).
  • Commit messages: imperative mood; mention the UN-RFC if relevant.