Class: Rigor::Plugin::Services
- Inherits:
-
Object
- Object
- Rigor::Plugin::Services
- Defined in:
- lib/rigor/plugin/services.rb,
sig/rigor/plugin/services.rbs
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 (ornilwhen 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.
ADR-9 slice 2 adds fact_store: the per-run cross-plugin Plugin::FactStore. Producer plugins publish
their facts in #prepare(services) (slice 3); consumer plugins read in #diagnostics_for_file via
services.fact_store.read(...). A fresh FactStore instance is constructed per Services when none is
supplied — the runner threads its own instance in once slice 3 wires #prepare invocation.
Instance Attribute Summary collapse
-
#cache_store ⇒ Object
readonly
Returns the value of attribute cache_store.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#fact_store ⇒ Object
readonly
Returns the value of attribute fact_store.
-
#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, fact_store: nil) ⇒ Services
constructor
A new instance of Services.
-
#io_boundary_for(plugin_id) ⇒ Object
Returns a fresh IoBoundary bound to
plugin_idand the currenttrust_policy.
Constructor Details
#initialize(reflection:, type:, configuration:, cache_store: nil, trust_policy: nil, fact_store: nil) ⇒ Services
Returns a new instance of Services.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rigor/plugin/services.rb', line 34 def initialize( reflection:, type:, configuration:, cache_store: nil, trust_policy: nil, fact_store: nil ) @reflection = reflection @type = type @configuration = configuration @cache_store = cache_store @trust_policy = trust_policy || default_trust_policy @fact_store = fact_store || FactStore.new freeze end |
Instance Attribute Details
#cache_store ⇒ Object (readonly)
Returns the value of attribute cache_store.
32 33 34 |
# File 'lib/rigor/plugin/services.rb', line 32 def cache_store @cache_store end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
32 33 34 |
# File 'lib/rigor/plugin/services.rb', line 32 def configuration @configuration end |
#fact_store ⇒ Object (readonly)
Returns the value of attribute fact_store.
32 33 34 |
# File 'lib/rigor/plugin/services.rb', line 32 def fact_store @fact_store end |
#reflection ⇒ Object (readonly)
Returns the value of attribute reflection.
32 33 34 |
# File 'lib/rigor/plugin/services.rb', line 32 def reflection @reflection end |
#trust_policy ⇒ Object (readonly)
Returns the value of attribute trust_policy.
32 33 34 |
# File 'lib/rigor/plugin/services.rb', line 32 def trust_policy @trust_policy end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
32 33 34 |
# File 'lib/rigor/plugin/services.rb', line 32 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 |