Skip to content

fix(nodes, test): scope core-module stubs so they don't leak across tests - #1642

Merged
dsapandora merged 6 commits into
developfrom
fix/test-sys-modules-isolation
Jul 22, 2026
Merged

dsapandora merged 6 commits into
developfrom
fix/test-sys-modules-isolation

Conversation

@dsapandora

@dsapandora dsapandora commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Several node tests installed stubs for core modules (rocketlib + submodules, pydantic, and their ai.common.*/requests/tenacity companions) into sys.modules at import time and never restored them. The stub stayed global for the rest of the pytest session and leaked into unrelated tests that import the real module.
  • Wrap each stub so it lives only while the node code is imported, and restore sys.modules in a finally. Switch setdefault to direct assignment so a stub left contaminated by another test can't be reused.
  • No test logic or assertions changed — only the stub lifecycle.

Type

test / bug fix (test isolation)

Testing

  • Tests updated (stub save/restore added; behaviour unchanged)
  • Tested locally (lint green: ruff; full suite runs in CI — no engine locally)
  • ./builder test passes (runs in CI on this PR)

Checklist

  • Commit messages follow conventional commits
  • No secrets or credentials included
  • Wiki updated (if applicable) — N/A
  • Breaking changes documented — none; test-only, no runtime behaviour changes

Linked Issue

Fixes #1640

Context: this unblocks #1636 (node-family renames), which does nothing to these tests but reorders pytest collection and surfaces the leak. With isolation fixed here, any reorder stays green.

Summary by CodeRabbit

  • Bug Fixes / Test Reliability
    • Improved test isolation by scoping dependency stubs to each test’s import window and restoring prior sys.modules state afterward.
    • Applied a consistent save-install-restore pattern across node and tool tests to prevent mock/module leakage between tests.
    • Updated dynamic imports to avoid persistent stub injection while keeping existing assertions unchanged.
    • Added an automatic pytest regression guard that detects leaked stubbed core modules and fails the test to enforce correct isolation.

@dsapandora
dsapandora requested a review from jmaionchi as a code owner July 20, 2026 19:29
Copilot AI review requested due to automatic review settings July 20, 2026 19:29
@github-actions github-actions Bot added the module:nodes Python pipeline nodes label Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Test import helpers now scope mocked dependency modules to module loading and restore prior sys.modules state. An autouse pytest guard detects leaked core-module stubs, while existing functional assertions remain unchanged.

Changes

Test import isolation

Layer / File(s) Summary
Core module leak detection
nodes/test/conftest.py
An autouse fixture scans guarded core modules, identifies leaked stubs, and fails tests that leave them in sys.modules.
Dynamic loader stub restoration
nodes/test/atlas/..., nodes/test/cloud_tts/..., nodes/test/guardrails/..., nodes/test/qdrant/...
Dynamic imports snapshot existing dependency modules, use temporary stubs, and restore or remove entries afterward.
Direct node import restoration
nodes/test/test_anomaly_detector.py, nodes/test/test_currency_convert_explicit.py
rocketlib stubs are limited to import windows and prior module state is restored.
Tool and fixture restoration
nodes/test/tool_*/..., nodes/test/test_db_hydradb.py
Tool setup installs fresh dependency stubs for imports, then restores prior modules; the HydraDB fixture applies the same behavior during teardown.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: jmaionchi, stepmikhaylov, rod-christensen, copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: scoping core-module stubs so they do not leak between tests.
Linked Issues check ✅ Passed The PR restores stubbed core modules around node imports and adds a guard against leaked stubs, matching the isolation fix in #1640.
Out of Scope Changes check ✅ Passed The changes stay focused on test isolation and leak prevention, with no unrelated runtime or feature work.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/test-sys-modules-isolation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

This PR improves pytest isolation for node/unit tests by scoping hand-rolled stubs for engine-only/core modules to the narrow import window that needs them, and restoring sys.modules immediately afterward. This prevents cross-test contamination when collection/execution order changes.

Changes:

  • Wrapped core-module stubbing (rocketlib, pydantic, ai.common.*, requests, tenacity) in try/finally blocks that restore prior sys.modules entries.
  • Replaced several sys.modules.setdefault(...) usages with direct assignment to avoid reusing previously-contaminated stubs.
  • Applied the pattern across multiple test modules that import node code under synthetic module/package setups.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
nodes/test/tool_xtrace_memory/test_tools.py Save/restore core stubs around node imports to prevent sys.modules leaks.
nodes/test/tool_mem0/test_tools.py Save/restore core stubs around node imports to prevent sys.modules leaks.
nodes/test/tool_filesystem/test_read_size_cap.py Scope rocketlib stub strictly to the node import and restore afterward.
nodes/test/test_currency_convert_explicit.py Scope rocketlib stub to the node import and restore afterward; switch to direct assignment.
nodes/test/test_anomaly_detector.py Scope rocketlib stub to the node import and restore afterward; switch to direct assignment.
nodes/test/guardrails/test_all.py Scope rocketlib stub to dynamic module load and restore afterward.
nodes/test/cloud_tts/test_cloud_tts.py Scope rocketlib/ai.* stubs to node import and restore afterward; switch to direct assignment.
nodes/test/atlas/test_isdeleted_filter.py Scope pydantic stub to dynamic module load and restore afterward; switch to direct assignment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dsapandora dsapandora changed the title test(nodes): scope core-module stubs so they don't leak across tests fix(nodes, test): scope core-module stubs so they don't leak across tests Jul 20, 2026

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nodes/test/tool_mem0/test_tools.py`:
- Around line 143-147: Update the `_ensure_*` helpers defined above the
referenced blocks in `nodes/test/tool_mem0/test_tools.py` (lines 143-147) and
`nodes/test/tool_xtrace_memory/test_tools.py` (lines 134-138) to always create
fresh `types.ModuleType` stubs and assign them directly to `sys.modules`,
removing conditional reuse checks. Preserve each helper’s existing module names
and stub contents so the `_saved_core` snapshot/restore flow provides strict
isolation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 37f73ff6-4a3f-458d-9a17-7dc93b13d864

📥 Commits

Reviewing files that changed from the base of the PR and between 4a09a43 and 44da9d4.

📒 Files selected for processing (8)
  • nodes/test/atlas/test_isdeleted_filter.py
  • nodes/test/cloud_tts/test_cloud_tts.py
  • nodes/test/guardrails/test_all.py
  • nodes/test/test_anomaly_detector.py
  • nodes/test/test_currency_convert_explicit.py
  • nodes/test/tool_filesystem/test_read_size_cap.py
  • nodes/test/tool_mem0/test_tools.py
  • nodes/test/tool_xtrace_memory/test_tools.py

Comment thread nodes/test/tool_mem0/test_tools.py Resolved
dsapandora added a commit that referenced this pull request Jul 21, 2026
Temporary — validates that the isolation fixes (PR #1642 / issue #1640) make
the node renames pass under the reordered pytest collection. This commit will
be reset; the fixes ship in #1642 against develop, not here.
dsapandora added a commit that referenced this pull request Jul 21, 2026
Temporary — validates that the isolation fixes (PR #1642 / issue #1640) make
the node renames pass under the reordered pytest collection. This commit will
be reset; the fixes ship in #1642 against develop, not here.
Copilot AI review requested due to automatic review settings July 21, 2026 08:27
@dsapandora
dsapandora force-pushed the fix/test-sys-modules-isolation branch from 44da9d4 to a8a705d Compare July 21, 2026 08:27

Copilot AI 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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread nodes/test/tool_mem0/test_tools.py Resolved
Copilot AI review requested due to automatic review settings July 21, 2026 14:29
@dsapandora
dsapandora force-pushed the fix/test-sys-modules-isolation branch from a8a705d to 561b75b Compare July 21, 2026 14:29

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread nodes/test/test_db_hydradb.py Resolved

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nodes/test/test_anomaly_detector.py`:
- Around line 13-26: Add the Ruff suppression comment `# noqa: E402` to the
module-level `from detector import AnomalyDetector` statement, leaving the
rocketlib stubbing and import setup unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ca6c0c26-0363-4339-8e37-a6e6603d2f7d

📥 Commits

Reviewing files that changed from the base of the PR and between a8a705d and 561b75b.

📒 Files selected for processing (9)
  • nodes/test/atlas/test_isdeleted_filter.py
  • nodes/test/cloud_tts/test_cloud_tts.py
  • nodes/test/guardrails/test_all.py
  • nodes/test/test_anomaly_detector.py
  • nodes/test/test_currency_convert_explicit.py
  • nodes/test/test_db_hydradb.py
  • nodes/test/tool_filesystem/test_read_size_cap.py
  • nodes/test/tool_mem0/test_tools.py
  • nodes/test/tool_xtrace_memory/test_tools.py

Comment thread nodes/test/test_anomaly_detector.py Resolved
asclearuc
asclearuc previously approved these changes Jul 21, 2026
Node tests stub rocketlib/pydantic/ai.common/requests/tenacity in sys.modules to
import a node without the engine. Several did not restore them, so a stub leaked
into the whole pytest session and broke unrelated tests (tool_slack,
rerank_cohere, face_detection, ...) whenever collection order changed — the
scenario in #1640, which surfaces in a plain `pytest nodes/test` run where the
real modules are not loaded.

- Wrap every stub in save/restore of sys.modules; for tests that build a
  self-contained rocketlib (tool_mem0, tool_xtrace_memory) assign fresh
  ModuleType stubs unconditionally so a foreign stub is never read or mutated.
  atlas drops the pydantic stub entirely (atlas.py loads the real rocketlib via
  ai.common.store, which needs real pydantic). Also covers cloud_tts, guardrails,
  ocr, tool_filesystem, qdrant, test_db_hydradb, anomaly_detector,
  currency_convert.
- Add an autouse guard in conftest.py that fails any test leaving a stub core
  module in sys.modules, so the suite refuses to regress instead of leaking
  silently.

Fixes #1640
Copilot AI review requested due to automatic review settings July 21, 2026 15:08
@dsapandora
dsapandora force-pushed the fix/test-sys-modules-isolation branch from 561b75b to f8bac23 Compare July 21, 2026 15:08

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

nodes/test/test_db_hydradb.py:170

  • The fixture cleanup runs after the yield, but if _install_stubs() or _load_package() raises during setup, teardown won’t run and the partially-installed sys.modules stubs can still leak into later tests. Wrapping the setup + yield in a try/finally ensures the restore always happens.
    _saved = {name: sys.modules.get(name) for name in _managed}
    Config = _install_stubs()
    client_mod, iglobal_mod, iinstance_mod = _load_package()
    yield SimpleNamespace(Config=Config, client_mod=client_mod, iglobal_mod=iglobal_mod, iinstance_mod=iinstance_mod)

Comment thread nodes/test/tool_mem0/test_tools.py Resolved
Comment thread nodes/test/conftest.py Resolved
Comment thread nodes/test/conftest.py Resolved
Comment thread nodes/test/test_anomaly_detector.py Resolved
Copilot AI review requested due to automatic review settings July 21, 2026 23:16

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread nodes/test/_sys_modules_guard.py Resolved
Copilot AI review requested due to automatic review settings July 22, 2026 05:20
@dsapandora
dsapandora force-pushed the fix/test-sys-modules-isolation branch from 14aa1b2 to 8a0b609 Compare July 22, 2026 05:20

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread nodes/test/test_sys_modules_guard.py Resolved
…own test)

asclearuc pointed out the module-scoped guard was fundamentally wrong: stubs
leak at IMPORT time (collection), long before any teardown, so a teardown check
blamed whichever module happened to finish while a later module's leak was
already in sys.modules — one leaker cascaded into N false failures naming
innocent, already-fixed files.

Move the guard to collection-time hooks (pytest_collectstart snapshots each
module's guarded entries, pytest_collectreport compares right after import),
undo each detected leak so it can't cascade, and fail at session finish
(raising inside a collection hook gives INTERNALERROR). The stub heuristic now
keys off __file__/__path__ so it also catches stubs built via module_from_spec.

Extract the guard to _sys_modules_guard.py and add test_sys_modules_guard.py:
it asserts the guard names the real leaker, undoes the leak, does not blame an
earlier clean module, and detects a __spec__-carrying stub.
Copilot AI review requested due to automatic review settings July 22, 2026 05:32
@dsapandora
dsapandora force-pushed the fix/test-sys-modules-isolation branch from 8a0b609 to 51703eb Compare July 22, 2026 05:32

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 22, 2026 06:17

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 22, 2026 07:32
@dsapandora
dsapandora force-pushed the fix/test-sys-modules-isolation branch from 049952d to 51703eb Compare July 22, 2026 07:32

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

nodes/test/_sys_modules_guard.py:118

  • pytest_sessionfinish forces session.exitstatus = 1 whenever leaks are present, which can mask more severe/diagnostic pytest exit codes (e.g. INTERNALERROR/usage errors) by downgrading them to 1. Only override the exit status when the session was otherwise going to succeed (exitstatus == 0).
def pytest_sessionfinish(session, exitstatus):  # noqa: ARG001
    """Fail the run when any test module leaked a core-module stub."""
    if _core_leaks:
        session.exitstatus = 1

@asclearuc asclearuc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rechecked at 51703eb3. The blocking issue from the last round is fully resolved — this is an Approve from me.

The guard now runs at collection time (pytest_collectstart snapshot + pytest_collectreport compare) in a dedicated _sys_modules_guard.py, records leaks and fails the run in pytest_sessionfinish, and undoes each leak so one offender can't cascade. The detection helper is extracted as check_after_import and unit-tested. _is_stub_module now also handles the module_from_spec case (via __path__), and test_sys_modules_guard.py covers it explicitly — both things I'd flagged.

I re-ran the same experiment that failed last round: one deliberate import-time leaker among five modules that restore correctly.

  • Before: 6 errors, five of them blaming innocent files.
  • Now: the leak is attributed to the leaker alone, no false positives, and the run exits 1. Removing the leaker → exit 0. The touched set is 169 passed; the guard's own 4 tests pass.

Two small follow-ups remain (both non-blocking, both flagged inline — fine to defer):

  • test_anomaly_detector.py / test_currency_convert_explicit.py still leave sys.path.insert(...) and the generic sys.modules['detector'] / ['convert'] entries for the session.
  • The hand-rolled save/restore is now in 8 files plus the guard; patch.dict(sys.modules, {...}) would collapse each to one line, and it's already the idiom here (tool_git, milvus, text_output).

Nice work turning the guard around, @dsapandora — the collection-time version plus its own test is exactly right. Approving.

Comment thread nodes/test/test_anomaly_detector.py Resolved
@dsapandora
dsapandora enabled auto-merge (squash) July 22, 2026 10:53
@dsapandora
dsapandora merged commit a438c23 into develop Jul 22, 2026
47 checks passed
@dsapandora
dsapandora deleted the fix/test-sys-modules-isolation branch July 22, 2026 10:54
dsapandora added a commit that referenced this pull request Jul 23, 2026
Now that #1642's collection-time guard undoes the sys.modules stub leaks, the
reordered pytest collection is harmless, so the test folders can follow their
nodes: nodes/test/{astra_db,atlas,chroma,milvus,pinecone,qdrant,weaviate} ->
store_*. Tests load src via ../../src/nodes/store_* (unchanged depth), so only
the two ocr breadcrumbs and two stale "Usage" docstrings needed the new paths.
dsapandora added a commit that referenced this pull request Jul 23, 2026
…o graph_* (#1636)

* refactor(nodes): rename vector stores to store_* and graph-first db to graph_*

Rename the nine vector-store nodes to the store_ prefix (matching their `store`
classType) and the two graph-first databases (ArangoDB, HydraDB) to graph_.
Update each services.json path to the new python module and add graph to the
ArangoDB/HydraDB classType (database and tool kept). protocol and prefix are left
untouched, so saved pipes keep resolving; no services-version bump.

Docs redirects map the old /nodes/<old> URLs to the new ones. Test module imports
and path references follow the renamed src folders. constraints.lock and docs
static pages are regenerated by CI.

Node test folders keep their original names so pytest collection order is unchanged.

* docs(nodes): align renamed node docs with store_*/graph_* identity

Co-located-docs follow-through for the rename in this PR (per asclearuc review):
- 10 node READMEs still carried the old title and a "View source" link to the
  old folder (# milvus -> # store_milvus, .../nodes/milvus ->
  .../nodes/store_milvus), which 404s after merge. store_postgres was already done.
- docs/README-nodes.md: the Vector Databases & Stores table listed the old
  folder-derived ids; refreshed to store_*. The catalog is hand-maintained (no
  generator), so the misleading "generated" note was corrected to match.
- tools/dependabot-smoke/smoke-nodes.sh: index_search -> store_elasticsearch so
  the opensearchpy smoke check keeps resolving after the folder rename.

* test(nodes): rename test folders to store_* to match the renamed nodes

Now that #1642's collection-time guard undoes the sys.modules stub leaks, the
reordered pytest collection is harmless, so the test folders can follow their
nodes: nodes/test/{astra_db,atlas,chroma,milvus,pinecone,qdrant,weaviate} ->
store_*. Tests load src via ../../src/nodes/store_* (unchanged depth), so only
the two ocr breadcrumbs and two stale "Usage" docstrings needed the new paths.
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
…ests (rocketride-org#1642)

* test(nodes): isolate core-module stubs in node tests + regression guard

Node tests stub rocketlib/pydantic/ai.common/requests/tenacity in sys.modules to
import a node without the engine. Several did not restore them, so a stub leaked
into the whole pytest session and broke unrelated tests (tool_slack,
rerank_cohere, face_detection, ...) whenever collection order changed — the
scenario in rocketride-org#1640, which surfaces in a plain `pytest nodes/test` run where the
real modules are not loaded.

- Wrap every stub in save/restore of sys.modules; for tests that build a
  self-contained rocketlib (tool_mem0, tool_xtrace_memory) assign fresh
  ModuleType stubs unconditionally so a foreign stub is never read or mutated.
  atlas drops the pydantic stub entirely (atlas.py loads the real rocketlib via
  ai.common.store, which needs real pydantic). Also covers cloud_tts, guardrails,
  ocr, tool_filesystem, qdrant, test_db_hydradb, anomaly_detector,
  currency_convert.
- Add an autouse guard in conftest.py that fails any test leaving a stub core
  module in sys.modules, so the suite refuses to regress instead of leaking
  silently.

Fixes rocketride-org#1640

* Potential fix for pull request finding

* Potential fix for pull request finding

* fix(test): scope the sys.modules guard to module level

The autouse guard ran per test, so it false-positived on tests that stub a core
module in a scope='module' fixture and restore it at module teardown (e.g.
db_clickhouse). Make the guard scope='module' so it checks after the module's
own fixtures have torn down; it still catches import-time stubs that never
restore.

* test(nodes): address review — package stubs, hydradb try/finally, qdrant assign

- Mark the ai/ai.common stubs as packages (__path__ = []) in tool_mem0,
  tool_xtrace_memory and cloud_tts so ai.common.* sub-imports resolve, matching
  the pattern already used in face_detection/ocr/graph tests.
- test_db_hydradb: wrap fixture setup + yield + restore in try/finally so
  sys.modules is restored even if setup raises.
- qdrant/test_search_threshold: replace setdefault with direct assignment.
- test_anomaly_detector: add noqa: E402 to the post-stub import.

* fix(test): guard sys.modules at collection time, not teardown (+ its own test)

asclearuc pointed out the module-scoped guard was fundamentally wrong: stubs
leak at IMPORT time (collection), long before any teardown, so a teardown check
blamed whichever module happened to finish while a later module's leak was
already in sys.modules — one leaker cascaded into N false failures naming
innocent, already-fixed files.

Move the guard to collection-time hooks (pytest_collectstart snapshots each
module's guarded entries, pytest_collectreport compares right after import),
undo each detected leak so it can't cascade, and fail at session finish
(raising inside a collection hook gives INTERNALERROR). The stub heuristic now
keys off __file__/__path__ so it also catches stubs built via module_from_spec.

Extract the guard to _sys_modules_guard.py and add test_sys_modules_guard.py:
it asserts the guard names the real leaker, undoes the leak, does not blame an
earlier clean module, and detects a __spec__-carrying stub.
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
…o graph_* (rocketride-org#1636)

* refactor(nodes): rename vector stores to store_* and graph-first db to graph_*

Rename the nine vector-store nodes to the store_ prefix (matching their `store`
classType) and the two graph-first databases (ArangoDB, HydraDB) to graph_.
Update each services.json path to the new python module and add graph to the
ArangoDB/HydraDB classType (database and tool kept). protocol and prefix are left
untouched, so saved pipes keep resolving; no services-version bump.

Docs redirects map the old /nodes/<old> URLs to the new ones. Test module imports
and path references follow the renamed src folders. constraints.lock and docs
static pages are regenerated by CI.

Node test folders keep their original names so pytest collection order is unchanged.

* docs(nodes): align renamed node docs with store_*/graph_* identity

Co-located-docs follow-through for the rename in this PR (per asclearuc review):
- 10 node READMEs still carried the old title and a "View source" link to the
  old folder (# milvus -> # store_milvus, .../nodes/milvus ->
  .../nodes/store_milvus), which 404s after merge. store_postgres was already done.
- docs/README-nodes.md: the Vector Databases & Stores table listed the old
  folder-derived ids; refreshed to store_*. The catalog is hand-maintained (no
  generator), so the misleading "generated" note was corrected to match.
- tools/dependabot-smoke/smoke-nodes.sh: index_search -> store_elasticsearch so
  the opensearchpy smoke check keeps resolving after the folder rename.

* test(nodes): rename test folders to store_* to match the renamed nodes

Now that rocketride-org#1642's collection-time guard undoes the sys.modules stub leaks, the
reordered pytest collection is harmless, so the test folders can follow their
nodes: nodes/test/{astra_db,atlas,chroma,milvus,pinecone,qdrant,weaviate} ->
store_*. Tests load src via ../../src/nodes/store_* (unchanged depth), so only
the two ocr breadcrumbs and two stale "Usage" docstrings needed the new paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test pollution: node tests leak core-module stubs (rocketlib/pydantic) into sys.modules

3 participants