This document defines the canonical run-history model in Codex Autorunner.
Use FlowStore at .codex-autorunner/flows.db as the single source of truth
for flow-engine run history. This store proves what the ticket-flow engine ran;
it does not by itself make a turn visible in Web Hub Chats.
- Runs:
flow_runs - Timeline/events:
flow_events - Artifacts:
flow_artifacts
Legacy numeric run directories are compatibility-only and must not be used for new run history features.
Web Hub chat visibility is sourced from hub orchestration records:
orch_thread_targets, orch_thread_executions, bindings, delivery ledgers,
and chat-surface events. A ticket-flow turn is visible only when orchestration
contains a repairable flow_run_id + ticket_id -> managed_thread_id link.
Retirement snapshots under .codex-autorunner/archive/runs/** are
reviewable retained output, not live source of truth. They exist for
operator review and audit after a run completes. Do not query archive storage
directories to discover which runs exist; always use FlowStore.
Run retirement snapshots are pruned by age/count/byte retention policies (see STATE_ROOTS.md and state-cleanup.md).
Use FlowStore run records:
- Open FlowStore for the repo.
- Query
list_flow_runs(...)(optionally byflow_typeor status). - Treat each
FlowRunRecord.id(string) as the canonical run id.
Primary fields:
idflow_typestatuscreated_at,started_at,finished_atcurrent_stepmetadata
Use FlowStore events:
- Query
get_events(run_id, ...). - Sort/order by
seq(monotonic per DB). - Render timeline using
timestamp,event_type,data, and optionalstep_id.
For streaming/polling use cases, use after_seq and event-type filters (get_events_by_type(s)).
Use FlowStore artifacts:
- Query
get_artifacts(run_id). - Resolve each artifact by
kind,path,created_at, andmetadata. pathmay be absolute or repo-relative; resolve against repo root before reading.
Artifact discovery must come from flow_artifacts first. Filesystem scanning is fallback-only for legacy compatibility paths.
When flow-chat mirroring is enabled, flow_artifacts may include:
chat_inbound- points to.codex-autorunner/flows/<run_id>/chat/inbound.jsonlchat_outbound- points to.codex-autorunner/flows/<run_id>/chat/outbound.jsonl
- Legacy numeric run logs (
.codex-autorunner/runs/<int>/run.log) are deprecated and not canonical for new runs. - Legacy
run_indexstorage/APIs have been removed from runtime code paths.
Hub usage summaries attribute token events to repos using a two-tier matcher:
- Exact path match (high confidence): the event's
cwdis the repo root or a subdirectory of it. - Heuristic name match (low confidence): the event's
cwdcontains a path component matchingrepo-id--*, which is the conventional worktree naming pattern. This match is name-based and may misattribute usage when non-worktree directories follow the same convention.
Both matched and unmatched usage is always visible in hub summaries. The
source_confidence field in each UsageSummary distinguishes the two tiers:
confidence: "high"— all events matched by exact path.confidence: "low"— all events matched by heuristic only.confidence: "mixed"— a combination of exact and heuristic matches.confidence: "none"— no events.
The heuristic_events count in the confidence dict reports how many events
were attributed via heuristic matching. Operators can use this to assess
attribution quality and decide whether stronger bindings are needed.
Events that match no known repo remain in the unmatched bucket rather than
being silently forced into a repo attribution. This is a contract: usage
reports must never silently upgrade an unmatched or heuristic-only event into
an authoritative attribution.