Skip to content

Enhance StreamMultiplexer with auto-reconnect and API overhaul#38

Merged
Kiryuumaru merged 12 commits intomasterfrom
feat/better-reconn
Mar 11, 2026
Merged

Enhance StreamMultiplexer with auto-reconnect and API overhaul#38
Kiryuumaru merged 12 commits intomasterfrom
feat/better-reconn

Conversation

@Kiryuumaru
Copy link
Copy Markdown
Owner

This pull request makes significant improvements to the project's engineering standards by introducing new instruction documents, updating the workflow and documentation guidance, and restructuring the solution's sample projects. The main changes include adding comprehensive rules for code quality, documentation, workflow, and terminal usage, as well as updating and reorganizing sample projects in the solution file.

Instruction and Workflow Documentation:

  • Added new, detailed instruction files in .github/instructions/ covering code quality, documentation, workflow, rule style, project context, and terminal usage. These documents enforce stricter standards for code hygiene, documentation updates, build/test requirements, and command usage in development workflows. [1] [2] [3] [4] [5] [6]
  • Replaced and consolidated older, less formal instruction files with new ones, ensuring all rules follow a unified style and are easier to find and interpret. [1] [2]

Solution Structure and Samples:

  • Updated NetConduit.sln to remove obsolete sample projects (NetConduit.Samples.ChatCli, NetConduit.Samples.VideoStream) and add new sample projects (NetConduit.Samples.GroupChat, NetConduit.Samples.Pong, NetConduit.Samples.RemoteShell, NetConduit.Samples.TcpTunnel). This improves the relevance and organization of sample code for users. [1] [2] [3]

Engineering Standards & Documentation

  • Added .github/instructions/code-quality.instructions.md specifying strict code hygiene, zero warnings policy, nullability handling, reliability principles, commenting rules, and XML documentation requirements.
  • Added .github/instructions/documentation.instructions.md requiring developers to check and update documentation for all API, test, and architecture changes, with clear mapping of documentation locations and update triggers.
  • Added .github/instructions/workflow.instructions.md detailing required build, test, and publish commands, as well as pre-commit verification and manual review checklists.
  • Added .github/instructions/rule-style.instructions.md to standardize the writing style, structure, and formatting of all instruction files.
  • Added .github/instructions/project-context.instructions.md clarifying project status, breaking change policy, design priorities, and terminology.

Terminal Usage Rules

  • Added .github/instructions/agent-terminal.instructions.md prohibiting the use of pipes, semicolons, &&, and redirection in terminal commands, and requiring commands to be executed separately to avoid VS Code approval prompts.
  • Removed the old .github/instructions/vscode-avoid-piping-causing-approval.instructions.md in favor of the new, more comprehensive terminal command rules.

Solution Structure Updates

  • Removed NetConduit.Samples.ChatCli and NetConduit.Samples.VideoStream projects from NetConduit.sln. [1] [2]
  • Added new sample projects: NetConduit.Samples.GroupChat, NetConduit.Samples.Pong, NetConduit.Samples.RemoteShell, and NetConduit.Samples.TcpTunnel to NetConduit.sln.
  • Updated solution folder structure to group source files more clearly.

These changes collectively raise the bar for code quality, documentation, and workflow consistency across the project, while also modernizing the sample projects included in the solution.

Introduce auto-reconnection logic to StreamMultiplexer using a configurable StreamFactory delegate. Multiplexer now automatically attempts to reconnect on transport errors, with support for exponential backoff, max attempt limits, and cancellation via event handlers. New events OnAutoReconnecting and OnAutoReconnectFailed allow monitoring and control of reconnection attempts.

MultiplexerOptions gains StreamFactory (required), reconnection/backoff settings, and AutoReconnectEventArgs. All tests updated to use TestMuxHelper and the new creation pattern. New tests added for auto-reconnect scenarios. PLAN.md documents the future connection overhaul design. This makes the multiplexer robust against transport failures and unifies connection/reconnection logic.
Major update to PLAN.md for StreamMultiplexer redesign:
- Initial and reconnection logic unified with retry/backoff
- API now uses static Create() and synchronous Start()
- State machine updated; handshake merged into connection
- Channel ops now async-await during connect/reconnect
- Migration and test guidance revised for new API
- Breaking changes; backwards compatibility not preserved
- Replace ad-hoc instruction files with formal, structured rules in `.github/instructions/`
- Add agent-terminal, code-quality, documentation, project-context, and rule-style guides
- Merge build-commands into workflow.instructions.md with expanded build/test/publish steps
- Standardize formatting, sectioning, and keyword usage across all instruction files
- Clarify and enforce rules for code hygiene, commenting, documentation updates, and workflow verification
- Created a new sample project for a multi-client group chat application.
- Implemented server and client logic for both TCP and WebSocket transports.
- Added message broadcasting, typing indicators, and user notifications.
- Included command handling for listing users, viewing stats, and kicking users.
- Defined message types and behavior for chat events.
- Added project files and launch settings for easy execution.
- Implemented stream handling with IStreamPair and StreamPair for resource management.
Introduce two new sample projects: NetConduit.Samples.Pong (real-time multiplayer terminal Pong using Terminal.Gui) and NetConduit.Samples.RemoteShell (SSH-like remote shell with command streaming and Ctrl+C support). Both are integrated into the solution and use NetConduit multiplexed channels for communication. All existing sample projects are updated to target .NET 10.0. No changes to core library code.
Switch server to provide a persistent shell per client, streaming real-time output and maintaining shell state across commands. Simplify protocol by removing per-command execution and exit code reporting. Improve Ctrl+C handling to send interrupts to the shell (SIGINT on Unix, child process kill on Windows). Enhance client input, history, and output handling. Add Windows interop for process management. Allow server shutdown via Ctrl+C or Q. Refactor and clean up code for clarity.
…new PLAN_DELTAMESSAGE.md and PLAN_TUNNEL.md for delta message transit and TCP tunneling
…r array operations; refactor LCS algorithm tests and add edge case scenarios for complex nested structures
- Implement WebSocket transport for NetConduit, enabling browser communication and firewall traversal.
- Create TcpTunnel sample demonstrating TCP port forwarding through a relay server, similar to SSH tunneling.
- Include detailed README for TcpTunnel with usage instructions, architecture overview, and protocol details.
- Add support for both TCP and WebSocket transports in the TcpTunnel application.
- Updated API documentation to include references to related concepts and options across various sections.
- Improved clarity in concepts related to backpressure, channels, events, and statistics.
- Added a new samples index to provide an overview of example applications demonstrating NetConduit features.
- Created detailed README files for each sample application, outlining features, usage, and architecture.
- Enhanced existing sample applications with clearer instructions and improved code comments.
@Kiryuumaru Kiryuumaru merged commit 95078e2 into master Mar 11, 2026
16 of 22 checks passed
@Kiryuumaru Kiryuumaru deleted the feat/better-reconn branch March 11, 2026 15:08
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.

1 participant