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
//! TR-7 (T20): the injectable side-call that turns an A10 `TurnsCleared`
//! span into a short LLM-written summary paragraph, instead of leaving it as
//! the deterministic `[turns cleared]` stub — "what incumbents' compaction
//! writes, but with the original retained in the sidecar" (TR-7.md).
//!
//! **Purity boundary.** [`super::project_messages`] must stay pure and
//! I/O-free (its own doc comment: "nothing here touches the filesystem").
//! Exactly like A8's disk probe ([`super::probe_read_freshness`]), the one
//! side-call this feature ever makes lives OUTSIDE projection, in
//! [`super::prepare_cleared_turns_summary`] — called by the driving caller
//! (`Agent::build_request_messages`, or a test) BEFORE
//! `project`/`project_messages` ever runs, with the result threaded through
//! [`super::ReductionPolicy::cleared_turns_summary`] (data, not a config
//! knob — mirrors [`super::ReductionPolicy::read_freshness`]).
//!
//! **Never blocks, never fails the pass.** [`SpanSummarizer::summarize`]
//! returning `Err` (a real implementation's way of modeling a timeout, a
//! provider error, a budget exhaustion — whatever the caller wants) simply
//! means [`super::prepare_cleared_turns_summary`] returns `None`, and
//! `project_messages` falls back to the byte-identical deterministic stub —
//! SPEC.md TR-7 dev/03.
//!
//! **Off by default.** [`super::ReductionPolicy::summarize_cleared_turns`]
//! defaults to `false`; with it off, `project_messages` never even looks at
//! [`super::ReductionPolicy::cleared_turns_summary`], so the A10 stub stays
//! byte-identical to pre-TR-7 behavior (dev/01) regardless of what a caller
//! did or didn't precompute.
use crateResult;
/// Injectable summarization side-call (SPEC.md TR-7's "explicit, budgeted,
/// injectable side-call"). A real implementation calls out to a cheap model;
/// tests inject a deterministic fake (and, for the dev/03 fault-injection
/// AC, one that always errors) — nothing in this crate's own test suite ever
/// performs a real network/model call.
/// The fixed, in-repo, VERSIONED summarization prompt template (SPEC.md
/// TR-7: "summarization prompt is fixed and versioned in-repo"). Bump this
/// any time [`render_prompt`]'s wording changes — the version rides the
/// audit trail ([`super::SpanSummary::prompt_version`]) precisely so a later
/// reader can tell which wording produced a given summary.
pub const PROMPT_VERSION: &str = "tr7-summary-v1";
/// Render the fixed prompt for summarizing one cleared span's rendered text
/// (see `render_span_text`). Exposed so a real [`SpanSummarizer`]
/// implementation (elsewhere — never in this crate's test-only code) sends
/// exactly the wording [`PROMPT_VERSION`] names.