Skip to main content

av_atif/
lib.rs

1//! ATIF — Agent Trajectory Interchange Format (Harbor), version 1.7.
2//!
3//! Verified against the published specification at
4//! harborframework.com/docs/agents/trajectory-format (2026-08-10):
5//!
6//! - root `Trajectory` with `schema_version`, optional run-scoped `session_id`
7//!   (relaxed in v1.7), `trajectory_id` + `subagent_trajectories` (v1.7),
8//!   `agent`, ordered `steps`, `final_metrics`, `extra` (v1.1);
9//! - `Step.step_id` sequential from 1; `source` ∈ {system, user, agent};
10//!   agent-only fields (`reasoning_content`, `reasoning_effort`, `model_name`,
11//!   `tool_calls`, `metrics`) rejected on non-agent steps; `observation`
12//!   allowed on agent steps and, since v1.2, system steps; `llm_call_count`
13//!   (v1.7) allowed on any step;
14//! - `Metrics` carries `prompt_tokens` / `completion_tokens` / `cached_tokens`
15//!   / `cost_usd` (+ `logprobs`, `completion_token_ids` v1.3,
16//!   `prompt_token_ids` v1.4) — the cached-token preservation that makes an
17//!   exported trajectory a replayable KV-cache checkpoint (brief Module H);
18//! - validator collects errors in one pass (Harbor philosophy), not just the
19//!   first — capped at `MAX_VALIDATION_ISSUES` with a truncation notice.
20//!
21//! Reader accepts every published version v1.0–v1.7 with per-version field
22//! gating; the writer always emits v1.7 (inbound tolerant, outbound strict).
23
24pub mod model;
25pub mod validate;
26pub mod writer;
27
28pub use model::{
29    Agent, FinalMetrics, Metrics, Observation, ObservationResult, ReasoningEffort, Source, Step,
30    SubagentTrajectoryRef, ToolCall, Trajectory, ATIF_VERSION, SUPPORTED_VERSIONS,
31};
32pub use validate::{validate_bytes, validate_trajectory, validate_value, Mode, ValidationIssue};
33pub use writer::{write_atomic, TrajectoryBuilder};