Skip to content

Fix #1797: bug(hermes): _bridge_ok cache permanently disables provider after transient star - #2001

Merged
syzsunshine219 merged 1 commit into
dev-v2.0.22from
bugfix/autodev-1797
Jul 2, 2026
Merged

syzsunshine219 merged 1 commit into
dev-v2.0.22from
bugfix/autodev-1797

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Fixes #1797: _bridge_ok cache in apps/memos-local-plugin/adapters/hermes/memos_provider/daemon_manager.py had no expiry, so a single transient _node_available() failure during Hermes gateway startup permanently disabled MemTensorProvider. The cache now expires after 60 seconds, and _node_available() failures fall through to a _probe_viewer() check that accepts an already-running MemOS bridge on :18800 as proof the environment is viable. shutdown_bridge() also resets the new _bridge_ok_at timestamp.

Added regression tests (BridgeOkCacheTests, 6 cases) covering cold-start revalidation, cache-hit short-circuit within TTL, TTL-expiry recovery, running-bridge fallback, shutdown reset, and full-call (non-probe) revalidation. Full plugin python suite green: 48 passed (42 existing + 6 new). Ruff lint and format both clean. Branch bugfix/autodev-1797 pushed to origin; openspec artifacts archived to memos-autodev-specs.

Related Issue (Required): Fixes #1797

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

The module-level _bridge_ok cache in daemon_manager.py had no expiry, so a
single transient _node_available() failure during Hermes gateway startup
(subprocess race, .env loaded after the first probe) permanently pinned
MemTensorProvider.is_available() to False. MemOS stayed silently offline for
the lifetime of the gateway even after the bridge daemon came up healthy.

This change introduces a 60s TTL on the cached answer and adds a
_probe_viewer() fallback: when _node_available() fails but a MemOS bridge is
already alive on :18800, treat the environment as viable (the bridge itself
was launched via Node). shutdown_bridge() now also clears the timestamp so a
later re-init starts from a clean slate.

Adds BridgeOkCacheTests covering cache hit, TTL expiry recovery, running-
bridge fallback, shutdown reset, and full-call revalidation. 48/48 python
tests pass.

Closes #1797
@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

No applicable test scope for the changed files — automated tests skipped. Changed paths do not map to any configured scope (env.yaml source_mapping). Manual review recommended.

Branch: bugfix/autodev-1797

@syzsunshine219
syzsunshine219 changed the base branch from dev-20260624-v2.0.22 to dev-v2.0.22 July 1, 2026 07:14
@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

❌ Automated Test Results: FAILED

Auto-fix retry 1/2 triggered.

Failed tests:

  • test_out_of_range_rejected_or_clamped_to_valid[negative_1]
  • test_out_of_range_rejected_or_clamped_to_valid[negative_60s]
  • test_out_of_range_rejected_or_clamped_to_valid[negative_one_day]
  • test_out_of_range_rejected_or_clamped_to_valid[max_plus_1]
  • test_out_of_range_rejected_or_clamped_to_valid[max_plus_one_day]
  • test_out_of_range_rejected_or_clamped_to_valid[hundred_x_max]
  • test_invalid_type_does_not_crash_or_corrupt[string_number]
  • test_invalid_type_does_not_crash_or_corrupt[string_text]
  • test_invalid_type_does_not_crash_or_corrupt[none_value]
  • test_invalid_type_does_not_crash_or_corrupt[dict_value]
Error details
The vector_scan max_age contract tests reveal that the memos provider does not validate or clamp out-of-range and invalid-type inputs on PATCH; dirty values (negatives, over-max, strings, None, dicts) round-trip through GET unchanged. AI-generated tests: 26/26 passed.

Branch: bugfix/autodev-1797

@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

Automated Test Results: PASSED

Cloud test-engine rerun against dev-v2.0.22 completed successfully.

  • Run: tr-8393a7da-371 on cloud test-engine 10011
  • Scope: memos_local_plugin/changed-repo-python
  • Result: 40 passed, 0 failed, 0 skipped

This replaces the earlier no-scope/failed signal for this PR. Manual code review is still required before merge.

@syzsunshine219
syzsunshine219 merged commit c507b04 into dev-v2.0.22 Jul 2, 2026
16 checks passed
@syzsunshine219
syzsunshine219 deleted the bugfix/autodev-1797 branch July 2, 2026 11:28
steven-stack-s pushed a commit to steven-stack-s/dsh-memos-local that referenced this pull request Sep 18, 2026
…s provider after transient star (MemTensor#2001)

fix(hermes): expire _bridge_ok cache so MemTensorProvider self-heals

The module-level _bridge_ok cache in daemon_manager.py had no expiry, so a
single transient _node_available() failure during Hermes gateway startup
(subprocess race, .env loaded after the first probe) permanently pinned
MemTensorProvider.is_available() to False. MemOS stayed silently offline for
the lifetime of the gateway even after the bridge daemon came up healthy.

This change introduces a 60s TTL on the cached answer and adds a
_probe_viewer() fallback: when _node_available() fails but a MemOS bridge is
already alive on :18800, treat the environment as viable (the bridge itself
was launched via Node). shutdown_bridge() now also clears the timestamp so a
later re-init starts from a clean slate.

Adds BridgeOkCacheTests covering cache hit, TTL expiry recovery, running-
bridge fallback, shutdown reset, and full-call revalidation. 48/48 python
tests pass.

Closes MemTensor#1797

Co-authored-by: MemOS AutoDev <autodev@memtensor.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:generated Generated or modified by AI | 由 AI 生成或修改 types:bug Something isn't working | 功能异常

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants