On this page
Read-only PG query functions backing StorageReader: list_tasks, read_run_report, read_inbox, query_events, replay (cursor-paginated), query_lessons, and other lookups over the event-store tables.
#trace.src.orxtra.trace._reader
#trace.src.orxtra.trace._reader
#_inbox_record_to_dict
def _inbox_record_to_dict(record: asyncpg.Record) -> dict[str, Any]Coerce an inbox_items row for InboxItem validation.
options and tags are jsonb columns. A pool without a jsonb codec (the plain asyncpg.create_pool used in production and tests) returns them as JSON text, so parse defensively -- matching read_run_config.
#list_tasks
async def list_tasks(pool: asyncpg.Pool, run_id: UUID) -> list[TaskSummary]#read_task_attempt
async def read_task_attempt(pool: asyncpg.Pool, task_id: UUID, attempt: int) -> TaskAttempt | None#read_latest_attempt
async def read_latest_attempt(pool: asyncpg.Pool, task_id: UUID) -> TaskAttempt | None#list_iterations
async def list_iterations(pool: asyncpg.Pool, task_id: UUID) -> list[IterationResult]#read_transcript
async def read_transcript(pool: asyncpg.Pool, session_id: UUID) -> list[dict[str, Any]]#search_transcript
async def search_transcript(pool: asyncpg.Pool, session_id: UUID, query: str) -> list[dict[str, Any]]#read_run_report
async def read_run_report(pool: asyncpg.Pool, run_id: UUID) -> RunReport | None#list_runs
async def list_runs(pool: asyncpg.Pool) -> list[RunSummary]#read_inbox
async def read_inbox(pool: asyncpg.Pool, run_id: UUID, status: str | None=None) -> list[InboxItem]#read_notepad
async def read_notepad(pool: asyncpg.Pool, run_id: UUID) -> list[NotepadEntry]#read_active_constraints
async def read_active_constraints(pool: asyncpg.Pool, run_id: UUID) -> list[dict[str, Any]]Read active constraints for a run.
#read_task_attempts
async def read_task_attempts(pool: asyncpg.Pool, task_id: UUID) -> list[TaskAttempt]Read all attempts for a task, ordered by attempt number.
#query_events
async def query_events(pool: asyncpg.Pool, run_id: UUID, event_type: str | None=None, since: datetime | None=None, limit: int=100) -> list[dict[str, Any]]Query events for a run with optional filters.
#read_inbox_item
async def read_inbox_item(pool: asyncpg.Pool, item_id: UUID) -> InboxItem | NoneRead a single inbox item by ID.
#read_run_config
async def read_run_config(pool: asyncpg.Pool, run_id: UUID) -> dict[str, Any] | NoneRead the config snapshot for a run.
#read_session_token_counts
async def read_session_token_counts(pool: asyncpg.Pool, session_id: UUID) -> list[dict[str, Any]]Read token counts from transcripts for a session.
#read_session_turn_count
async def read_session_turn_count(pool: asyncpg.Pool, session_id: UUID) -> intRead the number of transcript turns for a session.
#query_relevant_lessons
async def query_relevant_lessons(pool: asyncpg.Pool, tags: list[str]) -> list[dict[str, Any]]Query lessons matching any of the given relevance tags.
#read_decisions
async def read_decisions(pool: asyncpg.Pool, run_id: UUID, limit: int=10) -> list[dict[str, Any]]Read decisions for a run, newest first.
#read_constraints
async def read_constraints(pool: asyncpg.Pool, run_id: UUID, active_only: bool=True) -> list[dict[str, Any]]Read constraints for a run, optionally filtered to active only.
#read_assumptions
async def read_assumptions(pool: asyncpg.Pool, run_id: UUID, status: str | None=None) -> list[dict[str, Any]]Read assumptions for a run, optionally filtered by status.
#query_lessons
async def query_lessons(pool: asyncpg.Pool, run_id: UUID | None=None, tags: list[str] | None=None, permanent_only: bool=False) -> list[dict[str, Any]]Query lessons with optional filters.
#read_workflow_status
async def read_workflow_status(pool: asyncpg.Pool, workflow_id: UUID) -> dict[str, Any] | NoneRead overseer workflow status for a workflow.
#read_event
async def read_event(pool: asyncpg.Pool, event_id: UUID) -> dict[str, Any] | NoneRead a single event by its ID.
Returns the event as a dict, or None if not found.
#replay
async def replay(pool: asyncpg.Pool, *, event_types: list[str] | None=None, principal_id: UUID | None=None, since_id: UUID | None=None, limit: int=1000) -> list[dict[str, Any]]Replay events with optional filters and cursor-based pagination.
Uses since_id (UUIDv7, time-ordered) as cursor for monotonic pagination.