Add bounded one-line summariser using the configured default harness

internal/summarise performs a single tool-free generation through the
configured default harness (its interactive model), reusing the exact
stage.ModelGenerator/OpenCodeClient/PiClient construction provider-check
uses. It bounds input (InputCap), output (one line, OutputCap runes) and
time (DefaultTimeout), returns the NoSummary sentinel on any error/timeout/
unusable reply, never runs tools or writes files, and records the harness,
model and failed flag in one sanitized log line plus at most one
OperationEvidence.

Reuse: stage.TruncateRunes and stage.OperationLog.Record are the exported
forms of the existing rune-safe truncation and bounded evidence recording;
protocol.NormalizeText trims replies to one line. No new dependencies.

Not wired into titles/verdicts yet: protocol.OutputPreview and the
internal/server/notify.go notification summary are the obvious future call
sites.
This commit is contained in:
2026-10-16 10:55:43 +01:00
parent 7f7492a7bd
commit 5157b3a716
3 changed files with 568 additions and 0 deletions
+15
View File
@@ -105,6 +105,13 @@ func RedactEvidence(text string) string {
return text
}
// TruncateRunes is the exported form of truncateRunes. Callers outside the stage
// package that must bound text (for example the one-line summariser) reuse this
// single UTF-8-safe truncation instead of re-implementing rune handling.
func TruncateRunes(s string, limit int) (string, int) {
return truncateRunes(s, limit)
}
// truncateRunes caps s to at most limit bytes without splitting a UTF-8 rune,
// reporting how many bytes were dropped.
func truncateRunes(s string, limit int) (string, int) {
@@ -258,6 +265,14 @@ func RetainSession(transcript, sessionID string) string {
return string(merged)
}
// Record appends one pre-sanitized operation evidence to the log, reusing the
// same provider/model stamping, credential redaction and 32-record bound as the
// stage-internal record path. Packages outside stage (for example the one-line
// summariser) use it to leave bounded diagnostics without re-implementing it.
func (l *OperationLog) Record(e OperationEvidence, started time.Time) {
l.record(e, started)
}
func (l *OperationLog) record(e OperationEvidence, started time.Time) {
if l == nil {
return