Class: Rigor::Plugin::Services

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/plugin/services.rb

Overview

Dependency-injection container handed to every plugin’s Base#init method. Plugins read from the container; they MUST NOT mutate it. The container is constructed once per ‘Analysis::Runner.run` and destroyed at the end of the run.

ADR-2 § “Registration, Configuration, and Caching” reserves this surface for “constructor injection for analyzer services such as reflection providers, type factories, loggers, and configuration readers”. Slice 1 wires four of those:

  • ‘reflection`: the Reflection read-side facade.

  • ‘type`: the Type::Combinator factory module.

  • ‘configuration`: the project’s Configuration.

  • ‘cache_store`: the Cache::Store the run is using (or `nil` when caching is disabled). Slice 6 wires plugin-side cache producers through this entry.

Loggers are not yet a public surface in the core analyzer; they will be added when the diagnostics formatter grows a progress channel.

Slice 2 (Plugin trust / I/O policy) extends the container with ‘trust_policy` and a per-plugin `io_boundary_for(plugin_id)` factory. Plugins should reach for the boundary rather than raw `File.read` so reads stay within the trusted scope and feed cache invalidation; ADR-2 § “Plugin Trust and I/O Policy” documents the trust model the boundary enforces.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reflection:, type:, configuration:, cache_store: nil, trust_policy: nil) ⇒ Services

Returns a new instance of Services.



37
38
39
40
41
42
43
44
# File 'lib/rigor/plugin/services.rb', line 37

def initialize(reflection:, type:, configuration:, cache_store: nil, trust_policy: nil)
  @reflection = reflection
  @type = type
  @configuration = configuration
  @cache_store = cache_store
  @trust_policy = trust_policy || default_trust_policy
  freeze
end

Instance Attribute Details

#cache_storeObject (readonly)

Returns the value of attribute cache_store.



35
36
37
# File 'lib/rigor/plugin/services.rb', line 35

def cache_store
  @cache_store
end

#configurationObject (readonly)

Returns the value of attribute configuration.



35
36
37
# File 'lib/rigor/plugin/services.rb', line 35

def configuration
  @configuration
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



35
36
37
# File 'lib/rigor/plugin/services.rb', line 35

def reflection
  @reflection
end

#trust_policyObject (readonly)

Returns the value of attribute trust_policy.



35
36
37
# File 'lib/rigor/plugin/services.rb', line 35

def trust_policy
  @trust_policy
end

#typeObject (readonly)

Returns the value of attribute type.



35
36
37
# File 'lib/rigor/plugin/services.rb', line 35

def type
  @type
end

Instance Method Details

#io_boundary_for(plugin_id) ⇒ Object

Returns a fresh IoBoundary bound to ‘plugin_id` and the current `trust_policy`. The boundary accumulates per-plugin cache descriptor entries; the loader / contribution merger constructs one boundary per plugin per run.



50
51
52
# File 'lib/rigor/plugin/services.rb', line 50

def io_boundary_for(plugin_id)
  IoBoundary.new(policy: @trust_policy, plugin_id: plugin_id)
end