Skip to main content

contextgraph_trace/
lib.rs

1//! `contextgraph-trace` — the host execution trace (journal) and its replay
2//! oracles.
3//!
4//! **Sketch stage.** This crate implements
5//! [`docs/sketches/host-trace.md`]. It is published so downstream hosts can
6//! depend on the trace vocabulary by version instead of by git rev, but
7//! nothing here is part of the `contextgraph/1.0` surface: the journal wire
8//! format may change in any `0.x` release. Gate on [`TRACE_FORMAT`], not on
9//! the crate version. It exists so the shape can be exercised against real
10//! journals before any of it is proposed for the spec.
11//!
12//! [`docs/sketches/host-trace.md`]: https://github.com/macanderson/context-graph-protocol/blob/main/docs/sketches/host-trace.md
13//!
14//! The conformance suite holds a *provider* honest; nothing holds the
15//! host-side agent loop honest. This crate is that missing half, split the
16//! same way the rest of the protocol is:
17//!
18//! - **The journal** ([`TraceEvent`], [`Journal`]) — an append-only NDJSON
19//!   recording a harness (or a thin adapter observing one) emits while it
20//!   works: turns, prompt assemblies, tool-call pairing, verify observations,
21//!   side effects, crashes and resumes. It reuses the protocol's identity
22//!   spine — frames are named by [`FrameId`](contextgraph_types::FrameId),
23//!   verify observations carry the wire
24//!   [`Verdict`](contextgraph_types::Verdict) — and **no frame body ever
25//!   travels in it**.
26//! - **The oracles** ([`run_oracles`]) — pure replay checks over a parsed
27//!   journal, in the conformance suite's vocabulary: named checks,
28//!   pass/fail/skip, evidence naming the exact `seq` numbers. They catch the
29//!   defects an outcome-graded benchmark structurally cannot see: citing
30//!   evidence verified stale, budget arithmetic drifting from the
31//!   itemization, phantom tool executions, side effects replayed across a
32//!   crash-resume, resumes blind to their own durable record.
33//!
34//! The oracles never talk to the harness — they read the journal. That split
35//! is what makes an eventual benchmark runner agent-agnostic: one adapter per
36//! harness maps its native logs onto this vocabulary, and every check
37//! downstream is shared.
38//!
39//! Depends on `contextgraph-types` and serde only, so the oracles stay
40//! runnable anywhere the journal can be read.
41
42mod event;
43mod journal;
44mod oracle;
45mod report;
46
47pub use event::{EventBody, RenderedFrame, SessionOutcome, TRACE_FORMAT, ToolStatus, TraceEvent};
48pub use journal::{Journal, JournalError};
49pub use oracle::{
50    ALL_CHECKS, CHECK_ASSEMBLY_BUDGET, CHECK_CITATION, CHECK_COMPOSITION, CHECK_EFFECT_ONCE,
51    CHECK_RESUME, CHECK_SEQUENCE, CHECK_STALENESS, CHECK_TURN_LOOP, check_assembly_budget_honesty,
52    check_citation_at_use, check_deterministic_composition, check_effect_exactly_once,
53    check_resume_integrity, check_sequence_integrity, check_staleness_at_use,
54    check_turn_loop_pairing, run_oracles,
55};
56pub use report::{CheckResult, CheckStatus, TraceReport};