Skip to content
CAI
Software that uses CAICheck a score

fxn/zeitwerk

68.2

Adequate · 19 September 2026

2.2k

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is the Zeitwerk autoloader for Ruby, responsible for managing the loading and unloading of constants based on file system structure. It intercepts core Ruby loading mechanisms to provide automatic constant resolution, eager loading, and namespace management while maintaining compatibility with legacy require calls. The codebase includes internal optimizations for constant resolution performance and a comprehensive test suite to ensure reliability across various loading scenarios.

How it got here

2019 — Zeitwerk 2.8.3 upgrade and test modernization

9 changes.

The project upgraded Zeitwerk to version 2.8.3, introducing loader isolation, internal refactoring into dedicated modules, and new callback systems. Concurrently, the test infrastructure was modernized by switching from Rake to Minitest and expanding coverage for the new core components and loader behaviors.

2024–2026 — Autoload mechanism refactoring

4 changes.

This period focused on refactoring Zeitwerk's core autoload mechanisms by intercepting Ruby's require and const\_added hooks to better manage autovivification and namespace tracking. The internal registry was restructured into dedicated modules for improved organization, while a new optimized constant resolution map replaced the legacy string-based approach to enhance performance. Comprehensive tests were added to cover loader file system operations, constant path validation, and tagging features.

Features

Experimental loader isolation via Zeitwerk.with\_loader

Zeitwerk now provides an experimental \with\_loader\ method that creates a temporary loader instance, yields it to a block, and automatically unregisters it upon completion. This allows users to isolate loader lifecycles for specific operations without affecting the global registry. The main entry point also loads several new internal components (\real\_mod\_name\, \internal\, \cref\, \gem\_loader\, \null\_inflector\, \error\, \version\) and core extensions for \Kernel\ and \Module\.

lib · high confidence

Behavioural changes

Intercept require and const\_added to manage autoloads

Zeitwerk now hooks into Ruby's core loading mechanisms by wrapping Kernel\#require and prepending to Module\#const\_added. This allows the library to intercept file loads and namespace creations, triggering internal callbacks to handle autovivification and update its registry of explicit namespaces, ensuring that legacy require calls remain compatible while enabling automatic loading of project constants.

_lib/zeitwerk/core\ext · high confidence

Internal registry refactoring for autoloads, loaders, and namespaces

The internal registry system has been restructured into dedicated modules (Zeitwerk::Registry::Autoloads, Loaders, ExplicitNamespaces, and Inceptions) to manage autoload paths, loader instances, explicit namespace mappings, and inception tracking separately. This change improves internal organization and testability but does not alter the public API or external behavior of the Zeitwerk autoloader.

lib/zeitwerk/registry · high confidence

Introduces Zeitwerk::Cref::Map for optimized constant resolution

A new internal \Zeitwerk::Cref::Map\ class has been added to replace the previous string-based constant path approach. This synchronized, two-level hash structure uses module identity and constant symbols as keys to improve performance in the hot path of constant resolution, offering significant speedups for both reading and writing operations compared to the legacy implementation.

lib/zeitwerk/cref · high confidence

Refactors loader internals and adds explicit namespace loading callbacks

The loader's internal implementation has been restructured into dedicated modules (Callbacks, Config, EagerLoad, FileSystem, Helpers) to improve maintainability and performance. A key behavioral addition is the new \on\_load\ and \on\_unload\ callback system, allowing users to execute code when constants are loaded or unloaded. The loader now strictly raises \Zeitwerk::NameError\ when a file does not define the expected constant, and it supports \nsfile\ conventions for defining namespaces. Eager loading behavior has been refined to handle collapsed directories and exclusions more consistently, and file system operations are optimized using \Dir.scan\ where available.

lib/zeitwerk/loader · high confidence

Zeitwerk updated to version 2.8.3

The Zeitwerk library has been upgraded to version 2.8.3. This release includes significant internal refactoring, such as the introduction of the \Zeitwerk::Cref\ class to encapsulate module and constant name pairs, and the extraction of loader logic into dedicated modules (e.g., \Loader::Config\, \Loader::EagerLoad\). It also introduces new error classes like \ReloadingDisabledError\ and \ConflictingNamespaceDefinitionError\, adds a \NullInflector\ for cases where no inflection is needed, and updates the \Kernel\#require\ decoration to use a registry-based approach instead of direct method aliasing. The \Inflector\ class now supports hard-coded mappings via the \inflect\ method.

lib/zeitwerk · high confidence

Test coverage

Added test coverage for Zeitwerk loader features; Added tests for Zeitwerk core components and inflection behavior; Added tests for Zeitwerk loader file system operations, constant path validation, and tags; Refactored test support helpers and cleanup logic; Switch test runner from Rake to Minitest; Test suite configuration and helper updates.

Dependencies

Update Ruby requirement and test dependencies

The project now requires Ruby 3.2 or higher, replacing the previous 2.4.4 minimum. Test dependencies have been updated: Minitest is constrained to version 6.0, and new gems minitest-mock, minitest-proveit, and warning have been added, while rake and minitest-focus remain. RuboCop has been added as a development dependency, and the Gemfile.lock has been removed in favor of managing dependencies with Gel.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 68.

Lenses

  • Code Health 100
  • Architecture 90
  • Maturity 59
  • Readiness 59
  • Security 100

Changes since last survey

  • 300 commits — 289 feature/other, 11 fixes

By area

  • lib/zeitwerk — 122 commits
  • (root) — 95 commits
  • test/lib — 43 commits
  • (repo) — 23 commits
  • .github/workflows — 14 commits
  • .github/FUNDING.yml — 1 commit
  • test/support — 1 commit
  • test/test_helper.rb — 1 commit

Notable commits

  • fix: Fix URL for CI badge in README
  • fix: Fix autoload_path_set_by_me_for? with inceptions
  • fix: Fix log message when eager loading a directory ends
  • fix: Fix method signature annotation
  • fix: Fix test helper
  • fix: Fixes signature annotation
  • fix: Merge pull request #252 from teoljungberg/fix-spelling-errors
  • fix: README: Copy fix
  • fix: Revert "Define Zeitwerk::Cref#{to_s,hash,eql?,==}"
  • fix: Revert "Rename some variables"
  • fix: Revert "Support hashing crefs whose mod has an overridden name"
  • change: Add .github/FUNDING.yml
  • change: Add RuboCop to CI
  • change: Add Ruby 3.3 to CI matrix
  • change: Add Ruby 3.4 to CI
  • change: Add Ruby 4.0 to the CI matrix
  • change: Add TruffleRuby stable to CI
  • change: Add a constant path validator
  • change: Add a couple more of tests
  • change: Add a couple of missing signatures
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

fxn/zeitwerk was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 0616bcd004274f19055a8b80cd1ea35561fbc216 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.