1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! [`TopicMemoryHost`] — engine boundary for the topic-memory graph
//! integration (`B2` system-prompt injection).
//!
//! M5 (Engine-struct strangler step) introduces this host trait so the
//! future core-side `Engine` struct (M7) can hold `Box<dyn
//! TopicMemoryHost>` without taking a tui dependency on
//! `crates/tui/src/topic_memory.rs` (307 LOC) or transitively on the
//! `zagens-topic-memory` workspace crate (spike R9 — prefer
//! adapter-tui-side option (a) over crate dep option (b)).
//!
//! ## Call-graph (R1)
//!
//! Method surface derived from the live `Engine`'s direct calls on the
//! `topic_memory_runtime` field:
//!
//! | Method | Call site |
//! |-------------------|------------------------------------------------------------------------------------|
//! | `compose_block` | `crates/tui/src/core/engine/cycle_hooks.rs:243` (in `refresh_system_prompt_with_arbitration`) |
//! | `on_turn_complete`| `crates/tui/src/core/engine/message_handlers.rs:277` |
//!
//! ## Why no `settings` parameter?
//!
//! `TopicMemorySettings` is a tui-side type wrapping
//! `zagens-topic-memory` defaults. Passing `&TopicMemorySettings`
//! through the trait would force this core module to either depend on
//! that crate (spike R9 option (b), rejected) or define a parallel
//! settings struct (premature core-side leakage).
//!
//! M5 instead moves settings **into the implementation**:
//! `TopicMemoryRuntime` gains an owned `TopicMemorySettings` field at
//! construction (`TopicMemoryRuntime::new(settings)`) so the trait
//! methods see settings via `self`. Settings hot-reload is not
//! currently supported (no slash command updates it), so single-shot
//! ownership at engine init is sufficient.
/// Engine-side topic-memory host.
///
/// Implemented by `crates/tui/src/topic_memory.rs`'s
/// `TopicMemoryRuntime`, which owns its `TopicMemorySettings` and
/// runs-since-last-inject counter.