Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
265 lines
17 KiB
Markdown
265 lines
17 KiB
Markdown
# 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](docs/PROTOCOL.md) (the authority on formats and behaviour);
|
||
how to run a node is in [README.md](README.md); the Kubernetes setup is in
|
||
[k8s/README.md](k8s/README.md). This file does not repeat them.
|
||
|
||
Status as of 2026-11-19. Check `git log` before trusting any "not built yet"
|
||
below.
|
||
|
||
## 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 30 minutes 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 `85c26ad` (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 and the "Invite someone" page 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.** Today trust is a flag. Design: existing
|
||
operators sign "this key is a real operator"; a report counts if you trust
|
||
the voucher. Then **signed blocklists** subscribed to by curator key and
|
||
fetched over libp2p (decided: not URL files).
|
||
- **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.
|
||
Not measured: relayed streams (need a node behind a NAT). 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) are the next layer.
|
||
- **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** (reports cover listings only).
|
||
|
||
**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.
|
||
|
||
## 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 add`ed 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).
|
||
- 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) |
|
||
| `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 |
|