Class: Legion::LLM::Inference::AttemptContext
- Inherits:
-
Object
- Object
- Legion::LLM::Inference::AttemptContext
- Includes:
- Legion::Logging::Helper
- Defined in:
- lib/legion/llm/inference/attempt_context.rb
Overview
Immutable legion-owned execution object binding a Phase 1 Selection to its same-generation LaneRecord (SSOT v3 ยง14.1). Phase 1 Selection does not expose tier; AttemptContext resolves the lane from the exact snapshot generation and re-validates cross-record identity before any dispatch.
Any mismatch (generation drift, missing/mismatched lane/offering/instance, publisher-token or callable-handle disagreement) raises the internal Stale error before dispatch; RoutingSession converts it into a stale_selection Rejection so the owner captures a fresh snapshot. The consumed attempt target stays consumed across that transition.
Defined Under Namespace
Classes: Stale
Instance Attribute Summary collapse
-
#attempt_number ⇒ Object
readonly
Returns the value of attribute attempt_number.
-
#attempt_target_key ⇒ Object
readonly
Returns the value of attribute attempt_target_key.
-
#inventory_generation ⇒ Object
readonly
Returns the value of attribute inventory_generation.
-
#lane ⇒ Object
readonly
Returns the value of attribute lane.
-
#selection ⇒ Object
readonly
Returns the value of attribute selection.
Class Method Summary collapse
Instance Method Summary collapse
-
#fleet? ⇒ Boolean
Fleet tier changes only the dispatch mechanism, never selection or attempt identity.
-
#initialize(selection:, snapshot:, attempt_number:) ⇒ AttemptContext
constructor
A new instance of AttemptContext.
Constructor Details
#initialize(selection:, snapshot:, attempt_number:) ⇒ AttemptContext
Returns a new instance of AttemptContext.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 31 def initialize(selection:, snapshot:, attempt_number:) @selection = selection @attempt_number = Integer(attempt_number) @inventory_generation = selection.inventory_generation stale!('generation drift') unless snapshot.generation == selection.inventory_generation @lane = snapshot.lane(lane_id: selection.lane_id) stale!('lane absent in generation') if @lane.nil? instance = snapshot.instance(instance_key: selection.instance_key) stale!('instance absent in generation') if instance.nil? validate_lane_against_selection! validate_instance_against_selection!(instance) @attempt_target_key = selection.attempt_target_key freeze end |
Instance Attribute Details
#attempt_number ⇒ Object (readonly)
Returns the value of attribute attempt_number.
25 26 27 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 25 def attempt_number @attempt_number end |
#attempt_target_key ⇒ Object (readonly)
Returns the value of attribute attempt_target_key.
25 26 27 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 25 def attempt_target_key @attempt_target_key end |
#inventory_generation ⇒ Object (readonly)
Returns the value of attribute inventory_generation.
25 26 27 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 25 def inventory_generation @inventory_generation end |
#lane ⇒ Object (readonly)
Returns the value of attribute lane.
25 26 27 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 25 def lane @lane end |
#selection ⇒ Object (readonly)
Returns the value of attribute selection.
25 26 27 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 25 def selection @selection end |
Class Method Details
.build(selection:, snapshot:, attempt_number:) ⇒ Object
27 28 29 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 27 def self.build(selection:, snapshot:, attempt_number:) new(selection: selection, snapshot: snapshot, attempt_number: attempt_number) end |
Instance Method Details
#fleet? ⇒ Boolean
Fleet tier changes only the dispatch mechanism, never selection or attempt identity.
53 54 55 |
# File 'lib/legion/llm/inference/attempt_context.rb', line 53 def fleet? @lane.tier == :fleet end |