package server

import "context"

// jobKind identifies the kind of work a job performs.
//
// jobKind is stored in migrationStatus so observers can see what is running or
// what ran last.
type jobKind string

const (
	jobMigrateRun       jobKind = "migrate-run"
	jobExportProbe      jobKind = "export-probe"
	jobVmselectDeploy   jobKind = "vmselect-deploy"
	jobVmselectUndeploy jobKind = "vmselect-undeploy"
)

// job is a unit of long-running work that a Migration dispatches with
// single-flight semantics.
type job interface {
	Kind() jobKind
	Run(ctx context.Context) error
}

// artifactWriter is an optional interface a job may implement to write a
// detailed artifact.
//
// The artifact is persisted to <migration-dir>/artifacts/<jobId>.json.
// Migration calls WriteArtifact at most once, after Run returns nil. The
// record (id, startedAt, finishedAt) is passed so the artifact can embed the
// same identity and timestamps as jobs.jsonl.
type artifactWriter interface {
	WriteArtifact(path string, record *jobRecord) error
}

// warningSource exposes non-fatal, user-actionable problems discovered while
// a job runs. Migration persists them in the job record.
type warningSource interface {
	Warnings() []string
}
