class RubyLLM::Browser::OperationStore
Durable bookkeeping for browser operations.
The host supplies an implementation. {InMemoryOperationStore} is a fixture for tests and single-process demos only; production multi-worker or restart-safe use requires a durable store (for example the ActiveRecord store in ‘ruby_llm/browser/rails`).
Every method is expected to be atomic. Callers assume:
-
{#reserve} never starts two operations for one idempotency key
-
{#update} rejects a stale writer (fencing)
-
the reservation is held for ‘unknown` / `cleanup_pending`, not released early
Public Instance Methods
Returns the existing operation for the same actor/run/idempotency key, or reserves operation. Duplicate jobs must attach, never start a second session.
# File lib/ruby_llm/browser/operation_store.rb, line 27 def attach_or_reserve(_operation) raise NotImplementedError, "OperationStore#attach_or_reserve must be implemented" end
Atomically changes reserved to starting, checking the caller’s fence. A second delivery must never start even when it read the row before the first claim.
# File lib/ruby_llm/browser/operation_store.rb, line 59 def claim_start(_operation, now:) raise NotImplementedError, "OperationStore#claim_start must be implemented" end
Records provider-confirmed closure of this exact session, including cancellation.
# File lib/ruby_llm/browser/operation_store.rb, line 69 def confirm_closed(_operation, session_id:, now:) raise NotImplementedError, "OperationStore#confirm_closed must be implemented" end
@return [Operation, nil]
# File lib/ruby_llm/browser/operation_store.rb, line 32 def fetch(_id) raise NotImplementedError, "OperationStore#fetch must be implemented" end
Returns the operation or raises {InvalidInput} when absent.
# File lib/ruby_llm/browser/operation_store.rb, line 37 def fetch!(_id) raise NotImplementedError, "OperationStore#fetch! must be implemented" end
Claims the operation for one worker, bumping its fence token.
@return [Operation] the newly leased operation @raise [NotAuthorized] a different actor/run tries to claim it
# File lib/ruby_llm/browser/operation_store.rb, line 45 def lease(_id, actor_id:, run_id:, now:) raise NotImplementedError, "OperationStore#lease must be implemented" end
Marks an operation unable to confirm its own cleanup.
@return [Operation]
# File lib/ruby_llm/browser/operation_store.rb, line 76 def mark_cleanup_pending(_id, actor_id:, run_id:, error_code: nil, now:) raise NotImplementedError, "OperationStore#mark_cleanup_pending must be implemented" end
@return [Array<Operation>] operations currently holding a slot for the actor
# File lib/ruby_llm/browser/operation_store.rb, line 81 def open_for(_actor_id) raise NotImplementedError, "OperationStore#open_for must be implemented" end
@return [Array<Operation>] every open operation across all actors. Used by the
cleanup reaper, which is a host-operated, system-wide sweep.
# File lib/ruby_llm/browser/operation_store.rb, line 87 def open_operations raise NotImplementedError, "OperationStore#open_operations must be implemented" end
Persists a returned session even if cancellation fenced its starting worker.
# File lib/ruby_llm/browser/operation_store.rb, line 64 def record_session(_operation, session_id:, now:) raise NotImplementedError, "OperationStore#record_session must be implemented" end
Atomically stores a new operation and enforces the actor’s concurrency budget. @raise [InvalidInput] the id already exists @raise [BudgetExhausted] the concurrency slot is taken
# File lib/ruby_llm/browser/operation_store.rb, line 21 def reserve(_operation) raise NotImplementedError, "OperationStore#reserve must be implemented" end
Persists operation only if its fence is current.
@return [Operation] the stored operation @raise [InvalidInput] the writer is fenced (stale)
# File lib/ruby_llm/browser/operation_store.rb, line 53 def update(_operation) raise NotImplementedError, "OperationStore#update must be implemented" end