ingot

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ingot provides the data model and persistence layer for Ingots.

An Ingot is a compound record that bundles a bead, PR, worker lifecycle, and structured test results into a single queryable record.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertIngot

func InsertIngot(db *sql.DB, ingot *Ingot) error

InsertIngot inserts a new ingot row. It sets CreatedAt and UpdatedAt to now and writes the generated ID back to ingot.ID.

func InsertTestResult

func InsertTestResult(db *sql.DB, tr *TestResult) error

InsertTestResult inserts a test result row, setting RecordedAt to now if it is zero. It writes the generated ID back to tr.ID.

func UpdateIngotPR

func UpdateIngotPR(db *sql.DB, beadID, anvil string, prNum int, prURL string, prID *int) error

UpdateIngotPR updates pr_number, pr_url, pr_id, and updated_at. prID may be nil when the internal PR row has not yet been resolved, in which case the column is stored as NULL to avoid a FK violation.

func UpdateIngotStatus

func UpdateIngotStatus(db *sql.DB, beadID, anvil string, status Status) error

UpdateIngotStatus updates the status and updated_at of the ingot identified by (beadID, anvil).

func UpdateIngotTemperResults

func UpdateIngotTemperResults(db *sql.DB, beadID, anvil string, passed bool, failedStep string, durationMs int) error

UpdateIngotTemperResults updates temper fields and updated_at.

Types

type Ingot

type Ingot struct {
	ID               int          `json:"id"`
	BeadID           string       `json:"bead_id"`
	Anvil            string       `json:"anvil"`
	PRID             *int         `json:"pr_id,omitempty"` // FK to prs.id, NULL until PR created
	WorkerID         string       `json:"worker_id"`
	Status           Status       `json:"status"`
	TemperPassed     bool         `json:"temper_passed"`
	TemperFailedStep string       `json:"temper_failed_step,omitempty"`
	TemperDurationMs int          `json:"temper_duration_ms"`
	PRNumber         *int         `json:"pr_number,omitempty"` // GitHub PR number
	PRURL            string       `json:"pr_url,omitempty"`
	Title            string       `json:"title"`
	Branch           string       `json:"branch"`
	TestResults      []TestResult `json:"test_results,omitempty"` // eager-loaded
	CreatedAt        time.Time    `json:"created_at"`
	UpdatedAt        time.Time    `json:"updated_at"`
}

Ingot bundles a bead, PR, worker lifecycle, and test results into a single queryable record.

func GetIngot

func GetIngot(db *sql.DB, beadID, anvil string) (*Ingot, error)

GetIngot fetches a single ingot by (beadID, anvil), eager-loading its TestResults. Returns nil, nil if not found.

func GetIngotByBeadID

func GetIngotByBeadID(db *sql.DB, beadID string) ([]Ingot, error)

GetIngotByBeadID fetches all ingots matching beadID across any anvil, ordered deterministically by anvil name. Returns (nil, nil) when not found. When multiple rows are returned the caller should ask the user to supply --anvil to disambiguate.

func GetIngots

func GetIngots(db *sql.DB, anvil string, status string, limit int) ([]Ingot, error)

GetIngots returns ingots with optional filtering by anvil and/or status, ordered by updated_at descending, limited to limit rows.

func GetIngotsByStatus

func GetIngotsByStatus(db *sql.DB, status Status, limit int) ([]Ingot, error)

GetIngotsByStatus returns ingots filtered by status, limited to limit rows.

type Status

type Status string

Status represents the lifecycle stage of an ingot.

const (
	StatusInit     Status = "init"
	StatusSmith    Status = "smith"
	StatusTemper   Status = "temper"
	StatusWarden   Status = "warden"
	StatusApproved Status = "approved"
	StatusPROpen   Status = "pr_open"
	StatusPRMerged Status = "pr_merged"
	StatusFailed   Status = "failed"
	StatusStalled  Status = "stalled"
)

type TestResult

type TestResult struct {
	ID             int       `json:"id"`
	IngotID        int       `json:"ingot_id"`
	StepIndex      int       `json:"step_index"`
	StepName       string    `json:"step_name"`
	Command        string    `json:"command"`
	ExitCode       int       `json:"exit_code"`
	DurationMs     int       `json:"duration_ms"`
	Passed         bool      `json:"passed"`
	Optional       bool      `json:"optional"`
	OutputSummary  string    `json:"output_summary,omitempty"` // first ~1000 chars or key errors
	FullOutputPath string    `json:"full_output_path,omitempty"`
	RecordedAt     time.Time `json:"recorded_at"`
}

TestResult stores the outcome of a single temper step for an ingot.

func GetTestResults

func GetTestResults(db *sql.DB, ingotID int) ([]TestResult, error)

GetTestResults fetches all test results for an ingot ordered by step_index.

Jump to

Keyboard shortcuts

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