WatchPolicy

org.llm4s.agent.graph.WatchPolicy
See theWatchPolicy companion object
final case class WatchPolicy

How a GraphRuntime's subscriptions learn of commits made through another runtime or process sharing its Checkpointer. Commits made through the runtime itself are handed to its subscriptions as they land, whatever this says.

While enabled, each live subscription watches the store on a virtual thread of its own, named llm4s-watch-<threadId>, calling Checkpointer.awaitEventsAfter with pollInterval as the timeout, from the last event it has queued. A store that can be told of commits returns as soon as one lands; one that cannot - the default, and the SQLite store - is read once per pollInterval, so a commit made elsewhere reaches the subscription up to pollInterval after it lands. Only durable events cross runtimes: live progress (StreamEvent.Live) is never stored, so it reaches only the subscriptions of the runtime whose run sent it. When disabled, a subscription sees another runtime's commits only by subscribing again, which replays the log; a runtime that knows it is the only one using its store can disable it to save the watching thread and its reads.

'''Ordering.''' Each subscription reads on its own cursor, so a commit made elsewhere falls at a point among the runtime's live events that depends on which read reached that subscription (its initial replay, its watch, or a hand-over's gap read): two subscriptions can place it differently, though each delivers the durable events in seq order. Concurrently active subscriptions of one runtime that stay caught up share one live/durable interleaving, every event handed to several of them having the same relative placement for each, while nothing outside the runtime commits to the thread (#1920); an external commit allows them to differ, not necessarily make them differ. Where one order across runtimes matters, order durable events by seq (see GraphRuntime.subscribe).

pollInterval must be at least one millisecond - a shorter one would have every subscription read a polled store in a busy loop: apply and the with* setters throw IllegalArgumentException otherwise, and WatchPolicy.of returns a ValidationError.

Attributes

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

Members list

Value members

Concrete methods

Attributes

Source
WatchPolicy.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product