donna.memory.observers¶
donna.memory.observers
¶
Module-level observer registry for the memory ingest pipeline.
Slice 14 chose a hybrid wiring (brief §6):
- :class:
donna.tasks.database.Databaseaccepts amemory_observerin its constructor (Option A) — the DB already takes a handful of collaborators, so one more pointer is fine and the call sites stay exact. - :mod:
donna.preferences.correction_loggeris a loose module-level function. Threading an observer through everylog_correctioncaller would widen the public surface and churn unrelated call sites. Instead, the logger looks up a registered callback here and fires it best-effort — exactly what :func:register_observer/ :func:dispatchdo.
All callbacks must be coroutine functions; failures are swallowed and
logged (:func:structlog.warning with memory_ingest_failed), never
propagated to the caller. This matches the source modules'
fire-and-forget contract.
register_observer
¶
unregister_all
¶
Drop registered observers (for test isolation).
dispatch
async
¶
Dispatch event to every registered observer.
Awaited by the caller but exceptions per observer are swallowed
(logged as memory_ingest_failed). The source-of-truth write
has already committed by the time dispatch runs, and failure in
the memory pipeline must never unwind the caller.