Documentation
¶
Overview ¶
Package store is the server's SQLite persistence layer: executions, their stack/edge subgraph, and per-(class,target) approval gate state. Pure-Go SQLite (modernc.org/sqlite, no cgo); schema migrated by goose at Open.
Index ¶
- func BumpRev(db *sql.DB, id string) error
- func GetStackOutput(db *sql.DB, execID, stack, kind string) (pointer, excerpt string, ok bool, err error)
- func IsClassified(db *sql.DB, pr int, environment string) (bool, error)
- func LatestExecutionID(db *sql.DB, pr int, environment string) (string, bool)
- func LatestVerifyExecutionID(db *sql.DB, pr int, environment string) (string, bool)
- func LoadGraph(db *sql.DB, id string) (events.Graph, error)
- func MarkActive(db *sql.DB, pr int, environment string) error
- func MarkClassified(db *sql.DB, pr int, environment string) error
- func Open(dsn string) (*sql.DB, error)
- func SetCheckRunID(db *sql.DB, id string, checkRunID int64) error
- func SetReport(db *sql.DB, id, markdown string) error
- func UpdateStack(db *sql.DB, id, stack string, status events.Status, detail string) error
- func UpsertInit(db *sql.DB, in events.Init) error
- func UpsertPhase(db *sql.DB, p events.PhaseEvent) error
- func UpsertStackOutput(db *sql.DB, execID, stack, kind, pointer, excerpt string) error
- func UpsertTarget(db *sql.DB, pr int, environment, class, target, grant, state string) error
- type Execution
- type Gate
- type GateTarget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BumpRev ¶
BumpRev increments the cache-bust revision (used by the rendered SVG URL so GitHub's image proxy re-fetches on each state change).
func GetStackOutput ¶ added in v0.6.0
func GetStackOutput(db *sql.DB, execID, stack, kind string) (pointer, excerpt string, ok bool, err error)
GetStackOutput returns the stored pointer + excerpt for a stack's output kind. ok is false when none is recorded.
func IsClassified ¶
IsClassified reports whether a plan ever classified (pr, environment).
func LatestExecutionID ¶ added in v0.6.0
LatestExecutionID returns the most recent execution id for (pr, environment). ok is false when none exists.
func LatestVerifyExecutionID ¶ added in v0.6.0
LatestVerifyExecutionID returns the most recent verify-context execution id for (pr, environment) — i.e. a run whose status_context begins with "verify". ok is false when none exists.
func MarkActive ¶
MarkActive flips every stored target for (pr, environment) to ACTIVE, so the gate drops out of PendingGates and the live approval panel shows approved rather than the stale request-time waiting state.
func MarkClassified ¶
MarkClassified records that (pr, environment) was classified by a plan, even when the plan was clean (zero gate_targets). Idempotent.
func Open ¶
Open opens the SQLite database at dsn, enables WAL, and applies all migrations. dsn is a modernc.org/sqlite DSN, e.g. a file path or "file:/data/server.db".
func SetCheckRunID ¶
SetCheckRunID records the GitHub check-run id created for an execution.
func UpdateStack ¶
UpdateStack ticks one stack's status (and optional failure detail).
func UpsertInit ¶
UpsertInit records an execution and its changed subgraph from an Init event. Re-init with the same id is upsert-safe. The phase column is intentionally left untouched: the lifecycle phase is owned by UpsertPhase, which may run before Init.
func UpsertPhase ¶
func UpsertPhase(db *sql.DB, p events.PhaseEvent) error
UpsertPhase sets the execution's lifecycle phase, creating a bare row if Init has not run yet. Identity fields are only overwritten when the event carries a non-zero value, so a bare phase bump never clobbers data set by an earlier Init (and an early phase event survives a later Init).
func UpsertStackOutput ¶ added in v0.6.0
UpsertStackOutput records (or updates) the pointer + tail excerpt for one stack's output of a given kind ("log", later "plan"/"verify").
Types ¶
type Execution ¶
type Execution struct {
ID string
Repo string
SHA string
PR int
Environment string
CheckRunID sql.NullInt64
Rev int
ReportMarkdown string
LogURL string
Status string // execution-level commit status (e.g. "in_progress"/"success"/"failure"); written by the serve handler, distinct from per-stack events.Status
StatusContext string
Phase string
CreatedAt time.Time
}
Execution is a row of the executions table.
func GetExecution ¶
GetExecution loads one execution row.
func ListExecutions ¶ added in v0.6.0
ListExecutions returns the most recent executions, newest first.
type Gate ¶
Gate identifies the unit an approval verdict is posted for.
func PendingGates ¶
PendingGates returns the (pr, environment) gates that still have at least one target not yet ACTIVE — i.e. gates whose verdict may still need posting. The reconcile loop walks these to self-heal the gap where an approval event is processed while the grant is still activating (some providers fire no further event for the activating→active transition) and dropped events / restarts.
type GateTarget ¶
GateTarget holds the per-(class,target) grant state recorded for a (pr, environment).
func TargetsFor ¶
TargetsFor returns every GateTarget recorded for (pr, environment). Returns a non-nil empty slice when none match.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package migrations embeds the goose SQL migrations for the server store.
|
Package migrations embeds the goose SQL migrations for the server store. |