From c9ebe526cc41dbe67478332e850317f21fe4d986 Mon Sep 17 00:00:00 2001 From: Mathias Date: Fri, 2 Oct 2026 08:50:39 +0200 Subject: [PATCH] feat(domain): progress steps and the two timestamps that tell alive from progressing (ADR-035) Co-Authored-By: Claude Sonnet 5.5 --- internal/domain/domain.go | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/internal/domain/domain.go b/internal/domain/domain.go index 2952d6d..20fbd75 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -175,6 +175,32 @@ type Reconciliation struct { Contested []ContestedSpot `json:"contested,omitempty"` } +// StepState is where one phase of an upload job stands (ADR-035). +type StepState string + +const ( + StepPending StepState = "pending" + StepRunning StepState = "running" + StepDone StepState = "done" + StepFailed StepState = "failed" + // StepSkipped is a step that never ran because the job finished without it, for + // example the second engine's step when the first engine's text was used alone. + StepSkipped StepState = "skipped" +) + +// ProgressStep is one named phase of an upload job. Total is zero for a phase with no +// count; only a phase whose work is really countable carries one (ADR-035: no +// percentage that does not come from real counts). +type ProgressStep struct { + Key string `json:"key"` + Label string `json:"label"` + State StepState `json:"state"` + StartedAt time.Time `json:"started_at,omitzero"` + FinishedAt time.Time `json:"finished_at,omitzero"` + Done int `json:"done,omitempty"` + Total int `json:"total,omitempty"` +} + // UploadStatus is the state of an uploaded-audio transcription job. type UploadStatus string @@ -218,6 +244,13 @@ type UploadedTranscript struct { // Reconciliation is how a merged transcript came about, or nil for a single // engine (ADR-034). Set by Get, not by List. Reconciliation *Reconciliation - CreatedAt time.Time - FinishedAt time.Time // zero until the job reaches done or failed + // Progress is the job's phases, in order. Set by Get, not by List (ADR-035). + Progress []ProgressStep + // ProgressAt is when a phase last really changed or advanced; AliveAt is the + // heartbeat. They differ on purpose: alive says the service is still reporting, + // progress says work is moving (ADR-035). Both are zero until the job starts. + ProgressAt time.Time + AliveAt time.Time + CreatedAt time.Time + FinishedAt time.Time // zero until the job reaches done or failed }