The BlobHub data model the worker builds on
The worker is a client of the existing BlobHub session API. It introduces no new backend endpoints: it reads and writes the same sessions, session objects, and thread items any client speaks, as its own user. Everything below is part of the generic data model — the worker only attaches meaning to specificmetadata
blocks within it.
- Sessions — a session is the shared context the worker attaches to. One
session_agent_harnesssection attaches to one session. - Session objects — a
thread-typed session object has an envelope ofattributes(display metadata) andmetadata(the structured state). The worker uses two kinds: a singleworkerobject that marks its attachment, and one object per unit of work. See thread session object andupload_session_object. - Thread items — an append-only stream of items on a thread. The agent’s output is posted as items; a
human’s posts arrive as items. See
post_session_thread_item,list_session_thread_items, andget_session_thread_item. - Session events — the session’s event stream, which the worker listens to over the WebSocket API and reads
back with
list_session_eventsto learn what happened. The relevant types areobject.written,object.deleted,thread.item_postedand thesession.*lifecycle types. See Session events and Listeners.
What the worker reads and writes
The worker never invents new object types or commands. On each object it touches, it reads and writes only specificmetadata blocks — for example the control channel and agent settings on a unit-of-work object,
optionally an artifacts publish contract and a guarded-mode policy on that same object, and the
attachment marker on the worker object. The exact blocks per object are documented on the per-job-type
object pages, starting with the
Job Session Object and the
Worker Session Object.
Sync model
The worker stays current by listening. Each attached section opens one WebSocket connection to the realtime API and adds connection listeners on it: one for a whole-session section, two under asession_prefix, because a filter is a conjunction and a lifecycle event has no object alias. Every match arrives
as a listener/event frame carrying the stored event.
A frame is a latency path, not a guarantee, so the worker also sweeps: it lists the stream with
list_session_events from its persisted cursor, once after every (re)connect, once a minute while the connection
is live, and at the polling cadence while it is not. Frames make the worker
fast and sweeps make it correct. Only a sweep moves the persisted cursor, and each one re-reads the 60 seconds
before it, because event ids are minted before they commit and a listing can show a later id before an earlier one.
The worker keeps the ids it has already handled inside that window (seen) and drops repeats, so a frame and the
sweep that lists the same event handle it once. A worker that cannot reach the realtime API, or whose listener is
refused, still works: the section reports polling and sweeps at the fallback cadence.
An event is a hint, and the platform’s current state decides. Before acting on a lifecycle event, or on the
deletion of an object, the worker reads the session or the object, so a replayed or reordered event never tears
down work that still exists. Every write the worker makes carries its client tag
(see Filesystem Layout), which
the listeners exclude, so the worker does not wake on its own writes.
When the worker needs to change an envelope, it does an optimistic read-modify-write: read the current object,
mutate only the fields it owns, write back, and on a write conflict re-read and retry, resyncing from the next
event.
A section’s watch can be scoped to part of a session (session_prefix; see
Configuration) instead of the whole thing. Discovery is then list, then watch:
an attach pages every object under the prefix and classifies each alias it hasn’t seen as the worker’s own
work or not, and steady state re-classifies for free from the type each object.written event already carries — no
separate re-list. See Concepts for the mental model.
Local vs wire state
The worker keeps two views of each unit of work, and they are deliberately not the same:- The wire envelope (the session object’s
metadata) is authoritative for handoff — it is how the user and the worker communicate ownership and the control-channel state. - The local
thread.yamlon the worker host is authoritative for recovery — it records the resume pointer, the last consumed/posted item cursors, and the local failure detail, none of which appear on the wire.
Job types
A section’sjob_type is the discriminator that selects which validator runs at preflight, which objects the
section attaches to, and how it behaves at runtime. session_agent_harness is the one job type in v1. See
Job Types for the dispatch mechanics and extensibility.

