Expand description
The MemoryWriteHook trait — the per-write governance seam.
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.
The daemon wires a hook backed by the rule matcher: it synthesises a
MemoryWriteAttempted event from the chunk’s kind, source, caller, and
content prefix, runs the rule matcher over it, and returns the
appropriate decision based on what fired (Veto → Redact; LogOnly → Allow
but record the fire).
Without a hook, providers persist every write — the v1 default for tests and for daemons that haven’t wired the rule matcher path yet.
Structs§
- Closure
Hook - Convenience wrapper for callers that want to plug a closure in without declaring a struct. Useful for tests and for the daemon’s adapter that wraps the rule matcher.
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.