Summary
Replace the WireGuard star-topology relay with Headscale (self-hosted Tailscale) to remove the plaintext middlebox from the vault sync data path. Currently the relay decrypts/re-encrypts between peers — it can read all traffic. Headscale gives direct P2P WireGuard tunnels when NAT allows, with encrypted DERP fallback when it doesn't.
Companion to #18 (app-level E2EE). Together they provide defense-in-depth: no server can read payload contents.
Problem
In the current WireGuard star topology, the relay at poly@37.27.48.12 holds all peer keys and acts as a Layer 3 packet forwarder. It decrypts from Peer A and re-encrypts for Peer B — meaning the relay operator can read all plaintext IP packets including file contents, entity data, and federation events.
Proposed Solution
Phase 0: Deploy Headscale coordination server on poly (parallel with existing WG)
Phase 1: Migrate admin node (Darren's MacBook) to Tailscale
Phase 2: Migrate remaining peers (Shawn, NUC, friend-e2e)
Phase 3: Rewrite federation scripts (invite token schema, bootstrap flow, onboarding)
Phase 4: Extend E2EE to domain events (defense-in-depth, see #18)
Phase 5: MagicDNS + automated discovery (stretch)
Key Properties
- Zero KOI-net core code changes — protocol is transport-agnostic (HTTP POST to
base_url)
- Zero-downtime migration — WireGuard and Tailscale run simultaneously
- Direct P2P when NAT allows — encrypted DERP fallback otherwise
- DERP relay can't decrypt — fundamentally different from current WG star topology
- Simpler onboarding —
tailscale up --authkey=<key> vs ~15-step WG dance
Scripts to Modify
setup-relay.sh → setup-headscale.sh
activate-wireguard.sh → install-tailscale.sh
bootstrap-node.sh — rewrite invite token schema (currently WG-shaped)
create-invite.sh, approve-peer.sh, connect-peers.sh, validate-node.sh, remove-peer.sh
smoke-vault-sync.sh, personal-env.template, lib.sh
Files Unchanged (transport-agnostic)
api/koi_poller.py, api/koi_net_router.py, api/vault_sync.py
api/koi_protocol.py, api/koi_envelope.py, api/event_queue.py
api/koi_encryption.py, api/federation_events.py
Full Plan
See /plans/virtual-baking-cloud.md in the repo for the detailed implementation plan with code paths, DERP strategy options, and verification steps.
References
Summary
Replace the WireGuard star-topology relay with Headscale (self-hosted Tailscale) to remove the plaintext middlebox from the vault sync data path. Currently the relay decrypts/re-encrypts between peers — it can read all traffic. Headscale gives direct P2P WireGuard tunnels when NAT allows, with encrypted DERP fallback when it doesn't.
Companion to #18 (app-level E2EE). Together they provide defense-in-depth: no server can read payload contents.
Problem
In the current WireGuard star topology, the relay at poly@37.27.48.12 holds all peer keys and acts as a Layer 3 packet forwarder. It decrypts from Peer A and re-encrypts for Peer B — meaning the relay operator can read all plaintext IP packets including file contents, entity data, and federation events.
Proposed Solution
Phase 0: Deploy Headscale coordination server on poly (parallel with existing WG)
Phase 1: Migrate admin node (Darren's MacBook) to Tailscale
Phase 2: Migrate remaining peers (Shawn, NUC, friend-e2e)
Phase 3: Rewrite federation scripts (invite token schema, bootstrap flow, onboarding)
Phase 4: Extend E2EE to domain events (defense-in-depth, see #18)
Phase 5: MagicDNS + automated discovery (stretch)
Key Properties
base_url)tailscale up --authkey=<key>vs ~15-step WG danceScripts to Modify
setup-relay.sh→setup-headscale.shactivate-wireguard.sh→install-tailscale.shbootstrap-node.sh— rewrite invite token schema (currently WG-shaped)create-invite.sh,approve-peer.sh,connect-peers.sh,validate-node.sh,remove-peer.shsmoke-vault-sync.sh,personal-env.template,lib.shFiles Unchanged (transport-agnostic)
api/koi_poller.py,api/koi_net_router.py,api/vault_sync.pyapi/koi_protocol.py,api/koi_envelope.py,api/event_queue.pyapi/koi_encryption.py,api/federation_events.pyFull Plan
See
/plans/virtual-baking-cloud.mdin the repo for the detailed implementation plan with code paths, DERP strategy options, and verification steps.References