pub struct CompactionAuditSink { /* private fields */ }Expand description
Async bounded-mpsc audit sink for compaction records.
The sink serialises CompactedPageRecord values to a JSONL file via a
background writer task, mirroring the zeph-tools audit pattern. Dropped
records (when the channel is full) are counted and logged.
§Invariant
The sink MUST be flushed (all pending records written) before the compacted
context is passed to the LLM. Callers use CompactionAuditSink::flush to
ensure this.
§Examples
use zeph_context::typed_page::CompactionAuditSink;
use std::path::Path;
let sink = CompactionAuditSink::open(Path::new(".local/audit/compaction.jsonl"), 256)
.await
.unwrap();Implementations§
Source§impl CompactionAuditSink
impl CompactionAuditSink
Sourcepub async fn open(path: &Path, capacity: usize) -> Result<Self, Error>
pub async fn open(path: &Path, capacity: usize) -> Result<Self, Error>
Open a new audit sink writing to path.
capacity is the bounded channel depth; records dropped when full are counted
in the internal drop counter and logged at WARN.
§Errors
Returns an error when path cannot be opened for appending.
Sourcepub fn send(&self, record: CompactedPageRecord)
pub fn send(&self, record: CompactedPageRecord)
Send a record to the audit sink.
If the channel is full the record is dropped and the drop counter is incremented.
Sourcepub async fn flush(&self)
pub async fn flush(&self)
Flush all pending records by sending a sentinel and waiting for the writer task to drain. This uses a one-shot pair through the same channel ordering.
The implementation closes a clone’s sender so the channel drains; callers that need precise “before-LLM” semantics should call this before constructing the LLM request.
§Note
In the current bounded-mpsc design, flush is a best-effort operation: records
already accepted into the channel will be written, but there is no synchronous
confirmation from the writer task. The audit invariant is therefore best-effort,
not strict. A future revision may use a rendezvous channel for strict flush.
Sourcepub fn dropped_count(&self) -> u64
pub fn dropped_count(&self) -> u64
Number of records dropped due to a full channel.
Trait Implementations§
Source§impl Clone for CompactionAuditSink
impl Clone for CompactionAuditSink
Source§fn clone(&self) -> CompactionAuditSink
fn clone(&self) -> CompactionAuditSink
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CompactionAuditSink
impl RefUnwindSafe for CompactionAuditSink
impl Send for CompactionAuditSink
impl Sync for CompactionAuditSink
impl Unpin for CompactionAuditSink
impl UnsafeUnpin for CompactionAuditSink
impl UnwindSafe for CompactionAuditSink
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request