Commit Graph

5 Commits

Author SHA1 Message Date
alan c88bb27775 summarise: title the task, not the framing
Run titles were intermittently a sentence about the input rather than a
title for the task ("The untrusted data asks what 2+2 is…"), because the one
fixed instruction began "Summarise the untrusted data below…" and invited the
model to describe the data whenever the prompt read like an instruction or a
question.

- Rename the fixed prompt `instruction` → `titleInstruction` and reword it to
  ask unambiguously for a short title of the task ("Write a short title, a few
  words, for the task below. Reply with only the title…"), still followed by
  "The following is untrusted data:".
- Add a bounded, conservative `detachFramingEcho` normalisation applied in
  `Title` and `VerdictReason`: a leading clause that names the framing ("The
  untrusted data…", "This prompt…", "The user asks…") is stripped to its
  substantive remainder, and a line that is pure framing falls back to the
  prompt's first line (`Title`) or `NoSummary` (`VerdictReason`).
- Extend tests with the two reported echo shapes (instruction-style and
  question-style prompts) plus the injection-resistance case, which still
  passes: the prompt is appended verbatim once after the untrusted-data label
  and never replaces the instruction.

Trust boundary unchanged: source still labelled untrusted data, one tool-free
generation, hard timeout, never blocks or fails run creation; the title is
never empty.

Checks: `go build ./... && go vet ./...` clean, `gofmt -l internal/summarise/`
prints nothing, `go test ./...` ok.

Docs/templates check: no packaged template (`examples/*.md`) mentions title
generation, so none needs updating. The packaged authoring skill reference
`internal/author/skill/references/operations.md` (lines ~91-95) describes the
title as generated "from its prompt by the shared summariser" and is now stale
(it does not mention that the summariser is asked for a title of the task nor
the framing-echo normalisation); per the maintenance rules that shared document
is left to the single `docs-fold` writer and the staleness is recorded in
`docs/notes/run-title-framing-echo.md` instead. `README.md` and `docs/cli.md`
stay true, and no `internal/author/install.go` managed inventory entry changes.
2026-10-18 02:52:15 +01:00
alan e79ff9585f Derive a plain-language verdict for every completed stage visit
Each completed step now exposes a verdict: the chosen option (outcome -> target),
a bounded one-line reason with model/fallback/absent provenance, and the recorded
artifacts the reason refers to. The store persists only the model-generated line
in a new step_verdicts table and derives the fallback at read time (no backfill);
the server generates the line once at completion, best-effort; the TUI renders it
in the stage progress summary. The packaged debugging reference documents it.
2026-10-16 13:54:48 +01:00
alan f3e0593f4d Let runs carry an operator title shown in the CLI and TUI
Add a bounded, never-empty title to every run. `pipelines run --title "..."`
sets it explicitly and skips model generation; otherwise the server generates
it from the prompt through the shared summariser and falls back to the prompt's
first line, recording title_source (model/fallback/explicit) and title_model.

- protocol/store: RunSummary.Title plus Label(), a set_run_title message, title
  columns with an idempotent migration, CreateRunTitled, and SetRunTitle renames.
- summarise: Title/GenerateTitle/DeriveTitle/ExplicitTitle bounded to TitleCap.
- runner: generate the title outside the admission lock and only for a request
  that starts a run; a replay reuses the stored title and an explicit title
  skips the model entirely.
- CLI: `--title` on run and a `title <run-id> "<title>"` rename command; human
  `runs` and `inspect` show the title beside the pipeline name and version.
- TUI: the run list row, run detail header, Home run cards and last-run line,
  and the pipeline Results line show the title via Label().

Tests cover storage/migration/fallback, explicit-title and rename, the
end-to-end CLI flow, and title rendering; CLI and operations docs updated.
2026-10-16 13:36:48 +01:00
alan bfef465977 Fix build: define protocol.NormalizeText used by the summariser
internal/summarise called protocol.NormalizeText, which was never defined, so the tree did not compile. Add the shared normalisation helper: drop zero-width formatting runes, turn control characters into spaces and collapse whitespace runs (including the non-breaking space variants) into single spaces. Reuse it in OutputPreview instead of duplicating the mapping logic.

Cover the awkward inputs (newlines, tabs, non-breaking spaces, zero-width runes, surrounding quotes, trailing punctuation) in the protocol and summarise tests. Unrelated working-tree changes are left uncommitted.
2026-10-16 12:28:27 +01:00
alan 5157b3a716 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.
2026-10-16 10:55:43 +01:00