Commit

org.llm4s.agent.graph.Commit
See theCommit companion object
final case class Commit

One atomic write to a thread, fenced by the writing run's claim. The checkpointer applies all of it or none of it:

  • token must be the FencingToken of the thread's current claim (GraphError.StaleClaim otherwise, checked first): a writer that lost its claim records nothing.
  • checkpoint, if present, becomes the thread's latest, provided its parent is the current latest - the thread version the writer expects (GraphError.CheckpointConflict) - and its id is not already in the thread's history (GraphError.InvalidCommit); the previous latest stays in the history, and the pending writes recorded against it are dropped.
  • pendingWrites are recorded against the (resulting) latest checkpoint, and must name it - the version they expect (GraphError.InvalidCommit).
  • events are appended to the thread's durable log, each given the next sequence number.
  • retractTurn, which needs a checkpoint (GraphError.InvalidCommit otherwise), first removes from the history every checkpoint after the thread's latest settled one - the newest whose status is Completed or Failed, or all of them if there is none - so that nothing of a turn a guardrail blocked stays readable. The runtime sets it on the Failed checkpoint that closes a run a node blocked (NodeResult.Block).
  • effects are upserted by key into the thread's effect records (Checkpointer.effect), each remembered with its task's id and lineage. Before they are, a commit with a checkpoint releases every record for which releasesEffect holds, so replay evidence lives exactly as long as its task can run again (design §4.24). The runtime writes each record of a ReplayGuard as a commit of its own, with no checkpoint, pending write or event.
  • fence, if present as (other, otherToken), fences the commit by another thread's claim too: it applies only if otherToken is other's current claim, checked in the same atomic step as token and the write (one transaction, or under one lock), and otherwise is GraphError.StaleClaim(other, otherToken, otherCurrent) with nothing written - token checked first. The runtime fences every admission and settlement a parent drives on a child thread - its first commit, which writes its Checkpoint.origin, a reattachment's, a resume's and a settlement's - by the parent's claim (design 4.41), so a stale task of a parent taken over never registers or runs a child after a successor took the parent.
  • metadata, if present, replaces the thread's ThreadMetadata (design 4.52), fenced like the rest of the commit; None leaves it as it is. A thread keeps its metadata across commits until another replaces it, and loses it only with the thread (Checkpointer.deleteThread).

Attributes

Companion
object
Source
Checkpoint.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def releasesEffect(taskId: TaskId, lineage: String): Boolean

Whether this commit releases an effect record of the task taskId of lineage lineage (EffectRecord): whether that task is provably settled, so no run can look the record up again (design §4.24). Only a commit with a checkpoint releases anything. It releases a record whose task - id and lineage - is not live in the new checkpoint (GraphSnapshot.liveTasks; a settled checkpoint runs nothing) and was scheduled no later than its superstep; a settled (Completed or Failed) checkpoint releases every record. That checkpoint is durable once committed, so the superstep that scheduled the task never runs again: the task finished, or the durable plan scheduled other work under its id, and nothing can plan it again. A task scheduled later is kept, whoever recorded it:

Whether this commit releases an effect record of the task taskId of lineage lineage (EffectRecord): whether that task is provably settled, so no run can look the record up again (design §4.24). Only a commit with a checkpoint releases anything. It releases a record whose task - id and lineage - is not live in the new checkpoint (GraphSnapshot.liveTasks; a settled checkpoint runs nothing) and was scheduled no later than its superstep; a settled (Completed or Failed) checkpoint releases every record. That checkpoint is durable once committed, so the superstep that scheduled the task never runs again: the task finished, or the durable plan scheduled other work under its id, and nothing can plan it again. A task scheduled later is kept, whoever recorded it:

  • this run's, running ahead of a commit that lands late (Async);
  • a run's that a takeover fenced out, scheduled after its last durable checkpoint (Async, OnExit): the successor plans that work again, and from the same results it is the same task - the same lineage and keys - so the first plan's evidence answers for it, even while the stale run's effect is still under way. A store applies this to every record of the thread inside the commit.

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Attributes

Source
Checkpoint.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product