refactor(runtime-host): share the client peer endpoint - #4036
Conversation
f5a5dd7 to
11ccea3
Compare
4797a05 to
175f390
Compare
Keep one lazy peer endpoint for each Desktop or CLI owner so Direct profiles and reconnects reuse one Swarm. Cancel individual connection attempts without tearing down unrelated streams, and close the endpoint with its owner lifecycle. Generated-by: Codex
175f390 to
542784d
Compare
jackwener
left a comment
There was a problem hiding this comment.
I reviewed exact head 542784d6e6de59060e538adbffb5fca2227b4acc. I found no P0-P2 issues. The Client-lifetime shared Swarm removes a real repeated startup cost, and a real native-addon probe verified concurrent connections to two peers, request-local cancellation, late-dial fencing, reconnect through the same endpoint, stream independence, and idempotent shutdown.
[P3] Validate the endpoint API returned by the native addon
loadNativeModule() checks only the module-level ensurePeerIdentity and startPeerEndpoint exports. It does not validate the endpoint returned by startPeerEndpoint(). A previous addon build has connect, accept, and close, but lacks the new cancelConnect method. If current JavaScript loads that addon through MAKA_RUNTIME_HOST_PEER_NATIVE_PATH, a stale development artifact, or a mismatched upgrade, aborting a connection calls the missing method. The resulting TypeError is caught, while the shared endpoint is intentionally kept alive, so the pending connection remains until its native deadline or the whole owner closes.
This does not affect matched release bundles, so I consider it non-blocking. Please validate the returned endpoint's connect, cancelConnect, accept, and close methods before use, preferably behind an explicit native ABI version. The release smoke test should also cancel a pending connection so this compatibility boundary remains covered.
All exact-head hosted checks applicable to this change completed successfully; the optional Eval job was skipped. The current-main merge is clean. Local validation also passed the native release build, Cargo tests and clippy, affected workspace builds, 1,307 Runtime Host tests, 453 CLI tests, and 1,644 Desktop main-process tests. Retaining an integration regression for the multi-peer/cancel/reconnect/owner-close contract would further protect this refactor.
Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.
简体中文
本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。
jackwener
left a comment
There was a problem hiding this comment.
I rechecked exact head 542784d6e6de59060e538adbffb5fca2227b4acc after the completed review. The head is unchanged, all applicable hosted checks completed successfully, no unresolved review threads or new blocking findings exist, and the current-main merge remains clean. I am approving this head; the non-blocking native-addon compatibility suggestion remains in my earlier review.
Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.
简体中文
本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。
English
Summary
Refs #3842
Verification
cargo clippy --locked --all-targets --manifest-path native/runtime-host-peer/Cargo.toml -- -D warningscargo test --locked --manifest-path native/runtime-host-peer/Cargo.tomlThe full repository suite was not run locally; affected suites and repository CI cover this bounded refactor.
AI use
Tool(s) and scope: OpenAI Codex implemented and verified the refactor under M4n5ter's direction and review. The commit carries the required
Generated-by: Codextrailer.Checklist
Does this PR entail a change in behavior?
中文
摘要
关联 #3842
验证
cargo clippy --locked --all-targets --manifest-path native/runtime-host-peer/Cargo.toml -- -D warningscargo test --locked --manifest-path native/runtime-host-peer/Cargo.toml本地未运行全仓库测试;本次有界重构已覆盖受影响测试,并由仓库 CI 补充验证。
AI 使用
工具与范围:OpenAI Codex 在 M4n5ter 的指导和审核下实现并验证本次重构。提交已包含所需的
Generated-by: Codextrailer。检查清单
本 PR 是否改变行为?