Skip to content

feat(peer): add Ed25519 node identity, signed reachability leases, and resumable peer streams - #7137

Open
me2seeks wants to merge 1 commit into
stack/p2p-mesh-1-accept-remote-streamsfrom
stack/p2p-mesh-2-peer-identity-and-reachability
Open

me2seeks wants to merge 1 commit into
stack/p2p-mesh-1-accept-remote-streamsfrom
stack/p2p-mesh-2-peer-identity-and-reachability

Conversation

@me2seeks

@me2seeks me2seeks commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Stack A: P2P Mesh (Stacked PRs)

Part PR Branch Base
A1 #7136 stack/p2p-mesh-1-accept-remote-streams rust-preview
A2 (this PR) #7137 stack/p2p-mesh-2-peer-identity-and-reachability stack/p2p-mesh-1-accept-remote-streams
A3 #7138 stack/p2p-mesh-3-mesh-control-and-transit stack/p2p-mesh-2-peer-identity-and-reachability
A4 #7139 stack/p2p-mesh-4-cli-and-pairing-ticket stack/p2p-mesh-3-mesh-control-and-transit

Introduce platform/peer (maka-peer) providing cryptographic peer identity, signed reachability leases for seamless IP rotation, and resumable byte streams across mid-session carrier switchover.

Changes

  • platform/peer/src/identity.rs: PeerId newtype, Ed25519 NodeIdentity with zeroized seed loading (load_or_create / load_or_create_async), canonical Base64 signature validation, and 6-digit SAS derivation.
  • platform/peer/src/reachability.rs: DirectRoute, RelayRoute, PeerReachabilityLeaseV1, SignedPeerReachabilityLeaseV1, and LeaseReceiptStore with monotonic Instant deadlines (immune to wall-clock rollback) returning zero-copy UsableLease<'a>.
  • platform/peer/src/resumable.rs: ResumablePeerStream + ResumableStreamControl with 30s default recovery window, 2 MiB replay buffer, cancel-safe FrameDecoder, split carrier I/O, FRAME_REJECT mismatch abort, and explicit TerminalErrorSlot errors.
  • platform/peer/tests/peer_behaviors.rs: behavioral integration tests including real_host_websocket_session_survives_resumable_carrier_switchover running a real Host::serve_remote + Client::connect_websocket + HostLogs::read RPC across carrier switchover.

Verification

  • cargo test --locked -p maka-peer (5/5 pass, plus 50/50 consecutive stress runs)
  • node scripts/asf-license-headers.mjs check (pass)

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one recovery correctness issue that should be fixed before relying on the stream's graceful-close semantics.

Reviewed head: 850494fdf662f75b638ede836405d2911cba8144.


Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.

fn is_complete(&self) -> bool {
self.local_fin_sent
&& self.remote_fin_received
&& self.peer_acked_offset == self.outbound_next_offset

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2][recovery path] Wait for an explicit FIN acknowledgement before completing

peer_acked_offset == outbound_next_offset acknowledges only DATA bytes; it is already true at offset 0 and can also become true before the peer receives FRAME_FIN. Once both sides have sent FIN, this lets the worker exit after merely writing its FIN to the current carrier. If that frame is lost during a carrier switchover, the sender drops its control receiver while the peer still waits for FIN and eventually times out, so graceful close is not actually resumable.

I reproduced this by forwarding both HELLO frames, dropping A's FIN after A's carrier write succeeded, and then replacing B's carrier: A's replace_carrier returned Closed, while B terminated with TimedOut. Please track FIN acknowledgement separately (or add a FIN-ACK), retain FIN in replay state until the peer confirms it, and add this loss boundary as a regression test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants