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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! [`SeamHost`] — engine boundary for the Flash seam manager (issue
//! #159 layered-context pipeline).
//!
//! M5 (Engine-struct strangler step) introduces this host trait so the
//! future core-side `Engine` struct (M7) can hold `Option<Box<dyn
//! SeamHost>>` without taking a tui dependency on
//! `crates/tui/src/seam_manager.rs` (712 LOC).
//!
//! ## Call-graph (R1)
//!
//! Method surface derived from the live `Engine`'s direct calls on the
//! `seam_manager` field (M5 R1 mitigation — strictly call-graph
//! driven, **not** a dump of `SeamManager`'s public API):
//!
//! | Method | Call site |
//! |---------------------------|-------------------------------------------------------------|
//! | `config_enabled` | `crates/tui/src/core/engine/layered_context.rs:15` |
//! | `highest_level` | `crates/tui/src/core/engine/layered_context.rs:19` |
//! | `seam_level_for` | `crates/tui/src/core/engine/layered_context.rs:20` |
//! | `verbatim_window_start` | `crates/tui/src/core/engine/layered_context.rs:28` |
//! | `collect_seam_texts` | `cycle_hooks.rs:56` + `layered_context.rs:47` |
//! | `produce_soft_seam` | `layered_context.rs:49-57` |
//! | `recompact` | `layered_context.rs:70-72` |
//! | `seam_count` | `layered_context.rs:87` |
//! | `produce_flash_briefing` | `cycle_hooks.rs:70-72` |
//! | `reset` | `cycle_hooks.rs:195` |
//!
//! Inherent `SeamManager` methods *not* on this trait (because Engine
//! does not call them directly):
//! - `new(client, config)` — construction is a tui-side concern
//! (depends on `LlmClient` factory).
//! - `should_cycle(active_input_tokens)` — currently dead code, kept
//! in `SeamManager` for future wiring.
//! - `summarize_messages(...)` — private helper used by
//! `produce_soft_seam` / `recompact` internally.
//!
//! ## Why `config_enabled` instead of `config(&self) -> &SeamConfig`?
//!
//! `SeamConfig` is a tui-only type (`crates/tui/src/seam_manager.rs:64`)
//! and lifting it into core would create a brand-new config dependency
//! for **one** boolean Engine reads (`.enabled`). The trait surface
//! only exposes the single bit Engine actually consumes; richer config
//! introspection (`l1_threshold`, `seam_model`, …) stays inside the
//! tui-side `SeamManager` and feeds the other trait methods (e.g.
//! `seam_level_for`) directly.
use Path;
use async_trait;
use crateMessage;
/// Opaque error from a seam operation.
///
/// Boxed `dyn Error` keeps the trait surface free of tui-side error
/// hierarchies (`anyhow::Error`, `reqwest::Error`, `LlmClientError`,
/// `serde_json::Error`). Call sites already format errors via
/// `format!("{err}")` for status events (`cycle_hooks.rs:75-100`,
/// `layered_context.rs:62, 76`); the `Display` blanket of `dyn Error`
/// preserves the existing log shape.
pub type SeamError = ;
/// Engine-side Flash seam host.
///
/// Implemented by `crates/tui/src/seam_manager.rs`'s `SeamManager`
/// (M5 inline `impl SeamHost`). All ten methods are thin UFCS
/// delegations to the existing inherent methods on `SeamManager` — M5
/// adds zero behavior, only the trait surface.