Add cross-system read-only search

One query now finds anything in the system over the wire and from the CLI.

- protocol: add Search/SearchResults message types and a SearchRequest
  (query, optional kind filter, optional limit) / SearchResponse (typed,
  ranked matches plus truncation and scan-bound counters) pair, with typed
  payloads for pipeline, version, run, step/visit, field text and artifact.
- store: add Store.Search, a read-only query over pipelines,
  pipeline_versions, pipeline_runs, run_steps (+step_control) and
  step_artifacts. Ranks exact name (3) > name substring (2) > body text (1),
  breaks ties by recency then a stable kind/target order, and reports the
  matched field. Bounds work with a 50-default/200-max result cap, a 2000-row
  per-kind scan limit and a 2000-step / 1 MiB field-text scan budget.
- terms: a bare status word or lone date expression (today, yesterday, this
  week, YYYY-MM-DD) selects runs; anything else stays free text.
- server: dispatch protocol.Search to stores[0].Search; read-only and
  unconfirmed.
- cli: add `pipelines search QUERY [--type KIND] [--limit N] [--json]`, help
  text and a BROWSE line.
- store: add OpenReadOnly so the live-database check never runs DDL.
- docs: document the grammar, kinds, ranking and bounds in docs/cli.md,
  scope the TUI omnisearch to pipelines in docs/ui-ux-review.md, and add a
  search bullet to the packaged operations reference.
- tests: protocol round trip, store/ranking/term-parsing/limit/scan-bound
  unit tests, a server end-to-end test, and an env-guarded live check.

No new dependencies; go.mod/go.sum unchanged.
This commit is contained in:
2026-10-16 15:43:25 +01:00
parent dce624b428
commit c700b28e6a
16 changed files with 1914 additions and 8 deletions
@@ -71,6 +71,21 @@ delete databases, sessions, volumes or credentials to repair a workflow.
Use the authoritative `CLI_PREFIX` from the prompt:
- `CLI_PREFIX runs --json`: run history (optional `--pipeline NAME` scope).
- `CLI_PREFIX search QUERY [--type KIND] [--limit N] --json`: one read-only query
across pipelines, versions, runs, steps, field text and artifacts. QUERY is free
text, a bare status word (`queued`/`running`/`succeeded`/`failed`/`canceled`/
`interrupted`) selecting those runs, or a lone date expression (`today`,
`yesterday`, `this week` — Monday 00:00 local — or `YYYY-MM-DD`) selecting the
runs created in that window; anything else stays free text. `--type` is the only
narrowing mechanism and takes one of `pipeline`, `version`, `run`, `step`,
`field`, `artifact`; an unknown kind is an error. Ranking is exact name (3) >
name substring (2) > body text (1), equal tiers by recency, and every hit
reports `score`, `matched_field` and `recency`. The cap defaults to 50 and clamps
to 200; every kind scans at most 2000 rows and field scanning stops at 2000
steps / 1 MiB and reports
`truncated`/`scanned_steps`/`scanned_bytes`/`cap`/`scan_bound_bytes`. Targets are
stable: `pipeline:<id>`, `pipeline:<id>:v<version>`, `run:<id>`,
`run:<id>:<sequence>`, `run:<id>:<sequence>:<field>`, or an artifact URL.
- `CLI_PREFIX inspect RUN_ID --json`: selected run, visits and retained evidence.
Exact stage outputs are authoritative; a transcript over the 32 KiB retained
bound is a valid, credential-redacted preview envelope (with preserved stage