Class: Xeno::TurnRunner
- Inherits:
-
Object
- Object
- Xeno::TurnRunner
- Includes:
- Compaction
- Defined in:
- lib/xeno/turn_runner.rb
Overview
Drives one turn to completion (or to a park). This is the durable core:
RubyLLM's decomposed v2 loop (generate + self-executed tools +
add_message injection), checkpointed in the database at every move.
We never call run_tools (not idempotent) or complete (unbounded).
Crash-safety invariants:
- The user message and instructions were persisted when the turn was staged; the runner only advances the transcript.
generatepersists the assistant message via the acts_as callback path.- A tool execution and its transcript injection commit in ONE transaction (the action row is the checkpoint) — recorded calls are never re-run.
- Every write is fenced on the claim token; zombies affect zero rows.
- Trailing blank assistant rows (the mid-generate crash window) are removed before deciding anything (spike #2, hazard 1).
Constant Summary
Constants included from Compaction
Compaction::COMPACTION_PROMPT, Compaction::SUMMARY_PREFIX
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#turn ⇒ Object
readonly
Returns the value of attribute turn.
Instance Method Summary collapse
-
#initialize(turn, definition: Xeno.definition) ⇒ TurnRunner
constructor
A new instance of TurnRunner.
- #run ⇒ Object
Constructor Details
#initialize(turn, definition: Xeno.definition) ⇒ TurnRunner
Returns a new instance of TurnRunner.
21 22 23 24 25 |
# File 'lib/xeno/turn_runner.rb', line 21 def initialize(turn, definition: Xeno.definition) @turn = turn @session = turn.session @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
19 20 21 |
# File 'lib/xeno/turn_runner.rb', line 19 def definition @definition end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
19 20 21 |
# File 'lib/xeno/turn_runner.rb', line 19 def session @session end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
19 20 21 |
# File 'lib/xeno/turn_runner.rb', line 19 def token @token end |
#turn ⇒ Object (readonly)
Returns the value of attribute turn.
19 20 21 |
# File 'lib/xeno/turn_runner.rb', line 19 def turn @turn end |