See who did what
Every write records its actor: the credential that made it. When the caller says so, it also records the program or agent behind it, its model and its session. The journal, the history and the change feed show it. You can tell who changed what and undo one agent’s work without touching the rest.
What the actor records
Section titled “What the actor records”The actor has these fields:
auth: the credential,owneror the name of a named token. The engine sets it, and no header can claim itharnessandharness_version: the program or MCP client, such asclaude-codemodel: the model behind an agentsession: the agent’s sessiontool: the tool the agent called
A program sends the other fields with the X-Datanotes-Actor header, or the client’s actor option. Record who makes each write shows how. datanotes mcp fills them from the MCP connection, as Every write names the agent that made it explains.
See which token made a change
Section titled “See which token made a change”Every write records the credential as auth in its actor: owner, or the token’s name. When a program forwards an agent’s X-Datanotes-Actor header, the engine records both, as “harness / model via token”. A program that writes for itself, without the header, appears under its token’s name.
list_migrations shows this name in the by field of each change, and the whole actor in actor. list_changes shows the whole actor too.
Report what an agent does
Section titled “Report what an agent does”A program that serves its own Model Context Protocol (MCP) server can report its agents to the engine. Any token can do it:
POST /datanotes/sessions/identify/: names the model and harness behind an agent’s session. Later writes that carry the session inX-Datanotes-Actorrecord themPOST /datanotes/tool-calls/record/: records a tool call on the change feed, withserved_bynaming who served it
Tool calls appear on the change feed as events with kind: "tool_call". The engine sends them only to consumers that ask for that kind. The call field holds tool, ok, served_by, duration_ms, summary and session. It also holds the arguments, cut at 300 characters, and the value, cut at 1,000. The result’s size is in result_chars and result_tokens.
A large result costs less to report when the program cuts it first. The engine answers takes_summary: true when it accepts a cut call. Then send the value cut at 1,000 characters, and the result’s summary next to it. The event is the same as for the whole call. datanotes mcp does this after its first report.
A session belongs to one token
Section titled “A session belongs to one token”The first token that reports a session owns it. Both routes count as a report. After that, only that token and the owner can report the session. Another named token gets a 403 error, and the engine stores nothing. So no token can rename another agent’s model or add tool calls to its session.
Give each agent session its own id, such as a new UUID. The engine compares the first 16 characters of the id, so make them unique. When one program serves agents with several tokens, give each token its own sessions.
The engine keeps the owners of the last 2,000 sessions in memory, and forgets them when it restarts.
Read who did what
Section titled “Read who did what”Three operations read the record:
list_migrations: the journal, newest first, each write withby, the actor’s name, andactordescribe_history: the commits of one table or of every table, with the full actor; it needs history onlist_changes: every change with its actor, and withkinds: ["tool_call"]every tool call an MCP server reported
restore_database with before_migration brings every table back to the moment before an agent’s first write. Restore a table or the database shows how.
List the agent sessions
Section titled “List the agent sessions”The owner can list the agent sessions that used each credential. Call POST /datanotes/sessions/:
curl -X POST http://127.0.0.1:27150/datanotes/sessions/ \ -H "Authorization: Bearer your_owner_token" \ -H "Content-Type: application/json" \ -d '{"token": "cook", "limit": 20}'The body takes three optional fields:
token: only this credential,owneror a token’s namesince: the earliest event to look at, as an ISO date-time; 7 days ago by defaultlimit: the most sessions to return, 100 by default and 1,000 at most
The engine reads the sessions from the change feed, the most recent first. Each session has these fields:
tokenandsession: the credential and the session id. Work without a session is one entry withsession: null.harnessandmodel: what the agent reported about itselffirst_at,last_at,first_seqandlast_seq: when the session started and ended, and its place in the feedtool_call_countandfailed_tool_call_count: its tool calls, and how many of them failedrow_change_countandmigration_count: the rows it changed, and its distinct journal operationstablesandtools: the tables it wrote, and its tools by number of calls
Hand edits and background work have no credential, so the list leaves them out. A named token gets 403, even with maintain.
To see what one session did, filter the change feed and the journal:
list_changestakesauth, a credential, andsession, compared on its first 16 characters. Addkinds: ["tool_call"]for its tool calls.list_migrationsanswers each write’sactor, and takesauthto keep one credential’s writes.beforepages back: pass theexecuted_atof the oldest entry you read.
The database browser shows these sessions on its Users and sessions screen.