Merge lane-go: keep the lane's reviewed work

Combines lane-go's typed omni search, launch-time model overrides, TUI
artifacts view, run-state websocket push, and the "reflect the change where
it belongs" committer rule with the Templates gallery, chat/omni-search and
other reviewed work already on main. The 12 files both sides touched keep
both intents composed rather than dropping either side: the omni search keeps
the typed search contract (CLI `pipelines search` and the TUI popup with type
badges and marked snippets) alongside the run-list quick filter; cli.md and
ui-ux-review.md document both the search rework and the artifacts view;
orchestration.md, harnesses.md and operations.md keep the model-override and
reflect-where-it-belongs guidance; and the protocol/CLI/server/TUI code keeps
the new search, run-event, override and artifacts paths alongside the existing
run, title and help surfaces.

Checks before committing:
- go build ./...  -- pass
- go vet ./...  -- pass
- go test -count=1 ./internal/... ./cmd/...  -- all pass

Doc check before committing: nothing needs updating. The lane's own docs and
references (docs/cli.md, docs/ui-ux-review.md, and the orchestration,
harnesses and operations skill references) already carry the new features.
format.md and the packaged templates already describe the line-oriented result
format and the human decision stage from the earlier lane-go merge. The root
README already describes the omni search popup. Model overrides, the search
command, run events and the artifacts view are runtime/CLI/TUI surfaces that
cli.md documents; no template, README or topic-doc edit is required by this
merge.
This commit is contained in:
2026-10-17 02:04:58 +01:00
41 changed files with 3772 additions and 170 deletions
+17 -8
View File
@@ -102,12 +102,12 @@ type PipelineSummary struct {
UpdatedAt string `json:"updated_at"`
}
// Message is the JSON envelope shared by the server and client. It also carries
// the omni-search request/response: a client sends Type "search" with an ID, the
// Query text, an optional Kind type filter and an optional Limit, and the server
// replies with Type "search_results", the echoed ID and ranked Matches. Every
// search fields are optional so older peers ignore them. See search.go for the
// kind constants and wire-shape detail.
// Message is the JSON envelope shared by the server and client. It also brokers
// omni search: a client sends Type "search" with an ID, Query text, an optional
// Kind type filter and an optional Limit, and the server replies with Type
// "search_results", the echoed ID and a ranked SearchResponse. Both search fields
// are optional so older peers ignore them. See search.go for the per-type payloads
// and the ranking/kind/bound vocabulary.
type Message struct {
DefaultHarness string `json:"default_harness,omitempty"`
Build *buildinfo.Info `json:"build,omitempty"`
@@ -129,8 +129,6 @@ type Message struct {
Source string `json:"source,omitempty"`
Title string `json:"title,omitempty"`
Version int `json:"version,omitempty"`
Query string `json:"query,omitempty"`
Kind string `json:"kind,omitempty"`
Pipelines []PipelineSummary `json:"pipelines,omitempty"`
PipelineID int64 `json:"pipeline_id,omitempty"`
Detail *PipelineDetail `json:"detail,omitempty"`
@@ -145,6 +143,12 @@ type Message struct {
WritePaths []string `json:"write_paths,omitempty"`
RequestKey string `json:"request_key,omitempty"`
Workspace string `json:"workspace,omitempty"`
// Model and StageModels are the launch-time model overrides: Model applies to
// every model stage of the run and StageModels overrides individual stages by
// key (per-stage wins over whole-run). Both are optional so older peers ignore
// them; the same fields are echoed on the run record.
Model string `json:"model,omitempty"`
StageModels map[string]string `json:"stage_models,omitempty"`
// Search is the broad, read-only search traffic over pipelines, versions,
// runs, steps, field text and artifacts. See search.go for the per-type
// payloads and the ranking/kind/bound vocabulary.
@@ -161,4 +165,9 @@ type Message struct {
ChatEvent *ChatEventFrame `json:"chat_event,omitempty"`
ChatPermission *ChatPermissionFrame `json:"chat_permission,omitempty"`
ChatReply *ChatReplyRequest `json:"chat_reply,omitempty"`
// RunEvent is the server-pushed run state delta (see runevents.go) and
// RunIDs the optional subscribe scope, so a client asks for the runs it
// displays. Both are optional so older peers ignore them.
RunEvent *RunEventFrame `json:"run_event,omitempty"`
RunIDs []int64 `json:"run_ids,omitempty"`
}
+48
View File
@@ -0,0 +1,48 @@
package protocol
// Server-pushed run state. A client sends subscribe (scoped to the workspace and
// optionally to explicit run ids) to ask for the runs it displays: the server
// first returns the current state of those runs so a reconnecting client
// re-syncs, then pushes a compact run_event delta on every meaningful
// transition. It sends unsubscribe to stop. Like chat_event, run_event is a
// server-pushed frame with no matching request, so both fields are optional and
// older peers ignore them.
const (
Subscribe = "subscribe"
Unsubscribe = "unsubscribe"
RunEvent = "run_event"
)
// RunEventFrame is the server-pushed run_event delta. It carries only the values
// that changed, never the whole run: the run's identity, status, outcome, current
// stage, completed-step count and timestamps, plus at most one changed step.
// Every field is optional so an older peer ignores what it does not know and a
// client can fold the frame into its cached run.
type RunEventFrame struct {
RunID int64 `json:"run_id"`
Workspace string `json:"workspace,omitempty"`
Status string `json:"status,omitempty"`
Outcome string `json:"outcome,omitempty"`
CurrentStage string `json:"current_stage,omitempty"`
CompletedSteps int `json:"completed_steps,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
FinishedAt string `json:"finished_at,omitempty"`
// Artifacts is the number of files recorded for the referenced step, so a
// client can surface artifact capture without reading the step.
Artifacts int `json:"artifacts,omitempty"`
// Step is present when a single step changed (started, finished or waiting).
Step *RunStepDelta `json:"step,omitempty"`
}
// RunStepDelta is the compact change of one step within a RunEventFrame. It is a
// delta, not a RunStep: it omits the input/output, transcript, file changes and
// artifact bytes a full step carries.
type RunStepDelta struct {
Sequence int `json:"sequence"`
Stage string `json:"stage,omitempty"`
Status string `json:"status,omitempty"`
Outcome string `json:"outcome,omitempty"`
Target string `json:"target,omitempty"`
Diagnostic string `json:"diagnostic,omitempty"`
Artifacts int `json:"artifacts,omitempty"`
}
+65
View File
@@ -0,0 +1,65 @@
package protocol
import (
"encoding/json"
"reflect"
"strings"
"testing"
)
// TestRunEventGoldenJSON pins the exact wire shape of the pushed run_event frame
// so a JSON tag change cannot silently alter what a client parses.
func TestRunEventGoldenJSON(t *testing.T) {
frame := RunEventFrame{
RunID: 7, Workspace: "/work", Status: RunStatusRunning, CurrentStage: "build",
CompletedSteps: 1, CreatedAt: "2026-01-02T03:04:05Z", Artifacts: 2,
Step: &RunStepDelta{Sequence: 2, Stage: "build", Status: "completed", Outcome: "success", Target: SuccessEnd, Artifacts: 2},
}
encoded, err := json.Marshal(frame)
if err != nil {
t.Fatal(err)
}
want := `{"run_id":7,"workspace":"/work","status":"running","current_stage":"build","completed_steps":1,"created_at":"2026-01-02T03:04:05Z","artifacts":2,"step":{"sequence":2,"stage":"build","status":"completed","outcome":"success","target":"#success","artifacts":2}}`
if string(encoded) != want {
t.Fatalf("golden mismatch\n got %s\nwant %s", encoded, want)
}
var decoded RunEventFrame
if err := json.Unmarshal([]byte(want), &decoded); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(decoded, frame) {
t.Fatalf("golden did not decode back: %+v", decoded)
}
}
// TestRunEventEnvelopeRoundTrip proves the new optional fields survive the shared
// Message envelope and that an unused payload is omitted from the wire.
func TestRunEventEnvelopeRoundTrip(t *testing.T) {
message := Message{
Type: RunEvent,
ID: "r1",
RunEvent: &RunEventFrame{RunID: 3, Workspace: "/w", Status: RunStatusQueued, CreatedAt: "2026-01-02T03:04:05Z"},
RunIDs: []int64{3, 4},
}
encoded, err := json.Marshal(message)
if err != nil {
t.Fatal(err)
}
var decoded Message
if err := json.Unmarshal(encoded, &decoded); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(decoded.RunEvent, message.RunEvent) || !reflect.DeepEqual(decoded.RunIDs, message.RunIDs) {
t.Fatalf("run event fields lost: %+v", decoded)
}
minimal, err := json.Marshal(Message{Type: Subscribe, ID: "s1", Workspace: "/w"})
if err != nil {
t.Fatal(err)
}
for _, absent := range []string{"run_event", "run_ids"} {
if strings.Contains(string(minimal), absent) {
t.Fatalf("absent %q must be omitted: %s", absent, minimal)
}
}
}
+13
View File
@@ -21,8 +21,10 @@ const (
// the run and its step persist these statuses and the decision path resumes
// them. Store, server, CLI and TUI read the one pair below, never a literal.
const (
RunStatusQueued = "queued"
RunStatusWaiting = "waiting"
RunStatusRunning = "running"
StepStatusRunning = "running"
StepStatusWaiting = "waiting"
// NotifyWaiting is the notification event a human stage emits when it parks
// the run. It is the same value the `on=` policy accepts.
@@ -118,6 +120,12 @@ type RunSummary struct {
Diagnostic string `json:"diagnostic"`
ResultPreview string `json:"result_preview,omitempty"`
CompletedSteps int `json:"completed_steps"`
// Model and StageModels are the launch-time overrides this run records so it
// stays reproducible: Model covers every model stage and StageModels overrides
// individual stages by key. They are empty for a run that used the pinned
// models and for historical rows.
Model string `json:"model,omitempty"`
StageModels map[string]string `json:"stage_models,omitempty"`
}
// Label is the operator-facing name of a run: the generated Title when the
@@ -147,6 +155,11 @@ type RunStep struct {
SessionID string `json:"session_id"`
AgentActive bool `json:"agent_active"`
Transcript string `json:"transcript"`
// Provider and Model are the effective provider/model this visit actually ran
// with, recorded for every model stage (including failures). They are empty
// for non-model stages and historical steps.
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
// ArtifactsSkipped and ArtifactsTruncated count files excluded from the
// bounded per-step scan (over the file/size cap) and by the total budget.
ArtifactsSkipped int `json:"artifacts_skipped,omitempty"`
+65
View File
@@ -1,5 +1,10 @@
package protocol
import (
"fmt"
"unicode"
)
// Search brokered by the Pipelines server: one query can find a pipeline, a
// pipeline version, a run, a recorded step/visit, the text of a step field
// (input/output/evidence/transcript) or a recorded artifact. A client sends
@@ -156,3 +161,63 @@ type SearchArtifact struct {
SizeBytes int64 `json:"size_bytes"`
URL string `json:"url"`
}
// Label is the compact human description of a hit, built from the result's
// typed payload rather than its target token, so it is the single definition
// shared by the CLI and the TUI. A text-field hit's snippet is deliberately not
// part of the label: the CLI appends it and the TUI renders it on its own
// marked line, so the two surfaces show the match differently without
// duplicating the per-kind dispatch.
func (r SearchResult) Label() string {
switch r.Kind {
case SearchKindPipeline:
if r.Pipeline != nil {
return fmt.Sprintf("%s · v%d · %d stages", r.Pipeline.Name, r.Pipeline.Version, r.Pipeline.Stages)
}
case SearchKindVersion:
if r.Version != nil {
return fmt.Sprintf("pipeline %d · v%d · %s", r.Version.PipelineID, r.Version.Version, r.Version.ContentHash)
}
case SearchKindRun:
if r.Run != nil {
return fmt.Sprintf("run %d · %s · %s", r.Run.ID, r.Run.PipelineName, r.Run.Status)
}
case SearchKindStep:
if r.Step != nil {
return fmt.Sprintf("run %d · step %d · %s · %s", r.Step.RunID, r.Step.Sequence, r.Step.Stage, r.Step.Outcome)
}
case SearchKindField:
if r.Field != nil {
return fmt.Sprintf("run %d · step %d · %s", r.Field.RunID, r.Field.Sequence, r.Field.Field)
}
case SearchKindArtifact:
if r.Artifact != nil {
return fmt.Sprintf("run %d · step %d · %s · %s", r.Artifact.RunID, r.Artifact.Sequence, r.Artifact.Name, r.Artifact.ContentType)
}
}
return r.Target
}
// RuneIndexFold returns the rune index where query first matches text
// case-insensitively, or -1 when it does not. It folds runes rather than bytes
// so a caller never splits a UTF-8 boundary, and an empty query never matches.
// It is the single definition shared by server-side snippet windowing and the
// TUI's marker placement.
func RuneIndexFold(text, query []rune) int {
if len(query) == 0 || len(query) > len(text) {
return -1
}
for i := 0; i+len(query) <= len(text); i++ {
match := true
for j := range query {
if unicode.ToLower(text[i+j]) != unicode.ToLower(query[j]) {
match = false
break
}
}
if match {
return i
}
}
return -1
}
+43
View File
@@ -50,6 +50,49 @@ func TestSearchRequestResponseRoundTrip(t *testing.T) {
}
}
// TestRuneIndexFold pins the shared case-insensitive matcher used by both the
// server's snippet window and the TUI's marker, so it cannot drift per package.
func TestRuneIndexFold(t *testing.T) {
cases := []struct {
text, query string
want int
}{
{text: "prefix café résumé", query: "CAFÉ", want: 7},
{text: "Needle in a haystack", query: "needle", want: 0},
{text: "absent", query: "xyz", want: -1},
{text: "abc", query: "", want: -1},
{text: "ab", query: "abc", want: -1},
}
for _, tc := range cases {
if got := RuneIndexFold([]rune(tc.text), []rune(tc.query)); got != tc.want {
t.Fatalf("RuneIndexFold(%q, %q) = %d, want %d", tc.text, tc.query, got, tc.want)
}
}
}
// TestSearchLabelPerKind pins the single per-kind label shared by the CLI and
// TUI, so the six-kind dispatch lives in one place.
func TestSearchLabelPerKind(t *testing.T) {
cases := []struct {
result SearchResult
want string
}{
{SearchResult{Kind: SearchKindPipeline, Target: "pipeline:1", Pipeline: &SearchPipeline{Name: "demo", Version: 2, Stages: 3}}, "demo · v2 · 3 stages"},
{SearchResult{Kind: SearchKindVersion, Target: "pipeline:1:v2", Version: &SearchVersion{PipelineID: 1, Version: 2, ContentHash: "abc"}}, "pipeline 1 · v2 · abc"},
{SearchResult{Kind: SearchKindRun, Target: "run:7", Run: &SearchRun{ID: 7, PipelineName: "demo", Status: "succeeded"}}, "run 7 · demo · succeeded"},
{SearchResult{Kind: SearchKindStep, Target: "run:7:2", Step: &SearchStep{RunID: 7, Sequence: 2, Stage: "reviewer", Outcome: "success"}}, "run 7 · step 2 · reviewer · success"},
{SearchResult{Kind: SearchKindField, Target: "run:7:2:output", Field: &SearchField{RunID: 7, Sequence: 2, Field: "output", Snippet: "[needle] output"}}, "run 7 · step 2 · output"},
{SearchResult{Kind: SearchKindArtifact, Target: "/artifacts/7/2/shot.png", Artifact: &SearchArtifact{RunID: 7, Sequence: 2, Name: "shot.png", ContentType: "image/png"}}, "run 7 · step 2 · shot.png · image/png"},
// A result missing its typed payload falls back to the navigable target.
{SearchResult{Kind: SearchKindRun, Target: "run:9"}, "run:9"},
}
for _, tc := range cases {
if got := tc.result.Label(); got != tc.want {
t.Fatalf("Label(%s %s) = %q, want %q", tc.result.Kind, tc.result.Target, got, tc.want)
}
}
}
func TestSearchResultOmitsAbsentPayloadsAndEmptyKind(t *testing.T) {
encoded, err := json.Marshal(SearchResult{Kind: SearchKindRun, Target: "run:1", Score: 1, MatchedField: "status"})
if err != nil {