data

package
v0.144.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeInvalid     = "invalid_input"
	CodeDenied      = "denied"
	CodeConflict    = "fingerprint_conflict"
	CodeBusy        = "busy"
	CodeStale       = "stale_generation"
	CodeUnavailable = "unavailable"
	CodeCanceled    = "canceled"
	CodeRecovery    = "recovery_required"
	CodeLeaseLost   = "lease_lost"
	CodeGone        = "gone"
	CodeProvider    = "provider_failed"
)
View Source
const (
	CheckPassed      = "passed"
	CheckFailed      = "failed"
	CheckPlanned     = "planned"
	CheckUnavailable = "unavailable"
)
View Source
const (
	CoveredEmpty     = "covered_empty"
	Uncovered        = "uncovered"
	Partial          = "partial"
	PolicySuppressed = "policy_suppressed"
	Unavailable      = "unavailable"
)
View Source
const (
	ExploreCatalog           = "catalog_example"
	ExplorePrepared          = "prepared"
	ExploreActive            = "active"
	ExploreAvailable         = "available"
	ExploreUnsupported       = "unsupported"
	ExploreEmpty             = "empty"
	ExploreSuppressed        = "suppressed"
	ExploreDefaultLimit      = 25
	ExploreMaxLimit          = 100
	ExploreMaxSelectionBytes = 4 << 10
	ExploreMaxResponseBytes  = 256 << 10
	ExploreMaxMetadataBytes  = 64 << 10
)
View Source
const (
	InsightsMaxMetrics    = 16
	InsightsMaxCategories = 32
	InsightsMaxDays       = 90
	InsightsMaxQueries    = 8
	InsightsMaxRecords    = 10000
)
View Source
const (
	MaintenanceDisabled         = "disabled"
	MaintenanceDue              = "due"
	MaintenanceReady            = "ready"
	MaintenancePaused           = "paused"
	MaintenancePreparing        = "preparing"
	MaintenanceFailed           = "failed"
	MaintenanceRecoveryRequired = "recovery_required"
)
View Source
const (
	MaintenanceConfigureCommandID = "admin.data.maintenance.configure.v1"
	MaintenanceEnsureCommandID    = "admin.data.maintenance.ensure.v1"
	MaintenanceStatusQueryID      = "admin.data.maintenance.status.v1"
)
View Source
const (
	PreviewReady           = "ready"
	PreviewUnavailable     = "unavailable"
	PreviewExpired         = "expired"
	PreviewClosed          = "closed"
	PreviewMaxSurfaces     = 16
	PreviewMaxSessions     = 4
	PreviewMaxPrune        = 100
	PreviewDefaultLifetime = 15 * time.Minute
	PreviewMaxLifetime     = 30 * time.Minute
)
View Source
const MaxWireCounter uint64 = 1<<53 - 1
View Source
const WireVersion = "v1"

WireVersion freezes the lifecycle wire contract independently of host routes.

Variables

This section is empty.

Functions

func ActivityIngestionMigrations added in v0.142.2

func ActivityIngestionMigrations() fs.FS

ActivityIngestionMigrations exposes explicit SQLite/PostgreSQL receipt DDL. Apply the dialect's up migration after go-users activity/scope migrations. Receipts have no TTL or activity foreign key; restore and prune them together with the producer replay contract. Constructors never execute migrations.

func Error added in v0.139.0

func Error(code string) error

func ErrorCode added in v0.139.0

func ErrorCode(err error) string

func RejectPreviewEffects added in v0.139.3

func RejectPreviewEffects(ctx context.Context) error

Use at ordinary mutation/job/webhook/export boundaries before dispatch. Hosts must not spawn background work or drop this context on a preview request.

func RunMaintenance added in v0.139.4

func RunMaintenance(ctx context.Context, dispatch func(context.Context) (MaintenanceResult, error), report func(error)) error

RunMaintenance runs in the host-owned lifecycle. Dispatch must use the same registered Ensure command as manual callers, under a trusted delegated actor. No background work is started by DataModule or a status/read request.

func SafeErrorCode added in v0.139.1

func SafeErrorCode(err error) (string, bool)

SafeErrorCode finds a recognized lifecycle error through dispatcher wrappers and joined causes. The boolean distinguishes an explicit safe provider failure from an unknown error, which must retain the host's ordinary error handling.

func SettingsDocumentMigrations added in v0.140.0

func SettingsDocumentMigrations() fs.FS

SettingsDocumentMigrations returns the portable SQLite/PostgreSQL document migrations. Hosts install these in their ordered migration lifecycle.

func TranslationAssignmentMigrations added in v0.25.0

func TranslationAssignmentMigrations() fs.FS

TranslationAssignmentMigrations returns the legacy queue assignment migration set.

func TranslationFlowMigrations added in v0.27.0

func TranslationFlowMigrations() fs.FS

TranslationFlowMigrations returns the translation-flow migration set.

func TranslationFlowSQLiteMigrations added in v0.27.0

func TranslationFlowSQLiteMigrations() fs.FS

TranslationFlowSQLiteMigrations returns the sqlite-specific translation-flow migrations for local runtimes.

func UISchemas

func UISchemas() fs.FS

UISchemas returns the embedded UI schema filesystem.

func WorkflowRuntimeMigrations added in v0.75.0

func WorkflowRuntimeMigrations() fs.FS

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
	Explore   *ExploreAccess
}

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 Activation struct {
	ReceiptID  string `json:"receipt_id,omitempty"`
	Generation uint64 `json:"generation"`
	Ready      bool   `json:"ready"`
}

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"`
	PendingOperationID string     `json:"pending_operation_id,omitempty"`
	PendingReceiptID   string     `json:"pending_receipt_id,omitempty"`
}

ActiveState is the safe read model; physical intent IDs and fence/delegation metadata remain in OperationStore. Transitioning never claims a ready route.

type ApplicationPreviewAdapter added in v0.139.3

type ApplicationPreviewAdapter interface {
	PreviewGuarantees() PreviewGuarantees
	PreviewReadiness(context.Context, Principal, ExploreRead) error
	OpenPreview(context.Context, PreviewRecord, int) (PreviewRecord, error)
	LookupPreview(context.Context, string) (PreviewRecord, error)
	InspectPreview(context.Context, PreviewRecord) error
	EndPreview(context.Context, string, string) error
	PrunePreviews(context.Context, int) error
	InsightAuthorizationRevision
}

The adapter must allocate session AND receipt retention atomically. Open uses actor/scope/application/environment/target/request as its durable unique key; changed fingerprints conflict, even after expiry/close. Replay never extends expiry. Inspect is observation-only and checks durable state and isolation. New allocations use the requested session UUID; replays return the original UUID, allowing the service to roll back only resources owned by that launch. End releases only preview authority/resources, never a receipt or active stage. Methods are bounded, cancellable, detached and safe across processes. The authorization revision covers all mutable application/domain/field/row decisions used by this adapter; the same observation-only/nonreuse contract as InsightAuthorizationRevision applies. Enabled previews require the host Policy to implement that interface as well, covering identity/scope and host grants with durable, non-reused epochs. Hashes of current grants are insufficient for sessions spanning revoke/restore. A truly immutable policy may use a constant.

type ApplicationPreviewConfig added in v0.139.3

type ApplicationPreviewConfig struct {
	Adapter                      ApplicationPreviewAdapter
	Enabled                      bool
	ApplicationID, EnvironmentID string
	Lifetime                     time.Duration
	Surfaces                     []PreviewSurface
	// Now is a host clock, shared with its durable adapter.
	Now func() time.Time
}

type ApplicationPreviewSession added in v0.139.3

type ApplicationPreviewSession struct {
	SessionID string           `json:"session_id"`
	Selection ExploreSelection `json:"selection"`
	SurfaceID string           `json:"surface_id"`
	State     string           `json:"state"`
	ExpiresAt time.Time        `json:"expires_at"`
	LaunchURL string           `json:"launch_url,omitempty"`
	ReturnURL string           `json:"return_url,omitempty"`
	ReadOnly  bool             `json:"read_only"`
	// contains filtered or unexported fields
}

type ApplicationPreviewSessionQuery added in v0.139.3

type ApplicationPreviewSessionQuery struct {
	SessionID string `json:"session_id"`
}

func (ApplicationPreviewSessionQuery) Type added in v0.139.3

func (ApplicationPreviewSessionQuery) Validate added in v0.139.3

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 ArtifactRef struct {
	Provider    string    `json:"provider"`
	ID          string    `json:"id"`
	Target      TargetKey `json:"target"`
	Generation  uint64    `json:"generation"`
	RequesterID string    `json:"requester_id"`
	ExpiresAt   time.Time `json:"expires_at"`
}

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 Capability struct {
	Supported bool   `json:"supported"`
	Permitted bool   `json:"permitted"`
	Reason    string `json:"reason,omitempty"`
}

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 Check added in v0.139.0

type Check struct {
	ID          string `json:"id"`
	Label       string `json:"label,omitempty"`
	Status      string `json:"status"`
	Expected    string `json:"expected,omitempty"`
	Actual      string `json:"actual,omitempty"`
	EvidenceRef string `json:"evidence_ref,omitempty"`
}

Check is one validation, verification or planned check. Label is an optional human name; consoles fall back to the ID.

type Claim added in v0.139.0

type Claim struct {
	Operation Operation
	Replay    bool
}

type CloseApplicationPreviewCommand added in v0.139.3

type CloseApplicationPreviewCommand struct {
	SessionID string `json:"session_id"`
}

func (CloseApplicationPreviewCommand) Type added in v0.139.3

func (CloseApplicationPreviewCommand) Validate added in v0.139.3

type Command added in v0.139.0

type Command[T Message] struct{ Service *Service }

Command adapts each distinct typed message to the shared lifecycle service.

func (*Command[T]) Execute added in v0.139.0

func (c *Command[T]) Execute(ctx context.Context, msg T) error

func (*Command[T]) Run added in v0.139.0

func (c *Command[T]) Run(ctx context.Context, msg T) (Result, error)

type CompareSelectionsQuery added in v0.139.3

type CompareSelectionsQuery struct {
	Left        ExploreSelection `json:"left"`
	Right       ExploreSelection `json:"right"`
	MetricSetID string           `json:"metric_set_id"`
	InsightWindow
}

func (CompareSelectionsQuery) Type added in v0.139.3

func (CompareSelectionsQuery) Validate added in v0.139.3

func (q CompareSelectionsQuery) Validate() error

type Component added in v0.139.0

type Component struct {
	Path   string `json:"path"`
	Digest string `json:"digest"`
}

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"`
	// Presentation is optional and excluded from the composite digest.
	Presentation *DescriptorPresentation `json:"presentation,omitempty"`
}

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, current permission/capability discovery and descriptive presentation are excluded. Counts, evidence, samples and source/policy/generator metadata remain bound.

func (Descriptor) ScenarioSummary added in v0.139.4

func (d Descriptor) ScenarioSummary(scenarioID string) string

ScenarioSummary is the declared one-line purpose of a scenario ID, or "".

func (Descriptor) ScenarioTitle added in v0.139.4

func (d Descriptor) ScenarioTitle(scenarioID string) string

ScenarioTitle is the declared human title of a scenario ID, or "".

func (Descriptor) Summary added in v0.139.4

func (d Descriptor) Summary() string

Summary is the declared one-line purpose of the dataset, or "".

func (Descriptor) Title added in v0.139.4

func (d Descriptor) Title() string

Title is the declared human title of the dataset, or "" when none is declared.

func (Descriptor) ValidateIdentity added in v0.139.0

func (d Descriptor) ValidateIdentity() error

type DescriptorPresentation added in v0.139.4

type DescriptorPresentation struct {
	Title   string `json:"title,omitempty"`
	Summary string `json:"summary,omitempty"`
	// Scenarios names scenarios by ID; the versions of one scenario share it.
	Scenarios map[string]ScenarioPresentation `json:"scenarios,omitempty"`
}

DescriptorPresentation is optional descriptive metadata for people: a human title and summary for the dataset and its scenarios. It is digest-neutral: CompositeDigest excludes it, so editing a label never invalidates a dataset version, a prepared receipt or a request fingerprint. It carries no identity; consoles fall back to identifiers when a title is missing.

type ExplorationProvider added in v0.139.3

ExplorationProvider is optional. Every method is read-only, bounded, cancellable and domain filtered; cursors/record keys bind actor/scope/full selection/entity. Related permits only provider-declared depth-one relationships. AuthorizeExplore must recheck current domain/field policy without caching grants. Return detached DTOs; do not mutate shared buffers while the service validates/delivers them.

type ExploreAccess added in v0.139.3

type ExploreAccess struct {
	Selection      ExploreSelection
	MetricSetID    string
	MetricIDs      []string
	Coverage       bool
	EntityID       string
	Fields         []string
	RecordKeys     []string
	SurfaceIDs     []string
	RelationshipID string
	SourceEntityID string
	RecordKey      string
}

ExploreAccess reaches current host AND provider policy, including every delivered entity/field/row/link. A denial returns no partial result and no hidden counts.

type ExploreCell added in v0.139.3

type ExploreCell struct {
	State string `json:"state"`
	Value any    `json:"value"`
}

Explicit states distinguish unknown/redacted cells from a known null or empty value. Value is restricted to the column's scalar type by the service.

type ExploreCount added in v0.139.3

type ExploreCount struct {
	EntityID string  `json:"entity_id"`
	Scope    string  `json:"scope"`
	Total    *uint64 `json:"total"`
}

type ExploreEffect added in v0.139.3

type ExploreEffect struct {
	Phase       string `json:"phase"`
	Description string `json:"description"`
}

type ExploreEntity added in v0.139.3

type ExploreEntity struct {
	ID            string                `json:"id"`
	Label         string                `json:"label"`
	Description   string                `json:"description,omitempty"`
	Fields        []ExploreField        `json:"fields"`
	Relationships []ExploreRelationship `json:"relationships,omitempty"`
}

type ExploreEnvelope added in v0.139.3

type ExploreEnvelope struct {
	Selection            ExploreSelection `json:"selection"`
	PresentationRevision string           `json:"presentation_revision"`
	ObservedAt           time.Time        `json:"observed_at"`
	Provenance           string           `json:"provenance"`
	Completeness         string           `json:"completeness"`
	State                string           `json:"state"`
	Reason               string           `json:"reason,omitempty"`
}

type ExploreField added in v0.139.3

type ExploreField struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	Type        string `json:"type"`
	Unit        string `json:"unit,omitempty"`
}

type ExploreInsights added in v0.139.3

type ExploreInsights struct {
	ExploreEnvelope
	MetricSetID      string            `json:"metric_set_id"`
	EquivalentSchema string            `json:"equivalent_schema,omitempty"`
	Metrics          []InsightMetric   `json:"metrics"`
	Coverage         []InsightCoverage `json:"coverage"`
	Work             InsightWork       `json:"work"`
	// contains filtered or unexported fields
}

type ExploreInsightsQuery added in v0.139.3

type ExploreInsightsQuery struct {
	Selection   ExploreSelection `json:"selection"`
	MetricSetID string           `json:"metric_set_id"`
	InsightWindow
}

ExploreInsightsQuery reads one registered metric set. An omitted MetricSetID selects the provider's first registered set for the selection; the result names the set it read, which a comparison must then name explicitly.

func (ExploreInsightsQuery) Type added in v0.139.3

func (ExploreInsightsQuery) Validate added in v0.139.3

func (q ExploreInsightsQuery) Validate() error

type ExploreMetadata added in v0.139.3

type ExploreMetadata struct {
	ExploreEnvelope
	Title             string            `json:"title"`
	Summary           string            `json:"summary"`
	Origin            string            `json:"origin"`
	Entities          []ExploreEntity   `json:"entities"`
	Scenarios         []ExploreScenario `json:"scenarios"`
	Inventory         []ExploreCount    `json:"inventory"`
	Period            *ExplorePeriod    `json:"period"`
	Prerequisites     []string          `json:"prerequisites"`
	Attribution       []string          `json:"attribution"`
	Usages            []ExploreUsage    `json:"usages"`
	UsageCompleteness string            `json:"usage_completeness"`
}

type ExploreMetadataQuery added in v0.139.3

type ExploreMetadataQuery struct {
	Selection ExploreSelection `json:"selection"`
}

func (ExploreMetadataQuery) Type added in v0.139.3

func (ExploreMetadataQuery) Validate added in v0.139.3

func (q ExploreMetadataQuery) Validate() error

type ExplorePeriod added in v0.139.3

type ExplorePeriod struct {
	Start    string `json:"start"`
	End      string `json:"end"`
	Timezone string `json:"timezone"`
}

type ExploreRead added in v0.139.3

type ExploreRead struct {
	Selection ExploreSelection
	Target    TargetKey
	Receipt   *PreparationReceipt
}

type ExploreRelatedQuery added in v0.139.3

type ExploreRelatedQuery struct {
	ExploreSamplesQuery
	RecordKey      string `json:"record_key"`
	RelationshipID string `json:"relationship_id"`
}

func (ExploreRelatedQuery) Type added in v0.139.3

func (ExploreRelatedQuery) Type() string

func (ExploreRelatedQuery) Validate added in v0.139.3

func (q ExploreRelatedQuery) Validate() error

type ExploreRelationship added in v0.139.3

type ExploreRelationship struct {
	ID       string `json:"id"`
	Label    string `json:"label"`
	EntityID string `json:"entity_id"`
}

type ExploreRow added in v0.139.3

type ExploreRow struct {
	RecordKey string                 `json:"record_key"`
	Cells     map[string]ExploreCell `json:"cells"`
}

type ExploreSamples added in v0.139.3

type ExploreSamples struct {
	ExploreEnvelope
	EntityID       string         `json:"entity_id"`
	Columns        []ExploreField `json:"columns"`
	Rows           []ExploreRow   `json:"rows"`
	Total          *uint64        `json:"total"`
	NextCursor     *string        `json:"next_cursor"`
	SamplingMethod string         `json:"sampling_method"`
}

type ExploreSamplesQuery added in v0.139.3

type ExploreSamplesQuery struct {
	Selection ExploreSelection `json:"selection"`
	EntityID  string           `json:"entity_id"`
	Cursor    string           `json:"cursor,omitempty"`
	Limit     int              `json:"limit,omitempty"`
}

func (ExploreSamplesQuery) Type added in v0.139.3

func (ExploreSamplesQuery) Type() string

func (ExploreSamplesQuery) Validate added in v0.139.3

func (q ExploreSamplesQuery) Validate() error

type ExploreScenario added in v0.139.3

type ExploreScenario struct {
	Scenario         ScenarioRef `json:"scenario"`
	Title            string      `json:"title"`
	Summary          string      `json:"summary"`
	ExpectedOutcomes []string    `json:"expected_outcomes"`
}

type ExploreSelection added in v0.139.3

type ExploreSelection struct {
	Dataset         DatasetRef  `json:"dataset"`
	Scenario        ScenarioRef `json:"scenario"`
	TargetID        string      `json:"target_id"`
	Context         string      `json:"context"`
	ReceiptID       string      `json:"receipt_id,omitempty"`
	ContentRevision uint64      `json:"content_revision,omitempty"`
	Generation      *uint64     `json:"generation,omitempty"`
}

ExploreSelection pins lifecycle identity; it contains no principal or physical locator.

func (ExploreSelection) Equal added in v0.139.3

func (s ExploreSelection) Equal(other ExploreSelection) bool

Equal compares generation values, not pointer addresses.

func (ExploreSelection) Validate added in v0.139.3

func (s ExploreSelection) Validate() error

type ExploreSurface added in v0.139.3

type ExploreSurface struct {
	Resolve func(context.Context, Principal) (string, error)
}

ExploreSurface resolution belongs to the application, not provider/browser URLs.

type ExploreUsage added in v0.139.3

type ExploreUsage struct {
	SurfaceID string          `json:"surface_id"`
	Kind      string          `json:"kind"`
	Label     string          `json:"label"`
	Effects   []ExploreEffect `json:"effects"`
	Href      string          `json:"href,omitempty"`
}

A provider declares SurfaceID only. Href is filled by the trusted host registry.

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.

func (Input) Fingerprint added in v0.139.0

func (in Input) Fingerprint(k Kind) (string, error)

func (Input) Normalize added in v0.139.0

func (in Input) Normalize() Input

func (Input) Validate added in v0.139.0

func (in Input) Validate(k Kind) error

type InsightAuthorizationRevision added in v0.139.3

type InsightAuthorizationRevision interface {
	InsightAuthorizationRevision(context.Context, Principal) (string, error)
}

InsightAuthorizationRevision is required alongside InsightsProvider for safe aggregate delivery. The opaque revision covers ALL domain decisions affecting this principal's observations: row filters, metrics, coverage and usages across every selection. Advance it atomically with policy changes; never reuse an old revision (including revoke/restore). Constant revisions are valid only for immutable policy. Reads must be bounded, cancellable and observation-only: they must not invoke authorization callbacks or mutate any participant's policy.

A host Policy must also implement this interface if its decisions can change without changing the principal's current ModuleHash/PolicyHash/PermissionHash. Revisions are a coherence fence, never a cached grant. Individual current Authorize/AuthorizeExplore checks remain mandatory.

type InsightBucket added in v0.139.3

type InsightBucket struct {
	ID     string   `json:"id"`
	Label  string   `json:"label"`
	Value  *float64 `json:"value"`
	Status string   `json:"status"`
}

type InsightCoverage added in v0.139.3

type InsightCoverage struct {
	LocalDay string           `json:"local_day"`
	Timezone string           `json:"timezone"`
	Status   string           `json:"status"`
	Evidence *InsightEvidence `json:"evidence"`
	Reason   string           `json:"reason,omitempty"`
}

type InsightDeclarations added in v0.139.3

type InsightDeclarations struct {
	Usages            []ExploreUsage `json:"usages"`
	UsageCompleteness string         `json:"usage_completeness"`
	ExpectedOutcomes  []string       `json:"expected_outcomes"`
}

type InsightDeliveryCheck added in v0.139.3

type InsightDeliveryCheck func(context.Context) (context.Context, error)

InsightDeliveryCheck performs the transport's final current host/session check. Return its resolved context, derived from the supplied request context, so the seal retains any refreshed trusted state and tighter cancellation/deadline.

type InsightEvidence added in v0.139.3

type InsightEvidence struct {
	Selection      ExploreSelection `json:"selection"`
	Ref            string           `json:"ref"`
	VerificationID string           `json:"verification_id,omitempty"`
}

Coverage evidence must bind the exact selection. Covered-empty additionally requires matching passed lifecycle verification; expected dates are uncovered.

type InsightMetric added in v0.139.3

type InsightMetric struct {
	InsightMetricDefinition
	TimeScope      ExplorePeriod   `json:"time_scope"`
	Denominator    *float64        `json:"denominator"`
	Value          *float64        `json:"value"`
	Status         string          `json:"status"`
	Buckets        []InsightBucket `json:"buckets"`
	SamplingMethod string          `json:"sampling_method"`
}

type InsightMetricComparison added in v0.139.3

type InsightMetricComparison struct {
	ID            string         `json:"id"`
	Left          *InsightMetric `json:"left"`
	Right         *InsightMetric `json:"right"`
	Compatibility string         `json:"compatibility"`
	Delta         *float64       `json:"delta"`
	PercentChange *float64       `json:"percent_change"`
	Reason        string         `json:"reason,omitempty"`
}

type InsightMetricDefinition added in v0.139.3

type InsightMetricDefinition struct {
	ID         string `json:"id"`
	Label      string `json:"label"`
	Kind       string `json:"kind"`
	Unit       string `json:"unit"`
	Population string `json:"population"`
}

Definitions are provider registered and must match every returned metric. EquivalentSchema certifies equivalent definitions across datasets; empty only permits the same exact dataset. Policy includes metric IDs and coverage grants.

type InsightMetricSet added in v0.139.3

type InsightMetricSet struct {
	ID               string                    `json:"id"`
	EquivalentSchema string                    `json:"equivalent_schema,omitempty"`
	Metrics          []InsightMetricDefinition `json:"metrics"`
	Period           ExplorePeriod             `json:"period"`
	MaxQueries       int                       `json:"max_queries"`
	MaxRecords       int                       `json:"max_records"`
	WorkEvidence     string                    `json:"work_evidence"`
}

type InsightWindow added in v0.139.3

type InsightWindow struct {
	From  string `json:"from,omitempty"`
	To    string `json:"to,omitempty"`
	Limit int    `json:"limit,omitempty"`
}

InsightWindow is inclusive in the metric set's declared timezone. Empty means the registered default interval; a browser cannot select arbitrary dimensions.

func (InsightWindow) Validate added in v0.139.3

func (w InsightWindow) Validate() error

type InsightWork added in v0.139.3

type InsightWork struct {
	Queries int `json:"queries"`
	Records int `json:"records"`
}

type InsightsProvider added in v0.139.3

InsightsProvider is optional alongside ExplorationProvider. Capabilities and results are detached, read-only, current-policy filtered and cancellable. MaxQueries/Records bound actual domain-query work, not merely returned rows. The supplied remaining budget covers the entire request including both sides.

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 Kind added in v0.139.0

type Kind string
const (
	Validate Kind = "validate"
	Prepare  Kind = "prepare"
	Refresh  Kind = "refresh"
	Verify   Kind = "verify"
	Activate Kind = "activate"
	Reset    Kind = "reset"
	Generate Kind = "generate"
	Cancel   Kind = "cancel"
	// Recover reconciles an existing operation; it never claims new provider work.
	Recover Kind = "recover"
)

func (Kind) CommandID added in v0.139.0

func (k Kind) CommandID() string

func (Kind) Valid added in v0.139.0

func (k Kind) Valid() bool

func (Kind) Writes added in v0.139.0

func (k Kind) Writes() bool

type Lease added in v0.139.0

type Lease struct {
	OperationID string
	Target      TargetKey
	Fence       uint64
	ExpiresAt   time.Time
}

type MaintenanceBackend added in v0.139.4

MaintenanceBackend supplies domain policy and persistence. Acquire serializes ALL coordinators for this scope/target, across processes, honors cancellation, and releases on process death (e.g. the host's exclusive durable owner lock). Configure atomically CASes Revision and fingerprints actor/request replay. Save rejects changed/disabled policy revisions. Delegate binds the revision; lifecycle BeforeEffects must revalidate it through the host's policy/store. Observe and Load are read-only. Plan/Generated/Complete use domain services.

type MaintenanceConfigureCommand added in v0.139.4

type MaintenanceConfigureCommand struct{ Service *MaintenanceService }

func (*MaintenanceConfigureCommand) Execute added in v0.139.4

func (*MaintenanceConfigureCommand) Run added in v0.139.4

type MaintenanceConfigureRequest added in v0.139.4

type MaintenanceConfigureRequest struct {
	Enabled          bool   `json:"enabled"`
	ExpectedRevision uint64 `json:"expected_revision"`
	RequestKey       string `json:"request_key"`
	DryRun           bool   `json:"dry_run"`
}

func (MaintenanceConfigureRequest) Type added in v0.139.4

func (MaintenanceConfigureRequest) Validate added in v0.139.4

func (r MaintenanceConfigureRequest) Validate() error

type MaintenanceEnsureCommand added in v0.139.4

type MaintenanceEnsureCommand struct{ Service *MaintenanceService }

func (*MaintenanceEnsureCommand) Execute added in v0.139.4

func (*MaintenanceEnsureCommand) Run added in v0.139.4

type MaintenanceEnsureRequest added in v0.139.4

type MaintenanceEnsureRequest struct {
	PolicyRevision     uint64 `json:"policy_revision"`
	ExpectedGeneration uint64 `json:"expected_generation"`
	RequestKey         string `json:"request_key"`
	DryRun             bool   `json:"dry_run"`
}

func (MaintenanceEnsureRequest) Type added in v0.139.4

func (MaintenanceEnsureRequest) Validate added in v0.139.4

func (r MaintenanceEnsureRequest) Validate() error

type MaintenanceIdentity added in v0.139.4

type MaintenanceIdentity struct {
	Dataset    DatasetRef `json:"dataset"`
	Generation uint64     `json:"generation,omitempty"`
	Anchor     string     `json:"anchor"`
	Timezone   string     `json:"timezone"`
	PreparedAt string     `json:"prepared_at,omitempty"`
}

MaintenanceIdentity describes a verified time-bound dataset. Anchor and timezone are optional provider-owned coverage metadata, never platform clocks.

type MaintenanceLifecycle added in v0.139.4

type MaintenanceLifecycle interface {
	Run(context.Context, Kind, Input) (Result, error)
	Recover(context.Context, string) (Result, error)
}

type MaintenanceObservation added in v0.139.4

type MaintenanceObservation struct{ Fresh, Changed bool }

type MaintenanceProfile added in v0.139.4

type MaintenanceProfile struct {
	Digest    string
	Principal string
	// ReplaceDrift requires host-enforced immutable automatic data. Manual
	// activation generation changes pause regardless of this capability.
	ReplaceDrift bool
}

type MaintenanceRecord added in v0.139.4

type MaintenanceRecord struct {
	Revision                          uint64
	Enabled                           bool
	Owner, Principal, RecipeDigest    string
	Generation                        uint64
	Active                            *MaintenanceIdentity
	Due, ExpiresAt                    time.Time
	State, Reason, Epoch, EpochPrefix string
	Input                             Input
	Step                              Kind
	OperationID                       string
	Attempts                          int
	FailureWindow                     time.Time
	Failures                          int
	OriginActor, TriggerKey           string
}

MaintenanceRecord stores policy and resumable references; it grants no lifecycle lease or activation authority. Keep storage encoding host-owned.

type MaintenanceResult added in v0.139.4

type MaintenanceResult struct {
	Record MaintenanceRecord `json:"maintenance"`
	Target TargetState       `json:"target"`
	DryRun bool              `json:"dry_run"`
}

func (MaintenanceResult) CommandResultMetadata added in v0.139.4

func (r MaintenanceResult) CommandResultMetadata() map[string]any

func (MaintenanceResult) MarshalJSON added in v0.139.4

func (r MaintenanceResult) MarshalJSON() ([]byte, error)

MarshalJSON exposes maintenance readiness without coordinator inputs, requesting/delegated principals, policy hashes, epoch keys or pending intents. The in-process result retains references for trusted host adapters; persistence encodes MaintenanceRecord directly and therefore keeps recovery evidence.

type MaintenanceService added in v0.139.4

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

func NewMaintenanceService added in v0.139.4

func NewMaintenanceService(backend MaintenanceBackend, lifecycle MaintenanceLifecycle, now func() time.Time) (*MaintenanceService, error)

func (*MaintenanceService) Authorize added in v0.139.4

func (s *MaintenanceService) Authorize(ctx context.Context, manage bool) error

func (*MaintenanceService) Configure added in v0.139.4

func (*MaintenanceService) Ensure added in v0.139.4

func (*MaintenanceService) FreshForServing added in v0.139.4

func (s *MaintenanceService) FreshForServing(ctx context.Context, generation uint64) (bool, error)

FreshForServing is a read-only admission check. Hosts hold their delivery/ handover gate around it and serving. Retained artifacts must use their own authority; a manual activation is independent of automatic maintenance.

func (*MaintenanceService) NextRequest added in v0.139.4

func (*MaintenanceService) Status added in v0.139.4

type MaintenanceStatusHandler added in v0.139.4

type MaintenanceStatusHandler struct{ Service *MaintenanceService }

func (*MaintenanceStatusHandler) Execute added in v0.139.4

func (*MaintenanceStatusHandler) Query added in v0.139.4

type MaintenanceStatusQuery added in v0.139.4

type MaintenanceStatusQuery struct{}

func (MaintenanceStatusQuery) Type added in v0.139.4

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 Message added in v0.139.0

type Message interface {
	Type() string
	Validate() error
	OperationKind() Kind
	OperationInput() Input
}

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 OpenApplicationPreviewCommand added in v0.139.3

type OpenApplicationPreviewCommand = OpenApplicationPreviewInput

type OpenApplicationPreviewInput added in v0.139.3

type OpenApplicationPreviewInput struct {
	Selection ExploreSelection `json:"selection"`
	SurfaceID string           `json:"surface_id"`
	RequestID string           `json:"request_id"`
}

func (OpenApplicationPreviewInput) Type added in v0.139.3

func (OpenApplicationPreviewInput) Validate added in v0.139.3

func (q OpenApplicationPreviewInput) Validate() error

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)
	// LookupRequest returns found=true for a live claim, including a tombstone
	// whose operation was pruned (CodeGone). An expired/absent claim is not found.
	LookupRequest(context.Context, RequestKey) (Operation, bool, 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)
	ListReceipts(context.Context, TargetKey, ReceiptQuery) (ReceiptPage, 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 {
	// Return CodeDenied (or a legacy untyped denial) for denied access.
	// Backend failures must use CodeProvider/CodeUnavailable; cancellation uses
	// standard context causes. These fail closed without declaring grant loss.
	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 PreviewCapabilitiesQuery added in v0.139.3

type PreviewCapabilitiesQuery struct {
	Selection ExploreSelection `json:"selection"`
}

func (PreviewCapabilitiesQuery) Type added in v0.139.3

func (PreviewCapabilitiesQuery) Validate added in v0.139.3

func (q PreviewCapabilitiesQuery) Validate() error

type PreviewCapability added in v0.139.3

type PreviewCapability struct {
	Supported  bool              `json:"supported"`
	Reason     string            `json:"reason,omitempty"`
	Surfaces   []PreviewSurface  `json:"surfaces"`
	Guarantees PreviewGuarantees `json:"guarantees"`
	// contains filtered or unexported fields
}

type PreviewGuarantees added in v0.139.3

type PreviewGuarantees struct {
	Durable   bool `json:"durable"`
	Isolation bool `json:"isolation"`
	ReadOnly  bool `json:"read_only"`
	Retention bool `json:"retention"`
	Cleanup   bool `json:"cleanup"`
}

Every guarantee must be proven by the host before Enabled is set. Durable includes atomic request fingerprints, quotas, retention and restart recovery.

func (PreviewGuarantees) Safe added in v0.139.3

func (g PreviewGuarantees) Safe() bool

type PreviewReadContext added in v0.139.3

type PreviewReadContext struct {
	Session   ApplicationPreviewSession
	Principal Principal
	Read      ExploreRead
}

PreviewReadContext is obtained only through the service, after full current authorization. Application queries must require it and never select a default production route. Pass the original session to ValidatePreviewDelivery after query/render work. Each navigation/API read reauthorizes independently.

func ApplicationPreviewFromContext added in v0.139.3

func ApplicationPreviewFromContext(ctx context.Context) (PreviewReadContext, error)

func (PreviewReadContext) CacheKey added in v0.139.3

func (r PreviewReadContext) CacheKey() string

type PreviewRecord added in v0.139.3

type PreviewRecord struct {
	Session                      ApplicationPreviewSession
	Principal                    Principal
	ApplicationID, EnvironmentID string
	RequestID, Fingerprint       string
	Receipt                      PreparationReceipt
	// Original monotonic domain/host policy observations survive restart and
	// revoke/restore. They are authority metadata, never browser credentials.
	AuthorizationRevisions []string
}

PreviewRecord is server-only authority. Never serialize it to a browser.

func (PreviewRecord) Authorizes added in v0.139.3

func (r PreviewRecord) Authorizes(p Principal) bool

Execution and correlation IDs describe a request, not a session owner.

type PreviewSurface added in v0.139.3

type PreviewSurface struct {
	// Required domain/field grants stay server-side; these are not wire input.
	EntityID string   `json:"-"`
	Fields   []string `json:"-"`
	ID       string   `json:"id"`
	Label    string   `json:"label"`
	Kind     string   `json:"kind"`
}

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.

func (Principal) Valid added in v0.139.0

func (p Principal) Valid() bool

type Progress added in v0.139.0

type Progress struct {
	Stage     string `json:"stage"`
	Completed uint64 `json:"completed"`
	Total     uint64 `json:"total"`
}

type Provider added in v0.139.0

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 ReceiptPage added in v0.139.1

type ReceiptPage struct {
	Receipts   []PreparationReceipt `json:"receipts"`
	NextCursor string               `json:"next_cursor,omitempty"`
}

type ReceiptQuery added in v0.139.1

type ReceiptQuery struct {
	Limit  int
	Cursor string
}

ReceiptQuery pages authoritative receipts independently of operation history. Cursor is store-owned and opaque to callers; a page contains at most 100 rows.

type RecoverRequest added in v0.139.1

type RecoverRequest struct {
	TargetID    string `json:"target_id"`
	OperationID string `json:"operation_id"`
}

RecoverRequest references durable work and has no new-work request key or editable provider inputs. Recovery is authorized and audited as a supervisor.

func (RecoverRequest) OperationInput added in v0.139.1

func (m RecoverRequest) OperationInput() Input

func (RecoverRequest) OperationKind added in v0.139.1

func (RecoverRequest) OperationKind() Kind

func (RecoverRequest) Type added in v0.139.1

func (RecoverRequest) Type() string

func (RecoverRequest) Validate added in v0.139.1

func (m RecoverRequest) Validate() error

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 RequestKey added in v0.139.1

type RequestKey struct {
	ActorID        string
	Target         TargetKey
	Kind           Kind
	IdempotencyKey string
}

RequestKey identifies the durable request claim without disclosing another actor's work. Lookup is read-only; Claim still decides replay atomically.

type RequestState added in v0.139.2

type RequestState string

RequestState is what the durable store knows about one of the current actor's own requests (ADR-0003 reconciliation).

const (
	// RequestClaimed: the request was received; Operation describes it.
	RequestClaimed RequestState = "claimed"
	// RequestUnclaimed: no claim exists although the request's retry window is
	// still open, so resubmitting the unchanged request cannot duplicate work.
	RequestUnclaimed RequestState = "unclaimed"
	// RequestExpired: the claim is no longer retained, or the window cannot be
	// established; only explicit new work may follow.
	RequestExpired RequestState = "expired"
)

type RequestStatus added in v0.139.2

type RequestStatus struct {
	State      RequestState
	Operation  *Operation
	RetryUntil time.Time
}

RequestStatus never carries the stored key, fingerprint or principal to the caller's presentation; Operation is for server-side projection only.

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

func (r Result) CommandResultFailure() error

type RetryDescriptor added in v0.139.2

type RetryDescriptor struct {
	OperationID        string
	Kind               Kind
	State              State
	Input              Input
	ObservedGeneration *uint64
	FailureCode        string
}

RetryDescriptor is the safe retained input for explicitly starting new work after a terminal failed or canceled operation (Try again). It omits the original request key, fingerprint, principal, stage and credentials; the expected generation of activate/reset is cleared so it is re-observed before confirmation, while ObservedGeneration reports the original one.

type SamplePeriod added in v0.139.0

type SamplePeriod struct {
	LocalDay    string `json:"local_day"`
	Timezone    string `json:"timezone"`
	EvidenceRef string `json:"evidence_ref"`
}

type ScenarioPresentation added in v0.139.4

type ScenarioPresentation struct {
	Title   string `json:"title,omitempty"`
	Summary string `json:"summary,omitempty"`
}

ScenarioPresentation is the human title and summary of one scenario ID.

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 SelectionComparison added in v0.139.3

type SelectionComparison struct {
	Left              ExploreInsights           `json:"left"`
	Right             ExploreInsights           `json:"right"`
	ComparisonID      string                    `json:"comparison_id"`
	ObservedAt        time.Time                 `json:"observed_at"`
	Metrics           []InsightMetricComparison `json:"metrics"`
	LeftDeclarations  InsightDeclarations       `json:"left_declarations"`
	RightDeclarations InsightDeclarations       `json:"right_declarations"`
}

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) Active added in v0.139.0

func (s *Service) Active(ctx context.Context, targetID string) (ActiveState, error)

func (*Service) ApplicationPreviewRead added in v0.139.3

func (s *Service) ApplicationPreviewRead(ctx context.Context, q ApplicationPreviewSessionQuery, surface string) (PreviewReadContext, error)

func (*Service) ApplicationPreviewSession added in v0.139.3

func (s *Service) ApplicationPreviewSession(ctx context.Context, q ApplicationPreviewSessionQuery) (ApplicationPreviewSession, error)

func (*Service) AuthorizeAction added in v0.139.1

func (s *Service) AuthorizeAction(ctx context.Context, kind Kind, targetID string) error

AuthorizeAction rechecks current target grants without loading lifecycle records. It filters already declared controls; AuthorizeInput and Run still enforce ownership, selected input and capabilities before dispatch/effects.

func (*Service) AuthorizeExploration added in v0.139.3

func (s *Service) AuthorizeExploration(ctx context.Context, a ExploreAccess, additional ...ExploreAccess) error

AuthorizeExploration rechecks a loaded result after transport/host policy work. The host constructs a bounded grant group from the typed result, never from untrusted principal, receipt or physical routing metadata. All grants must select the same read. Related grants always include separate source checks.

func (*Service) AuthorizeInput added in v0.139.0

func (s *Service) AuthorizeInput(ctx context.Context, kind Kind, input Input) error

AuthorizeInput performs no effects. Named factories use it before dispatch; typed handlers still enforce policy again at the service boundary.

func (*Service) AuthorizeInsights added in v0.139.3

func (s *Service) AuthorizeInsights(ctx context.Context, results []ExploreInsights, declarations ...ExploreAccess) error

AuthorizeInsights checks the whole group's current metric/declaration grants after host work and validates the original read's source and policy fence. Transports pass their final host check to ValidateInsightsDelivery for sealing.

func (*Service) AuthorizeProjection added in v0.139.2

func (s *Service) AuthorizeProjection(ctx context.Context, a AccessRequest) error

AuthorizeProjection checks current policy for previously loaded display data. It avoids repository reads, validates scope/target binding, and never grants authority to execute Input. Factories, Run and artifact lookups still load and authorize their exact authoritative records at their existing boundaries.

func (*Service) AuthorizeView added in v0.139.1

func (s *Service) AuthorizeView(ctx context.Context, targetID string) error

AuthorizeView rechecks current target read grants without loading lifecycle state. It is suitable for delivery of projections already loaded by the service.

func (*Service) Catalog added in v0.139.0

func (s *Service) Catalog(ctx context.Context, targetID string, limit int) ([]Descriptor, error)

func (*Service) CloseApplicationPreview added in v0.139.3

func (*Service) CompareSelections added in v0.139.3

func (s *Service) CompareSelections(ctx context.Context, q CompareSelectionsQuery) (SelectionComparison, error)

func (*Service) Describe added in v0.139.0

func (s *Service) Describe(ctx context.Context, ref DatasetRef, targetID string) (Descriptor, error)

func (*Service) DiscardPreviewLaunch added in v0.139.3

func (s *Service) DiscardPreviewLaunch(ctx context.Context, out ApplicationPreviewSession) error

DiscardPreviewLaunch rolls back a launch that its transport could not deliver. Replayed sessions and ordinary read/query results never own that allocation.

func (*Service) ExploreInsights added in v0.139.3

func (s *Service) ExploreInsights(ctx context.Context, q ExploreInsightsQuery) (ExploreInsights, error)

func (*Service) ExploreMetadata added in v0.139.3

func (s *Service) ExploreMetadata(ctx context.Context, q ExploreMetadataQuery) (ExploreMetadata, error)

func (*Service) ExploreRelated added in v0.139.3

func (s *Service) ExploreRelated(ctx context.Context, q ExploreRelatedQuery) (ExploreSamples, error)

func (*Service) ExploreSamples added in v0.139.3

func (s *Service) ExploreSamples(ctx context.Context, q ExploreSamplesQuery) (ExploreSamples, error)

func (*Service) LookupArtifact added in v0.139.0

func (s *Service) LookupArtifact(ctx context.Context, providerID, artifactID string) (any, error)

func (*Service) LookupOperation added in v0.139.0

func (s *Service) LookupOperation(ctx context.Context, id string) (Operation, error)

func (*Service) LookupReceipt added in v0.139.1

func (s *Service) LookupReceipt(ctx context.Context, targetID, id string) (PreparationReceipt, error)

LookupReceipt reads the current authoritative receipt, including its latest verification, rather than an immutable historical operation result.

func (*Service) OpenApplicationPreview added in v0.139.3

func (*Service) Operations added in v0.139.0

func (s *Service) Operations(ctx context.Context, targetID string, limit int) ([]Operation, error)

func (*Service) PreviewCapabilities added in v0.139.3

func (s *Service) PreviewCapabilities(ctx context.Context, q PreviewCapabilitiesQuery) (PreviewCapability, error)

func (*Service) Receipts added in v0.139.1

func (s *Service) Receipts(ctx context.Context, targetID string, query ReceiptQuery) (ReceiptPage, error)

Receipts exposes bounded, current-policy pages independent of operation history. Filtering does not alter the store cursor; denied rows stay omitted.

func (*Service) Recover added in v0.139.0

func (s *Service) Recover(ctx context.Context, operationID string) (Result, error)

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.

func (*Service) RequestStatus added in v0.139.2

func (s *Service) RequestStatus(ctx context.Context, kind Kind, targetID, key string, submittedAt time.Time) (RequestStatus, error)

RequestStatus looks up the current actor's own request for kind, target and request key without claiming anything. The actor and scope come from trusted context; submittedAt is the client's own record of its first submission and only bounds when a missing claim may be reported unclaimed.

func (*Service) ResolveRequestGeneration added in v0.139.1

func (s *Service) ResolveRequestGeneration(ctx context.Context, kind Kind, input Input) (Input, error)

ResolveRequestGeneration binds an adapter's generation precondition to the first durable request using the same actor/target/command/key. A refreshed form may observe a newer generation, but a retry must preserve the original one. All other inputs must match. New requests retain their submitted generation; Run's atomic claim and generation CAS remain the final authority. Direct typed Run callers keep strict fingerprint semantics.

func (*Service) RetryDescriptor added in v0.139.2

func (s *Service) RetryDescriptor(ctx context.Context, operationID string) (RetryDescriptor, error)

RetryDescriptor loads the exact retained input of the current actor's own terminal failed/canceled operation under current scope, target, read and execute policy. It never substitutes a newer catalog entry or receipt: missing or changed inputs, receipts and capabilities report unavailable. Starting the new work still goes through the ordinary typed commands.

func (*Service) Run added in v0.139.0

func (s *Service) Run(ctx context.Context, kind Kind, input Input) (Result, error)

Run executes bounded work inline. Transport acceptance is distinct from Result: only the latter reports preparation/verification/activation. Queued transports dispatch these same messages; they must propagate a trusted bounded principal.

func (*Service) ValidateInsightsDelivery added in v0.139.3

func (s *Service) ValidateInsightsDelivery(ctx context.Context, results []ExploreInsights, finalCheck ...InsightDeliveryCheck) error

ValidateInsightsDelivery checks the original observations, then runs an optional final host/session check, then seals the whole group's source pins and policy revisions. Transports must put their LAST host check here: no policy, provider or host callbacks may run after this returns and before writing the result. Only results loaded by this Service may disclose aggregates; JSON cannot mint a fence. The supplied check must retain the request's cancellation/deadline.

func (*Service) ValidatePreviewCapabilitiesDelivery added in v0.139.3

func (s *Service) ValidatePreviewCapabilitiesDelivery(ctx context.Context, out PreviewCapability, finalCheck ...InsightDeliveryCheck) error

Capability discovery is also fenced through the transport's final host check.

func (*Service) ValidatePreviewDelivery added in v0.139.3

func (s *Service) ValidatePreviewDelivery(ctx context.Context, out ApplicationPreviewSession, finalCheck ...InsightDeliveryCheck) (err error)

Custom transports must run their LAST current host check in finalCheck. The private original fence prevents JSON, forged selections and late revocation from manufacturing authority after application query/render work.

func (*Service) ValidatePreviewHost added in v0.139.3

func (s *Service) ValidatePreviewHost(ctx context.Context, application, environment, actor, scope string) error

func (*Service) WithApplicationPreview added in v0.139.3

func (s *Service) WithApplicationPreview(ctx context.Context, q ApplicationPreviewSessionQuery, surface string) (context.Context, PreviewReadContext, error)

type ServiceConfig added in v0.139.0

type ServiceConfig struct {
	Preview         ApplicationPreviewConfig
	ExploreSurfaces map[string]ExploreSurface
	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.
	// Current principal hashes must cover every mutable host policy decision.
	// Policies with independent mutable grants/filters must also implement
	// InsightAuthorizationRevision before offering coherent aggregate reads.
	// Use CodeProvider/CodeUnavailable for backend outages, standard context
	// causes for cancellation, and CodeDenied (or a legacy untyped denial) for
	// invalid/revoked identities.
	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
	// RetryWindow is the host-declared replay window of request claims; it must
	// match the operation store's retention (1 hour–90 days). Zero leaves it
	// undeclared, so request reconciliation never reports a missing claim as
	// safely resubmittable.
	RetryWindow time.Duration
}

type State added in v0.139.0

type State string
const (
	Queued    State = "queued"
	Running   State = "running"
	Succeeded State = "succeeded"
	Failed    State = "failed"
	Canceled  State = "canceled"
)

func (State) Terminal added in v0.139.0

func (s State) Terminal() 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 TargetCapabilities struct {
	Recovery     bool
	Fencing      bool
	SafeReset    bool
	Cancellation bool
}

type TargetKey added in v0.139.0

type TargetKey struct {
	ScopeKey string `json:"scope_key"`
	TargetID string `json:"target_id"`
}

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.

Directories

Path Synopsis
examples
datamodule
Package datamodule is the kitchen sink's synthetic dataset provider and managed target.
Package datamodule is the kitchen sink's synthetic dataset provider and managed target.
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.

Jump to

Keyboard shortcuts

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