Repository navigation
Conversation
Generated-by: Maka
Generated-by: Maka
M4n5ter
left a comment
There was a problem hiding this comment.
English
Thanks for putting this together and exercising the Windows Desktop ↔ WSL flow end to end. I'd hold off on merging the current approach — not because WSL support isn't wanted, but because pulling the full peer stack into the core workspace goes against where we want rust-preview's transport boundary to land.
Why we shouldn't merge this shape
-
41k+ lines of transport/crypto weight for a local WSL hop:
- Bringing
platform/peer(~10.2k lines,libp2p+ pinnedwebrtc-rs) into the main workspace forces vendoring ~31k lines ofdeno-cryptoanddeno-node-cryptojust to reconcile theaespin (0.8.3vs0.8.4), even though this WSL path doesn't use WebRTC, relays, Kademlia, or QUIC at all (127.0.0.1TCP only). - Longer term, we plan to introduce the mainline peer engine as a plugin, and also leave room for a self-hosted Maka Server for multi-Host communication and collaboration. Core crates (
cli,desktop-shell,host-runtime) shouldn't depend onPeerId,Multiaddr, orConnectivitySnapshot.
- Bringing
-
Concrete transport & lifecycle issues in the current draft:
- Unnecessary layering & serialization: every Host call goes through
wire -> WebSocket -> 1-byte kind -> 64KB duplex bridge (stop-and-wait per-write oneshot ACK) -> yamux/noise -> 127.0.0.1 TCP -> same-process loopback TcpStream::connect + copy_bidirectional -> WebSocket -> wire, with all concurrent stream opens serialized behind a globalMutexinEndpoint::open. - Stale pending credential:
wsl_peer::Listener::newcallshost.prepare_accessonce at startup and serves that cached token forever; once the 15-minutePendingTTL expires before first pairing, the Host becomes permanently unreachable until restarted. - Fragile Desktop lifecycle:
direct2d.rscouples window teardown tomaka_peer::ConnectivitySnapshot, loops reconnects without separating user exit vs. disconnect cleanly, dropsruntime.shutdown_background()while keeping spawned tasks from previous sessions on the shared runtime, and binds127.0.0.1(mirrored-mode dependent).
- Unnecessary layering & serialization: every Host call goes through
Recommended direction (split into two small PRs)
Two pieces this PR identified are genuinely the right cuts: host::Client needs a transport-agnostic way to open multiple streams to the same target, and workbench::host::admit needs to decouple the expected root_id from the local client data directory.
Instead of importing platform/peer, we can keep the core boundary minimal and let WSL, future Peer plugins, and a future Maka Server all sit cleanly on top of it:
-
PR 1 — Minimal
Clientstream-opener abstraction (platform/host-runtime):- Abstract repeated dialing in
host::ClientandCallChannelOpeneraround anOpenChannelclosure returning a boxed async byte stream (ChannelIo: AsyncRead + AsyncWrite + Unpin + Send + 'static,OpenChannel = Arc<dyn Fn() -> BoxFuture<'static, io::Result<Channel>> + Send + Sync>), exposingClient::connect_on(open, epoch)alongsideClient::connect(path, epoch). - Keep
Host::channel/wireframing as-is (no per-substream HTTP/WebSocket upgrade when the underlying transport already multiplexes raw streams, and noTransportKind/Hostingress trait yet — we can extract a guardedIngressfromHost::servewhen the first direct remote/plugin transport lands).
- Abstract repeated dialing in
-
PR 2 — Lightweight WSL wiring (
products/maka):- Use
wsl.exe --execwith a lightweight mux (e.g. plainyamux) owning stdout from byte 0 (diagnostics on stderr), and have the Linux helper forward each normal substream straight to the existing Linux Host Local IPC. - This requires zero TCP listeners, works regardless of WSL2 NAT vs. mirrored networking, avoids remote pairing/expiry for a same-user local Desktop, and automatically reuses an already running Linux Host along with its UID check, residency accounting, and graceful drain.
- A few invariants to make sure we preserve in PR 2:
- Half-close:
Client::closeshuts down the write side and waits forResponse::Closed; the mux ↔ IPC bridge must propagate half-close rather than dropping the whole stream on first EOF. - Cold-start residency handoff: reuse the existing Linux
deployment::connect_local(which already holds the launch lease /executor.lock) to hold a short-lived startupClientuntil Windows establishes its anchor and acks handoff over a one-shot bootstrap substream, then close the startupClient. - Connection ownership in
desktop-shell: keepTarget(distro/root/expectedroot_id) separate from a singleConnection(which owns itsWslBridgechild process + mux driver, rather than relying onArcdrop). Keepdirect2d.rsunaware of yamux/peer, and distinguish user quit (runquit_ephemeralbefore tearing down the helper) from disconnect/reconnect (fence & clean up, then reconnect without sendingQuit).
- Half-close:
- Use
If this direction sounds good, let's drop platform/peer and third-party/deno-* and start with PR 1. Happy to help review the small opener PR right away.
简体中文
感谢把 Windows Desktop ↔ WSL 的端到端链路跑通。当前形态不太建议直接合入——不是不需要 WSL 支持,而是为了本机 WSL 把整套 peer 栈拖进主 workspace,与 rust-preview 期望的传输边界方向不符。
为什么不建议按当前形态合入
-
为了本机 WSL 跨边界,引入了 4.1 万+ 行传输/加密代码包袱:
- 把
platform/peer(约 1.02 万行,libp2p+ 锁定版本的webrtc-rs)迁进主 workspace,被迫把deno-crypto和deno-node-crypto(约 3.1 万行)整包 vendor 进来,只为了对齐aes版本锁(0.8.3vs0.8.4);而这套 WSL 路径完全没有用到 WebRTC、Relay、Kademlia 或 QUIC(只走了127.0.0.1TCP)。 - 长期规划上,
main的 peer 引擎后续会以插件形式引入,未来也计划支持用户自部署 Maka Server 用于多 Host 通讯和协作。核心 crate(cli、desktop-shell、host-runtime)不应耦合PeerId、Multiaddr或ConnectivitySnapshot。
- 把
-
当前草稿中的具体传输与生命周期问题:
- 多余的协议套娃与串行瓶颈:每条 Host 调用链都要走
wire -> WebSocket -> 1 字节 kind -> 64KB duplex 桥(每次写入同步 oneshot 等 ACK)-> yamux/noise -> 127.0.0.1 TCP -> 同进程再回环 TcpStream::connect + copy_bidirectional -> WebSocket -> wire,且Endpoint::open用全局Mutex把并发开流串行化了。 - Pending 凭证过期后永久不可达:
wsl_peer::Listener::new只在启动时调用一次host.prepare_access并永久缓存该 token;若首次配对前超过 15 分钟PendingTTL,之后每次配对都下发过期 token,只能重启 Host。 - Desktop 生命周期较脆弱:
direct2d.rs直接依赖maka_peer::ConnectivitySnapshot触发关窗重连,没有把用户主动退出与断线重连干净区分,删掉runtime.shutdown_background()后前一次会话 spawn 的任务仍滞留在共享 runtime 上;同时写死127.0.0.1依赖 WSL mirrored 网络模式。
- 多余的协议套娃与串行瓶颈:每条 Host 调用链都要走
建议方向(拆成两个小 PR)
这个 PR 识别出的两处切口本身是对的:host::Client 需要传输无关地向同一目标反复开流,workbench::host::admit 需要把预期的 root_id 与本机 client 数据目录解耦。
不需要引入 platform/peer,只要把核心边界收干净,WSL、后续的 Peer 插件和未来的 Maka Server 就能自然挂在这层之上:
-
PR 1 — 最小化的
Client开流抽象(platform/host-runtime):- 将
host::Client和CallChannelOpener中重复的 IPC 拨号抽象为返回异步字节流的OpenChannel(ChannelIo: AsyncRead + AsyncWrite + Unpin + Send + 'static,OpenChannel = Arc<dyn Fn() -> BoxFuture<'static, io::Result<Channel>> + Send + Sync>),在保留Client::connect(path, epoch)的同时提供Client::connect_on(open, epoch)。 - 保持现有
Host::channel/wire帧协议不变(底层传输本身已支持原始流复用时,无需为每条子流再跑 HTTP/WebSocket Upgrade);现阶段也不提前加TransportKind或 Host 入站 trait——等第一个直投远端/插件传输落地时,再从Host::serve抽出带 residency 守卫的Ingress。
- 将
-
PR 2 — 轻量 WSL 接线(
products/maka):- 通过
wsl.exe --exec启动 helper,用轻量多路复用(如纯yamux)从第 0 字节独占 stdout(诊断日志走 stderr),Linux 侧 helper 将每条普通子流直接透明转发到现有的 Linux Host Local IPC。 - 这样做不需要任何 TCP 监听端口,不受 WSL2 NAT / mirrored 网络模式影响,省去同机 Desktop 的 remote pairing 及过期问题,同时天然复用正在运行的 Linux Host 及其 UID 校验、residency 计数和优雅排空路径。
- PR 2 落地时建议守住几条不变量:
- 保留半关闭(half-close):
Client::close会先关闭写端再等待读端返回Response::Closed,mux ↔ IPC 桥接需正确传播半关闭,不能一侧 EOF 就直接丢弃整条流。 - 冷启动 residency 交接:复用 Linux 现有
deployment::connect_local(已自带 launch lease /executor.lock)持有一个短命 startupClient,待 Windows 侧建好 anchor 并通过一次性 bootstrap 子流确认交接后再关闭该 startupClient。 desktop-shell连接所有权:把长期Target(distro / root / 预期root_id)与单次Connection(独占WslBridge子进程与 mux driver,不靠最后一个Arcdrop 回收)分层;窗口层(direct2d.rs)不感知 yamux/peer,明确区分用户退出(先跑完quit_ephemeral再拆 helper)与断线重连(fence + 清理后重连,不发Quit)。
- 保留半关闭(half-close):
- 通过
如果这个方向达成一致,建议先移除 platform/peer 和 third-party/deno-*,从 PR 1 开始推进,小 opener PR 提上来可以马上看。
Generated-by: Maka
|
Thanks for the review. I split the transport-neutral Host client work into #7028 so it can be reviewed independently, without WSL, the peer engine, or the Deno AES patches. The motivation for keeping P2P on the WSL path is to exercise the same Host-over-peer-stream boundary that future iOS/Android clients can use, not to make those clients depend on WSL bootstrap. A future mobile QR flow would use its own device pairing and admission. This does not require bringing roster, signed address publication, relay authorization, or resumable streams into this PR. The question of how the peer engine is packaged and owned (including the plugin direction) is still open; I am not treating this branch as merge-ready. In 03d48a8 the WSL peer listener derives its address from the running network mode: mirrored uses loopback, NAT derives the guest IPv4 from the route to its default gateway, and unsupported modes fail explicitly. The internal Host WebSocket remains loopback-only. The commit also fixes half-close and the startup/pairing paths. The Windows peer regression tests and Linux CLI typecheck passed; NAT has not been exercised on a real NAT-mode WSL instance. |
EnglishThanks for splitting out #7028 — that's definitely the right place to focus first. On the motivation for keeping P2P on the WSL path: I think we're conflating two unrelated problems here. Preparing for future mobile/remote clients has nothing to do with WSL. If the goal is to exercise the remote Host-over-stream boundary (pairing, remote admission, multi-channel calls, reconnects), the direct and faithful way is to run a regular remote Linux Host and connect to it over the network — not route it through WSL.
Keeping the two tracks separate is much cleaner:
Also, in AI-agent-driven development there is really no reason to treat already-written code as a sunk cost or hesitate to discard an earlier prototype — patching around the wrong foundation costs far more long-term than starting fresh on the right boundary. I wouldn't invest more effort hardening the WSL-over-peer branch here; let's get the client transport abstraction right in #7028 first, then land WSL and remote/plugin transports cleanly on their own merits. 简体中文感谢把 #7028 拆出来,先聚焦那边是对的。 关于在 WSL 路径上保留 P2P 的理由,我觉得这里把两件不相干的事混在一起了。 为未来的移动端/远程客户端铺路,和 WSL 本身没有关系。如果目标是提前验证远端 Host-over-stream 的边界(配对、远端 admission、多通道调用、断线重连),最直接也最贴近真实场景的做法就是起一台普通的远端 Linux Host,让客户端跨网络连接,而不是绕道 WSL。
把两条线彻底分开会清晰得多:
另外,在 AI Agent 驱动的开发模式下,完全没必要把已经写出来的代码当成沉没成本、舍不得推倒重来——在不合适的底座上反复打补丁的长期代价,远比换到正确边界重新实现高得多。建议不要再继续往 #7011 这条 WSL-over-peer 路径上叠补丁了,我们先把 #7028 的传输抽象收干净,再各自独立推进 WSL 和远端/插件传输。 |
Astro-Han
left a comment
There was a problem hiding this comment.
I checked the incremental change through 03d48a89f8c333dea3c577adec473c54c631c532, the added dependency and notice inputs, and the original hosted CI failures. This is a focused integration check, not complete validation of all 99 files or Windows/WSL behavior.
- P2 — regenerate the distribution notices for the AES change. The new
third-party/deno-crypto/Cargo.toml/third-party/deno-node-crypto/Cargo.tomlpins andCargo.lockintroduceaes0.8.4, whereas the Rust base uses 0.8.3. Neither the PR'sproducts/maka/cli/notices.jsonnor the tested merge's manifest coverscargo:[email protected]. linux-checks job 135607408554 fails explicitly withThird-party notices do not cover current component or license data: cargo:[email protected]. Its checkout is011353d1cc91086ebaf43f517e6bfde4671a977f, with parents Rust d0bfb20 and this exact PR head. Update and verify the generated dependency/notice artifacts for the actual new graph. - P2 — make the imported JavaScript pass the repository formatter. The added
third-party/deno-crypto/00_crypto.jsis rejected by tooling job 135607408048; Biome checks 525 files and reports one formatting error in this new file. This independently keeps the current CI red.
I also read the earlier architectural review. The current change still imports the peer and crypto stack; these CI findings neither resolve that design discussion nor establish correctness of pairing expiry, half-close, cold starts, reconnects, or cleanup. The retained-image native failure also occurs with the baseline NSH tree, so I am not attributing it to this transport change. I did not run Cargo or native WSL/Windows tests locally.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
Summary
Verification
--no-default-features.Scope and follow-ups
This PR requires a compatible Linux Maka executable already present in the selected distro (passed via
--wsl-maka). Fresh-distro setup, automatic installation, and a startup picker are out of scope. The WSL Host currently runs in service mode; idle retirement is not changed here.AI use
Tool(s) and scope: Maka implemented, reviewed and exercised the draft WSL transport and Desktop wiring.
Checklist
Does this PR entail a change in behavior?