Files
allmende/SPECS.md
T

22 KiB
Raw Blame History

Allmende: project brief for agents

Read this first. It says what the project is, what exists, what is left, and the rules the owner has set. The protocol itself is in docs/PROTOCOL.md (the authority on formats and behaviour); how to run a node is in README.md; the Kubernetes setup is in k8s/README.md. This file does not repeat them.

Status as of 2026-11-25. Check git log before trusting any "not built yet" below.

Handover: where things stand

For an agent starting fresh. Everything is committed and pushed to main; the tree was clean at the end of the last session.

State. The node is feature-complete for a first public run: identity, listings, gossip and sync, messaging, abuse reports, a web UI, metrics, an "Invite someone" page (allmende address), recovery of own listings, and measured limits (memory, relay). The manifest pins image 960a6e6. The owner applies manifests by hand; whether the cluster runs that image is theirs to say.

Decided in the last session, do not reopen without new facts

  • Message-sender abuse reports: not built (see "What is left").
  • Vouching and signed blocklists: deferred until there are enough independent operators (see "What is left").
  • The bootstrap node runs with --no-phrase on purpose: its identity lapses after a year and is replaced (k8s/README.md). Do not advise backing it up.

Nothing is in progress. Pick the next item with the owner. Candidates, with what each still needs:

Item Needs from the owner
Second bootstrap name (a dynamic-DNS host as fallback to allmende.stinnesbeck.com) the DDNS hostname (outside stinnesbeck.com) and the public node's peer ID (pod log line node running ... peer_id=...). Do not guess either
Manage the trusted-reporter list from the web UI or a file a go-ahead; small
--max-relay-reservations flag (relay holds libp2p's default 128 and refuses the rest) whether they want a different number
Real-NAT relay and hole-punching test a machine behind a NAT; cannot be done alone
Forward secrecy for messages a design decision (cost: a recovered device cannot read old messages)
Images the legal review first (§184b StGB)
Owner's signed reply to a report; reporter reputation a design decision; only after reports see real use

Traps

  • Never touch the cluster (rules below). kubectl kustomize k8s/base renders locally and is fine.
  • The args script in k8s/base/statefulset.yaml builds the command with set --: every line but the last needs a trailing \.
  • The difficulty change (16 to 24) is network-wide: old and new nodes exchange no listings.
  • Test IPs must be real public ones (1.1.1.1, 8.8.8.8): libp2p treats the documentation ranges as non-public.
  • Before killing a process, check it is yours; do not use pkill -f or pgrep -f with a pattern that also matches your own shell. Kill by PID.

The idea

Allmende is German for "commons". It is a free, distributed marketplace for buying, selling and renting property, with no central server and no company in the middle.

  • Listings are replicated across the nodes of the people who take part. Nobody owns the network, and it costs nothing to use.
  • Whoever lists runs a node (a command-line program). Searchers and buyers need only a browser: every node serves the web UI, a search API and a message relay.
  • The software is AGPL-3.0 and must stay free for everyone. The owner does not want a trademark or a company around it.
  • It starts in one region (a German state or metro area; GDPR applies) and grows from there.

Goals

  1. Anyone can search listings in a browser, with no account, and verify every listing themselves (signatures are checked in the browser; a gateway cannot forge anything).
  2. Anyone can list a property by running one binary. Non-technical people must be able to do it: the identity is a 12-word phrase, not a key file.
  3. Buyers can contact sellers privately (end-to-end encrypted, anonymous towards the network) from a browser, with no account.
  4. Nobody can switch it off or take it over. No central index, no network-wide moderation, no single bootstrap point (DNS is only a convenience).
  5. Abuse (scams, spam, illegal content) is made expensive and locally manageable, not centrally banned.

Non-goals and settled decisions (do not reopen)

  • The Go node is the product. There is no phone app and no desktop app. A Rust/Tauri rewrite was built, compared and deleted on purpose. Do not revive it.
  • Language: Go for the node, TypeScript for the web UI (embedded in the binary; web/dist/app.js is committed).
  • No account system, no payments, no ads, no tracking.
  • Personal data stays off the network: a replicated listing has no name, address, phone or email (location is a geohash of ~1 km). The exact address is released only by the owner, inside an encrypted thread.
  • Images, when built, are origin-hosted only: never replicated or cached by third parties.

How it fits together

 browser (any visitor)            node (listers run one; everyone can use any node)
 ───────────────────────          ─────────────────────────────────────────────────
 search, verify listings  ◄────►  HTTP API + embedded web UI   (internal/api, web/)
 E2E-encrypted messages           store: SQLite                 (internal/store)
 tips about abuse                 libp2p: gossip, DHT, relay    (internal/p2p)
                                  identity + certificates       (internal/identity)
  • Identity. A 12-word phrase makes a root key, shown once, never stored. It signs a certificate (at most 366 days) for a per-machine device key. The device key signs listings and is the libp2p peer ID. Lose the machine: allmende recover with the phrase signs a revocation and a new certificate. Lose the phrase: start a new identity (listings expire in 30 days anyway). The same phrase renews the certificate from the owner page in its last 30 days (same device key; the node never stores the phrase). init --no-phrase creates an identity that cannot be renewed (used for the bootstrap node).
  • Listings. Canonical JSON (RFC 8785), ed25519 signatures, proof-of-work (24 leading zero bits since 2026-11-19, was 16; pow.Mine hashes the bytes before the nonce once and finds the same nonce as trying them in order, about 4 s a listing on 8 cores; it deters casual bulk posting, not GPUs), geohash location, seq-based versions (higher wins), tombstones for deletion, at most 30 days to live (the owner renews by hand, so abandoned listings lapse).
  • Network. libp2p. Gossipsub topics per region (a 3-character geohash cell, ~150 km) plus global topics for revocations and reports. New connections sync with digests (only what differs is transferred) and a background anti-entropy round every 10 minutes (3 peers per round) repairs gossip lost while connected. Peers are found through DNS (_dnsaddr TXT records), a seed cache, a private Kademlia DHT, mDNS, and NAT traversal (port mapping, hole punching, relays through --public nodes).
  • Messaging. A buyer's browser makes a throwaway thread key per listing and seals messages to the listing's device key. Envelopes are gossiped on the region topic and held by relays for 14 days. Only the owner can read them; the owner's replies (including a signed address grant) are signed so a buyer can tell the real owner. Anti-spam: proof-of-work whose price rises as a listing's inbox fills, first-message rules (short, no links), a daily limit of new conversations, owner block.
  • Abuse reports. Signed by node operators, gossiped, never delete anything. Each node decides whose reports count (--trust-reporter, --hide-after); a flagged listing is hidden from that node's search behind a notice but stays reachable by link. Visitors can only send unsigned proof-of-work tips to the node's operator, which hide nothing.

What exists

Area State
Identity: phrase, certificates, revocation, recover done, tested
Listings: format, signing, PoW, conflict rules, expiry done
P2P: gossip, region sync, digest sync, anti-entropy, DHT, NAT traversal, DNS bootstrap, --announce done
HTTP API + embedded web UI (search, detail, in-browser verification, en/de) done
Owner UI: sign-in link, my listings, requests, conversation, release address, publish/edit/renew/delete, regions (by place name) done
Messaging: E2E crypto, relay, queues, inbox, block, adaptive PoW, address grants done
Abuse reports: record, gossip, sync, hide rule, tips, operator form and queue done (phase 1)
Place names for --region (GeoNames, CC BY 4.0) done
Expiry reminder in the terminal (≤5 days left) done
Device certificate renewal from the browser with the phrase (last 30 days; same device key, listings re-signed) done
Fast proof-of-work miner (internal/pow/mine.go), default difficulty 24 for listings, reports and revocations done; network-wide change: nodes still at 16 and nodes at 24 exchange no listings
Abuse limits: per-peer gossip rate and ban (internal/p2p/guard.go), sync stream limits, 100 listings per author, 16 inbound connections per public IP, 600 API requests a minute per client, trusted proxies for X-Forwarded-For done, tested, simulated
Packaging: Dockerfile, Nix flake and module, make image done
Kubernetes bootstrap node (k8s/, kustomize, Traefik IngressRoute; DIFFICULTY, REGION, TRUSTED_PROXY in config.env) written and deployed by the owner. The manifest now pins image 960a6e6 (digest in kustomization.yaml, pushed 2026-11-19), which has everything above, peer exchange, the faster anti-entropy, recovery of own listings, synchronous=NORMAL, batched sync storage, the idle sync timeout, the "Invite someone" page and the metrics port (9090, inside the cluster only) included; whether it is applied is the owner's to say, and the previously running image is older than digest sync, anti-entropy and reports
Load tool cmd/allmende-load (signed invented listings into a data directory, mining-time measurement) and scripts/fake-listings.mjs done. A 100,000-listing capacity test was started and dropped on purpose (owner: not a goal now); the limits noticed on the way are maxSyncPages 200 × page 500, syncTimeout 2 minutes, a ListingDigest that scans a whole region, one SQLite connection
Network simulator cmd/allmende-sim: 100-300 real nodes, latency, connection loss, attackers, seeds down, repair (results in docs/PROTOCOL.md) done
Tests: Go (-race), web (node:test + jsdom), end-to-end with real binaries (make e2e) all passing

The public bootstrap node is bootstrap.allmende.stinnesbeck.com (TCP and UDP 4001), found through _dnsaddr.allmende.stinnesbeck.com. It follows no region and trusts no reporter.

What is left

Roughly in the order the owner and I would take them. Ask the owner before starting a design-heavy item; see "Working with the owner".

Technical, designed or small

  • Fallback bootstrap list inside the binary, for networks that block DNS TXT lookups. Needs a stable address for the bootstrap node; its peer ID changes when the no-phrase identity is recreated (every ≤366 days).
  • Vouching for reporters and signed blocklists: decided not to build yet (2026-11-19, owner). Today trust is a flag (--trust-reporter). Design if it is ever needed: existing operators sign "this key is a real operator"; a key counts only if keys you trust vouch for it (depth 1, at least two distinct vouchers, vouches expire and are capped), so a spammer's ring of nodes vouching for each other is an island and counts for nothing. Blocklists would be subscribed to by curator key and fetched over libp2p (not URL files). Why not now: with one operator it adds nothing over the flag; a signed blocklist is what a signed report already is; the web of trust among strangers cannot be tested without real independent operators; and spam is already limited by proof-of-work, quotas, the peer guard and the IP gate. Reconsider when there are enough independent operators that adding trusted keys by hand is a real chore. A cheaper step first: manage the trusted-reporter list from the web UI or a file.
  • Owner's signed reply to a report, and a reputation for reporters whose reports are routinely overruled.
  • Forward secrecy for messages. Today a leaked device key reads envelopes still stored (≤14 days). Idea: rotating prekeys published in the listing. Cost: a device recovered from the phrase can never read old messages.
  • Image storage. Upload, re-encode, strip metadata, size caps, origin hosting, gateways that stream without storing, hash-list matching where access exists. Listings already have an images field of hashes.
  • Recovering listings onto an empty database is built (internal/p2p/recover.go, sync kind author): the node asks its first 3 peers per run for everything signed by its own key. It finds only what connected peers hold, so listings in a region nobody connected follows stay lost. Messages are not recovered (a recovered device cannot read old ones anyway).
  • Public node memory was measured (cmd/allmende-conns): 1000 inbound connections cost about 130 MB, 156 MB at the peak with 100 listings flooded to all of them, against the 512 MiB pod limit; the manifest sets GOMEMLIMIT=400MiB as a safety net. With a 269 MB database (50,000 listings) the same node idled at 53 MB, held 137 MB with 1000 connections and peaked at 174 MB with 1000 connections plus 30 real nodes catching up. As a relay (allmende-conns -relay): 128 reservations held of 200 asked (libp2p's default cap; 8 per address), 67 MB with 128 open circuits; a relayed connection ends after 2 min or 128 KB, so it only brings nodes into contact. With one public node at most 128 NAT'd nodes can have a relay at once; not tested with a real NAT or hole punching. The run found that a newcomer stored only ~137 listings/s with SQLite's synchronous=FULL and its 2-minute sync cut-off left 18% of a 20k region for the next round; the store now uses synchronous=NORMAL, stores a sync page in one transaction (PutMany, signatures checked in parallel), and a sync is only cut off after 2 minutes without progress (30 minutes at most). A newcomer taking 20,000 listings: 120 s and unfinished before, 24 s now.
  • What the abuse limits do not cover (internal/p2p/guard.go, ipgate.go, internal/api/ratelimit.go): attackers with many real addresses, valid but unwanted records under the limits, and bans are per node and not shared (deliberate: a shared ban could be used against honest nodes). Signed blocklists (see vouching above) would be the next layer, once there are enough operators to need them.
  • Rate limits depend on the deployment: the per-IP connection limit needs real source addresses (externalTrafficPolicy: Local; the nodeport overlay uses Cluster and hides them), and the API limit needs TRUSTED_PROXY to cover the ingress or the whole site shares one allowance.
  • Joining without the seeds: peer exchange and region-tagged peer cache are built (internal/p2p/peerexchange.go), tested with real nodes, and in the sim's "all seeds shut down" scenario a newcomer whose remembered peers are all in another region now gets everything (56 of 56; it was 0 of 114). Still open: a node that remembers no live peer at all needs a seed or the DNS name.
  • Repair is now every 10 min with 3 peers per round (median ~11 min by the sim; was ~2 h). Not measured on a real network.
  • Message-sender abuse: decided not to build (2026-11-19, owner). A buyer has no key, only a throwaway thread key (and a new ephemeral key per envelope), and only the owner can read the text. A signed, gossiped report on a thread key is dodged by a new key for one more proof-of-work, and it would publish that a private conversation happened. What exists instead: block, the link ban, the daily new-thread limit, and a price that rises as a listing's queue fills. Options not taken: a local report that also raises the price for that listing; gateway IP bans.

Decisions and non-code work (the owner's)

  • German legal review before any public launch: GDPR erasure, §184b StGB exposure for images, anti-discrimination law (AGG) content rules, and messaging. Treat this as a launch blocker.
  • Reciprocity and incentives: what nodes owe the network.
  • A project domain (allmende.io and .de are taken).
  • Run a second bootstrap node on another network; test the first from outside the home network (phone on mobile data); recreate the no-phrase identity before its certificate expires.

Deploy: building and applying a new image to the cluster is the owner's job (see rules below).

Working with the owner (rules)

These come from the owner and are not negotiable.

  • Never touch the Kubernetes cluster. No kubectl apply, no changes to live resources, ever. Write and render manifests only; the owner deploys by hand.
  • Edit files with the Edit tool (or Write for new files). Do not use Python, sed -i or similar scripts to modify files.
  • Scratch files go in .tmp/ in the project, not /tmp.
  • Run scripts/sim-sweep.sh only when the owner says so, and render graphs and dashboards locally (scripts/sim-dashboard.mjs); never publish them to claude.ai.
  • Ask design decisions with the question tool, but not routinely: pick the conventional default for small things and say so.
  • Commit and push finished work to main (allow rules for git commit and git push are set). Add the attribution trailer the harness gives you.
  • Report honestly: say when tests fail or something was skipped. Do not discard errors to make a test pass; assert the exact outcome. If you break one of these rules, say so in your report.
  • Commit trailers: Co-Authored-By and Claude-Session lines as the harness gives them.

Developing

make check        # go vet, go test -race, web typecheck + tests, end-to-end
make test         # Go tests only
make web          # rebuild web/dist after changing web/src (commit the result)
make e2e          # real nodes end to end (needs Node.js, web/node_modules)
make image        # build and push the container image (clean tree only)
  • Go module: git.stinnesbeck.com/nils/allmende, binary allmende (cmd/allmende). Remote: ssh://git@git.stinnesbeck.com:2222/nils/allmende.git.
  • Web tests run against the built bundle (web/dist/app.js): run make web (or npm run build in web/) before npm test.
  • Nix: files must be git added for nix build to see them, and vendorHash in nix/package.nix must be recomputed after go.mod or import changes.
  • The container image is pinned in k8s/base/kustomization.yaml by tag and registry digest (the local podman digest differs from the registry's; pull the tag back to read the real one).
  • Build and pin a new image (when the owner says "build and pin the new image"): commit everything first (make image needs a clean tree and tags the image with the short HEAD hash); run make image; then podman pull --policy=always git.stinnesbeck.com/nils/allmende:<hash> and podman image inspect --format '{{.Digest}}' ...:<hash>; set newTag and digest in k8s/base/kustomization.yaml with Edit; update the pin in the Kubernetes row of the table above; check with kubectl kustomize k8s/base; commit ("k8s: image and its digest (...)") and push. That commit moves HEAD, so the pinned tag is always the commit before it. Tell the owner to run kubectl apply -k k8s/base; never run it yourself.
  • Scratch and background work: put test data in .tmp/; stop any background watcher or test node you started before reporting done.
  • Protocol changes must keep old nodes working: the deployed bootstrap node runs an older version. New sync kinds fall back to the original full pull when a peer does not know them.
  • Tests are part of the job. Every feature so far has Go tests, web tests where the UI changed, and an e2e.sh step where a real binary must be wired correctly.

Map of the code

Path What
cmd/allmende CLI: init, run, recover, address (the address others can join through), version; flags; terminal notices; shutdown
internal/identity phrase → root key, certificates, device keys, revocations
internal/listing the listing record: seal, check, regions, geohash
internal/message encrypted envelopes, plaintext rules, sealing (mirrored in web/src/message.ts, checked against a golden fixture)
internal/report the signed abuse report
internal/store SQLite: listings, messages, inbox, reports, tips; conflict rules; hide rule
internal/p2p libp2p node, topics, validators, sync, discovery; guard.go (per-peer limits and bans), ipgate.go (connections per IP)
internal/inbox the owner's conversations, replies, block
internal/api HTTP API (public reads, relay, admin); ratelimit.go (per-client limit, trusted proxies); metrics.go (Prometheus text on the separate --metrics listener)
internal/places, internal/jcs, internal/pow place names, canonical JSON, hashcash (pow.Mine, the fast miner)
cmd/allmende-sim, cmd/allmende-load, cmd/allmende-conns network simulator; load and mining-time tool; holds many connections to one node to measure its memory
web/ TypeScript UI (embedded), tests, build; web/static/places.tsv is generated
k8s/, nix/, Dockerfile deployment
scripts/e2e.sh, scripts/e2e/ end-to-end with real binaries and jsdom