Part III — Branches, sap and seeds

08 · The seeds: federation

Wind and animals carry baobab seeds far away. Federation carries public saberes beyond the network of mucuas: to chat clients (XMPP) and to the Fediverse (ActivityPub).

Files to read

  1. federacao/visibilidade.py — the gate: only protecao: publico + visibility: public + not encrypted goes out.
  2. federacao/mapeador.py, federacao/atores.py — saber → Dublin Core / ActivityStreams; mucua, galaxy, mocambola → actors.
  3. federacao/adaptadores/base.py and the adapters (xmpp*.py, activitypub.py).
  4. federacao/ingestao.py — what arrives from outside enters the collection.
  5. federacao/xmpp_bot.py + xmpp_i18n.py + bot_backend.py — the bot that publishes and searches over chat.
  6. federacao/xmpp_ponte.py, xmpp_extauth.py, api/v3/xmpp.py — the mucua's own XMPP (what the protocol calls a server), using Baobáxia's accounts.
  7. federacao/http_sig.py, api/v3/activitypub.py.

Pluggable adapters

classDiagram
    class Adaptador {
        <<abstract>>
        +nome
        +habilitado
        +publicar(saber)
        +consumir(atividade)
        +status()
    }
    class XMPPAdaptador
    class ActivityPubAdaptador {
        +documento_ator()
        +documento_outbox()
        -_assina_entrega()
    }
    class Transporte {
        <<xmpp>>
    }
    class TransporteHTTP {
        <<activitypub>>
    }
    class SlixmppTransporte
    class ComponenteTransporte
    class HttpxTransporte
    Adaptador <|-- XMPPAdaptador
    Adaptador <|-- ActivityPubAdaptador
    XMPPAdaptador --> Transporte
    ActivityPubAdaptador --> TransporteHTTP
    Transporte <|-- SlixmppTransporte : client
    Transporte <|-- ComponenteTransporte : XEP-0114
    TransporteHTTP <|-- HttpxTransporte

Each adapter lights up with BBX_FED_<NAME>=on (federacao/config.py).

What arrives from outside (version 3.3)

sequenceDiagram
    participant R as remote mucua
    participant I as POST /ap/galaxia/{uuid}/inbox
    participant H as _remetente_verificado
    participant G as ingestao.ingerir
    R->>I: Create + Signature(keyId=…/ap/mucua/X#main-key) + Digest + Date
    I->>H: checks Digest, Date (±5 min) and Ed25519 with mucua X's pubkey
    alt signature missing or invalid
        I-->>R: 401
    end
    I->>G: external saber
    G->>G: well-formed uuid? nature is not an identity one?
    G->>G: does the uuid already exist and is it LOCAL? → refuse
    G->>G: marks origem_externa, origem_mucua, _verificado
    G-->>I: saber ingested (enters normal search)

Up to 3.2 this route was always mounted, with no signature, and the upsert accepted the uuid of any local saber — see module 11.

The bot

The bot talks in several languages (xmpp_i18n.py): buscar pesca, publicar, sending a photo, titulo …, enviar. It uses the same publica/operacoes.py layer as the CLI. Messages and commands are kept apart from the logic — a new language is a new dictionary.

Practice

  1. Read visibilidade.pode_federar and list three saberes that never go out.
  2. In test_xmpp_bot_i18n.py, add a command in another language.
  3. Run testes/test_federacao_inbox_segura.py. Change one line of the gate in ingestao.py and see which test breaks.

To talk about

  • Which saberes does a community want to scatter to the wind, and which does it want to keep only among its own mucuas?

vedi questo capitolo come sapere