Skip to content

Fix #1747: bridge.cts 启动竞态: startStdioServer 应在 core.init 之前启动#2046

Merged
syzsunshine219 merged 1 commit into
MemTensor:dev-v2.0.22from
Memtensor-AI:bugfix/autodev-1747
Jul 2, 2026
Merged

Fix #1747: bridge.cts 启动竞态: startStdioServer 应在 core.init 之前启动#2046
syzsunshine219 merged 1 commit into
MemTensor:dev-v2.0.22from
Memtensor-AI:bugfix/autodev-1747

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Investigation for issue #1747 found the requested structural fix — moving startStdioServer({ core }) before await core.init() in apps/memos-local-plugin/bridge.cts — already landed on the base branch dev-20260624-v2.0.22 via commit 7c6bd250 (May 2026). The current bridge.cts starts the stdio server at line 328 and only awaits core.init() at line 338, so the reported orphan-episode startup race is no longer reproducible.

To prevent a future refactor from silently reversing that ordering, this branch adds a regression test at apps/memos-local-plugin/tests/unit/bridge/startup-order.test.ts with two vitest cases: (1) startStdioServer returns before core.init() resolves, using a stub MemoryCore whose init() blocks 50 ms to simulate orphan recovery, and (2) core.init() runs concurrently with stdio startup — measured wall-clock time confirms stdio is available in ≪ init-delay ms. Negative verification: reversing the order in a scratch script trips the first assertion as expected.

Full bridge unit suite passes: tests/unit/bridge/stdio.test.ts (5), methods.test.ts (10), and the new startup-order.test.ts (2) — 17/17 tests green. tsc --noEmit is clean. No lockfile or source changes were made. Suggested follow-ups from the issue (removing the dead CORE_INIT RPC method; adding a server.ready signal) are deliberately out of scope and can be filed as separate tickets.

Task file archived to memos-autodev-specs main branch at commit d4525a4. Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller.

Related Issue (Required): Fixes #1747

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Automated tests are pending.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.

Reviewer Checklist

…ering (MemTensor#1747)

Add regression coverage for MemTensor#1747: the Hermes stdio bridge must call
startStdioServer() BEFORE awaiting core.init(). Otherwise orphan-episode
recovery (LLM-heavy, 10-60+s) inside init() blocks the stdio read loop,
and the Python adapter times out on the first session.open RPC.

The structural fix already shipped in 7c6bd25 (May 2026). This test
prevents the ordering from being silently reversed by a future refactor:

* startStdioServer returns before core.init() resolves
* core.init() runs concurrently with stdio (stdio available within ms,
  not after the init-block delay)

Uses a stub MemoryCore with a delayed init to simulate orphan recovery.
Full bridge suite: 17/17 tests pass. Type-check clean.

Closes MemTensor#1747
@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

🤖 Open Code Review

Target: PR #2046
Task: 31f2fe4d89e96947
Base: dev-20260624-v2.0.22
Head: bugfix/autodev-1747

OpenCodeReview: No supported files changed.

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

All tests passed (2/2 executed). memos_local_plugin/unit: 2/2. Duration: 3s

Branch: bugfix/autodev-1747

@Memtensor-AI Memtensor-AI changed the base branch from dev-20260624-v2.0.22 to dev-v2.0.22 July 2, 2026 12:36
@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

Automated Test Results: PASSED

Cloud test-engine run tr-a4543582-27f completed successfully.

  • Base: dev-v2.0.22
  • Scopes tested: memos_local_plugin
  • Result: 2/2 tests passed
  • Duration: 3s

This PR has cloud test coverage for the changed plugin scope. Manual review is still required before merge.

@syzsunshine219 syzsunshine219 merged commit 62af341 into MemTensor:dev-v2.0.22 Jul 2, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated bug Something isn't working | 功能异常

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants