Skip to content

Bump reflexio-ai to 0.2.25 (CPU-default reranker) + venv-direct backend with vendored-install self-repair#72

Merged
yyiilluu merged 5 commits into
mainfrom
fix/rerank-cpu-device
Jun 10, 2026
Merged

Bump reflexio-ai to 0.2.25 (CPU-default reranker) + venv-direct backend with vendored-install self-repair#72
yyiilluu merged 5 commits into
mainfrom
fix/rerank-cpu-device

Conversation

@yyiilluu

@yyiilluu yyiilluu commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

Two related changes that together fix the multi-GB memory footprint of the claude-smart backend on Apple Silicon and harden how the plugin runs its Python environment.

1. reflexio-ai 0.2.25 (ReflexioAI/reflexio#143)

The relevance-floor cross-encoder previously auto-selected MPS on Apple Silicon; torch's MPS caching allocator accumulated GPU buffers across searches and never released them — measured at 4.4 GB physical footprint (3.0 GB IOAccelerator/MPS) on a live backend. 0.2.25 defaults the reranker to CPU with a REFLEXIO_RERANK_DEVICE override (documented in DEVELOPER.md) and silences tqdm batch bars in server logs.

Verified live: after a 12-query /api/search burst on the fixed backend, vmmap shows no IOAccelerator region and a 982 MB footprint (peak 1.2 GB) — a ~3.4 GB reduction — with relevance-floor filtering still active.

Lock returned to the strict PyPI source via REFLEXIO_RELEASE_SOURCE=pypi scripts/release-with-reflexio.sh (release checks + full test suite + npm pack passed).

2. Backend runs from the prepared venv with vendored-install self-repair

  • Vendored Reflexio installs use --reinstall --no-deps (not editable) so the venv always matches the shipped vendor snapshot.
  • Hooks, CLI, and backend invoke the prepared venv interpreter directly instead of uv run.
  • ensure_vendored_reflexio_active repairs a stale reflexio-ai install before backend start (covered in tests/test_install_scripts.py).
  • ensure-plugin-root.sh resolves the symlink target to a physical path.

Tests

  • 87/87 install-script tests pass.
  • Full suite run by the pypi release flow passed.

Summary by CodeRabbit

  • Documentation

    • Documented REFLEXIO_RERANK_DEVICE environment variable to configure the reranker device.
  • Chores

    • Bumped Reflexio dependency to v0.2.25.
    • Improved vendored component installation, verification, and backend startup to be more reliable.
    • Normalized plugin-root handling and switched CLI/hook execution to use the prepared plugin Python environment.
  • Tests

    • Updated and added tests to reflect installer, startup, and plugin-root behaviors.

yyiilluu added 2 commits June 10, 2026 11:07
… Reflexio

Replace editable vendored Reflexio installs with --reinstall --no-deps so
the venv always matches the shipped vendor snapshot, invoke the prepared
venv's interpreter directly from hooks/CLI/backend instead of uv run,
resolve plugin-root to a physical path, and add
ensure_vendored_reflexio_active to repair a stale reflexio-ai install
before backend start.
reflexio-ai 0.2.25 defaults the relevance-floor cross-encoder to CPU
(REFLEXIO_RERANK_DEVICE override available), eliminating ~3 GB of MPS
memory the backend accumulated on Apple Silicon. Document the new env
var in DEVELOPER.md and return the lock to the strict PyPI source.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • plugin/uv.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b2b50ee-519d-43ba-8ee5-983ae250b37d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Upgrade reflexio-ai to 0.2.25, replace editable vendored installs with non-editable reinstalls, add a vendored-version check/repair at backend start, run Reflexio/CLI/hooks via the prepared venv Python with PYTHONPATH wiring, canonicalize plugin-root symlink targets, and update tests.

Changes

Reflexio Installation and Execution Refactoring

Layer / File(s) Summary
Version bump and environment documentation
plugin/pyproject.toml, reflexio.lock.json, DEVELOPER.md
Upgrade reflexio-ai to >=0.2.25 and document the REFLEXIO_RERANK_DEVICE environment variable.
Vendored Reflexio installation model transition
bin/claude-smart.js, plugin/scripts/smart-install.sh, scripts/release-with-reflexio.sh
Replace editable (-e) installs with non-editable uv pip install --reinstall --no-deps across bootstrap, smart-install, and release flows.
Backend service runtime refactoring with vendored check
plugin/scripts/backend-service.sh
Add ensure_vendored_reflexio_active() to detect/repair vendored version mismatches; compute backend_pythonpath (prepend vendor/reflexio when present) and launch Reflexio with the prepared venv Python (-m reflexio.cli).
CLI and hook execution model update
plugin/scripts/cli.sh, plugin/scripts/hook_entry.sh, plugin/scripts/ensure-plugin-root.sh
Run CLI and hook entry points using resolved plugin venv Python (claude_smart_plugin_python) instead of uv run; canonicalize TARGET to a physical absolute path for .reflexio/plugin-root.
Test suite validation
tests/test_install_scripts.py
Add test_backend_service_uses_prepared_venv_reflexio_cli; tighten vendored install assertions to --reinstall --no-deps; add test_ensure_plugin_root_canonicalizes_symlink_target; refactor hook-entry tests to use isolated plugin trees.

Sequence Diagram(s)

sequenceDiagram
  participant BackendScript as backend-service.sh
  participant PreparedVenvPython as prepared venv Python
  participant UVpip as uv pip
  participant ReflexioCLI as reflexio.cli
  BackendScript->>PreparedVenvPython: ensure_vendored_reflexio_active() (read vendor pyproject.toml)
  PreparedVenvPython->>BackendScript: compare installed reflexio-ai version
  BackendScript->>UVpip: uv pip install --reinstall --no-deps vendor/reflexio (on mismatch)
  BackendScript->>PreparedVenvPython: set PYTHONPATH and exec -m reflexio.cli services start
  PreparedVenvPython->>ReflexioCLI: start backend service
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

"I'm a rabbit in a dev tree's glade,
Swapping -e for reinstalls that won't fade,
Venvs now lead, PYTHONPATH in hand,
Symlinks fixed, the backend takes its stand,
Hooray for tidy boots and tests that stayed!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% 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 comprehensively covers both main changes: the reflexio-ai 0.2.25 bump with CPU-default reranker and the venv-direct backend architecture with vendored-install self-repair logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rerank-cpu-device

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@plugin/scripts/backend-service.sh`:
- Around line 186-213: The function ensure_vendored_reflexio_active currently
hardcodes plugin_python to "$PLUGIN_ROOT/.venv/bin/python" which breaks Windows;
replace that assignment to use the existing helper claude_smart_plugin_python
(same name used in cli.sh) to resolve the platform-specific venv python path,
keep the rest of the function unchanged (references:
ensure_vendored_reflexio_active, plugin_python, claude_smart_plugin_python) so
the subsequent Python check and pip install use the correct executable on
Windows and Unix.
- Around line 315-320: The call to claude_smart_spawn_detached hardcodes
"$PLUGIN_ROOT/.venv/bin/reflexio" which breaks Windows; compute a platform-aware
reflexio binary path (like plugin_python is resolved) into a variable (e.g.,
reflexio_bin) that picks ".venv/bin/reflexio" on Unix and
".venv/Scripts/reflexio" or ".venv/Scripts/reflexio.exe" on Windows, then
replace the hardcoded path in the claude_smart_spawn_detached invocation with
that reflexio_bin variable so the script works cross-platform.

In `@plugin/scripts/hook_entry.sh`:
- Around line 6-7: Update the header comment in hook_entry.sh to correctly state
that vendored Reflexio is installed non-editably (using the --reinstall
--no-deps style) rather than as an editable install; reference the
smart-install.sh behavior and the relevant tests
(test_reflexio_vendor_release_uses_generated_bundle and
test_smart_install_installs_vendored_reflexio) in the comment so it accurately
describes that hooks use the dependency set produced by smart-install.sh which
includes non-editable vendored Reflexio installs.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e2d6475-7631-4097-a393-80e3ffa8f3f6

📥 Commits

Reviewing files that changed from the base of the PR and between 5f5f963 and f207ffe.

📒 Files selected for processing (11)
  • DEVELOPER.md
  • bin/claude-smart.js
  • plugin/pyproject.toml
  • plugin/scripts/backend-service.sh
  • plugin/scripts/cli.sh
  • plugin/scripts/ensure-plugin-root.sh
  • plugin/scripts/hook_entry.sh
  • plugin/scripts/smart-install.sh
  • reflexio.lock.json
  • scripts/release-with-reflexio.sh
  • tests/test_install_scripts.py

Comment thread plugin/scripts/backend-service.sh
Comment thread plugin/scripts/backend-service.sh
Comment thread plugin/scripts/hook_entry.sh Outdated
yyiilluu added 3 commits June 10, 2026 11:30
ensure_vendored_reflexio_active hardcoded the Unix venv python path;
resolve it via claude_smart_plugin_python like cli.sh and hook_entry.sh.
Launch the backend with the venv python via -m reflexio.cli instead of
the Unix-only .venv/bin/reflexio entry point, and build PYTHONPATH with
a ;-separator and cygpath-converted vendor path on Windows, since native
Windows Python does not understand :-separated MSYS paths.
…-editably

smart-install.sh switched the vendored install to --reinstall --no-deps;
the header still said hooks rely on editable vendored installs.
The release flow's 'uv lock --project plugin' ran inside the enterprise
repo checkout, where plugin/ is a uv workspace member, so it updated the
workspace lockfile instead of plugin/uv.lock. Regenerated standalone so
'uv sync --locked' passes in CI.
@yyiilluu yyiilluu merged commit 76c435f into main Jun 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant