Class: Rigor::Plugin::Services
- Inherits:
-
Object
- Object
- Rigor::Plugin::Services
- 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
-
#cache_store ⇒ Object
readonly
Returns the value of attribute cache_store.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#reflection ⇒ Object
readonly
Returns the value of attribute reflection.
-
#trust_policy ⇒ Object
readonly
Returns the value of attribute trust_policy.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(reflection:, type:, configuration:, cache_store: nil, trust_policy: nil) ⇒ Services
constructor
A new instance of Services.
-
#io_boundary_for(plugin_id) ⇒ Object
Returns a fresh IoBoundary bound to ‘plugin_id` and the current `trust_policy`.
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_store ⇒ Object (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 |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
35 36 37 |
# File 'lib/rigor/plugin/services.rb', line 35 def configuration @configuration end |
#reflection ⇒ Object (readonly)
Returns the value of attribute reflection.
35 36 37 |
# File 'lib/rigor/plugin/services.rb', line 35 def reflection @reflection end |
#trust_policy ⇒ Object (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 |
#type ⇒ Object (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 |