renderTuningReport function
Renders the tuning report (issue #1398 AC5): per-model p50/p95
inter-chunk gap, watchdog-fire counts, and the recipe line
(streamIdleTimeoutMs ≈ 2× p95 → <value>). Empty string when no
instrumentation data is present — the report section simply does not
render (AC5's "when instrumentation data is present").
Implementation
String renderTuningReport({InterChunkGapRecorder? recorder}) {
final summaries = (recorder ?? interChunkGapRecorder).summaries;
if (summaries.isEmpty) return '';
final buffer = StringBuffer('tuning report (inter-chunk gap):\n');
for (final summary in summaries.values) {
buffer
..write(
' ${summary.model}: p50 ${_humanize(summary.p50)} '
'p95 ${_humanize(summary.p95)} '
'(n=${summary.samples}, watchdog fires ${summary.watchdogFires})',
)
..write(
' — recipe: streamIdleTimeoutMs ≈ 2× p95 → '
'${_humanize(summary.recipeSuggestion)}\n',
);
}
return buffer.toString();
}