pub enum TranscriptMessage {
System {
id: String,
created_at: String,
content: String,
pinned: bool,
},
User {
id: String,
created_at: String,
content: String,
trust: Option<TrustEnvelope>,
pinned: bool,
attachments: Vec<ReferenceMeta>,
},
Assistant {
id: String,
created_at: String,
content: String,
reasoning_content: Option<String>,
tool_calls: Vec<ToolCall>,
pinned: bool,
},
Tool {
id: String,
created_at: String,
tool_call_id: String,
summary: String,
output: Option<OutputRef>,
trust: Option<TrustEnvelope>,
is_error: bool,
pinned: bool,
process_id: Option<String>,
},
Compact {
id: String,
created_at: String,
summary: String,
dropped_count: i32,
pinned: bool,
},
Fold {
id: String,
created_at: String,
subtask_id: String,
summary: String,
dropped_count: i32,
archive_ref: String,
pinned: bool,
},
}Expand description
A transcript entry. Discriminated union over the conversation roles plus the compaction boundary
marker. Reasoning content is a normalized channel on Assistant — never folded into ordinary
content, because per-provider re-feed rules differ (DeepSeek forbids re-feeding CoT; Kimi
requires echoing it in tool-call turns).
Variants§
System
User
Fields
trust: Option<TrustEnvelope>attachments: Vec<ReferenceMeta>D2 — typed, persisted references attached to this user turn.
Metadata-only on the wire (no image bytes — those continue to
travel through the legacy Attachment channel). serde-default
- skip-when-empty keeps every pre-D2 transcript row wire- compatible: rows written before D2 deserialize into an empty vec, rows written after D2 skip the key when no references are attached (so an empty user turn still serializes to the legacy 5-field shape).
Assistant
Fields
Tool
The result of a tool call. summary is the compact transcript line; the full (possibly
large) payload is referenced by output and kept out of context.
Fields
trust: Option<TrustEnvelope>Compact
A compaction/tombstone boundary (G7). Marks where older turns were summarized and dropped. Visible in the transcript — compaction is never silent.
Fold
A context-fold boundary. Marks where a subtask’s sub-trajectory was folded into
a summary. The full sub-trajectory is archived to disk and retrievable via archive_ref.
Structural (per-subtask), complementary to the 70% emergency compactor.
Implementations§
Source§impl TranscriptMessage
impl TranscriptMessage
Sourcepub fn set_id(&mut self, value: String)
pub fn set_id(&mut self, value: String)
Rewrite the message id. Used at the storage boundary to migrate legacy
constant IDs (tr, final, etc.) to the row-derived canonical form
and by the live engine when a re-emitted assistant completion
disagrees with the persisted row sequence.
Sourcepub fn created_at(&self) -> &str
pub fn created_at(&self) -> &str
Created-at timestamp; same regardless of variant.
Sourcepub fn user(
id: impl Into<String>,
created_at: impl Into<String>,
content: impl Into<String>,
trust: Option<TrustEnvelope>,
pinned: bool,
) -> Self
pub fn user( id: impl Into<String>, created_at: impl Into<String>, content: impl Into<String>, trust: Option<TrustEnvelope>, pinned: bool, ) -> Self
Canonical constructor for a User transcript row. Defaults
attachments to empty so the many call sites that don’t carry
references don’t have to spell out the field. Callers that DO
attach references should use TranscriptMessage::user_with_attachments.
Sourcepub fn user_with_attachments(
id: impl Into<String>,
created_at: impl Into<String>,
content: impl Into<String>,
trust: Option<TrustEnvelope>,
pinned: bool,
attachments: Vec<ReferenceMeta>,
) -> Self
pub fn user_with_attachments( id: impl Into<String>, created_at: impl Into<String>, content: impl Into<String>, trust: Option<TrustEnvelope>, pinned: bool, attachments: Vec<ReferenceMeta>, ) -> Self
Canonical constructor for a User transcript row that carries typed
D2 references. Use this at the canonical write path (transcript.rs)
and the message-submission entry point (api_sessions.rs); all other
call sites should use TranscriptMessage::user.
pub fn is_provider_visible(&self) -> bool
Sourcepub fn user_attachments(&self) -> &[ReferenceMeta]
pub fn user_attachments(&self) -> &[ReferenceMeta]
Borrow the user-row attachments (empty vec for any non-user variant).
Used by the persistence layer to round-trip references across
write / read boundaries without coupling to .. destructure shape.
Sourcepub fn into_user_attachments(self) -> Vec<ReferenceMeta>
pub fn into_user_attachments(self) -> Vec<ReferenceMeta>
Owned copy of the user-row attachments (empty vec for any non-user variant). Useful at submission time when the row needs to forward attachments to a downstream consumer.