releaseworkflow

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: GPL-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package releaseworkflow coordinates immutable release workflow stages and keeps repository and private-resource concerns behind one command boundary.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWorkflowNotFound hides both absent and foreign-owner workflows.
	ErrWorkflowNotFound = errors.New("release workflow not found")
	// ErrRevisionConflict reports optimistic concurrency failure.
	ErrRevisionConflict = errors.New("release workflow revision conflict")
	// ErrIdempotencyConflict reports reuse of a key with different command input.
	ErrIdempotencyConflict = errors.New("release workflow idempotency conflict")
	// ErrOperationConflict reports another active command or mismatched operation idempotency.
	ErrOperationConflict = errors.New("release workflow operation conflict")
	// ErrInvalidTransition reports a command whose dependencies are incomplete.
	ErrInvalidTransition = errors.New("release workflow invalid transition")
	// ErrPrivateResourceUnavailable reports missing, expired, or restart-invalidated authority.
	ErrPrivateResourceUnavailable = errors.New("release workflow private resource unavailable")
	// ErrPrivateResourceConsumed reports reuse of single-use private authority.
	ErrPrivateResourceConsumed = errors.New("release workflow private resource consumed")
	// ErrPrivateResourceIntegrity reports digest or metadata tampering in durable private authority.
	ErrPrivateResourceIntegrity = errors.New("release workflow private resource integrity check failed")
)

Functions

func CommandOperationKind

func CommandOperationKind(command Command) (api.OperationKind, bool)

CommandOperationKind classifies one user intent without transport-owned type switches.

func DownstreamEligibleProjections

func DownstreamEligibleProjections(
	projections api.TrackerReleaseProjectionSet,
	dupes api.DupeAssessment,
) api.TrackerReleaseProjectionSet

DownstreamEligibleProjections applies the shared retained eligibility predicate while preserving projection order and snapshot identity.

func DownstreamEligibleProjectionsAfterMedia

func DownstreamEligibleProjectionsAfterMedia(
	projections api.TrackerReleaseProjectionSet,
	dupes api.DupeAssessment,
	media api.MediaArtifactSet,
) api.TrackerReleaseProjectionSet

DownstreamEligibleProjectionsAfterMedia removes trackers with terminal tracker-scoped image-host failures from the regular post-dupe eligible set.

func ProjectionEligibleForDownstream

func ProjectionEligibleForDownstream(
	projection api.TrackerReleaseProjection,
	dupe api.TrackerDupeAssessment,
	hasDupe bool,
) bool

ProjectionEligibleForDownstream reports whether retained projection and duplicate state permit media, description, and upload-plan work.

func TrackerImageHostFailure

func TrackerImageHostFailure(media api.MediaArtifactSet, trackerID api.TrackerID) (api.WorkflowFailure, bool)

TrackerImageHostFailure returns the terminal image-host failure that blocks one tracker in the retained media snapshot.

func WithCompositeUploadMediaInputs

func WithCompositeUploadMediaInputs(ctx context.Context, inputs CompositeUploadMediaInputs) context.Context

WithCompositeUploadMediaInputs supplies private adapter-resolved media to StartUpload.

func WithTrackerDecisionMode

func WithTrackerDecisionMode(ctx context.Context, mode TrackerDecisionMode) context.Context

WithTrackerDecisionMode supplies trusted workflow-creation policy to an adapter. Existing workflows always use their persisted mode.

Types

type Application

Application is the compact adapter-facing workflow command/query surface.

type ApproveTrackersCommand

type ApproveTrackersCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Approval         api.TrackerApproval
	IdempotencyKey   string
}

ApproveTrackersCommand publishes exact post-dupe tracker authority.

type AttachMediaArtifactsCommand

type AttachMediaArtifactsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Media            *api.MediaArtifactSetRef
	Attachments      []api.MediaAttachment
	IdempotencyKey   string
}

AttachMediaArtifactsCommand consumes owner-scoped staged resources and publishes them into exact workflow media lineage.

type CancelWorkflowCommand

type CancelWorkflowCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Reason           string
	IdempotencyKey   string
}

CancelWorkflowCommand terminates a workflow and releases all private authority.

type CaptureMediaCommand

type CaptureMediaCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Instructions     api.MediaCaptureInstructions
	IdempotencyKey   string
}

CaptureMediaCommand plans and captures all required screenshots/DVD menus.

type CheckDuplicatesCommand

type CheckDuplicatesCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	SkipRemote       bool
	CheckOrdinal     uint8
	IdempotencyKey   string
}

CheckDuplicatesCommand executes one exact finalized projection revision.

type Clock

type Clock interface {
	Now() time.Time
}

Clock supplies deterministic workflow timestamps.

type Command

type Command interface {
	// contains filtered or unexported methods
}

Command is a sealed adapter-facing user intent. Internal publication inputs deliberately do not implement it.

func CommandFromRequest

func CommandFromRequest(request any) (Command, error)

CommandFromRequest validates one shared adapter request and maps it to the workflow command consumed by every CLI, browser, and public HTTP entrypoint.

type CommandResult

type CommandResult = api.ReleaseWorkflowCurrent

CommandResult is retained as an internal compatibility name while all adapters consume the pkg/api-owned serialized projection.

type CompositeUploadCommand

type CompositeUploadCommand struct {
	WorkflowID         api.WorkflowID
	ExpectedRevision   api.WorkflowRevision
	SessionFingerprint api.WorkflowFingerprint
	Goal               api.WorkflowGoal
	IdempotencyKey     string
}

CompositeUploadCommand resumes retained workflow intent from its durable checkpoint and drives it to the upload or debug goal.

type CompositeUploadMediaInputs

type CompositeUploadMediaInputs struct {
	Comparisons []StagedMediaContent
	DVDMenus    []StagedMediaContent
}

CompositeUploadMediaInputs contains adapter-resolved local image bytes. Values live only in the request context until they are staged in the private vault.

type CreateWorkflowCommand

type CreateWorkflowCommand struct {
	WorkflowID          api.WorkflowID
	Instructions        api.ReleaseFactInstructions
	IdempotencyKey      string
	RequestFingerprint  api.WorkflowFingerprint
	TrackerDecisionMode TrackerDecisionMode
	Composite           *compositeUploadSession
}

CreateWorkflowCommand creates fact instructions and a draft aggregate. Composite, when set, installs retained composite state in the same mutation.

type DecideDuplicatesCommand

type DecideDuplicatesCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Decisions        map[api.TrackerID]api.DupeDecision
	IdempotencyKey   string
}

DecideDuplicatesCommand publishes owner decisions without repeating remote searches.

type DeleteMediaArtifactsCommand

type DeleteMediaArtifactsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Media            api.MediaArtifactSetRef
	ArtifactIDs      []api.PublicResourceID
	IdempotencyKey   string
}

DeleteMediaArtifactsCommand deletes owner-scoped retained media by opaque ID.

type DescriptionBuilder

DescriptionBuilder generates projection- and media-bound descriptions. Fingerprints must not invoke text generation or remote image work so the workflow can reuse a compatible retained revision without side effects.

type DryRunUploadsCommand

type DryRunUploadsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	NoSeed           bool
	TrackerIDs       []api.TrackerID
	IdempotencyKey   string
}

DryRunUploadsCommand prepares sanitized reports without tracker submission.

type DupeAssessmentBuilder

DupeAssessmentBuilder executes projection-bound duplicate checks and returns a safe retained snapshot plus optional private evidence for later planning.

type DurablePrivateResource

type DurablePrivateResource interface {
	MarshalPrivateResource() (kind string, payload []byte, err error)
}

DurablePrivateResource marshals one private value for owner-scoped restart recovery. Payloads may contain private paths or credentials and must only be written to the private vault.

type EvaluateInputReadinessCommand added in v0.3.2

type EvaluateInputReadinessCommand struct {
	WorkflowID          api.WorkflowID
	ExpectedRevision    api.WorkflowRevision
	TrackerIDs          []api.TrackerID
	TrackerInputAnswers map[api.TrackerID]map[string]*string
	IdempotencyKey      string
}

EvaluateInputReadinessCommand publishes local selected-tracker input readiness.

type ExecuteUploadsCommand

type ExecuteUploadsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	NoSeed           bool
	TrackerIDs       []api.TrackerID
	Interaction      api.InteractionMode
	IdempotencyKey   string
}

ExecuteUploadsCommand directly prepares and executes eligible trackers.

type GenerateDescriptionsCommand

type GenerateDescriptionsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Instructions     api.DescriptionInstructions
	IdempotencyKey   string
}

GenerateDescriptionsCommand generates or reuses exact compatible descriptions.

type IDGenerator

type IDGenerator interface {
	NewID(prefix string) (string, error)
}

IDGenerator supplies opaque workflow and snapshot IDs.

type IncrementalMediaArtifactBuilder

IncrementalMediaArtifactBuilder preserves current media and skips already retained requested screenshot indexes during later capture commands.

type InputReadinessEvaluator added in v0.3.2

type InputReadinessEvaluator interface {
	Requirements(context.Context, []api.TrackerID) (api.MetadataRequirementSet, error)
	Evaluate(context.Context, api.UploadSubject, []api.TrackerID) (api.InputReadinessEvaluation, error)
}

InputReadinessEvaluator evaluates selected tracker input demands without authentication, duplicate checks, or other remote work.

type InvalidateTrackersCommand

type InvalidateTrackersCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	TrackerIDs       []api.TrackerID
	Reason           string
	IdempotencyKey   string
}

InvalidateTrackersCommand selectively invalidates tracker projections and results.

type MediaArtifactBuilder

MediaArtifactBuilder captures generation- and projection-bound media while keeping local paths and bytes in a private resource.

type MediaArtifactContent

type MediaArtifactContent struct {
	Body        io.ReadCloser
	ContentType string
}

MediaArtifactContent is one owner-checked retained media stream.

type MediaArtifactMutator

MediaArtifactMutator owns private attachment and image-host mutations while the workflow module owns revision checks and snapshot publication.

type MediaPlanner

MediaPlanner supplies safe screenshot timing and non-authoritative previews for one exact prepared release.

type MediaPreviewContent

type MediaPreviewContent struct {
	// DiscID identifies the prepared disc used for this preview.
	DiscID string
	// DiscName is the safe page-facing label for DiscID.
	DiscName    string
	Bytes       []byte
	ContentType string
	Width       int
	Height      int
}

MediaPreviewContent retains one non-authoritative frame preview without exposing image bytes or filesystem identity in workflow snapshots.

type MemoryPrivateResourceStore

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

MemoryPrivateResourceStore retains process-local, single-use workflow authority.

func NewMemoryPrivateResourceStore

func NewMemoryPrivateResourceStore() *MemoryPrivateResourceStore

NewMemoryPrivateResourceStore returns an empty process-local private store.

func (*MemoryPrivateResourceStore) Consume

func (s *MemoryPrivateResourceStore) Consume(
	ownerID string,
	workflowID api.WorkflowID,
	resourceID string,
	now time.Time,
) (any, error)

Consume atomically returns and invalidates one single-use resource.

func (*MemoryPrivateResourceStore) Delete

func (s *MemoryPrivateResourceStore) Delete(ownerID string, workflowID api.WorkflowID, resourceID string)

Delete removes one resource without marking its single-use key consumed.

func (*MemoryPrivateResourceStore) Get

func (s *MemoryPrivateResourceStore) Get(
	ownerID string,
	workflowID api.WorkflowID,
	resourceID string,
	now time.Time,
) (any, error)

Get returns an unconsumed, unexpired owner-scoped resource.

func (*MemoryPrivateResourceStore) InvalidateAll

func (s *MemoryPrivateResourceStore) InvalidateAll()

InvalidateAll models process restart by removing all private execution authority.

func (*MemoryPrivateResourceStore) InvalidateWorkflow

func (s *MemoryPrivateResourceStore) InvalidateWorkflow(ownerID string, workflowID api.WorkflowID)

InvalidateWorkflow removes every private resource owned by one workflow.

func (*MemoryPrivateResourceStore) InvalidateWorkflowExcept

func (s *MemoryPrivateResourceStore) InvalidateWorkflowExcept(
	ownerID string,
	workflowID api.WorkflowID,
	preservedResourceIDs ...string,
)

InvalidateWorkflowExcept removes workflow resources except explicitly preserved IDs, including their existing expiry or consumed state.

func (*MemoryPrivateResourceStore) Put

func (s *MemoryPrivateResourceStore) Put(
	ownerID string,
	workflowID api.WorkflowID,
	resourceID string,
	value any,
	expiresAt time.Time,
) error

Put retains one owner-scoped private resource.

type MemoryRepository

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

MemoryRepository is a concurrency-safe owner-scoped workflow repository.

func NewMemoryRepository

func NewMemoryRepository() *MemoryRepository

NewMemoryRepository returns an empty in-memory workflow repository.

func (*MemoryRepository) AcceptIntent

AcceptIntent retains one exact desired-state request in memory.

func (*MemoryRepository) AppendEvents

func (r *MemoryRepository) AppendEvents(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	events []api.WorkflowEvent,
) ([]api.WorkflowEvent, error)

AppendEvents assigns workflow-global event cursors and retains immutable copies.

func (*MemoryRepository) BeginEffect

BeginEffect fences one in-memory external attempt.

func (*MemoryRepository) CheckpointWork

func (r *MemoryRepository) CheckpointWork(ctx context.Context, record api.ReleaseWorkflowWorkRecord) error

CheckpointWork retains the latest safe in-memory operation checkpoint.

func (*MemoryRepository) ClaimWork

ClaimWork acquires one in-memory operation lease.

func (*MemoryRepository) CompleteEffect

CompleteEffect retains one known terminal in-memory receipt.

func (*MemoryRepository) CompleteWork

func (r *MemoryRepository) CompleteWork(ctx context.Context, record api.ReleaseWorkflowWorkRecord) error

CompleteWork retains the terminal checkpoint and closes its in-memory lease.

func (*MemoryRepository) Create

func (r *MemoryRepository) Create(
	ctx context.Context,
	ownerID string,
	idempotencyKey string,
	fingerprint api.WorkflowFingerprint,
	state State,
) (State, bool, error)

Create atomically creates state or returns the prior result for a matching idempotency key.

func (*MemoryRepository) CreateOperation

func (*MemoryRepository) Delete

func (r *MemoryRepository) Delete(ctx context.Context, ownerID string, workflowID api.WorkflowID) error

Delete removes one owner-scoped workflow and its creation receipts.

func (*MemoryRepository) ListActiveOperations

func (r *MemoryRepository) ListActiveOperations(ctx context.Context) ([]api.ReleaseWorkflowOperationRecord, error)

func (*MemoryRepository) Load

func (r *MemoryRepository) Load(ctx context.Context, ownerID string, workflowID api.WorkflowID) (State, error)

Load returns one detached owner-scoped workflow state.

func (*MemoryRepository) LoadEvents

func (r *MemoryRepository) LoadEvents(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	after uint64,
	limit int,
) ([]api.WorkflowEvent, error)

LoadEvents returns retained events after one workflow cursor.

func (*MemoryRepository) LoadLatestOperation

func (r *MemoryRepository) LoadLatestOperation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
) (api.ReleaseWorkflowOperationRecord, error)

func (*MemoryRepository) LoadOperation

func (r *MemoryRepository) LoadOperation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.ReleaseWorkflowOperationRecord, error)

func (*MemoryRepository) LoadOperationByIdempotency

func (r *MemoryRepository) LoadOperationByIdempotency(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	commandName string,
	idempotencyKey string,
) (api.ReleaseWorkflowOperationRecord, error)

LoadOperationByIdempotency returns one exact in-memory command receipt.

func (*MemoryRepository) LoadWork

func (r *MemoryRepository) LoadWork(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.ReleaseWorkflowWorkRecord, error)

LoadWork returns one detached in-memory operation lease and checkpoint.

func (*MemoryRepository) MarkOperationEffectsUnknown

func (r *MemoryRepository) MarkOperationEffectsUnknown(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
	now time.Time,
) error

MarkOperationEffectsUnknown fences in-memory attempts interrupted by restart.

func (*MemoryRepository) RenewWork

RenewWork extends one currently owned in-memory operation lease.

func (*MemoryRepository) ResolveEffectUnknown

func (r *MemoryRepository) ResolveEffectUnknown(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	kind api.WorkflowExternalEffectKind,
	scopeID string,
	now time.Time,
) error

ResolveEffectUnknown records manual verification for one uncertain in-memory effect.

func (*MemoryRepository) Save

func (r *MemoryRepository) Save(ctx context.Context, ownerID string, expected api.WorkflowRevision, state State) error

Save applies one optimistic state update.

func (*MemoryRepository) SaveContinuation

SaveContinuation materializes one in-memory continuation projection.

func (*MemoryRepository) SaveOperation

func (r *MemoryRepository) SaveOperation(
	ctx context.Context,
	expectedSequence uint64,
	record api.ReleaseWorkflowOperationRecord,
) error

type Module

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

Module owns workflow sequencing, invalidation, idempotency, and private retention.

func New

func New(repository Repository, privateStore PrivateResourceStore, preparer ReleasePreparer, options ...Option) (*Module, error)

New constructs the deep release-workflow application module.

func (*Module) CancelOperation

func (m *Module) CancelOperation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.WorkflowOperationStatus, error)

CancelOperation requests cancellation of one active owner-scoped operation. If the operation finishes before the cancellation message is saved, its terminal status is returned unchanged.

func (*Module) Continue

func (m *Module) Continue(
	ctx context.Context,
	ownerID string,
	request api.ContinueReleaseWorkflowRequest,
) (CommandResult, error)

Continue advances at most one backend-owned transition toward a desired goal. Repeated calls plus Current polling are the complete adapter orchestration contract. Matching preparation inputs restore the persisted generation before downstream work; unavailable or incompatible prepared data returns an error instead of being rebuilt.

func (*Module) Current

func (m *Module) Current(ctx context.Context, ownerID string, workflowID api.WorkflowID) (CommandResult, error)

Current returns detached current stage snapshots without regenerating or refreshing any workflow dependency.

func (*Module) Execute

func (m *Module) Execute(ctx context.Context, ownerID string, command Command) (CommandResult, error)

Execute applies one typed command with owner scoping, optimistic concurrency, and idempotency.

func (*Module) MediaArtifact

func (m *Module) MediaArtifact(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	mediaRef api.MediaArtifactSetRef,
	artifactID api.PublicResourceID,
) (MediaArtifactContent, error)

MediaArtifact returns one retained owner-scoped media stream addressed only by its exact workflow/media revision and opaque artifact ID.

func (*Module) MediaPlan

func (m *Module) MediaPlan(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
) (api.MediaPlan, error)

MediaPlan returns a safe page-facing plan bound to the current exact release and tracker-projection revision.

func (*Module) Operation

func (m *Module) Operation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.WorkflowOperationStatus, error)

Operation returns one detached owner-scoped pollable operation status.

func (*Module) OperationEvents

func (m *Module) OperationEvents(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
	after uint64,
	limit int,
) ([]api.WorkflowEvent, error)

OperationEvents returns retained events for one owner-scoped operation after a workflow-global event cursor.

func (*Module) PreviewArtifact

func (m *Module) PreviewArtifact(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	previewID api.PublicResourceID,
) (MediaArtifactContent, error)

PreviewArtifact returns owner-scoped transient preview bytes by opaque ID.

func (*Module) PreviewFrame

func (m *Module) PreviewFrame(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	expectedRevision api.WorkflowRevision,
	discID string,
	timestampSeconds float64,
) (api.FramePreview, error)

PreviewFrame creates non-authoritative owner-scoped preview content without publishing media or invalidating downstream workflow state.

func (*Module) StageMediaResource

func (m *Module) StageMediaResource(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	expectedRevision api.WorkflowRevision,
	content StagedMediaContent,
) (api.WorkflowResourceRef, error)

StageMediaResource retains owner-scoped image bytes for a later exact AttachMediaArtifactsCommand without exposing a host filesystem path.

func (*Module) Start

func (m *Module) Start(ctx context.Context, ownerID string, command Command) (api.WorkflowOperationStatus, error)

Start durably accepts one long-running command and returns its queued operation before server-owned background work begins.

func (*Module) StartLiveTestUpload added in v0.3.2

func (m *Module) StartLiveTestUpload(
	ctx context.Context,
	ownerID string,
	request api.CreateReleaseWorkflowUploadRequest,
) (CommandResult, error)

StartLiveTestUpload drives the requested execution mode to a dry-run. Its effective goal and no-seed policy are bound into the durable session receipt. It requires a live-test policy and never permits tracker or client writes.

func (*Module) StartUpload

func (m *Module) StartUpload(
	ctx context.Context,
	ownerID string,
	request api.CreateReleaseWorkflowUploadRequest,
) (CommandResult, error)

StartUpload validates and normalizes one owner-scoped request, idempotently creates its workflow, stages private media, and starts the durable composite operation unless the same request is already active or terminal.

func (*Module) SubmitUploadFeedback

func (m *Module) SubmitUploadFeedback(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	feedback api.ReleaseWorkflowUploadFeedback,
) (CommandResult, error)

SubmitUploadFeedback validates exact action authority, idempotently applies one response, and starts the resumed composite operation.

func (*Module) Workflow

func (m *Module) Workflow(ctx context.Context, ownerID string, workflowID api.WorkflowID) (api.ReleaseWorkflow, error)

Workflow returns one detached owner-scoped aggregate.

type OperationRepository

OperationRepository persists progress separately from aggregate state.

type Option

type Option func(*Module) error

Option configures a workflow module.

func WithClock

func WithClock(clock Clock) Option

WithClock installs a deterministic workflow clock.

func WithDescriptionBuilder

func WithDescriptionBuilder(builder DescriptionBuilder) Option

WithDescriptionBuilder installs retained description generation.

func WithDupeAssessmentBuilder

func WithDupeAssessmentBuilder(builder DupeAssessmentBuilder) Option

WithDupeAssessmentBuilder installs projection-bound duplicate execution.

func WithIDGenerator

func WithIDGenerator(generator IDGenerator) Option

WithIDGenerator installs an opaque ID generator.

func WithInputReadinessEvaluator added in v0.3.2

func WithInputReadinessEvaluator(evaluator InputReadinessEvaluator) Option

WithInputReadinessEvaluator installs selected-tracker local input evaluation.

func WithLiveTestPolicy added in v0.3.2

func WithLiveTestPolicy(policy *api.LiveTestPolicy) Option

WithLiveTestPolicy installs process-owned safety independently of contexts.

func WithLogger

func WithLogger(logger api.Logger) Option

WithLogger installs the application logger used for sanitized asynchronous operation diagnostics.

func WithMediaArtifactBuilder

func WithMediaArtifactBuilder(builder MediaArtifactBuilder) Option

WithMediaArtifactBuilder installs generation-bound media capture.

func WithOperationErrorClassifier

func WithOperationErrorClassifier(classifier func(api.OperationKind, error) error) Option

WithOperationErrorClassifier installs the application boundary that maps asynchronous command errors to transport-safe operation failures.

func WithProcessEpoch

func WithProcessEpoch(epoch string) Option

WithProcessEpoch installs a process identity for deterministic restart tests. Production callers use a random epoch created by New.

func WithTrackerPreflightBuilder

func WithTrackerPreflightBuilder(builder TrackerPreflightBuilder) Option

WithTrackerPreflightBuilder installs projection-bound live readiness checks.

func WithTrackerProjectionBuilder

func WithTrackerProjectionBuilder(builder TrackerProjectionBuilder) Option

WithTrackerProjectionBuilder installs tracker catalog/runtime/projection ownership.

func WithUploadPlanBuilder

func WithUploadPlanBuilder(builder UploadPlanBuilder) Option

WithUploadPlanBuilder installs exact reviewed-operation planning.

type PersistentRepository

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

PersistentRepository stores safe public workflow state in the shared repository capability. Private resources remain process-local.

func NewPersistentRepository

func NewPersistentRepository(states api.ReleaseWorkflowStateRepository) (*PersistentRepository, error)

NewPersistentRepository constructs a durable public workflow repository.

func (*PersistentRepository) AcceptIntent

AcceptIntent persists one exact desired-state request.

func (*PersistentRepository) AppendEvents

func (r *PersistentRepository) AppendEvents(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	events []api.WorkflowEvent,
) ([]api.WorkflowEvent, error)

AppendEvents retains immutable workflow-scoped events.

func (*PersistentRepository) BeginEffect

BeginEffect durably fences one exact external attempt.

func (*PersistentRepository) CheckpointWork

func (r *PersistentRepository) CheckpointWork(ctx context.Context, record api.ReleaseWorkflowWorkRecord) error

func (*PersistentRepository) ClaimWork

func (*PersistentRepository) CompleteEffect

CompleteEffect persists one known terminal external-attempt receipt.

func (*PersistentRepository) CompleteWork

func (*PersistentRepository) Create

func (r *PersistentRepository) Create(
	ctx context.Context,
	ownerID string,
	idempotencyKey string,
	fingerprint api.WorkflowFingerprint,
	state State,
) (State, bool, error)

Create atomically creates state or returns the prior matching creation.

func (*PersistentRepository) CreateOperation

func (*PersistentRepository) Delete

func (r *PersistentRepository) Delete(ctx context.Context, ownerID string, workflowID api.WorkflowID) error

Delete removes one owner-scoped durable workflow.

func (*PersistentRepository) ListActiveOperations

func (r *PersistentRepository) ListActiveOperations(ctx context.Context) ([]api.ReleaseWorkflowOperationRecord, error)

func (*PersistentRepository) Load

func (r *PersistentRepository) Load(ctx context.Context, ownerID string, workflowID api.WorkflowID) (State, error)

Load returns one detached owner-scoped durable state.

func (*PersistentRepository) LoadEvents

func (r *PersistentRepository) LoadEvents(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	after uint64,
	limit int,
) ([]api.WorkflowEvent, error)

LoadEvents returns retained immutable events after one cursor.

func (*PersistentRepository) LoadLatestOperation

func (r *PersistentRepository) LoadLatestOperation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
) (api.ReleaseWorkflowOperationRecord, error)

func (*PersistentRepository) LoadOperation

func (r *PersistentRepository) LoadOperation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.ReleaseWorkflowOperationRecord, error)

func (*PersistentRepository) LoadOperationByIdempotency

func (r *PersistentRepository) LoadOperationByIdempotency(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	commandName string,
	idempotencyKey string,
) (api.ReleaseWorkflowOperationRecord, error)

LoadOperationByIdempotency returns one exact durable command receipt.

func (*PersistentRepository) LoadWork

func (r *PersistentRepository) LoadWork(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.ReleaseWorkflowWorkRecord, error)

func (*PersistentRepository) MarkOperationEffectsUnknown

func (r *PersistentRepository) MarkOperationEffectsUnknown(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
	now time.Time,
) error

MarkOperationEffectsUnknown fences started effects interrupted by restart.

func (*PersistentRepository) RenewWork

func (*PersistentRepository) ResolveEffectUnknown

func (r *PersistentRepository) ResolveEffectUnknown(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	kind api.WorkflowExternalEffectKind,
	scopeID string,
	now time.Time,
) error

ResolveEffectUnknown records manual verification that an uncertain effect did not complete.

func (*PersistentRepository) Save

func (r *PersistentRepository) Save(ctx context.Context, ownerID string, expected api.WorkflowRevision, state State) error

Save applies one optimistic durable state update.

func (*PersistentRepository) SaveContinuation

SaveContinuation materializes one safe continuation projection.

func (*PersistentRepository) SaveOperation

func (r *PersistentRepository) SaveOperation(
	ctx context.Context,
	expectedSequence uint64,
	record api.ReleaseWorkflowOperationRecord,
) error

type PreflightTrackersCommand

type PreflightTrackersCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	InputFingerprint api.WorkflowFingerprint
	Interaction      api.InteractionMode
	ExecutionMode    api.WorkflowExecutionMode
	IdempotencyKey   string
}

PreflightTrackersCommand runs live checks and atomically publishes both the assessment and a new finalized projection revision.

type PrepareReleaseCommand

type PrepareReleaseCommand struct {
	WorkflowID          api.WorkflowID
	ExpectedRevision    api.WorkflowRevision
	Input               api.PrepareInput
	TrackerIDs          []api.TrackerID
	TrackerInputAnswers map[api.TrackerID]map[string]*string
	IdempotencyKey      string
}

PrepareReleaseCommand creates a canonical release snapshot from retained fact instructions.

type PrivateArtifactVault

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

PrivateArtifactVault persists codec-supported private resources as owner/workflow-scoped opaque, digest-checked files. Unsupported runtime values remain available in memory and fail closed after restart.

func NewPrivateArtifactVault

func NewPrivateArtifactVault(root string, codecs ...PrivateResourceCodec) (*PrivateArtifactVault, error)

NewPrivateArtifactVault opens or creates one restricted private artifact root.

func (*PrivateArtifactVault) CleanupExpired

func (v *PrivateArtifactVault) CleanupExpired(now time.Time) error

CleanupExpired removes expired payloads and consumed tombstones before the cutoff.

func (*PrivateArtifactVault) Consume

func (v *PrivateArtifactVault) Consume(
	ownerID string,
	workflowID api.WorkflowID,
	resourceID string,
	now time.Time,
) (any, error)

Consume atomically returns and invalidates one single-use resource.

func (*PrivateArtifactVault) Delete

func (v *PrivateArtifactVault) Delete(ownerID string, workflowID api.WorkflowID, resourceID string)

Delete removes one private resource and its persisted metadata.

func (*PrivateArtifactVault) Get

func (v *PrivateArtifactVault) Get(
	ownerID string,
	workflowID api.WorkflowID,
	resourceID string,
	now time.Time,
) (any, error)

Get returns an unconsumed, unexpired owner-scoped resource.

func (*PrivateArtifactVault) InvalidateAll

func (v *PrivateArtifactVault) InvalidateAll()

InvalidateAll clears process-local handles while preserving durable files, modeling a process restart.

func (*PrivateArtifactVault) InvalidateWorkflow

func (v *PrivateArtifactVault) InvalidateWorkflow(ownerID string, workflowID api.WorkflowID)

InvalidateWorkflow removes every private resource owned by one workflow.

func (*PrivateArtifactVault) InvalidateWorkflowExcept

func (v *PrivateArtifactVault) InvalidateWorkflowExcept(
	ownerID string,
	workflowID api.WorkflowID,
	preservedResourceIDs ...string,
)

InvalidateWorkflowExcept removes workflow resources except explicitly preserved IDs, including their durable payload and metadata.

func (*PrivateArtifactVault) Put

func (v *PrivateArtifactVault) Put(
	ownerID string,
	workflowID api.WorkflowID,
	resourceID string,
	value any,
	expiresAt time.Time,
) error

Put retains one owner-scoped private resource.

type PrivateResourceCodec

type PrivateResourceCodec struct {
	Kind   string
	Decode func([]byte) (any, error)
}

PrivateResourceCodec rehydrates one private resource kind with current process services.

type PrivateResourceStore

type PrivateResourceStore interface {
	Put(ownerID string, workflowID api.WorkflowID, resourceID string, value any, expiresAt time.Time) error
	Get(ownerID string, workflowID api.WorkflowID, resourceID string, now time.Time) (any, error)
	Consume(ownerID string, workflowID api.WorkflowID, resourceID string, now time.Time) (any, error)
	Delete(ownerID string, workflowID api.WorkflowID, resourceID string)
	InvalidateWorkflow(ownerID string, workflowID api.WorkflowID)
	// InvalidateWorkflowExcept invalidates one workflow while retaining named resources.
	InvalidateWorkflowExcept(ownerID string, workflowID api.WorkflowID, preservedResourceIDs ...string)
	InvalidateAll()
}

PrivateResourceStore retains owner-scoped resources that must never enter public snapshots.

type ProjectTrackersCommand

type ProjectTrackersCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	TrackerIDs       []api.TrackerID
	Instructions     map[api.TrackerID]api.TrackerProjectionInstructions
	ExecutionMode    api.WorkflowExecutionMode
	IdempotencyKey   string
}

ProjectTrackersCommand resolves catalog/runtime/selection and tracker-local projections behind one transition.

type RegisteredArtifactAuthority

type RegisteredArtifactAuthority struct {
	ClientSubject api.ClientSubject
	Torrents      map[api.TrackerID]api.TorrentResult
}

RegisteredArtifactAuthority retains private exact-torrent authority after a successful tracker submission. It must never enter public workflow snapshots.

func (RegisteredArtifactAuthority) MarshalPrivateResource

func (a RegisteredArtifactAuthority) MarshalPrivateResource() (string, []byte, error)

MarshalPrivateResource persists private registered torrent paths and authenticated URLs only inside the owner-scoped private vault.

type ReleasePreparer

ReleasePreparer owns canonical prepared-release generation.

type ReleasePreparerFunc

ReleasePreparerFunc adapts a function to ReleasePreparer.

func (ReleasePreparerFunc) CorrectionsCurrent added in v0.3.2

func (f ReleasePreparerFunc) CorrectionsCurrent(ctx context.Context, source string, revision uint64) (bool, error)

CorrectionsCurrent checks source correction authority before workflow reuse. Function adapters without a mutable correction store retain their authority.

func (ReleasePreparerFunc) Prepare

Prepare calls the adapted preparation function.

func (ReleasePreparerFunc) PrepareResolved added in v0.3.2

PrepareResolved delegates collection of the accepted input to its owner.

func (ReleasePreparerFunc) ResolveDisplay

ResolveDisplay calls the adapted exact-generation display projection function.

func (ReleasePreparerFunc) ResolveDuplicateSubject

func (f ReleasePreparerFunc) ResolveDuplicateSubject(ctx context.Context, input api.DuplicateCheckInput) (api.DuplicateSubject, error)

ResolveDuplicateSubject calls the adapted exact-generation duplicate projection function.

func (ReleasePreparerFunc) ResolveInput added in v0.3.2

ResolveInput delegates source correction resolution to the preparation owner.

func (ReleasePreparerFunc) ResolveUploadSubject

func (f ReleasePreparerFunc) ResolveUploadSubject(ctx context.Context, input api.UploadSubjectInput) (api.UploadSubject, error)

ResolveUploadSubject calls the adapted exact-generation operation projection function.

type RemoveHostedImagesCommand

type RemoveHostedImagesCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Media            api.MediaArtifactSetRef
	ArtifactIDs      []api.PublicResourceID
	IdempotencyKey   string
}

RemoveHostedImagesCommand removes hosted outcomes by opaque artifact ID.

type ReorderMediaArtifactsCommand

type ReorderMediaArtifactsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Media            api.MediaArtifactSetRef
	ArtifactIDs      []api.PublicResourceID
	IdempotencyKey   string
}

ReorderMediaArtifactsCommand establishes selected final-media order by opaque artifact ID without changing private resource identity.

type ReplaceFactInstructionsCommand

type ReplaceFactInstructionsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Instructions     api.ReleaseFactInstructions
	CorrectionPatch  *api.ReleaseCorrectionPatch
	SourcePath       string
	IdempotencyKey   string
}

ReplaceFactInstructionsCommand publishes a new instruction revision and invalidates all facts and downstream state.

type Repository

Repository atomically persists owner-scoped public workflow state.

type ResetDescriptionOverrideCommand

type ResetDescriptionOverrideCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Descriptions     api.DescriptionSetRef
	GroupKey         string
	IdempotencyKey   string
}

ResetDescriptionOverrideCommand restores one exact retained description group.

type ResetReleaseCommand

type ResetReleaseCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Input            api.PrepareInput
	TrackerIDs       []api.TrackerID
	IdempotencyKey   string
}

ResetReleaseCommand replaces exact fact instructions and force-reprepares in one operation.

type ResolveActionCommand

type ResolveActionCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Answer           api.RequiredActionAnswer
	IdempotencyKey   string
}

ResolveActionCommand resolves one pending action with stale-revision protection.

type RetainedMediaCommitter

type RetainedMediaCommitter interface {
	Commit(context.Context) error
}

RetainedMediaCommitter finalizes staged external media mutations. Local artifact deletion commits before the workflow revision is saved so a failed commit keeps the artifact durable and retryable; hosted-image removal commits after the revision has committed. Commit must be idempotent so retries can converge after a partial filesystem or repository failure.

type RetainedMediaResource

RetainedMediaResource keeps media bytes and filesystem identity private while allowing opaque workflow artifact reads and bounded deletion.

type RetainedUploadExecution

type RetainedUploadExecution interface {
	ResolveAction(context.Context, api.TrackerID, api.RequiredActionKind, bool) (api.UploadPlanTracker, error)
	Execute(context.Context, []api.TrackerID) ([]api.UploadTrackerResult, error)
	RegisteredArtifactAuthority() RegisteredArtifactAuthority
	Release() error
}

RetainedUploadExecution is private single-use execution authority. Execute must submit already-prepared operations without rebuilding semantic payloads.

type RetryClientInjectionsCommand

type RetryClientInjectionsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Retry            api.ClientInjectionRetryRef
	IdempotencyKey   string
}

RetryClientInjectionsCommand retries retained client effects without rebuilding or resubmitting a tracker upload.

type RetryFailedUploadsCommand

type RetryFailedUploadsCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Retry            api.FailedTrackerRetryRef
	NoSeed           bool
	IdempotencyKey   string
}

RetryFailedUploadsCommand retries only failed trackers from one exact prior result.

type SaveDescriptionOverrideCommand

type SaveDescriptionOverrideCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Descriptions     api.DescriptionSetRef
	GroupKey         string
	Source           string
	IdempotencyKey   string
}

SaveDescriptionOverrideCommand changes one exact retained description group.

type SelectBlurayCandidateCommand

type SelectBlurayCandidateCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	ReleaseID        string
	IdempotencyKey   string
}

SelectBlurayCandidateCommand validates and selects one retained candidate, then force-reprepares.

type SetMediaSelectionCommand

type SetMediaSelectionCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Media            api.MediaArtifactSetRef
	ArtifactIDs      []api.PublicResourceID
	Selected         bool
	IdempotencyKey   string
}

SetMediaSelectionCommand changes selection state for opaque retained media.

type StagedMediaAttachment

type StagedMediaAttachment struct {
	Attachment api.MediaAttachment
	Content    StagedMediaContent
}

StagedMediaAttachment binds private staged bytes to one requested artifact shape.

type StagedMediaContent

type StagedMediaContent struct {
	Name        string
	Bytes       []byte
	ContentType string
}

StagedMediaContent is owner-scoped private upload content. Name and bytes never enter public workflow snapshots.

type State

type State struct {
	OwnerID             string
	ProcessEpoch        string
	TrackerDecisionMode TrackerDecisionMode
	Workflow            api.ReleaseWorkflow
	Corrections         *api.ReleaseCorrectionsSnapshot
	// PendingCorrectionConfirmation retains workflow-validated confirmation
	// authority until canonical preparation completes.
	PendingCorrectionConfirmation *api.CorrectionConfirmation
	PreparationInput              *api.PrepareInput
	// PreparationDemand retains normalized metadata requirements separately because
	// PrepareInput omits its internal-only requirements from persisted JSON used for hydration.
	PreparationDemand      api.MetadataRequirementSet
	TrackerInputAnswers    map[api.TrackerID]map[string]string
	FactInstructions       map[api.ReleaseFactInstructionSnapshotID]api.ReleaseFactInstructionSnapshot
	Releases               map[api.ReleaseSnapshotID]api.ReleaseSnapshot
	InputReadiness         map[api.InputReadinessSnapshotID]api.InputReadinessSnapshot
	Catalogs               map[api.TrackerCatalogSnapshotID]api.TrackerCatalogSnapshot
	Runtimes               map[api.TrackerRuntimeSnapshotID]api.TrackerRuntimeSnapshot
	Selections             map[api.TrackerSelectionID]api.TrackerSelection
	ProjectionInstructions map[api.TrackerProjectionInstructionSnapshotID]api.TrackerProjectionInstructionSnapshot
	Projections            map[api.TrackerReleaseProjectionSetID]api.TrackerReleaseProjectionSet
	Preflights             map[api.TrackerPreflightAssessmentID]api.TrackerPreflightAssessment
	Dupes                  map[api.DupeAssessmentID]api.DupeAssessment
	TrackerApprovals       map[api.TrackerApprovalSnapshotID]api.TrackerApprovalSnapshot
	Media                  map[api.MediaArtifactSetID]api.MediaArtifactSet
	Descriptions           map[api.DescriptionSetID]api.DescriptionSet
	DryRuns                map[api.UploadDryRunResultID]api.UploadDryRunResult
	UploadResults          map[api.UploadResultID]api.UploadResult
	Operations             map[api.WorkflowOperationID]api.WorkflowOperationStatus
	Receipts               map[string]commandReceipt
	Composite              *compositeUploadSession
}

State is the repository value owned exclusively by the workflow module. Snapshots are immutable; maps retain prior revisions for exact-reference reads.

type TrackerDecisionMode

type TrackerDecisionMode string

TrackerDecisionMode is trusted persisted policy for downstream tracker authority.

const (
	// TrackerDecisionModePostDupeGate requires explicit tracker approval after duplicate checking.
	TrackerDecisionModePostDupeGate TrackerDecisionMode = "post_dupe_gate"
	// TrackerDecisionModeWebUIControls uses the app's existing stage-specific tracker controls.
	TrackerDecisionModeWebUIControls TrackerDecisionMode = "webui_controls"
)

type TrackerPreflightBuilder

TrackerPreflightBuilder hides live tracker readiness checks behind one projection-bound application port. Returned values are unstamped templates; the workflow module owns identity, lineage, and publication.

type TrackerProjectionBuilder

TrackerProjectionBuilder hides catalog/config resolution and tracker-local projection semantics. Rule authorization inputs are tracker-scoped, server-held fingerprints that implementations accept only for an identical freshly evaluated waivable-failure set.

type UploadMediaImagesCommand

type UploadMediaImagesCommand struct {
	WorkflowID       api.WorkflowID
	ExpectedRevision api.WorkflowRevision
	Media            api.MediaArtifactSetRef
	ArtifactIDs      []api.PublicResourceID
	Host             string
	Retry            bool
	IdempotencyKey   string
}

UploadMediaImagesCommand hosts selected local artifacts for exact media lineage.

type UploadPlanBuildOptions

type UploadPlanBuildOptions struct {
	DryRun               bool
	NoSeed               bool
	TrackerIDs           []api.TrackerID
	TrackerApproval      *api.TrackerApprovalSnapshotRef
	AuthorityFingerprint api.WorkflowFingerprint
}

UploadPlanBuildOptions controls side effects and execution policy for one retained upload preparation.

type UploadPlanBuilder

UploadPlanBuilder creates the public review projection and the exact private prepared operations represented by it.

Jump to

Keyboard shortcuts

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