Merge lane-go: titles, verdicts, human stage, line result format, stale-client guard
Integrates nine commits of reviewed work from the lane-go branch after the automated resolver failed on this merge five times (each attempt dying on the malformed-result defect whose fix is contained in this same merge). Integration decisions: - Search: kept main's shipped design (Store.Search + SearchResponse.Results) and dropped lane-go's parallel, older attempt (an unused Message.Matches field, an absent runs.search, and two partial TUI plumbing blocks). lane-go itself did not compile: protocol.SearchMatch was undefined and model.go referenced searchNav, requestSearch and applyRunNav, which exist nowhere. Those partial TUI blocks are removed; the queued TUI omni-search item will implement the surface properly on main's design. - Both sides' additions are kept where they are independent: run titles and provenance, the human decision stage and its CLI/TUI surface, the derived stage verdict, the stale-client guard, the line-oriented result format, and main's search command. - The search key's help label is now "/ omni search"; the two tests asserting the old label are updated rather than the label reverted. - docs/cli.md and the packaged operations reference carry both sides' text. Verified: go build ./... , go vet ./... and the full go test ./... suite pass.
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"git.a-wan.net/alan/pipelines/internal/buildinfo"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/summarise"
|
||||
)
|
||||
|
||||
// Options configures the HTTP handler.
|
||||
@@ -31,6 +32,15 @@ type Options struct {
|
||||
// it from the first store; when neither is available chat_sessions returns an
|
||||
// empty list rather than the endpoint's whole session list.
|
||||
OwnedSessions func(context.Context) ([]pipeline.SessionOwner, error)
|
||||
// RunTitles generates the operator-facing title stored with each new run.
|
||||
// When nil, run creation stores the prompt-derived fallback without a model
|
||||
// call, which keeps tests and unconfigured servers deterministic.
|
||||
RunTitles func(context.Context, string) summarise.Title
|
||||
// StepVerdicts generates the bounded one-line reason stored with each
|
||||
// completed stage visit. When nil, the store derives the verdict's reason at
|
||||
// read time with no model call, which keeps tests and unconfigured servers
|
||||
// deterministic.
|
||||
StepVerdicts func(context.Context, map[string]any) string
|
||||
}
|
||||
|
||||
// Handler serves the persistent connection with default options. Canceling ctx
|
||||
@@ -53,6 +63,12 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
if runErr == nil && options.ArtifactsRoot != "" {
|
||||
runs.artifactsRoot = options.ArtifactsRoot
|
||||
}
|
||||
if runErr == nil && options.RunTitles != nil {
|
||||
runs.title = options.RunTitles
|
||||
}
|
||||
if runErr == nil && options.StepVerdicts != nil {
|
||||
runs.verdict = options.StepVerdicts
|
||||
}
|
||||
if runErr == nil {
|
||||
runs.schedulerWG.Add(1)
|
||||
go runs.scheduleLoop()
|
||||
@@ -96,6 +112,16 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
defer connCancel()
|
||||
var writeMu sync.Mutex
|
||||
write := func(message protocol.Message) error {
|
||||
// Every server frame (responses, the welcome and chat events) carries
|
||||
// the build identity and protocol so an older client fails fast or
|
||||
// warns once instead of silently misreading a field. build is
|
||||
// computed once per handler.
|
||||
if message.Build == nil {
|
||||
message.Build = &build
|
||||
}
|
||||
if message.Protocol == 0 {
|
||||
message.Protocol = protocol.ProtocolVersion
|
||||
}
|
||||
writeMu.Lock()
|
||||
defer writeMu.Unlock()
|
||||
writeCtx, cancel := context.WithTimeout(connCtx, 5*time.Second)
|
||||
@@ -133,7 +159,6 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
response.Status = systemStatus(r, started, runErr)
|
||||
} else if request.Type == protocol.Ping {
|
||||
response.Time = time.Now().UTC().Format(time.RFC3339)
|
||||
response.Build = &build
|
||||
} else if request.Type == protocol.ListTemplates {
|
||||
response.Type = protocol.Templates
|
||||
response.Templates = examples.Catalog()
|
||||
@@ -208,7 +233,7 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
response.Error = err.Error()
|
||||
}
|
||||
}
|
||||
} else if runs != nil && (request.Type == protocol.RunPipeline || request.Type == protocol.RetryRun || request.Type == protocol.ListRuns || request.Type == protocol.GetRun || request.Type == protocol.CancelRun || request.Type == protocol.GetRunEvidence) {
|
||||
} else if runs != nil && (request.Type == protocol.RunPipeline || request.Type == protocol.RetryRun || request.Type == protocol.ListRuns || request.Type == protocol.GetRun || request.Type == protocol.CancelRun || request.Type == protocol.DecideRun || request.Type == protocol.SetRunTitle || request.Type == protocol.GetRunEvidence) {
|
||||
var err error
|
||||
switch request.Type {
|
||||
case protocol.GetRunEvidence:
|
||||
@@ -220,6 +245,12 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
case protocol.RetryRun:
|
||||
response.Type = protocol.RunStarted
|
||||
response.RunDetail, err = runs.retry(request)
|
||||
case protocol.DecideRun:
|
||||
response.Type = protocol.Run
|
||||
response.RunDetail, err = runs.decide(request)
|
||||
case protocol.SetRunTitle:
|
||||
response.Type = protocol.Run
|
||||
response.RunDetail, err = runs.setTitle(request.RunID, request.Title)
|
||||
case protocol.ListRuns:
|
||||
response.Type = protocol.Runs
|
||||
response.Runs, err = runs.listRuns()
|
||||
|
||||
Reference in New Issue
Block a user