Done the way the owner asked and the spike mapped: the crate and the manifests renamed, then what the build reported fixed. Layers: 138 "proto unresolved" errors across 169 files; cargo fmt reordering imports; six fixture paths built as strings in brokerd's and bxctl's tests, which the compiler cannot see, and comments naming crates/proto/; the crate-dependency check and its self-test. One more the spike did not reach: a `\nproto =` key inside a printf format in the self-test, which a word-boundary replacement skips because `n` and `p` are both word characters. make gate: gate: ok, 944 tests; no new entry in /tmp. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
75 lines
1.9 KiB
Rust
75 lines
1.9 KiB
Rust
//! Session log record types. One JSON object per line; assistant messages are stored verbatim.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{CallId, DataClass, Epoch, Hash32, SessionId, Timestamp};
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ToolCall {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub arguments: String,
|
|
}
|
|
|
|
/// What one completion cost. The same five numbers as `LogRecord::Usage`, without the time.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct Usage {
|
|
pub cache_n: u64,
|
|
pub prompt_n: u64,
|
|
pub predicted_n: u64,
|
|
pub reasoning_tokens: u64,
|
|
pub thinking_capped: bool,
|
|
}
|
|
|
|
// JSON: {"type":"user","time":"…","content":"…"} ; the tag sits beside the fields; types are snake_case
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case", deny_unknown_fields)]
|
|
pub enum LogRecord {
|
|
SessionStart {
|
|
time: Timestamp,
|
|
session: SessionId,
|
|
epoch: Epoch,
|
|
slot: u32,
|
|
baseline: Hash32,
|
|
},
|
|
User {
|
|
time: Timestamp,
|
|
content: String,
|
|
},
|
|
Assistant {
|
|
time: Timestamp,
|
|
content: Option<String>,
|
|
reasoning_content: Option<String>,
|
|
tool_calls: Vec<ToolCall>,
|
|
},
|
|
ToolResult {
|
|
time: Timestamp,
|
|
call: CallId,
|
|
tool_call_id: String,
|
|
content: String,
|
|
class: DataClass,
|
|
untrusted: bool,
|
|
truncated: bool,
|
|
},
|
|
Usage {
|
|
time: Timestamp,
|
|
cache_n: u64,
|
|
prompt_n: u64,
|
|
predicted_n: u64,
|
|
reasoning_tokens: u64,
|
|
thinking_capped: bool,
|
|
},
|
|
CacheLoss {
|
|
time: Timestamp,
|
|
expected: u64,
|
|
got: u64,
|
|
},
|
|
EpochEnd {
|
|
time: Timestamp,
|
|
next: Epoch,
|
|
summary: String,
|
|
},
|
|
}
|