store

package
v0.1.16-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package store provides PostgreSQL-backed data persistence using pgx and sqlc.

Index

Constants

View Source
const (

	// TargetSchemaVersion is the highest embedded Tern migration version.
	TargetSchemaVersion int32 = 6
)

Variables

View Source
var ErrBootstrapNodeExists = errors.New("store: bootstrap node already exists")

ErrBootstrapNodeExists is returned when bootstrap completion targets an already-enrolled node ID.

View Source
var ErrBootstrapTokenInvalid = errors.New("store: bootstrap token invalid")

ErrBootstrapTokenInvalid is returned when a bootstrap token is missing, revoked, already consumed, or bound to a different node.

View Source
var ErrEmptyNodeID = errors.New("store: ClaimJob requires non-empty nodeID")

ErrEmptyNodeID is returned when ClaimJob is called with an empty NodeID.

View Source
var ErrInvalidJSON = errors.New("store: invalid JSON for JSONB column")

ErrInvalidJSON is returned when a JSONB column receives invalid JSON bytes.

View Source
var ErrRunRestartActive = errors.New("store: only terminal runs can be restarted")

ErrRunRestartActive is returned when a non-terminal run is restarted.

View Source
var ErrRunRestartWaveCancelled = errors.New("store: cannot restart a run in a cancelled wave")

ErrRunRestartWaveCancelled is returned when the owning wave was cancelled.

View Source
var ErrUnsupportedSchema = errors.New("store: unsupported database schema for Tern adoption")

ErrUnsupportedSchema is returned when an existing database cannot be safely baselined into the Tern migration chain.

Functions

func CurrentSchemaVersion

func CurrentSchemaVersion(ctx context.Context, pool *pgxpool.Pool) (int32, error)

CurrentSchemaVersion returns the applied Tern schema version.

func FromPGUUID

func FromPGUUID[S ~string](u pgtype.UUID) S

FromPGUUID converts a pgtype.UUID to a string-like domain identifier. When the input is not valid, it returns the zero value for S (empty string).

func RunMigrations

func RunMigrations(ctx context.Context, pool *pgxpool.Pool) error

RunMigrations applies embedded Tern migrations. Existing databases from the final custom migration state are baselined at Tern version 1 so cleanup migration 2 can run normally on adoption.

func ToPGUUID

func ToPGUUID[S ~string](id S) pgtype.UUID

ToPGUUID converts a string-like domain identifier to pgtype.UUID. Empty or invalid UUID text returns the zero-value (Valid=false).

Types

type ApiToken

type ApiToken struct {
	ID          pgtype.UUID        `json:"id"`
	TokenHash   string             `json:"token_hash"`
	TokenID     string             `json:"token_id"`
	Role        string             `json:"role"`
	Username    *string            `json:"username"`
	Description *string            `json:"description"`
	IssuedAt    pgtype.Timestamptz `json:"issued_at"`
	ExpiresAt   pgtype.Timestamptz `json:"expires_at"`
	LastUsedAt  pgtype.Timestamptz `json:"last_used_at"`
	RevokedAt   pgtype.Timestamptz `json:"revoked_at"`
	CreatedBy   *string            `json:"created_by"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
}

type ArtifactBundle

type ArtifactBundle struct {
	ID         pgtype.UUID        `json:"id"`
	RunID      types.RunID        `json:"run_id"`
	JobID      *types.JobID       `json:"job_id"`
	Name       *string            `json:"name"`
	BundleSize int64              `json:"bundle_size"`
	ObjectKey  *string            `json:"object_key"`
	Cid        *string            `json:"cid"`
	Digest     *string            `json:"digest"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
}

type BootstrapToken

type BootstrapToken struct {
	ID           pgtype.UUID        `json:"id"`
	TokenHash    string             `json:"token_hash"`
	TokenID      string             `json:"token_id"`
	NodeID       *types.NodeID      `json:"node_id"`
	IssuedAt     pgtype.Timestamptz `json:"issued_at"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
	UsedAt       pgtype.Timestamptz `json:"used_at"`
	CertIssuedAt pgtype.Timestamptz `json:"cert_issued_at"`
	RevokedAt    pgtype.Timestamptz `json:"revoked_at"`
	IssuedBy     *string            `json:"issued_by"`
}

type CancelActiveJobsByRunAttemptParams

type CancelActiveJobsByRunAttemptParams struct {
	RunID   types.RunID `json:"run_id"`
	Attempt int32       `json:"attempt"`
}

type ClearRepoSHAChainFromJobParams

type ClearRepoSHAChainFromJobParams struct {
	ID      types.JobID `json:"id"`
	RunID   types.RunID `json:"run_id"`
	Attempt int32       `json:"attempt"`
}

type CompleteBootstrapEnrollmentParams

type CompleteBootstrapEnrollmentParams struct {
	TokenID         string
	NodeID          types.NodeID
	CertSerial      string
	CertFingerprint string
	CertNotBefore   time.Time
	CertNotAfter    time.Time
}

CompleteBootstrapEnrollmentParams contains the certificate metadata recorded when a one-time bootstrap token successfully enrolls a new node.

type ConfigBundleMap

type ConfigBundleMap struct {
	Hash      string             `json:"hash"`
	BundleID  string             `json:"bundle_id"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type ConfigEnv

type ConfigEnv struct {
	Key       string             `json:"key"`
	Target    string             `json:"target"`
	Value     string             `json:"value"`
	Secret    bool               `json:"secret"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type ConfigIn

type ConfigIn struct {
	Entry     string             `json:"entry"`
	Dst       string             `json:"dst"`
	Section   string             `json:"section"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type CountJobsByRunAndStatusParams

type CountJobsByRunAndStatusParams struct {
	RunID  types.RunID     `json:"run_id"`
	Status types.JobStatus `json:"status"`
}

type CountJobsByRunAttemptGroupByStatusParams

type CountJobsByRunAttemptGroupByStatusParams struct {
	RunID   types.RunID `json:"run_id"`
	Attempt int32       `json:"attempt"`
}

type CountJobsByRunAttemptGroupByStatusRow

type CountJobsByRunAttemptGroupByStatusRow struct {
	Status types.JobStatus `json:"status"`
	Count  int32           `json:"count"`
}

type CountRunsByWaveStatusRow

type CountRunsByWaveStatusRow struct {
	Status types.RunStatus `json:"status"`
	Count  int32           `json:"count"`
}

type CreateArtifactBundleParams

type CreateArtifactBundleParams struct {
	RunID      types.RunID  `json:"run_id"`
	JobID      *types.JobID `json:"job_id"`
	Name       *string      `json:"name"`
	BundleSize int64        `json:"bundle_size"`
	Cid        *string      `json:"cid"`
	Digest     *string      `json:"digest"`
}

type CreateDiffParams

type CreateDiffParams struct {
	RunID     types.RunID  `json:"run_id"`
	JobID     *types.JobID `json:"job_id"`
	PatchSize int64        `json:"patch_size"`
	Summary   []byte       `json:"summary"`
}

type CreateEventParams

type CreateEventParams struct {
	RunID   types.RunID        `json:"run_id"`
	JobID   *types.JobID       `json:"job_id"`
	Time    pgtype.Timestamptz `json:"time"`
	Level   string             `json:"level"`
	Message string             `json:"message"`
	Meta    []byte             `json:"meta"`
}

type CreateJobParams

type CreateJobParams struct {
	ID          types.JobID     `json:"id"`
	RunID       types.RunID     `json:"run_id"`
	RepoID      types.RepoID    `json:"repo_id"`
	RepoBaseRef string          `json:"repo_base_ref"`
	Attempt     int32           `json:"attempt"`
	Status      types.JobStatus `json:"status"`
	JobType     types.JobType   `json:"job_type"`
	JobImage    string          `json:"job_image"`
	NextID      *types.JobID    `json:"next_id"`
	Name        string          `json:"name"`
	Meta        []byte          `json:"meta"`
	RepoShaIn   string          `json:"repo_sha_in"`
}

type CreateLogParams

type CreateLogParams struct {
	RunID    types.RunID  `json:"run_id"`
	JobID    *types.JobID `json:"job_id"`
	ChunkNo  int32        `json:"chunk_no"`
	DataSize int64        `json:"data_size"`
}

type CreateMigParams

type CreateMigParams struct {
	ID        types.MigID   `json:"id"`
	Name      string        `json:"name"`
	SpecID    *types.SpecID `json:"spec_id"`
	CreatedBy *string       `json:"created_by"`
}

type CreateMigRepoParams

type CreateMigRepoParams struct {
	ID      types.MigRepoID `json:"id"`
	MigID   types.MigID     `json:"mig_id"`
	Url     string          `json:"url"`
	BaseRef string          `json:"base_ref"`
}

type CreateNamedSpecParams

type CreateNamedSpecParams struct {
	ID                types.SpecID       `json:"id"`
	Name              string             `json:"name"`
	Description       string             `json:"description"`
	Source            []byte             `json:"source"`
	Sha               string             `json:"sha"`
	SourceCommittedAt pgtype.Timestamptz `json:"source_committed_at"`
	Spec              []byte             `json:"spec"`
	CreatedBy         *string            `json:"created_by"`
}

type CreateNodeDaemonLogParams

type CreateNodeDaemonLogParams struct {
	NodeID    types.NodeID `json:"node_id"`
	Component string       `json:"component"`
	Stream    string       `json:"stream"`
	Message   string       `json:"message"`
}

type CreateNodeParams

type CreateNodeParams struct {
	ID          types.NodeID `json:"id"`
	Name        string       `json:"name"`
	IpAddress   netip.Addr   `json:"ip_address"`
	Version     *string      `json:"version"`
	Concurrency int32        `json:"concurrency"`
}

type CreateRunParams

type CreateRunParams struct {
	ID              types.RunID  `json:"id"`
	WaveID          types.WaveID `json:"wave_id"`
	MigID           types.MigID  `json:"mig_id"`
	SpecID          types.SpecID `json:"spec_id"`
	RepoID          types.RepoID `json:"repo_id"`
	RepoBaseRef     string       `json:"repo_base_ref"`
	SourceCommitSha string       `json:"source_commit_sha"`
	RepoSha0        string       `json:"repo_sha0"`
	CreatedBy       *string      `json:"created_by"`
}

type CreateSpecBundleParams

type CreateSpecBundleParams struct {
	ID        string  `json:"id"`
	Cid       string  `json:"cid"`
	Digest    string  `json:"digest"`
	Size      int64   `json:"size"`
	CreatedBy *string `json:"created_by"`
}

type CreateSpecParams

type CreateSpecParams struct {
	ID        types.SpecID `json:"id"`
	Name      string       `json:"name"`
	Spec      []byte       `json:"spec"`
	CreatedBy *string      `json:"created_by"`
}

type CreateWaveParams

type CreateWaveParams struct {
	ID        types.WaveID `json:"id"`
	MigID     types.MigID  `json:"mig_id"`
	SpecID    types.SpecID `json:"spec_id"`
	CreatedBy *string      `json:"created_by"`
}

type CreateWaveWithRunsParams

type CreateWaveWithRunsParams struct {
	Wave CreateWaveParams
	Runs []CreateRunParams
}

CreateWaveWithRunsParams contains the complete DB materialization for one launch.

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteConfigInParams

type DeleteConfigInParams struct {
	Dst     string `json:"dst"`
	Section string `json:"section"`
}

type DeleteGlobalEnvParams

type DeleteGlobalEnvParams struct {
	Key    string `json:"key"`
	Target string `json:"target"`
}

type Diff

type Diff struct {
	ID        pgtype.UUID        `json:"id"`
	RunID     types.RunID        `json:"run_id"`
	JobID     *types.JobID       `json:"job_id"`
	PatchSize int64              `json:"patch_size"`
	ObjectKey *string            `json:"object_key"`
	Summary   []byte             `json:"summary"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type Event

type Event struct {
	ID      int64              `json:"id"`
	RunID   types.RunID        `json:"run_id"`
	JobID   *types.JobID       `json:"job_id"`
	Time    pgtype.Timestamptz `json:"time"`
	Level   string             `json:"level"`
	Message string             `json:"message"`
	Meta    []byte             `json:"meta"`
}

type GetAPITokenByIDRow

type GetAPITokenByIDRow struct {
	TokenID     string             `json:"token_id"`
	Role        string             `json:"role"`
	Username    *string            `json:"username"`
	Description *string            `json:"description"`
	IssuedAt    pgtype.Timestamptz `json:"issued_at"`
	ExpiresAt   pgtype.Timestamptz `json:"expires_at"`
	LastUsedAt  pgtype.Timestamptz `json:"last_used_at"`
	RevokedAt   pgtype.Timestamptz `json:"revoked_at"`
	CreatedBy   *string            `json:"created_by"`
}

type GetAdjacentJobIndicesRow

type GetAdjacentJobIndicesRow struct {
	PrevID types.JobID  `json:"prev_id"`
	NextID *types.JobID `json:"next_id"`
}

type GetBootstrapTokenRow

type GetBootstrapTokenRow struct {
	NodeID       *types.NodeID      `json:"node_id"`
	IssuedAt     pgtype.Timestamptz `json:"issued_at"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
	UsedAt       pgtype.Timestamptz `json:"used_at"`
	CertIssuedAt pgtype.Timestamptz `json:"cert_issued_at"`
	RevokedAt    pgtype.Timestamptz `json:"revoked_at"`
}

type GetGlobalEnvParams

type GetGlobalEnvParams struct {
	Key    string `json:"key"`
	Target string `json:"target"`
}

type GetLatestRunByMigAndRepoStatusParams

type GetLatestRunByMigAndRepoStatusParams struct {
	MigID  types.MigID     `json:"mig_id"`
	RepoID types.RepoID    `json:"repo_id"`
	Status types.RunStatus `json:"status"`
}

type GetLatestRunByMigAndRepoStatusRow

type GetLatestRunByMigAndRepoStatusRow struct {
	RunID  types.RunID  `json:"run_id"`
	RepoID types.RepoID `json:"repo_id"`
}

type GetMigRepoByURLParams

type GetMigRepoByURLParams struct {
	MigID types.MigID `json:"mig_id"`
	Url   string      `json:"url"`
}

type GetNamedSpecByNameSourceSHAParams

type GetNamedSpecByNameSourceSHAParams struct {
	Name   string `json:"name"`
	Domain string `json:"domain"`
	Repo   string `json:"repo"`
	Sha    string `json:"sha"`
}

type GetRunSnapshotMetadataRow

type GetRunSnapshotMetadataRow struct {
	RunID           types.RunID  `json:"run_id"`
	RepoID          types.RepoID `json:"repo_id"`
	RepoBaseRef     string       `json:"repo_base_ref"`
	SourceCommitSha string       `json:"source_commit_sha"`
	RepoUrl         string       `json:"repo_url"`
}

type HasRunningJobForRunNodeParams

type HasRunningJobForRunNodeParams struct {
	RunID  types.RunID   `json:"run_id"`
	NodeID *types.NodeID `json:"node_id"`
}

type InsertAPITokenParams

type InsertAPITokenParams struct {
	TokenHash   string             `json:"token_hash"`
	TokenID     string             `json:"token_id"`
	Role        string             `json:"role"`
	Username    *string            `json:"username"`
	Description *string            `json:"description"`
	IssuedAt    pgtype.Timestamptz `json:"issued_at"`
	ExpiresAt   pgtype.Timestamptz `json:"expires_at"`
	CreatedBy   *string            `json:"created_by"`
}

type InsertBootstrapTokenParams

type InsertBootstrapTokenParams struct {
	TokenHash string             `json:"token_hash"`
	TokenID   string             `json:"token_id"`
	NodeID    *types.NodeID      `json:"node_id"`
	IssuedAt  pgtype.Timestamptz `json:"issued_at"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	IssuedBy  *string            `json:"issued_by"`
}

type Job

type Job struct {
	ID          types.JobID        `json:"id"`
	RunID       types.RunID        `json:"run_id"`
	RepoID      types.RepoID       `json:"repo_id"`
	RepoBaseRef string             `json:"repo_base_ref"`
	Attempt     int32              `json:"attempt"`
	Status      types.JobStatus    `json:"status"`
	JobType     types.JobType      `json:"job_type"`
	JobImage    string             `json:"job_image"`
	NextID      *types.JobID       `json:"next_id"`
	Name        string             `json:"name"`
	NodeID      *types.NodeID      `json:"node_id"`
	ExitCode    *int32             `json:"exit_code"`
	StartedAt   pgtype.Timestamptz `json:"started_at"`
	FinishedAt  pgtype.Timestamptz `json:"finished_at"`
	DurationMs  int64              `json:"duration_ms"`
	RepoShaIn   string             `json:"repo_sha_in"`
	RepoShaOut  string             `json:"repo_sha_out"`
	RepoShaIn8  string             `json:"repo_sha_in8"`
	RepoShaOut8 string             `json:"repo_sha_out8"`
	Meta        []byte             `json:"meta"`
}

type JobMetric

type JobMetric struct {
	ID                int64              `json:"id"`
	NodeID            types.NodeID       `json:"node_id"`
	JobID             types.JobID        `json:"job_id"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	CpuConsumedNs     int64              `json:"cpu_consumed_ns"`
	DiskConsumedBytes int64              `json:"disk_consumed_bytes"`
	MemConsumedBytes  int64              `json:"mem_consumed_bytes"`
}

type ListAPITokensRow

type ListAPITokensRow struct {
	TokenID     string             `json:"token_id"`
	Role        string             `json:"role"`
	Username    *string            `json:"username"`
	Description *string            `json:"description"`
	IssuedAt    pgtype.Timestamptz `json:"issued_at"`
	ExpiresAt   pgtype.Timestamptz `json:"expires_at"`
	LastUsedAt  pgtype.Timestamptz `json:"last_used_at"`
	RevokedAt   pgtype.Timestamptz `json:"revoked_at"`
	CreatedBy   *string            `json:"created_by"`
}

type ListArtifactBundlesByRunAndJobParams

type ListArtifactBundlesByRunAndJobParams struct {
	RunID types.RunID  `json:"run_id"`
	JobID *types.JobID `json:"job_id"`
}

type ListCreatedJobsByRunAttemptParams

type ListCreatedJobsByRunAttemptParams struct {
	RunID   types.RunID `json:"run_id"`
	Attempt int32       `json:"attempt"`
}

type ListDistinctReposRow

type ListDistinctReposRow struct {
	RepoID     types.RepoID       `json:"repo_id"`
	RepoUrl    string             `json:"repo_url"`
	LastRunAt  pgtype.Timestamptz `json:"last_run_at"`
	LastStatus interface{}        `json:"last_status"`
}

type ListEventsByRunSinceParams

type ListEventsByRunSinceParams struct {
	RunID types.RunID `json:"run_id"`
	ID    int64       `json:"id"`
}

type ListJobsByRunAttemptParams

type ListJobsByRunAttemptParams struct {
	RunID   types.RunID `json:"run_id"`
	Attempt int32       `json:"attempt"`
}

type ListJobsForTUIParams

type ListJobsForTUIParams struct {
	Limit  int32   `json:"limit"`
	Offset int32   `json:"offset"`
	RunID  *string `json:"run_id"`
}

type ListJobsForTUIRow

type ListJobsForTUIRow struct {
	JobID      types.JobID     `json:"job_id"`
	Name       string          `json:"name"`
	JobType    types.JobType   `json:"job_type"`
	Status     types.JobStatus `json:"status"`
	DurationMs int64           `json:"duration_ms"`
	JobImage   string          `json:"job_image"`
	NodeID     *types.NodeID   `json:"node_id"`
	MigName    string          `json:"mig_name"`
	RunID      types.RunID     `json:"run_id"`
	RepoID     types.RepoID    `json:"repo_id"`
}

type ListLatestNamedSpecsParams

type ListLatestNamedSpecsParams struct {
	Limit    int32 `json:"limit"`
	Offset   int32 `json:"offset"`
	Archived bool  `json:"archived"`
}

type ListLatestNamedSpecsRow

type ListLatestNamedSpecsRow struct {
	ID                string             `json:"id"`
	Name              string             `json:"name"`
	Description       string             `json:"description"`
	Source            []byte             `json:"source"`
	Sha               string             `json:"sha"`
	SourceCommittedAt pgtype.Timestamptz `json:"source_committed_at"`
	Spec              []byte             `json:"spec"`
	CreatedBy         *string            `json:"created_by"`
	UpdatedBy         *string            `json:"updated_by"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	ArchivedAt        pgtype.Timestamptz `json:"archived_at"`
}

type ListLogsByRunAndJobParams

type ListLogsByRunAndJobParams struct {
	RunID types.RunID  `json:"run_id"`
	JobID *types.JobID `json:"job_id"`
}

type ListLogsByRunAndJobSinceParams

type ListLogsByRunAndJobSinceParams struct {
	RunID types.RunID  `json:"run_id"`
	JobID *types.JobID `json:"job_id"`
	ID    int64        `json:"id"`
}

type ListLogsByRunSinceParams

type ListLogsByRunSinceParams struct {
	RunID types.RunID `json:"run_id"`
	ID    int64       `json:"id"`
}

type ListMigsParams

type ListMigsParams struct {
	Limit        int32   `json:"limit"`
	Offset       int32   `json:"offset"`
	ArchivedOnly *bool   `json:"archived_only"`
	NameFilter   *string `json:"name_filter"`
}

type ListNodeDaemonLogsParams

type ListNodeDaemonLogsParams struct {
	NodeID     types.NodeID `json:"node_id"`
	Component  *string      `json:"component"`
	LimitCount int32        `json:"limit_count"`
}

type ListRunSBOMRowsByJobTypeParams

type ListRunSBOMRowsByJobTypeParams struct {
	RunID   types.RunID   `json:"run_id"`
	JobType types.JobType `json:"job_type"`
}

type ListRunSBOMRowsByJobTypeRow

type ListRunSBOMRowsByJobTypeRow struct {
	Lib string `json:"lib"`
	Ver string `json:"ver"`
}

type ListRunsForRepoParams

type ListRunsForRepoParams struct {
	RepoID types.RepoID `json:"repo_id"`
	Limit  int32        `json:"limit"`
	Offset int32        `json:"offset"`
}

type ListRunsForRepoRow

type ListRunsForRepoRow struct {
	RunID       types.RunID        `json:"run_id"`
	WaveID      types.WaveID       `json:"wave_id"`
	MigID       types.MigID        `json:"mig_id"`
	Status      types.RunStatus    `json:"status"`
	RepoBaseRef string             `json:"repo_base_ref"`
	Attempt     int32              `json:"attempt"`
	StartedAt   pgtype.Timestamptz `json:"started_at"`
	FinishedAt  pgtype.Timestamptz `json:"finished_at"`
}

type ListRunsParams

type ListRunsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListRunsTimingsParams

type ListRunsTimingsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListRunsWithMetadataParams

type ListRunsWithMetadataParams struct {
	AllRuns    bool   `json:"all_runs"`
	CreatedBy  string `json:"created_by"`
	RepoUrl    string `json:"repo_url"`
	OffsetRows int32  `json:"offset_rows"`
	LimitRows  int32  `json:"limit_rows"`
}

type ListRunsWithMetadataRow

type ListRunsWithMetadataRow struct {
	ID               types.RunID        `json:"id"`
	WaveID           types.WaveID       `json:"wave_id"`
	MigID            types.MigID        `json:"mig_id"`
	SpecID           types.SpecID       `json:"spec_id"`
	RepoID           types.RepoID       `json:"repo_id"`
	RepoBaseRef      string             `json:"repo_base_ref"`
	SourceCommitSha  string             `json:"source_commit_sha"`
	RepoSha0         string             `json:"repo_sha0"`
	CreatedBy        *string            `json:"created_by"`
	Status           types.RunStatus    `json:"status"`
	Attempt          int32              `json:"attempt"`
	LastError        *string            `json:"last_error"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	StartedAt        pgtype.Timestamptz `json:"started_at"`
	FinishedAt       pgtype.Timestamptz `json:"finished_at"`
	Stats            []byte             `json:"stats"`
	RepoUrl          string             `json:"repo_url"`
	SpecName         string             `json:"spec_name"`
	SpecSourceDomain string             `json:"spec_source_domain"`
	SpecSourceRepo   string             `json:"spec_source_repo"`
}

type ListRunsWithURLByWaveRow

type ListRunsWithURLByWaveRow struct {
	ID              types.RunID        `json:"id"`
	WaveID          types.WaveID       `json:"wave_id"`
	MigID           types.MigID        `json:"mig_id"`
	SpecID          types.SpecID       `json:"spec_id"`
	RepoID          types.RepoID       `json:"repo_id"`
	RepoBaseRef     string             `json:"repo_base_ref"`
	SourceCommitSha string             `json:"source_commit_sha"`
	RepoSha0        string             `json:"repo_sha0"`
	CreatedBy       *string            `json:"created_by"`
	Status          types.RunStatus    `json:"status"`
	Attempt         int32              `json:"attempt"`
	LastError       *string            `json:"last_error"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	StartedAt       pgtype.Timestamptz `json:"started_at"`
	FinishedAt      pgtype.Timestamptz `json:"finished_at"`
	Stats           []byte             `json:"stats"`
	RepoUrl         string             `json:"repo_url"`
}

type ListSpecBundlesParams

type ListSpecBundlesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListSpecsParams

type ListSpecsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListStaleRunningJobsRow

type ListStaleRunningJobsRow struct {
	RunID       types.RunID `json:"run_id"`
	Attempt     int32       `json:"attempt"`
	RunningJobs int32       `json:"running_jobs"`
}

type ListWavesByMigParams

type ListWavesByMigParams struct {
	MigID  types.MigID `json:"mig_id"`
	Limit  int32       `json:"limit"`
	Offset int32       `json:"offset"`
}

type ListWavesParams

type ListWavesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type Log

type Log struct {
	ID        int64              `json:"id"`
	RunID     types.RunID        `json:"run_id"`
	JobID     *types.JobID       `json:"job_id"`
	ChunkNo   int32              `json:"chunk_no"`
	DataSize  int64              `json:"data_size"`
	ObjectKey *string            `json:"object_key"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type Mig

type Mig struct {
	ID         types.MigID        `json:"id"`
	Name       string             `json:"name"`
	SpecID     *types.SpecID      `json:"spec_id"`
	CreatedBy  *string            `json:"created_by"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
	ArchivedAt pgtype.Timestamptz `json:"archived_at"`
}

type MigRepo

type MigRepo struct {
	ID        types.MigRepoID    `json:"id"`
	MigID     types.MigID        `json:"mig_id"`
	RepoID    types.RepoID       `json:"repo_id"`
	BaseRef   string             `json:"base_ref"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type Node

type Node struct {
	ID              types.NodeID       `json:"id"`
	Name            string             `json:"name"`
	IpAddress       netip.Addr         `json:"ip_address"`
	Version         *string            `json:"version"`
	Concurrency     int32              `json:"concurrency"`
	CpuTotalMillis  int32              `json:"cpu_total_millis"`
	CpuFreeMillis   int32              `json:"cpu_free_millis"`
	MemTotalBytes   int64              `json:"mem_total_bytes"`
	MemFreeBytes    int64              `json:"mem_free_bytes"`
	DiskTotalBytes  int64              `json:"disk_total_bytes"`
	DiskFreeBytes   int64              `json:"disk_free_bytes"`
	Drained         bool               `json:"drained"`
	CertSerial      *string            `json:"cert_serial"`
	CertFingerprint *string            `json:"cert_fingerprint"`
	CertNotBefore   pgtype.Timestamptz `json:"cert_not_before"`
	CertNotAfter    pgtype.Timestamptz `json:"cert_not_after"`
	LastHeartbeat   pgtype.Timestamptz `json:"last_heartbeat"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
}

type NodeDaemonLog

type NodeDaemonLog struct {
	ID        int64              `json:"id"`
	NodeID    types.NodeID       `json:"node_id"`
	Component string             `json:"component"`
	Stream    string             `json:"stream"`
	Message   string             `json:"message"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type NodeDiagnostic

type NodeDiagnostic struct {
	NodeID        types.NodeID       `json:"node_id"`
	Component     string             `json:"component"`
	Status        string             `json:"status"`
	LastError     *string            `json:"last_error"`
	Version       *string            `json:"version"`
	ImageRef      *string            `json:"image_ref"`
	LocalImageID  *string            `json:"local_image_id"`
	RemoteImageID *string            `json:"remote_image_id"`
	Details       []byte             `json:"details"`
	LastCheckedAt pgtype.Timestamptz `json:"last_checked_at"`
	LastSuccessAt pgtype.Timestamptz `json:"last_success_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

type NodeMetric

type NodeMetric struct {
	ID             int64              `json:"id"`
	NodeID         types.NodeID       `json:"node_id"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	CpuTotalMillis int32              `json:"cpu_total_millis"`
	CpuFreeMillis  int32              `json:"cpu_free_millis"`
	MemTotalBytes  int64              `json:"mem_total_bytes"`
	MemFreeBytes   int64              `json:"mem_free_bytes"`
	DiskTotalBytes int64              `json:"disk_total_bytes"`
	DiskFreeBytes  int64              `json:"disk_free_bytes"`
}

type PgStore

type PgStore struct {
	*Queries
	// contains filtered or unexported fields
}

PgStore wraps a pgxpool connection pool and implements Store.

func (*PgStore) CancelRun

func (s *PgStore) CancelRun(ctx context.Context, runID types.RunID) error

CancelRun atomically cancels one run and all active child jobs.

func (*PgStore) CancelWave

func (s *PgStore) CancelWave(ctx context.Context, waveID types.WaveID) error

CancelWave atomically cancels one wave and all active child runs/jobs.

func (*PgStore) ClaimJob

func (s *PgStore) ClaimJob(ctx context.Context, nodeID types.NodeID) (Job, error)

ClaimJob atomically claims the next claimable job for a node. Requires a non-empty nodeID; returns ErrEmptyNodeID if the nodeID is empty. This prevents jobs from entering Running state with node_id=NULL.

func (*PgStore) Close

func (s *PgStore) Close()

Close releases all resources held by the store.

func (*PgStore) CompleteBootstrapEnrollment

func (s *PgStore) CompleteBootstrapEnrollment(ctx context.Context, arg CompleteBootstrapEnrollmentParams) error

CompleteBootstrapEnrollment atomically consumes one bootstrap token and creates the node it was minted for.

func (*PgStore) CreateDiff

func (s *PgStore) CreateDiff(ctx context.Context, arg CreateDiffParams) (Diff, error)

CreateDiff validates the Summary JSONB field and creates a new diff.

func (*PgStore) CreateJob

func (s *PgStore) CreateJob(ctx context.Context, arg CreateJobParams) (Job, error)

CreateJob validates the Meta JSONB field and creates a new job.

func (*PgStore) CreateNamedSpec

func (s *PgStore) CreateNamedSpec(ctx context.Context, arg CreateNamedSpecParams) (Spec, error)

CreateNamedSpec validates JSONB fields and creates a new named spec.

func (*PgStore) CreateSpec

func (s *PgStore) CreateSpec(ctx context.Context, arg CreateSpecParams) (Spec, error)

CreateSpec validates the Spec JSONB field and creates a new spec.

func (*PgStore) CreateWaveWithRuns

func (s *PgStore) CreateWaveWithRuns(ctx context.Context, arg CreateWaveWithRunsParams) (Wave, []Run, error)

CreateWaveWithRuns atomically creates a wave and its selected run rows.

func (*PgStore) Pool

func (s *PgStore) Pool() *pgxpool.Pool

Pool returns the underlying connection pool. This is useful for operations that need direct pool access, such as partition management.

func (*PgStore) RestartRun

func (s *PgStore) RestartRun(ctx context.Context, runID types.RunID) (Run, error)

RestartRun atomically resets one terminal run to Queued on the next attempt.

func (*PgStore) UnclaimJob

func (s *PgStore) UnclaimJob(ctx context.Context, arg UnclaimJobParams) error

UnclaimJob reverts a claimed Running job back to claimable Queued state. The update is guarded by both job ID and node ID to avoid stealing claims.

func (*PgStore) UpdateJobCompletionWithMeta

func (s *PgStore) UpdateJobCompletionWithMeta(ctx context.Context, arg UpdateJobCompletionWithMetaParams) error

UpdateJobCompletionWithMeta validates the Meta JSONB field and completes a job with metadata.

func (*PgStore) UpdateJobMeta

func (s *PgStore) UpdateJobMeta(ctx context.Context, arg UpdateJobMetaParams) error

UpdateJobMeta validates the Meta JSONB field and updates job metadata.

func (*PgStore) UpdateWaveCompletion

func (s *PgStore) UpdateWaveCompletion(ctx context.Context, arg UpdateWaveCompletionParams) error

UpdateWaveCompletion validates the Stats JSONB field and completes a wave.

func (*PgStore) UpsertNodeDiagnostic

func (s *PgStore) UpsertNodeDiagnostic(ctx context.Context, arg UpsertNodeDiagnosticParams) (NodeDiagnostic, error)

UpsertNodeDiagnostic validates the Details JSONB field and stores daemon state.

type Querier

type Querier interface {
	// Archives a mig by setting archived_at to now().
	// Archiving must be refused when the mig has any jobs in a running state.
	// This query only sets the timestamp; validation logic must be in the caller.
	ArchiveMig(ctx context.Context, id types.MigID) error
	// Bulk-cancels active jobs for a run (Created/Queued/Running -> Cancelled).
	// finished_at is set once; duration_ms is computed from started_at when present.
	CancelActiveJobsByRun(ctx context.Context, runID types.RunID) (int64, error)
	// Bulk-cancels active jobs for a specific run attempt.
	// Targets Created/Queued/Running and preserves terminal jobs.
	// finished_at is set once; duration_ms is computed from started_at when present.
	CancelActiveJobsByRunAttempt(ctx context.Context, arg CancelActiveJobsByRunAttemptParams) (int64, error)
	CancelActiveRunsByWave(ctx context.Context, waveID types.WaveID) (int64, error)
	CheckAPITokenRevoked(ctx context.Context, tokenID string) (pgtype.Timestamptz, error)
	CheckBootstrapTokenRevoked(ctx context.Context, tokenID string) (pgtype.Timestamptz, error)
	// Atomically claim the next claimable job for a node.
	ClaimJob(ctx context.Context, nodeID types.NodeID) (Job, error)
	ClearRepoSHAChainFromJob(ctx context.Context, arg ClearRepoSHAChainFromJobParams) (int64, error)
	CountJobsByRun(ctx context.Context, runID types.RunID) (int64, error)
	CountJobsByRunAndStatus(ctx context.Context, arg CountJobsByRunAndStatusParams) (int64, error)
	// Counts jobs by status for a specific run attempt.
	// Used by terminal detection to determine runs.status.
	CountJobsByRunAttemptGroupByStatus(ctx context.Context, arg CountJobsByRunAttemptGroupByStatusParams) ([]CountJobsByRunAttemptGroupByStatusRow, error)
	// Counts jobs with optional run_id filter.
	// run_id: if non-null, count jobs for that run; if null, count all jobs.
	// Used with ListJobsForTUI to provide total for TUI pagination.
	CountJobsForTUI(ctx context.Context, runID *string) (int64, error)
	CountRunsByWaveStatus(ctx context.Context, waveID types.WaveID) ([]CountRunsByWaveStatusRow, error)
	// Counts distinct stale nodes that currently have at least one running job.
	// Excludes NULL node_id rows (orphaned running jobs) from node count.
	CountStaleNodesWithRunningJobs(ctx context.Context, lastHeartbeat pgtype.Timestamptz) (int64, error)
	// Creates a new artifact bundle metadata. Blob data is stored in object storage.
	// Bundles are grouped at the job level only (build_id removed).
	CreateArtifactBundle(ctx context.Context, arg CreateArtifactBundleParams) (ArtifactBundle, error)
	// Creates a new diff entry associated with a job. Blob data is stored in object storage.
	CreateDiff(ctx context.Context, arg CreateDiffParams) (Diff, error)
	CreateEvent(ctx context.Context, arg CreateEventParams) (Event, error)
	// Note: `id` is a required TEXT parameter (KSUID-backed); caller generates via types.NewJobID().
	CreateJob(ctx context.Context, arg CreateJobParams) (Job, error)
	// Creates a new log chunk metadata. Blob data is stored in object storage.
	// Logs are grouped at the job level only (build_id removed).
	CreateLog(ctx context.Context, arg CreateLogParams) (Log, error)
	CreateMig(ctx context.Context, arg CreateMigParams) (Mig, error)
	CreateMigRepo(ctx context.Context, arg CreateMigRepoParams) (MigRepo, error)
	CreateNamedSpec(ctx context.Context, arg CreateNamedSpecParams) (Spec, error)
	// Creates a new node with an application-supplied URL-safe ID as the primary key.
	CreateNode(ctx context.Context, arg CreateNodeParams) (Node, error)
	CreateNodeDaemonLog(ctx context.Context, arg CreateNodeDaemonLogParams) (NodeDaemonLog, error)
	CreateRun(ctx context.Context, arg CreateRunParams) (Run, error)
	CreateSpec(ctx context.Context, arg CreateSpecParams) (Spec, error)
	// Creates a new spec bundle metadata row. Blob data is stored in object storage.
	CreateSpecBundle(ctx context.Context, arg CreateSpecBundleParams) (SpecBundle, error)
	CreateWave(ctx context.Context, arg CreateWaveParams) (Wave, error)
	DeleteArtifactBundle(ctx context.Context, id pgtype.UUID) error
	DeleteArtifactBundlesOlderThan(ctx context.Context, createdAt pgtype.Timestamptz) error
	// Removes a bundle map entry by hash.
	DeleteConfigBundleMap(ctx context.Context, hash string) error
	// Removes an in entry by dst and section.
	DeleteConfigIn(ctx context.Context, arg DeleteConfigInParams) error
	// Removes all in entries for a section.
	DeleteConfigInBySection(ctx context.Context, section string) error
	DeleteDiff(ctx context.Context, id pgtype.UUID) error
	DeleteDiffsOlderThan(ctx context.Context, createdAt pgtype.Timestamptz) error
	// DeleteExpiredArtifactBundles removes artifact bundle rows older than the specified timestamp.
	DeleteExpiredArtifactBundles(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)
	// DeleteExpiredDiffs removes diff rows older than the specified timestamp.
	DeleteExpiredDiffs(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)
	// DeleteExpiredEvents removes event rows older than the specified timestamp.
	DeleteExpiredEvents(ctx context.Context, time pgtype.Timestamptz) (int64, error)
	// DeleteExpiredLogs removes log rows older than the specified timestamp.
	DeleteExpiredLogs(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)
	// Removes an environment entry by key and target.
	// No-op if the (key, target) pair does not exist (exec returns no error).
	DeleteGlobalEnv(ctx context.Context, arg DeleteGlobalEnvParams) error
	DeleteJob(ctx context.Context, id types.JobID) error
	DeleteLog(ctx context.Context, id int64) error
	DeleteLogsOlderThan(ctx context.Context, createdAt pgtype.Timestamptz) error
	// Deletes a mig. Use with caution; should only be called when safe to remove.
	DeleteMig(ctx context.Context, id types.MigID) error
	// Deletes a mig_repo by id.
	// Note: mig_repos.id remains referenced by API-level repo membership records.
	DeleteMigRepo(ctx context.Context, id types.MigRepoID) error
	DeleteNode(ctx context.Context, id types.NodeID) error
	DeleteRun(ctx context.Context, id types.RunID) error
	DeleteSBOMRowsByJob(ctx context.Context, jobID types.JobID) error
	// Deletes a spec bundle metadata row by ID.
	// Called by blobpersist as rollback when object storage upload fails.
	DeleteSpecBundle(ctx context.Context, id string) error
	DeleteWave(ctx context.Context, id types.WaveID) error
	GetAPITokenByID(ctx context.Context, tokenID string) (GetAPITokenByIDRow, error)
	// Transitional: returns current job id and linked successor id.
	GetAdjacentJobIndices(ctx context.Context, id types.JobID) (GetAdjacentJobIndicesRow, error)
	// Returns artifact bundle metadata including object_key for object-storage retrieval.
	GetArtifactBundle(ctx context.Context, id pgtype.UUID) (ArtifactBundle, error)
	GetBootstrapToken(ctx context.Context, tokenID string) (GetBootstrapTokenRow, error)
	GetEvent(ctx context.Context, id int64) (Event, error)
	// Retrieves a single environment entry by key and target.
	// Returns pgx.ErrNoRows if the (key, target) pair does not exist.
	GetGlobalEnv(ctx context.Context, arg GetGlobalEnvParams) (ConfigEnv, error)
	GetJob(ctx context.Context, id types.JobID) (Job, error)
	GetLatestDiffByJob(ctx context.Context, jobID *types.JobID) (Diff, error)
	GetLatestRunByMigAndRepoStatus(ctx context.Context, arg GetLatestRunByMigAndRepoStatusParams) (GetLatestRunByMigAndRepoStatusRow, error)
	// Returns log metadata including object_key for object-storage retrieval.
	GetLog(ctx context.Context, id int64) (Log, error)
	GetMig(ctx context.Context, id types.MigID) (Mig, error)
	GetMigByName(ctx context.Context, name string) (Mig, error)
	GetMigRepo(ctx context.Context, id types.MigRepoID) (MigRepo, error)
	// Gets a mig_repo by mig_id and repo_url (for uniqueness constraint enforcement).
	GetMigRepoByURL(ctx context.Context, arg GetMigRepoByURLParams) (MigRepo, error)
	GetNamedSpecByNameSourceSHA(ctx context.Context, arg GetNamedSpecByNameSourceSHAParams) (Spec, error)
	GetNode(ctx context.Context, id types.NodeID) (Node, error)
	GetRepo(ctx context.Context, id types.RepoID) (Repo, error)
	GetRun(ctx context.Context, id types.RunID) (Run, error)
	GetRunSnapshotMetadata(ctx context.Context, id types.RunID) (GetRunSnapshotMetadataRow, error)
	GetRunTiming(ctx context.Context, id types.RunID) (RunsTiming, error)
	GetSpec(ctx context.Context, id types.SpecID) (Spec, error)
	// Returns spec bundle metadata including object_key for object-storage retrieval.
	GetSpecBundle(ctx context.Context, id string) (SpecBundle, error)
	// Returns the most recently created spec bundle for a given cid.
	// Used for deduplication: callers should check by CID before uploading.
	GetSpecBundleByCID(ctx context.Context, cid string) (SpecBundle, error)
	GetWave(ctx context.Context, id types.WaveID) (Wave, error)
	// Checks if a mig_repo has any historical executions.
	// Returns true if the repo cannot be deleted due to history, false otherwise.
	HasMigRepoHistory(ctx context.Context, repoID types.RepoID) (bool, error)
	HasRunningJobForRunNode(ctx context.Context, arg HasRunningJobForRunNodeParams) (bool, error)
	IncrementRunAttempt(ctx context.Context, id types.RunID) error
	InsertAPIToken(ctx context.Context, arg InsertAPITokenParams) error
	InsertBootstrapToken(ctx context.Context, arg InsertBootstrapTokenParams) error
	ListAPITokens(ctx context.Context) ([]ListAPITokensRow, error)
	// ListArtifactBundlePartitions retrieves all partition names for the artifact_bundles table.
	ListArtifactBundlePartitions(ctx context.Context) ([]string, error)
	// Returns artifact bundle metadata including object_key for object-storage retrieval.
	ListArtifactBundlesByCID(ctx context.Context, cid *string) ([]ArtifactBundle, error)
	// Returns artifact bundle metadata including object_key for object-storage retrieval.
	ListArtifactBundlesByRun(ctx context.Context, runID types.RunID) ([]ArtifactBundle, error)
	// Returns artifact bundle metadata including object_key for object-storage retrieval.
	ListArtifactBundlesByRunAndJob(ctx context.Context, arg ListArtifactBundlesByRunAndJobParams) ([]ArtifactBundle, error)
	// config_bundle_map.sql — CRUD queries for global bundle map entries (config_bundle_map table).
	// Provides ListConfigBundleMap, UpsertConfigBundleMap, DeleteConfigBundleMap.
	// Returns all bundle map entries ordered by hash for deterministic iteration.
	ListConfigBundleMap(ctx context.Context) ([]ConfigBundleMap, error)
	// config_in.sql — CRUD queries for global in mount entries (config_in table).
	// Provides ListConfigIn, UpsertConfigIn, DeleteConfigIn, DeleteConfigInBySection.
	// Returns all in entries ordered by section then dst for deterministic iteration.
	ListConfigIn(ctx context.Context) ([]ConfigIn, error)
	// Returns in entries for a specific section ordered by dst.
	ListConfigInBySection(ctx context.Context, section string) ([]ConfigIn, error)
	ListCreatedJobsByRunAttempt(ctx context.Context, arg ListCreatedJobsByRunAttemptParams) ([]Job, error)
	// Returns diff metadata for a run.
	ListDiffsByRun(ctx context.Context, runID types.RunID) ([]Diff, error)
	// Lists distinct repos for a mig with last known run metadata,
	// optionally filtered by repo_url substring.
	ListDistinctRepos(ctx context.Context, filter string) ([]ListDistinctReposRow, error)
	// ListEventPartitions retrieves all partition names for the events table.
	ListEventPartitions(ctx context.Context) ([]string, error)
	ListEventsByRun(ctx context.Context, runID types.RunID) ([]Event, error)
	ListEventsByRunSince(ctx context.Context, arg ListEventsByRunSinceParams) ([]Event, error)
	ListFailedRepoIDsByMig(ctx context.Context, migID types.MigID) ([]types.RepoID, error)
	// config_env.sql — CRUD queries for global environment variables (config_env table).
	// Provides ListGlobalEnv, GetGlobalEnv, UpsertGlobalEnv, DeleteGlobalEnv.
	// Returns all global environment entries, ordered by key then target for consistent iteration.
	// Used by ConfigHolder initialization and HTTP list endpoint.
	ListGlobalEnv(ctx context.Context) ([]ConfigEnv, error)
	ListJobsByRun(ctx context.Context, runID types.RunID) ([]Job, error)
	ListJobsByRunAttempt(ctx context.Context, arg ListJobsByRunAttemptParams) ([]Job, error)
	// Lists jobs with optional run_id filter, ordered newest-to-oldest by job id.
	// run_id: if non-null, filter to jobs for that run; if null, return all jobs.
	// Joins runs and migs to surface mig_name per job for the TUI jobs-list screen.
	ListJobsForTUI(ctx context.Context, arg ListJobsForTUIParams) ([]ListJobsForTUIRow, error)
	ListLatestNamedSpecs(ctx context.Context, arg ListLatestNamedSpecsParams) ([]ListLatestNamedSpecsRow, error)
	// ListLogPartitions retrieves all partition names for the logs table.
	ListLogPartitions(ctx context.Context) ([]string, error)
	// Returns log metadata including object_key for object-storage retrieval.
	ListLogsByRun(ctx context.Context, runID types.RunID) ([]Log, error)
	// Returns log metadata including object_key for object-storage retrieval.
	ListLogsByRunAndJob(ctx context.Context, arg ListLogsByRunAndJobParams) ([]Log, error)
	// Returns log metadata including object_key for object-storage retrieval.
	ListLogsByRunAndJobSince(ctx context.Context, arg ListLogsByRunAndJobSinceParams) ([]Log, error)
	// Returns log metadata including object_key for object-storage retrieval.
	ListLogsByRunSince(ctx context.Context, arg ListLogsByRunSinceParams) ([]Log, error)
	ListMigReposByMig(ctx context.Context, migID types.MigID) ([]MigRepo, error)
	// Lists migs with optional filtering by archived status and name substring.
	// archived_only: if true, return only archived migs; if false, return only active migs; if null, return all.
	// name_filter: if non-empty, filter by name substring (case-insensitive); if null/empty, no name filtering.
	ListMigs(ctx context.Context, arg ListMigsParams) ([]Mig, error)
	ListNodeDaemonLogs(ctx context.Context, arg ListNodeDaemonLogsParams) ([]NodeDaemonLog, error)
	ListNodeDiagnostics(ctx context.Context, nodeID types.NodeID) ([]NodeDiagnostic, error)
	// ListNodeMetricsPartitions retrieves all partition names for the node_metrics table.
	ListNodeMetricsPartitions(ctx context.Context) ([]string, error)
	ListNodes(ctx context.Context) ([]Node, error)
	ListQueuedRunsByWave(ctx context.Context, waveID types.WaveID) ([]Run, error)
	ListRunSBOMRowsByJobType(ctx context.Context, arg ListRunSBOMRowsByJobTypeParams) ([]ListRunSBOMRowsByJobTypeRow, error)
	ListRuns(ctx context.Context, arg ListRunsParams) ([]Run, error)
	ListRunsByWave(ctx context.Context, waveID types.WaveID) ([]Run, error)
	ListRunsForRepo(ctx context.Context, arg ListRunsForRepoParams) ([]ListRunsForRepoRow, error)
	ListRunsTimings(ctx context.Context, arg ListRunsTimingsParams) ([]RunsTiming, error)
	ListRunsWithMetadata(ctx context.Context, arg ListRunsWithMetadataParams) ([]ListRunsWithMetadataRow, error)
	ListRunsWithURLByWave(ctx context.Context, waveID types.WaveID) ([]ListRunsWithURLByWaveRow, error)
	// Lists spec bundles ordered by created_at descending (most recent first).
	ListSpecBundles(ctx context.Context, arg ListSpecBundlesParams) ([]SpecBundle, error)
	// Lists spec bundles whose last_ref_at is before the given threshold.
	// Used by GC to find bundles eligible for deletion.
	ListSpecBundlesUnreferencedBefore(ctx context.Context, lastRefAt pgtype.Timestamptz) ([]SpecBundle, error)
	// Lists specs ordered by created_at descending (most recent first).
	// There is an index on created_at to optimize this query.
	ListSpecs(ctx context.Context, arg ListSpecsParams) ([]Spec, error)
	// Lists running jobs whose assigned node is stale at the provided cutoff.
	// Rows are grouped by (run_id, attempt) for deterministic recovery processing.
	ListStaleRunningJobs(ctx context.Context, lastHeartbeat pgtype.Timestamptz) ([]ListStaleRunningJobsRow, error)
	ListWaves(ctx context.Context, arg ListWavesParams) ([]Wave, error)
	ListWavesByMig(ctx context.Context, arg ListWavesByMigParams) ([]Wave, error)
	ListWavesWithQueuedRuns(ctx context.Context) ([]types.WaveID, error)
	MarkBootstrapTokenCertIssued(ctx context.Context, tokenID string) error
	// Atomically promote a specific linked successor job: Created -> Queued.
	// The candidate is eligible only when every predecessor that points to it is Success.
	PromoteJobByIDIfUnblocked(ctx context.Context, id types.JobID) (Job, error)
	ResolveLatestNamedSpecByDomainRepoName(ctx context.Context, arg ResolveLatestNamedSpecByDomainRepoNameParams) ([]ResolveLatestNamedSpecByDomainRepoNameRow, error)
	ResolveLatestNamedSpecByName(ctx context.Context, arg ResolveLatestNamedSpecByNameParams) ([]ResolveLatestNamedSpecByNameRow, error)
	ResolveLatestNamedSpecByRepoName(ctx context.Context, arg ResolveLatestNamedSpecByRepoNameParams) ([]ResolveLatestNamedSpecByRepoNameRow, error)
	ResolveNamedSpecVersionByDomainRepoName(ctx context.Context, arg ResolveNamedSpecVersionByDomainRepoNameParams) ([]Spec, error)
	ResolveNamedSpecVersionByName(ctx context.Context, arg ResolveNamedSpecVersionByNameParams) ([]Spec, error)
	ResolveNamedSpecVersionByRepoName(ctx context.Context, arg ResolveNamedSpecVersionByRepoNameParams) ([]Spec, error)
	RevokeAPIToken(ctx context.Context, tokenID string) error
	// Atomically promote the next unblocked job in a run attempt: Created -> Queued.
	// A created job is unblocked when all predecessor jobs that point to it are Success.
	ScheduleNextJob(ctx context.Context, arg ScheduleNextJobParams) (Job, error)
	TrimNodeDaemonLogs(ctx context.Context, arg TrimNodeDaemonLogsParams) error
	// Unarchives a mig by clearing archived_at.
	UnarchiveMig(ctx context.Context, id types.MigID) error
	// Revert a claimed Running job back to claimable Queued state.
	// Guarded by both job id and node id so a foreign node cannot steal the slot.
	UnclaimJob(ctx context.Context, arg UnclaimJobParams) error
	UpdateAPITokenLastUsed(ctx context.Context, tokenID string) error
	UpdateBootstrapTokenLastUsed(ctx context.Context, tokenID string) error
	UpdateJobCompletion(ctx context.Context, arg UpdateJobCompletionParams) error
	UpdateJobCompletionWithMeta(ctx context.Context, arg UpdateJobCompletionWithMetaParams) error
	// Persist the container image name used to execute a job.
	// This is set by the node immediately before job execution starts.
	UpdateJobImageName(ctx context.Context, arg UpdateJobImageNameParams) error
	UpdateJobMeta(ctx context.Context, arg UpdateJobMetaParams) error
	UpdateJobNextID(ctx context.Context, arg UpdateJobNextIDParams) error
	UpdateJobRepoSHAIn(ctx context.Context, arg UpdateJobRepoSHAInParams) error
	UpdateJobStatus(ctx context.Context, arg UpdateJobStatusParams) error
	UpdateMigRepoBaseRef(ctx context.Context, arg UpdateMigRepoBaseRefParams) error
	UpdateMigSpec(ctx context.Context, arg UpdateMigSpecParams) error
	UpdateNamedSpecArchiveState(ctx context.Context, arg UpdateNamedSpecArchiveStateParams) (Spec, error)
	UpdateNodeCertMetadata(ctx context.Context, arg UpdateNodeCertMetadataParams) error
	UpdateNodeDrained(ctx context.Context, arg UpdateNodeDrainedParams) error
	UpdateNodeHeartbeat(ctx context.Context, arg UpdateNodeHeartbeatParams) error
	UpdateRunBaseRef(ctx context.Context, arg UpdateRunBaseRefParams) error
	UpdateRunError(ctx context.Context, arg UpdateRunErrorParams) error
	UpdateRunResume(ctx context.Context, id types.RunID) error
	UpdateRunStatus(ctx context.Context, arg UpdateRunStatusParams) error
	// Updates last_ref_at to now() for the given spec bundle.
	// Call this whenever a spec or run references the bundle to keep GC metadata fresh.
	UpdateSpecBundleLastRefAt(ctx context.Context, id string) error
	UpdateWaveCompletion(ctx context.Context, arg UpdateWaveCompletionParams) error
	UpdateWaveStatus(ctx context.Context, arg UpdateWaveStatusParams) error
	// Inserts or updates a bundle map entry (upsert on primary key hash).
	// Refreshes bundle_id and updated_at on conflict.
	UpsertConfigBundleMap(ctx context.Context, arg UpsertConfigBundleMapParams) error
	// Inserts or updates an in entry (upsert on composite key (dst, section)).
	// Refreshes entry and updated_at on conflict (entry may change if hash changes).
	UpsertConfigIn(ctx context.Context, arg UpsertConfigInParams) error
	// Inserts or updates an environment entry (upsert on composite key (key, target)).
	// Updates value, secret, and refreshes updated_at on conflict.
	// This ensures idempotent set operations from the CLI or API.
	UpsertGlobalEnv(ctx context.Context, arg UpsertGlobalEnvParams) error
	UpsertJobMetric(ctx context.Context, arg UpsertJobMetricParams) error
	// Bulk upsert a mig_repo by normalized repo_url.
	// Uniqueness is on (mig_id, repo_id) to prevent duplicate repo membership per mig.
	UpsertMigRepo(ctx context.Context, arg UpsertMigRepoParams) (MigRepo, error)
	UpsertNodeDiagnostic(ctx context.Context, arg UpsertNodeDiagnosticParams) (NodeDiagnostic, error)
	UpsertSBOMRow(ctx context.Context, arg UpsertSBOMRowParams) error
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) ArchiveMig

func (q *Queries) ArchiveMig(ctx context.Context, id types.MigID) error

Archives a mig by setting archived_at to now(). Archiving must be refused when the mig has any jobs in a running state. This query only sets the timestamp; validation logic must be in the caller.

func (*Queries) CancelActiveJobsByRun

func (q *Queries) CancelActiveJobsByRun(ctx context.Context, runID types.RunID) (int64, error)

Bulk-cancels active jobs for a run (Created/Queued/Running -> Cancelled). finished_at is set once; duration_ms is computed from started_at when present.

func (*Queries) CancelActiveJobsByRunAttempt

func (q *Queries) CancelActiveJobsByRunAttempt(ctx context.Context, arg CancelActiveJobsByRunAttemptParams) (int64, error)

Bulk-cancels active jobs for a specific run attempt. Targets Created/Queued/Running and preserves terminal jobs. finished_at is set once; duration_ms is computed from started_at when present.

func (*Queries) CancelActiveRunsByWave

func (q *Queries) CancelActiveRunsByWave(ctx context.Context, waveID types.WaveID) (int64, error)

func (*Queries) CheckAPITokenRevoked

func (q *Queries) CheckAPITokenRevoked(ctx context.Context, tokenID string) (pgtype.Timestamptz, error)

func (*Queries) CheckBootstrapTokenRevoked

func (q *Queries) CheckBootstrapTokenRevoked(ctx context.Context, tokenID string) (pgtype.Timestamptz, error)

func (*Queries) ClaimJob

func (q *Queries) ClaimJob(ctx context.Context, nodeID types.NodeID) (Job, error)

Atomically claim the next claimable job for a node.

func (*Queries) ClearRepoSHAChainFromJob

func (q *Queries) ClearRepoSHAChainFromJob(ctx context.Context, arg ClearRepoSHAChainFromJobParams) (int64, error)

func (*Queries) CountJobsByRun

func (q *Queries) CountJobsByRun(ctx context.Context, runID types.RunID) (int64, error)

func (*Queries) CountJobsByRunAndStatus

func (q *Queries) CountJobsByRunAndStatus(ctx context.Context, arg CountJobsByRunAndStatusParams) (int64, error)

func (*Queries) CountJobsByRunAttemptGroupByStatus

Counts jobs by status for a specific run attempt. Used by terminal detection to determine runs.status.

func (*Queries) CountJobsForTUI

func (q *Queries) CountJobsForTUI(ctx context.Context, runID *string) (int64, error)

Counts jobs with optional run_id filter. run_id: if non-null, count jobs for that run; if null, count all jobs. Used with ListJobsForTUI to provide total for TUI pagination.

func (*Queries) CountRunsByWaveStatus

func (q *Queries) CountRunsByWaveStatus(ctx context.Context, waveID types.WaveID) ([]CountRunsByWaveStatusRow, error)

func (*Queries) CountStaleNodesWithRunningJobs

func (q *Queries) CountStaleNodesWithRunningJobs(ctx context.Context, lastHeartbeat pgtype.Timestamptz) (int64, error)

Counts distinct stale nodes that currently have at least one running job. Excludes NULL node_id rows (orphaned running jobs) from node count.

func (*Queries) CreateArtifactBundle

func (q *Queries) CreateArtifactBundle(ctx context.Context, arg CreateArtifactBundleParams) (ArtifactBundle, error)

Creates a new artifact bundle metadata. Blob data is stored in object storage. Bundles are grouped at the job level only (build_id removed).

func (*Queries) CreateDiff

func (q *Queries) CreateDiff(ctx context.Context, arg CreateDiffParams) (Diff, error)

Creates a new diff entry associated with a job. Blob data is stored in object storage.

func (*Queries) CreateEvent

func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event, error)

func (*Queries) CreateJob

func (q *Queries) CreateJob(ctx context.Context, arg CreateJobParams) (Job, error)

Note: `id` is a required TEXT parameter (KSUID-backed); caller generates via types.NewJobID().

func (*Queries) CreateLog

func (q *Queries) CreateLog(ctx context.Context, arg CreateLogParams) (Log, error)

Creates a new log chunk metadata. Blob data is stored in object storage. Logs are grouped at the job level only (build_id removed).

func (*Queries) CreateMig

func (q *Queries) CreateMig(ctx context.Context, arg CreateMigParams) (Mig, error)

func (*Queries) CreateMigRepo

func (q *Queries) CreateMigRepo(ctx context.Context, arg CreateMigRepoParams) (MigRepo, error)

func (*Queries) CreateNamedSpec

func (q *Queries) CreateNamedSpec(ctx context.Context, arg CreateNamedSpecParams) (Spec, error)

func (*Queries) CreateNode

func (q *Queries) CreateNode(ctx context.Context, arg CreateNodeParams) (Node, error)

Creates a new node with an application-supplied URL-safe ID as the primary key.

func (*Queries) CreateNodeDaemonLog

func (q *Queries) CreateNodeDaemonLog(ctx context.Context, arg CreateNodeDaemonLogParams) (NodeDaemonLog, error)

func (*Queries) CreateRun

func (q *Queries) CreateRun(ctx context.Context, arg CreateRunParams) (Run, error)

func (*Queries) CreateSpec

func (q *Queries) CreateSpec(ctx context.Context, arg CreateSpecParams) (Spec, error)

func (*Queries) CreateSpecBundle

func (q *Queries) CreateSpecBundle(ctx context.Context, arg CreateSpecBundleParams) (SpecBundle, error)

Creates a new spec bundle metadata row. Blob data is stored in object storage.

func (*Queries) CreateWave

func (q *Queries) CreateWave(ctx context.Context, arg CreateWaveParams) (Wave, error)

func (*Queries) DeleteArtifactBundle

func (q *Queries) DeleteArtifactBundle(ctx context.Context, id pgtype.UUID) error

func (*Queries) DeleteArtifactBundlesOlderThan

func (q *Queries) DeleteArtifactBundlesOlderThan(ctx context.Context, createdAt pgtype.Timestamptz) error

func (*Queries) DeleteConfigBundleMap

func (q *Queries) DeleteConfigBundleMap(ctx context.Context, hash string) error

Removes a bundle map entry by hash.

func (*Queries) DeleteConfigIn

func (q *Queries) DeleteConfigIn(ctx context.Context, arg DeleteConfigInParams) error

Removes an in entry by dst and section.

func (*Queries) DeleteConfigInBySection

func (q *Queries) DeleteConfigInBySection(ctx context.Context, section string) error

Removes all in entries for a section.

func (*Queries) DeleteDiff

func (q *Queries) DeleteDiff(ctx context.Context, id pgtype.UUID) error

func (*Queries) DeleteDiffsOlderThan

func (q *Queries) DeleteDiffsOlderThan(ctx context.Context, createdAt pgtype.Timestamptz) error

func (*Queries) DeleteExpiredArtifactBundles

func (q *Queries) DeleteExpiredArtifactBundles(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)

DeleteExpiredArtifactBundles removes artifact bundle rows older than the specified timestamp.

func (*Queries) DeleteExpiredDiffs

func (q *Queries) DeleteExpiredDiffs(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)

DeleteExpiredDiffs removes diff rows older than the specified timestamp.

func (*Queries) DeleteExpiredEvents

func (q *Queries) DeleteExpiredEvents(ctx context.Context, time pgtype.Timestamptz) (int64, error)

DeleteExpiredEvents removes event rows older than the specified timestamp.

func (*Queries) DeleteExpiredLogs

func (q *Queries) DeleteExpiredLogs(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)

DeleteExpiredLogs removes log rows older than the specified timestamp.

func (*Queries) DeleteGlobalEnv

func (q *Queries) DeleteGlobalEnv(ctx context.Context, arg DeleteGlobalEnvParams) error

Removes an environment entry by key and target. No-op if the (key, target) pair does not exist (exec returns no error).

func (*Queries) DeleteJob

func (q *Queries) DeleteJob(ctx context.Context, id types.JobID) error

func (*Queries) DeleteLog

func (q *Queries) DeleteLog(ctx context.Context, id int64) error

func (*Queries) DeleteLogsOlderThan

func (q *Queries) DeleteLogsOlderThan(ctx context.Context, createdAt pgtype.Timestamptz) error

func (*Queries) DeleteMig

func (q *Queries) DeleteMig(ctx context.Context, id types.MigID) error

Deletes a mig. Use with caution; should only be called when safe to remove.

func (*Queries) DeleteMigRepo

func (q *Queries) DeleteMigRepo(ctx context.Context, id types.MigRepoID) error

Deletes a mig_repo by id. Note: mig_repos.id remains referenced by API-level repo membership records.

func (*Queries) DeleteNode

func (q *Queries) DeleteNode(ctx context.Context, id types.NodeID) error

func (*Queries) DeleteRun

func (q *Queries) DeleteRun(ctx context.Context, id types.RunID) error

func (*Queries) DeleteSBOMRowsByJob

func (q *Queries) DeleteSBOMRowsByJob(ctx context.Context, jobID types.JobID) error

func (*Queries) DeleteSpecBundle

func (q *Queries) DeleteSpecBundle(ctx context.Context, id string) error

Deletes a spec bundle metadata row by ID. Called by blobpersist as rollback when object storage upload fails.

func (*Queries) DeleteWave

func (q *Queries) DeleteWave(ctx context.Context, id types.WaveID) error

func (*Queries) GetAPITokenByID

func (q *Queries) GetAPITokenByID(ctx context.Context, tokenID string) (GetAPITokenByIDRow, error)

func (*Queries) GetAdjacentJobIndices

func (q *Queries) GetAdjacentJobIndices(ctx context.Context, id types.JobID) (GetAdjacentJobIndicesRow, error)

Transitional: returns current job id and linked successor id.

func (*Queries) GetArtifactBundle

func (q *Queries) GetArtifactBundle(ctx context.Context, id pgtype.UUID) (ArtifactBundle, error)

Returns artifact bundle metadata including object_key for object-storage retrieval.

func (*Queries) GetBootstrapToken

func (q *Queries) GetBootstrapToken(ctx context.Context, tokenID string) (GetBootstrapTokenRow, error)

func (*Queries) GetEvent

func (q *Queries) GetEvent(ctx context.Context, id int64) (Event, error)

func (*Queries) GetGlobalEnv

func (q *Queries) GetGlobalEnv(ctx context.Context, arg GetGlobalEnvParams) (ConfigEnv, error)

Retrieves a single environment entry by key and target. Returns pgx.ErrNoRows if the (key, target) pair does not exist.

func (*Queries) GetJob

func (q *Queries) GetJob(ctx context.Context, id types.JobID) (Job, error)

func (*Queries) GetLatestDiffByJob

func (q *Queries) GetLatestDiffByJob(ctx context.Context, jobID *types.JobID) (Diff, error)

func (*Queries) GetLog

func (q *Queries) GetLog(ctx context.Context, id int64) (Log, error)

Returns log metadata including object_key for object-storage retrieval.

func (*Queries) GetMig

func (q *Queries) GetMig(ctx context.Context, id types.MigID) (Mig, error)

func (*Queries) GetMigByName

func (q *Queries) GetMigByName(ctx context.Context, name string) (Mig, error)

func (*Queries) GetMigRepo

func (q *Queries) GetMigRepo(ctx context.Context, id types.MigRepoID) (MigRepo, error)

func (*Queries) GetMigRepoByURL

func (q *Queries) GetMigRepoByURL(ctx context.Context, arg GetMigRepoByURLParams) (MigRepo, error)

Gets a mig_repo by mig_id and repo_url (for uniqueness constraint enforcement).

func (*Queries) GetNamedSpecByNameSourceSHA

func (q *Queries) GetNamedSpecByNameSourceSHA(ctx context.Context, arg GetNamedSpecByNameSourceSHAParams) (Spec, error)

func (*Queries) GetNode

func (q *Queries) GetNode(ctx context.Context, id types.NodeID) (Node, error)

func (*Queries) GetRepo

func (q *Queries) GetRepo(ctx context.Context, id types.RepoID) (Repo, error)

func (*Queries) GetRun

func (q *Queries) GetRun(ctx context.Context, id types.RunID) (Run, error)

func (*Queries) GetRunSnapshotMetadata

func (q *Queries) GetRunSnapshotMetadata(ctx context.Context, id types.RunID) (GetRunSnapshotMetadataRow, error)

func (*Queries) GetRunTiming

func (q *Queries) GetRunTiming(ctx context.Context, id types.RunID) (RunsTiming, error)

func (*Queries) GetSpec

func (q *Queries) GetSpec(ctx context.Context, id types.SpecID) (Spec, error)

func (*Queries) GetSpecBundle

func (q *Queries) GetSpecBundle(ctx context.Context, id string) (SpecBundle, error)

Returns spec bundle metadata including object_key for object-storage retrieval.

func (*Queries) GetSpecBundleByCID

func (q *Queries) GetSpecBundleByCID(ctx context.Context, cid string) (SpecBundle, error)

Returns the most recently created spec bundle for a given cid. Used for deduplication: callers should check by CID before uploading.

func (*Queries) GetWave

func (q *Queries) GetWave(ctx context.Context, id types.WaveID) (Wave, error)

func (*Queries) HasMigRepoHistory

func (q *Queries) HasMigRepoHistory(ctx context.Context, repoID types.RepoID) (bool, error)

Checks if a mig_repo has any historical executions. Returns true if the repo cannot be deleted due to history, false otherwise.

func (*Queries) HasRunningJobForRunNode

func (q *Queries) HasRunningJobForRunNode(ctx context.Context, arg HasRunningJobForRunNodeParams) (bool, error)

func (*Queries) IncrementRunAttempt

func (q *Queries) IncrementRunAttempt(ctx context.Context, id types.RunID) error

func (*Queries) InsertAPIToken

func (q *Queries) InsertAPIToken(ctx context.Context, arg InsertAPITokenParams) error

func (*Queries) InsertBootstrapToken

func (q *Queries) InsertBootstrapToken(ctx context.Context, arg InsertBootstrapTokenParams) error

func (*Queries) ListAPITokens

func (q *Queries) ListAPITokens(ctx context.Context) ([]ListAPITokensRow, error)

func (*Queries) ListArtifactBundlePartitions

func (q *Queries) ListArtifactBundlePartitions(ctx context.Context) ([]string, error)

ListArtifactBundlePartitions retrieves all partition names for the artifact_bundles table.

func (*Queries) ListArtifactBundlesByCID

func (q *Queries) ListArtifactBundlesByCID(ctx context.Context, cid *string) ([]ArtifactBundle, error)

Returns artifact bundle metadata including object_key for object-storage retrieval.

func (*Queries) ListArtifactBundlesByRun

func (q *Queries) ListArtifactBundlesByRun(ctx context.Context, runID types.RunID) ([]ArtifactBundle, error)

Returns artifact bundle metadata including object_key for object-storage retrieval.

func (*Queries) ListArtifactBundlesByRunAndJob

func (q *Queries) ListArtifactBundlesByRunAndJob(ctx context.Context, arg ListArtifactBundlesByRunAndJobParams) ([]ArtifactBundle, error)

Returns artifact bundle metadata including object_key for object-storage retrieval.

func (*Queries) ListConfigBundleMap

func (q *Queries) ListConfigBundleMap(ctx context.Context) ([]ConfigBundleMap, error)

config_bundle_map.sql — CRUD queries for global bundle map entries (config_bundle_map table). Provides ListConfigBundleMap, UpsertConfigBundleMap, DeleteConfigBundleMap. Returns all bundle map entries ordered by hash for deterministic iteration.

func (*Queries) ListConfigIn

func (q *Queries) ListConfigIn(ctx context.Context) ([]ConfigIn, error)

config_in.sql — CRUD queries for global in mount entries (config_in table). Provides ListConfigIn, UpsertConfigIn, DeleteConfigIn, DeleteConfigInBySection. Returns all in entries ordered by section then dst for deterministic iteration.

func (*Queries) ListConfigInBySection

func (q *Queries) ListConfigInBySection(ctx context.Context, section string) ([]ConfigIn, error)

Returns in entries for a specific section ordered by dst.

func (*Queries) ListCreatedJobsByRunAttempt

func (q *Queries) ListCreatedJobsByRunAttempt(ctx context.Context, arg ListCreatedJobsByRunAttemptParams) ([]Job, error)

func (*Queries) ListDiffsByRun

func (q *Queries) ListDiffsByRun(ctx context.Context, runID types.RunID) ([]Diff, error)

Returns diff metadata for a run.

func (*Queries) ListDistinctRepos

func (q *Queries) ListDistinctRepos(ctx context.Context, filter string) ([]ListDistinctReposRow, error)

Lists distinct repos for a mig with last known run metadata, optionally filtered by repo_url substring.

func (*Queries) ListEventPartitions

func (q *Queries) ListEventPartitions(ctx context.Context) ([]string, error)

ListEventPartitions retrieves all partition names for the events table.

func (*Queries) ListEventsByRun

func (q *Queries) ListEventsByRun(ctx context.Context, runID types.RunID) ([]Event, error)

func (*Queries) ListEventsByRunSince

func (q *Queries) ListEventsByRunSince(ctx context.Context, arg ListEventsByRunSinceParams) ([]Event, error)

func (*Queries) ListFailedRepoIDsByMig

func (q *Queries) ListFailedRepoIDsByMig(ctx context.Context, migID types.MigID) ([]types.RepoID, error)

func (*Queries) ListGlobalEnv

func (q *Queries) ListGlobalEnv(ctx context.Context) ([]ConfigEnv, error)

config_env.sql — CRUD queries for global environment variables (config_env table). Provides ListGlobalEnv, GetGlobalEnv, UpsertGlobalEnv, DeleteGlobalEnv. Returns all global environment entries, ordered by key then target for consistent iteration. Used by ConfigHolder initialization and HTTP list endpoint.

func (*Queries) ListJobsByRun

func (q *Queries) ListJobsByRun(ctx context.Context, runID types.RunID) ([]Job, error)

func (*Queries) ListJobsByRunAttempt

func (q *Queries) ListJobsByRunAttempt(ctx context.Context, arg ListJobsByRunAttemptParams) ([]Job, error)

func (*Queries) ListJobsForTUI

func (q *Queries) ListJobsForTUI(ctx context.Context, arg ListJobsForTUIParams) ([]ListJobsForTUIRow, error)

Lists jobs with optional run_id filter, ordered newest-to-oldest by job id. run_id: if non-null, filter to jobs for that run; if null, return all jobs. Joins runs and migs to surface mig_name per job for the TUI jobs-list screen.

func (*Queries) ListLatestNamedSpecs

func (q *Queries) ListLatestNamedSpecs(ctx context.Context, arg ListLatestNamedSpecsParams) ([]ListLatestNamedSpecsRow, error)

func (*Queries) ListLogPartitions

func (q *Queries) ListLogPartitions(ctx context.Context) ([]string, error)

ListLogPartitions retrieves all partition names for the logs table.

func (*Queries) ListLogsByRun

func (q *Queries) ListLogsByRun(ctx context.Context, runID types.RunID) ([]Log, error)

Returns log metadata including object_key for object-storage retrieval.

func (*Queries) ListLogsByRunAndJob

func (q *Queries) ListLogsByRunAndJob(ctx context.Context, arg ListLogsByRunAndJobParams) ([]Log, error)

Returns log metadata including object_key for object-storage retrieval.

func (*Queries) ListLogsByRunAndJobSince

func (q *Queries) ListLogsByRunAndJobSince(ctx context.Context, arg ListLogsByRunAndJobSinceParams) ([]Log, error)

Returns log metadata including object_key for object-storage retrieval.

func (*Queries) ListLogsByRunSince

func (q *Queries) ListLogsByRunSince(ctx context.Context, arg ListLogsByRunSinceParams) ([]Log, error)

Returns log metadata including object_key for object-storage retrieval.

func (*Queries) ListMigReposByMig

func (q *Queries) ListMigReposByMig(ctx context.Context, migID types.MigID) ([]MigRepo, error)

func (*Queries) ListMigs

func (q *Queries) ListMigs(ctx context.Context, arg ListMigsParams) ([]Mig, error)

Lists migs with optional filtering by archived status and name substring. archived_only: if true, return only archived migs; if false, return only active migs; if null, return all. name_filter: if non-empty, filter by name substring (case-insensitive); if null/empty, no name filtering.

func (*Queries) ListNodeDaemonLogs

func (q *Queries) ListNodeDaemonLogs(ctx context.Context, arg ListNodeDaemonLogsParams) ([]NodeDaemonLog, error)

func (*Queries) ListNodeDiagnostics

func (q *Queries) ListNodeDiagnostics(ctx context.Context, nodeID types.NodeID) ([]NodeDiagnostic, error)

func (*Queries) ListNodeMetricsPartitions

func (q *Queries) ListNodeMetricsPartitions(ctx context.Context) ([]string, error)

ListNodeMetricsPartitions retrieves all partition names for the node_metrics table.

func (*Queries) ListNodes

func (q *Queries) ListNodes(ctx context.Context) ([]Node, error)

func (*Queries) ListQueuedRunsByWave

func (q *Queries) ListQueuedRunsByWave(ctx context.Context, waveID types.WaveID) ([]Run, error)

func (*Queries) ListRunSBOMRowsByJobType

func (q *Queries) ListRunSBOMRowsByJobType(ctx context.Context, arg ListRunSBOMRowsByJobTypeParams) ([]ListRunSBOMRowsByJobTypeRow, error)

func (*Queries) ListRuns

func (q *Queries) ListRuns(ctx context.Context, arg ListRunsParams) ([]Run, error)

func (*Queries) ListRunsByWave

func (q *Queries) ListRunsByWave(ctx context.Context, waveID types.WaveID) ([]Run, error)

func (*Queries) ListRunsForRepo

func (q *Queries) ListRunsForRepo(ctx context.Context, arg ListRunsForRepoParams) ([]ListRunsForRepoRow, error)

func (*Queries) ListRunsTimings

func (q *Queries) ListRunsTimings(ctx context.Context, arg ListRunsTimingsParams) ([]RunsTiming, error)

func (*Queries) ListRunsWithMetadata

func (q *Queries) ListRunsWithMetadata(ctx context.Context, arg ListRunsWithMetadataParams) ([]ListRunsWithMetadataRow, error)

func (*Queries) ListRunsWithURLByWave

func (q *Queries) ListRunsWithURLByWave(ctx context.Context, waveID types.WaveID) ([]ListRunsWithURLByWaveRow, error)

func (*Queries) ListSpecBundles

func (q *Queries) ListSpecBundles(ctx context.Context, arg ListSpecBundlesParams) ([]SpecBundle, error)

Lists spec bundles ordered by created_at descending (most recent first).

func (*Queries) ListSpecBundlesUnreferencedBefore

func (q *Queries) ListSpecBundlesUnreferencedBefore(ctx context.Context, lastRefAt pgtype.Timestamptz) ([]SpecBundle, error)

Lists spec bundles whose last_ref_at is before the given threshold. Used by GC to find bundles eligible for deletion.

func (*Queries) ListSpecs

func (q *Queries) ListSpecs(ctx context.Context, arg ListSpecsParams) ([]Spec, error)

Lists specs ordered by created_at descending (most recent first). There is an index on created_at to optimize this query.

func (*Queries) ListStaleRunningJobs

func (q *Queries) ListStaleRunningJobs(ctx context.Context, lastHeartbeat pgtype.Timestamptz) ([]ListStaleRunningJobsRow, error)

Lists running jobs whose assigned node is stale at the provided cutoff. Rows are grouped by (run_id, attempt) for deterministic recovery processing.

func (*Queries) ListWaves

func (q *Queries) ListWaves(ctx context.Context, arg ListWavesParams) ([]Wave, error)

func (*Queries) ListWavesByMig

func (q *Queries) ListWavesByMig(ctx context.Context, arg ListWavesByMigParams) ([]Wave, error)

func (*Queries) ListWavesWithQueuedRuns

func (q *Queries) ListWavesWithQueuedRuns(ctx context.Context) ([]types.WaveID, error)

func (*Queries) MarkBootstrapTokenCertIssued

func (q *Queries) MarkBootstrapTokenCertIssued(ctx context.Context, tokenID string) error

func (*Queries) PromoteJobByIDIfUnblocked

func (q *Queries) PromoteJobByIDIfUnblocked(ctx context.Context, id types.JobID) (Job, error)

Atomically promote a specific linked successor job: Created -> Queued. The candidate is eligible only when every predecessor that points to it is Success.

func (*Queries) ResolveNamedSpecVersionByDomainRepoName

func (q *Queries) ResolveNamedSpecVersionByDomainRepoName(ctx context.Context, arg ResolveNamedSpecVersionByDomainRepoNameParams) ([]Spec, error)

func (*Queries) ResolveNamedSpecVersionByName

func (q *Queries) ResolveNamedSpecVersionByName(ctx context.Context, arg ResolveNamedSpecVersionByNameParams) ([]Spec, error)

func (*Queries) ResolveNamedSpecVersionByRepoName

func (q *Queries) ResolveNamedSpecVersionByRepoName(ctx context.Context, arg ResolveNamedSpecVersionByRepoNameParams) ([]Spec, error)

func (*Queries) RevokeAPIToken

func (q *Queries) RevokeAPIToken(ctx context.Context, tokenID string) error

func (*Queries) ScheduleNextJob

func (q *Queries) ScheduleNextJob(ctx context.Context, arg ScheduleNextJobParams) (Job, error)

Atomically promote the next unblocked job in a run attempt: Created -> Queued. A created job is unblocked when all predecessor jobs that point to it are Success.

func (*Queries) TrimNodeDaemonLogs

func (q *Queries) TrimNodeDaemonLogs(ctx context.Context, arg TrimNodeDaemonLogsParams) error

func (*Queries) UnarchiveMig

func (q *Queries) UnarchiveMig(ctx context.Context, id types.MigID) error

Unarchives a mig by clearing archived_at.

func (*Queries) UnclaimJob

func (q *Queries) UnclaimJob(ctx context.Context, arg UnclaimJobParams) error

Revert a claimed Running job back to claimable Queued state. Guarded by both job id and node id so a foreign node cannot steal the slot.

func (*Queries) UpdateAPITokenLastUsed

func (q *Queries) UpdateAPITokenLastUsed(ctx context.Context, tokenID string) error

func (*Queries) UpdateBootstrapTokenLastUsed

func (q *Queries) UpdateBootstrapTokenLastUsed(ctx context.Context, tokenID string) error

func (*Queries) UpdateJobCompletion

func (q *Queries) UpdateJobCompletion(ctx context.Context, arg UpdateJobCompletionParams) error

func (*Queries) UpdateJobCompletionWithMeta

func (q *Queries) UpdateJobCompletionWithMeta(ctx context.Context, arg UpdateJobCompletionWithMetaParams) error

func (*Queries) UpdateJobImageName

func (q *Queries) UpdateJobImageName(ctx context.Context, arg UpdateJobImageNameParams) error

Persist the container image name used to execute a job. This is set by the node immediately before job execution starts.

func (*Queries) UpdateJobMeta

func (q *Queries) UpdateJobMeta(ctx context.Context, arg UpdateJobMetaParams) error

func (*Queries) UpdateJobNextID

func (q *Queries) UpdateJobNextID(ctx context.Context, arg UpdateJobNextIDParams) error

func (*Queries) UpdateJobRepoSHAIn

func (q *Queries) UpdateJobRepoSHAIn(ctx context.Context, arg UpdateJobRepoSHAInParams) error

func (*Queries) UpdateJobStatus

func (q *Queries) UpdateJobStatus(ctx context.Context, arg UpdateJobStatusParams) error

func (*Queries) UpdateMigRepoBaseRef

func (q *Queries) UpdateMigRepoBaseRef(ctx context.Context, arg UpdateMigRepoBaseRefParams) error

func (*Queries) UpdateMigSpec

func (q *Queries) UpdateMigSpec(ctx context.Context, arg UpdateMigSpecParams) error

func (*Queries) UpdateNamedSpecArchiveState

func (q *Queries) UpdateNamedSpecArchiveState(ctx context.Context, arg UpdateNamedSpecArchiveStateParams) (Spec, error)

func (*Queries) UpdateNodeCertMetadata

func (q *Queries) UpdateNodeCertMetadata(ctx context.Context, arg UpdateNodeCertMetadataParams) error

func (*Queries) UpdateNodeDrained

func (q *Queries) UpdateNodeDrained(ctx context.Context, arg UpdateNodeDrainedParams) error

func (*Queries) UpdateNodeHeartbeat

func (q *Queries) UpdateNodeHeartbeat(ctx context.Context, arg UpdateNodeHeartbeatParams) error

func (*Queries) UpdateRunBaseRef

func (q *Queries) UpdateRunBaseRef(ctx context.Context, arg UpdateRunBaseRefParams) error

func (*Queries) UpdateRunError

func (q *Queries) UpdateRunError(ctx context.Context, arg UpdateRunErrorParams) error

func (*Queries) UpdateRunResume

func (q *Queries) UpdateRunResume(ctx context.Context, id types.RunID) error

func (*Queries) UpdateRunStatus

func (q *Queries) UpdateRunStatus(ctx context.Context, arg UpdateRunStatusParams) error

func (*Queries) UpdateSpecBundleLastRefAt

func (q *Queries) UpdateSpecBundleLastRefAt(ctx context.Context, id string) error

Updates last_ref_at to now() for the given spec bundle. Call this whenever a spec or run references the bundle to keep GC metadata fresh.

func (*Queries) UpdateWaveCompletion

func (q *Queries) UpdateWaveCompletion(ctx context.Context, arg UpdateWaveCompletionParams) error

func (*Queries) UpdateWaveStatus

func (q *Queries) UpdateWaveStatus(ctx context.Context, arg UpdateWaveStatusParams) error

func (*Queries) UpsertConfigBundleMap

func (q *Queries) UpsertConfigBundleMap(ctx context.Context, arg UpsertConfigBundleMapParams) error

Inserts or updates a bundle map entry (upsert on primary key hash). Refreshes bundle_id and updated_at on conflict.

func (*Queries) UpsertConfigIn

func (q *Queries) UpsertConfigIn(ctx context.Context, arg UpsertConfigInParams) error

Inserts or updates an in entry (upsert on composite key (dst, section)). Refreshes entry and updated_at on conflict (entry may change if hash changes).

func (*Queries) UpsertGlobalEnv

func (q *Queries) UpsertGlobalEnv(ctx context.Context, arg UpsertGlobalEnvParams) error

Inserts or updates an environment entry (upsert on composite key (key, target)). Updates value, secret, and refreshes updated_at on conflict. This ensures idempotent set operations from the CLI or API.

func (*Queries) UpsertJobMetric

func (q *Queries) UpsertJobMetric(ctx context.Context, arg UpsertJobMetricParams) error

func (*Queries) UpsertMigRepo

func (q *Queries) UpsertMigRepo(ctx context.Context, arg UpsertMigRepoParams) (MigRepo, error)

Bulk upsert a mig_repo by normalized repo_url. Uniqueness is on (mig_id, repo_id) to prevent duplicate repo membership per mig.

func (*Queries) UpsertNodeDiagnostic

func (q *Queries) UpsertNodeDiagnostic(ctx context.Context, arg UpsertNodeDiagnosticParams) (NodeDiagnostic, error)

func (*Queries) UpsertSBOMRow

func (q *Queries) UpsertSBOMRow(ctx context.Context, arg UpsertSBOMRowParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Repo

type Repo struct {
	ID        types.RepoID       `json:"id"`
	Url       string             `json:"url"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type ResolveLatestNamedSpecByDomainRepoNameParams

type ResolveLatestNamedSpecByDomainRepoNameParams struct {
	Name     string `json:"name"`
	Domain   string `json:"domain"`
	Repo     string `json:"repo"`
	Archived bool   `json:"archived"`
}

type ResolveLatestNamedSpecByDomainRepoNameRow

type ResolveLatestNamedSpecByDomainRepoNameRow struct {
	ID                string             `json:"id"`
	Name              string             `json:"name"`
	Description       string             `json:"description"`
	Source            []byte             `json:"source"`
	Sha               string             `json:"sha"`
	SourceCommittedAt pgtype.Timestamptz `json:"source_committed_at"`
	Spec              []byte             `json:"spec"`
	CreatedBy         *string            `json:"created_by"`
	UpdatedBy         *string            `json:"updated_by"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	ArchivedAt        pgtype.Timestamptz `json:"archived_at"`
}

type ResolveLatestNamedSpecByNameParams

type ResolveLatestNamedSpecByNameParams struct {
	Name     string `json:"name"`
	Archived bool   `json:"archived"`
}

type ResolveLatestNamedSpecByNameRow

type ResolveLatestNamedSpecByNameRow struct {
	ID                string             `json:"id"`
	Name              string             `json:"name"`
	Description       string             `json:"description"`
	Source            []byte             `json:"source"`
	Sha               string             `json:"sha"`
	SourceCommittedAt pgtype.Timestamptz `json:"source_committed_at"`
	Spec              []byte             `json:"spec"`
	CreatedBy         *string            `json:"created_by"`
	UpdatedBy         *string            `json:"updated_by"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	ArchivedAt        pgtype.Timestamptz `json:"archived_at"`
}

type ResolveLatestNamedSpecByRepoNameParams

type ResolveLatestNamedSpecByRepoNameParams struct {
	Name     string `json:"name"`
	Repo     string `json:"repo"`
	Archived bool   `json:"archived"`
}

type ResolveLatestNamedSpecByRepoNameRow

type ResolveLatestNamedSpecByRepoNameRow struct {
	ID                string             `json:"id"`
	Name              string             `json:"name"`
	Description       string             `json:"description"`
	Source            []byte             `json:"source"`
	Sha               string             `json:"sha"`
	SourceCommittedAt pgtype.Timestamptz `json:"source_committed_at"`
	Spec              []byte             `json:"spec"`
	CreatedBy         *string            `json:"created_by"`
	UpdatedBy         *string            `json:"updated_by"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	ArchivedAt        pgtype.Timestamptz `json:"archived_at"`
}

type ResolveNamedSpecVersionByDomainRepoNameParams

type ResolveNamedSpecVersionByDomainRepoNameParams struct {
	Name      string `json:"name"`
	Domain    string `json:"domain"`
	Repo      string `json:"repo"`
	ShaPrefix string `json:"sha_prefix"`
	Archived  bool   `json:"archived"`
}

type ResolveNamedSpecVersionByNameParams

type ResolveNamedSpecVersionByNameParams struct {
	Name      string `json:"name"`
	ShaPrefix string `json:"sha_prefix"`
	Archived  bool   `json:"archived"`
}

type ResolveNamedSpecVersionByRepoNameParams

type ResolveNamedSpecVersionByRepoNameParams struct {
	Name      string `json:"name"`
	Repo      string `json:"repo"`
	ShaPrefix string `json:"sha_prefix"`
	Archived  bool   `json:"archived"`
}

type Run

type Run struct {
	ID              types.RunID        `json:"id"`
	WaveID          types.WaveID       `json:"wave_id"`
	MigID           types.MigID        `json:"mig_id"`
	SpecID          types.SpecID       `json:"spec_id"`
	RepoID          types.RepoID       `json:"repo_id"`
	RepoBaseRef     string             `json:"repo_base_ref"`
	SourceCommitSha string             `json:"source_commit_sha"`
	RepoSha0        string             `json:"repo_sha0"`
	CreatedBy       *string            `json:"created_by"`
	Status          types.RunStatus    `json:"status"`
	Attempt         int32              `json:"attempt"`
	LastError       *string            `json:"last_error"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	StartedAt       pgtype.Timestamptz `json:"started_at"`
	FinishedAt      pgtype.Timestamptz `json:"finished_at"`
	Stats           []byte             `json:"stats"`
}

type RunsTiming

type RunsTiming struct {
	ID      types.RunID `json:"id"`
	QueueMs int64       `json:"queue_ms"`
	RunMs   int64       `json:"run_ms"`
}

type Sbom

type Sbom struct {
	JobID  types.JobID  `json:"job_id"`
	RepoID types.RepoID `json:"repo_id"`
	Lib    string       `json:"lib"`
	Ver    string       `json:"ver"`
}

type ScheduleNextJobParams

type ScheduleNextJobParams struct {
	RunID   types.RunID `json:"run_id"`
	Attempt int32       `json:"attempt"`
}

type Spec

type Spec struct {
	ID                types.SpecID       `json:"id"`
	Name              string             `json:"name"`
	Description       string             `json:"description"`
	Source            []byte             `json:"source"`
	Sha               string             `json:"sha"`
	SourceCommittedAt pgtype.Timestamptz `json:"source_committed_at"`
	Spec              []byte             `json:"spec"`
	CreatedBy         *string            `json:"created_by"`
	UpdatedBy         *string            `json:"updated_by"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	ArchivedAt        pgtype.Timestamptz `json:"archived_at"`
}

type SpecBundle

type SpecBundle struct {
	ID        string             `json:"id"`
	Cid       string             `json:"cid"`
	Digest    string             `json:"digest"`
	Size      int64              `json:"size"`
	ObjectKey *string            `json:"object_key"`
	CreatedBy *string            `json:"created_by"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	LastRefAt pgtype.Timestamptz `json:"last_ref_at"`
}

type Store

type Store interface {
	Querier
	CancelRun(ctx context.Context, runID types.RunID) error
	CancelWave(ctx context.Context, waveID types.WaveID) error
	CompleteBootstrapEnrollment(ctx context.Context, arg CompleteBootstrapEnrollmentParams) error
	CreateWaveWithRuns(ctx context.Context, arg CreateWaveWithRunsParams) (Wave, []Run, error)
	RestartRun(ctx context.Context, runID types.RunID) (Run, error)
	Close()
	Pool() *pgxpool.Pool
}

Store defines the interface for database operations. The sqlc-generated Queries type implements the query methods via Querier.

func NewStore

func NewStore(ctx context.Context, dsn string) (Store, error)

NewStore creates a new Store by establishing a connection pool to the PostgreSQL database. The dsn parameter should be a valid PostgreSQL connection string. Callers must call Close() when done to release resources.

type TrimNodeDaemonLogsParams

type TrimNodeDaemonLogsParams struct {
	NodeID    types.NodeID `json:"node_id"`
	Component string       `json:"component"`
	KeepCount int32        `json:"keep_count"`
}

type UnclaimJobParams

type UnclaimJobParams struct {
	ID     types.JobID  `json:"id"`
	NodeID types.NodeID `json:"node_id"`
}

type UpdateJobCompletionParams

type UpdateJobCompletionParams struct {
	Status     types.JobStatus `json:"status"`
	ExitCode   *int32          `json:"exit_code"`
	RepoShaOut string          `json:"repo_sha_out"`
	ID         types.JobID     `json:"id"`
}

type UpdateJobCompletionWithMetaParams

type UpdateJobCompletionWithMetaParams struct {
	Status     types.JobStatus `json:"status"`
	ExitCode   *int32          `json:"exit_code"`
	RepoShaOut string          `json:"repo_sha_out"`
	Meta       []byte          `json:"meta"`
	ID         types.JobID     `json:"id"`
}

type UpdateJobImageNameParams

type UpdateJobImageNameParams struct {
	ID       types.JobID `json:"id"`
	JobImage string      `json:"job_image"`
}

type UpdateJobMetaParams

type UpdateJobMetaParams struct {
	ID   types.JobID `json:"id"`
	Meta []byte      `json:"meta"`
}

type UpdateJobNextIDParams

type UpdateJobNextIDParams struct {
	ID     types.JobID  `json:"id"`
	NextID *types.JobID `json:"next_id"`
}

type UpdateJobRepoSHAInParams

type UpdateJobRepoSHAInParams struct {
	ID        types.JobID `json:"id"`
	RepoShaIn string      `json:"repo_sha_in"`
}

type UpdateJobStatusParams

type UpdateJobStatusParams struct {
	ID         types.JobID        `json:"id"`
	Status     types.JobStatus    `json:"status"`
	StartedAt  pgtype.Timestamptz `json:"started_at"`
	FinishedAt pgtype.Timestamptz `json:"finished_at"`
	DurationMs int64              `json:"duration_ms"`
}

type UpdateMigRepoBaseRefParams

type UpdateMigRepoBaseRefParams struct {
	ID      types.MigRepoID `json:"id"`
	BaseRef string          `json:"base_ref"`
}

type UpdateMigSpecParams

type UpdateMigSpecParams struct {
	ID     types.MigID   `json:"id"`
	SpecID *types.SpecID `json:"spec_id"`
}

type UpdateNamedSpecArchiveStateParams

type UpdateNamedSpecArchiveStateParams struct {
	Archived  bool    `json:"archived"`
	UpdatedBy *string `json:"updated_by"`
	ID        string  `json:"id"`
}

type UpdateNodeCertMetadataParams

type UpdateNodeCertMetadataParams struct {
	ID              types.NodeID       `json:"id"`
	CertSerial      *string            `json:"cert_serial"`
	CertFingerprint *string            `json:"cert_fingerprint"`
	CertNotBefore   pgtype.Timestamptz `json:"cert_not_before"`
	CertNotAfter    pgtype.Timestamptz `json:"cert_not_after"`
}

type UpdateNodeDrainedParams

type UpdateNodeDrainedParams struct {
	ID      types.NodeID `json:"id"`
	Drained bool         `json:"drained"`
}

type UpdateNodeHeartbeatParams

type UpdateNodeHeartbeatParams struct {
	ID             types.NodeID       `json:"id"`
	LastHeartbeat  pgtype.Timestamptz `json:"last_heartbeat"`
	CpuTotalMillis int32              `json:"cpu_total_millis"`
	CpuFreeMillis  int32              `json:"cpu_free_millis"`
	MemTotalBytes  int64              `json:"mem_total_bytes"`
	MemFreeBytes   int64              `json:"mem_free_bytes"`
	DiskTotalBytes int64              `json:"disk_total_bytes"`
	DiskFreeBytes  int64              `json:"disk_free_bytes"`
	Version        string             `json:"version"`
}

type UpdateRunBaseRefParams

type UpdateRunBaseRefParams struct {
	ID          types.RunID `json:"id"`
	RepoBaseRef string      `json:"repo_base_ref"`
}

type UpdateRunErrorParams

type UpdateRunErrorParams struct {
	ID        types.RunID `json:"id"`
	LastError *string     `json:"last_error"`
}

type UpdateRunStatusParams

type UpdateRunStatusParams struct {
	ID     types.RunID     `json:"id"`
	Status types.RunStatus `json:"status"`
}

type UpdateWaveCompletionParams

type UpdateWaveCompletionParams struct {
	ID     types.WaveID     `json:"id"`
	Status types.WaveStatus `json:"status"`
	Stats  []byte           `json:"stats"`
}

type UpdateWaveStatusParams

type UpdateWaveStatusParams struct {
	ID     types.WaveID     `json:"id"`
	Status types.WaveStatus `json:"status"`
}

type UpsertConfigBundleMapParams

type UpsertConfigBundleMapParams struct {
	Hash     string `json:"hash"`
	BundleID string `json:"bundle_id"`
}

type UpsertConfigInParams

type UpsertConfigInParams struct {
	Entry   string `json:"entry"`
	Dst     string `json:"dst"`
	Section string `json:"section"`
}

type UpsertGlobalEnvParams

type UpsertGlobalEnvParams struct {
	Key    string `json:"key"`
	Target string `json:"target"`
	Value  string `json:"value"`
	Secret bool   `json:"secret"`
}

type UpsertJobMetricParams

type UpsertJobMetricParams struct {
	NodeID            types.NodeID `json:"node_id"`
	JobID             types.JobID  `json:"job_id"`
	CpuConsumedNs     int64        `json:"cpu_consumed_ns"`
	DiskConsumedBytes int64        `json:"disk_consumed_bytes"`
	MemConsumedBytes  int64        `json:"mem_consumed_bytes"`
}

type UpsertMigRepoParams

type UpsertMigRepoParams struct {
	ID      types.MigRepoID `json:"id"`
	MigID   types.MigID     `json:"mig_id"`
	Url     string          `json:"url"`
	BaseRef string          `json:"base_ref"`
}

type UpsertNodeDiagnosticParams

type UpsertNodeDiagnosticParams struct {
	NodeID        types.NodeID       `json:"node_id"`
	Component     string             `json:"component"`
	Status        string             `json:"status"`
	LastError     *string            `json:"last_error"`
	Version       *string            `json:"version"`
	ImageRef      *string            `json:"image_ref"`
	LocalImageID  *string            `json:"local_image_id"`
	RemoteImageID *string            `json:"remote_image_id"`
	Details       []byte             `json:"details"`
	LastCheckedAt pgtype.Timestamptz `json:"last_checked_at"`
	LastSuccessAt pgtype.Timestamptz `json:"last_success_at"`
}

type UpsertSBOMRowParams

type UpsertSBOMRowParams struct {
	JobID  types.JobID  `json:"job_id"`
	RepoID types.RepoID `json:"repo_id"`
	Lib    string       `json:"lib"`
	Ver    string       `json:"ver"`
}

type Wave

type Wave struct {
	ID         types.WaveID       `json:"id"`
	MigID      types.MigID        `json:"mig_id"`
	SpecID     types.SpecID       `json:"spec_id"`
	CreatedBy  *string            `json:"created_by"`
	Status     types.WaveStatus   `json:"status"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
	StartedAt  pgtype.Timestamptz `json:"started_at"`
	FinishedAt pgtype.Timestamptz `json:"finished_at"`
	Stats      []byte             `json:"stats"`
}

Directories

Path Synopsis
Package ttlworker provides a background worker for purging expired data from the database.
Package ttlworker provides a background worker for purging expired data from the database.
Package wavescheduler provides a background worker for scheduling queued runs within waves.
Package wavescheduler provides a background worker for scheduling queued runs within waves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL