reference
Data structures
Leaf uses JSON for the state the server sends to the browser, the events in a page's log, and the records stored beside the log. Each table below lists one structure's fields with their types, whether each is required, and what it means.
The tables are generated from the schemas Leaf validates and tests against, so they change when the code does. An event kind's meaning is written once, in Events and threads, which each kind below links to. How the pieces fit together is on How it works.
Served state
The page's runtime reads the state from GET /api/state. The
definitions at the end of this section describe JSON responses to POST
requests. The user-view and interaction endpoints return no response body.
leaf page state prints selected fields from the same state.
GET /api/state
The answer GET /api/state serves a page's runtime, which the POST /api/event answer carries as state and leaf.page publishes as /_leaf/state/*.json: Reading, which served_state.page.read_served_page composes, with what the serving route adds; a request naming a reading the tab holds may be answered with a Tail instead. Leaf alone writes it, so nothing validates it in flight; the tests validate real readings against this schema, and the browser build generates its type from it (build/browser/contract-types.mjs). It is not part of the page protocol: the runtime that reads it comes from the Leaf that serves it (runtime_selection.py), so a change needs no bump. leaf:event refers to any kernel event record, leaf:event/<kind> to one kind's and leaf:verb to a verb (verbs), as registry.schema.leaf_resources composes them; an object here adding served fields to an event record closes it again with unevaluatedProperties.
Type: Reading.
| Field | Type | Required | Description |
|---|---|---|---|
layer | object | yes | The identity of the layer the shown revision was read under, or the page's before a revision exists (layer-registry.md): its generation and selection, and the fingerprint and producer of the layer the serving Leaf composes for it (served_state.page.served_layer_identity). |
layer. | string | yes | |
layer. | string | yes | |
layer. | array of string | ||
layer. | Provenance | ||
reading | string | yes | The token of the page's own facts this answer read (page_inputs.join_reading), which the reading a news answer names is compared with. No other page moves it. |
release | string | The leaf.page release that served the page. |
Reading
One page's state as served_state.page.read_served_page composes it from one transaction, before the serving route adds the layer it serves under and its token. Before the page has an active revision, active and browser are null.
| Field | Type | Required | Description |
|---|---|---|---|
now | string | yes | The server clock used to calibrate browser timestamps and relative ages; a laptop an hour out would otherwise date new comments an hour out too. An edge host refreshes this and taken together at delivery; captured event timestamps and already-folded activity keep their original dates. |
working_grace_ms | integer | yes | How long working may go unheard before it reads as quiet, measured on the now clock. activity is already folded; a package dating a worker's own reports reads readWork's quiet, which reads this rather than a copy. |
taken | number | yes | The moment this answer was taken, for a tab holding two. Answers cross (two sockets, one held by a proxy or a test while a later one lands, a POST's answer beside a read), and the log's sequence orders everything in a state but the reading and its data, which are hashes with no order of their own. Live answers are stamped inside their page transaction; an edge host dates a fresh read of its stored publication at delivery. The wall clock rather than a counter, which would start over with the server and make a tab open across that restart refuse every answer until the count caught up. |
active | Revision or null | yes | The revision the live root serves (files.document_descriptor), or null before the first. |
versions | array of object | yes | Each public version with its revision and address (files.version_descriptors). |
versions[]. | integer | yes | The public version number, vN's N. |
versions[]. | integer | yes | The immutable revision the version stamped. |
versions[]. | string | yes | The version's address. |
revision_labels | map of string | yes | Each revision's public name, vN or a draft's, by revision number (files.revision_labels). |
seen | Revision or null | yes | The newest revision a tab showed the user while they were there, posted as they left (read_state.seen_revision), from which the browser counts what changed since (host/since-seen.js). Null before any, and on a hosted copy, whose reader is not the page's user. |
source_error | string or null | yes | Why activating the page's authored source failed, or null. |
data | object | yes | The page's data sources, each with its value (data.read_data). A whole answer to a tab that names this version in Leaf-Data-Version leaves out sources, which the tab restores from the reading it holds; a Tail carries only the sources that changed. |
data. | string | yes | |
data. | map of object | ||
data. | string | yes | |
data. | string | yes | |
data. | string | yes | |
data. | string | yes | |
data. | any | ||
data. | string | ||
data.sources.* one of: requires value and forbids error; requires error and forbids value. | |||
files | map of object | yes | Each bound file, by binding (file_bindings.bound_files): its label, the name the browser shows for it, an unreadable file's included. The file itself is the source under the binding's id in data, whose run moves with each write. |
files. | string | yes | |
status | object | yes | The agent's declaration, the newest status event (activity.declaration), as presence.presence reads it; that module owns the presence fields below. |
status. | string | yes | waiting on the user or idle, done with the page; waiting before the agent declares anything. |
status. | string | When the agent declared it, or when a start reopened an idle page; absent before the first declaration. | |
listening | boolean | yes | Whether a wait lease on the page is held: the active claimant session's, or the page's own where no session claims it. |
session_alive | boolean or null | yes | Whether the claimant's lifetime stands, or null where nothing claimed the page. |
live_turn | object or null | yes | What the claimant's harness says of its turn now (Harness.live_turn), or null. |
live_turn when state is "busy" | "waiting" | "idle". | |||
live_turn. | "busy" | "waiting" | "idle" | yes | |
live_turn. | string | yes | |
live_turn. | boolean | yes | |
cursor | integer | yes | The acknowledgement cursor, the greatest through a receipt in the log holds: the updates through it reached their durable consumer. |
pending | integer | yes | How many of the user's events past the cursor the agent hasn't taken in. |
agent | string | yes | The name the page calls its agent (presence.page_agent). |
claim_session | string or null | yes | The claimant session, or null. |
session_name | string or null | yes | What the claimant's harness calls its session now (Harness.session_name), or null where it names none. |
turn | string or null | yes | The claimant's current turn, which an opened delivery names, or null. It and the two stamps after it are the claim's turn under the session record's names, which sessions.turn_open and sessions.turn_closed read. |
turn_closed | string or null | yes | When the claimant's current turn closed, or null while it is open or nothing claims the page. |
turn_opened | string or null | yes | When that turn opened or was last renewed, or null where nothing claims the page. |
turn_takes_input | boolean | yes | Whether an open turn of the claimant's takes new input before it ends (Harness.turn_takes_input). |
input_wakes | boolean | yes | Whether the nudge the claimant's next input gets would start a turn of its session's (Harness.input_wakes). |
session_cwd | string or null | yes | Where the claimant was working when it claimed the page, or null for a page nothing claimed. |
activity | Activity | yes | Where the agent's work on the whole page stands (activity.py), which the Leaf panel reads. |
workflows | array of Workflow | yes | The page's workflows, strongest first (work_state.served_workflows). |
browser | Browser or null | yes | The browser's reading of the shown and active revisions (served_state.browser.browser_state), or null before the first revision. |
events | array of Event | yes | The log, as logged: a message's text is Markdown the page's vendored runtime renders, an agent's with the HTML its writer's gate validated. The wire adds nothing, so the only vocabulary a page's frozen layer has to keep speaking is the log's own, which $events already stamps. An export's reading is folded from less of it (exporting._page_log). |
preview | object | The identity a developer preview shows in browser chrome, as leaf-dev preview wrote it (server.preview_metadata); absent on a page that is not a preview. | |
preview. | string | yes | The name of the source file the preview serves, without its extension. |
preview. | string | yes | The checkout whose Leaf serves it. |
preview. | "user" | "author" | yes | user for a --user preview, whose presses reach the session that claimed it; author for a plain one. |
preview. | string | yes | When the preview started. |
preview. | object | yes | The fixture publication the preview's watcher last applied. |
preview. | string | yes | |
preview. | string | yes | |
publication | object | On a host that answers every comment itself, such as leaf.page, who answers this copy of the page; absent elsewhere. | |
publication. | string | yes | Who answers the copy. |
Event
One logged event, exactly as $events declares its kind.
Type: event.
EventReference
The admitted gesture an answer or ending came from (obligations.event_reference).
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
kind | string | yes | |
seq | integer | yes | |
ts | string | yes | |
author | string | yes |
Provenance
Where a Leaf payload came from (layer.payload_provenance): its commit and dirty bit, and its age as committed or installed.
| Field | Type | Required | Description |
|---|---|---|---|
path | string | ||
commit | string | ||
dirty | boolean | ||
committed | string | ||
installed | string |
Revision
One revision's live address, public stamp or draft label, and captured identity (files.document_descriptor).
| Field | Type | Required | Description |
|---|---|---|---|
revision | integer | yes | The revision's number. |
version | integer or null | yes | The public version that stamped it, or null for a draft. |
url | string | yes | The revision's address. |
label | string | yes | Its public name, vN or a draft's (files.revision_labels). |
executable | string | yes | The capture's executable identity, independent of public stamps, which a client compares with its delivered document. |
activated_at | string | yes | When it went live. |
Subject
What a workflow or to-do stands on.
| Field | Type | Required | Description |
|---|---|---|---|
when kind is "thread" | "widget" | "element". | |||
kind | "thread" | "widget" | "element" | yes | |
id | string | yes | |
when kind is "page". | |||
kind | "page" | yes | |
WorkState
Where a piece of work stands (standing.py): waiting on its next actor, running while the agent is observed at work on it, blocked while it is owed and nothing moves it, or done. The log alone says waiting or done; activity.py is the one producer of the other two.
Type: "waiting" | "running" | "blocked" | "done".
WorkReason
What a state leaves out (standing.py). Under blocked: terminal, the agent's turn waits on the user in its own window; stopped, the turn that had it was seen to end before answering; quiet, nothing has renewed it within the working grace; undelivered, no turn has taken it in past the pickup grace; failed, the harness gave up and handed it back.
Type: "terminal" | "stopped" | "quiet" | "undelivered" | "failed" | null.
Outcome
How a done piece of work ended, or null while it is open.
Type: "done" | "failed" | "dropped" | null.
Activity
The page's one reading of where the agent's side of its work stands (activity.canonical_activity), without its workflows and records, which the state serves on their own.
| Field | Type | Required | Description |
|---|---|---|---|
presence | "here" | "away" | "gone" | "closed" | yes | Whether anyone is there to take input: here, away between turns, gone when no session holds the page, or closed once the agent declared it done with the page. |
state | WorkState | yes | running while the agent's turn is at work, blocked when what it had in hand stopped or went quiet or its turn waits on the user in its own window, waiting while it owes something nobody is on, done when it owes nothing. |
reason | WorkReason | yes | |
next_actor | "user" | "agent" | null | yes | Whose move changes the reading: the user's for a dialog in the agent's own window and for an update only their nudge will move; null when the agent owes nothing. |
detail | string | yes | |
detail_source | object or null | yes | |
detail_source. | string | yes | |
detail_source. | string | yes | |
observed | string | yes | |
observed_kind | WorkKind or null | yes | |
counts | object | yes | The answers the agent owes, each counted once: as unseen where no turn has taken its update in and nothing is at work on it, and otherwise by where its update stands. |
counts. | integer | yes | |
counts. | integer | yes | |
counts. | integer | yes | |
counts. | integer | yes | |
ts | string or null | yes | |
next_transition_at | string or null | yes | |
obligations | array of string | yes | The ids of the update records whose next actor is the agent: the answers it owes (activity.canonical_activity). |
WorkKind
The step a harness observed the agent taking: working, or waiting on the user in its own window in a dialog it does not name. The browser words each one (runtime/state/activity-words.js).
Type: "working" | "awaiting_user".
WorkflowLine
A workflow's last explicit work line comes from a start record, so its text and log position arrive together (workflows.workflow); a failed delivery has neither.
| Field | Type | Required | Description |
|---|---|---|---|
| variant 1. | |||
detail | string | ||
detail_seq | integer | ||
| variant 2. | |||
detail | null | ||
detail_seq | null | ||
Workflow
One update the user handed over that has not settled, as its delivery (workflows.py), standing where activity.py reads it.
Type: WorkflowLine.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
input | string | yes | |
message | string or null | yes | The message a thread input is said in, which shows its delivery: its own, or for a revision the message it rewrote. |
seq | integer | yes | |
revision | integer or null | yes | |
subject | Subject | yes | |
coordinate | array of string | yes | |
obligation | string or null | yes | The id of the obligation record this update serves (workflows.handed_over): its own, or for an older input in a run of turns the newest's; null for an update that owes nothing. |
state | WorkState | yes | |
reason | WorkReason | yes | |
seen | boolean | yes | Whether a turn of the agent's has taken it in: a harness opened it into one, or the agent started or began answering it. |
ts | string or null | yes | |
delivery_seq | integer or null | yes | |
delivery_session | string or null | yes | |
delivery_turn | string or null | yes | |
detail | string or null | yes | |
detail_seq | integer or null | yes | The log position of the start whose line detail is, which places the thread's working message among its messages. |
agent | string or null | yes | |
session | string or null | yes | |
response | object or null | yes | |
response variant 1. The failure record that answered the update, which the browser's news names it by. | |||
response. | string | yes | |
response. | string or null | yes | |
started_by | array of object | yes | The starts that take the update in hand, from which the hooks read whether one holds it now (activity.in_hand). |
started_by[]. | string | yes | |
started_by[]. | string or null | yes | |
started_by[]. | string or null | yes | |
started_by[]. | integer | yes | |
started_by[]. | string | yes | |
thread | string or null | yes | The thread it stands in: a thread input's own, a widget in a message's thread, or null for a page widget. |
| variant 1. | |||
subject. | "widget" | yes | |
subject. | string | yes | |
| variant 2. | |||
subject. | "thread" | yes | |
subject. | string | yes | |
Start
A start in force on an item (todos.running): the line the agent said of it, when, by whom, and the turn it holds the item for.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
item | string | yes | |
text | string | yes | |
seq | integer | yes | |
ts | string | yes | |
agent | string or null | yes | |
session | string or null | yes | |
turn | string or null | yes |
PlanStep
One step of the plan (plans.plan_reading): a heading, which names no item and reads its standing from the records its steps name, or a step naming an obligation, a to-do among them, whose title and standing it shows, with the words a finished to-do's end gave as detail; done of total counts its steps that ended done, dropped ones left out.
| Field | Type | Required | Description |
|---|---|---|---|
title | string or null | yes | |
next_actor | "user" | "agent" | null | yes | |
state | WorkState | yes | |
reason | WorkReason | yes | |
outcome | Outcome | yes | |
item | object or null | yes | |
item when kind is "todo" | "obligation". | |||
item. | "todo" | "obligation" | yes | |
item. | string | yes | |
running | Start or null | yes | |
since | string or null | yes | |
detail | string or null | yes | |
waiting_on | string or null | yes | On a to-do's step: what the to-do waits on, as its record says (todos), or null. |
steps | array of PlanStep | yes | |
done | integer | yes | |
total | integer | yes | |
Gesture
What an action did, in its record form's terms and its own document's words (gesture_words.GestureWords.gesture).
| Field | Type | Required | Description |
|---|---|---|---|
form | "choice" | "move" | "edit" | "add" | "set" | "answer" | "verb" | yes | |
chosen | array of string | ||
unit | string | ||
to | string | ||
words | string | ||
value | any | ||
verb | string | ||
when form is "choice", requires chosen. | |||
when form is "move", requires unit. | |||
when form is "add", requires words. | |||
when form is "set", requires value. | |||
when form is "answer", requires chosen. | |||
when form is "verb", requires verb. | |||
HistoryRow
One logged event as a history feed reads it (history.history). Which of the optional fields a row carries follows its kind.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
ts | string | yes | |
kind | "comment" | "reply" | "edit" | "resolve" | "unresolve" | "action" | "report" | "note" | yes | |
author | string | yes | |
agent | string or null | yes | |
undone | boolean | yes | |
thread | object or null | ||
thread. | string | yes | |
anchor | Anchor | ||
about | comment's about or null | ||
emoji | string | ||
holds | comment's holds or null | ||
drawing | boolean | ||
excerpt | string or null | ||
widget | string | ||
gesture | Gesture | ||
value | any | ||
version | integer | ||
when kind is "comment", requires anchor, about. | |||
when kind is "reply", requires thread. | |||
when kind is "edit", requires thread. | |||
when kind is "resolve", requires thread. | |||
when kind is "unresolve", requires thread. | |||
when kind is "action", requires widget, gesture. | |||
when kind is "report", requires widget, value, excerpt. | |||
when kind is "note", requires version, excerpt. | |||
Browser
What the browser reads of the page's revisions and the work on them (served_state.browser.browser_state).
| Field | Type | Required | Description |
|---|---|---|---|
basis | object | yes | The log position the reading was taken through, and, in an answer a page server sent, key, the reading's name, a digest of its content, which a request sends back in Leaf-Held-Basis to be answered with only what changed since (Tail). |
basis. | integer | yes | |
basis. | string | ||
history | array of HistoryRow | The newest rows, newest first, sent only to a page holding a widget that declares history. | |
views | map of View | yes | Each projected revision's view, by revision number. |
plan | object or null | yes | The agent's outline of the work, its steps naming obligations by id (plans.plan_reading), or null. |
plan. | string | yes | |
plan. | string | yes | |
plan. | string or null | yes | |
plan. | string or null | yes | |
plan. | array of PlanStep | yes | |
thread_memberships | map of array of string | yes | Every thread whose history each logged event changes (thread_context.thread_memberships), which the browser reads for the gesture an unsent undo takes back or an unsent action replaces. |
version_notes | map of string | yes | Each version's note, by version. |
View
One revision's view: its document, the threads as its registry reads them, and the work and undo readings drawn on it.
| Field | Type | Required | Description |
|---|---|---|---|
basis | object | yes | |
basis. | integer | yes | |
basis. | integer | yes | |
document | ViewDocument | yes | |
thread | object | yes | The threads as this revision reads them: its registry classifies their widgets' decisions, and so the obligations and attention those give. |
thread. | Projection | yes | |
thread. | array of Thread | yes | |
obligations | array of Obligation | yes | Every obligation record of this view, its document's then its threads', answered and withdrawn ones included. The one copy of each: a list row names an obligation by id. |
reports | array of object | yes | The view's report feed, in log order (projection.canonical_reports). |
reports[]. | string | yes | |
reports[]. | object | yes | |
reports[]. | "widget" | yes | |
reports[]. | string | yes | |
reports[]. | "report" | yes | |
reports[]. | string | yes | |
reports[]. | object | yes | |
reports[]. | string or null | yes | |
reports[]. | string | yes | |
reports[]. | integer | yes | |
reports[]. | integer | yes | |
reports[]. | string or null | yes | |
reports[]. | string or null | yes | |
reports[]. | "effective" | "outranked" | "settled" | yes | |
undo | array of object | yes | The user's gestures this document can take back, newest first (served_state.document.browser_undo_candidates), or in an answer with since those new or changed since; newest marks the user's newest gesture, and gesture says what that one did when it is an action. |
undo[]. | Event | yes | |
undo[]. | array of string | ||
undo[]. | true | ||
undo[]. | Gesture | ||
published_at | string or null | yes | |
queues | object | yes | On Me and On <agent> and what each has finished, newest first (served_state.queues). |
queues. | array of QueueRow | yes | |
queues. | array of QueueRow | yes | |
queues. | array of QueueRow | yes |
Projection
One declared state projection (served_state.wire.browser_projection).
| Field | Type | Required | Description |
|---|---|---|---|
entries | array of object | yes | Each widget event this projection classifies, in log order, or in an answer with since those new or changed since. |
entries[]. | action or report | yes | |
entries[]. | [string, string, string] | yes | |
entries[]. | verb (verbs) | yes | The operation the event was admitted under, by the immutable registry of the revision that interpreted it, which may differ from the active document's. Browser folds read this rather than reinterpreting history through whichever registry the current DOM selected. |
entries[]. | any | yes | The record of the action as it stands, which the browser folds rather than the event's own detail: a version that rewrote a member of the set an attribute record holds leaves the set without that member. |
entries[]. | "document" | "thread" | yes | |
entries[]. | array of string | yes | |
entries[]. | boolean | yes | Whether a later revision absorbed this move, whose markup places the unit. |
entries[]. | boolean | yes | Whether nothing has taken this action back or retracted it, so it stands at its coordinate once every newer one is withdrawn. |
actions | array of string | yes | |
reports | array of string | yes | |
desired | array of string | yes |
ObligationAnswer
| Field | Type | Required | Description |
|---|---|---|---|
value | any | yes | |
event | EventReference or null | yes |
WidgetObligationSource
| Field | Type | Required | Description |
|---|---|---|---|
kind | "widget" | yes | |
id | string | yes | |
tag | string | yes |
UpdateObligationSource
An update the user handed over: id is the input's event, subject the thread or widget it stands on.
| Field | Type | Required | Description |
|---|---|---|---|
kind | "update" | yes | |
id | string | yes | |
subject | Subject | yes |
MessageObligationSource
| Field | Type | Required | Description |
|---|---|---|---|
kind | "message" | yes | |
id | string | yes |
TodoObligationSource
A to-do the agent opened: id is its opening event, subject what it stands on.
| Field | Type | Required | Description |
|---|---|---|---|
kind | "todo" | yes | |
id | string | yes | |
subject | Subject | yes |
ObligationPrompt
| Field | Type | Required | Description |
|---|---|---|---|
text | string or null | yes | |
target | string or null | yes | Where the user goes to answer: the id of the group the author declares round a widget, or of the widget itself, or of the thread or widget an update stands on; null for a message, whose thread supplies navigation. |
Obligation
One thing owed, the record every list, thread and plan step reads (obligations.py): what a message or widget waits on the user for, what a user update is owed (workflows.handed_over), or a to-do the agent opened (todos.py). It says where it stands in the fields every record does (standing.py). The source owns the canonical value; identity includes its kind so authored ids and message ids cannot collide, but a to-do's, which is its opening event's.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
source | WidgetObligationSource or UpdateObligationSource or MessageObligationSource or TodoObligationSource | yes | |
thread | string or null | yes | |
message | string or null | yes | |
prompt | ObligationPrompt | yes | |
answer | ObligationAnswer or null | yes | |
end | object or null | yes | On a to-do: how the agent ended it, by leaf task end or the stamped version that completed it; where the result is, or why there is none. |
end. | string or null | yes | |
end. | object | yes | The ending's reference, which names no kind. |
end. | string | yes | |
end. | integer | yes | |
end. | string | yes | |
end. | string | yes | |
next_actor | "user" | "agent" | null | yes | |
state | WorkState | yes | |
reason | WorkReason | yes | |
outcome | Outcome | yes | |
answered | boolean | yes | Whether the answer its source takes stands on it (standing.answered): the user's own answer to a question, or the reply to an update, and not an end the agent recorded. |
seen | boolean | On an update: whether a turn of the agent's has taken it in. | |
workflow | string or null | On an update: the id of the workflow it stands by, the strongest serving it, or null once nothing does. | |
waiting_on | string or null | On a to-do: what its work waits on, in the agent's words, until a start takes it up or it ends (todos), or null. | |
line | Start or null | On a to-do: the start in force on it, whose text is the line the agent last said of it, or null. | |
seq | integer | ||
ts | string | ||
agent | string or null | ||
session | string or null | ||
revision | integer or null | ||
| variant 1. | |||
answer. | any | yes | |
| variant 1. | |||
| variant 2. | |||
| variant 2. | |||
answer. | null | yes | |
| variant 3. | |||
answer. | object | yes | |
answer. | string | ||
answer. | string | ||
one of: requires waiting_on, line, seq, ts, agent, session, revision. | |||
QueueRow
One row of On Me, On <agent> or Done (served_state.queues); owner names its list. It names its obligation by id, whose record is the view's obligations entry.
Type: ObligationRow.
ObligationRow
An obligation record's row in On Me, On <agent> or Done (served_state.queues). The record says where it stands, whether the agent has it in hand and how a done one ended.
| Field | Type | Required | Description |
|---|---|---|---|
kind | "widget" | "update" | "message" | "todo" | yes | The record's source.kind. |
id | string | yes | The obligation, whose record is the view's obligations entry. |
owner | "user" | "agent" | yes | The list the row stands on, or stood on before Done. |
subject | Subject | yes | |
thread | string or null | yes | The thread it stands in, or null. |
also | array of string | yes | The other obligations the user answers at the same place, each a view's obligations entry: the further records a thread's reply answers, and on an obligation's row those of a thread about it. |
Anchor
Where a thread stands on the page, as a comment, reply or reanchor names it, or null.
Type: comment's anchor or reply's anchor or reanchor's anchor.
MessageEdited
The user's latest rewrite of a message, and the words it replaced (events.rewritten).
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
seq | integer | yes | |
ts | string | yes | |
was | string | yes |
MessageWithdrawn
The undo that took a message back while something still stood on it, and what it said; the message keeps its place with no words and no mark (events.message_reading).
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
ts | string | yes | |
was | string | yes |
Message
A logged comment or reply as a served thread holds it, with its latest edit's words, and its current content version (read_state.content_version), which the browser marks read once its words have been shown. An agent's message carries the name it is shown under as agent (schema.agent_name).
| Field | Type | Required | Description |
|---|---|---|---|
agent | string | ||
html | true | An agent's message whose current Markdown holds HTML (events.thread_structure), which the browser draws as markup. | |
content_version | string | yes | |
completed_by | string or null | What ended this progress message (served_state.thread.progress_ends): the agent message that superseded it, which hides it only while that message is presented, or null where the turn that wrote it ended. | |
edited | MessageEdited | ||
withdrawn | MessageWithdrawn |
ContentVersion
One version of an agent message's content: the message, and its latest edit's id or else its own (read_state.content_version).
| Field | Type | Required | Description |
|---|---|---|---|
message | string | yes | The message's event id. |
version | string | yes | The content version's id, which a read event names. |
Thread
One thread, keyed by the comment that opened it (events.build_threads), as served_state.thread.browser_thread serves it.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
root | Message | yes | |
title | string or null | yes | |
anchor | Anchor | yes | |
detached_from | Anchor | yes | |
rewritten_from | Anchor | yes | |
gone_element | object or null | yes | The element the thread is about, where the latest version doesn't hold it, as the version of the message that placed the thread on it read it (served_state.thread.gone_element); else null. |
gone_element. | string | yes | |
gone_element. | string | yes | |
gone_element. | string | yes | |
msgs | array of Message | yes | |
revisions | array of edit | yes | The user's edits in log order, each with was, the words it replaced. |
revisions[]. | string | yes | |
resolved | resolve or action or null | yes | What closed the thread, an agent's named by agent (schema.agent_name), or null while it is open. |
resolved. | string | ||
seat | string or null | yes | The widget whose thread seat the root stands in (events.seat_root), or null. |
summaries | array of object | yes | The thread's current summaries (events.active_summaries). |
summaries[]. | string | yes | |
summaries[]. | integer | yes | |
summaries[]. | string | yes | |
summaries[]. | string | yes | |
summaries[]. | array of string | yes | |
summaries[]. | string | yes | |
summaries[]. | string | ||
unread | map of string | yes | The content version of each message the user hasn't read, by the message's id, in log order (read_state.unread_content). |
attention | string or null | yes | Whose turn the thread is and where it stands: the id of the open obligation record that speaks for it (standing.leading), in the view's obligations, or null for nobody's (served_state.browser._apply_thread_attention). |
ViewDocument
A revision's document as a view serves it: its widget state's projection under the registry it captured (served_state.document.browser_document).
| Field | Type | Required | Description |
|---|---|---|---|
revision | integer | yes | |
projection | Projection | yes |
ViewAnswer
The answer GET /api/view gives (served_state.service.PageStateService.page_comparison): what a version comparison folds of one revision at an exact log boundary.
| Field | Type | Required | Description |
|---|---|---|---|
document | ViewDocument | yes |
Tail
What a page server sends a tab in place of a reading when the tab's request names, in Leaf-Held-Basis, the browser.basis.key of a reading it holds and the server still remembers that reading (served_state.tail). The browser applies patch to the reading since names and completes the whole answer from it (completeState in transport/layer-client.js).
| Field | Type | Required | Description |
|---|---|---|---|
since | object | yes | The reading the changes start from. |
since. | string | yes | |
patch | array of Change | yes | The changes from that reading to this one, in order, data sources included, each source's value only where its revision moved. They leave out events. |
events | array of Event | yes | The events logged after that reading's through_seq. |
Change
One change a Tail makes to the reading it starts from, at at, a path of keys through its objects from the root of what it changes: the reading, or for a change inside a list's item, that item (served_state.tail).
| Field | Type | Required | Description |
|---|---|---|---|
variant 1. The value at at is now value, whole. | |||
at | array of string | yes | |
value | any | yes | |
variant 2. The object holding the last key of at no longer holds it. | |||
at | array of string | yes | |
when by is "id" | "event" | "self". The list at at, whose items are each named by its id (by id), its event's id (event) or itself, a string (self), changed: items holds its new items whole, changed pairs the name of each item it held that is now otherwise with the changes from that item to what it is now, dropped names those it no longer holds, and after pairs each item that is new or moved, in the list's order, with the name of the item now before it, or null for the first. Every other item keeps its place. | |||
at | array of string | yes | |
by | "id" | "event" | "self" | yes | |
items | array of any | ||
changed | array of [string, array of Change] | ||
dropped | array of string | ||
after | array of [string, string or null] | ||
EventAnswer
The answer POST /api/event gives once its gates pass (event_endpoint).
| Field | Type | Required | Description |
|---|---|---|---|
when ok is true. Accepted, with the event the log holds for it and the page's state, which holds the event's receipt (event_endpoint.with_state). | |||
ok | true | yes | |
event | Event | yes | |
needs_reply | boolean | yes | Whether the event owes the agent an answer: its update stands among those the agent owes (obligations.update_obligation). |
state | served state or Tail | yes | |
when ok is false and final is true. Refused, and final: nothing was appended. error is the words the tab shows its user. A refusal admission made carries state, which restores the tab from current truth; a gate's refusal (http.PageEndpoint.refuse) carries none. | |||
ok | false | yes | |
final | true | yes | |
error | string | yes | |
findings | array of Finding | yes | |
attempt | any | The posted attempt, echoed as it came. | |
state | served state or Tail | ||
when ok is false. A fault that may have landed either side of the append, so the next identical request finds out (event_endpoint.event_fault). | |||
ok | false | yes | |
error | string | yes | |
attempt | any | The posted attempt, echoed as it came. | |
Finding
What a refusal refused on (findings.Finding.json, less its words). The browser shows the refusal's error instead.
| Field | Type | Required | Description |
|---|---|---|---|
code | string | yes | |
severity | "error" | "advice" | yes | |
at | string | ||
values | object |
SampleAnswer
The answer POST /api/samples gives: the new live sample's address, and its interaction page (http_routes.create_sample).
| Field | Type | Required | Description |
|---|---|---|---|
url | string | yes | |
page | string | yes |
MediaAnswer
The answer POST /api/media gives: the stored image's page-relative path (media.store_uploaded_media).
| Field | Type | Required | Description |
|---|---|---|---|
path | string | yes |
FileSnapshot
One bound file as GET and a successful POST /api/files/<binding> answer it (file_bindings): its name, its text with LF line endings, and the revision a save names.
| Field | Type | Required | Description |
|---|---|---|---|
label | string | yes | |
text | string | yes | |
revision | string | yes |
StaleFile
A save refused because the file changed since the revision it named, with the file as it is now.
| Field | Type | Required | Description |
|---|---|---|---|
error | string | yes | |
current | FileSnapshot | yes |
LivePage
One of the machine's other live pages, as its own server publishes its compact row (server_rows.py), named by page_key and linked by url (presence.other_leaves). A row is open: a neighbor's Leaf may publish fields this one ignores.
| Field | Type | Required | Description |
|---|---|---|---|
page_key | string | yes | |
url | string | yes | |
title | string | yes | |
session_cwd | string or null | yes | |
activity | object | yes | |
activity. | Activity's presence | yes | |
activity. | Activity's state | yes | |
activity. | Activity's reason | yes | |
activity. | Activity's next_actor | yes | |
activity. | Activity's detail | yes | |
activity. | Activity's observed | yes | |
activity. | Activity's observed_kind | yes | |
activity. | Activity's counts | yes | |
activity. | Activity's ts | yes | |
activity. | Activity's next_transition_at | yes |
NewsAnswer
The answer GET /api/news gives (http_routes.news_route): three readings the tab follows apart. reading names the page's own reading, the one an /api/state answer carries; pages names the list /api/pages answers (presence.pages_reading), or is null while no other page is live, and moves on its own, so another page's change never asks the tab to read this page's state again; drafts names the store of the user's drafts /api/drafts answers and its version (drafts.py), which a keystroke moves without moving the page's reading.
| Field | Type | Required | Description |
|---|---|---|---|
reading | string | yes | |
pages | string or null | yes | |
drafts | object | yes | |
drafts. | string | yes | |
drafts. | integer | yes |
Draft
One draft the user is writing, the generation its last write made (drafts.py): its attempt, words and what its send depends on beside them, with the store's version at that write.
| Field | Type | Required | Description |
|---|---|---|---|
attempt | string | yes | |
text | string | yes | |
payload | object | ||
held | string | ||
version | integer | yes |
DraftsAnswer
The answer GET /api/drafts gives, and what a served document carries of it (lf-drafts): every draft the user is writing on the page, by its context, with the store's identity and version. A sent or put-away draft is absent.
| Field | Type | Required | Description |
|---|---|---|---|
store | string | yes | |
version | integer | yes | |
drafts | map of Draft | yes |
DraftWriteAnswer
The answer POST /api/draft gives: the context's generation as the store now holds it, null where a send or Cancel settled it, and whether that is what the write asked for. A write names the generation it replaces, so another tab's or device's later words come back in place of this tab's.
| Field | Type | Required | Description |
|---|---|---|---|
written | boolean | yes | |
store | string | yes | |
version | integer | yes | |
record | null or Draft | yes |
PagesAnswer
The answer GET /api/pages gives: the machine's other live pages, in title order (presence.neighbor_reading). It holds no consistency with the page's own reading. A capture, such as an export or a render check's, lists none.
Type: array of LivePage.
Refusal
Any route's refusal of a request (http.PageEndpoint.refuse): the words the page shows.
| Field | Type | Required | Description |
|---|---|---|---|
error | string | yes |
LayerAnswer
A write held because the tab speaks another layer (http_routes.layer_gate): the generation it should speak, which the Leaf-Layer header also carries, so the tab reloads without reading this.
| Field | Type | Required | Description |
|---|---|---|---|
layer | string | yes |
Events
Each line of a page's events.jsonl is one event, validated
against the schema for its kind before it is appended. The first table lists
the fields every kind shares; each kind's table lists the rest.
Every event
| Field | Type | Required | Description |
|---|---|---|---|
attention | boolean | yes | |
id | string | yes | |
ts | string | yes | |
seq | integer | yes |
comment
What it means. The browser may post it to POST /api/event. A message kind. A undoable kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "comment" | yes | |
revision | integer | yes | |
text | string | ||
emoji | string | ||
anchor | object | ||
anchor. | string or null | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | true | ||
anchor. | string | ||
anchor one of: requires section; requires quote; requires datum. | |||
drawing | object | ||
drawing. | array of array of [number, number] | yes | |
drawing. | [number, number] | yes | |
drawing. | object | ||
drawing. | string | yes | |
drawing. | array of object | yes | |
drawing. | string | yes | |
drawing. | integer | yes | |
drawing. | integer | yes | |
drawing. | boolean | ||
drawing. | string | ||
drawing. | [number, number] | yes | |
drawing. | "light" | "dark" | yes | |
suggestion | boolean | ||
about | "design" | ||
title | string | ||
agent | string | ||
session | string | ||
attempt | string | ||
holds | string | ||
obligation | true | ||
viewing | array of string | ||
one of: requires text; requires emoji; requires drawing and forbids text. | |||
reply
What it means. The browser may post it to POST /api/event. A message kind. A undoable kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "reply" | yes | |
parent | string | yes | |
revision | integer | ||
publication | string | ||
text | string | ||
emoji | string | ||
anchor | object or null | ||
anchor. | string or null | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | string | ||
anchor. | true | ||
anchor. | string | ||
anchor one of: requires section; requires quote; requires datum. | |||
title | string | ||
agent | string | ||
session | string | ||
todo | string | ||
waiting_on | string | ||
ephemeral | true | ||
unannounced | true | ||
no_reply | true | ||
start | object | ||
start. | string | yes | |
turn | string | ||
failure | string | ||
responds | string | ||
attempt | string | ||
obligation | true or array of string | ||
one of: requires text; requires emoji; requires no_reply. | |||
edit
What it means. The browser may post it to POST /api/event. A undoable kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | "user" | yes | |
kind | "edit" | yes | |
attempt | string | ||
message | string | yes | |
revision | integer | Where an agent's new words hold HTML, the revision its markup was checked against, as a message holding HTML names one. | |
text | string | yes | The message's new words. None deletes it: readings keep it in its place with no words (events.md, "Messages"). |
base | string | ||
agent | string | ||
session | string | ||
when author is "agent", requires agent, session. | |||
when author is "user", forbids agent, session. | |||
summary
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | yes | |
kind | "summary" | yes | |
thread | string | yes | |
from | string | yes | |
through | string | yes | |
text | string | yes | |
label | string | ||
agent | string | yes | |
session | string | yes |
read
What it means. The browser may post it to POST /api/event. A bookkeeping kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | "user" | yes | |
kind | "read" | yes | |
messages | array of object | yes | |
messages[]. | string | yes | |
messages[]. | string | yes | |
attempt | string |
seen
What it means. The browser may post it to POST /api/event. A bookkeeping kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | "user" | yes | |
kind | "seen" | yes | |
revision | integer | yes | |
attempt | string |
thread_title
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | yes | |
kind | "thread_title" | yes | |
thread | string | yes | |
title | string | yes | |
agent | string | yes | |
session | string | yes |
todo
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | yes | |
kind | "todo" | yes | |
subject | object | yes | |
subject when kind is "widget" | "element" | "thread". | |||
subject. | "widget" | "element" | "thread" | yes | |
subject. | string | yes | |
subject when kind is "page". | |||
subject. | "page" | yes | |
revision | integer | ||
title | string | yes | |
agent | string | ||
session | string | ||
waiting_on | string | ||
start
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | yes | |
kind | "start" | yes | |
item | string | yes | |
text | string | yes | |
turn | string | ||
agent | string | ||
session | string |
status
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | yes | |
kind | "status" | yes | |
state | "waiting" | "idle" | yes | |
agent | string | ||
session | string |
plan
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | yes | |
kind | "plan" | yes | |
steps | array of object | yes | |
steps[] variant 1. | |||
steps[]. | integer | yes | |
steps[]. | string | yes | |
steps[] variant 2. | |||
steps[]. | integer | yes | |
steps[]. | string | yes | |
agent | string | ||
session | string | ||
todo_end
| Field | Type | Required | Description |
|---|---|---|---|
author | "agent" | yes | |
kind | "todo_end" | yes | |
todo | string | yes | |
outcome | "done" | "failed" | "dropped" | yes | |
detail | string | ||
agent | string | ||
session | string |
activation
What it means. A bookkeeping kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | "page" | yes | |
kind | "activation" | yes | |
revision | integer | yes | |
publication | string | yes |
reanchor
What it means. A bookkeeping kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | "page" | yes | |
kind | "reanchor" | yes | |
thread | string | yes | |
revision | integer | yes | |
anchor | object or null | yes | |
anchor. | string | yes |
resolve
What it means. The browser may post it to POST /api/event. A undoable kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "resolve" | yes | |
parent | string | yes | |
agent | string | ||
session | string | ||
attempt | string |
unresolve
What it means. The browser may post it to POST /api/event. A undoable kind.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "unresolve" | yes | |
parent | string | yes | |
agent | string | ||
session | string | ||
attempt | string |
action
What it means. The browser may post it to POST /api/event. A undoable kind. Carries a verb (verbs) the user writes.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "action" | yes | |
widget | string | yes | |
action | string | yes | |
detail | object | yes | |
meaning | object | yes | |
meaning. | "page" | "thread" | yes | |
meaning. | string | yes | |
meaning. | array of string | yes | |
meaning. | string or null | ||
meaning. | string | ||
meaning. | object | ||
meaning. | string | yes | |
meaning. | string | yes | |
meaning. | object or null | yes | |
meaning. | object or null | yes | |
meaning. | boolean | yes | |
meaning. | object or boolean | yes | |
revision | integer | yes | |
answered | boolean | ||
attempt | string |
pickup
| Field | Type | Required | Description |
|---|---|---|---|
author | "page" | yes | |
kind | "pickup" | yes | |
events | array of string | yes | |
phase | "queued" | "opened" | "failed" | yes | |
session | string or null | yes | |
turn | string or null | yes | |
failure | string | ||
refs | map of object | ||
refs. | string | yes | |
refs. | string or null | yes | |
when phase is "failed", requires failure. | |||
otherwise, forbids failure. | |||
receipt
| Field | Type | Required | Description |
|---|---|---|---|
author | "page" | yes | |
kind | "receipt" | yes | |
through | integer | yes |
undo
What it means. The browser may post it to POST /api/event.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "undo" | yes | |
undoes | string | yes | |
answered | boolean | ||
attempt | string |
report
What it means. Carries a verb (verbs) the agent writes.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "report" | yes | |
widget | string | yes | |
action | string | yes | |
detail | object | yes | |
meaning | object | yes | |
meaning. | "page" | "thread" | yes | |
meaning. | string | yes | |
meaning. | array of string | yes | |
meaning. | object | ||
meaning. | string | yes | |
meaning. | string | yes | |
meaning. | object or null | yes | |
meaning. | object or null | yes | |
meaning. | boolean | yes | |
meaning. | object or boolean | yes | |
revision | integer | yes | |
agent | string | ||
session | string |
note
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "note" | yes | |
version | integer | yes | |
revision | integer | yes | |
publication | string | ||
text | string | yes | |
restated | array of string | ||
settles | array of object | ||
settles[]. | "report" | "todo" | yes | |
settles[]. | string | yes | |
agent | string | ||
session | string |
error
What it means. The browser may post it to POST /api/event.
| Field | Type | Required | Description |
|---|---|---|---|
author | string | yes | |
kind | "error" | yes | |
revision | integer | ||
text | string | yes |
render
| Field | Type | Required | Description |
|---|---|---|---|
author | "page" | yes | |
kind | "render" | yes | |
revision | integer | yes | |
findings | array of object | yes | |
findings[]. | string | yes | |
findings[]. | "error" | "advice" | yes | |
findings[]. | string | yes |
Records
Leaf keeps these JSON files outside a page's log and document, in the page
directory, the machine's state home, or the browser's storage. Each carries
a
format naming the protocol at which its shape last changed.
Each file but a page's layer.json carries that number before
its suffix, as drafts@51.json, so a Leaf of one shape never
reads or replaces another's. delivery is the envelope an agent
reads with leaf delivery read.
access
The key every page this machine serves is read with (host_key), in the state home's access.json.
Stored with format leaf-access/13.
| Field | Type | Required | Description |
|---|---|---|---|
token | string | yes |
antigravity
The Antigravity language server endpoint a session's environment named (ANTIGRAVITY_LS_ADDRESS), in the state home's sessions/<digest>.antigravity (mode 0600), used to query live status and wake an idle conversation through agentapi.
Stored with format leaf-antigravity/66.
| Field | Type | Required | Description |
|---|---|---|---|
address | string | yes | The language server host:port. |
token | string | yes | The CSRF token authenticating local calls (empty string on agy CLI). |
pid | integer | yes | The Antigravity language server or CLI process. |
exe | string | The binary carrying agentapi (ANTIGRAVITY_AGENTAPI_EXE). | |
app_data | string | Antigravity's product data directory (ANTIGRAVITY_APP_DATA_DIR). |
antigravity-app
The Antigravity Desktop App's live language server endpoint, written by Leaf's sidecar (sidecars/leaf/state.mjs) in the state home's antigravity-app.json (mode 0600), so sandboxed Desktop App MCP tool calls resolve the live address and rotating sidecar CSRF token by matching PID.
Stored with format leaf-antigravity-app/66.
| Field | Type | Required | Description |
|---|---|---|---|
address | string | yes | The language server host:port. |
token | string | yes | The CSRF token authenticating local calls (empty string on agy CLI). |
pid | integer | yes | The Antigravity language server or CLI process. |
exe | string | The binary carrying agentapi (ANTIGRAVITY_AGENTAPI_EXE). | |
app_data | string | Antigravity's product data directory (ANTIGRAVITY_APP_DATA_DIR). |
bridge
Where the running bridge of one version of bridge.py listens, in the state home's bridge/<key>.json.
Stored with format leaf-bridge/13.
| Field | Type | Required | Description |
|---|---|---|---|
port | integer | yes | The loopback port it listens on. |
token | string | yes | The token a request carries. |
pid | integer | yes | The bridge's process. |
bridge-session
A session the bridge serves, one of the session's own files in the state home's sessions/ (registrations), with the fields of the lifetime it lives by (Harness.lifetime) beside its id.
Stored with format leaf-bridge-session/13.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | The harness's session id. |
claim
The session that receives a page's updates, in the state home's claims/<page key>.json (claim_path).
Stored with format leaf-claim/13.
| Field | Type | Required | Description |
|---|---|---|---|
page | string | yes | The page directory. |
ts | string (date-time) | yes | When the claim was published. |
id | string | yes | The claimant session (sessions.SESSION). |
generation | string | yes | The generation of the session this claim names. |
acquisition | string | yes | This publication's own identity (same_claim). |
harness | string | yes | The claimant's Harness.name. |
agent | string | yes | The name the claimant shows. |
cwd | string | yes | The claimant's working directory. |
messaged_ending | string | The turn ending after which input last messaged the session (note_messaged). |
clerk
The lines Leaf queued for a session's next step, in the state home's sessions/<digest>.clerk (state.session_file): one for each record the clerk wrote and each finding it passes on (clerk), and one for each summary a summary fork wrote or left to the agent (summary_fork). Each says whether it wakes the session (wake): a line that tells it of work it now owes wakes it while it is idle, until a hook has printed the line.
Stored with format leaf-clerk/52.
| Field | Type | Required | Description |
|---|---|---|---|
lines | array of object | yes | |
lines[]. | string | yes | |
lines[]. | boolean | yes |
codex-delivery
One delivery a Codex task is handing to its agent (DeliveryRecord), in the state home's sessions/<digest>.deliveries/<id>.json and, once nothing is owed on it, that directory's history/. A record at another format is ignored, and the events its page has not acknowledged are captured afresh.
Stored with format leaf-codex-delivery/14.
| Field | Type | Required | Description |
|---|---|---|---|
state | "collecting" | "offering" | "hook" | "starting" | "queued" | "opened" | "abandoned" | yes | How far the handoff has gone (RECORD_VARIANTS). |
created_at | number | yes | When it was captured, in seconds since the epoch. |
batches | array of object | yes | One per page. |
batches[]. | string | yes | The page directory. |
batches[]. | string | yes | |
batches[]. | array of object | yes | The captured events, by id and seq. |
batches[]. | string | yes | |
batches[]. | integer | yes | |
when state is "collecting". | |||
batches[]. | integer | yes | |
batches[]. | array of object | yes | |
batches[]. | string | yes | |
batches[]. | string or null | yes | |
batches[]. | string | yes | |
batches[]. | array of string | yes | |
batches[]. | object | ||
batches[]. | "reply" | "markup" | yes | |
batches[].events[].answer when kind is "reply". | |||
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[].events[].answer when kind is "markup". | |||
batches[]. | string | yes | |
when state is "queued" | "opened" | "abandoned". | |||
pending | array of integer | yes | The indexes into batches whose page receipts are still to be written. |
when state is "hook" | "opened". | |||
turn | string | yes | The Codex turn that carries the delivery: the one its hook ran in, or the one its App Server delivery entered. |
completion
A model completion a page server asks of a Claude Code session, in the state home's sessions/<digest>.completion.<id>, which Leaf's hooks module makes and replies to (completions).
Stored with format leaf-completion/43.
| Field | Type | Required | Description |
|---|---|---|---|
request | object | yes | What the module passes to $.model.complete as it stands. |
deadline | number | yes | When the page server stops waiting, in POSIX seconds. |
reply | object | What the model call came to, as the module reports it: the answer's text, or why there is none (failed, with the HTTP status of an API error), its usage and elapsed_ms. |
data-source
One source's publication, in the page directory's data/<source>.json, which leaf data set writes whole.
Stored with format leaf-data-source/16.
| Field | Type | Required | Description |
|---|---|---|---|
contract | string | yes | The data contract the value was validated against at the write. |
run | string | yes | An opaque receipt naming the write, a rerun with the same value included. |
updated | string (date-time) | yes | When the value was written. |
value | any | yes | The source's complete value. |
delivery
The immutable envelope leaf delivery read prints (references/event-batches.md), in the state home's deliveries/<id>.json: the updates that need the agent's attention, one batch per page. Registry when clauses read its events, with an event's thread digest as thread and its batch's held as held (registry.contract.event_clauses).
Stored with format leaf-delivery/64.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | The delivery id, sixteen hex characters, which the agent's pointer names. |
created_at | number | yes | When it was first collected, in seconds since the epoch. |
acknowledge | string or null | yes | How the reader confirms receipt, or null where the harness did. |
batches | array of object | yes | One per page. |
batches[]. | string | yes | The page directory. |
batches[]. | string or null | yes | The session that owned the page at capture. |
batches[]. | integer | yes | The log position the batch was captured through. |
batches[]. | array of object | yes | The threads the batch's events land in, each with its messages other than the batch's own (thread_context.batch_threads). A when clause reads an event's as its thread. |
batches[]. | string | yes | The thread's id, which the batch's events name. |
batches[]. | string or null | yes | Null until the thread is named. |
batches[]. | comment's anchor or reply's anchor or reanchor's anchor | yes | Where the thread stands on the page. |
batches[]. | comment's anchor or reply's anchor or reanchor's anchor | yes | What a detached thread was about: the anchor whose quote a version's rewrite had moved it off, else the anchor it last had; or null. |
batches[]. | comment's anchor or reply's anchor or reanchor's anchor | yes | The anchor a revision's rewrite moved the thread off, whose quote holds the words the thread was about, or null. |
batches[]. | string or null | yes | Who closed the thread, or null while it is open. |
batches[]. | object | yes | How many messages and gestures a long thread leaves out of messages and actions. |
batches[]. | integer | yes | |
batches[]. | integer | yes | |
batches[]. | array of object | yes | Its earlier messages (thread_context.MESSAGE_FIELDS), less the batch's own events: the first and the latest of a long thread. |
batches[]. | string | yes | The message's event id. |
batches[]. | integer | yes | Its event's place in the log. |
batches[]. | string | yes | |
batches[]. | string | When it was said. | |
batches[]. | string | The name an agent's message is shown under. | |
batches[]. | string | ||
batches[]. | true | Marks a one-line progress reply, which answers nothing. | |
batches[]. | string | A reaction's emoji, in place of text. | |
batches[]. | comment's drawing | ||
batches[]. | boolean | True where the comment is a suggestion. | |
batches[]. | comment's viewing | ||
batches[]. | object | The user's latest rewrite, and the words it replaced. | |
batches[]. | string | yes | |
batches[]. | integer | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | object | The user's undo of a message something still stood on, and what the message said; it keeps its place with nothing in it. | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | array of object | yes | The thread's summaries in force (events.active_summaries). |
batches[]. | string | yes | |
batches[]. | integer | yes | |
batches[]. | string | yes | The first message the summary folds. |
batches[]. | string | yes | The last message it folds. |
batches[]. | array of string | yes | Every message it folds, in thread order. |
batches[]. | string | yes | The summary's Markdown, empty for a fold that only hides the messages. |
batches[]. | string | The name the agent gave the range, leading the summary. | |
batches[]. | array of object | yes | Gestures in force on widgets sent in the thread, other than the batch's own (thread_context.ACTION_FIELDS). |
batches[]. | string | yes | |
batches[]. | integer | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | object | yes | |
batches[]. | object | An earlier range worth summarizing, from its first message through its last, taking in the thread's summaries in force. | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | map of string | yes | Each clause's text once, by an id only this batch's events use. |
batches[]. | array of event | yes | In log order, each the logged record less the browser's attempt, with what the delivery reads of it (batch_data, handled). |
batches[]. | object | yes | What the event changes. |
batches[].events[].subject when kind is "thread" | "widget". | |||
batches[]. | "thread" | "widget" | yes | |
batches[]. | string | yes | |
batches[].events[].subject when kind is "page". | |||
batches[]. | "page" | yes | |
batches[]. | array of string | yes | Every thread the event belongs to. |
batches[]. | map of string | The words of each element the gesture names, by id, as the page it was made on wrote them. | |
batches[]. | map of string | The name of each element in says, by id, in the gesture's own document: its declared name or leading title, else its words. | |
batches[]. | string | On the user's rewrite of their own message, the words it replaced. | |
batches[]. | boolean | A comment's own flag; beside an edit's was, true where the rewritten message is a suggestion, so its new text is the exact replacement it proposes. | |
batches[]. | array of object | On the user's message or edit about a widget, one their thread is anchored in or was sent in, the work they had made there without sending it ($verbs.unsent), as it stood when they wrote: what the widget showed them (thread_context.unsent_at_messages). Absent where none stood. | |
batches[]. | string | yes | |
batches[]. | integer | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | object | yes | |
batches[]. | array of object | The agent's questions the input may have answered though it answers them by no rule: on a widget action, those still waiting on the user's words in a thread about that widget's obligations (obligations.waiting_about); on the user's message in a thread, those still waiting on a pick on a widget an agent sent there (obligations.waiting_in_thread). Each is the obligation's id and the text that asked it. | |
batches[]. | string | yes | |
batches[]. | string or null | yes | |
batches[]. | array of object | On the user's message in a thread, the agent's questions in words it answered by rule, whatever it says, so they have left On Me (obligations.settled_by_message). Each is the obligation's id and the text that asked it. | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | object | The response the event owed at capture (obligations.response_address); absent where it owes none. | |
batches[].events[].answer when kind is "reply". A thread reply under parent answering the input responds. | |||
batches[]. | "reply" | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | The delivery reference identifying this answer. |
batches[].events[].answer when kind is "markup". A stamped page revision recording the widget action action. | |||
batches[]. | "markup" | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | The delivery reference identifying this answer. |
batches[]. | array of string | Ids of the batch's handling clauses that apply, in reading order. | |
batches[]. | array of object | The agent's open to-dos on the page whose work waits on something it named (todos, waiting_on), each its id, the text naming the work and its waiting_on, so the input that ends a wait arrives beside it. A when clause reads it on each of the batch's events as held. Absent where none waits. | |
batches[]. | string | yes | |
batches[]. | string | yes | |
batches[]. | string | yes | |
draft
The selection composer's submission payload, kept beside its words in the shared draft generation (runtime/records/drafts.js): the anchor and the revision it was captured on, whether it is a suggestion or about design, its drawing, and when it was last touched. A draft's drawing adds at, the matrix that stands it in its anchor's section, which the comment leaves out: here properties beside a leaf: reference add to the object it names, as the build writes it in for the protocol baseline (build/browser/contract-types.mjs). Its format, leaf-draft/<since>, names the protocol at which this payload's shape last changed; the composer reads only its current format.
Stored with format leaf-draft/52.
| Field | Type | Required | Description |
|---|---|---|---|
format | string | yes | |
anchor | comment's anchor or null | yes | |
revision | integer | yes | |
suggest | boolean | yes | |
about | comment's about or null | yes | |
drawing | comment's drawing or null | yes | |
drawing. | array of number | ||
touched | number | yes |
drafts
The user's unsent message drafts on a page, in the page directory's drafts.json.
Stored with format leaf-drafts/51.
| Field | Type | Required | Description |
|---|---|---|---|
store | string | yes | The store's identity, minted when its file is created. |
version | integer | yes | Counts the store's writes; each record holds the count at its own. |
drafts | map of object | yes | Each draft's latest generation, by its context, which a generation the log admitted no longer is. |
drafts. | string | yes | The generation's attempt, which its send carries into the log. |
drafts. | string | yes | The words, untrimmed. |
drafts. | object | What the generation's send depends on beside its words, such as a comment's anchor ($events.draft). | |
drafts. | string | A reply a refusal handed back to the draft whose message opens its thread. | |
drafts. | integer |
file-bindings
The local text files a page may edit, in the page directory's files.json.
Stored with format leaf-file-bindings/50.
| Field | Type | Required | Description |
|---|---|---|---|
bindings | map of string | yes | Each binding id's file: its path from the page directory when it lies inside it, and otherwise its canonical absolute path. |
http-connections
Stored with format leaf-http-connections/19.
| Field | Type | Required | Description |
|---|---|---|---|
page | string | yes | |
connections | map of object | yes | |
connections. | string | yes | |
connections. | string | yes | |
connections. | string | yes | |
connections. | string | yes | |
connections. | integer | yes |
layer
A page's layer selection, layer.json in its directory: the packages every Leaf that reads the page composes, in order, and the generation an open document speaks. Its format names the page protocol of the Leaf that last initialized the page, so unlike every other record it keeps one file whatever its shape (write_layer).
Stored with format leaf-layer/67.
| Field | Type | Required | Description |
|---|---|---|---|
packages | array of string | yes | |
generation | string | yes |
preview
What a developer preview shows in browser chrome, as leaf-dev preview writes it to the page directory's preview.json.
Stored with format leaf-preview/13.
| Field | Type | Required | Description |
|---|---|---|---|
example | string | yes | The name of the source file the preview serves, without its extension. |
checkout | string | yes | The checkout whose Leaf serves it. |
interaction | "user" | "author" | yes | user for a --user preview, whose presses reach the session that claimed it; author for a plain one. |
started | string | yes | When the preview started. |
input | object | yes | The fixture publication the preview's watcher last applied. |
input. | string | yes | |
input. | string | yes |
render-reading
The latest render check of a page, by page check --render or its server (handover_pass), in the state home's render-readings/<page key>.json. Disposable: without it, a version is read again.
Stored with format leaf-render-reading/57.
| Field | Type | Required | Description |
|---|---|---|---|
page | string | yes | The page directory. |
digest | string | yes | The artifact digest of the version read. |
data | string or null | yes | The version of the page's data the check read the page with (data.data_version); null where the check never read the page, as where it overran its deadline. |
findings | array of object | yes | What it found (findings.Finding.json), every finding of which the agent has heard. |
visuals | map of object | yes | What each visual in the page drew at the desktop window, by the visual's id (drawnVisuals in render-checks/widgets.js); empty where the check stopped before it read them. |
visuals. | array of object | yes | The parts the visual offered a thread. |
visuals. | string | yes | |
visuals. | string | yes | |
visuals. | boolean | yes | Whether the page puts a thread on a part the visual didn't draw on the whole visual, rather than nowhere (drawsAbsentParts). |
row
A serving page's row, which other pages show it by, in the state home's rows/<page key>.json.
Stored with format leaf-row/65.
| Field | Type | Required | Description |
|---|---|---|---|
page | string | yes | The page directory. |
page_key | string | yes | The page's key (state.page_key). |
server_id | string | yes | The server incarnation that published the row; a reader takes only the live service's own. |
row | object | yes | What other pages show of it. |
row. | string | yes | The page's title. |
row. | string or null | yes | The claimant session's working directory, or null. |
row. | object | yes | The page's activity, bounded to the fields a row shows (compact_activity). |
row. | object | yes | |
row. | integer | yes | How many rows On Me holds. |
row. | array of string | yes | The names of On Me's rows that have one, in On Me's order (service._on_user_names). |
row. | object | yes | What the Leaf panel counts of the threads (thread_counts): the open threads, and of those the ones the user hasn't read. |
row. | integer | yes | |
row. | integer | yes |
service
The page's desired service, in the page directory's service.json, which hosting.py writes.
Stored with format leaf-service/13.
| Field | Type | Required | Description |
|---|---|---|---|
host | string | yes | The address a URL names. |
bind | string | yes | The address the server binds. |
port | integer | yes | The port the server listens on. |
enabled | boolean | yes | Whether the page should be served. |
lifetime | "session" | "persistent" | yes | Whether the server stops when no live session claims the page, or runs until leaf server stop. |
runtime | object | yes | The Leaf that served it (layer.payload_provenance). |
server_id | string | yes | The serving incarnation the server lease names. |
restart | string | The mark hosting.restarting_server leaves while it holds a served page down to restart it. |
session
One harness session's lifecycle, in the state home's sessions/<digest>.lifecycle (session_file): the lifetime it lives by, whether it has ended, and its current turn.
Stored with format leaf-session/65.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | The harness's own session id. |
generation | string | yes | Replaced when a claim made before can no longer name this lifetime. |
ended | null or string (date-time) | yes | When the session ended, or null while it lives. |
turn | string or null | yes | The id of the session's latest turn, or null before its first. |
turn_opened | null or string (date-time) | yes | When the latest turn opened or was last renewed. |
turn_closed | null or string (date-time) | yes | When the turn closed, or null while it is open. |
revision | integer | yes | Incremented by every write (write_session). |
provider | boolean | yes | Whether the harness, rather than Leaf, names the turn. |
lifetime | object | yes | What keeps the session alive (Harness.lifetime), as service.session_lives reads it: nothing yet, the process, a background job's record, the Claude desktop app's record of the session, a desktop Codex chat's native source (transcript_path), or the App Server process an embedded session's thread runs in. |
lifetime variant 2. | |||
lifetime. | integer | yes | |
lifetime variant 3. | |||
lifetime. | integer | yes | |
lifetime variant 4. | |||
lifetime. | string | yes | |
lifetime variant 5. | |||
lifetime. | string | yes | |
lifetime when chat is true. | |||
lifetime. | true | yes | |
transcript_path | string | The native chat a desktop Codex lifetime stands on (chat_exists). | |
session-runtime
One harness session's hook and runtime observations, in the state home's sessions/<digest>.runtime (session_file): whether its hooks ran in this instance, the Leaf root its hooks last ran, the harness process its hooks module last ran in, the tool calls its PreToolUse hook already handled, when its tool boundaries last checked status lines, and the pages a hook pointed its open turn at.
Stored with format leaf-session-runtime/66.
| Field | Type | Required | Description |
|---|---|---|---|
hooks | boolean | Whether the harness ran a Leaf hook in this instance. | |
root | string | The resolved root of the Leaf the session's hooks last ran. | |
module_pid | integer | The harness process PID in which the session's Leaf module last ran, or whose user Leaf told it didn't. | |
tools | array of string | Recent tool_use_ids already handled by PreToolUse. | |
status_checked_at | number | POSIX seconds when a tool boundary last checked status lines. | |
pointed | object | Pages a hook handed the open turn by pointer, with the last log position pointed at per page. | |
pointed. | string | yes | |
pointed. | string | yes | |
pointed. | map of integer | yes |
user-views
The user's browser views of a page, in the page directory's user-views.json.
Stored with format leaf-user-views/47.
| Field | Type | Required | Description |
|---|---|---|---|
sessions | map of object | yes | Each document's latest report, by its session id. |
sessions. | object | yes | The rendering identity captured by this document. |
sessions. | object | yes | |
sessions. | string | yes | |
sessions. | boolean | yes | |
sessions. | string | yes | The document's random session id. |
sessions. | integer | yes | The report's place among its session's reports. |
sessions. | boolean | yes | Whether the document was visible. |
sessions. | integer | yes | The revision the document shows. |
sessions. | integer or null | yes | The log position the tab's latest server reading was taken through, or null before one arrives. |
sessions. | object | yes | The layout viewport, in CSS pixels. |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | object | yes | The visual viewport, as window.visualViewport reports it. |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | object | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | "light" | "dark" | yes | The scheme the document is drawn in. |
sessions. | boolean | yes | Whether the user prefers reduced motion. |
sessions. | "coarse" | "fine" | yes | Whether the primary pointer is coarse, as a finger is, or fine. |
sessions. | object | yes | The document's scroll offset. |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | array of string | yes | |
sessions. | object or null | yes | The document's latest view checks, with the revision, log position, viewport and scheme they read, or null. |
sessions. | integer | yes | |
sessions. | object | yes | |
sessions. | object | yes | |
sessions. | string | yes | |
sessions. | boolean | yes | |
sessions. | integer | yes | |
sessions. | integer or null | yes | |
sessions. | object | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | object | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | object | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | number | yes | |
sessions. | "light" | "dark" | yes | |
sessions. | object | yes | |
sessions. | string (date-time) | yes | When the server first received these checks. |
sessions. | string (date-time) | yes | When the server received the report. |
viewed | number | When a report last said a document was visible, in POSIX seconds (viewed_at). |
Interaction batch
The browser posts what it observed of the user's session, such as DOM
events, to the page's diagnostic trace, observations.jsonl.
Nothing in the page's state is read from it.
POST /api/interaction
A batch of browser interaction observations as both doors admit it: the local server's /api/interaction (interaction_log.admit_batch) and leaf.page's Worker, whose zod schema (interactionBatch in worker/src/interactions.ts) worker/test/interactions.test.ts holds to this one. A batch that fails is refused whole. An entry's other fields stay open: the local server keeps them as the browser sent them (runtime/transport/interaction-log.js), and the Worker keeps only the structural fields its projection declares.
| Field | Type | Required | Description |
|---|---|---|---|
session | string | yes | The tab's diagnostic session, the runtime's one random identifier (runtime/base/ids.js). |
entries | array of object | yes | The observations, each numbered by sequence. |
entries[]. | string | yes | The tab's wall clock, as Date.prototype.toISOString writes it. |
entries[]. | number | yes | The document's monotonic clock (performance.now). |
entries[]. | integer | yes | The observation's place in its session, from 1. |
entries[]. | "visible" | "hidden" | yes | The document's visibilityState when it observed the entry. |
entries[]. | string | yes | What was observed, such as a DOM event's type. |