* fix(federation): validate inbound envelope freshness and replay Signed-off-by: luojie <16602829831@163.com> * fix(federation): reject JCS envelopes signed before replay history began The inbound replay guard is in memory and created in initialize(), so an envelope captured up to ~5.5 min before a restart could be replayed once into the new lifecycle. Record the guard's creation time and fail closed with MESSAGE_PREDATES_REPLAY_HISTORY for earlier signed timestamps. Tests: guard-level restart-window test with an injected clock, and a plugin-level test with real Ed25519 signatures showing an envelope accepted by one instance is rejected by a fresh instance created after. Co-Authored-By: RuFlo <ruv@ruv.net> --------- Signed-off-by: luojie <16602829831@163.com> Co-authored-by: luojie <16602829831@163.com> Co-authored-by: r <r@x>
@claude-flow/plugin-agent-federation
Cross-installation agent federation with zero-trust security, PII-gated data flow, and compliance-grade audit trails.
Install + run
npx -y -p @claude-flow/plugin-agent-federation@latest ruflo-federation --help
Subcommands
| Command | Description |
|---|---|
ruflo-federation init |
Initialize federation on this node (generates keypair) |
ruflo-federation join <peer-url> |
Join a federation by connecting to a peer |
ruflo-federation leave |
Leave the current federation |
ruflo-federation peers |
List known peers and their trust levels |
ruflo-federation peers add <node-id> |
Add a peer to the federation |
ruflo-federation peers remove <node-id> |
Remove a peer |
ruflo-federation status |
Show federation health, sessions, trust levels |
ruflo-federation audit |
Query compliance-grade audit logs |
ruflo-federation trust |
Manage trust scores and tiers |
ruflo-federation config |
Show/update federation config |
Configuration via .env
FEDERATION_NODE_NAME=my-node # default: hostname
FEDERATION_BIND_HOST=127.0.0.1 # default: 127.0.0.1 (0.0.0.0 accepts other hosts)
FEDERATION_BIND_PORT=8443 # default: 8443
FEDERATION_TRUST_LEVEL=untrusted # default: untrusted
Tests
Handshake signatures cover ruflo:federation:handshake:v1: followed by the nonce,
not the peer-supplied nonce alone. Signing adapters must sign the supplied bytes
unchanged. Both peers must use this context; raw-nonce handshake responses from
older peers are rejected, so upgrade federation peers together. This prevents a
handshake response from also verifying as a signature over bare envelope bytes.
JCS-signed inbound envelopes must target this node, agree with their signed ID/type/source/session metadata, and be no older than five minutes or more than 30 seconds in the future. A replay guard is shared by the plugin's inbound callbacks. It retains IDs until the signed timestamp expires, with limits of 1,024 IDs per peer, 256 peers, 8,192 IDs total and 256 characters per ID. Capacity exhaustion rejects new messages instead of evicting live replay history.
Replay history is in memory for one plugin lifecycle; restarting the plugin
clears it. To close the restart window, a JCS envelope whose signed timestamp is
earlier than the guard's creation (plugin initialize) is rejected with
MESSAGE_PREDATES_REPLAY_HISTORY, so an envelope captured before a restart cannot
be replayed into the new lifecycle. Peers whose clocks run behind this node may
see fresh messages rejected for up to that skew immediately after a restart.
This is not durable or cross-replica deduplication. The existing
legacy-v1 heartbeat/status compatibility path cannot authenticate nested envelope
fields and does not acquire JCS replay guarantees. Signature and policy checks
still run before a JCS message can reserve an ID or reach the event bus.
325 unit tests covering audit, routing, discovery, plugin lifecycle.
npm test
License
MIT — Claude Flow Team.