Strfry Relay Bridge (fleetmesh-strfry) ======================================= `fleetmesh-strfry` is the high-performance relay bridge connecting a Fleetmesh node to a local or remote [strfry](https://github.com/hoytech/strfry) Nostr relay. .. image:: ../_static/logo-fleetmesh.svg :align: center :alt: Fleetmesh Logo :width: 240px \ Overview & Purpose ------------------ While Fleetmesh nodes maintain an embedded SQLite event store and direct peer-to-peer transports (Iroh QUIC, FIPS/DoD rungs), production public gateways and community nodes frequently front high-concurrency public WebSocket traffic. `strfry` is a C++20 Nostr relay engine backed by LMDB, capable of handling millions of concurrent subscribers and sustained write throughput. The `fleetmesh-strfry` package bridges these two worlds: - **Bi-directional Relay Synchronization**: Subscribes to an active strfry relay instance over WebSockets, verifies incoming events against Fleetmesh acceptance policies, writes them to the node's `store.sqlite`, and publishes the node's egress events to strfry. - **Queue Draining on Every Tick**: Egress events that cannot be delivered immediately are queued in memory and safely drained on each node event loop tick or via explicit flush commands. - **Deep Write Policy Enforcement**: Implements the strfry write-policy plugin protocol over stdin/stdout, enforcing cryptographic signatures, clock skew limits, NIP-40 expiration, rate limits, and optional **bilateral peering grant validation** against the node's ``grants.sqlite``. - **Bulk Data Migration (StrfryPipe)**: Facilitates streaming JSONL export and import between the node's SQLite eventstore and strfry's native LMDB database. Package Architecture -------------------- `fleetmesh-strfry` relies solely on the Python standard library. It imports the node package at runtime (``node.eventstore``, ``node.grants``, ``fleetmesh_node.keystore``, ``node.relay``, ``fleetmesh_node.compartment``) and, through it, ``fleetmesh_core`` and ``fleetmesh_schema``: .. list-table:: :widths: 30 70 :header-rows: 1 * - Module - Primary Responsibility * - ``fleetmesh_strfry.bridge`` - ``StrfryRelayBridge``: WebSocket client handling live subscription, ingestion, and queued egress publishing. * - ``fleetmesh_strfry.policy`` - ``StrfryPolicyEngine`` and ``StrfryPluginRunner``: Write-policy plugin for strfry, enforcing protocol rules and grant checks. * - ``fleetmesh_strfry.pipe`` - ``StrfryPipe``: Streaming JSONL bulk pipeline connecting `strfry export`/`import` with node event stores. * - ``fleetmesh_strfry.plugin`` - ``StrfryBridgePlugin``: Node compartment integration, enabling in-process lifecycle management and CLI verbs. Runtime Environment ------------------- The package runs directly on the node host alongside the other Fleetmesh checkouts: .. code-block:: sh # Example PYTHONPATH setup on a deployment host export PYTHONPATH=/opt/fleetmesh/strfry-bridge:/opt/fleetmesh/meshnode:/opt/fleetmesh/core:/opt/fleetmesh/schema Installation ------------ `fleetmesh-strfry` can be installed in editable mode or as a standard package: .. code-block:: sh cd strfry-bridge pip install -e . Subsystems & Documentation -------------------------- .. list-table:: :widths: 25 75 :header-rows: 1 * - Document - Description * - :doc:`modes` - Operational modes: in-process compartment plugin (Mode 1) and standalone service daemon (Mode 2). * - :doc:`policy` - Strfry write-policy plugin protocol, verification gates, and bilateral peering grant enforcement. * - :doc:`pipe` - Bulk data synchronization pipeline between SQLite eventstore and strfry LMDB. * - :doc:`api` - Python API reference with autodoc documentation for all modules.