Documentation
¶
Index ¶
- Constants
- func Error(code string) error
- func ErrorCode(err error) string
- func TranslationAssignmentMigrations() fs.FS
- func TranslationFlowMigrations() fs.FS
- func TranslationFlowSQLiteMigrations() fs.FS
- func UISchemas() fs.FS
- func WorkflowRuntimeMigrations() fs.FS
- type AccessRequest
- type ActivateRequest
- type Activation
- type ActiveState
- type ArtifactProvider
- type ArtifactRef
- type CancelRequest
- type Capability
- type CatalogProvider
- type Check
- type Claim
- type Command
- type Component
- type Coverage
- type DatasetRef
- type Descriptor
- type Failure
- type GenerateRequest
- type Generator
- type Input
- type Intent
- type IntentObservation
- type Kind
- type Lease
- type ManagedTarget
- type Message
- type Observation
- type Operation
- type OperationStore
- type Policy
- type PreparationReceipt
- type PrepareRequest
- type Principal
- type Progress
- type Provider
- type RefreshRequest
- type ResetRequest
- type Result
- type SamplePeriod
- type ScenarioRef
- type Service
- func (s *Service) Active(ctx context.Context, targetID string) (ActiveState, error)
- func (s *Service) AuthorizeInput(ctx context.Context, kind Kind, input Input) error
- func (s *Service) Catalog(ctx context.Context, targetID string, limit int) ([]Descriptor, error)
- func (s *Service) Describe(ctx context.Context, ref DatasetRef, targetID string) (Descriptor, error)
- func (s *Service) LookupArtifact(ctx context.Context, providerID, artifactID string) (any, error)
- func (s *Service) LookupOperation(ctx context.Context, id string) (Operation, error)
- func (s *Service) Operations(ctx context.Context, targetID string, limit int) ([]Operation, error)
- func (s *Service) Recover(ctx context.Context, operationID string) (Result, error)
- func (s *Service) Run(ctx context.Context, kind Kind, input Input) (Result, error)
- type ServiceConfig
- type State
- type StoreCapabilities
- type TargetCapabilities
- type TargetKey
- type TargetState
- type ValidateRequest
- type VerificationResult
- type VerifyRequest
- type Work
Constants ¶
const ( CodeInvalid = "invalid_input" CodeDenied = "denied" CodeConflict = "fingerprint_conflict" CodeBusy = "busy" CodeStale = "stale_generation" CodeCanceled = "canceled" CodeRecovery = "recovery_required" CodeLeaseLost = "lease_lost" CodeGone = "gone" CodeProvider = "provider_failed" )
const ( CheckPassed = "passed" CheckFailed = "failed" CheckPlanned = "planned" )
const ( CoveredEmpty = "covered_empty" Uncovered = "uncovered" Partial = "partial" PolicySuppressed = "policy_suppressed" )
const MaxWireCounter uint64 = 1<<53 - 1
const WireVersion = "v1"
WireVersion freezes the lifecycle wire contract independently of host routes.
Variables ¶
This section is empty.
Functions ¶
func TranslationAssignmentMigrations ¶ added in v0.25.0
TranslationAssignmentMigrations returns the legacy queue assignment migration set.
func TranslationFlowMigrations ¶ added in v0.27.0
TranslationFlowMigrations returns the translation-flow migration set.
func TranslationFlowSQLiteMigrations ¶ added in v0.27.0
TranslationFlowSQLiteMigrations returns the sqlite-specific translation-flow migrations for local runtimes.
func WorkflowRuntimeMigrations ¶ added in v0.75.0
WorkflowRuntimeMigrations returns the workflow runtime migration set.
Types ¶
type AccessRequest ¶ added in v0.139.0
type AccessRequest struct {
Action string
Target TargetKey
Operation *Operation
Receipt *PreparationReceipt
Artifact *ArtifactRef
}
type ActivateRequest ¶ added in v0.139.0
type ActivateRequest struct{ Input }
func (ActivateRequest) OperationInput ¶ added in v0.139.0
func (m ActivateRequest) OperationInput() Input
func (ActivateRequest) OperationKind ¶ added in v0.139.0
func (ActivateRequest) OperationKind() Kind
func (ActivateRequest) Type ¶ added in v0.139.0
func (ActivateRequest) Type() string
func (ActivateRequest) Validate ¶ added in v0.139.0
func (m ActivateRequest) Validate() error
type Activation ¶ added in v0.139.0
type ActiveState ¶ added in v0.139.0
type ActiveState struct {
Target TargetKey `json:"target"`
Activation Activation `json:"activation"`
Transitioning bool `json:"transitioning"`
RecoveryRequired bool `json:"recovery_required"`
}
ActiveState is the safe read model; physical intent IDs and fence/delegation metadata remain in OperationStore. Transitioning never claims a ready route.
type ArtifactProvider ¶ added in v0.139.0
type ArtifactProvider interface {
LookupArtifact(context.Context, Principal, ArtifactRef) (any, error)
}
ArtifactProvider resolves opaque references after current service and domain policy checks. Never return a public URL or an implicit PII/export grant.
type ArtifactRef ¶ added in v0.139.0
type CancelRequest ¶ added in v0.139.0
type CancelRequest struct{ Input }
func (CancelRequest) OperationInput ¶ added in v0.139.0
func (m CancelRequest) OperationInput() Input
func (CancelRequest) OperationKind ¶ added in v0.139.0
func (CancelRequest) OperationKind() Kind
func (CancelRequest) Type ¶ added in v0.139.0
func (CancelRequest) Type() string
func (CancelRequest) Validate ¶ added in v0.139.0
func (m CancelRequest) Validate() error
type Capability ¶ added in v0.139.0
type CatalogProvider ¶ added in v0.139.0
type CatalogProvider interface {
Catalog(context.Context, Principal, TargetKey, int) ([]DatasetRef, error)
}
CatalogProvider returns bounded references already filtered by application domain policy. The service rechecks each descriptor before disclosing it. Absence means catalog discovery is unsupported; exact Describe remains usable.
type Command ¶ added in v0.139.0
Command adapts each distinct typed message to the shared lifecycle service.
type Coverage ¶ added in v0.139.0
type Coverage struct {
Status string `json:"status"`
Sample SamplePeriod `json:"sample"`
}
type DatasetRef ¶ added in v0.139.0
type DatasetRef struct {
Provider string `json:"provider"`
ID string `json:"id"`
Version string `json:"version"`
Digest string `json:"digest"`
}
func (DatasetRef) Valid ¶ added in v0.139.0
func (r DatasetRef) Valid() bool
type Descriptor ¶ added in v0.139.0
type Descriptor struct {
Dataset DatasetRef `json:"dataset"`
Components []Component `json:"components"`
SourceContractHash string `json:"source_contract_hash"`
SourceContractVersion string `json:"source_contract_version"`
PolicyHash string `json:"policy_hash"`
AudienceHashes map[string]string `json:"audience_hashes"`
Attribution []string `json:"attribution"`
Timezone string `json:"timezone"`
Samples []SamplePeriod `json:"samples"`
GeneratorVersion string `json:"generator_version,omitempty"`
Seed string `json:"seed,omitempty"`
GeneratorOptions map[string]string `json:"generator_options,omitempty"`
Synthetic bool `json:"synthetic"`
Counts map[string]uint64 `json:"counts"`
Prerequisites []string `json:"prerequisites"`
Scenarios []ScenarioRef `json:"scenarios"`
Capabilities map[Kind]Capability `json:"capabilities"`
}
func (Descriptor) CompositeDigest ¶ added in v0.139.0
func (d Descriptor) CompositeDigest() (string, error)
CompositeDigest canonicalizes path order and JSON map keys. Digest, scenario back-references and current permission/capability discovery are excluded. Counts, evidence, samples and source/policy/generator metadata remain bound.
func (Descriptor) ValidateIdentity ¶ added in v0.139.0
func (d Descriptor) ValidateIdentity() error
type Failure ¶ added in v0.139.0
type Failure struct {
Code string `json:"code"`
Fields map[string]string `json:"fields,omitempty"`
}
Failure contains only safe codes; provider errors are never serialized verbatim.
type GenerateRequest ¶ added in v0.139.0
type GenerateRequest struct{ Input }
func (GenerateRequest) OperationInput ¶ added in v0.139.0
func (m GenerateRequest) OperationInput() Input
func (GenerateRequest) OperationKind ¶ added in v0.139.0
func (GenerateRequest) OperationKind() Kind
func (GenerateRequest) Type ¶ added in v0.139.0
func (GenerateRequest) Type() string
func (GenerateRequest) Validate ¶ added in v0.139.0
func (m GenerateRequest) Validate() error
type Generator ¶ added in v0.139.0
type Generator interface {
Generate(context.Context, Work) (DatasetRef, error)
}
type Input ¶ added in v0.139.0
type Input struct {
Dataset DatasetRef `json:"dataset"`
Scenario ScenarioRef `json:"scenario"`
TargetID string `json:"target_id"`
IdempotencyKey string `json:"idempotency_key"`
ReceiptID string `json:"receipt_id,omitempty"`
ExpectedGeneration *uint64 `json:"expected_generation,omitempty"`
OperationID string `json:"operation_id,omitempty"`
DryRun bool `json:"dry_run"`
BatchLimit int `json:"batch_limit"`
PageLimit int `json:"page_limit"`
TimeoutSeconds int `json:"timeout_seconds"`
}
Input is shared by UI, CLI, jobs and schedules. It deliberately has no actor, scope, principal, filesystem or credential fields. Zero generation is meaningful.
type Intent ¶ added in v0.139.0
type Intent struct {
ID string `json:"id"`
OperationID string `json:"operation_id"`
Target TargetKey `json:"target"`
Kind Kind `json:"kind"`
Prior Activation `json:"prior"`
Next Activation `json:"next"`
Receipt *PreparationReceipt `json:"receipt,omitempty"`
Fence uint64 `json:"fence"`
}
type IntentObservation ¶ added in v0.139.0
type IntentObservation string
const ( RoutingPrior IntentObservation = "prior" RoutingNext IntentObservation = "next" RoutingUnknown IntentObservation = "unknown" )
type ManagedTarget ¶ added in v0.139.0
type ManagedTarget interface {
Capabilities() TargetCapabilities
Allocate(context.Context, Work) error
InspectReceipt(context.Context, PreparationReceipt) error
Commit(context.Context, Work, Intent) error
InspectIntent(context.Context, Intent) (Observation, error)
DrainCleanup(context.Context, Work, string) error
}
Allocate uses the persisted Work.StageID and is idempotent by operation/stage. ManagedTarget implements physical effects, not operation/generation authority. Commit is idempotent by intent.ID and fenced: durable routing identifies the intent even across restart. An ambiguous error must be inspected, never undone blindly. InspectReceipt is read-only and checks stage/content/checkpoint identity. DrainCleanup fences and drains all stage writers before deletion; it is forbidden for active, retained rollback or pending-intent receipts.
type Observation ¶ added in v0.139.0
type Observation struct {
Routing IntentObservation
// Ready means the observed physical routing is safe and healthy, including
// a safely deactivated target. It is distinct from Activation.Ready, which
// reports an active prepared dataset. An unready prior route cannot settle
// an intent any more than an unready next route can.
Ready bool
}
func (Observation) AuthoritativeRouting ¶ added in v0.139.0
func (o Observation) AuthoritativeRouting() IntentObservation
AuthoritativeRouting keeps reconciliation and store validation on the same authority rule. Known routing without readiness still requires recovery.
type Operation ¶ added in v0.139.0
type Operation struct {
Result Result `json:"result"`
Target TargetKey `json:"target"`
Principal Principal `json:"principal"`
Input Input `json:"input"`
Fingerprint string `json:"fingerprint"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
RecoveryPrincipal *Principal `json:"recovery_principal,omitempty"`
StageID string `json:"stage_id,omitempty"`
CancelRequested bool `json:"cancel_requested"`
}
type OperationStore ¶ added in v0.139.0
type OperationStore interface {
Capabilities() StoreCapabilities
Claim(context.Context, Operation) (Claim, error)
GetOperation(context.Context, string) (Operation, error)
ListOperations(context.Context, TargetKey, int) ([]Operation, error)
Acquire(context.Context, string, TargetKey, time.Duration) (Lease, error)
AcquireRecovery(context.Context, string, TargetKey, time.Duration) (Lease, error)
Renew(context.Context, Lease, time.Duration) (Lease, error)
CheckLease(context.Context, Lease) error
// CheckCleanup rejects active, pending or retained receipts under the lease.
CheckCleanup(context.Context, Lease, string) error
Release(context.Context, Lease) error
Save(context.Context, Operation, uint64, *Lease) (Operation, error)
RequestCancel(context.Context, string, uint64) (Operation, error)
PutReceipt(context.Context, Lease, PreparationReceipt) error
GetReceipt(context.Context, string) (PreparationReceipt, error)
// GetArtifact loads original metadata by provider and opaque ID; caller
// claims about requester, scope, expiry or generation are never authoritative.
GetArtifact(context.Context, string, string) (ArtifactRef, error)
PutVerification(context.Context, Lease, string, uint64, VerificationResult) (PreparationReceipt, error)
Target(context.Context, TargetKey) (TargetState, error)
BeginIntent(context.Context, Lease, Intent, uint64) error
ResolveIntent(context.Context, Lease, Intent, Observation, Operation, uint64) (Operation, error)
}
OperationStore owns durable atomicity. Every mutator must reject expired or stale leases, and stale operation revisions. Claims have a unique compound key (actor, scope, target, command version, caller key) and immutable fingerprint. Target keys include scope. No callback may perform physical effects in a DB tx. Lease time uses authoritative store time. Tokens monotonically increase and never reset when a claim expires/releases. Acquire rejects pending intents and recovery_required; AcquireRecovery fences all prior workers and binds the operation and any pending intent; it requires the previous lease to expire. Save increments Revision atomically; progress/cancel also participate in CAS. Persist receipt/verification before events, never overwrite receipt content. BeginIntent atomically checks lease, generation, receipt/content and operation revision. ResolveIntent atomically finalizes activation, intent and operation; routing-next increments generation exactly once; routing-prior retains it. Both known routes require Observation.Ready (physical safety/health); an unready route follows AuthoritativeRouting's unknown/recovery rule and cannot finalize a terminal outcome or clear pending evidence. Unknown preserves intent, blocks writes and persists recovering, not failed. Retention preserves idempotency tombstones for its advertised retry window, active/pending/rollback receipts, artifacts and all recovery evidence. Hosts must configure bounded lease, retry, retention and artifact durations before writes.
type Policy ¶ added in v0.139.0
type Policy interface {
Authorize(context.Context, Principal, AccessRequest) error
}
type PreparationReceipt ¶ added in v0.139.0
type PreparationReceipt struct {
ID string `json:"id"`
Target TargetKey `json:"target"`
StageID string `json:"stage_id"`
Dataset DatasetRef `json:"dataset"`
Scenario ScenarioRef `json:"scenario"`
ModuleHash string `json:"module_hash"`
PolicyHash string `json:"policy_hash"`
PermissionHash string `json:"permission_hash"`
ContentRevision uint64 `json:"content_revision"`
SourceCheckpoint string `json:"source_checkpoint"`
DerivedCheckpoint string `json:"derived_checkpoint"`
RequesterID string `json:"requester_id"`
Verification *VerificationResult `json:"verification,omitempty"`
}
type PrepareRequest ¶ added in v0.139.0
type PrepareRequest struct{ Input }
func (PrepareRequest) OperationInput ¶ added in v0.139.0
func (m PrepareRequest) OperationInput() Input
func (PrepareRequest) OperationKind ¶ added in v0.139.0
func (PrepareRequest) OperationKind() Kind
func (PrepareRequest) Type ¶ added in v0.139.0
func (PrepareRequest) Type() string
func (PrepareRequest) Validate ¶ added in v0.139.0
func (m PrepareRequest) Validate() error
type Principal ¶ added in v0.139.0
type Principal struct {
ActorID string `json:"actor_id"`
ScopeKey string `json:"scope_key"`
ExecutionID string `json:"execution_id"`
CorrelationID string `json:"correlation_id,omitempty"`
ModuleHash string `json:"module_hash"`
PolicyHash string `json:"policy_hash"`
PermissionHash string `json:"permission_hash"`
}
Principal is supplied by a host resolver consulting current trusted state. It is not embedded in Input or accepted from JSON.
type Provider ¶ added in v0.139.0
type Provider interface {
Describe(context.Context, Principal, DatasetRef) (Descriptor, error)
Validate(context.Context, Principal, Input) ([]Check, error)
Plan(context.Context, Principal, Kind, Input) ([]Check, error)
Prepare(context.Context, Work) (PreparationReceipt, error)
Refresh(context.Context, Work) (PreparationReceipt, error)
Verify(context.Context, Work, PreparationReceipt) (VerificationResult, error)
}
Provider uses application commands/services for domain work. Validate and Plan are read-only, including artifact effects. Plan checks say planned/unavailable. Prepare and Refresh only write the supplied owned stage. A receipt is immutable; changing its content requires a new receipt and fresh verification.
type RefreshRequest ¶ added in v0.139.0
type RefreshRequest struct{ Input }
func (RefreshRequest) OperationInput ¶ added in v0.139.0
func (m RefreshRequest) OperationInput() Input
func (RefreshRequest) OperationKind ¶ added in v0.139.0
func (RefreshRequest) OperationKind() Kind
func (RefreshRequest) Type ¶ added in v0.139.0
func (RefreshRequest) Type() string
func (RefreshRequest) Validate ¶ added in v0.139.0
func (m RefreshRequest) Validate() error
type ResetRequest ¶ added in v0.139.0
type ResetRequest struct{ Input }
func (ResetRequest) OperationInput ¶ added in v0.139.0
func (m ResetRequest) OperationInput() Input
func (ResetRequest) OperationKind ¶ added in v0.139.0
func (ResetRequest) OperationKind() Kind
func (ResetRequest) Type ¶ added in v0.139.0
func (ResetRequest) Type() string
func (ResetRequest) Validate ¶ added in v0.139.0
func (m ResetRequest) Validate() error
type Result ¶ added in v0.139.0
type Result struct {
OperationID string `json:"operation_id"`
Kind Kind `json:"kind"`
State State `json:"state"`
Revision uint64 `json:"revision"`
Phase string `json:"phase"`
DryRun bool `json:"dry_run"`
Active bool `json:"active"`
Receipt *PreparationReceipt `json:"receipt,omitempty"`
Verification *VerificationResult `json:"verification,omitempty"`
Activation *Activation `json:"activation,omitempty"`
Checks []Check `json:"checks,omitempty"`
Progress Progress `json:"progress"`
Dataset *DatasetRef `json:"dataset,omitempty"`
Failure *Failure `json:"failure,omitempty"`
}
func (Result) CommandResultFailure ¶ added in v0.139.0
type SamplePeriod ¶ added in v0.139.0
type ScenarioRef ¶ added in v0.139.0
type ScenarioRef struct {
Dataset DatasetRef `json:"dataset"`
ID string `json:"id"`
Version string `json:"version"`
ProfileHash string `json:"profile_hash"`
}
func (ScenarioRef) Valid ¶ added in v0.139.0
func (r ScenarioRef) Valid() bool
type Service ¶ added in v0.139.0
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶ added in v0.139.0
func NewService(cfg ServiceConfig) (*Service, error)
func (*Service) AuthorizeInput ¶ added in v0.139.0
AuthorizeInput performs no effects. Named factories use it before dispatch; typed handlers still enforce policy again at the service boundary.
func (*Service) Describe ¶ added in v0.139.0
func (s *Service) Describe(ctx context.Context, ref DatasetRef, targetID string) (Descriptor, error)
func (*Service) LookupArtifact ¶ added in v0.139.0
func (*Service) LookupOperation ¶ added in v0.139.0
func (*Service) Operations ¶ added in v0.139.0
func (*Service) Recover ¶ added in v0.139.0
Recover is an explicit authorized supervisor operation, never an implicit UI retry. It waits for lease expiry through the store, fences old workers and inspects routing. Unknown authority retains the intent and blocks new writes.
type ServiceConfig ¶ added in v0.139.0
type ServiceConfig struct {
Providers map[string]Provider
Target ManagedTarget
Store OperationStore
Policy Policy
// Resolve must consult current trusted state, including revocation, on every
// invocation. It must not read actor/scope/delegation from Input.
Resolve func(context.Context) (Principal, error)
LeaseDuration time.Duration
CleanupTimeout time.Duration
// WritesEnabled is the host's explicit conformance gate (T05). Durable capability
// flags are additionally required; they are not themselves conformance evidence.
WritesEnabled bool
}
type StoreCapabilities ¶ added in v0.139.0
type StoreCapabilities struct {
Durable bool
AtomicClaims bool
Fencing bool
AtomicIntentFinalize bool
ProtectedRetention bool
}
func (StoreCapabilities) WriteReady ¶ added in v0.139.0
func (c StoreCapabilities) WriteReady() bool
type TargetCapabilities ¶ added in v0.139.0
type TargetState ¶ added in v0.139.0
type TargetState struct {
Activation Activation
Pending *Intent
RecoveryRequired bool
}
type ValidateRequest ¶ added in v0.139.0
type ValidateRequest struct{ Input }
func (ValidateRequest) OperationInput ¶ added in v0.139.0
func (m ValidateRequest) OperationInput() Input
func (ValidateRequest) OperationKind ¶ added in v0.139.0
func (ValidateRequest) OperationKind() Kind
func (ValidateRequest) Type ¶ added in v0.139.0
func (ValidateRequest) Type() string
func (ValidateRequest) Validate ¶ added in v0.139.0
func (m ValidateRequest) Validate() error
type VerificationResult ¶ added in v0.139.0
type VerificationResult struct {
ID string `json:"id"`
ContentRevision uint64 `json:"content_revision"`
Checks []Check `json:"checks"`
Coverage []Coverage `json:"coverage"`
Artifacts []ArtifactRef `json:"artifacts,omitempty"`
}
func (VerificationResult) Passed ¶ added in v0.139.0
func (v VerificationResult) Passed() bool
type VerifyRequest ¶ added in v0.139.0
type VerifyRequest struct{ Input }
func (VerifyRequest) OperationInput ¶ added in v0.139.0
func (m VerifyRequest) OperationInput() Input
func (VerifyRequest) OperationKind ¶ added in v0.139.0
func (VerifyRequest) OperationKind() Kind
func (VerifyRequest) Type ¶ added in v0.139.0
func (VerifyRequest) Type() string
func (VerifyRequest) Validate ¶ added in v0.139.0
func (m VerifyRequest) Validate() error
type Work ¶ added in v0.139.0
type Work struct {
OperationID string
Principal Principal
Input Input
Lease Lease
StageID string
BeforeEffects func(context.Context) error
Progress func(context.Context, Progress) error
}
Work is created by the lifecycle service. BeforeEffects must be called between bounded batches and immediately before each effect; targets/domain services must reject stale Fence values. Request cancellation alone is not a fencing protocol.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
sqlitestore
Package sqlitestore is a small file-backed reference adapter for lifecycle conformance and host examples.
|
Package sqlitestore is a small file-backed reference adapter for lifecycle conformance and host examples. |