Skip to main content

Module write_hook

Module write_hook 

Source
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 (the before_write event still gets matcher coverage for audit; the chunk just doesn’t land in memory_chunks). Used to honor redact_memory rules.
  • 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§

ClosureHook
Convenience wrapper for callers that want to plug a closure in without declaring a struct. Useful for tests, examples, and small policy adapters.

Enums§

WriteDecision
What a MemoryWriteHook tells the provider to do with an incoming chunk.

Traits§

MemoryWriteHook
The hook providers consult before persisting a chunk.