Skip to content

refactor(runtime-host): share the client peer endpoint - #4036

Merged
M4n5ter merged 1 commit into
mainfrom
refactor/runtime-host-share-client-peer-endpoint
Aug 28, 2026
Merged

refactor(runtime-host): share the client peer endpoint#4036
M4n5ter merged 1 commit into
mainfrom
refactor/runtime-host-share-client-peer-endpoint

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Aug 27, 2026

Copy link
Copy Markdown
Member
English

Summary

  • Reuse one lazy Client peer endpoint across Direct profiles and reconnects for each Desktop or CLI lifecycle
  • Cancel an individual pending peer connection without closing the shared Swarm or unrelated streams
  • Keep the endpoint under one explicit owner and close it once during Desktop or CLI shutdown
  • Preserve the existing Host profile, Runtime Host protocol, credential, and direct-only authority boundaries

Refs #3842

Verification

  • cargo clippy --locked --all-targets --manifest-path native/runtime-host-peer/Cargo.toml -- -D warnings
  • cargo test --locked --manifest-path native/runtime-host-peer/Cargo.toml
  • Runtime Host, CLI, and Desktop typechecks
  • Targeted Runtime Host peer, CLI context, and Desktop manager suites
  • Native smoke: one Client Swarm concurrently opened streams to two independent peer endpoints
  • ASF headers, peer dependency inventory, and peer notices checks

The full repository suite was not run locally; affected suites and repository CI cover this bounded refactor.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex implemented and verified the refactor under M4n5ter's direction and review. The commit carries the required Generated-by: Codex trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — Direct connections now share a Client-lifecycle peer endpoint
  • No
中文

摘要

  • 每个 Desktop 或 CLI 生命周期内,Direct profiles 与 reconnects 复用一个惰性 Client peer endpoint
  • 单独取消一个待处理 peer 连接,不关闭共享 Swarm 或无关 streams
  • endpoint 由唯一明确的 owner 管理,并在 Desktop 或 CLI 关闭时只关闭一次
  • 保持现有 Host profile、Runtime Host protocol、credential 与 direct-only authority 边界不变

关联 #3842

验证

  • cargo clippy --locked --all-targets --manifest-path native/runtime-host-peer/Cargo.toml -- -D warnings
  • cargo test --locked --manifest-path native/runtime-host-peer/Cargo.toml
  • Runtime Host、CLI 与 Desktop typecheck
  • Runtime Host peer、CLI context 与 Desktop manager 的针对性测试
  • Native smoke:同一个 Client Swarm 并发打开到两个独立 peer endpoint 的 stream
  • ASF headers、peer dependency inventory 与 peer notices 检查

本地未运行全仓库测试;本次有界重构已覆盖受影响测试,并由仓库 CI 补充验证。

AI 使用

  • 没有生成式工具作出实质贡献
  • 生成式工具作出实质贡献

工具与范围:OpenAI Codex 在 M4n5ter 的指导和审核下实现并验证本次重构。提交已包含所需的 Generated-by: Codex trailer。

检查清单

  • 测试覆盖本次变更,且在缺少本次修复时会失败
  • lint、format、typecheck 与受影响测试均在本地通过

本 PR 是否改变行为?

  • 是 — Direct 连接现在共享 Client 生命周期级 peer endpoint

@M4n5ter
M4n5ter force-pushed the refactor/runtime-host-share-client-peer-endpoint branch from f5a5dd7 to 11ccea3 Compare August 27, 2026 17:02
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Aug 27, 2026
@M4n5ter
M4n5ter force-pushed the refactor/runtime-host-share-client-peer-endpoint branch 13 times, most recently from 4797a05 to 175f390 Compare August 27, 2026 18:46
@M4n5ter
M4n5ter marked this pull request as ready for review August 28, 2026 00:00
@github-actions github-actions Bot added effort/XL Over 1000 readable lines and removed effort/M Under 500 readable lines labels Aug 28, 2026
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
@M4n5ter
M4n5ter force-pushed the refactor/runtime-host-share-client-peer-endpoint branch from 175f390 to 542784d Compare August 28, 2026 01:18

@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 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 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 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
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

@M4n5ter
M4n5ter merged commit 172bcfd into main Aug 28, 2026
15 checks passed
@M4n5ter
M4n5ter deleted the refactor/runtime-host-share-client-peer-endpoint branch August 28, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Over 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants