This chamber is what lets a federated app go up in a few lines. Receiving at the inbox, dispatching from the outbox, keeping the actor ledger, retrying deliveries that failed—hand the whole business of federation to it, and you get to think only about what your app is: what people can post, and how it looks. hollo and hackers.pub were both raised this way.
My favorite corner is a small ledger called KvSpecDeterminer. For each remote island, it remembers which wax-seal etiquette worked. Federation is in a transitional moment for its rites, and not everyone can read the same etiquette—so it hands you a way to live with that reality too.
Highlights
- builder.ts (1,460 lines) is the build-it-later method. hackers.pub uses this FederationBuilder to raise its parts as separate wings.
- Reliability partitions share the room: circuit-breaker.ts (keep some distance from an ailing party), idempotency.ts (don't read the same document twice), retry.ts, keycache.ts.
- negotiation.ts is the cushion for content negotiation—serving HTML or JSON-LD from the same URL.
A passage from the sutra
async determineSpec(
origin: string,
): Promise<HttpMessageSignaturesSpec> {
return await this.kv.get<HttpMessageSignaturesSpec>([
...this.prefix,
origin,
]) ?? this.defaultSpec;
}
async rememberSpec(
origin: string,
spec: HttpMessageSignaturesSpec,
): Promise<void> {
await this.kv.set([...this.prefix, origin], spec);
}