workloadintent

package
v0.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package workloadintent persists durable desired intent, fenced worker execution receipts, independent health observations, and transactional River outbox jobs for MCP servers, raw managed deployments, staged image publications, and imperative component restarts.

Index

Constants

View Source
const (
	// QueueSchema isolates workload intent River tables from other platform tables.
	QueueSchema = "workload_intent_queue"
	// QueueWorkloads carries bounded reconciliation for servers, deployments, and restarts.
	QueueWorkloads = "workloads"
	// QueueRegistryPublication isolates long-running archive publications so transfers
	// cannot starve workload reconciliation.
	QueueRegistryPublication = "registry_publication"

	KindReconcileServer           = "reconcile_server"
	KindReconcileDeployment       = "reconcile_deployment"
	KindReconcileImagePublication = "reconcile_image_publication"
	KindReconcileComponentRestart = "reconcile_component_restart"
)

Variables

View Source
var (
	// ErrDisabled is returned when PLATFORM_WORKLOAD_INTENT_JOURNAL is not enabled.
	ErrDisabled = errors.New("workload intent journal is disabled")
	// ErrStaleReceipt is returned when a worker receipt or checkpoint fails fence
	// or desired revision validation.
	ErrStaleReceipt = errors.New("stale workload intent receipt")
	// ErrStaleObservation is returned when an observer epoch, revision, or target
	// UID fails conditional validation.
	ErrStaleObservation = errors.New("stale workload intent observation")
	// ErrInvalidInput is returned when a workload intent request is malformed.
	ErrInvalidInput = errors.New("invalid workload intent request")
	// ErrTagOverlapConflict is returned when a mutable-tag publication overlaps an
	// active publication under reject_overlap policy.
	ErrTagOverlapConflict = errors.New("concurrent publication already active for target tag")
	// ErrInvalidStateTransition is returned when an upload or intent transition is
	// not permitted from its current state.
	ErrInvalidStateTransition = errors.New("invalid workload intent state transition")
)

Functions

This section is empty.

Types

type ReconcileComponentRestartJobArgs

type ReconcileComponentRestartJobArgs struct {
	OperationID       string `json:"operationId"`
	DesiredRevisionID string `json:"desiredRevisionId"`
	RequestID         string `json:"requestId,omitempty"`
	Traceparent       string `json:"traceparent,omitempty"`
	Tracestate        string `json:"tracestate,omitempty"`
}

ReconcileComponentRestartJobArgs is the River payload for imperative component restarts.

func (ReconcileComponentRestartJobArgs) Kind

type ReconcileDeploymentJobArgs

type ReconcileDeploymentJobArgs struct {
	DeploymentID      string `json:"deploymentId"`
	DesiredRevisionID string `json:"desiredRevisionId"`
	RequestID         string `json:"requestId,omitempty"`
	Traceparent       string `json:"traceparent,omitempty"`
	Tracestate        string `json:"tracestate,omitempty"`
}

ReconcileDeploymentJobArgs is the River payload for raw Deployment/Service apply/delete.

func (ReconcileDeploymentJobArgs) Kind

type ReconcileImagePublicationJobArgs

type ReconcileImagePublicationJobArgs struct {
	PublicationID     string `json:"publicationId"`
	DesiredRevisionID string `json:"desiredRevisionId"`
	RequestID         string `json:"requestId,omitempty"`
	Traceparent       string `json:"traceparent,omitempty"`
	Tracestate        string `json:"tracestate,omitempty"`
}

ReconcileImagePublicationJobArgs is the River payload for finalized image publication.

func (ReconcileImagePublicationJobArgs) Kind

type ReconcileServerJobArgs

type ReconcileServerJobArgs struct {
	ServerID          string `json:"serverId"`
	DesiredRevisionID string `json:"desiredRevisionId"`
	RequestID         string `json:"requestId,omitempty"`
	Traceparent       string `json:"traceparent,omitempty"`
	Tracestate        string `json:"tracestate,omitempty"`
}

ReconcileServerJobArgs is the River payload for MCPServer apply/retirement.

func (ReconcileServerJobArgs) Kind

type Writer

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

Writer owns workload intent persistence and the insert-only River client.

func Open

func Open(ctx context.Context, db *sql.DB, dsn string) (*Writer, error)

Open prepares storage for the opt-in workload intent journal. The DSN must point to the same PostgreSQL database as db and support advisory locks.

func (*Writer) AbortImagePublication

func (w *Writer) AbortImagePublication(ctx context.Context, publicationID string, req apikit.ImagePublicationAbortRequest) (apikit.ImagePublicationIntent, error)

AbortImagePublication marks an unfinalized publication Aborted or Expired without queuing work.

func (*Writer) BeginImagePublication

BeginImagePublication registers a staged upload in Uploading state. It NEVER enqueues a River job until FinalizeImagePublication commits immutable staging metadata, and enforces mutable-tag overlap policy.

func (*Writer) ClaimDeploymentFence

func (w *Writer) ClaimDeploymentFence(ctx context.Context, deploymentID, workerID string) (apikit.DeploymentIntentFenceResponse, error)

ClaimDeploymentFence bumps the per-deployment execution fence epoch and returns the authoritative desired intent.

func (*Writer) ClaimImagePublicationFence

func (w *Writer) ClaimImagePublicationFence(ctx context.Context, publicationID, workerID string) (apikit.ImagePublicationFenceResponse, error)

ClaimImagePublicationFence bumps the execution fence for a publication and transitions Queued -> Publishing when claimed.

func (*Writer) ClaimObserverLease

func (w *Writer) ClaimObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.WorkloadObserverLeaseResponse, error)

ClaimObserverLease atomically increments the monotonic observer epoch for clusterKey so older observers cannot overwrite fresher observations.

func (*Writer) ClaimRestartOperationFence

func (w *Writer) ClaimRestartOperationFence(ctx context.Context, operationID, workerID string) (apikit.RestartOperationFenceResponse, error)

ClaimRestartOperationFence bumps the execution fence and marks Queued -> InProgress.

func (*Writer) ClaimServerFence

func (w *Writer) ClaimServerFence(ctx context.Context, serverID, workerID string) (apikit.ServerIntentFenceResponse, error)

ClaimServerFence bumps the per-server execution fence epoch and returns the authoritative desired server intent.

func (*Writer) CreateRestartOperation

CreateRestartOperation atomically persists a FIXED acceptance-time RestartedAt RFC3339 token, target components, and enqueues reconcile_component_restart on the workloads queue in one transaction.

func (*Writer) DeleteDeploymentIntent

func (w *Writer) DeleteDeploymentIntent(ctx context.Context, deploymentID string, req apikit.DeploymentIntentDeleteRequest) (apikit.DeploymentIntent, error)

DeleteDeploymentIntent marks a raw Deployment intent as deleted and enqueues reconcile_deployment on workloads in one transaction.

func (*Writer) FinalizeImagePublication

func (w *Writer) FinalizeImagePublication(ctx context.Context, publicationID string, req apikit.ImagePublicationFinalizeRequest) (apikit.ImagePublicationIntent, error)

FinalizeImagePublication commits immutable staged artifact coordinates and enqueues reconcile_image_publication on the dedicated registry_publication queue in ONE SQL transaction. Unfinalized uploads are never queued.

func (*Writer) GetDeploymentIntent

func (w *Writer) GetDeploymentIntent(ctx context.Context, deploymentID string) (apikit.DeploymentIntent, bool, error)

GetDeploymentIntent returns one raw Deployment intent by deployment_id.

func (*Writer) GetImagePublicationIntent

func (w *Writer) GetImagePublicationIntent(ctx context.Context, publicationID string) (apikit.ImagePublicationIntent, bool, error)

GetImagePublicationIntent returns one image publication intent by publication_id.

func (*Writer) GetRestartOperationIntent

func (w *Writer) GetRestartOperationIntent(ctx context.Context, operationID string) (apikit.RestartOperationIntent, bool, error)

GetRestartOperationIntent returns one restart operation by operation_id.

func (*Writer) GetServerIntent

func (w *Writer) GetServerIntent(ctx context.Context, serverID string) (apikit.ServerIntent, bool, error)

GetServerIntent returns one MCPServer intent by server_id.

func (*Writer) ListDeploymentIntents

func (w *Writer) ListDeploymentIntents(ctx context.Context) ([]apikit.DeploymentIntent, error)

ListDeploymentIntents returns all recorded raw Deployment intents.

func (*Writer) ListImagePublicationIntents

func (w *Writer) ListImagePublicationIntents(ctx context.Context) ([]apikit.ImagePublicationIntent, error)

ListImagePublicationIntents returns all recorded image publication intents.

func (*Writer) ListRestartOperationIntents

func (w *Writer) ListRestartOperationIntents(ctx context.Context) ([]apikit.RestartOperationIntent, error)

ListRestartOperationIntents returns all recorded imperative restart operations.

func (*Writer) ListServerIntents

func (w *Writer) ListServerIntents(ctx context.Context) ([]apikit.ServerIntent, error)

ListServerIntents returns all recorded MCPServer intents with receipts and observations.

func (*Writer) RecordDeploymentObservation

func (w *Writer) RecordDeploymentObservation(ctx context.Context, deploymentID string, req apikit.DeploymentIntentObservationRequest) (apikit.WorkloadStatusObservation, error)

RecordDeploymentObservation persists independent health observation for a raw Deployment without mutating desired intent, receipts, or River jobs.

func (*Writer) RecordDeploymentReceipt

func (w *Writer) RecordDeploymentReceipt(ctx context.Context, deploymentID string, req apikit.DeploymentIntentReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

RecordDeploymentReceipt records a fenced worker execution receipt for one raw deployment.

func (*Writer) RecordImagePublicationReceipt

func (w *Writer) RecordImagePublicationReceipt(ctx context.Context, publicationID string, req apikit.ImagePublicationReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

RecordImagePublicationReceipt records a fenced publication receipt, helper identity, verified manifest digest, and resulting publication status.

func (*Writer) RecordRestartComponentCheckpoint

func (w *Writer) RecordRestartComponentCheckpoint(ctx context.Context, operationID string, req apikit.RestartComponentCheckpointRequest) (apikit.RestartOperationIntent, error)

RecordRestartComponentCheckpoint durably records completion for one target component under the active execution fence without modifying RestartedAt.

func (*Writer) RecordRestartOperationReceipt

func (w *Writer) RecordRestartOperationReceipt(ctx context.Context, operationID string, req apikit.RestartOperationReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

RecordRestartOperationReceipt records a fenced final receipt for a restart operation.

func (*Writer) RecordServerObservation

func (w *Writer) RecordServerObservation(ctx context.Context, serverID string, req apikit.ServerIntentObservationRequest) (apikit.WorkloadStatusObservation, error)

RecordServerObservation persists independent health observation without mutating desired intent, receipts, or River jobs.

func (*Writer) RecordServerReceipt

func (w *Writer) RecordServerReceipt(ctx context.Context, serverID string, req apikit.ServerIntentReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

RecordServerReceipt records a fenced worker execution receipt for one server.

func (*Writer) RecordServerRetirementCheckpoint

func (w *Writer) RecordServerRetirementCheckpoint(ctx context.Context, serverID string, req apikit.ServerRetirementCheckpointRequest) (apikit.ServerIntent, error)

RecordServerRetirementCheckpoint durably persists ordered server retirement progress fenced by fence_epoch and desired_revision_id.

func (*Writer) RetireServerIntent

func (w *Writer) RetireServerIntent(ctx context.Context, serverID string, req apikit.ServerIntentRetireRequest) (apikit.ServerIntent, error)

RetireServerIntent transitions a server intent to Retiring, captures TargetCRUID, and enqueues reconcile_server on workloads in one transaction.

func (*Writer) UpsertDeploymentIntent

func (w *Writer) UpsertDeploymentIntent(ctx context.Context, req apikit.DeploymentIntentUpsertRequest) (apikit.DeploymentIntent, error)

UpsertDeploymentIntent atomically records desired raw Deployment/Service intent and enqueues reconcile_deployment on the workloads queue in one transaction.

func (*Writer) UpsertServerIntent

func (w *Writer) UpsertServerIntent(ctx context.Context, req apikit.ServerIntentUpsertRequest) (apikit.ServerIntent, error)

UpsertServerIntent atomically records desired Active MCPServer intent and enqueues reconcile_server on the workloads queue in one transaction.

Jump to

Keyboard shortcuts

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