CodeSampleX

サンプル

zeitwerk 2.8.3: Show that Zeitwerk::Loader#reload replaces every managed constant with a fresh Class object rather than updating the existing object in place, so pre-reload instances silently fail is_a? checks against the live constant after reload.

検証済みサンプル — gem zeitwerk 2.8.3: Show that Zeitwerk::Loader#reload replaces every managed constant with a fresh Class object rather than updating the existing…

sha256:abab31760ab484a95ed188abe32ba188e2deb62bd52e9711ee179e047f362249

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
2
宣言された環境 ruby linux x64 ruby ruby bundler

検証実行環境

環境 コントラクト ステージ 実行日
ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-17
ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-18

ケース

HOW
ゴール
Show that Zeitwerk::Loader#reload replaces every managed constant with a fresh Class object rather than updating the existing object in place, so pre-reload instances silently fail is_a? checks against the live constant after reload.
パッケージ
シンボル
  • Zeitwerk::Loader#enable_reloading
  • Zeitwerk::Loader#reload
  • Zeitwerk::Loader#setup
  • Zeitwerk::Loader#push_dir
環境
ruby
作成日
2026-08-17T02:50:01Z

コントラクト

  1. After loader.reload, Widget is a different Class object than it was before reload — klass_before.equal?(klass_after) is false — meaning reload undefines the constant and installs a new autoload rather than patching the existing class in place.
  2. klass_before.name == 'Widget' && klass_after.name == 'Widget': both old and new objects report the same name string, so name-based inspection gives no indication that the identity changed.
  3. instance.is_a?(Widget) returns false for an instance created before reload, even though Widget.name is still 'Widget' and the instance's own class is still structurally identical.
  4. instance.is_a?(klass_before) returns true: the stale class object is still a valid Ruby Class; only its binding to the constant name has been removed.
  5. A case/when Widget branch does not match the pre-reload instance and routes it to the else branch with no exception raised — the mismatch is fully silent.

ファイル

  • Gemfile
  • Gemfile.lock
  • NOTES.md
  • app/widget.rb
  • csx.json
  • test/contract.rb

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

csx-seed