Skip to main content
rootsign.init() configures one agent for the whole process and builds the client that stores its records. Two jobs need more control: recording for several agents from one process, and writing records inside a database transaction you own. For both, pass the agent’s ID and an ingest client to rootsign.session() yourself. Everything inside the session, @rootsign.trace() and wrap_tools() included, then uses them. This page uses the PostgreSQL backend. Arguments you pass always win over init(). A session given both agent_id= and client= needs no init() at all.

Record for several agents in one process

1

Register each agent once

register_agent() stores an agent and returns it. Registration is a one-time setup step, so run it once and keep the IDs. This script saves them to agents.json:
register.py
Running it again does not register the agents twice. It stops with an error that gives the ID you already have:
2

Open a session per agent

Pass each agent’s ID, and a client, to rootsign.session(). ManagedLocalIngestClient is the client init() uses on PostgreSQL: it commits each record as it is written.
agents.py
3

Verify each session

An agent ID the store does not know is refused, and the session does not open:
The clear errors for registering an agent twice and for an unknown agent ID were added after RootSign 0.3.1. In 0.3.1 and earlier, a second register_agent() failed with a raw IntegrityError, and a session for an unknown agent ran with every record refused.

Write records inside your own transaction

LocalIngestClient(db=...) writes into an AsyncSession you own, and you decide when to commit:
own_transaction.py
Three rules follow from owning the transaction:
  • Nothing is visible until you commit. Another connection, rootsign verify included, sees no records from the session until then.
  • A rollback discards the whole session. Roll back instead of committing, and rootsign verify <session_id> prints Error: no session <session_id> in the database and exits 3.
  • Calls cannot be held for approval. A held call’s pending record would stay uncommitted, so nobody could see it to approve it. require_approval=True with this client raises HiTLUnsupportedBackendError before anything is written. Use ManagedLocalIngestClient for held calls.
The approval error with your own transaction was added after RootSign 0.3.1. In 0.3.1 and earlier, the held call waited for an approval nobody could see, then failed with ActionNotFoundError.

Which client to use

Python API

session(), its arguments and what it raises.

Run on PostgreSQL

Start the database, create the tables and switch the backend.