Skip to content

fix(desktop): connect shared sessions through Peer Mesh - #4238

Merged
M4n5ter merged 14 commits into
mainfrom
feat/local-host-peer-mesh-membership
Aug 30, 2026
Merged

fix(desktop): connect shared sessions through Peer Mesh#4238
M4n5ter merged 14 commits into
mainfrom
feat/local-host-peer-mesh-membership

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Aug 30, 2026

Copy link
Copy Markdown
Member
English

Summary

  • Distinguish the Desktop Client from managed Runtime Hosts and let each endpoint join, create, and manage Peer Meshes explicitly
  • Expose Peer Mesh management directly from managed Remote Host actions and recover stale authority routes through the trusted management channel
  • Persist signed endpoint and Mesh display names, make full Peer/Mesh identifiers copyable, and keep large Mesh lists collapsed by default
  • Keep collaboration connection progress visible while preserving the separation between Mesh membership and Session authority

Refs #3843

Verification

  • npm run typecheck
  • node --test packages/runtime-host/dist/__tests__/peer-mesh.test.js — 10 passed
  • node --test packages/cli/dist/__tests__/runtime-host-operator-command.test.js — 6 passed
  • Desktop local/SSH management suites — 27 passed
  • npm --workspace @maka/desktop run build:renderer
  • npm run check:asf-headers
  • npm run astryx:surface-inventory
  • Verified the Desktop Client and local Runtime Host flows with npm run dev:peer, including aliases, collapsed/expanded Mesh cards, identifier copying, and managed-Host reconciliation

Collapsed Peer Mesh management with distinct Desktop and Host endpoints

AI use

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

Tool(s) and scope: OpenAI Codex assisted with implementation, tests, and UI verification under M4n5ter's direction

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 — described under Summary above
  • No
简体中文

概要

  • 明确区分 Desktop Client 与受管 Runtime Host,使每个 endpoint 都能显式加入、创建和管理 Peer Mesh
  • 在受管 Remote Host 的操作菜单中直接提供 Peer Mesh 管理,并通过可信管理通道恢复过期的 authority route
  • 持久化并签名 endpoint 与 Mesh 别名,支持点击复制完整 Peer/Mesh ID,并默认折叠 Mesh 列表
  • 保持协作连接进度可见,同时维持 Mesh membership 与 Session authority 的边界

关联 #3843

验证

  • npm run typecheck
  • node --test packages/runtime-host/dist/__tests__/peer-mesh.test.js — 10 项通过
  • node --test packages/cli/dist/__tests__/runtime-host-operator-command.test.js — 6 项通过
  • Desktop 本地/SSH 管理测试 — 27 项通过
  • npm --workspace @maka/desktop run build:renderer
  • npm run check:asf-headers
  • npm run astryx:surface-inventory
  • 使用 npm run dev:peer 验证 Desktop Client 与本机 Runtime Host,包括别名、Mesh 折叠/展开、ID 复制及受管 Host 同步恢复

默认折叠并区分 Desktop 与 Host endpoint 的 Peer Mesh 管理界面

AI 使用

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

工具及范围:OpenAI Codex 在 M4n5ter 指导下协助实现、测试和 UI 验证

检查清单

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

本 PR 是否改变行为?

  • 是 — 已在概要中说明

@github-actions github-actions Bot added the effort/XL Over 1000 readable lines label Aug 30, 2026

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review result: P1 NO-GO on the current head. The new signed endpoint/mesh name fields are emitted on the existing Peer Mesh v1 wire format, but the previous v1 decoder rejects those extra keys, so rolling upgrades can partition existing meshes even though all hosted checks are green.

Validation: full npm run build:test; 43 focused Peer Mesh/operator/Desktop tests; git diff --check; direct new-encoder/old-decoder reproduction.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

Comment thread packages/runtime-host/src/peer-mesh/node.ts

@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.

Approved at the author's explicit direction for exact head bd7d05912b2f5cf8cbf1a582e3644ee21b99d814.


Automated review notice: This comment was posted by an automated review agent operated by WAWQAQ. It is not an independent human review and does not replace one.

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 5ab8868728ea52a06963e9a743d367ca86366ed9. I found no P0-P3 issues in the current diff.

The follow-up correctly allows the managed-service operator launcher to append its validated --client-data-root argument to Peer Mesh commands while keeping control/deployment lookup bound to the verified managed root identity. I also re-evaluated my earlier mixed-version concern: Peer Mesh was introduced after the latest release tag (v0.1.11), so this PR is defining its first released v1 shape rather than regressing a supported rolling-upgrade contract. That earlier concern is therefore not a blocker for this head.

Validation: full npm run build:test; all CLI tests (633/633); focused Desktop operator/profile tests (33/33); focused Peer Mesh/native tests (14/14); git diff --check; all hosted checks successful. Local Rust tests were not rerun because this host has Rust 1.75 while the repository requires Rust 1.98+, but the hosted Rust quality job and all native-addon platform builds passed.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review result: P1 NO-GO on exact head 9880cf48ca4cdc82b8d36bfbe4ea119ae30da766.

The new concurrent recovery path can indefinitely preserve an expired authority route whenever any reachable gossip member responds faster than the authority. This keeps application route discovery from recovering the direct authority path even though the authority remains reachable.

Validation: clean npm run build:test; focused Peer Mesh/native tests 14/14; lint and format checks; git diff --check; a deterministic three-reconcile reproduction with a reachable authority delayed by 25 ms. All hosted checks are terminal green, but the PR is currently conflicting with the latest main.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

this.#syncPeer(meshId, target, AbortSignal.any([signal, controllers[index]!.signal])),
);
try {
await Promise.any(attempts);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Do not let a gossip-only success cancel route recovery from the authority

When the stored authority route is expired, this Promise.any treats any fulfilled sync as sufficient and immediately aborts every other attempt. A reachable gossip member can legitimately return a successful sync without a fresh authority route because responseRoutes only includes live routes that member currently knows. If that member is consistently faster, every reconciliation cancels the still-reachable authority before it responds, so the authority record remains stale indefinitely and resolveRoutes(authorityPeerId) cannot recover its direct route.

I reproduced this by expiring all routes, keeping the authority reachable with only a 25 ms response delay, refreshing another member, and reconciling the affected member three times: the authority entry stayed stale each time. Making the gossip peer unreachable allowed the next reconciliation to refresh the authority immediately, confirming the race. Please only consider a fallback successful for this branch if it actually installs a fresh authority route, or otherwise allow the authority attempt to complete.

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review result: P1 NO-GO on exact head 42a056a79ec7a8c0ce4cb13abb84c47b6d81ea38. The previous authority-route starvation finding is fixed, but the new cancellation UI does not actually cancel non-reconcile Peer Mesh mutations.

Validation: clean npm run build:test; full typecheck; focused Runtime Host suites 44/44, Desktop management suites 33/33, Peer Mesh/native suites 14/14, Desktop profile/manager suites 74/74; changed-file Biome; git diff --check; and a direct IPC cancellation reproduction. The PR currently has no hosted checks and remains conflicting with current main.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

return response.result;
};
if (action === 'reconcile') return reconcileManagedTarget(input.localMesh?.(), run, signal);
return run({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Propagate the operation signal to cancellable mutations

The controller created for operationId is dropped here (and in the managed-host branch below), because this command object omits signal; executeLocal likewise calls mesh.join(...) and mesh.leave(...) without passing its signal. The dialog exposes Cancel for these operations and closes immediately after invoking it, so a stalled join/leave can keep running and later commit a membership change after the user believes it was cancelled. I reproduced both Desktop leave and local-host leave through the IPC handlers: the callee observed signalPassed: false, and both promises were still pending after runtime-host-peer-mesh:cancel. Please pass the signal through every networked mutation and add cancellation regressions for Desktop and managed targets.

M4n5ter added 12 commits August 30, 2026 20:39
Join managed Runtime Hosts through explicit Client and Host Mesh targets, recover stale authority routes over management channels, and expose managed Host Mesh actions directly.

Persist signed endpoint and Mesh names, keep stable identifiers copyable, and make Mesh rosters collapsible without exposing internal revisions.

Generated-by: Codex
Activate Relay v2 reservations when transit policy is added to an existing peer connection, and preserve native path failures as stable errors. Keep managed endpoint metadata and signed routes atomic while tightening the Desktop management boundary.

Generated-by: OpenAI Codex
Allow the generic managed-service operator launcher to pass its validated client data root through Peer Mesh commands, so Desktop can reconcile managed Hosts instead of failing during argument parsing.

Generated-by: OpenAI Codex
@M4n5ter
M4n5ter force-pushed the feat/local-host-peer-mesh-membership branch from 42a056a to 1b4aba0 Compare August 30, 2026 12:40
@M4n5ter
M4n5ter merged commit 4cbe224 into main Aug 30, 2026
15 checks passed
@M4n5ter
M4n5ter deleted the feat/local-host-peer-mesh-membership branch August 30, 2026 13:33
saltand pushed a commit to saltand/maka-agent that referenced this pull request Aug 31, 2026
* fix(desktop): connect shared sessions through Peer Mesh

Join managed Runtime Hosts through explicit Client and Host Mesh targets, recover stale authority routes over management channels, and expose managed Host Mesh actions directly.

Persist signed endpoint and Mesh names, keep stable identifiers copyable, and make Mesh rosters collapsible without exposing internal revisions.

Generated-by: Codex

* fix(peer): connect Mesh members to managed Hosts

Activate Relay v2 reservations when transit policy is added to an existing peer connection, and preserve native path failures as stable errors. Keep managed endpoint metadata and signed routes atomic while tightening the Desktop management boundary.

Generated-by: OpenAI Codex

* fix(cli): accept managed Mesh operator context

Allow the generic managed-service operator launcher to pass its validated client data root through Peer Mesh commands, so Desktop can reconcile managed Hosts instead of failing during argument parsing.

Generated-by: OpenAI Codex

* fix(peer): recover Mesh routes through reachable members

Generated-by: OpenAI Codex

* fix(desktop): make peer collaboration recoverable

* fix(peer): preserve active Mesh transport paths

* fix(desktop): recover interrupted managed Host setup

* fix(desktop): activate managed Host Peer Mesh

* fix(cli): replace incompatible development Hosts

* refactor(desktop): isolate Runtime Host management UI

* test(runtime-host): finalize owner pairings explicitly

* fix(desktop): make Peer Mesh refresh local and bounded

* style(cli): format Runtime Host setup changes

* docs(astryx): refresh surface inventory
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.

3 participants