Пример
Release managed root directories and retained loader memory by coordinating Zeitwerk unload and unregister lifecycle calls
sha256:75407f503d18673b17265d62c127a0e8fb4349c235b2832a4d25826f1d56f9fa
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Кейс
- Цель
- Release managed root directories and retained loader memory by coordinating Zeitwerk unload and unregister lifecycle calls HOW
- Пакеты
- zeitwerk 2.8.3
- Окружение
- ruby
- Создан
- 2026-08-17T01:23:41Z
Что обычно предполагают
Calling loader.unload completely tears down a Zeitwerk loader and releases its root directories for re-use by new loaders or for garbage collection.
Автор образца записал здесь то, чего ожидал бы разработчик или модель. Контракт ниже — это то, что действительно выполнялось.
Контракт
- assert calling loader.unload clears constants and autoloads but retains the loader in Zeitwerk::Registry.loaders and Zeitwerk::Loader.all_dirs, blocking any new loader from managing that root directory with Zeitwerk::Error until loader.unregister is explicitly called
- assert calling loader.unregister without calling loader.unload leaves Ruby VM autoload triggers registered on namespace constants but disconnects loader tracking
- assert calling loader.unregister removes the loader from Zeitwerk::Registry.loaders and permits full garbage collection of unreferenced loader instances
- assert calling loader.unregister on a loader created with Zeitwerk::Loader.for_gem purges the cached entry from Zeitwerk::Registry.gem_loaders_by_root_file so subsequent for_gem calls construct a new instance
- assert executing loader.unload followed by loader.unregister completely purges constants, loaded features, directory registrations, and global references
- assert zeitwerk 2.8.3 is pure Ruby with zero runtime dependencies and zero C extensions
Файлы
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- fixtures/app/models/post.rb
- fixtures/app/models/user.rb
- fixtures/fake_gem/lib/fake_gem.rb
- fixtures/fake_gem/lib/fake_gem/version.rb
- src/lifecycle_manager.rb
- test/contract.rb
Скачать проверенный артефакт (tar.gz) — те самые байты, на которых выполнялся контракт
Исходный сидер
Квитанции проверки
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-17 · ed25519:d91480838ac982c9