fix(update): preserve activated extras across runtime rebuilds - #73309
Closed
hxwvaa wants to merge 1 commit into
Closed
fix(update): preserve activated extras across runtime rebuilds#73309hxwvaa wants to merge 1 commit into
hxwvaa wants to merge 1 commit into
Conversation
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
hermes updaterebuilt the managed environment with.[all], then calledactive_features()to decide what to refresh. That detector infers activation from packages currently installed in the environment. A replacement runtime has already removed a lazy backend's anchor package, so the updater cannot recover the previously active feature.Reproduction
python-telegram-bot[webhooks]==22.6).security.allow_lazy_installs: false..[all]install omits Telegram, and post-rebuildactive_features()returns no Telegram feature.Why active-feature detection fails after removal
It is intentionally presence-based and does not persist history. Once the replacement runtime has dropped the package, its anchor is gone; probing after the rebuild cannot distinguish “previously activated then removed” from “never activated.”
Fix design
Snapshot the allowlisted active lazy features before the update can replace site-packages, then restore that exact snapshot after the core dependency install. The restore path only accepts names in
LAZY_DEPSand its pinned specs, so it is general across declared lazy backends without accepting arbitrary packages. Cold features remain absent.Security behavior
This does not modify
security.allow_lazy_installs. Runtimeensure()remains blocked when it is false. The explicit updater may restore only dependencies already captured before its own managed-runtime rebuild.Tests executed
AttributeError: module 'tools.lazy_deps' has no attribute 'restore_features'.python -m pytest tests/tools/test_lazy_deps.py tests/hermes_cli/test_lazy_refresh_venv_repair.py -q: 84 passed.ruff check tools/lazy_deps.py hermes_cli/main.py tests/tools/test_lazy_deps.py tests/hermes_cli/test_lazy_refresh_venv_repair.py: passed.py_compile tools/lazy_deps.py hermes_cli/main.py: passed.scripts/run_tests.shcould not run on the Windows author host because it invokes WSL and no WSL distribution is installed. Direct broader collection is also blocked by Linux-only test prerequisites; CI is required for platform-parity validation.ty check tools/lazy_deps.py hermes_cli/main.pyreports existing diagnostics acrosshermes_cli/main.pyoutside this diff.Fixes #72924