Class: OllamaAgent::Runtime::CompensationEngine
- Inherits:
-
Object
- Object
- OllamaAgent::Runtime::CompensationEngine
- Defined in:
- lib/ollama_agent/runtime/compensation_engine.rb
Overview
Replays recorded compensations (blob restore or unlink) for a manifest_id.
Instance Method Summary collapse
-
#compensate(manifest_id:, logical_stamp:) ⇒ Hash
:restored,:missing,:errors(Array of error hashes). -
#initialize(blob_store:, compensation_manifest:, atomic_mutator:, fencing_allocator:) ⇒ CompensationEngine
constructor
A new instance of CompensationEngine.
Constructor Details
#initialize(blob_store:, compensation_manifest:, atomic_mutator:, fencing_allocator:) ⇒ CompensationEngine
Returns a new instance of CompensationEngine.
9 10 11 12 13 14 |
# File 'lib/ollama_agent/runtime/compensation_engine.rb', line 9 def initialize(blob_store:, compensation_manifest:, atomic_mutator:, fencing_allocator:) @blob_store = blob_store @compensation_manifest = compensation_manifest @atomic_mutator = atomic_mutator @fencing_allocator = fencing_allocator end |
Instance Method Details
#compensate(manifest_id:, logical_stamp:) ⇒ Hash
Returns :restored, :missing, :errors (Array of error hashes).
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ollama_agent/runtime/compensation_engine.rb', line 17 def compensate(manifest_id:, logical_stamp:) raise ArgumentError, "kernel wiring incomplete" unless coordinator_wired? tallies = { restored: 0, missing: 0 } errors = [] @compensation_manifest.each_unapplied(manifest_id: manifest_id) do |row| apply_one(row, tallies, errors, logical_stamp) end { restored: tallies[:restored], missing: tallies[:missing], errors: errors } end |