Expand description
Run-history routes: GET /api/runs (filtered, paginated list), GET /api/runs/{id}
(full run detail: config, initial readings, samples, results, writes), GET /api/runs/{id}/export (CSV/JSON sample export), and DELETE /api/runs/{id}.
DTO shapes deliberately mirror bhtune-cli’s commands::history --output json JSON
(RunSummaryJson/RunDetailJson/etc.) field-for-field, so the CLI and the HTTP API
describe the same run the same way – one shape for the product’s two faces, per this
workspace’s DTO-decoupling convention (every JSON-facing consumer builds its own
projection of the non-Serialize bhtune-db row types, rather than the row types
themselves growing a Serialize impl). The one deliberate addition over the CLI’s own
RunDetailJson is a full samples array (not just a samples_recorded count) – the
trend chart (history-explorer-ui) needs the raw per-tick data, and the data-volume math
in AGENTS.md’s “History explorer” section (thousands of rows per run, not millions) says
inlining it is cheap enough not to need its own paginated route.
Structs§
- Initial
Readings Response - Local projection of
bhtune_db::models::TuneRunInitialReadings– see this module’s doc comment for why every JSON-facing type here is its own projection rather than aSerializeimpl on thebhtune-dbrow type. - MvActuation
Response - Local projection of one accepted OPC DA manipulated-variable command and its independent
live readback evidence. Commanded MV samples remain in
SampleResponse; this audit trail is the only response surface that reports measured MV values. - PidConstant
Tags Response - A run’s snapshotted PID constant tag names, present only when all three were configured.
Nested under
RunDetailResponse::pid_constant_tagsfollowing the same “Option<...>presence itself is the signal” conventioninitial_readingsalready uses, rather than a separate boolean plus three more nullable top-level fields. - PidParameter
Labels Response - The operator-facing names for the three calculated PID constants, derived from the template snapshot stored on the run rather than the mutable template catalog.
- Result
Response - Local projection of
TuneResultRow. - RunDetail
Response - RunExport
Query - RunList
Query - Query parameters for
GET /api/runs, mirroringTuneRunFilter’s fields one-to-one plusPagination. Every field is optional; an absentlimit/offsetfalls back toPagination::default(50 rows, offset 0), matching the CLI’s own default page size. - RunList
Response - RunSummary
Response - One run in
GET /api/runs’srunsarray – deliberately a subset matching the CLI’s ownhistory listtable columns, not the full detail (that’sRunDetailResponse, forGET /api/runs/{id}). - Sample
Response - One recorded tick: the
Tickinput and resulting engine state, plus the driver- reported PV quality at read time.Tick/MrftStatealready deriveSerializeinbhtune-core(they round-trip through golden-trace fixtures too), so they’re embedded directly rather than re-projected field-by-field like the other DTOs here. - Write
Response - Local projection of
TuneWriteRow.
Enums§
- RunExport
Format - Format for
GET /api/runs/{id}/export– deliberately a local, HTTP-facing enum rather than reusingbhtune_cli::args::ExportFormatdirectly: that type isclap-oriented (ValueEnum) and has noDeserialize/ToSchema, matching this module’s own DTO-decoupling convention (see the module doc comment). Converted tobhtune_cli::args::ExportFormatat the one call site that needs it ([export_run]), so the actual CSV/JSON serialization (bhtune_cli::commands::export::samples_to_bytes) is implemented exactly once and the CLI’sbhtune exportand this route can never disagree about what a run’s export looks like.