サンプル
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