Skip to main content

Module book_queue

Module book_queue 

Source
Expand description

Bookkeeping off the hook’s answer. Each tool call used to keep the book inside the call, under the one book.lock every seat on the host shares, and the first write of a session filed a claim and committed the tracker there. That cost seconds and hundreds of megabytes per call, with every other hook waiting on the lock. A call now leaves a job in the runtime directory and answers. One drainer per user applies the jobs in the order they came, one process at a time, and commits each tracker file once per batch.

A job carries what the call knew and the drainer cannot learn later: the environment, the directory, the runner above the call and HEAD at the time of the call.

Functions§

apply
ljos hook --apply-book JOB...: apply the jobs in order and commit the tracker once at the end. A job the book lock keeps out stays queued, and so do the ones after it.
book_later
Queue the book for this hook call and return the recall a session start or a prompt hands the model, read from the book as it stands.
catch_up
Let the jobs queued before this call apply first, for a reader that acts on the book or the claims: a finish, a start, a commit’s book. Waits at most [CATCH_UP]; a job still queued then applies later. Jobs queued after the call began are not waited for, so a burst cannot hold the reader. Inside a hook or a drainer this returns at once, since the job it would wait for may be its own.
drain
ljos hook --drain: apply every queued job. With wait, wait for a drainer that runs and return once the spool is empty; without, leave the work to that drainer.
enqueue
Queue the book for this call, and start a drainer when none runs.
enqueue_ask
Queue the ask the guard put to this call.
has_pending
Whether jobs wait in the spool. A direct bookkeeper queues behind them, so the book sees calls in the order they came.