EncryptingRunQueue

org.llm4s.agent.encryption.EncryptingRunQueue
See theEncryptingRunQueue companion object
@Experimental
final class EncryptingRunQueue extends RunQueue

A RunQueue that encrypts the inputs inner stores, with keys from keys (#2449): the companion of EncryptingCheckpointer for a store's queue, which is a separate SPI and so is not covered by wrapping the checkpointer. Give it to every RunSubmitter and AgentWorker in place of the store's queue.

'''What is encrypted''': a Start input and each answer of a Resume, under the key of the submission's tenant, bound to the tenant, the thread, the agent and - for an answer - its interrupt. The store issues an entry's id as it inserts it, so an input is not bound to its entry: someone who can write to the database can exchange the inputs of two entries of one thread, tenant and agent, and nothing else.

'''What stays in plain''': everything the queue orders, leases, scopes and reports by - entry, thread, agent, tenant and run ids, the submission key, the policy, attempts and lease holders, timestamps, trace contexts, an input's kind and its interrupt ids - and an entry's outcome, with the failure message or cancel note it carries: close and cancel name an entry by its lease or id alone, without the tenant a key is chosen by.

A retried submission under a SubmissionKey still gets the first one's ticket. The store compares what it holds, and two encryptions of one input differ, so it reports the key as reused; this queue then reads that entry, opens it and compares the submissions itself.

An entry whose input cannot be opened fails the call that read it (EncryptionError) - after inner has acted: a take has leased it, a cancel has cancelled it. Such an entry stays at the head of its thread's queue, leased again as each lease expires, until its key is supplied or the entry is cancelled.

Attributes

Companion
object
Source
EncryptingRunQueue.scala
Graph
Supertypes
trait RunQueue
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def awaitClosed(tenantId: Option[TenantId], entryId: EntryId, timeout: FiniteDuration): Result[QueueEntry]

Entry entryId once it is closed, or as it is when timeout passes - whichever is first; errors are entry's. The default polls entry every 100 milliseconds; a store that is told of closes overrides it. Interrupting the waiting thread ends the wait with Left(CancelledError), its interrupt flag set again.

Entry entryId once it is closed, or as it is when timeout passes - whichever is first; errors are entry's. The default polls entry every 100 milliseconds; a store that is told of closes overrides it. Interrupting the waiting thread ends the wait with Left(CancelledError), its interrupt flag set again.

Attributes

Definition Classes
Source
EncryptingRunQueue.scala
def cancel(tenantId: Option[TenantId], target: CancelTarget, reason: CancelReason): Result[Cancellation]

Passed to the store unchanged: a cancellation carries nothing that is encrypted.

Passed to the store unchanged: a cancellation carries nothing that is encrypted.

Attributes

Source
EncryptingRunQueue.scala
def close(lease: Lease, outcome: EntryOutcome): Result[QueueEntry]

Closes lease's entry with outcome and answers it closed; refused unless lease is current.

Closes lease's entry with outcome and answers it closed; refused unless lease is current.

Attributes

Source
EncryptingRunQueue.scala

Passed to the store unchanged.

Passed to the store unchanged.

Attributes

Source
EncryptingRunQueue.scala
def entry(tenantId: Option[TenantId], entryId: EntryId): Result[QueueEntry]

The entry, with its input decrypted.

The entry, with its input decrypted.

Attributes

Source
EncryptingRunQueue.scala
def openEntries(tenantId: Option[TenantId], threadId: ThreadId): Result[Vector[QueueEntry]]

tenantId's open entries on threadId, in the order they run (see the class doc); empty for an unknown thread.

tenantId's open entries on threadId, in the order they run (see the class doc); empty for an unknown thread.

Attributes

Source
EncryptingRunQueue.scala

For each of threads that has an open entry - of any tenant: the operator's store-wide retention sweep asks it - the RunIds of every attempt its open entries recorded (an empty set for open entries that have recorded none); a thread with no open entry is absent. What the worker's sweep guard answers (org.llm4s.agent.graph.SweepGuard, W2): the thread keeps its tombstone and the newest checkpoint of each of these runs (rule 4). At most SweepPolicy.MaxBatchSize threads are asked at once.

For each of threads that has an open entry - of any tenant: the operator's store-wide retention sweep asks it - the RunIds of every attempt its open entries recorded (an empty set for open entries that have recorded none); a thread with no open entry is absent. What the worker's sweep guard answers (org.llm4s.agent.graph.SweepGuard, W2): the thread keeps its tombstone and the newest checkpoint of each of these runs (rule 4). At most SweepPolicy.MaxBatchSize threads are asked at once.

Attributes

Source
EncryptingRunQueue.scala
def reclaim(ticketLifetime: FiniteDuration, limit: Int): Result[Int]

Removes up to limit closed entries whose close is ticketLifetime or more ago, by the store's clock, oldest first, input and attempts included, and answers how many it removed; never an open entry. The store-wide retention sweep (W2) calls it.

Removes up to limit closed entries whose close is ticketLifetime or more ago, by the store's clock, oldest first, input and attempts included, and answers how many it removed; never an open entry. The store-wide retention sweep (W2) calls it.

Attributes

Source
EncryptingRunQueue.scala
def recordAttempt(lease: Lease, runId: RunId): Result[AttemptStart]

Passed to the store unchanged: an attempt record carries nothing that is encrypted.

Passed to the store unchanged: an attempt record carries nothing that is encrypted.

Attributes

Source
EncryptingRunQueue.scala
def release(lease: Lease): Result[Unit]

Passed to the store unchanged.

Passed to the store unchanged.

Attributes

Source
EncryptingRunQueue.scala
def renew(lease: Lease, ttl: FiniteDuration): Result[Lease]

Passed to the store unchanged.

Passed to the store unchanged.

Attributes

Source
EncryptingRunQueue.scala
def submit(submission: Submission): Result[Ticket]

Submits submission with its input encrypted; a reused submission key is compared against the stored entry in plain.

Submits submission with its input encrypted; a reused submission key is compared against the stored entry in plain.

Attributes

Source
EncryptingRunQueue.scala

Leases the next entry, with its input decrypted; an entry that cannot be decrypted is a Left and stays leased until the lease expires.

Leases the next entry, with its input decrypted; an entry that cannot be decrypted is a Left and stays leased until the lease expires.

Attributes

Source
EncryptingRunQueue.scala

Concrete fields

Attributes

Source
EncryptingRunQueue.scala