Class: TurnKit::Store
- Inherits:
-
Object
show all
- Defined in:
- lib/turnkit/store.rb
Instance Method Summary
collapse
-
#append_message(_attributes) ⇒ Object
-
#claim_tool_execution(_id, from: "running", to: "completed", **_attributes) ⇒ Object
claim_tool_execution mirrors claim_turn: an atomic compare-and-set on status, so a tool result recorded by a live worker and a reconciler marking the execution interrupted cannot overwrite each other.
-
#claim_turn(_id, from: "pending", to: "running", **_attributes) ⇒ Object
claim_turn is the concurrency-safety point: it must atomically compare-and-set status from from to to (returning nil when the turn is not in from), so concurrent workers cannot both claim a turn.
-
#create_conversation(_attributes) ⇒ Object
-
#create_tool_execution(_attributes) ⇒ Object
-
#create_turn(_attributes) ⇒ Object
-
#list_messages(_conversation_id, through_sequence: nil, turn_id: nil) ⇒ Object
-
#list_tool_executions(turn_id:) ⇒ Object
-
#list_turns(root_turn_id: nil, conversation_id: nil, agent_name: nil) ⇒ Object
-
#load_conversation(_id) ⇒ Object
-
#load_tool_execution(_id) ⇒ Object
-
#load_turn(_id) ⇒ Object
-
#next_message_sequence(_conversation_id) ⇒ Object
-
#reconcile_stale_turns(before:) ⇒ Object
reconcile_stale_turns is the other concurrency-safety point: it must atomically transition each pending/running turn whose stale anchor (heartbeat_at, else started_at, else created_at) is older than before to stale, rechecking both predicates at write time so a concurrently claimed, heartbeated, or completed turn is never overwritten.
-
#update_turn(_id, _attributes) ⇒ Object
Instance Method Details
#append_message(_attributes) ⇒ Object
9
|
# File 'lib/turnkit/store.rb', line 9
def append_message(_attributes) = raise(NotImplementedError)
|
claim_tool_execution mirrors claim_turn: an atomic compare-and-set on
status, so a tool result recorded by a live worker and a reconciler
marking the execution interrupted cannot overwrite each other.
26
|
# File 'lib/turnkit/store.rb', line 26
def claim_tool_execution(_id, from: "running", to: "completed", **_attributes) = raise(NotImplementedError)
|
#claim_turn(_id, from: "pending", to: "running", **_attributes) ⇒ Object
claim_turn is the concurrency-safety point: it must atomically
compare-and-set status from from to to (returning nil when the turn
is not in from), so concurrent workers cannot both claim a turn.
18
|
# File 'lib/turnkit/store.rb', line 18
def claim_turn(_id, from: "pending", to: "running", **_attributes) = raise(NotImplementedError)
|
#create_conversation(_attributes) ⇒ Object
5
|
# File 'lib/turnkit/store.rb', line 5
def create_conversation(_attributes) = raise(NotImplementedError)
|
21
|
# File 'lib/turnkit/store.rb', line 21
def create_tool_execution(_attributes) = raise(NotImplementedError)
|
#create_turn(_attributes) ⇒ Object
12
|
# File 'lib/turnkit/store.rb', line 12
def create_turn(_attributes) = raise(NotImplementedError)
|
#list_messages(_conversation_id, through_sequence: nil, turn_id: nil) ⇒ Object
10
|
# File 'lib/turnkit/store.rb', line 10
def list_messages(_conversation_id, through_sequence: nil, turn_id: nil) = raise(NotImplementedError)
|
27
|
# File 'lib/turnkit/store.rb', line 27
def list_tool_executions(turn_id:) = raise(NotImplementedError)
|
#list_turns(root_turn_id: nil, conversation_id: nil, agent_name: nil) ⇒ Object
19
|
# File 'lib/turnkit/store.rb', line 19
def list_turns(root_turn_id: nil, conversation_id: nil, agent_name: nil) = raise(NotImplementedError)
|
#load_conversation(_id) ⇒ Object
6
|
# File 'lib/turnkit/store.rb', line 6
def load_conversation(_id) = raise(NotImplementedError)
|
22
23
24
25
|
# File 'lib/turnkit/store.rb', line 22
def load_tool_execution(_id) = raise(NotImplementedError)
|
#load_turn(_id) ⇒ Object
13
|
# File 'lib/turnkit/store.rb', line 13
def load_turn(_id) = raise(NotImplementedError)
|
#next_message_sequence(_conversation_id) ⇒ Object
8
|
# File 'lib/turnkit/store.rb', line 8
def next_message_sequence(_conversation_id) = raise(NotImplementedError)
|
#reconcile_stale_turns(before:) ⇒ Object
reconcile_stale_turns is the other concurrency-safety point: it must
atomically transition each pending/running turn whose stale anchor
(heartbeat_at, else started_at, else created_at) is older than before
to stale, rechecking both predicates at write time so a concurrently
claimed, heartbeated, or completed turn is never overwritten. Returns
the reconciled turn records. Descendant turns of a dead process stop
heartbeating too and are reconciled by the same predicate, so no
explicit subtree cascade is needed.
37
|
# File 'lib/turnkit/store.rb', line 37
def reconcile_stale_turns(before:) = []
|
#update_turn(_id, _attributes) ⇒ Object
14
15
16
17
|
# File 'lib/turnkit/store.rb', line 14
def update_turn(_id, _attributes) = raise(NotImplementedError)
|