Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [Unreleased]

### Fixed
- Every file under `lib/agentic/` now loads through Zeitwerk alone: the 57 `require_relative` lines between loader-managed files are gone, and `spec/zeitwerk_spec.rb` eager-loads the gem in a fresh process and fails on any `require_relative` that comes back
- Test suite loads on Ruby 4.0: `benchmark` is a bundled (not default) gem there, so it is now declared in the Gemfile
- `EventDispatcher` slow-observer spec uses a monotonic clock and a looser bound so it no longer flakes on loaded hosts

Expand Down
5 changes: 0 additions & 5 deletions lib/agentic/artifact_generator.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require_relative "artifact"
require_relative "artifact_generation_result"
require_relative "workspace"
require_relative "capabilities/file_generation_capability"

module Agentic
# Coordinates artifact generation using LLM agents
#
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/capabilities/file_generation_capability.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "../artifact"
require_relative "../workspace"
require "json"

module Agentic
Expand Down
5 changes: 0 additions & 5 deletions lib/agentic/capabilities/register_file_generation.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require_relative "file_generation_capability"
require_relative "../capability_specification"
require_relative "../capability_provider"
require_relative "../agent_capability_registry"

module Agentic
module Capabilities
# Register the file_generation capability with the registry
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/cli/execution_observer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "progress_tracker"

module Agentic
class CLI < Thor
# Observer that provides real-time feedback during plan execution
Expand Down
1 change: 0 additions & 1 deletion lib/agentic/cli/human_intervention_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require "thor"
require "json"
require "yaml"
require_relative "../human_intervention/portal"

module Agentic
class CLI
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/cli/streaming/enhanced_progress_tracker.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "multi_zone_display"

module Agentic
class CLI < Thor
module Streaming
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/cli/streaming/multi_zone_display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require "tty-box"
require "tty-cursor"
require "tty-screen"
require_relative "streaming_zone"
require_relative "progress_zone"

module Agentic
class CLI < Thor
Expand Down
5 changes: 0 additions & 5 deletions lib/agentic/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require_relative "configuration/schema"
require_relative "configuration/schema_registry"
require_relative "configuration/schemas"
require_relative "configuration/builder"

module Agentic
# Unified configuration system with schema validation and type checking
#
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/configuration/builder.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "schemas"

module Agentic
module Configuration
# Configuration builder with fluent interface and validation
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/configuration/schema_registry.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "schema"

module Agentic
module Configuration
# Central registry for managing configuration schemas
Expand Down
3 changes: 0 additions & 3 deletions lib/agentic/configuration/schemas.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# frozen_string_literal: true

require_relative "schema"
require_relative "schema_registry"

module Agentic
module Configuration
# Pre-defined schemas for core Agentic configuration objects
Expand Down
3 changes: 0 additions & 3 deletions lib/agentic/human_intervention/portal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
require "json"
require "securerandom"
require "monitor"
require_relative "workflow_manager"
require_relative "monitoring_system"
require_relative "authentication_system"

module Agentic
module HumanIntervention
Expand Down
4 changes: 0 additions & 4 deletions lib/agentic/observability/adapter_factory.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

require_relative "base_adapter"
require_relative "console_adapter"
require_relative "file_adapter"

module Agentic
module Observability
# Factory for creating observability adapters
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/observability/console_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "base_adapter"

module Agentic
module Observability
# Console adapter for outputting events to STDOUT/STDERR
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/observability/event_dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

require "async"
require "async/queue"
require_relative "event_pipeline"
require_relative "event_context"

module Agentic
module Observability
Expand Down
3 changes: 0 additions & 3 deletions lib/agentic/observability/file_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# frozen_string_literal: true

require_relative "base_adapter"
require_relative "file_observer"

module Agentic
module Observability
# File adapter for logging events to local files
Expand Down
4 changes: 0 additions & 4 deletions lib/agentic/observability_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
require "set"
require "json"
require "async"
require_relative "observability/event_data"
require_relative "observability/file_observer"
require_relative "observability/adapter_factory"
require_relative "observability/event_dispatcher"

module Agentic
# Unified observability engine for all event coordination
Expand Down
4 changes: 0 additions & 4 deletions lib/agentic/performance.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

require_relative "performance/cache"
require_relative "performance/cache_manager"
require_relative "performance/optimizer"

module Agentic
# Performance optimization framework for the Agentic system
#
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/performance/cache_manager.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "cache"

module Agentic
module Performance
# Cache manager for coordinating multiple cache instances and strategies
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/performance/optimizer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "cache_manager"

module Agentic
module Performance
# Performance optimization framework with caching, pooling, and monitoring
Expand Down
4 changes: 0 additions & 4 deletions lib/agentic/security.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

require_relative "security/sanitizer"
require_relative "security/config"
require_relative "security/secure_error_mixin"

module Agentic
# Security module providing comprehensive PII sanitization and secure error handling
#
Expand Down
2 changes: 0 additions & 2 deletions lib/agentic/security/secure_error_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative "config"

module Agentic
module Security
# Mixin to add security-aware error handling to existing error classes
Expand Down
4 changes: 0 additions & 4 deletions lib/agentic/verification/strategy_factory.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

require_relative "verification_strategy"
require_relative "llm_verification_strategy"
require_relative "schema_verification_strategy"

module Agentic
module Verification
# Factory for creating verification strategies with consistent configuration
Expand Down
3 changes: 0 additions & 3 deletions lib/agentic/verification/verification_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# frozen_string_literal: true

require_relative "strategy_factory"
require_relative "verification_hub"

module Agentic
module Verification
# Helper methods for setting up verification using standardized patterns
Expand Down
1 change: 0 additions & 1 deletion lib/agentic/verification/verification_hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def add_strategy(strategy)
# @param dependencies [Hash] Strategy dependencies
# @return [void]
def add_strategy_from_factory(type, config: {}, **dependencies)
require_relative "strategy_factory"
strategy = StrategyFactory.create(type, config: config, **dependencies)
add_strategy(strategy)
end
Expand Down
4 changes: 0 additions & 4 deletions lib/agentic/workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

require "securerandom"
require "fileutils"
require_relative "artifact"
require_relative "artifact_graph"
require_relative "observable"
require_relative "verification/artifact_verification_strategy"

module Agentic
# Manages an isolated workspace for artifact generation
Expand Down
43 changes: 43 additions & 0 deletions spec/zeitwerk_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

require "open3"

# Loader contract check. lib/agentic.rb makes Zeitwerk the single code loader
# and tells files not to require_relative their siblings. Zeitwerk tolerates
# a managed file being required directly, so a stray require never crashes;
# it only hand-maintains a load-order edge the loader already owns, which is
# how the rule came back 57 lines strong with no red build. The first example
# tests the promise behind the rule, the second tests the rule.
RSpec.describe "Zeitwerk loader" do
let(:lib_dir) { File.expand_path("../lib", __dir__) }

# A fresh interpreter, so no constant is already loaded by spec_helper and
# nothing in this process's state can hide a file that only loads because
# another file was required first. force: true also walks lib/agentic/cli,
# which the loader excludes from normal eager loading.
it "eager-loads every constant under lib/agentic/ in a fresh process" do
script = <<~RUBY
require "agentic"
loader = Zeitwerk::Registry.loaders.find { |l| l.tag == "agentic" }
abort "no Zeitwerk loader tagged agentic (did the gem name change?)" unless loader
loader.eager_load(force: true)
print Agentic::CLI.name
RUBY

out, err, status = Open3.capture3(RbConfig.ruby, "-W0", "-I", lib_dir, "-e", script)

expect(status).to be_success, "eager load failed:\n#{err}"
expect(out).to eq("Agentic::CLI")
end

it "manages every file under lib/agentic/ without require_relative" do
offenders = Dir[File.join(lib_dir, "agentic", "**", "*.rb")].sort.flat_map do |file|
File.foreach(file).with_index(1).filter_map do |line, number|
"#{file.delete_prefix("#{lib_dir}/")}:#{number}: #{line.strip}" if line.match?(/\A\s*require_relative\b/)
end
end

expect(offenders).to be_empty,
"require_relative between loader-managed files (reference the constant instead):\n #{offenders.join("\n ")}"
end
end
Loading