pub struct PromptLogEntry {
pub timestamp: DateTime<Utc>,
pub hook_type: String,
pub injection_kind: String,
pub palace: String,
pub trigger_prompt: String,
pub injection: String,
pub injection_length: usize,
pub palace_facts_count: Option<usize>,
pub unread_messages_count: Option<usize>,
pub duration_ms: u64,
}Expand description
One enriched-prompt log entry — written as a single JSONL line.
Why: the consumer is a human running jq over a day’s worth of injections
to grade signal-vs-noise. Stable field names, RFC-3339 timestamps, and
numeric byte/duration counts keep the analysis script trivial.
What: tagged by injection_kind. palace_facts_count is filled for
prompt-context-facts; unread_messages_count for inbox-check-messages.
Both default to None so the JSON shape stays compact for entries that
only have one of the two.
Test: single_event_roundtrip writes one entry and parses it back.
Fields§
§timestamp: DateTime<Utc>RFC-3339 UTC timestamp set at the moment the entry is built.
hook_type: String"UserPromptSubmit" or "SessionStart".
injection_kind: String"prompt-context-facts" or "inbox-check-messages".
palace: StringPalace id the injection was scoped to.
trigger_prompt: StringHook stdin verbatim; replaced with "sha256:<hex>" when
hash_prompts = true in the active config.
injection: StringHook stdout (the actual injection sent to Claude Code) verbatim.
injection_length: usizeByte length of injection.
palace_facts_count: Option<usize>Number of facts in the prompt-context injection, when applicable.
unread_messages_count: Option<usize>Number of unread messages in the inbox-check injection, when applicable.
duration_ms: u64Wall-clock duration of the invocation, in milliseconds.
Implementations§
Source§impl PromptLogEntry
impl PromptLogEntry
Sourcepub fn new(
hook_type: impl Into<String>,
injection_kind: impl Into<String>,
palace: impl Into<String>,
trigger_prompt: impl Into<String>,
injection: impl Into<String>,
) -> Self
pub fn new( hook_type: impl Into<String>, injection_kind: impl Into<String>, palace: impl Into<String>, trigger_prompt: impl Into<String>, injection: impl Into<String>, ) -> Self
Construct a new entry stamped with the current UTC time.
Why: the hook caller has the raw fields handy but should not carry
chrono in its imports. This helper builds an entry with timestamp
auto-populated and zero-initialised optional counts.
What: sets timestamp = Utc::now() and copies the supplied fields.
Test: single_event_roundtrip.
Sourcepub fn with_duration_ms(self, ms: u64) -> Self
pub fn with_duration_ms(self, ms: u64) -> Self
Builder: set the duration this hook invocation took.
Sourcepub fn with_palace_facts_count(self, n: usize) -> Self
pub fn with_palace_facts_count(self, n: usize) -> Self
Builder: attach the palace-facts count (prompt-context only).
Sourcepub fn with_unread_messages_count(self, n: usize) -> Self
pub fn with_unread_messages_count(self, n: usize) -> Self
Builder: attach the unread-messages count (inbox-check only).
Trait Implementations§
Source§impl Clone for PromptLogEntry
impl Clone for PromptLogEntry
Source§fn clone(&self) -> PromptLogEntry
fn clone(&self) -> PromptLogEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PromptLogEntry
impl Debug for PromptLogEntry
Source§impl<'de> Deserialize<'de> for PromptLogEntry
impl<'de> Deserialize<'de> for PromptLogEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PromptLogEntry
impl RefUnwindSafe for PromptLogEntry
impl Send for PromptLogEntry
impl Sync for PromptLogEntry
impl Unpin for PromptLogEntry
impl UnsafeUnpin for PromptLogEntry
impl UnwindSafe for PromptLogEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more