Skip to content

Conversation

@amitu
Copy link
Contributor

@amitu amitu commented Sep 17, 2025

Summary

Complete implementation of fastn-p2p streaming API and remote shell functionality (rshell/rexec). This is the main tracking PR that implements the complete plan originally outlined in PR #2202, building on the fastn-context foundation from PR #2203.

🎯 Complete Implementation Plan

Phase 1: Basic fastn-context (Minimal)Completed

Phase 2: fastn-p2p Streaming API 🔄 In Progress

  • Add client module with connect() function
  • Implement client::Session with stdin/stdout streams
  • Add basic open_uni()/accept_uni() for stderr-like streams
  • Add server::Session with protocol negotiation and context integration
  • Add Session -> Request conversion (into_request())
  • Preserve existing Request methods (get_input, handle)
  • Basic context integration (sessions get context)
  • Current: PR feat: implement fastn-p2p streaming API foundation for remote shell functionality #2205 ⏳ (API foundation → this feature branch)

Phase 3: Test and ValidateNext

  • Fill in TODO implementations with actual iroh streaming
  • Update fastn-p2p-test sender/receiver to use new API
  • Test both RPC (Session->Request) and streaming patterns
  • Validate iroh connection reuse works correctly
  • Scope: End-to-end P2P streaming validation

Phase 4: Remote Shell IntegrationFinal

  • Update fastn-remote to use fastn-p2p streaming API
  • Implement rshell using client::connect() -> Session
  • Implement server-side rshell using Session streams
  • Add stderr handling via open_uni()/accept_uni()
  • Test fastn rshell and fastn rexec commands work
  • Scope: Working remote shell over P2P

🔗 Related PRs

🎯 Success Criteria

  1. ✅ fastn-context integrated - Hierarchical contexts for debugging (PR feat: create fastn-context crate with hierarchical context system for debugging and operations #2203)
  2. 🔄 Streaming API complete - Client/server Session types (PR feat: implement fastn-p2p streaming API foundation for remote shell functionality #2205)
  3. ⏳ fastn-p2p-test passes - New streaming API validated (Phase 3)
  4. ⏳ fastn rshell works - Interactive shell over P2P (Phase 4)
  5. ⏳ fastn rexec works - Command execution with separate stderr (Phase 4)
  6. ✅ No regressions - Existing fastn-p2p call() functionality preserved

🔧 API Overview

New Streaming API

// Client side streaming
let session = fastn_p2p::client::connect(our_key, target, protocol).await?;
session.stdin   // Send to server
session.stdout  // Receive from server
let stderr = session.accept_uni().await?; // Additional streams

// Server side with context
fn handle_session(session: fastn_p2p::server::Session<Protocol>) {
    let ctx = session.context(); // fastn-context integration
    let request = session.into_request(); // RPC compatibility
}

Minimal Breaking Changes

  • Add client::connect() function (new)
  • Add client::Session type (new)
  • Add server::Session type (new)
  • Add Session::into_request() method (new)
  • Keep all existing Request

    methods intact ✅

📋 Development Strategy

This feature branch allows us to:

  • Build incrementally through focused, reviewable PRs
  • Test continuously as each phase completes
  • Maintain compatibility throughout development
  • Review in chunks rather than one massive change

Goal: Working remote shell over P2P with minimal API surface for immediate use.

The comprehensive monitoring and ecosystem migration will come in follow-up PRs once the core streaming foundation is proven.

🤖 Generated with Claude Code

@amitu amitu closed this Sep 17, 2025
@amitu amitu force-pushed the feature/fastn-p2p-streaming branch from 505f5ca to 1762de3 Compare September 17, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants