Expand description
The MemoryWriteHook trait — per-write governance for memory backends.
Memory writes are themselves governable events. Before a provider
persists a chunk, it calls MemoryWriteHook::before_write(chunk). The
hook can:
- return
Ok(WriteDecision::Allow)— the provider persists the chunk verbatim. - return
Ok(WriteDecision::Redact { reason })— the provider drops the chunk silently (thebefore_writeevent still gets matcher coverage for audit; the chunk just doesn’t land inmemory_chunks). Used to honorredact_memoryrules. - return
Err(_)— the write surfaces as a hard error to the caller.
A production runtime can wire this to any policy engine: synthesize an event from the chunk’s kind, source, caller, and content, then return the appropriate decision. Without a hook, providers persist every write.
Structs§
- Closure
Hook - Convenience wrapper for callers that want to plug a closure in without declaring a struct. Useful for tests, examples, and small policy adapters.
Enums§
- Write
Decision - What a
MemoryWriteHooktells the provider to do with an incoming chunk.
Traits§
- Memory
Write Hook - The hook providers consult before persisting a chunk.