1.10. Pluggable Protocol Architecture & Ecosystem Interoperability

1.10.1. Pluggable Protocol Architecture & Ecosystem Interoperability Specification

1.10.1.1. Deep Architectural Analysis and Implementation Blueprint for AT Protocol, ActivityPub, and Secure Scuttlebutt (SSB)


1.10.1.2. 1. Executive Summary & Problem Statement

Fleetmesh (fleetmesh.org) is designed as a sovereign, verifiable edge compute, storage, and networking fabric. At its inception, Fleetmesh adopted open protocols: Nostr (NIP-01, NIP-11, NIP-42, NIP-44, NIP-59, NIP-77) for relaying, peer discovery, and encrypted transport; Blossom (BUD-01..04) for content-addressable blob storage; Cashu (NUT-00..24) for ecash settlement and paid fetch; and DIDComm v2 for internal mesh messaging.

However, the current node runtime (meshnode) embeds these protocol families directly into core components:

  1. Hardcoded Relay Face: NodeApp.face unconditionally binds and starts a Nostr RelayServer over WebSocket/HTTP.

  2. Coupled Transport Ladder: TransportRouter assumes the fallback rung is a Nostr relay transport (RelayRung), with protocol-specific framing embedded in envelope unpackers.

  3. Rigid Storage Schema: Event stores and blob servers are tightly wired to Nostr event structures and Blossom HTTP routes.

1.10.1.2.1. The Strategic Imperative

The decentralized web is rapidly coalescing around major sovereign protocol ecosystems:

  • ATProto (Authenticated Transfer Protocol): The open protocol underpinning Bluesky, characterized by self-sovereign DIDs (did:plc, did:web), Merkle Search Trees (MST), IPLD/DAG-CBOR repositories, XRPC APIs, and the firehose event stream (com.atproto.sync.subscribeRepos).

  • ActivityPub (W3C): The federated social web standard (Fediverse / Mastodon), featuring Actor models, WebFinger discovery, ActivityStreams 2.0 (JSON-LD), and HTTP Signatures over Inbox/Outbox HTTP endpoints.

  • Secure Scuttlebutt (SSB): An offline-first, peer-to-peer append-only log protocol based on Secret Handshake (SHS), Box Stream, and MuxRPC over raw TCP.

Fleetmesh must not be locked into a single protocol dialect. We must transform Fleetmesh into a Pluggable Multi-Protocol Node Runtime, where:

  • Each protocol family (Nostr, ATProto, ActivityPub, SSB) is an independent, modular package that can be enabled or disabled declaratively in config.json.

  • A disabled protocol incurs zero listening ports, zero background threads, zero storage overhead, and zero capability advertisements.

  • The node core can run purely as an ATProto Personal Data Server (PDS) or edge relay, purely as an ActivityPub actor node, purely as a private DIDComm/FIPS/Iroh mesh node, or as a multi-protocol gateway bridging all of them.

  • Fleetmesh’s unique superpowers—bilateral token-bucket budgets, capacity evaluation, verifiable WASM compute, and Cashu micro-settlements—can be applied to protect and monetize foreign protocol surfaces against crawler storms and spam.


1.10.1.3. 2. Codebase Audit: State of Protocol Modularity Today

A comprehensive audit of meshnode and fleetmesh_core reveals both significant structural strengths and specific architectural pinch points that must be decoupled.

+---------------------------------------------------------------------------------------+
|                               CURRENT COUPLING MATRIX                                 |
+-------------------+-------------------------------------------------------------------+
| Layer             | Hardcoded Nostr / Blossom Couplings                               |
+-------------------+-------------------------------------------------------------------+
| Ingress / Host    | - NodeApp.__init__ unconditionally constructs RelayServer         |
|                   | - NodeApp.start() unconditionally binds face.host:face.port       |
|                   | - Socket assumes WebSocket (NIP-01) or ws.PlainHTTP (NIP-11/BUD)  |
|                   | - Foreign HTTP handlers must hack into face.http_handlers list    |
+-------------------+-------------------------------------------------------------------+
| Transport Egress  | - TransportRouter._send_ladder appends 'nostr' as hard floor      |
|                   | - Assumes all messages are DIDComm JWEs wrapped in NIP-59         |
|                   | - DidcommInbound unwrap expects Nostr gift-wrap envelopes         |
+-------------------+-------------------------------------------------------------------+
| Storage Engine    | - MeshStoreProtocol enforces Nostr event dict (kind, tags, sig)   |
|                   | - NodeStore indexes strictly by event_id, pubkey, kind, created_at|
|                   | - SyncProtocol & Negentropy sync Nostr event ID sets (NIP-77)     |
+-------------------+-------------------------------------------------------------------+
| Configuration     | - No top-level "protocols" block in NodeConfig                    |
|                   | - Nostr relay face cannot be disabled                             |
|                   | - Zero-overhead disabled state does not exist                     |
+-------------------+-------------------------------------------------------------------+
| Wire Codecs       | - fleetmesh_core/wire/cbor.py rejects Major Type 6 (tags),        |
|                   |   blocking Tag 42 required for ATProto IPLD CIDs                  |
+-------------------+-------------------------------------------------------------------+

1.10.1.3.1. 2.1 Existing Modularity Strengths

  1. Strict Interoperability Policy (meshnode/docs/interop.md):

    • “Reuse before invent”: Open protocols are spoken unchanged; peering, budgets, and settlement belong to Fleetmesh.

    • “Foreign protocols are dialects, not forks”: Capabilities are announced with native c tags rather than rebranded under https://fleetmesh.org/.

    • Conformance is verified against upstream test vectors (scripts/check-interop.py).

  2. Cryptographic Foundations (core/fleetmesh_core/crypto/keys.py):

    • The node generates and manages three fundamental keys:

      • node: secp256k1 (multicodec 0xe7 0x01), BIP-340 Schnorr. Directly reusable for ATProto K-256 (did:key:zQ3sh...).

      • agreement: X25519 (multicodec 0xec 0x01). Reusable for SSB Box Stream ECDH.

      • transport: Ed25519 (multicodec 0xed 0x01). Directly reusable for ActivityPub HTTP Signatures and SSB feed identities (@<pubkey>.ed25519).

  3. CIDv1 Codec (core/fleetmesh_core/identity/cid.py):

    • sha256_to_cid() and cid_to_sha256() map between Blossom hex digests and IPFS CIDv1 multibase ‘b’ (raw sha2-256 bafkrei...), establishing the foundation for cross-protocol blob sharing.

  4. Transport Ladder Abstraction (meshnode/fleetmesh_node/transport/):

    • TransportRouter negotiates between fips-native, iroh, and libp2p using RungProtocol and per-rung circuit breakers (ladder.py).

  5. Compartment Worker Model (meshnode/fleetmesh_node/compartment/):

    • Clean actor isolation where workers tick, report health, declare channels, and register DIDComm handlers.

1.10.1.3.2. 2.2 Coupling Points in the Current Codebase

1.10.1.3.2.1. 1. Ingress & Host Face Coupling (meshnode/fleetmesh_node/app/core.py & meshnode/fleetmesh_node/nostr/relayserver.py)

In meshnode/fleetmesh_node/app/core.py:

  • Lines 239–252: NodeApp.__init__ unconditionally instantiates self.face = relayserver.RelayServer(...).

  • Line 569: NodeApp.start() unconditionally executes self.face.start().

  • RelayServer binds the edge socket directly. It attempts an RFC 6455 WebSocket handshake for every incoming connection; if the handshake fails, it catches ws.PlainHTTP and dispatches to NIP-11, Blossom (BUD-01/02/04), /metrics, and /gossip.

  • Compartments requiring HTTP exposure (e.g. nsite and linked) must mutate self.face.http_handlers.

  • Result: Non-Nostr protocols cannot cleanly mount HTTP endpoints, WebSockets, or path-based APIs without coupling to RelayServer.

1.10.1.3.2.2. 2. Transport Ladder Coupling (meshnode/fleetmesh_node/transport/router.py)

In meshnode/fleetmesh_node/transport/router.py:

  • Lines 541–542 (_send_ladder):

    if 'nostr' not in order:
        order.append('nostr')
    
  • Line 523: Direct fallback to self.nostr.send(..., stored=True) when store-and-forward is requested.

  • Inbound unwrap (didcomm_inbound.open_inbound) expects NIP-59 gift-wrapped events or DIDComm JWEs.

  • Result: If Nostr is disabled or omitted, message routing fails. The ladder cannot treat foreign transport rungs (e.g. SSB TCP, ATProto sync) as first-class citizens.

1.10.1.3.2.3. 3. Storage Engine Coupling (core/fleetmesh_core/wire/interfaces.py & core/fleetmesh_core/storage/)
  • MeshStoreProtocol defines insert_event(event: Mapping[str, Any], now: int) -> str and enumerate_range(filt: ...).

  • The backing tables in SQLite (fleetmesh_node/nostr/eventstore.py) and PostgreSQL (core/fleetmesh_core/storage/store_postgres.py) assume Nostr event structures (id, pubkey, created_at, kind, tags, content, sig).

  • SyncPeer (fleetmesh_node/planes/store/sync/) and Negentropy (fleetmesh_core/storage/negentropy.py) operate on 32-byte Nostr event ID sets.

  • Result: Storing ATProto MST nodes or ActivityStreams JSON-LD objects requires dedicated storage adapters or table schemas.

1.10.1.3.2.4. 4. CBOR Codec Limitations (core/fleetmesh_core/wire/cbor.py)
  • Line 9: “Major type 6 (tags) is deliberately unhandled: nothing this node reads carries one…”

  • In DAG-CBOR (RFC 8949 + IPLD), CIDs are encoded as CBOR Tag 42 (0xd8 0x2a).

  • Result: Parsing ATProto commits, records, or MST blocks currently raises CBORError: unhandled CBOR major type: 6.


1.10.1.4. 3. Architecture & Design Principles

+-----------------------------------------------------------------------------------+
|                                 Node Daemon Core                                  |
|  +--------------------+  +----------------------+  +---------------------------+  |
|  | Keystore & DID     |  | Budget & Capacity    |  | Verified Storage Engines  |  |
|  | (ed25519/secp256k1)|  | (AIMD Token Buckets) |  | (SQLite, Postgres, CAS)   |  |
|  +--------------------+  +----------------------+  +---------------------------+  |
|                                       |                                           |
|                  +------------------------------------+                           |
|                  |    ProtocolHostRouter (Multiplex)  |                           |
|                  |   Public Port (8000 / 443 with TLS)|                           |
|                  +------------------------------------+                           |
+-----------------------------------|-----------------------------------------------+
                                    |
          +-------------------------+-------------------------+---------------------+
          |                         |                         |                     |
+-------------------+     +-------------------+     +-------------------+     +-------------+
|  fleetmesh-nostr  |     | fleetmesh-atproto |     | fleetmesh-actpub  |     | fleetmesh-  |
| (NIP-01..77, BUD) |     | (XRPC, Firehose,  |     | (ActivityStreams, |     |     ssb     |
|                   |     |  MST, did:plc)    |     |  WebFinger, Inbox)|     | (SHS, MuxRPC|
+-------------------+     +-------------------+     +-------------------+     |  TCP 8008)  |
          |                         |                         |               +-------------+
     [Nostr Relays]           [Bluesky PDS]           [W3C Fediverse]          [SSB Network]

1.10.1.4.1. Principle 1: A Protocol is a Suite, Not a Single Compartment

A compartment in Fleetmesh (fleetmesh_node/compartment/base.py) is an in-process worker that ticks, holds state, handles DIDComm PIURIs, and can front a sidecar. A Protocol Suite is a higher-level subsystem spanning multiple layers:

  1. Ingress / Server Face: HTTP routes, WebSocket handlers, or raw socket listeners.

  2. Egress / Transport Rung: Outbound delivery mechanisms integrated into TransportRouter.

  3. Identity & Resolution: Resolving protocol-specific identifiers (did:plc, acct:user@domain, npub, @feed.ed25519) and mapping them to/from the node’s native cryptographic keys.

  4. Record / Content Storage: Adapting protocol-specific schemas (MST DAG-CBOR, ActivityStreams JSON-LD, Nostr Events, SSB append-only logs) to backing relational stores or CAS blob storage.

  5. Capability Advertisement: Announcing capabilities in the node’s descriptor (kind 11801) and protocol-native metadata endpoints (e.g. NIP-11, /.well-known/atproto-did, WebFinger).

1.10.1.4.2. Principle 2: Zero-Overhead Disabled State

When a protocol is disabled ("enabled": false or omitted):

  • No network ports or sockets are opened.

  • No HTTP or WebSocket endpoints are mounted.

  • No background tick routines or crawler threads are spawned.

  • No capability tags are placed into the node’s descriptor.

  • Memory consumption and startup latency for that protocol suite drop to absolute zero.

1.10.1.4.3. Principle 3: Standards Fidelity & Origin Sovereignty

Adhering to Fleetmesh’s core policy in meshnode/docs/interop.md:

  • Foreign protocols are spoken verbatim as published by their respective governing standards (com.atproto.* by Bluesky, W3C ActivityStreams/ActivityPub by W3C, NIPs by Nostr, Scuttlebutt Protocol Guide by SSB).

  • Foreign protocols are never forked, rebranded, or placed under https://fleetmesh.org/.

  • Every protocol package must prove conformance using test vectors directly from upstream specifications.

1.10.1.4.4. Principle 4: Unified Ingress Multiplexing (ProtocolHostRouter)

Rather than forcing each protocol to bind its own arbitrary TCP port, Fleetmesh introduces ProtocolHostRouter: a unified, high-performance HTTP and WebSocket request router. A single public edge port (e.g., 8000 or 443 behind TLS) cleanly hosts:

  • GET /xrpc/*, POST /xrpc/* -> Routed to ATProto XRPC engine.

  • GET /xrpc/com.atproto.sync.subscribeRepos -> Routed to ATProto Firehose WebSocket.

  • GET /.well-known/atproto-did -> Routed to ATProto DID verification.

  • GET /.well-known/webfinger -> Routed to ActivityPub WebFinger discovery.

  • POST /users/{id}/inbox -> Routed to ActivityPub federation ingress.

  • GET /users/{id} -> Routed to ActivityPub Actor document.

  • GET / with Upgrade: websocket -> Routed to Nostr NIP-01 relay server (if enabled).

  • GET / with Accept: application/nostr+json -> Routed to Nostr NIP-11 relay info.

  • PUT /upload, GET /{sha256} -> Routed to Blossom Content-Addressable Blob server.

Dedicated non-HTTP protocols (such as SSB on TCP port 8008 or FIPS on Unix Domain Sockets) declare standalone socket bindings.


1.10.1.5. 4. Core Protocol Package Abstraction

The unified protocol package specification is defined in fleetmesh_core.wire.interfaces and enforced via ProtocolPackage:

from __future__ import annotations
from dataclasses import dataclass
from typing import (
    Any,
    Callable,
    Mapping,
    Optional,
    Protocol,
    Sequence,
    TypeVar,
    runtime_checkable,
)

@dataclass(frozen=True)
class ProtocolHealth:
    healthy: bool
    status: str
    connections_active: int
    messages_in: int
    messages_out: int
    errors: Sequence[str] = ()

@dataclass(frozen=True)
class RouteMatch:
    path_prefix: str
    methods: tuple[str, ...]
    handler: Callable[[Any], Any]
    is_websocket: bool = False

@runtime_checkable
class ProtocolHostRouter(Protocol):
    """Unified HTTP / WebSocket multiplexer mounted on the node's public port."""
    def mount_route(self, prefix: str, handler: Callable[..., Any], methods: Sequence[str] = ('GET',)) -> None: ...
    def mount_websocket(self, path: str, handler: Callable[..., Any]) -> None: ...
    def unmount_all(self, owner: str) -> None: ...

@runtime_checkable
class ProtocolIdentityAdapter(Protocol):
    """Translates between Fleetmesh keys and foreign protocol identity models."""
    def resolve_id(self, uri: str) -> Optional[str]: ...
    def sign_assertion(self, payload: bytes) -> bytes: ...
    def verify_assertion(self, payload: bytes, signature: bytes, pubkey: str) -> bool: ...

@runtime_checkable
class ProtocolPackage(Protocol):
    """The formal interface every pluggable protocol package implements."""
    name: str                           # e.g., 'atproto', 'activitypub', 'nostr', 'ssb'
    version: str                        # e.g., '1.0.0'
    standards: tuple[str, ...]          # e.g., ('com.atproto.sync', 'did:plc', 'NIP-01')

    def configure(self, config: Mapping[str, Any]) -> None:
        """Parse, validate, and store the protocol-specific configuration block."""
        ...

    def identity_adapter(self, keystore: Any) -> Optional[ProtocolIdentityAdapter]:
        """Return the identity and cryptographic adapter for this protocol family."""
        ...

    def mount_ingress(self, host: ProtocolHostRouter) -> None:
        """Register HTTP and WebSocket route handlers onto the shared public host face."""
        ...

    def transport_rung(self, context: Any) -> Optional[Any]:
        """Return an outbound TransportProtocol rung for TransportRouter, if supported."""
        ...

    def compartments(self) -> tuple[type[Any], ...]:
        """Return any background Compartment classes to splice into NodeApp MANIFEST."""
        ...

    def start(self) -> None:
        """Boot the protocol runtime (open sockets, connect to upstreams)."""
        ...

    def stop(self) -> None:
        """Gracefully terminate connections and release listeners."""
        ...

    def health(self) -> ProtocolHealth:
        """Return real-time operational metrics and health status."""
        ...

    def descriptor_capabilities(self) -> tuple[tuple[str, str], ...]:
        """Return protocol capability tags (e.g. ('c', 'https://atproto.com/...')) for kind 11801."""
        ...

1.10.1.6. 5. Deep-Dive Implementation Specifications

1.10.1.6.1. 5.1 ATProto (Bluesky Ecosystem)

+-------------------------------------------------------------------------------+
|                       fleetmesh-protocol-atproto                              |
|                                                                               |
|  +--------------------+  +----------------------+  +-----------------------+  |
|  | Identity & Auth    |  | Repo Engine (MST)    |  | Ingress / Egress      |  |
|  | - did:plc resolver |  | - DAG-CBOR Commits   |  | - XRPC HTTP API       |  |
|  | - did:web resolver |  | - CAR File Exporter  |  | - Firehose WebSocket  |  |
|  | - K-256/P-256 Sign |  | - Blossom CAS Blobs  |  | - Upstream PDS Client |  |
|  +--------------------+  +----------------------+  +-----------------------+  |
+-------------------------------------------------------------------------------+
1.10.1.6.1.1. 5.1.1 Identity & Cryptography Mapping
  • DIDs: ATProto relies on did:plc and did:web.

    • Fleetmesh’s keystore already generates and manages secp256k1 (K-256) keys for Nostr.

    • The ATProto package maps the node’s secp256k1 key directly to an ATProto signing key (did:key:zQ3sh...).

    • An ATProto DID document is generated and published to did:plc directory or served at /.well-known/did.json for did:web.

  • Handle Resolution:

    • Handles (e.g. alice.meshnode.net) are resolved via DNS TXT (_atproto.alice.meshnode.net) or HTTP (https://alice.meshnode.net/.well-known/atproto-did).

    • The package includes a caching handle resolver integrating fleetmesh_node/transport/dnstxt.py and fleetmesh_node/transport/netfetch.py.

1.10.1.6.1.2. 5.1.2 Data Model: Merkle Search Trees (MST) & CAR Archives
  • Wire Codec Upgrade (fleetmesh_core/wire/cbor.py):

    • Add support for CBOR Major Type 6 (Tags), specifically Tag 42 (IPLD Link).

    • Form: 0xd8 0x2a followed by byte string b'\x00' + multihash.

    • Enforce canonical sorting rules per RFC 8949 and DAG-CBOR specs.

  • Records: ATProto stores user records (app.bsky.feed.post, app.bsky.actor.profile, etc.) in a Merkle Search Tree (MST) serialized using DAG-CBOR.

  • Commit Log & CAR Engine (fleetmesh_core/storage/car.py):

    • Every update creates a signed commit pointing to the new MST root CID.

    • Commits are packaged into Content-Addressable aRchives (CAR files).

  • Fleetmesh Storage Integration:

    • MST nodes and commit metadata are indexed in Fleetmesh’s SQLite / PostgreSQL storage engine.

    • Unified Blossom CAS Integration: Media attachments (avatars, banners, post images) are content-addressed by CID (raw SHA-256 multihash bafkrei...). Fleetmesh’s cid.py (cid_to_sha256) translates CIDs to SHA-256 hex strings, allowing them to be stored and fetched directly from Fleetmesh’s Blossom BlobStore (BUD-01). This provides immediate deduplication and unified storage across Nostr and ATProto!

1.10.1.6.1.3. 5.1.3 Wire & API Surfaces
  • XRPC Ingress:

    • Mounted on /xrpc/*.

    • Implements core Lexicon methods:

      • com.atproto.server.describeServer

      • com.atproto.sync.getRepo (returns CAR stream)

      • com.atproto.sync.getRecord

      • com.atproto.sync.getBlob (redirects/streams from Blossom store)

      • com.atproto.repo.getRecord, com.atproto.repo.listRecords

  • Firehose Ingress / Egress:

    • Ingress: GET /xrpc/com.atproto.sync.subscribeRepos serving real-time DAG-CBOR commit blocks to downstream indexers (AppViews).

    • Egress: WebSocket client subscribing to Bluesky Relay firehoses (wss://bsky.network/xrpc/...), filtering records, and caching them locally.

1.10.1.6.1.4. 5.1.4 Fleetmesh Bilateral Budget Protection

Crawling the ATProto firehose generates significant network and CPU load. Fleetmesh integrates its bilateral token-bucket budgets (CapacityLedger):

  • Downstream firehose consumers must establish peering contracts or authenticate with Cashu tokens (NUT-24 / paid fetch).

  • Unauthenticated consumers are rate-limited via AIMD (Additive Increase, Multiplicative Decrease) token buckets.


1.10.1.6.2. 5.2 ActivityPub (W3C Fediverse)

+-------------------------------------------------------------------------------+
|                      fleetmesh-protocol-activitypub                           |
|                                                                               |
|  +--------------------+  +----------------------+  +-----------------------+  |
|  | WebFinger & Actor  |  | ActivityStreams 2.0  |  | Ingress / Egress      |  |
|  | - /.well-known/    |  | - JSON-LD Processor  |  | - POST /inbox         |  |
|  |   webfinger        |  | - Object / Collection|  | - GET /outbox         |  |
|  | - Actor Document   |  |   Store              |  | - HTTP Signatures S2S |  |
|  +--------------------+  +----------------------+  +-----------------------+  |
+-------------------------------------------------------------------------------+
1.10.1.6.2.1. 5.2.1 Identity & WebFinger
  • Actor URI: Actors are identified by HTTPS URIs: https://<domain>/users/<username>.

  • WebFinger: Mounted on GET /.well-known/webfinger?resource=acct:<user>@<domain>. Returns JRD (JSON Resource Descriptor) pointing to the Actor URI.

  • Actor Document: Returns ActivityStreams 2.0 JSON-LD containing:

    • id, type: Person or Service.

    • inbox: https://<domain>/users/<username>/inbox

    • outbox: https://<domain>/users/<username>/outbox

    • publicKey: Ed25519 or RSA public key PEM. Fleetmesh uses its native Ed25519 identity key (did:key:z6M...).

1.10.1.6.2.2. 5.2.2 Wire & Federation
  • S2S Ingress (POST /inbox and POST /users/{id}/inbox):

    • Receives inbound federated activities: Create, Follow, Announce (boost), Like, Undo, Delete.

    • Authenticates sender using HTTP Signatures (RFC 9421 / draft-cavage) by fetching remote actor’s public key.

  • S2S Egress:

    • Delivers signed activities to remote followers’ inboxes using HTTP POST with HTTP Signatures signed by the node’s Ed25519 key.

  • Database Schema (fleetmesh_node/storage/activitypub.sqlite):

    • actors: (uri, username, domain, public_key_pem, inbox_url, updated_at)

    • activities: (id, actor_uri, type, object_json, published_at, local)

    • followers: (actor_uri, target_user, followed_at)

    • inbox: (id, activity_id, recipient, read_at)

  • Spam & DDoS Protection via Fleetmesh Capacity Engine:

    • Remote federated instances sending invalid activities or spamming the inbox are subjected to Fleetmesh’s StrainLedger penalty scores and throttled automatically.


1.10.1.6.3. 5.3 Secure Scuttlebutt (SSB)

+-------------------------------------------------------------------------------+
|                         fleetmesh-protocol-ssb                                |
|                                                                               |
|  +--------------------+  +----------------------+  +-----------------------+  |
|  | Secret Handshake   |  | Box Stream & MuxRPC  |  | Append-Only Log       |  |
|  | - SHS 4-phase KEX  |  | - Framing & Ciphers  |  | - Feed verification   |  |
|  | - Curve25519/Ed25519 - JSON/Binary Duplex   |  | - Monotonic sequences |  |
|  +--------------------+  +----------------------+  +-----------------------+  |
+-------------------------------------------------------------------------------+
1.10.1.6.3.1. 5.3.1 Architecture: Why SSB is Structurally Distinct

Unlike ATProto and ActivityPub (which are HTTP/WebSocket based), SSB operates over raw TCP streams (port 8008) with peer-to-peer discovery (LAN UDP broadcasts) and custom binary encryption framing.

1.10.1.6.3.2. 5.3.2 Secret Handshake (SHS) & Box Stream
  1. Secret Handshake (SHS):

    • 4-phase cryptographic key exchange using:

      • Ephemeral Curve25519 keys,

      • Long-term Ed25519 identity keys (converted to Curve25519 via crypto_sign_ed25519_pk_to_curve25519),

      • 32-byte network capability key (“caps” key, e.g. mainnet d4a1da283c1e443e022da12bc6139952b324e4001f40fa38ba5754035a49807f).

    • Guarantees mutual authentication, forward secrecy, and identity hiding.

  2. Box Stream Framing:

    • Encrypts all subsequent TCP traffic into 34-byte header frames (18-byte chunk length MAC + payload MAC) using XSalsa20-Poly1305 or ChaCha20-Poly1305.

1.10.1.6.3.3. 5.3.3 MuxRPC Protocol
  • Asynchronous bidirectional RPC protocol over Box Stream.

  • Supports five call styles: async, sync, source (pull stream), sink, and duplex.

  • Core methods:

    • createHistoryStream: Pulls message logs starting from sequence number $N$.

    • gossip.ping: Heartbeat and latency tracking.

    • blobs.get: Retrieves content-addressed blobs by SHA-256 hash &<sha256>.sha256.

1.10.1.6.3.4. 5.3.4 Dual Implementation Options in Fleetmesh:
  • Option A (In-Tree Asyncio Server): An asyncio TCP server in fleetmesh_node/planes/transport/ssb/ implementing SHS and Box Stream.

  • Option B (SSB Sidecar Daemon - Recommended):

    • Follows Fleetmesh’s existing FIPS and libp2p sidecar architecture (fleetmesh_node/sidecar/fleetmesh_ssb.py).

    • Communicates with the main meshnode process over a Unix domain socket (ssb.sock).

    • Plugs into TransportRouter as an outbound rung:

      class SSBRung(Rung):
          name = 'ssb'
          rank = 25
      

1.10.1.6.4. 5.4 Nostr & Blossom — Decoupled Package

The existing fleetmesh_node/nostr/ implementation is decoupled into fleetmesh-protocol-nostr:

  • Ingress: NIP-01 WebSocket relay (RelayServer), NIP-11 relay information, BUD-01/02 Blossom blob endpoints.

  • Transport Rung: RelayRung for NIP-59 gift-wrapped DIDComm messages.

  • Storage: Event store and retention rules (NodeStore).

  • Enabling/Disabling: If disabled, no Nostr WebSocket listener opens and no Nostr subscriptions are initiated. Operators can run a pure ATProto/ActivityPub node without Nostr overhead.


1.10.1.7. 6. Unified Ingress Host Architecture (ProtocolHostRouter)

To avoid port fragmentation, ProtocolHostRouter multiplexes all HTTP and WebSocket traffic through a single port:

                                  Incoming TCP (Port 8000)
                                             |
                                [ProtocolHostRouter Multiplexer]
                                             |
         +------------------+---------------+------------------+------------------+
         | (Upgrade: WS)    | (Path: /xrpc) | (Path: /users)   | (Path: /upload)  |
         v                  v               v                  v                  v
  +--------------+   +--------------+ +--------------+  +--------------+   +--------------+
  | Nostr NIP-01 |   | ATProto XRPC | | ActivityPub  |  | Blossom Blob |   | /.well-known |
  | Relay Server |   | & Firehose WS| | Inbox/Outbox |  | BUD-01 CAS   |   | Discovery    |
  +--------------+   +--------------+ +--------------+  +--------------+   +--------------+

1.10.1.7.1. Route Dispatching Rules

  1. Path-Prefix Matching:

    • /xrpc/ -> Dispatched to fleetmesh-protocol-atproto.

    • /users/, /actors/, /inbox/ -> Dispatched to fleetmesh-protocol-activitypub.

    • /upload, /[a-f0-9]{64} -> Dispatched to Blossom CAS storage.

  2. Standard Discovery Well-Knowns:

    • /.well-known/atproto-did -> ATProto DID identity.

    • /.well-known/webfinger -> ActivityPub WebFinger JRD.

    • /.well-known/did.json -> W3C DID document.

  3. Root (/) Protocol Negotiation:

    • If Upgrade: websocket: Handed to Nostr Relay WebSocket handler (or ATProto firehose if on /xrpc/com.atproto.sync.subscribeRepos).

    • If Accept: application/nostr+json: Handed to NIP-11 Relay Information handler.

    • If Accept: application/activity+json, application/ld+json: Handed to ActivityPub root Actor handler.

    • Default: Returns node overview, supported protocols, and capability links.


1.10.1.8. 7. Declarative Configuration Schema

The node configuration (config.json) introduces the top-level protocols block:

{
  "class": "edge",
  "name": "edge-alpha",
  "storage": {
    "engine": "sqlite",
    "path": "node.db"
  },
  "protocols": {
    "host": {
      "listen": "0.0.0.0",
      "port": 8000,
      "public_url": "https://mesh.fleetmesh.org"
    },
    "nostr": {
      "enabled": true,
      "relays": ["wss://relay.damus.io"],
      "require_auth": false,
      "blossom": {
        "enabled": true,
        "max_bytes": 104857600
      }
    },
    "atproto": {
      "enabled": true,
      "handle": "node.fleetmesh.org",
      "service_did": "did:web:node.fleetmesh.org",
      "pds": {
        "enabled": true,
        "allow_registration": false
      },
      "firehose": {
        "relay_upstream": "wss://bsky.network/xrpc/com.atproto.sync.subscribeRepos",
        "subscribe": true,
        "publish": true
      },
      "metered_peering": true
    },
    "activitypub": {
      "enabled": true,
      "domain": "social.fleetmesh.org",
      "summary": "Fleetmesh Sovereign Edge Node",
      "rate_limit_per_inbox": 60,
      "allow_local_federation": false
    },
    "ssb": {
      "enabled": false,
      "port": 8008,
      "caps": "d4a1da283c1e443e022da12bc6139952b324e4001f40fa38ba5754035a49807f"
    }
  }
}

allow_local_federation (ActivityPub) and allow_local_peers (p2panda) are dev/LAN-only opt-ins, off by default. Turning one on lets outbound federation or a p2panda push reach a loopback or private address; whenever it is off the fetch keeps the full SSRF policy.


1.10.1.9. 8. Cross-Protocol Federation & Value Proposition

Why run these protocols on Fleetmesh instead of running independent standalone daemons?

+-------------------------------------------------------------------------------+
|                      Fleetmesh Cross-Protocol Federation                      |
|                                                                               |
|       Nostr (Kind 1 Note) <-------------> ActivityPub (Create{Note})          |
|                ^                                  ^                           |
|                |                                  |                           |
|                +------------> ATProto <-----------+                           |
|                        (app.bsky.feed.post)                                   |
|                                 ^                                             |
|                                 |                                             |
|                                 v                                             |
|                             SSB (post)                                        |
|                                                                               |
|  * Unified CAS Blob Storage: One image uploaded once serves Blossom, Bluesky, |
|    Fediverse, and Scuttlebutt media attachments without data duplication.     |
|  * Bilateral Token-Bucket Defense: Protection against crawler scrapers.       |
|  * Cashu Micro-Settlement: Paid firehose access and monetization.             |
+-------------------------------------------------------------------------------+

1.10.1.9.1. 8.1 Identity Cross-Mapping

Dimension

Nostr

ATProto

ActivityPub

Secure Scuttlebutt

Identifier

npub1... (bech32)

did:plc:... / did:web:...

acct:user@domain

@<base64>.ed25519

Signing Key

secp256k1 (Schnorr BIP-340)

secp256k1 (K-256) / P-256

ed25519 / RSA

ed25519

Encryption

secp256k1 ECDH / NIP-44

P-256 / secp256k1

X25519 JWE / RSA

curve25519 Box Stream

Fleetmesh Key

node_pk (node)

node_pk (node)

transport_pk (transport)

transport_pk (transport)

1.10.1.9.2. 8.2 Data Model Translation

Operation

Nostr

ATProto

ActivityPub

SSB

Text Post

Kind 1 Event

app.bsky.feed.post

Create { type: "Note" }

type: "post"

Profile

Kind 0 Metadata

app.bsky.actor.profile

Person { ... }

type: "about"

Follow

Kind 3 Contact List

app.bsky.graph.follow

Follow { ... }

type: "contact"

Reaction

Kind 7 Reaction

app.bsky.feed.like

Like { ... }

type: "vote"

Media Blob

Blossom SHA-256 hex

CIDv1 raw sha2-256 (bafkrei...)

URL / Attachment

&<sha256>.sha256

1.10.1.9.3. 8.3 Fleetmesh Core Superpowers Applied to Foreign Protocols

  1. Unified Storage Plane (Blossom CAS as Single Source of Truth):

    • In ATProto, media blobs are SHA-256 multihash CIDs (bafkrei...). In Blossom (Nostr), blobs are SHA-256 hex strings. In ActivityPub, media is referenced by URL. In SSB, blobs are &<hash>.sha256.

    • Fleetmesh unifies all media into the local content-addressable BlobStore. A media file uploaded via Blossom is instantly resolvable as an ATProto blob, an ActivityPub attachment, or an SSB blob without data duplication.

  2. Economic Defense & Micropayments:

    • ATProto firehoses and ActivityPub inboxes are notoriously vulnerable to scraping and DDoS spam.

    • Fleetmesh applies bilateral peering tokens (CapacityLedger) and Cashu ecash (NUT-24 Paid Fetch) to inbound firehose and S2S traffic, creating the first economically defended federated server.

  3. Decentralized Multi-Protocol Identity:

    • A single Fleetmesh node identity maintains cryptographic linkages across all ecosystems:

      • Nostr: npub1... (secp256k1)

      • ATProto: did:plc:... / did:web:... (secp256k1)

      • ActivityPub: https://domain/users/node (ed25519)

      • DIDComm: did:key:z6M... (ed25519)

      • SSB: @<ed25519-key>.ed25519

    • These are published in signed identity attestations, allowing users to verify that the same sovereign operator controls identities across all ecosystems.


1.10.1.10. 9. Implementation Roadmap & Testing Strategy

+-------------------------------------------------------------------------------+
| Phase 1: Ingress Multiplexer & Abstraction Foundation                         |
| - ProtocolHostRouter multiplexer (HTTP/WS on port 8000)                       |
| - Decouple RelayServer into fleetmesh-protocol-nostr package                  |
| - Add protocols block to NodeConfig schema                                    |
+-------------------------------------------------------------------------------+
                                    |
                                    v
+-------------------------------------------------------------------------------+
| Phase 2: AT Protocol Package (Bluesky)                                        |
| - DAG-CBOR Tag 42 & CAR v1 encoder/decoder in fleetmesh_core                  |
| - Merkle Search Tree (MST) repository storage engine                          |
| - XRPC HTTP API (/xrpc/*) and Firehose WebSocket publisher                    |
| - Blossom CAS blob mapping (CIDv1 <-> SHA-256)                                |
| - Conformance testing against Bluesky test vectors                            |
+-------------------------------------------------------------------------------+
                                    |
                                    v
+-------------------------------------------------------------------------------+
| Phase 3: ActivityPub Package (W3C Fediverse)                                  |
| - WebFinger discovery & Actor document generation                             |
| - HTTP Signatures (RFC 9421) inbound verifier & outbound signer               |
| - S2S Ingress (/inbox) and Outbox distribution worker                         |
| - StrainLedger spam shielding                                                 |
| - Interop testing against Mastodon test instances                             |
+-------------------------------------------------------------------------------+
                                    |
                                    v
+-------------------------------------------------------------------------------+
| Phase 4: Secure Scuttlebutt Package (SSB)                                     |
| - Secret Handshake (SHS) & Box Stream TCP server (port 8008 / sidecar)        |
| - MuxRPC duplex stream handler & append-only feed storage                     |
| - Integration as SSBRung in TransportRouter                                   |
+-------------------------------------------------------------------------------+
                                    |
                                    v
+-------------------------------------------------------------------------------+
| Phase 5: Cross-Protocol Gateway & Census Integration                          |
| - Cross-protocol bidirectional translation compartments                       |
| - Cashu NUT-24 paid firehose monetization                                     |
| - Update scripts/check-interop.py with upstream standards vectors             |
+-------------------------------------------------------------------------------+

1.10.1.10.1. Detailed Phase Breakdown

1.10.1.10.1.1. Phase 1: Ingress Multiplexer & Abstraction Foundation
  • Milestone 1.1: Define ProtocolPackage, ProtocolHostRouter, and ProtocolHealth in fleetmesh_core.wire.interfaces.

  • Milestone 1.2: Implement ProtocolHostRouter multiplexer in fleetmesh_node/transport/host.py supporting path-based and header-based dispatching.

  • Milestone 1.3: Decouple RelayServer and BlossomServer into the fleetmesh-protocol-nostr package, conforming to ProtocolPackage.

  • Milestone 1.4: Add protocols block to fleetmesh_node/config/ with backwards compatibility for legacy face configs.

1.10.1.10.1.2. Phase 2: ATProto Package Implementation (fleetmesh-protocol-atproto)
  • Milestone 2.1: Implement did:plc and did:web resolution + secp256k1 signing in fleetmesh_core.identity.

  • Milestone 2.2: Upgrade fleetmesh_core.wire.cbor to support Major Type 6 (Tag 42 IPLD CIDs) and implement Merkle Search Tree (MST) + CAR export in fleetmesh_core.storage.

  • Milestone 2.3: Implement XRPC HTTP endpoints (/xrpc/*) and WebSocket firehose subscriber/publisher.

  • Milestone 2.4: Validate conformance against Bluesky protocol test vectors (com.atproto.repo, com.atproto.sync).

1.10.1.10.1.3. Phase 3: ActivityPub Package Implementation (fleetmesh-protocol-activitypub)
  • Milestone 3.1: Implement WebFinger discovery and Actor document generation.

  • Milestone 3.2: Implement ActivityStreams 2.0 JSON-LD parser and storage schema in NodeStore.

  • Milestone 3.3: Implement HTTP Signatures (RFC 9421 / draft-cavage) using the node’s Ed25519 keys.

  • Milestone 3.4: Implement Inbox (POST) and Outbox (GET/POST) handlers, with test validation against Mastodon test instances.

1.10.1.10.1.4. Phase 4: Secure Scuttlebutt Package Implementation (fleetmesh-protocol-ssb)
  • Milestone 4.1: Implement Secret Handshake (SHS) and Box Stream framing in fleetmesh_core.crypto.ssb.

  • Milestone 4.2: Implement MuxRPC duplex framing and create history stream sync.

  • Milestone 4.3: Integrate SSB TCP socket listener on port 8008 or sidecar (fleetmesh_node/sidecar/fleetmesh_ssb.py).

  • Milestone 4.4: Implement SSBRung in TransportRouter.

1.10.1.10.1.5. Phase 5: Cross-Protocol Gateway & Peering Metering
  • Milestone 5.1: Implement cross-protocol translation compartments (Nostr Kind 1 <-> ATProto post <-> ActivityPub note <-> SSB post).

  • Milestone 5.2: Apply token-bucket rate limiting and Cashu settlement to ATProto firehose egress and ActivityPub inbox ingress.

  • Milestone 5.3: Update scripts/check-interop.py census to track ATProto Lexicons, W3C ActivityPub RFCs, and SSB specifications.


1.10.1.11. 10. Key Architectural Decisions & Open Questions

  1. Multiplexer Technology:

    • Option A: Lightweight built-in asynchronous HTTP/WebSocket dispatcher (zero external dependencies, zero supply-chain risk, matching current wsproto/asyncio patterns).

    • Option B: Standard ASGI server integration (Starlette / Uvicorn).

    • Recommendation: Option A for node core minimalism, with optional ASGI adapter.

  2. Package Distribution:

    • Option A: In-tree modules inside fleetmesh_node/protocols/ (monorepo approach).

    • Option B: Separate installable packages (pip install fleetmesh-protocol-atproto).

    • Recommendation: Hybrid approach: Core protocols (Nostr, ATProto, ActivityPub) ship in-tree under fleetmesh_node/protocols/, loaded dynamically via the protocols config block, while external protocols use the existing plugin loader.

  3. Firehose Resource Management:

    • Subscribing to the Bluesky firehose requires processing hundreds of events per second.

    • Question: Should the ATProto firehose subscriber run inside the meshnode process or as an external worker sidecar (similar to the FIPS and P2P sidecars)?

    • Recommendation: Optional sidecar mode for high-volume firehoses, in-process mode for personal PDS / edge leaves.

  4. SSB Integration Model:

    • Question: In-process TCP socket or standalone sidecar?

    • Recommendation: Sidecar architecture (fleetmesh_node/sidecar/fleetmesh_ssb.py) communicating over a Unix domain socket, maintaining complete fault isolation from the node daemon and matching the existing libp2p pattern.


1.10.1.12. 11. Production Implementations: p2panda and Rhio Cluster Sync

The pluggable protocol runtime houses two additional production suites delivering append-only cryptographic ordering and micro-datacenter cluster replication.

1.10.1.12.1. 11.1 p2panda Protocol Package (fleetmesh-protocol-p2panda)

Conforming to the p2panda specification (v0.4.0), this package integrates decentralized append-only operation logs:

  • Cryptographic Foundation: Author identities are 64-character lowercase hex Ed25519 public keys mapped from the node’s transport keypair.

  • Deterministic CBOR Encoding: Uses fleetmesh_core.wire.cbor for canonical RFC 8949 deterministic encoding of operation headers and payloads.

  • Strict Chain Monotonicity:

    • Genesis operations (seq_num == 0) strictly enforce backlink is None and previous_seq_num is None.

    • Successive operations (seq_num > 0) require previous_seq_num == seq_num - 1 and cryptographic backlink continuity (backlink == prev_op.id).

  • Storage Engine (P2PandaLogStore): Thread-safe SQLite store configured with PRAGMA busy_timeout=5000; and single-initialization PRAGMA journal_mode=WAL;.

  • HTTP/CBOR Ingress:

    • GET /p2panda/status: Node protocol health, author identity, and operation counts.

    • GET /p2panda/operations?author=<pubkey>: Ordered operation logs from sequence number.

    • GET /p2panda/operations/<op_id>: Direct permalink returning single verified operation.

    • GET /p2panda/operations/<author>: Direct permalink returning author operation stream.

    • POST /p2panda/operations: Accepts canonical CBOR or JSON operation envelopes, verifying signatures and appending to local logs.

  • Transport Ladder Rung (P2PandaRung): Operates at rank 15 in TransportRouter. Delivers DIDComm messages wrapped as signed p2panda operations to local logs and upstream HTTP/CBOR endpoints.

1.10.1.12.2. 11.2 Rhio Protocol Package (fleetmesh-protocol-rhio)

Derived from HIRO MicroDataCenters Rhio cluster architecture, this package equips nodes for high-throughput edge micro-datacenter clustering:

  • Bao Chunked Tree Hashing (RhioBaoTree): Standard-library hierarchical Merkle tree hashing using 1024-byte chunk slicing with \x00 leaf domain separators and \x01 parent domain separators. Enables verified streaming content retrieval.

  • CAS Blob Synchronization (RhioBlobSync): Local content-addressable storage repository paired with SQLite metadata (rhio_blobs.db). Uses INSERT OR IGNORE semantics to preserve original creation timestamps and S3 synchronization status (synced_s3).

  • Decoupled Sidecar Daemon (fleetmesh-rhio): Runs as a separate process managing NATS JetStream pub/sub connections and S3/MinIO cluster synchronization. Communicates with meshnode over Unix Domain Socket (rhio.sock) via the fleetmesh-rhio/1 newline-delimited JSON IPC protocol with automatic socket cleanup and reconnect recovery.

  • HTTP Ingress:

    • GET /rhio/status: Node network ID, NATS endpoint, S3 endpoint, and stored blob count.

    • GET /rhio/blobs?hash=<sha256> & GET /rhio/blobs/<sha256>: Direct binary CAS stream retrieval.

    • POST /rhio/blobs: Stores raw bytes or base64 JSON payloads, calculating Bao roots and recording CAS entries.

    • GET /rhio/sync: S3 cluster synchronization status.

  • Transport Ladder Rung (RhioRung): Operates at rank 12 in TransportRouter. Publishes outbound DIDComm envelopes across NATS JetStream subjects (fleetmesh.<pubkey>).