fix(auto-install): gate cli-entry on uv-tool install context (#834) - #836
Conversation
There was a problem hiding this comment.
Sorry @robotrocketscience, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
PR-size soft capThis PR is over the advisory size threshold:
Bigger PRs collide with more open work, which under the parallel-session workflow tends to produce repeated This is advisory only — nothing is blocked. If the size is intentional (large refactor, module removal, generated code), apply the |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR gates the auto-install manifest merge to only execute when aelfrice runs from the user's installed ChangesUVTool Install Context Gating
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
[claim:review:prince:2026-05-15T01:49:10Z] |
|
Reviewed Fix is correct. Tests cover the right axes:
Changelog entry is accurate: notes that the "opted out: …" line in the bug report was a pre-existing Behavior matrix from the PR body matches my read of the diff:
Minor — out of scope, worth noting:
Adding |
|
[release:review:prince:2026-05-15T01:50:56Z] |
|
merge-train: blocked branch is not fast-forward on The |
A worktree's `uv run aelf <cmd>` resolves to the worktree's local `.venv` aelfrice — not the user's installed `uv tool` copy — yet `auto_install_at_cli_entry` ran unconditionally and rewrote the user's global `~/.claude/settings.json` against the worktree's bundled manifest. With a stamp at one version and a worktree pinned to a different version, the merge re-pinned hook commands to the worktree's `.venv` paths and re-stamped the version backwards. New `is_running_from_uv_tool_install()` delegates to `lifecycle._is_uv_tool_install` so detection stays in one place. `auto_install_at_cli_entry` gates on it after the existing `AELFRICE_NO_AUTO_INSTALL` env check; explicit `aelf setup` still calls into `maybe_install_manifest` directly so contributors can opt in to a worktree merge.
Three new tests in test_auto_install.py: - test_auto_install_at_cli_entry_skips_when_not_uv_tool — gate False, the helper short-circuits before touching stamp / settings.json (the regression reproducer for the original bug). - test_is_running_from_uv_tool_install_delegates_to_lifecycle — both branches via the lifecycle._is_uv_tool_install seam. - test_auto_install_at_cli_entry_runs_when_uv_tool — sanity that the gate True path still invokes maybe_install_manifest. Uses a stub rather than running the merge end-to-end because maybe_install_manifest binds STAMP_PATH / OPT_OUT_PATH at function definition time and the real merge path would leak to the user's actual ~/.aelfrice/. Existing test_auto_install_at_cli_entry_does_not_propagate_exceptions in test_cli_auto_install.py monkeypatches the new gate to True so it continues to exercise the post-gate exception-handling path.
c40550a to
d91c5fc
Compare
|
merge-train: merged d91c5fc → |
Closes #834.
Bug
auto_install_at_cli_entryran on every CLI invocation, includinguv run aelf <cmd>from a project worktree's local.venv. With~/.aelfrice/installed-manifest-versionstamped at one version and a worktree pinned to a different one (the routine multi-worktree workflow), the merge ran against the worktree's bundled manifest and rewrote the user's global~/.claude/settings.json— re-pinning hook commands to the worktree's.venvpaths and re-stamping the version backwards. The "opted out: …" line in the bug report is a separate symptom: the user already had those six hooks in~/.aelfrice/opt-out-hooks.json(from a prioraelf setup --no-X); the merge correctly skipped them, but the surrounding stamp downgrade and settings rewrite happened without consent.Fix
Option A from the issue body. New
is_running_from_uv_tool_install()delegates to the existinglifecycle._is_uv_tool_install(single-source detection:~/.local/share/uv/tools/aelfrice/exists, orsys.prefixresolves under the uv tools root).auto_install_at_cli_entrygates on it after the existingAELFRICE_NO_AUTO_INSTALLenv check.After this PR:
aelf <cmd>fromuv tool install aelfriceuv run aelf <cmd>from a worktree.venvpytestagainst checked-out sourcepython -m aelfrice.clifrom a system Pythonaelf setup(explicit)setupcallsmaybe_install_manifestdirectly, gate doesn't applySymmetric with the existing
AELFRICE_NO_AUTO_INSTALL=1env override; the new gate is the implicit version of the same escape hatch for non-uv-tool contexts.Tests
Three new tests in
tests/test_auto_install.py:test_auto_install_at_cli_entry_skips_when_not_uv_tool— gate False → no stamp written, no settings.json created. Direct regression reproducer.test_is_running_from_uv_tool_install_delegates_to_lifecycle— confirms both branches of the gate flow throughlifecycle._is_uv_tool_installso detection stays in one place.test_auto_install_at_cli_entry_runs_when_uv_tool— gate True path still invokesmaybe_install_manifest. Uses a stub rather than the real merge:maybe_install_manifestbindsSTAMP_PATH/OPT_OUT_PATHat function-definition time, so an end-to-end test would leak to the user's actual~/.aelfrice/.test_cli_auto_install.py::test_auto_install_at_cli_entry_does_not_propagate_exceptionsupdated to monkeypatch the new gate to True so the post-gate exception-handling path is still exercised.Full suite: 4271 passed, 62 skipped, 75 xfailed (
pytest -x -q --timeout=120, run during pre-PR gate).Out of scope
demotion_pressureIndexError ([bug] aelf v3.1.0 crashes on any DB touched by post-#814 code — demotion_pressure schema/reader skew #833 — being worked separately).maybe_install_manifestso monkeypatchingauto_install.STAMP_PATH/OPT_OUT_PATHpropagates into the merge path. The default-arg binding is a real test-pollution hazard but not the user-facing bug; flagging here as a follow-up.Summary by CodeRabbit
uv toolinstallations, preventing unintended modifications to global configuration and settings files when running from project worktrees with incompatible or mismatched manifest versions. The existingAELFRICE_NO_AUTO_INSTALLenvironment variable override remains fully functional, and test coverage has been expanded to validate the new behavior.