Class: TurnKit::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/turnkit/store.rb

Direct Known Subclasses

ActiveRecordStore, MemoryStore

Instance Method Summary collapse

Instance Method Details

#append_message(_attributes) ⇒ Object

Raises:

  • (NotImplementedError)


9
# File 'lib/turnkit/store.rb', line 9

def append_message(_attributes) = raise(NotImplementedError)

#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.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


18
# File 'lib/turnkit/store.rb', line 18

def claim_turn(_id, from: "pending", to: "running", **_attributes) = raise(NotImplementedError)

#create_conversation(_attributes) ⇒ Object

Raises:

  • (NotImplementedError)


5
# File 'lib/turnkit/store.rb', line 5

def create_conversation(_attributes) = raise(NotImplementedError)

#create_tool_execution(_attributes) ⇒ Object

Raises:

  • (NotImplementedError)


21
# File 'lib/turnkit/store.rb', line 21

def create_tool_execution(_attributes) = raise(NotImplementedError)

#create_turn(_attributes) ⇒ Object

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


10
# File 'lib/turnkit/store.rb', line 10

def list_messages(_conversation_id, through_sequence: nil, turn_id: nil) = raise(NotImplementedError)

#list_tool_executions(turn_id:) ⇒ Object

Raises:

  • (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

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


6
# File 'lib/turnkit/store.rb', line 6

def load_conversation(_id) = raise(NotImplementedError)

#load_tool_execution(_id) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
25
# File 'lib/turnkit/store.rb', line 22

def load_tool_execution(_id) = 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.

#load_turn(_id) ⇒ Object

Raises:

  • (NotImplementedError)


13
# File 'lib/turnkit/store.rb', line 13

def load_turn(_id) = raise(NotImplementedError)

#next_message_sequence(_conversation_id) ⇒ Object

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


14
15
16
17
# File 'lib/turnkit/store.rb', line 14

def update_turn(_id, _attributes) = raise(NotImplementedError)
# 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.