Class: Legion::Extensions::Llm::Inventory::Snapshot
- Inherits:
-
Object
- Object
- Legion::Extensions::Llm::Inventory::Snapshot
- Defined in:
- lib/legion/extensions/llm/inventory/snapshot.rb
Overview
A structurally immutable, generation-tagged read model of the registry.
Lookups return the frozen record or nil and never synthesize a default.
instances_by_key contains only activated instances;
publication_status_by_key also contains initializing claims. Lanes
are keyed by the 5-tuple lane id and iterate in lexicographic id
order (readable iteration). A caller cannot observe a later
inventory-record or generation mutation through an older snapshot;
the captured CallableHandle lifecycle is the single intentional
exception. See phase-1-lex-llm-additive.md section 11.3.
Instance Attribute Summary collapse
-
#generation ⇒ Object
readonly
Returns the value of attribute generation.
Instance Method Summary collapse
- #each_instance(&block) ⇒ Object
- #each_lane(&block) ⇒ Object
- #each_publication_status(&block) ⇒ Object
-
#initialize(generation:, instances_by_key:, lanes_by_id:, publication_status_by_key:) ⇒ Snapshot
constructor
A new instance of Snapshot.
- #instance(instance_key:) ⇒ Object
- #lane(lane_id:) ⇒ Object
- #lanes_for(instance_key:) ⇒ Object
- #publication_status(instance_key:) ⇒ Object
Constructor Details
#initialize(generation:, instances_by_key:, lanes_by_id:, publication_status_by_key:) ⇒ Snapshot
Returns a new instance of Snapshot.
23 24 25 26 27 28 29 30 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 23 def initialize(generation:, instances_by_key:, lanes_by_id:, publication_status_by_key:) @generation = generation @instances_by_key = order_instances(instances_by_key).freeze @lanes_by_id = lanes_by_id.dup.freeze @publication_status_by_key = order_instances(publication_status_by_key).freeze @ordered_lanes = @lanes_by_id.keys.sort.map { |id| @lanes_by_id[id] }.freeze freeze end |
Instance Attribute Details
#generation ⇒ Object (readonly)
Returns the value of attribute generation.
21 22 23 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 21 def generation @generation end |
Instance Method Details
#each_instance(&block) ⇒ Object
54 55 56 57 58 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 54 def each_instance(&block) return to_enum(:each_instance) unless block @instances_by_key.each_value(&block) end |
#each_lane(&block) ⇒ Object
48 49 50 51 52 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 48 def each_lane(&block) return to_enum(:each_lane) unless block @ordered_lanes.each(&block) end |
#each_publication_status(&block) ⇒ Object
60 61 62 63 64 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 60 def each_publication_status(&block) return to_enum(:each_publication_status) unless block @publication_status_by_key.each_value(&block) end |
#instance(instance_key:) ⇒ Object
32 33 34 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 32 def instance(instance_key:) @instances_by_key[instance_key] end |
#lane(lane_id:) ⇒ Object
36 37 38 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 36 def lane(lane_id:) @lanes_by_id[lane_id] end |
#lanes_for(instance_key:) ⇒ Object
40 41 42 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 40 def lanes_for(instance_key:) @ordered_lanes.select { |lane| lane.instance_key == instance_key }.freeze end |
#publication_status(instance_key:) ⇒ Object
44 45 46 |
# File 'lib/legion/extensions/llm/inventory/snapshot.rb', line 44 def publication_status(instance_key:) @publication_status_by_key[instance_key] end |