Skip to content

fix: prevent per-session runtime copies (#65)#66

Open
yyiilluu wants to merge 1 commit into
mainfrom
fix/issue-65-session-runtime-copies
Open

fix: prevent per-session runtime copies (#65)#66
yyiilluu wants to merge 1 commit into
mainfrom
fix/issue-65-session-runtime-copies

Conversation

@yyiilluu
Copy link
Copy Markdown
Contributor

@yyiilluu yyiilluu commented Jun 3, 2026

Summary

  • Detect claude-smart plugin roots that live under per-session ~/.reflexio/Cu* copies.
  • Redirect install, hook, CLI, backend, and dashboard script entrypoints to the stable plugin root instead of bootstrapping runtimes in session copies.
  • Add a regression test proving smart-install.sh creates .venv in the stable root and leaves the Cu* session copy untouched.

Test Plan

  • uv run --project plugin pytest tests/test_install_scripts.py::test_smart_install_redirects_reflexio_session_copies_to_stable_root -q
  • bash -n plugin/scripts/_lib.sh plugin/scripts/smart-install.sh plugin/scripts/hook_entry.sh plugin/scripts/backend-service.sh plugin/scripts/dashboard-service.sh plugin/scripts/cli.sh
  • git diff --check
  • uv run --project plugin pytest tests/test_install_scripts.py::test_smart_install_installs_vendored_reflexio tests/test_install_scripts.py::test_smart_install_redirects_reflexio_session_copies_to_stable_root tests/test_install_scripts.py::test_codex_hook_ensure_root_tracks_active_plugin_root -q

Fixes #65

Summary by CodeRabbit

  • Bug Fixes
    • Plugin installation and execution now consistently use a stable plugin root instead of session-specific copies, improving reliability across installations and ensuring consistent behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7d53ba03-9273-4814-ba1f-0a980b6b0ac4

📥 Commits

Reviewing files that changed from the base of the PR and between 78983aa and dfc1ff4.

📒 Files selected for processing (7)
  • plugin/scripts/_lib.sh
  • plugin/scripts/backend-service.sh
  • plugin/scripts/cli.sh
  • plugin/scripts/dashboard-service.sh
  • plugin/scripts/hook_entry.sh
  • plugin/scripts/smart-install.sh
  • tests/test_install_scripts.py

📝 Walkthrough

Walkthrough

This PR adds machinery to redirect per-session Reflexio runtime copies to a shared stable plugin root, preventing unbounded disk growth. Helper functions detect session copies and locate stable alternatives, then re-execute scripts under the stable root when found. All five entry-point scripts integrate this redirection early in their control flow.

Changes

Stable Plugin Root Redirection

Layer / File(s) Summary
Stable root detection and re-execution helpers
plugin/scripts/_lib.sh
Four new functions: claude_smart_canonical_dir validates and canonicalizes paths; claude_smart_is_reflexio_session_copy detects session-scoped roots; claude_smart_stable_plugin_root_for_session_copy searches candidate stable roots by directory structure and pyproject.toml presence; claude_smart_reexec_stable_plugin_root_if_needed re-executes the script under a stable root when found and its script executable exists.
Script entry point integration
plugin/scripts/backend-service.sh, plugin/scripts/cli.sh, plugin/scripts/dashboard-service.sh, plugin/scripts/hook_entry.sh, plugin/scripts/smart-install.sh
Each script adds an early call to claude_smart_reexec_stable_plugin_root_if_needed immediately after computing PLUGIN_ROOT, enabling transparent re-execution under a stable root before proceeding with install/bootstrap/hook/service logic.
Regression test for stable root redirection
tests/test_install_scripts.py
New test creates session and stable plugin roots, seeds ~/.reflexio/plugin-root pointing to stable, runs smart-install.sh from session root, and asserts .venv and uv sync invocations occur only under the stable root.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • ReflexioAI/claude-smart#57: Adjusts setup-local-dev.sh to keep ~/.reflexio/plugin-root pointing at the live checkout so that stable-root redirection resolves correctly.
  • ReflexioAI/claude-smart#32: Hardened install and bootstrap flow in plugin/scripts/smart-install.sh and plugin/scripts/cli.sh, coordinating with this PR's early re-exec-to-stable-plugin-root guards.

Poem

🐰 A rabbit hops through sessions old,
Each copy swelling, growing bold—
But smart redirection finds the way,
One stable root to save the day!
No more a terabyte to store,
Just shared roots, shared disk, and more.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: prevent per-session runtime copies' accurately reflects the main objective: redirecting plugin execution away from per-session ~/.reflexio copies to a stable shared root.
Linked Issues check ✅ Passed The PR implements a key mitigation to issue #65 by detecting session copies and redirecting all script entrypoints to stable roots, preventing runtime duplication; includes regression test validation.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objectives: helper functions, script redirects, and regression test; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-65-session-runtime-copies

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.

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.

Critical: per-session runtime copies in ~/.reflexio grow unbounded — 1 TB / 47.7M files, nearly filled a 1.9 TB drive

1 participant