Help us shape the future of Go! Take the 2026 Go Developer Survey

entity

package
v0.3.0-20261028150941-... Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DegreeGreen is a fully healthy scope: nothing broken.
	DegreeGreen = 0.0
	// DegreePartial is a broken scope with individual project results available.
	DegreePartial = 0.5
	// DegreeBroken is a fully broken scope.
	DegreeBroken = 1.0
)

Degree bounds. A degree answers "how broken was this scope?" on a closed interval, so both endpoints are named rather than spelled as bare literals.

Variables

This section is empty.

Functions

func CompareRequestID

func CompareRequestID(a, b string) (int, error)

CompareRequestID compares ingest order of two request IDs in the same queue. Callers must ensure the IDs belong to the same queue. Returns -1 if a is older than b, 0 if equal, 1 if a is newer than b. IDs must be canonical positive decimal strings whose scope is carried separately.

func QueueLogID

func QueueLogID(version int64) string

QueueLogID returns the stable occurrence identity for a state version.

Types

type Build

type Build struct {
	// ID is the build's own key: the runner-assigned id returned by
	// Trigger (e.g. a Buildkite build number). Opaque; never parsed or
	// derived by stovepipe.
	ID string `json:"id"`
	// RequestID is the Request this build validates (Build->Request
	// navigation; no reverse index from Request to its builds is needed).
	RequestID string `json:"request_id"`
	// Status is the build's lifecycle state.
	Status BuildStatus `json:"status"`
	// Version is used for optimistic locking. Versioning starts at 1 and
	// is incremented for each change to the object.
	Version int32 `json:"version"`
}

Build represents a single build triggered for a Request's commit. All fields except Status and Version are immutable after creation — build is the sole creator (via BuildStore.Create), and buildsignal is the sole writer of Status/Version afterward.

type BuildID

type BuildID struct {
	// ID is the runner-assigned identifier for the build.
	ID string `json:"id"`
}

BuildID wraps the runner-assigned build identifier for BuildRunner Status/Cancel/Trigger parameters.

type BuildIssue

type BuildIssue struct {
	// TaskID identifies the logical validation task, stable across builds and retries; it must be nonempty.
	TaskID string `json:"task_id"`
	// UnitID identifies the failed unit within the task; empty for a task-wide issue.
	// Repeated observations of the same condition use the same TaskID and UnitID.
	UnitID string `json:"unit_id"`
	// FixID is the opaque executor-provided repair identifier; empty means none is recorded.
	FixID string `json:"fix_id"`
	// Version is the optimistic-lock version, initially zero.
	Version int32 `json:"version"`
}

BuildIssue is a validation failure observed within a build, identified by task and optional unit.

type BuildMetadata

type BuildMetadata map[string]string

BuildMetadata carries caller-supplied, provider-echoed free-form metadata about a build. The runner must not depend on its contents. Empty today; expected to carry real data eventually (e.g. conflict-graph info, or other upstream decisions relevant to the build) once a concrete need lands in either domain — the shape is deferred until then, not decided here.

type BuildStatus

type BuildStatus string

BuildStatus defines the possible states of a build. Shaped the same as SubmitQueue's own BuildStatus (submitqueue/entity/build.go), but defined locally rather than shared — see build.md's "Alternatives considered for sharing the contract".

const (
	// BuildStatusUnknown is the unreachable zero value, set by default when
	// the structure is initialized. It should never be seen in the system.
	BuildStatusUnknown BuildStatus = ""

	// BuildStatusAccepted indicates the build has been accepted for
	// execution by the runner via Trigger, but has not yet started.
	BuildStatusAccepted BuildStatus = "accepted"

	// BuildStatusRunning indicates the build is currently executing.
	BuildStatusRunning BuildStatus = "running"

	// BuildStatusSucceeded indicates the build completed successfully.
	// This is a terminal state.
	BuildStatusSucceeded BuildStatus = "succeeded"

	// BuildStatusFailed indicates the build did not complete successfully.
	// This is a terminal state.
	BuildStatusFailed BuildStatus = "failed"

	// BuildStatusCancelled indicates the build was cancelled.
	// This is a terminal state.
	BuildStatusCancelled BuildStatus = "cancelled"
)

func (BuildStatus) IsTerminal

func (s BuildStatus) IsTerminal() bool

IsTerminal returns true if the status represents a final state (Succeeded, Failed, or Cancelled). A terminal status is write-once: once buildsignal persists one, a later poll reporting a different terminal value must never overwrite it (see buildsignal.md's Algorithm, step 6).

type BuildStrategy

type BuildStrategy string

BuildStrategy defines how build validates the request's commit.

const (
	// BuildStrategyUnknown is the zero value before process chooses a strategy.
	BuildStrategyUnknown BuildStrategy = ""
	// BuildStrategyIncrementalSinceGreen validates only the delta since the pinned baseline URI.
	BuildStrategyIncrementalSinceGreen BuildStrategy = "incremental_since_green"
	// BuildStrategyFull validates the whole repo from scratch.
	BuildStrategyFull BuildStrategy = "full"
)

type GetProjectStatusRequest

type GetProjectStatusRequest struct {
	// Queue identifies the queue containing the validation request.
	Queue string
	// RequestID is the queue-scoped decimal identifier, empty when selecting by URI.
	RequestID string
	// ChangeURI identifies the exact commit under validation, empty when selecting by request ID.
	ChangeURI string
	// Projects limits results to the supplied consumer-defined project IDs; empty selects all recorded projects.
	Projects []string
	// PageSize is the maximum number of project results per page.
	PageSize int32
	// PageToken is an opaque continuation token for full project-result pagination.
	PageToken string
}

GetProjectStatusRequest selects a validation request by queue and exactly one of request ID or commit URI.

type GetProjectStatusResult

type GetProjectStatusResult struct {
	// RequestSummary is the authoritative validation projection selected by the lookup.
	RequestSummary RequestSummary
	// RepositoryValidationFact is the repository result when HasRepositoryValidationFact is true.
	RepositoryValidationFact ValidationFact
	// HasRepositoryValidationFact distinguishes a missing fact from a recorded green result.
	HasRepositoryValidationFact bool
	// ProjectResultsComplete reports whether the implementation has finished its project-result set.
	ProjectResultsComplete bool
	// ProjectValidationFacts contains recorded results in request order, or descending degree then ascending project ID when Projects is empty.
	ProjectValidationFacts []ValidationFact
	// NextPageToken continues requested-project result pagination when another page exists.
	NextPageToken string
	// UpdatedAtMs is the newest durable lifecycle or result timestamp represented by the response.
	UpdatedAtMs int64
}

GetProjectStatusResult is the current validation projection for one request.

type GetQueueStatusRequest

type GetQueueStatusRequest struct {
	// Queue is the stable repo-and-ref namespace.
	Queue string
	// ChangeURI is an immutable commit URI; empty selects current enablement.
	ChangeURI string
}

type GetQueueStatusResult

type GetQueueStatusResult struct {
	// Queue is the selected repo-and-ref namespace.
	Queue string
	// Enablement is current enablement or enablement covering the requested commit.
	Enablement QueueState
}

type GetRequestHistoryByIDRequest

type GetRequestHistoryByIDRequest struct {
	// ID is the queue-scoped identifier of the request.
	ID string
	// Queue is the logical queue containing the request and scopes the lookup.
	Queue string
}

GetRequestHistoryByIDRequest identifies one retained request history by request ID.

type GetRequestHistoryByURIRequest

type GetRequestHistoryByURIRequest struct {
	// URI is the exact VCS-agnostic commit URI associated with the request.
	URI string
	// Queue is the logical queue containing the request and scopes the lookup.
	Queue string
}

GetRequestHistoryByURIRequest identifies retained histories by an exact commit URI.

type IngestRequest

type IngestRequest struct {
	// Queue is the name of the queue whose head commit should be ingested.
	Queue string
	// HasEnablement distinguishes an explicit decision from ordinary ingestion.
	HasEnablement bool
	// Enablement is the optional explicit enabled or disabled setting.
	Enablement QueueEnablement
}

IngestRequest represents the validated inputs of an ingest RPC call. The controller resolves the queue's head commit and mints a request ID internally.

type IngestResult

type IngestResult struct {
	// ID is the canonical decimal request identifier assigned within the selected queue.
	ID string
	// Enablement is the applied decision or the observed durable enablement.
	Enablement QueueState
}

IngestResult is the outcome of a successful ingest operation.

type IssueEvent

type IssueEvent string

IssueEvent identifies an issue lifecycle transition.

const (
	// IssueEventUnknown is the unset event value.
	IssueEventUnknown IssueEvent = ""
	// IssueEventOpened records that an issue became open.
	IssueEventOpened IssueEvent = "opened"
	// IssueEventResolved records that an issue was resolved.
	IssueEventResolved IssueEvent = "resolved"
)

type IssueLog

type IssueLog struct {
	// TaskID identifies the logical validation task.
	TaskID string `json:"task_id"`
	// UnitID identifies the validation unit; empty for a task-wide issue.
	UnitID string `json:"unit_id"`
	// Event identifies the opening or resolution.
	Event IssueEvent `json:"event"`
	// BuildID identifies the build where the issue was first seen or confirmed resolved.
	BuildID string `json:"build_id"`
	// TimestampMs is when the transition was first recorded, in Unix milliseconds.
	TimestampMs int64 `json:"timestamp_ms"`
}

IssueLog is an immutable issue lifecycle transition within a queue. Task, unit, build, and event identify one transition.

func (IssueLog) Validate

func (l IssueLog) Validate() error

Validate verifies the invariants required for a newly persisted issue log.

type IssueState

type IssueState struct {
	// TaskID identifies the logical validation task and must be nonempty.
	TaskID string `json:"task_id"`
	// UnitID identifies the validation unit; empty for a task-wide issue.
	UnitID string `json:"unit_id"`
	// Status distinguishes open and closed issues.
	Status IssueStatus `json:"status"`
	// FirstSeenBuildID identifies the current or most recent opening.
	FirstSeenBuildID string `json:"first_seen_build_id"`
	// LastProcessedBuildID identifies the most recent build applied to this issue.
	LastProcessedBuildID string `json:"last_processed_build_id"`
	// LastChangedBuildID identifies the build responsible for the current open or closed status.
	LastChangedBuildID string `json:"last_changed_build_id"`
	// ChangedAtMs is the latest status transition's timestamp in Unix milliseconds.
	ChangedAtMs int64 `json:"changed_at_ms"`
	// Version is the positive optimistic-lock version; it never resets on reopening.
	Version int32 `json:"version"`
}

IssueState is the latest state of a validation condition within a queue. Closed records retain their identity and version across later openings.

func (IssueState) Validate

func (s IssueState) Validate() error

Validate checks the identity, status, and version of an issue state.

type IssueStatus

type IssueStatus string

IssueStatus describes whether a validation issue is open or closed.

const (
	// IssueStatusUnknown is the unset status.
	IssueStatusUnknown IssueStatus = ""
	// IssueStatusOpen identifies an open validation issue.
	IssueStatusOpen IssueStatus = "open"
	// IssueStatusClosed identifies an issue that is no longer open.
	IssueStatusClosed IssueStatus = "closed"
)

type IssueTrackingPhase

type IssueTrackingPhase string

IssueTrackingPhase describes whether one source build's issue updates are underway or complete.

const (
	// IssueTrackingPhaseUnknown is the unset phase.
	IssueTrackingPhaseUnknown IssueTrackingPhase = ""
	// IssueTrackingPhaseRefreshing means reported build issues are being opened or kept open.
	IssueTrackingPhaseRefreshing IssueTrackingPhase = "refreshing"
	// IssueTrackingPhaseRefreshed means a refresh pass completed; later refresh notifications remain eligible.
	IssueTrackingPhaseRefreshed IssueTrackingPhase = "refreshed"
	// IssueTrackingPhaseFinalizing means existing issues are being reconciled after all reported issues were applied.
	IssueTrackingPhaseFinalizing IssueTrackingPhase = "finalizing"
	// IssueTrackingPhaseFinalized means final reconciliation completed; later refresh notifications are ignored.
	IssueTrackingPhaseFinalized IssueTrackingPhase = "finalized"
	// IssueTrackingPhaseAbandoning means an incomplete pass is being stopped without processing its remaining range.
	IssueTrackingPhaseAbandoning IssueTrackingPhase = "abandoning"
	// IssueTrackingPhaseAbandoned means a pass stopped before completing its range.
	IssueTrackingPhaseAbandoned IssueTrackingPhase = "abandoned"
)

type IssueTrackingState

type IssueTrackingState struct {
	// RequestID is the newest accepted source request, compared by ingest order.
	RequestID string `json:"request_id"`
	// BuildID identifies the source build whose pass is underway or most recently completed.
	BuildID string `json:"build_id"`
	// NotificationID identifies the message that owns this reconciliation pass.
	NotificationID string `json:"notification_id"`
	// CursorTaskID identifies the current issue's task; active passes revisit it on continuation.
	// Empty with an empty CursorUnitID starts the phase's range.
	CursorTaskID string `json:"cursor_task_id"`
	// CursorUnitID identifies the unit at the cursor; empty is task-wide.
	CursorUnitID string `json:"cursor_unit_id"`
	// Finalize identifies a terminal reconciliation pass rather than an ordinary refresh.
	Finalize bool `json:"finalize"`
	// HasTaskWideIssues records whether this pass has encountered a task-wide issue.
	HasTaskWideIssues bool `json:"has_task_wide_issues"`
	// Phase distinguishes active, completed, and abandoned work.
	Phase IssueTrackingPhase `json:"phase"`
	// Version is the positive optimistic-lock version of this state.
	Version int32 `json:"version"`
}

IssueTrackingState is the queue-scoped source-order boundary and resumable reconciliation state.

func (IssueTrackingState) Validate

func (s IssueTrackingState) Validate() error

Validate verifies the identity, phase, and version of a persisted state.

type ListRequest

type ListRequest struct {
	// Queue is the required configured queue containing the requests.
	Queue string
	// AcceptedAtOrAfterMs is the inclusive Unix millisecond bound when HasAcceptedAtOrAfterMs is true.
	AcceptedAtOrAfterMs int64
	// HasAcceptedAtOrAfterMs distinguishes an explicit lower bound from an omitted one.
	HasAcceptedAtOrAfterMs bool
	// AcceptedBeforeMs is the exclusive Unix millisecond bound when HasAcceptedBeforeMs is true.
	AcceptedBeforeMs int64
	// HasAcceptedBeforeMs distinguishes an explicit upper bound from an omitted one.
	HasAcceptedBeforeMs bool
	// PageSize is the maximum number of summaries, from 1 to 200; zero selects 50.
	PageSize int32
	// PageToken is an opaque continuation bound to the queue and resolved time window.
	PageToken string
}

ListRequest selects current request summaries from one queue by acceptance time.

type ListResult

type ListResult struct {
	// Requests contains summaries ordered by descending acceptance time, then descending bytewise request ID.
	Requests []RequestSummary
	// NextPageToken continues after the last returned key; empty means no further mapping was observed.
	NextPageToken string
}

ListResult is one page of current summaries, not a snapshot across pages.

type OpenIssue

type OpenIssue struct {
	// TaskID identifies the logical validation task and must be nonempty.
	TaskID string `json:"task_id"`
	// UnitID identifies the validation unit; empty for a task-wide issue.
	UnitID string `json:"unit_id"`
	// FirstSeenBuildID identifies the build where this opening of the issue was first observed.
	FirstSeenBuildID string `json:"first_seen_build_id"`
}

OpenIssue is a currently open validation issue within a queue. Its task and unit identify the condition; the first-seen build identifies this opening.

type ProjectFactByDegree

type ProjectFactByDegree struct {
	// URI is the commit containing the project result.
	URI string
	// Degree is the breakage degree in [0, 1], ordered highest first.
	Degree float64
	// Project identifies the fact and breaks equal-degree ties in ascending bytewise order.
	Project string
}

ProjectFactByDegree maps an ordered key to an immutable project fact within a queue.

func NewProjectFactByDegree

func NewProjectFactByDegree(fact ValidationFact) (ProjectFactByDegree, error)

NewProjectFactByDegree derives a degree lookup entry from a named project's fact. Invalid degrees, empty URIs and whole-repository facts return an error.

type Queue

type Queue struct {

	// Name is the stable logical id for the queue. It should be unique within the system.
	Name string `json:"name"`

	// LastGreenURI is the queue's last-known-good commit: the most recent head at which
	// whole-repo validation recorded green (health degree 0). Empty until the first such outcome.
	LastGreenURI string `json:"last_green_uri"`

	// LastGreenRequestID is the request that established LastGreenURI. The bookmark only
	// moves forward: a green outcome adopts the pair only when this id is empty or older
	// than the candidate's, compared by ingest order via CompareRequestID.
	LastGreenRequestID string `json:"last_green_request_id"`

	// InFlightCount is the number of trunk validations admitted by process but not yet terminal.
	InFlightCount int32 `json:"in_flight_count"`

	// LatestRequestID is the request id of the newest head ingest accepted for this queue.
	// Empty until the first request is created. Coalescing compares IDs via CompareRequestID.
	LatestRequestID string `json:"latest_request_id"`

	// Enablement is the applied enabled/disabled state; empty means unregistered.
	Enablement QueueEnablement `json:"enablement"`

	// EnablementVersion is the queue-scoped enablement sequence; zero means unregistered.
	// Operational changes do not advance this sequence.
	EnablementVersion int64 `json:"enablement_version"`

	// EffectiveFromCommitURI is the inclusive immutable enablement boundary; empty for initial registration.
	EffectiveFromCommitURI string `json:"effective_from_commit_uri"`

	// EnablementChangedAtMs is the enablement application timestamp in Unix milliseconds.
	EnablementChangedAtMs int64 `json:"enablement_changed_at_ms"`

	// Version is the version of the object. It is used for optimistic locking.
	// Versioning starts at 1 and is incremented for each change to the object.
	Version int32 `json:"version"`
}

Queue holds per-queue pipeline coordination state for a named repo+ref (e.g. "monorepo/main").

func (Queue) EnablementState

func (q Queue) EnablementState() QueueState

type QueueConfig

type QueueConfig struct {
	// Name uniquely identifies this queue within the system.
	// Referenced by Request.Queue.
	Name string `json:"name" yaml:"name"`
	// MaxConcurrent is the cap on concurrent in-flight validations for the queue.
	MaxConcurrent int32 `json:"max_concurrent" yaml:"max_concurrent"`
	// GateWaitDelayMs is the redelivery delay while the latest head waits for a slot.
	GateWaitDelayMs int64 `json:"gate_wait_delay_ms" yaml:"gate_wait_delay_ms"`
}

QueueConfig holds deployment configuration for a Stovepipe validation queue. Mutable runtime state (latest head, in-flight count) lives on the Queue row; knobs such as max_concurrent are resolved here at gate-check time. Immutable after load.

type QueueEnablement

type QueueEnablement string

QueueEnablement is applied enablement, independent of execution controls and verdicts.

const (
	// QueueEnablementUnknown is unset and never an explicit disablement.
	QueueEnablementUnknown  QueueEnablement = ""
	QueueEnablementEnabled  QueueEnablement = "enabled"
	QueueEnablementDisabled QueueEnablement = "disabled"
)

type QueueLog

type QueueLog struct {
	// ID is the stable queue-scoped occurrence identity derived from QueueStateVersion.
	ID string
	// Queue is the stable repo-and-ref namespace.
	Queue string
	// TimestampMs is the application's timestamp in Unix milliseconds.
	TimestampMs int64
	// State is the committed enabled or disabled value.
	State QueueEnablement
	// QueueStateVersion is the positive version identifying the applied state.
	QueueStateVersion int64
	// EffectiveFromCommitURI is the inclusive immutable boundary; empty only at version 1.
	EffectiveFromCommitURI string
}

QueueLog is one immutable occurrence of a committed enablement state.

func (QueueLog) Snapshot

func (l QueueLog) Snapshot() QueueState

func (QueueLog) Validate

func (l QueueLog) Validate() error

type QueueState

type QueueState struct {
	// Queue is the stable repo-and-ref namespace, at most 255 bytes.
	Queue string
	// State is enabled or disabled.
	State QueueEnablement
	// EffectiveFromCommitURI is the inclusive immutable boundary, at most 255 bytes; empty only at version 1.
	EffectiveFromCommitURI string
	// ChangedAtMs is the application timestamp in Unix milliseconds.
	ChangedAtMs int64
	// Version is the positive queue-scoped enablement sequence.
	Version int64
}

QueueState describes applied enablement, independent of storage row versions.

func (QueueState) Validate

func (s QueueState) Validate() error

type QueueSummary

type QueueSummary struct {
	// Queue is the stable repo-and-ref namespace, at most 255 bytes.
	Queue string
	// State is the latest materialized enabled/disabled value.
	State QueueEnablement
	// QueueStateVersion identifies the applied enablement occurrence represented here.
	QueueStateVersion int64
	// EffectiveFromCommitURI is the inclusive immutable boundary; empty at state version 1.
	EffectiveFromCommitURI string
	// StateTimestampMs is the occurrence timestamp in Unix milliseconds.
	StateTimestampMs int64
	// Version is the positive optimistic-lock version of this projection.
	Version int64
}

QueueSummary is the current read model derived from retained queue history.

func (QueueSummary) Snapshot

func (s QueueSummary) Snapshot() QueueState

func (QueueSummary) Validate

func (s QueueSummary) Validate() error

type Request

type Request struct {

	// ID is the canonical decimal request identifier, unique within Queue.
	ID string `json:"id"`
	// Queue is the name of the queue (a named repo+ref) being validated. Together with ID it
	// identifies the request and is the stable handle the ingest caller supplies.
	Queue string `json:"queue"`
	// URI is the opaque, VCS-agnostic locator of the commit under validation, as produced by the
	// SourceControl extension.
	URI string `json:"uri"`

	// BuildStrategy is the validation scope process chose when admitting this request.
	BuildStrategy BuildStrategy `json:"build_strategy"`
	// BaseURI is the base URI to be used for this request when the strategy is incremental.
	// Empty for full builds and cold start.
	BaseURI string `json:"base_uri"`

	// State is the current state of the request in the pipeline.
	State RequestState `json:"state"`
	// TerminalBuildID is the build that established this request's terminal
	// state. It is empty when no build established the terminal state.
	TerminalBuildID string `json:"terminal_build_id"`
	// Version is the version of the object. It is used for optimistic locking.
	// Versioning starts at 1 and is incremented for each change to the object.
	Version int32 `json:"version"`
}

Request represents a single validation of a queue at a particular commit. The queue reports a newly observed commit, Stovepipe mints a Request (identity scoped by the queue), and the request flows through the pipeline accumulating state.

type RequestAcceptance

type RequestAcceptance struct {
	// Queue is the queue containing the request.
	Queue string
	// AcceptedAtMs is the original retained acceptance timestamp in Unix milliseconds and is positive.
	AcceptedAtMs int64
	// RequestID identifies the request within Queue and breaks timestamp ties bytewise.
	RequestID string
}

RequestAcceptance is an immutable mapping from (queue, acceptance time, request ID) to a request.

type RequestEvent

type RequestEvent string

RequestEvent identifies a retained occurrence that does not change request state.

const (
	// RequestEventUnknown is the unset event value.
	RequestEventUnknown RequestEvent = ""
	// RequestEventBuildTriggered records that a build was durably accepted.
	RequestEventBuildTriggered RequestEvent = "build_triggered"
	// RequestEventBuildFinished records that a build first reached a terminal status.
	RequestEventBuildFinished RequestEvent = "build_finished"
	// RequestEventValidationFactRecorded records that an immutable validation verdict was established.
	RequestEventValidationFactRecorded RequestEvent = "validation_fact_recorded"
	// RequestEventProjectFactsRecorded records that all project validation facts for a request were established.
	RequestEventProjectFactsRecorded RequestEvent = "project_facts_recorded"
	// RequestEventRecordAbandoned records that record-stage work stopped after exhausting retries.
	RequestEventRecordAbandoned RequestEvent = "record_abandoned"
	// RequestEventBuildAnalysisAbandoned records incomplete build analysis, not a validation outcome.
	RequestEventBuildAnalysisAbandoned RequestEvent = "build_analysis_abandoned"
	// RequestEventIssueTrackingAbandoned records incomplete issue tracking, not a validation outcome.
	RequestEventIssueTrackingAbandoned RequestEvent = "issue_tracking_abandoned"
)

type RequestHistory

type RequestHistory struct {
	// RequestID is the queue-scoped identifier of the request.
	RequestID string
	// Events are retained request-log events ordered by occurrence time and stable identity.
	Events []RequestLog
	// RequestSummary is the current lifecycle projection for this request.
	RequestSummary RequestSummary
}

RequestHistory groups retained events and the current materialized summary for one request.

type RequestLog

type RequestLog struct {
	// ID is the stable identity of the occurrence within the request.
	ID string `json:"id"`
	// Queue is the logical queue containing the request and scopes RequestID.
	Queue string `json:"queue"`
	// RequestID identifies the request whose log contains this record.
	RequestID string `json:"request_id"`
	// TimestampMs is when the occurrence was first retained, in Unix milliseconds.
	TimestampMs int64 `json:"timestamp_ms"`
	// State is the durable request state recorded by a state record and is unset on an event record.
	State RequestState `json:"state"`
	// Event identifies the occurrence recorded by an event record and is unset on a state record.
	Event RequestEvent `json:"event"`
	// RequestVersion is the durable request version recorded by a state record and is zero on an event record.
	RequestVersion int32 `json:"request_version"`
	// OutcomeReason is the durable domain reason for a terminal request state and is otherwise unset.
	OutcomeReason RequestOutcomeReason `json:"outcome_reason"`
	// Metadata contains optional occurrence context; nil and empty maps are equivalent.
	Metadata map[string]string `json:"metadata"`
}

RequestLog is one immutable request state or explanatory lifecycle occurrence.

func (RequestLog) Validate

func (e RequestLog) Validate() error

Validate verifies the invariants required for a newly persisted request log.

type RequestOutcomeReason

type RequestOutcomeReason string

RequestOutcomeReason identifies the durable domain reason for a terminal request state.

const (
	// RequestOutcomeReasonUnknown is the unset outcome reason.
	RequestOutcomeReasonUnknown RequestOutcomeReason = ""
	// RequestOutcomeReasonBuildSucceeded indicates that the request's build succeeded.
	RequestOutcomeReasonBuildSucceeded RequestOutcomeReason = "build_succeeded"
	// RequestOutcomeReasonBuildFailed indicates that the request's build failed.
	RequestOutcomeReasonBuildFailed RequestOutcomeReason = "build_failed"
	// RequestOutcomeReasonBuildCancelled indicates that the request's build was cancelled.
	RequestOutcomeReasonBuildCancelled RequestOutcomeReason = "build_cancelled"
	// RequestOutcomeReasonProcessingFailed indicates that validation could not be prepared.
	RequestOutcomeReasonProcessingFailed RequestOutcomeReason = "processing_failed"
	// RequestOutcomeReasonBuildPollingExhausted indicates that build status could not be resolved.
	RequestOutcomeReasonBuildPollingExhausted RequestOutcomeReason = "build_polling_exhausted"
	// RequestOutcomeReasonValidationTimeout indicates that validation exceeded its allowed duration.
	RequestOutcomeReasonValidationTimeout RequestOutcomeReason = "validation_timeout"
	// RequestOutcomeReasonSupersededByNewerHead indicates that a newer request replaced this one.
	RequestOutcomeReasonSupersededByNewerHead RequestOutcomeReason = "superseded_by_newer_head"
)

type RequestState

type RequestState string

RequestState defines the internal state of a Stovepipe validation request as it moves through the pipeline. States are internal and used to implement a state machine; a customer-facing status type may be layered on top later, as in SubmitQueue.

const (
	// RequestStateUnknown is the unreachable zero value. It is set by default when the
	// structure is initialized and should never be seen in the system.
	RequestStateUnknown RequestState = ""
	// RequestStateAccepted is the initial state of a request: a new commit has been observed
	// for the queue and the request has been admitted into the pipeline, but no validation
	// strategy has been chosen yet.
	RequestStateAccepted RequestState = "accepted"
	// RequestStateProcessing means process admitted the request, recorded build strategy and
	// baseline, and published to build.
	RequestStateProcessing RequestState = "processing"
	// RequestStateSuperseded means process skipped the request because a newer head exists.
	RequestStateSuperseded RequestState = "superseded"
	// RequestStateSucceeded means the build validating this request's commit reached a
	// successful terminal status.
	RequestStateSucceeded RequestState = "succeeded"
	// RequestStateFailed means the build validating this request's commit reached an
	// unsuccessful terminal status, or the request could never complete and was forced to a
	// conservative unsuccessful outcome (see workflow.md's fail-closed posture).
	RequestStateFailed RequestState = "failed"
	// RequestStateCancelled means the build validating this request's commit was cancelled
	// before reaching a verdict. Distinct from failed: what a cancellation implies for
	// greenness is decided where greenness is recorded, not here.
	RequestStateCancelled RequestState = "cancelled"
)

func (RequestState) HasBuildOutcome

func (s RequestState) HasBuildOutcome() bool

HasBuildOutcome returns true if the state records the terminal status of this request's build: succeeded, failed, or cancelled. Superseded requests never ran a build, so they are terminal without an outcome.

func (RequestState) IsTerminal

func (s RequestState) IsTerminal() bool

IsTerminal returns true if the state is one the pipeline never advances past: superseded (a newer head preempted this request before it was validated) or one of the three build outcomes. Greenness derived from an outcome is a separate fact recorded against the URI, so it is not part of this lifecycle.

type RequestSummary

type RequestSummary struct {
	// RequestID is the canonical decimal request identifier, unique within Queue.
	RequestID string
	// Queue is the queue containing the request.
	Queue string
	// URI is the commit validated by the request.
	URI string
	// BaseURI is the incremental-validation baseline and is empty before selection or for a full build.
	BaseURI string
	// State is the current durable request lifecycle state.
	State RequestState
	// RequestVersion is the version of the request state represented by this summary.
	RequestVersion int32
	// StateTimestampMs is when the represented state was first retained, in Unix milliseconds.
	StateTimestampMs int64
	// AcceptedAtMs is the original acceptance timestamp in Unix milliseconds; zero means unknown and a positive value is immutable.
	AcceptedAtMs int64
	// ProjectResultsCompletedAtMs is the completion timestamp in Unix milliseconds; zero means unknown and a positive value is immutable.
	ProjectResultsCompletedAtMs int64
	// OutcomeReason is the reason for the represented state; empty means unavailable or inapplicable.
	OutcomeReason RequestOutcomeReason
	// Version is the optimistic-lock version of this materialized view.
	Version int32
}

RequestSummary is the materialized current view of a validation request.

type ValidationFact

type ValidationFact struct {
	// URI is the commit the fact describes, in the queue's VCS-agnostic locator
	// form. Unique per (queue, URI, project).
	URI string `json:"uri"`
	// Project is the scope the degree applies to. Empty means the whole
	// repository; named projects narrow the fact to part of it.
	Project string `json:"project"`
	// Degree is how broken the scope was, on the closed interval
	// [DegreeGreen, DegreeBroken]. A failed repository with project results has
	// DegreePartial; without project results it has DegreeBroken.
	Degree float64 `json:"degree"`
	// RequestID is the request that established the fact.
	RequestID string `json:"request_id"`
	// CreatedAt is the millisecond timestamp at which the fact was recorded.
	CreatedAt int64 `json:"created_at"`
}

ValidationFact is the durable record of how broken one scope was at one commit.

It is immutable and create-only: the first fact written for an identity is the permanent answer, and a later contradicting outcome for the same identity is dropped rather than overwriting it. Identity is (queue, URI, project) — the queue is the binding of the store the fact lives in and so is not carried on the fact itself.

Absence is distinct from DegreeGreen: a URI with no fact has not been validated, which is not the same as having been validated and found healthy.

func (ValidationFact) IsGreen

func (f ValidationFact) IsGreen() bool

IsGreen reports whether the fact records a fully healthy scope. Any degree above DegreeGreen is some amount of broken.

Jump to

Keyboard shortcuts

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