Add audit and session log record types to proto
Implemented-By: Laguna S 2.1 (OpenCode)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
//! Audit log record types. One JSON object per line, hash-chained by the exact bytes of each line.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{CallId, DataClass, DenyReason, Hash32, SessionId, Timestamp};
|
||||
|
||||
// JSON: {"outcome":"allowed","grant":"…"} ; the tag sits beside the fields; outcomes are snake_case
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "outcome", rename_all = "snake_case", deny_unknown_fields)]
|
||||
pub enum DecisionRecord {
|
||||
Allowed {
|
||||
grant: String,
|
||||
},
|
||||
Approved {
|
||||
grant: String,
|
||||
approver: String,
|
||||
post: Option<String>,
|
||||
},
|
||||
Denied {
|
||||
reason: DenyReason,
|
||||
grant: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct AuditRecord {
|
||||
pub seq: u64,
|
||||
pub time: Timestamp,
|
||||
pub prev: Hash32,
|
||||
pub session: SessionId,
|
||||
pub call: CallId,
|
||||
pub tool: String,
|
||||
pub arguments: String,
|
||||
pub session_taint: DataClass,
|
||||
pub decision: DecisionRecord,
|
||||
}
|
||||
@@ -1,15 +1,19 @@
|
||||
//! Shared data types and the frame codec for Boxmaker. No policy and no I/O beyond frames.
|
||||
|
||||
pub mod audit;
|
||||
pub mod class;
|
||||
pub mod frame;
|
||||
pub mod grant;
|
||||
pub mod ids;
|
||||
pub mod log;
|
||||
pub mod wire;
|
||||
|
||||
pub use audit::{AuditRecord, DecisionRecord};
|
||||
pub use class::DataClass;
|
||||
pub use frame::{FrameError, MAX_FRAME, read_frame, write_frame};
|
||||
pub use grant::{Constraints, Grant, Mode};
|
||||
pub use ids::{CallId, Epoch, Hash32, SessionId, Timestamp, ValueError};
|
||||
pub use log::{LogRecord, ToolCall};
|
||||
pub use wire::{
|
||||
DenyReason, Envelope, ErrorCode, Message, PROTOCOL_VERSION, ToolRequest, ToolResponse,
|
||||
WireError,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//! 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)]
|
||||
pub struct ToolCall {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub arguments: String,
|
||||
}
|
||||
|
||||
// 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,
|
||||
},
|
||||
CacheLoss {
|
||||
time: Timestamp,
|
||||
expected: u64,
|
||||
got: u64,
|
||||
},
|
||||
EpochEnd {
|
||||
time: Timestamp,
|
||||
next: Epoch,
|
||||
summary: String,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user