contract

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package contract defines the provider-neutral, versioned messaging contracts for the Kigae Engine execution fabric.

These types are the frozen wire-level contracts from KORA-ENGINE-RFC.md §7 (provider contracts), §7.1 (command and query protocol), §7.3 (identity and delegation), and §8 (durable delivery). They are deliberately independent of any concrete provider (LocalProvider or NATSProvider) and of the analytics, orm, and webhook packages so that every adapter (HTTP, chat, channel, MCP, SDK, UI, NATS) can project from a single canonical source.

Once a contract version is frozen, its JSON shape must not change in a breaking way. Additive changes bump the version field on the envelope and are accompanied by a contract version test in contract_test.go.

Package contract - desired-state and reconciliation wire models (RECON-002).

Cloud and runtime exchange desired state as typed records. These are the authoritative shapes for configuration intent; JSON and NATS are transport only, and reconciliation code should avoid ad hoc maps.

Package contract — capability handle contract (PLUGIN-001).

Components never construct providers directly; they request capabilities and receive handles. The issuer grants only what the component's manifest declared (deny-by-default), scoped to component, operation, or call. A handle carries an owner, a scope, and cleanup evidence so every effect is attributable and releasable (invariant 6/7).

Package contract — provider-neutral authentication and identity contracts (AUTH-001).

These typed contracts are the foundation the auth epic builds on: every sign-in provider implements AuthProvider, every flow returns a single IdentityAssertion, and every adapter (HTTP, channel, AI, MCP, SDK) consumes that assertion to resolve a principal. Nothing here leaks provider secrets; secret values are referenced by opaque identifiers that resolve through the secret store.

Package contract — observed-state and reconciliation wire models (RECON-001).

Runtimes report authenticated observed state while Cloud sends signed desired generations. These typed models are the authoritative interchange: JSON and NATS are transport only, and no map[string]any crosses a package boundary.

Package contract — resource identity and registry contracts (GRAPH-001).

These types give every engine resource a namespaced, versioned identity (architecture specification invariant 5) and an explainable dependency shape. They are framework-neutral and provider-neutral: the operation kernel, component runtime, reconciliation loop, and UI manifest serving all address a resource through ResourceRef, never through an ad-hoc doctype name + map.

Package contract — semantic UI manifest schema (UI-001).

The server describes *what* a screen means (pages, regions, blocks, actions, states); any ES-module renderer decides *how* to draw it. This schema is framework-neutral by construction: no React/Vue/Svelte/DOM identifier appears in it. Manifests are inert data — actions reference kernel command names, never HTTP paths or JavaScript handlers.

Index

Constants

View Source
const (
	CloudMembershipRoleOwner = "owner"
	CloudOwnerEngineRole     = "Administrator"
)

Cloud membership and Engine tenant roles are separate authority domains. At signup, a Cloud organization owner receives the Engine tenant Administrator role. Engine enforces that role within the routed tenant; Cloud retains organization membership and billing authority.

View Source
const (
	ModulePrivate    ModuleAccess    = "private"
	ModulePublished  ModuleAccess    = "published"
	MutationCRUD     MutationMode    = "crud"
	MutationCommands MutationMode    = "commands_only"
	EffectQuery      OperationEffect = "query"
	EffectLocal      OperationEffect = "local_command"
	EffectExternal   OperationEffect = "external_command"
)
View Source
const CurrentVersion = 1

CurrentVersion is the single frozen contract schema version emitted by this package. Envelope implementations set their Version from this value.

View Source
const ErrLayoutInvalid = "catalog.layout_invalid"

ErrLayoutInvalid is the stable code for rejected layout hints.

View Source
const MaxEventCausationDepth uint16 = 32
View Source
const MaxTenantDisplayNameLength = 120

MaxTenantDisplayNameLength caps ProvisionTenant.DisplayName in Unicode characters after trimming.

View Source
const SiteDirectoryVersion = 1

SiteDirectoryVersion is the current provider-neutral site directory wire contract. Breaking changes require a new versioned contract.

Variables

View Source
var (
	ErrOrderViolation   = errors.New("contract: per-key ordering violated")
	ErrDuplicateReceipt = errors.New("contract: duplicate delivery receipt")
)

Typed durable-delivery sentinels (DURABLE-001). Callers match via errors.Is, never string matching.

View Source
var (
	ErrResourceNamespaceRequired = NewError(CodeValidationFailed, "resource namespace is required")
	ErrResourceNameRequired      = NewError(CodeValidationFailed, "resource name is required")
	ErrResourceNotFound          = NewError(CodeNotFound, "resource not found")
	ErrResourceVersionConflict   = NewError(CodeConflict, "resource version already registered")
	ErrResourceKindUnknown       = NewError(CodeValidationFailed, "unknown resource kind")
)

Resource registry sentinel errors. These are stable, typed values; callers must match on them (or errors.Is) rather than string-matching messages.

View Source
var ErrCausationCycle = errors.New("offline command batch contains a causation cycle")

ErrCausationCycle is returned when a command batch contains a causation cycle, which cannot be ordered deterministically.

View Source
var ErrInvalidOfflineIntent = errors.New("offline intent is invalid")

Functions

func AcceptsOfflineSchema

func AcceptsOfflineSchema(gate OfflineSchemaGate) bool

AcceptsOfflineSchema reports whether the server should accept a bundle.

func AppendBusinessEvent added in v1.0.0

func AppendBusinessEvent(ctx context.Context, writer interface {
	Append(context.Context, *sql.Tx, EventEnvelope) error
}, tx *sql.Tx, schemas interface {
	Registered(SchemaRef) bool
	Validate(SchemaRef, json.RawMessage) error
}, execution ModuleExecution, definition BusinessEventDefinition, payloadSchema SchemaRef, payload json.RawMessage, site, aggregateType, aggregateID, correlationID, causationID string) (string, error)

func CanonicalManifestJSON added in v1.0.0

func CanonicalManifestJSON(manifest any) ([]byte, error)

CanonicalManifestJSON emits RFC 8785 compatible JSON for the v1 marketplace manifest shape. V1 numeric fields are integers in the interoperable range.

func ConflictResolutionRetryable

func ConflictResolutionRetryable(mode string) bool

ConflictResolutionRetryable reports whether a rejected operation should stay available for another sync attempt or manual resolution.

func DuplicateAck

func DuplicateAck(previous, next SyncCursor) bool

DuplicateAck reports whether a cursor acknowledgement is a repeat of a previously acknowledged version.

func EncodeData

func EncodeData(v any) (json.RawMessage, error)

EncodeData marshals a value into the json.RawMessage field of an envelope.

func EngineVersionAtLeast added in v1.0.0

func EngineVersionAtLeast(running, required string) (bool, error)

EngineVersionAtLeast reports running >= required using semver 2.0.0 section 11 precedence. An optional leading "v" and "+build" metadata are accepted; build metadata is ignored in comparison.

func ManifestDigest added in v1.0.0

func ManifestDigest(canonical []byte) string

ManifestDigest returns SHA-256 over canonical manifest bytes.

func MustEncodeData

func MustEncodeData(v any) json.RawMessage

MustEncodeData marshals a value into json.RawMessage, panicking on error. Use only for values known to be JSON-encodable.

func NewCommandID

func NewCommandID() string

NewCommandID returns a ULID suitable for a CommandEnvelope.ID.

func NewCorrelationID

func NewCorrelationID() string

NewCorrelationID returns a ULID suitable for a correlation trace.

func NewEventID

func NewEventID() string

NewEventID returns a ULID suitable for an EventEnvelope.ID.

func NewID

func NewID() string

NewID returns a ULID string for envelopes, outbox rows, and receipts.

func NewIDAt

func NewIDAt(t time.Time) string

NewIDAt returns a ULID string for the given monotonic time.

func NewOperationID

func NewOperationID() string

NewOperationID returns a ULID suitable for CommandResult.OperationID and TaskReceipt.OperationID.

func NormalizeTenantDisplayName added in v1.0.0

func NormalizeTenantDisplayName(value string) (string, error)

NormalizeTenantDisplayName trims surrounding whitespace and validates a provisioning display name. An empty input means "not supplied" and returns an empty name; a value that is only whitespace is rejected.

func OfflineQueryFactKey added in v1.0.0

func OfflineQueryFactKey(fields map[string]json.RawMessage, field string) (string, error)

OfflineQueryFactKey returns the canonical scalar identity declared by an offline-eligible query. It is shared by snapshot and replay validators.

func OperationCanTransition

func OperationCanTransition(from, to OfflineOperationStatus) bool

OperationCanTransition reports whether an offline operation can move to the next local lifecycle state without losing audit visibility.

func PackDigest added in v1.0.0

func PackDigest(canonicalManifest []byte, files []PackFile) (string, error)

PackDigest computes the kora-pack-v1 digest over canonical manifest bytes and sorted, length-prefixed files. It enforces transport-level path, file type, and byte limits; Engine remains responsible for parsing file content.

func PackFileComponent added in v1.0.0

func PackFileComponent(filePath string) string

PackFileComponent returns the component namespace (16 lowercase hex chars) of a "components/<ns>/..." or "<dir>/components/<ns>/..." path, or "" for root files.

func PackageFileType added in v1.0.0

func PackageFileType(filePath string) (string, bool)

PackageFileType infers the content type of a package file from its path.

func ParsePackDigest added in v1.0.0

func ParsePackDigest(value string) error

ParsePackDigest verifies the stored lowercase digest shape.

func PublishedOperationRef added in v1.0.0

func PublishedOperationRef(owner ModuleID, capability CapabilityName, operation string) string

func RetainConflict

func RetainConflict(conflict OfflineConflict) bool

RetainConflict reports whether a rejected operation should remain visible to operators or the retry loop.

func SkippedSchemaVersion

func SkippedSchemaVersion(client, current string, accepted []string) bool

SkippedSchemaVersion reports whether the client jumped over a required intermediate schema version.

func StaleWrite

func StaleWrite(baseVersion, serverVersion int) bool

StaleWrite reports whether the incoming offline write is based on an older version than the server currently accepts.

func TombstoneRetained

func TombstoneRetained(t OfflineTombstone, now time.Time) bool

TombstoneRetained reports whether the tombstone still falls within the supported offline retention window.

func ValidPackageFileType added in v1.0.0

func ValidPackageFileType(filePath, contentType string) bool

ValidPackageFileType reports whether contentType is allowed at filePath.

func ValidateApplyModuleChange added in v1.0.0

func ValidateApplyModuleChange(cmd ApplyModuleChange) error

func ValidateApplyPackage added in v1.0.0

func ValidateApplyPackage(cmd ApplyPackage) error

func ValidateAssignee added in v1.0.0

func ValidateAssignee(assignee Assignee) error

func ValidateBusinessEvent added in v1.0.0

func ValidateBusinessEvent(definition BusinessEventDefinition, owner ModuleID, schema SchemaRef, eventType string) error

func ValidateCancelRequest added in v1.0.0

func ValidateCancelRequest(cmd CancelRequest) error

func ValidateConfigurationSurfaceBindings added in v1.0.0

func ValidateConfigurationSurfaceBindings(bindings []ConfigurationSurfaceBinding) error

func ValidateConsumerDefinition added in v1.0.0

func ValidateConsumerDefinition(consumer ConsumerDefinition, owner ModuleID, events map[string]BusinessEventDefinition) error

ValidateConsumerDefinition binds every accepted payload schema to a known event contract and an explicit consumer owner.

func ValidateCronSchedule added in v1.0.0

func ValidateCronSchedule(expression string) error

ValidateCronSchedule checks the supported five-field cron subset.

func ValidateDeleteTenant added in v1.0.0

func ValidateDeleteTenant(cmd DeleteTenant) error

func ValidateGrantTenantMember added in v1.0.0

func ValidateGrantTenantMember(cmd GrantTenantMember) error

func ValidateHistoricalSnapshot added in v1.0.0

func ValidateHistoricalSnapshot(snapshot HistoricalSnapshot, validate func(SchemaRef, json.RawMessage) error) error

ValidateHistoricalSnapshot checks the captured payload against its stored schema without resolving the source provider.

func ValidateInstalledPackages added in v1.0.0

func ValidateInstalledPackages(packages []InstalledPackage) error

ValidateInstalledPackages enforces immutable package requirements and conflicts across the complete candidate installation set.

func ValidateManagedOperation added in v1.0.0

func ValidateManagedOperation(value ManagedOperation) error

func ValidateManagementCapabilitiesV2 added in v1.0.0

func ValidateManagementCapabilitiesV2(value ManagementCapabilitiesV2) error

func ValidateManifestPackRefs added in v1.0.0

func ValidateManifestPackRefs(requires, conflicts []ManifestPackRef) error

ValidateManifestPackRefs validates pinned package requirements and declared package/release conflicts before a composition can reach activation.

func ValidateModuleChangePlan added in v1.0.0

func ValidateModuleChangePlan(plan ModuleChangePlan, expectedRevision uint64, openWork []ModuleBlocker) error

func ValidateModuleExtensions added in v1.0.0

func ValidateModuleExtensions(modules []ModuleDescriptor, registered func(SchemaRef) bool) error

func ValidateModuleLifecycleTransition added in v1.0.0

func ValidateModuleLifecycleTransition(from, to ModuleLifecycleState) error

func ValidateModuleSet added in v1.0.0

func ValidateModuleSet(modules []ModuleDescriptor, registered func(SchemaRef) bool) error

ValidateModuleSet rejects ambiguous ownership and returns deterministic errors.

func ValidatePageRequest added in v1.0.0

func ValidatePageRequest(page PageRequest) error

func ValidatePlanModuleChange added in v1.0.0

func ValidatePlanModuleChange(request PlanModuleChange) error

func ValidatePlanTenantMember added in v1.0.0

func ValidatePlanTenantMember(cmd PlanTenantMember) error

func ValidateProvisionTenant added in v1.0.0

func ValidateProvisionTenant(cmd ProvisionTenant) error

ValidateProvisionTenant enforces bounded, opaque allocation references and DNS aliases. It intentionally cannot express a DSN, filesystem path, or URL.

func ValidateReassignRequest added in v1.0.0

func ValidateReassignRequest(cmd ReassignRequest) error

func ValidateReconcileTenantDeleteOperation added in v1.0.0

func ValidateReconcileTenantDeleteOperation(cmd ReconcileTenantDeleteOperation) error

func ValidateReconcileTenantInvitationOperation added in v1.0.0

func ValidateReconcileTenantInvitationOperation(cmd ReconcileTenantInvitationOperation) error

func ValidateReconcileTenantPackageOperation added in v1.0.0

func ValidateReconcileTenantPackageOperation(cmd ReconcileTenantPackageOperation) error

func ValidateReconcileTenantProvisionOperation added in v1.0.0

func ValidateReconcileTenantProvisionOperation(cmd ReconcileTenantProvisionOperation) error

func ValidateReconcileTenantStateOperation added in v1.0.0

func ValidateReconcileTenantStateOperation(cmd ReconcileTenantStateOperation) error

func ValidateRequestTenantInvitation added in v1.0.0

func ValidateRequestTenantInvitation(cmd RequestTenantInvitation) error

func ValidateResourceBusinessScope added in v1.0.0

func ValidateResourceBusinessScope(scope BusinessScope, resourcePolicy ResourceScopeKind) error

func ValidateRespondRequest added in v1.0.0

func ValidateRespondRequest(cmd RespondRequest) error

ValidateRespondRequest checks the request body bounds before authorization and transactional response checks are performed by the request service.

func ValidateRevokeManagedChannelClientV2 added in v1.0.0

func ValidateRevokeManagedChannelClientV2(value RevokeManagedChannelClientV2) error

func ValidateRevokeTenantMember added in v1.0.0

func ValidateRevokeTenantMember(cmd RevokeTenantMember) error

func ValidateScheduledJobDefinitions added in v1.0.0

func ValidateScheduledJobDefinitions(jobs []ScheduledJobDefinition) error

ValidateScheduledJobDefinitions checks the scheduler contract shared by Cloud and Engine. Job execution remains application-owned.

func ValidateScheduledJobModuleOwners added in v1.0.0

func ValidateScheduledJobModuleOwners(jobs []ScheduledJobDefinition, modules []ModuleDescriptor) error

func ValidateSetTenantState added in v1.0.0

func ValidateSetTenantState(cmd SetTenantState) error

func ValidateSiteDirectoryEntryV2 added in v1.0.0

func ValidateSiteDirectoryEntryV2(value SiteDirectoryEntryV2) error

ValidateSiteDirectoryEntryV2 checks the safe, versioned routing projection. It intentionally does not interpret aliases as authorization grants.

func ValidateSubmitRequest added in v1.0.0

func ValidateSubmitRequest(cmd SubmitRequest) error

ValidateSubmitRequest checks transport-independent wire constraints. It does not establish tenant membership, policy eligibility, or subject visibility; those checks belong to the request service at commit time.

func ValidateTenantAlias added in v1.0.0

func ValidateTenantAlias(alias string) error

ValidateTenantAlias checks one canonical DNS alias used for management lookups. Callers may normalize case and a terminal dot before validation.

func ValidateTenantDescriptorV2 added in v1.0.0

func ValidateTenantDescriptorV2(value TenantDescriptorV2) error

func ValidateTenantMemberPlan added in v1.0.0

func ValidateTenantMemberPlan(value TenantMemberPlan) error

Types

type ActionRef

type ActionRef struct {
	Label          string `json:"label"`
	Command        string `json:"command"`
	IdempotencyKey bool   `json:"idempotency_key"`
	Requires       string `json:"requires,omitempty"`
}

ActionRef references a kernel command to invoke. IdempotencyKey marks the action as eligible for optimistic UI; Requires is the capability scope the action needs.

type ActionSpec added in v1.0.0

type ActionSpec struct {
	Name        string `json:"name"`
	Version     uint32 `json:"version"`
	InputSchema string `json:"input_schema"`
	//contract:json
	//contract:maxJSONBytes=65536
	Input json.RawMessage `json:"input"`
	Next  StepID          `json:"next"`
}

type ActorContext

type ActorContext struct {
	PrincipalID     string        `json:"principal_id"`
	PrincipalType   PrincipalType `json:"principal_type"` // human|service|agent
	SubjectUserID   string        `json:"subject_user_id,omitempty"`
	OrganizationID  string        `json:"organization_id,omitempty"`
	Site            string        `json:"site"`
	Roles           []string      `json:"roles,omitempty"`
	Scopes          []string      `json:"scopes,omitempty"`
	Channel         string        `json:"channel,omitempty"`
	DeviceID        string        `json:"device_id,omitempty"`
	AuthenticatedAt time.Time     `json:"authenticated_at"`
	AuthSessionID   string        `json:"auth_session_id,omitempty"`
	DelegationID    string        `json:"delegation_id,omitempty"`
}

ActorContext is the versioned identity/delegation context attached to every command (RFC §7.3). It records who is executing and, where applicable, the human on whose behalf a service or agent acts.

func (ActorContext) Authenticated

func (a ActorContext) Authenticated() bool

Authenticated reports whether the actor carries an identity. Missing identity fails closed in production paths.

type AgentManifest added in v1.0.0

type AgentManifest struct {
	Ref              ResourceRef   `json:"ref"`
	Allowed          []ResourceRef `json:"allowed,omitempty"`
	Prohibited       []ResourceRef `json:"prohibited,omitempty"`
	ApprovalRequired []ResourceRef `json:"approval_required,omitempty"`
	TimeoutSeconds   int           `json:"timeout_seconds,omitempty"`
	MaxRetries       int           `json:"max_retries,omitempty"`
}

func (AgentManifest) AgentAllows added in v1.0.0

func (m AgentManifest) AgentAllows(ref ResourceRef) (allowed bool, approvalRequired bool)

AgentAllows applies the deny-by-default agent policy. Approval-required capabilities are reported separately so callers can create a durable human handoff instead of silently executing them.

type ApplicationCatalog added in v1.0.0

type ApplicationCatalog struct {
	Revision             uint64                         `json:"revision"`
	BusinessScope        BusinessScope                  `json:"business_scope"`
	Modules              []ApplicationCatalogModule     `json:"modules"`
	PublishedQueries     []ApplicationCatalogQuery      `json:"published_queries"`
	PublishedProjections []ApplicationCatalogProjection `json:"published_projections"`
	PublishedOperations  []ApplicationCatalogOperation  `json:"published_operations"`
	Schemas              []ModuleSchemaDocument         `json:"schemas"`
	AllowedEntityChoices []BusinessScope                `json:"allowed_entity_choices"`
	AvailableScopes      []BusinessScope                `json:"available_scopes,omitempty"`
	Blockers             []ModuleBlocker                `json:"blockers"`
}

ApplicationCatalog is the actor-filtered tenant-session view of published module reads and actions. It contains presentation metadata and only schemas referenced by surfaces this actor may access; it grants no execution rights.

func (ApplicationCatalog) Validate added in v1.0.0

func (c ApplicationCatalog) Validate() error

type ApplicationCatalogModule added in v1.0.0

type ApplicationCatalogModule struct {
	ID      ModuleID `json:"id"`
	Version string   `json:"version"`
	State   string   `json:"state"`
}

type ApplicationCatalogOperation added in v1.0.0

type ApplicationCatalogOperation struct {
	OperationRef    string                     `json:"operation_ref"`
	OwnerModuleID   ModuleID                   `json:"owner_module_id"`
	Capability      CapabilityName             `json:"capability"`
	Operation       string                     `json:"operation"`
	InputSchema     SchemaRef                  `json:"input_schema"`
	OutputSchema    SchemaRef                  `json:"output_schema"`
	Availability    OperationAvailability      `json:"availability"`
	Permissions     []string                   `json:"permissions"`
	Presentation    SurfacePresentation        `json:"presentation"`
	OfflineEligible bool                       `json:"offline_eligible,omitempty"`
	Checkout        *CheckoutOperationContract `json:"checkout,omitempty"`
	Payment         *PaymentOperationContract  `json:"payment,omitempty"`
}

type ApplicationCatalogProjection added in v1.0.0

type ApplicationCatalogProjection struct {
	OwnerModuleID ModuleID          `json:"owner_module_id"`
	ID            string            `json:"id"`
	Route         string            `json:"route"`
	OutputSchema  SchemaRef         `json:"output_schema"`
	ScopePolicy   ResourceScopeKind `json:"scope_policy"`
	AllowedFields []string          `json:"allowed_fields"`
}

ApplicationCatalogProjection identifies an owner-published, actor-authorized historical read surface. It grants no rebuild or provider authority.

type ApplicationCatalogQuery added in v1.0.0

type ApplicationCatalogQuery struct {
	OwnerModuleID   ModuleID                  `json:"owner_module_id"`
	Name            string                    `json:"name"`
	Capability      CapabilityName            `json:"capability"`
	Route           string                    `json:"route"`
	InputSchema     SchemaRef                 `json:"input_schema"`
	OutputSchema    SchemaRef                 `json:"output_schema"`
	ScopePolicy     ResourceScopeKind         `json:"scope_policy"`
	AllowedFields   []string                  `json:"allowed_fields"`
	PageLimit       uint16                    `json:"page_limit"`
	Presentation    SurfacePresentation       `json:"presentation"`
	OfflineEligible bool                      `json:"offline_eligible,omitempty"`
	OfflineFactKey  string                    `json:"offline_fact_key,omitempty"`
	ReferenceLookup *PublishedReferenceLookup `json:"reference_lookup,omitempty"`
}

type ApplyModuleChange added in v1.0.0

type ApplyModuleChange struct {
	Meta               CommandMeta          `json:"meta"`
	ModuleID           ModuleID             `json:"module_id"`
	TargetState        ModuleLifecycleState `json:"target_state"`
	TargetVersion      string               `json:"target_version,omitempty"`
	ProviderSelections []ProviderSelection  `json:"provider_selections,omitempty"`
	PlanHash           string               `json:"plan_hash"`
	ExpectedRevision   uint64               `json:"expected_revision"`
}

ApplyModuleChange pins the reviewed plan to the expected snapshot revision.

type ApplyPackage added in v1.0.0

type ApplyPackage struct {
	Meta   CommandMeta `json:"meta"`
	Tenant TenantID    `json:"tenant_id"`
	//contract:minLength=3
	//contract:maxLength=160
	//contract:pattern=^[A-Za-z0-9][A-Za-z0-9._:-]{1,159}$
	ArtifactRef string `json:"artifact_ref"`
	// Optional immutable module releases selected for this template package.
	// The Engine passes these IDs back to Cloud when resolving the artifact so
	// that artifact delivery reproduces the exact composition Cloud approved.
	//contract:maxItems=50
	OptionalReleaseIDs []string `json:"optional_release_ids,omitempty"`
	// ProviderSelections pins provider choices for capabilities needed by this
	// activation. Choices are included in the durable command for recovery.
	//contract:maxItems=256
	ProviderSelections []ProviderSelection `json:"provider_selections,omitempty"`
	//contract:minLength=64
	//contract:maxLength=64
	//contract:pattern=^[a-f0-9]{64}$
	Digest                 string   `json:"digest"`
	ExpectedConfigRevision Revision `json:"expected_config_revision"`
}

type Approval

type Approval struct {
	ID                string        `json:"id"`
	Site              string        `json:"site"`
	OperationID       string        `json:"operation_id"`
	Actor             ActorContext  `json:"actor"`
	ToolName          string        `json:"tool_name"`
	State             ApprovalState `json:"state"`
	TargetFingerprint string        `json:"target_fingerprint"`
	ArgumentHash      string        `json:"argument_hash"`
	RecordVersion     int           `json:"record_version,omitempty"`
	RequestedAt       time.Time     `json:"requested_at"`
	ExpiresAt         time.Time     `json:"expires_at,omitempty"`
	GrantedAt         time.Time     `json:"granted_at,omitempty"`
	GrantedBy         string        `json:"granted_by,omitempty"`
	AuthSessionID     string        `json:"auth_session_id,omitempty"`
}

Approval is the durable record of a required confirmation or recent-auth check, including the full argument/target fingerprint so that a pending approval is invalidated when its targets change.

type ApprovalState

type ApprovalState string

ApprovalState is the durable state of a confirmation-required operation (RFC §10.4.2 / validation gate 4). Confirmation cannot be satisfied by prompt text or client-only headers.

const (
	ApprovalPending ApprovalState = "pending_approval"
	ApprovalGranted ApprovalState = "granted"
	ApprovalDenied  ApprovalState = "denied"
	ApprovalExpired ApprovalState = "expired"
	ApprovalRevoked ApprovalState = "revoked"
)

type Assignee added in v1.0.0

type Assignee struct {
	Kind AssigneeKind `json:"kind"`
	ID   string       `json:"id"`
}

type AssigneeKind added in v1.0.0

type AssigneeKind string
const (
	AssigneeUser  AssigneeKind = "user"
	AssigneeRole  AssigneeKind = "role"
	AssigneeGroup AssigneeKind = "group"
)

type AssignmentID added in v1.0.0

type AssignmentID string

func ParseAssignmentID added in v1.0.0

func ParseAssignmentID(raw string) (AssignmentID, error)

type AssignmentMode added in v1.0.0

type AssignmentMode string
const (
	AssignmentAny        AssignmentMode = "any"
	AssignmentAll        AssignmentMode = "all"
	AssignmentSequential AssignmentMode = "sequential"
)

type AssignmentSpec added in v1.0.0

type AssignmentSpec struct {
	Mode AssignmentMode `json:"mode"`
	//contract:maxItems=50
	Assignees []Assignee `json:"assignees"`
}

type AssignmentStatus added in v1.0.0

type AssignmentStatus string
const (
	AssignmentBlocked    AssignmentStatus = "blocked"
	AssignmentPending    AssignmentStatus = "pending"
	AssignmentResponded  AssignmentStatus = "responded"
	AssignmentSuperseded AssignmentStatus = "superseded"
	AssignmentCancelled  AssignmentStatus = "cancelled"
)

type AssignmentView added in v1.0.0

type AssignmentView struct {
	ID               AssignmentID     `json:"id"`
	Stage            uint16           `json:"stage"`
	Assignee         Assignee         `json:"assignee"`
	Status           AssignmentStatus `json:"status"`
	AllowedResponses []ResponseKind   `json:"allowed_responses"`
}

type AuthFlow

type AuthFlow struct {
	State    string `json:"state"`
	Redirect string `json:"redirect_url,omitempty"`
}

AuthFlow is the intermediate state handed to the client to begin a redirect or challenge flow. State is a server-issued, single-use, short-TTL opaque token; clients never mint it.

type AuthProvider

type AuthProvider interface {
	Discovery() ProviderProfile
	Begin(ctx context.Context, state string) (AuthFlow, error)
	Complete(ctx context.Context, code string, pkce PKCEVerifier) (IdentityAssertion, error)
	Revoke(ctx context.Context, subject string) error
	Health(ctx context.Context) error
}

AuthProvider is the provider-neutral sign-in contract. Implementations are registered per family and never construct or expose provider secrets.

type BindingInspection added in v1.0.0

type BindingInspection struct {
	ConsumerModuleID ModuleID       `json:"consumer_module_id"`
	CapabilityName   CapabilityName `json:"capability_name"`
	ProviderID       string         `json:"provider_id"`
	BindingRevision  uint64         `json:"binding_revision"`
}

BindingInspection contains no credentials or provider configuration.

type BindingKey added in v1.0.0

type BindingKey struct {
	Scope            BusinessScope  `json:"scope"`
	ConsumerModuleID ModuleID       `json:"consumer_module_id"`
	CapabilityName   CapabilityName `json:"capability_name"`
}

type Block

type Block struct {
	Kind        string      `json:"kind"` // record | collection | form | custom-es-module
	Collection  string      `json:"collection,omitempty"`
	Fields      []FieldRef  `json:"fields,omitempty"`
	Actions     []ActionRef `json:"actions,omitempty"`
	FeatureFlag string      `json:"feature_flag,omitempty"`
}

Block is one component of a region.

type BlockingRisk

type BlockingRisk string

BlockingRisk marks a capability whose risk (from RFC §18.1) prevents it from being advertised as supported.

const (
	RiskTenantIsolation BlockingRisk = "tenant-isolation"
	RiskAuthorization   BlockingRisk = "authorization"
	RiskIdentity        BlockingRisk = "identity"
	RiskCredentialScope BlockingRisk = "credential-scope"
	RiskDurableEffects  BlockingRisk = "durable-business-effects"
)

type BusinessEffect added in v1.0.0

type BusinessEffect struct {
	//contract:minLength=1
	//contract:maxLength=160
	Key string `json:"key"`
	//contract:minLength=1
	//contract:maxLength=512
	TargetRef string `json:"target_ref"`
	//contract:maxLength=160
	EntityID string `json:"entity_id"`
	//contract:minLength=1
	//contract:maxLength=64
	Amount string `json:"amount"`
	//contract:minLength=1
	//contract:maxLength=16
	Currency   string    `json:"currency"`
	OccurredAt time.Time `json:"occurred_at"`
	//contract:maxLength=160
	Lifecycle string `json:"lifecycle,omitempty"`
}

BusinessEffect is an owner-supplied downstream effect fact.

type BusinessEventDefinition added in v1.0.0

type BusinessEventDefinition struct {
	Type          string    `json:"type" yaml:"type"`
	PayloadSchema SchemaRef `json:"payload_schema" yaml:"payload_schema"`
	OwnerModuleID ModuleID  `json:"owner_module_id" yaml:"owner_module_id"`
}

BusinessEventDefinition ties an authoritative business event to its owning module.

type BusinessFinding added in v1.0.0

type BusinessFinding struct {
	//contract:minLength=1
	//contract:maxLength=160
	ID   string              `json:"id"`
	Kind BusinessFindingKind `json:"kind"`
	//contract:minLength=1
	//contract:maxLength=160
	Key string `json:"key"`
	//contract:minLength=1
	//contract:maxLength=512
	SourceRef string `json:"source_ref"`
	//contract:maxItems=100
	TargetRefs []string             `json:"target_refs,omitempty"`
	Expected   BusinessObligation   `json:"expected"`
	Actual     []BusinessEffect     `json:"actual,omitempty"`
	State      BusinessFindingState `json:"state"`
	//contract:maxBytes=8192
	Evidence string `json:"evidence,omitempty"`
}

BusinessFinding is redacted, provider-qualified reconciliation evidence.

type BusinessFindingAction added in v1.0.0

type BusinessFindingAction string
const (
	BusinessFindingActionWaived   BusinessFindingAction = "waived"
	BusinessFindingActionRepaired BusinessFindingAction = "repaired"
)

type BusinessFindingActionResult added in v1.0.0

type BusinessFindingActionResult struct {
	FindingID string                `json:"finding_id"`
	Action    BusinessFindingAction `json:"action"`
}

BusinessFindingActionResult confirms one accepted owner-governed action.

type BusinessFindingDecision added in v1.0.0

type BusinessFindingDecision struct {
	//contract:minLength=1
	//contract:maxLength=160
	FindingID string `json:"finding_id"`
	//contract:maxBytes=8192
	Reason string `json:"reason,omitempty"`
}

BusinessFindingDecision identifies an owner-published reconciliation finding to waive or repair.

func (BusinessFindingDecision) Validate added in v1.0.0

func (request BusinessFindingDecision) Validate(requireReason bool) error

type BusinessFindingKind added in v1.0.0

type BusinessFindingKind string
const (
	FindingMissingEffect     BusinessFindingKind = "missing_effect"
	FindingDuplicateEffect   BusinessFindingKind = "duplicate_effect"
	FindingAmountMismatch    BusinessFindingKind = "amount_mismatch"
	FindingScopeMismatch     BusinessFindingKind = "scope_mismatch"
	FindingUnknownOutcome    BusinessFindingKind = "unknown_outcome"
	FindingPendingGrace      BusinessFindingKind = "pending_grace"
	FindingLifecycleMismatch BusinessFindingKind = "lifecycle_mismatch"
)

type BusinessFindingState added in v1.0.0

type BusinessFindingState string
const (
	BusinessFindingOpen          BusinessFindingState = "open"
	BusinessFindingInvestigating BusinessFindingState = "investigating"
	BusinessFindingResolved      BusinessFindingState = "resolved"
	BusinessFindingWaived        BusinessFindingState = "waived"
)

type BusinessObligation added in v1.0.0

type BusinessObligation struct {
	//contract:minLength=1
	//contract:maxLength=160
	Key string `json:"key"`
	//contract:minLength=1
	//contract:maxLength=512
	SourceRef string `json:"source_ref"`
	//contract:maxLength=160
	EntityID string `json:"entity_id"`
	//contract:minLength=1
	//contract:maxLength=64
	Amount string `json:"amount"`
	//contract:minLength=1
	//contract:maxLength=16
	Currency   string    `json:"currency"`
	OccurredAt time.Time `json:"occurred_at"`
	//contract:maxLength=160
	Lifecycle string `json:"lifecycle,omitempty"`
}

BusinessObligation is an owner-supplied source fact used in a reconciliation report. Amounts remain decimal strings to avoid floating point loss.

type BusinessReconciliationRunRequest added in v1.0.0

type BusinessReconciliationRunRequest struct {
	//contract:minLength=1
	//contract:maxLength=160
	OwnerModuleID ModuleID `json:"owner_module_id"`
	//contract:minLength=1
	//contract:maxLength=160
	RuleID string `json:"rule_id"`
	//contract:minLength=1
	//contract:maxLength=160
	RunID string `json:"run_id"`
	//contract:maxLength=160
	PreviousRunID string `json:"previous_run_id,omitempty"`
}

BusinessReconciliationRunRequest starts or continues a durable report.

func (BusinessReconciliationRunRequest) Validate added in v1.0.0

func (request BusinessReconciliationRunRequest) Validate() error

type BusinessReconciliationSummary added in v1.0.0

type BusinessReconciliationSummary struct {
	Scope                      BusinessScope `json:"scope"`
	UnresolvedBusinessFindings uint32        `json:"unresolved_business_findings"`
}

BusinessReconciliationSummary is the exact-scope unresolved finding count.

type BusinessRef added in v1.0.0

type BusinessRef struct {
	ProviderID   string        `json:"provider_id"`
	ResourceType string        `json:"resource_type"`
	ID           string        `json:"id"`
	Scope        BusinessScope `json:"scope"`
}

BusinessRef is a stable provider-qualified identity, never a local row name.

type BusinessReferenceProviderHandle added in v1.0.0

type BusinessReferenceProviderHandle interface {
	CapabilityHandle
	BusinessReferenceResolver
}

BusinessReferenceProviderHandle is a granted capability handle that also resolves provider-owned business identities in the handle's exact scope.

type BusinessReferenceResolver added in v1.0.0

type BusinessReferenceResolver interface {
	Resolve(context.Context, ScopeContext, BusinessRef) (ResolvedBusinessRef, error)
}

type BusinessReferenceValidator added in v1.0.0

type BusinessReferenceValidator func(ModuleID, ReferenceRule, json.RawMessage) error

BusinessReferenceValidator is injected from a verified runtime binding plan into the shared document validation path. It is deliberately not serializable and cannot be supplied through an API payload.

type BusinessRun added in v1.0.0

type BusinessRun struct {
	TenantID      TenantID              `json:"tenant_id"`
	OwnerModuleID ModuleID              `json:"owner_module_id"`
	ID            string                `json:"id"`
	RuleID        string                `json:"rule_id"`
	Version       uint32                `json:"version"`
	Scope         BusinessScope         `json:"scope"`
	Cutoff        time.Time             `json:"cutoff"`
	Complete      bool                  `json:"complete"`
	Cursors       BusinessRunCursor     `json:"cursors,omitempty"`
	Watermarks    BusinessRunWatermarks `json:"watermarks,omitempty"`
	//contract:maxItems=10000
	Findings  []BusinessFinding `json:"findings,omitempty"`
	CreatedAt time.Time         `json:"created_at"`
}

BusinessRun is an immutable reconciliation result scoped to one tenant and business entity.

type BusinessRunCursor added in v1.0.0

type BusinessRunCursor struct {
	//contract:maxLength=1024
	Source string `json:"source,omitempty"`
	//contract:maxLength=1024
	Target string `json:"target,omitempty"`
	//contract:maxItems=10000
	SourceRows []BusinessObligation `json:"source_rows,omitempty"`
	//contract:maxItems=10000
	TargetRows     []BusinessEffect      `json:"target_rows,omitempty"`
	Watermarks     BusinessRunWatermarks `json:"watermarks,omitempty"`
	SourceComplete bool                  `json:"source_complete,omitempty"`
	TargetComplete bool                  `json:"target_complete,omitempty"`
}

BusinessRunCursor preserves the bounded replay state for an incomplete run.

type BusinessRunWatermarks added in v1.0.0

type BusinessRunWatermarks struct {
	SourceRevision string    `json:"source_revision,omitempty"`
	TargetRevision string    `json:"target_revision,omitempty"`
	SourceSnapshot string    `json:"source_snapshot,omitempty"`
	TargetSnapshot string    `json:"target_snapshot,omitempty"`
	SourceAsOf     time.Time `json:"source_as_of,omitempty"`
	TargetAsOf     time.Time `json:"target_as_of,omitempty"`
}

BusinessRunWatermarks pin both source query snapshots.

type BusinessScope added in v1.0.0

type BusinessScope struct {
	TenantID      TenantID          `json:"tenant_id"`
	Kind          BusinessScopeKind `json:"kind"`
	LegalEntityID string            `json:"legal_entity_id,omitempty"`
}

BusinessScope identifies a tenant or one verified legal entity.

func (BusinessScope) Validate added in v1.0.0

func (s BusinessScope) Validate() error

type BusinessScopeKind added in v1.0.0

type BusinessScopeKind string
const (
	ScopeKindTenant      BusinessScopeKind = "tenant"
	ScopeKindLegalEntity BusinessScopeKind = "legal_entity"
)

type CancelRequest added in v1.0.0

type CancelRequest struct {
	Meta CommandMeta `json:"meta"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

type CancelWorkflow added in v1.0.0

type CancelWorkflow struct {
	Meta CommandMeta `json:"meta"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

type Capability

type Capability struct {
	Name        string
	Description string
	Status      CapabilityStatus
	Risks       []BlockingRisk
}

Capability is a named, versioned contract or feature whose implementation and production-readiness must be tracked per the RFC handoff rule.

func BaselineCapabilities

func BaselineCapabilities() []Capability

BaselineCapabilities returns the canonical capability list for the current (Phase 0) implementation state. It is the single source of truth for the status vocabulary until later phases register their contracts.

type CapabilityAction added in v1.0.0

type CapabilityAction struct {
	CapabilityName CapabilityName `json:"capability_name"`
	OperationName  string         `json:"operation_name"`
	InputSchema    SchemaRef      `json:"input_schema"`
	OutputSchema   SchemaRef      `json:"output_schema"`
}

CapabilityAction declares a schema-checked provider operation.

type CapabilityContract added in v1.0.0

type CapabilityContract struct {
	Ref         ResourceRef     `json:"ref"`
	Description string          `json:"description,omitempty"`
	Inputs      []TypedField    `json:"inputs,omitempty"`
	Outputs     []TypedField    `json:"outputs,omitempty"`
	Requires    []ResourceRef   `json:"requires,omitempty"`
	Effects     []string        `json:"effects,omitempty"`
	Risk        ToolSafetyLevel `json:"risk,omitempty"`
}

CapabilityContract describes what may be done without prescribing its executor.

type CapabilityGrant

type CapabilityGrant struct {
	Component  string
	Capability CapabilityName
	Scope      GrantScope
}

CapabilityGrant declares that a component may receive a capability at a given scope.

type CapabilityHandle

type CapabilityHandle interface {
	Name() CapabilityName
	Scope() GrantScope
	Revoke()
	Evidence() CleanupEvidence
}

CapabilityHandle is a grant-checked reference to one capability. Revoke is idempotent and releases underlying resources via the handle's disposer.

type CapabilityInspection added in v1.0.0

type CapabilityInspection struct {
	Name       CapabilityName `json:"name"`
	State      string         `json:"state"`
	ReasonCode string         `json:"reason_code,omitempty"`
}

CapabilityInspection is a bounded availability diagnostic.

type CapabilityLease added in v1.0.0

type CapabilityLease struct {
	ID               string        `json:"id"`
	TenantID         TenantID      `json:"tenant_id"`
	Scope            BusinessScope `json:"scope"`
	CallerModuleID   ModuleID      `json:"caller_module_id"`
	ProviderModuleID ModuleID      `json:"provider_module_id,omitempty"`
	ProviderID       string        `json:"provider_id"`
	Operation        string        `json:"operation"`
	BindingRevision  uint64        `json:"binding_revision"`
	GrantEpoch       uint64        `json:"grant_epoch"`
	ExpiresAt        time.Time     `json:"expires_at"`
	State            string        `json:"state"`
	AdmittedAttempts uint64        `json:"admitted_attempts"`
	CredentialRef    string        `json:"credential_ref,omitempty"`
}

CapabilityLease is an internal durable, scope-bound grant for one provider operation. It is persisted by the tenant module store, not exposed on a wire.

func (CapabilityLease) Validate added in v1.0.0

func (l CapabilityLease) Validate() error

type CapabilityName

type CapabilityName string

CapabilityName identifies a grantable capability. Values are stable and used as telemetry labels, so additions are fine but renames are not.

type CapabilityOffer added in v1.0.0

type CapabilityOffer struct {
	Name       CapabilityName  `json:"name"`
	Contract   SchemaRef       `json:"contract"`
	Operations []OperationSpec `json:"operations"`
}

type CapabilityRequirement added in v1.0.0

type CapabilityRequirement struct {
	Name     CapabilityName `json:"name"`
	Contract SchemaRef      `json:"contract"`
	Required bool           `json:"required"`
}

type CapabilitySelector added in v1.0.0

type CapabilitySelector struct {
	CallerModuleID ModuleID
	ProviderID     string
	Operation      string
}

CapabilitySelector identifies one caller/provider operation within a business scope. It intentionally has no wildcard fields.

func (CapabilitySelector) Validate added in v1.0.0

func (s CapabilitySelector) Validate() error

type CapabilityStatus

type CapabilityStatus string

CapabilityStatus is the status vocabulary from KORA-ENGINE-RFC.md:

planned       specified but not implemented
experimental  implemented behind an explicit feature flag, no compatibility promise
supported     contract, recovery, security, and observability tests pass in a stated mode
retired       no new callers may depend on it
const (
	CapabilityPlanned      CapabilityStatus = "planned"
	CapabilityExperimental CapabilityStatus = "experimental"
	CapabilitySupported    CapabilityStatus = "supported"
	CapabilityRetired      CapabilityStatus = "retired"
)

type ChannelSessionIssueRequestV2 added in v1.0.0

type ChannelSessionIssueRequestV2 struct {
	ClientName      string            `json:"client_name"`
	ConversationKey string            `json:"conversation_key"`
	Provider        string            `json:"provider"`
	SenderAddress   string            `json:"sender_address"`
	Permissions     []PermissionGrant `json:"permissions"`
	TrustedUntil    string            `json:"trusted_until"`
	SensitiveUntil  string            `json:"sensitive_until,omitempty"`
}

ChannelSessionIssueRequestV2 is the managed channel's session request.

type ChannelSessionIssueResponseV2 added in v1.0.0

type ChannelSessionIssueResponseV2 struct {
	SessionID       string     `json:"session_id"`
	AccessToken     string     `json:"access_token"`
	TrustedUntil    time.Time  `json:"trusted_until"`
	SensitiveUntil  *time.Time `json:"sensitive_until,omitempty"`
	ConversationKey string     `json:"conversation_key"`
}

ChannelSessionIssueResponseV2 carries a newly issued, short-lived bearer credential. Consumers must treat AccessToken as a secret.

type CheckoutInputBinding added in v1.0.0

type CheckoutInputBinding struct {
	CartItems      string `json:"cart_items"`
	RequestedTotal string `json:"requested_total"`
	Currency       string `json:"currency"`
	PaymentMethod  string `json:"payment_method"`
	CustomerRef    string `json:"customer_ref,omitempty"`
	RegisterRef    string `json:"register_ref,omitempty"`
	ShiftRef       string `json:"shift_ref,omitempty"`
	TillSessionRef string `json:"till_session_ref,omitempty"`
	CustomerPhone  string `json:"customer_phone,omitempty"`
}

type CheckoutOperationContract added in v1.0.0

type CheckoutOperationContract struct {
	Input    CheckoutInputBinding     `json:"input"`
	Outcomes []CheckoutOutcomeBinding `json:"outcomes"`
}

func (CheckoutOperationContract) Validate added in v1.0.0

func (c CheckoutOperationContract) Validate(inputSchema, outputSchema json.RawMessage) error

type CheckoutOutcomeBinding added in v1.0.0

type CheckoutOutcomeBinding struct {
	Kind           CheckoutOutcomeKind `json:"kind"`
	StatusField    string              `json:"status_field"`
	SuccessValue   string              `json:"success_value"`
	ReferenceField string              `json:"reference_field,omitempty"`
}

type CheckoutOutcomeKind added in v1.0.0

type CheckoutOutcomeKind string
const (
	CheckoutPaymentInitiated CheckoutOutcomeKind = "payment_initiated"
	CheckoutPaymentSettled   CheckoutOutcomeKind = "payment_settled"
	CheckoutInvoiceIssued    CheckoutOutcomeKind = "invoice_issued"
	CheckoutFulfillmentEnded CheckoutOutcomeKind = "fulfillment_completed"
)

type Claim

type Claim struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Claim is one verified, bounded identity claim. Claims are typed and limited; raw provider payloads are never propagated.

type CleanupEvidence

type CleanupEvidence struct {
	Owner      string
	ScopeID    string
	AcquiredAt time.Time
	ReleasedAt time.Time
}

CleanupEvidence records the ownership and release of a handle.

type Code

type Code string

Code is a stable, machine-readable error code. These values must not be renamed or repurposed once frozen, because callers depend on them.

const (
	CodePermissionDenied      Code = "PERMISSION_DENIED"
	CodeValidationFailed      Code = "VALIDATION_FAILED"
	CodeNotFound              Code = "NOT_FOUND"
	CodeConflict              Code = "CONFLICT"
	CodeDeadlineExceeded      Code = "DEADLINE_EXCEEDED"
	CodeDependencyUnavailable Code = "DEPENDENCY_UNAVAILABLE"
	CodeIdempotencyKeyReused  Code = "IDEMPOTENCY_KEY_REUSED"
	CodeUnauthenticated       Code = "UNAUTHENTICATED"
	CodeResourceExhausted     Code = "RESOURCE_EXHAUSTED"
	CodeStaleSubject          Code = "STALE_SUBJECT"
	CodeLeaseLost             Code = "LEASE_LOST"
	CodeOutcomeUnknown        Code = "OUTCOME_UNKNOWN"
	CodeUnsupportedVersion    Code = "UNSUPPORTED_VERSION"
	CodeInternal              Code = "INTERNAL_ERROR"
)

func NormalizeCode

func NormalizeCode(s string) Code

NormalizeCode returns the Code for an unstructured error string. It is a best-effort mapping used when an adapter cannot produce a typed error; the caller should prefer wrapping with a typed Error via NewError.

type CommandBatch

type CommandBatch struct {
	Commands []CommandEnvelope `json:"commands"`
}

CommandBatch is a set of offline commands submitted for sync (OFFLINE-002).

type CommandBus

type CommandBus interface {
	Request(ctx context.Context, command CommandEnvelope) (CommandResult, error)
	Submit(ctx context.Context, command CommandEnvelope) (TaskReceipt, error)
}

CommandBus dispatches commands synchronously (Request) or asynchronously (Submit).

type CommandEnvelope

type CommandEnvelope struct {
	Type string `json:"type"`
	//contract:min=1
	Version        int          `json:"version"`
	ID             string       `json:"id"`
	Site           string       `json:"site"`
	Actor          ActorContext `json:"actor"`
	CorrelationID  string       `json:"correlation_id,omitempty"`
	CausationID    string       `json:"causation_id,omitempty"`
	IdempotencyKey string       `json:"idempotency_key,omitempty"`
	Deadline       time.Time    `json:"deadline"`
	//contract:json
	Data json.RawMessage `json:"data,omitempty"`
}

CommandEnvelope is the versioned transport for a command (RFC §7). It is serialized as the command is dispatched through any provider.

func OrderByCausation

func OrderByCausation(cmds []CommandEnvelope) ([]CommandEnvelope, error)

OrderByCausation returns the commands topologically ordered by causation: a command whose CausationID references another command's ID in the batch is placed after its parent. Independent commands preserve their input order. This guarantees "parent before child" replay regardless of submission order.

func (CommandEnvelope) Expired

func (c CommandEnvelope) Expired(now time.Time) bool

Expired reports whether the command deadline has passed. A missing or expired deadline returns CodeDeadlineExceeded before business execution.

type CommandMeta added in v1.0.0

type CommandMeta struct {
	IdempotencyKey   IdempotencyKey `json:"idempotency_key"`
	ExpectedRevision Revision       `json:"expected_revision,omitempty"`
}

CommandMeta carries retry identity and optimistic concurrency data.

type CommandResult

type CommandResult struct {
	OperationID   string `json:"operation_id"`
	CorrelationID string `json:"correlation_id"`
	Status        Status `json:"status"`
	//contract:json
	Data     json.RawMessage `json:"data,omitempty"`
	Error    *Error          `json:"error,omitempty"`
	Replayed bool            `json:"replayed,omitempty"`
}

CommandResult is the versioned result of a synchronous command (RFC §7.1).

type ComponentObservation

type ComponentObservation struct {
	Ref        ResourceRef       `json:"ref"`
	Status     ObservationStatus `json:"status"`
	Generation int               `json:"generation"`
	Detail     string            `json:"detail,omitempty"`
	SeenAt     time.Time         `json:"seen_at"`
}

ComponentObservation is the observed state of one resource. Detail is a bounded, redacted human-readable string — never a payload or secret.

type CompositionPlan added in v1.0.0

type CompositionPlan struct {
	Modules          []ModuleDescriptor        `json:"modules"`
	Packages         []InstalledPackage        `json:"packages,omitempty"`
	Extensions       []ResolvedModuleExtension `json:"extensions,omitempty"`
	Bindings         []BindingInspection       `json:"bindings"`
	ActivationOrder  []ModuleID                `json:"activation_order"`
	Conflicts        []string                  `json:"conflicts,omitempty"`
	CyclePaths       [][]ModuleID              `json:"cycle_paths,omitempty"`
	DisabledOptional []CapabilityRequirement   `json:"disabled_optional,omitempty"`
	PlanHash         string                    `json:"plan_hash"`
}

CompositionPlan is deterministic preflight output before configuration mutation.

func PlanComposition added in v1.0.0

func PlanComposition(modules []ModuleDescriptor, providers []ProviderRegistration, selections []ProviderSelection, scope BusinessScope, revision uint64) (CompositionPlan, error)

func PlanInstalledComposition added in v1.0.0

func PlanInstalledComposition(packages []InstalledPackage, modules []ModuleDescriptor, providers []ProviderRegistration, selections []ProviderSelection, scope BusinessScope, revision uint64) (CompositionPlan, error)

PlanInstalledComposition combines package dependency validation with the existing capability graph planner and hashes the entire activation plan.

type ConditionSpec added in v1.0.0

type ConditionSpec struct {
	//contract:maxLength=8192
	Expression string          `json:"expression,omitempty"`
	Field      *FieldCondition `json:"field,omitempty"`
	IfTrue     StepID          `json:"if_true"`
	IfFalse    StepID          `json:"if_false"`
}

type ConfigurationCandidateV2 added in v1.0.0

type ConfigurationCandidateV2 struct {
	ProposalID          string `json:"proposal_id,omitempty"`
	ConversationID      string `json:"conversation_id,omitempty"`
	BaseConfigVersionID string `json:"base_config_version_id,omitempty"`
	//contract:json
	Doctypes []json.RawMessage `json:"doctypes"`
	//contract:json
	Roles []json.RawMessage `json:"roles,omitempty"`
	//contract:json
	Permissions []json.RawMessage `json:"permissions,omitempty"`
	//contract:json
	Views []json.RawMessage `json:"views,omitempty"`
	//contract:json
	Scripts []json.RawMessage `json:"scripts,omitempty"`
	// V2 workflow definitions use the same strict decoder as package imports.
	//contract:json
	WorkflowDefinitions []json.RawMessage `json:"workflow_definitions,omitempty"`
	//contract:maxItems=512
	PublishedBindings []ConfigurationSurfaceBinding `json:"published_bindings,omitempty"`
}

ConfigurationCandidateV2 is the read-only onboarding validation input. Resource bodies remain JSON because their versioned Engine schemas evolve independently; this envelope fixes the cross-repository field names.

type ConfigurationCheckV2 added in v1.0.0

type ConfigurationCheckV2 struct {
	Valid             bool                    `json:"valid"`
	OrderedDocTypes   []string                `json:"ordered_doctypes"`
	BaseConfigVersion string                  `json:"base_config_version_id,omitempty"`
	Errors            []string                `json:"errors,omitempty"`
	Warnings          []string                `json:"warnings,omitempty"`
	Conflicts         []ConfigurationConflict `json:"conflicts,omitempty"`
	Impact            []ConfigurationImpact   `json:"impact,omitempty"`
	//contract:maxItems=512
	PublishedBindings []ConfigurationSurfaceBinding `json:"published_bindings,omitempty"`
	ModuleBlockers    []ModuleBlocker               `json:"module_blockers,omitempty"`
}

ConfigurationCheckV2 is the shared read-only result of onboarding configuration validation and impact analysis.

type ConfigurationConflict added in v1.0.0

type ConfigurationConflict struct {
	Kind   string `json:"kind"`
	Name   string `json:"name"`
	Detail string `json:"detail"`
}

type ConfigurationDraftResultV2 added in v1.0.0

type ConfigurationDraftResultV2 struct {
	ProposalID           string   `json:"proposal_id"`
	ConversationID       string   `json:"conversation_id,omitempty"`
	DraftConfigVersionID string   `json:"draft_config_version_id"`
	VersionNum           int      `json:"version_num"`
	Status               string   `json:"status"`
	OrderedDocTypes      []string `json:"ordered_doctypes"`
}

ConfigurationDraftResultV2 identifies the one inactive version composed from a candidate. The response does not imply eligibility or activation.

type ConfigurationDraftV2 added in v1.0.0

type ConfigurationDraftV2 struct {
	ProposalID           string `json:"proposal_id"`
	DraftConfigVersionID string `json:"draft_config_version_id,omitempty"`
	ConversationID       string `json:"conversation_id,omitempty"`
	BaseConfigVersionID  string `json:"base_config_version_id,omitempty"`
	// CreatedBy is retained for source compatibility. Engine attribution comes
	// from the authenticated execution identity, never this caller field.
	CreatedBy string `json:"created_by,omitempty"`
	//contract:json
	DocTypes []json.RawMessage `json:"doctypes"`
	//contract:json
	Roles []json.RawMessage `json:"roles,omitempty"`
	//contract:json
	Permissions []json.RawMessage `json:"permissions,omitempty"`
	//contract:json
	Views []json.RawMessage `json:"views,omitempty"`
	//contract:json
	Scripts       []json.RawMessage        `json:"scripts,omitempty"`
	ScheduledJobs []ScheduledJobDefinition `json:"scheduled_jobs,omitempty"`
	//contract:json
	WorkflowDefinitions []json.RawMessage `json:"workflow_definitions,omitempty"`
	//contract:maxItems=512
	PublishedBindings []ConfigurationSurfaceBinding `json:"published_bindings,omitempty"`
}

ConfigurationDraftV2 is Cloud's request to compose an inactive Engine configuration version. Resource bodies remain JSON values because their domain schemas are validated by Engine; callers must not treat this as a generic activation or tenant mutation API.

type ConfigurationImpact added in v1.0.0

type ConfigurationImpact struct {
	Name   string `json:"name"`
	Kind   string `json:"kind"`
	Action string `json:"action"`
	Safe   bool   `json:"safe"`
}

type ConfigurationPatch added in v1.0.0

type ConfigurationPatch struct {
	Ref        ResourceRef      `json:"ref"`
	Target     ResourceRef      `json:"target"`
	Operations []PatchOperation `json:"operations"`
	Author     string           `json:"author"`
	Reason     string           `json:"reason"`
}

type ConfigurationSnapshotFileV2 added in v1.0.0

type ConfigurationSnapshotFileV2 struct {
	Path        string `json:"path"`
	Content     string `json:"content"`
	ContentType string `json:"content_type"`
}

type ConfigurationSnapshotResponseV2 added in v1.0.0

type ConfigurationSnapshotResponseV2 struct {
	VersionID        string   `json:"version_id"`
	Version          int      `json:"version"`
	Status           string   `json:"status"`
	Site             string   `json:"site"`
	Label            string   `json:"label"`
	DoctypeNames     []string `json:"doctype_names"`
	DoctypeCount     int      `json:"doctype_count"`
	RolesCount       int      `json:"roles_count"`
	PermissionsCount int      `json:"permissions_count"`
	//contract:json
	Snapshot json.RawMessage `json:"snapshot"`
	//contract:json
	PackFiles []ConfigurationSnapshotFileV2 `json:"pack_files"`
}

ConfigurationSnapshotResponseV2 returns a versioned declarative snapshot; it contains configuration metadata only, never tenant business records.

type ConfigurationSurfaceBinding added in v1.0.0

type ConfigurationSurfaceBinding struct {
	Kind ConfigurationSurfaceKind `json:"kind"`
	// ViewName binds this published surface to the exact generated view that
	// consumes it. It is configuration metadata, never an execution grant.
	//contract:maxLength=160
	ViewName        string        `json:"view_name"`
	CatalogRevision uint64        `json:"catalog_revision"`
	BusinessScope   BusinessScope `json:"business_scope"`
	//contract:maxLength=128
	//contract:pattern=^[a-z][a-z0-9_.-]{0,127}$
	OwnerModuleID ModuleID `json:"owner_module_id"`
	//contract:maxLength=160
	Name         string     `json:"name,omitempty"`
	OperationRef string     `json:"operation_ref,omitempty"`
	InputSchema  *SchemaRef `json:"input_schema,omitempty"`
	OutputSchema SchemaRef  `json:"output_schema"`
}

ConfigurationSurfaceBinding pins generated UI to one exact registered module surface. It is descriptive configuration, never an authorization grant. Execution must still authorize the current actor and business scope.

func (ConfigurationSurfaceBinding) Validate added in v1.0.0

func (b ConfigurationSurfaceBinding) Validate() error

type ConfigurationSurfaceKind added in v1.0.0

type ConfigurationSurfaceKind string

ConfigurationSurfaceKind identifies an owner-published surface referenced by a generated page or view.

const (
	ConfigurationQuery      ConfigurationSurfaceKind = "query"
	ConfigurationProjection ConfigurationSurfaceKind = "projection"
	ConfigurationOperation  ConfigurationSurfaceKind = "operation"
)

type ConfigurationVersionSummaryV2 added in v1.0.0

type ConfigurationVersionSummaryV2 struct {
	ID      string `json:"id"`
	Site    string `json:"site"`
	Version int    `json:"version"`
	Status  string `json:"status"`
}

ConfigurationVersionSummaryV2 identifies a stored tenant configuration. It is intended for authenticated management clients that need to anchor a proposed change to the current active or draft version.

type ConflictRecord

type ConflictRecord struct {
	Name            string    `json:"name"`
	Site            string    `json:"site"`
	Doctype         string    `json:"doctype"`
	DocName         string    `json:"doc_name"`
	LosingExpectedV int64     `json:"losing_expected_version"`
	WinningActualV  int64     `json:"winning_actual_version"`
	LoserCommandKey string    `json:"loser_command_key"`
	DetectedAt      time.Time `json:"detected_at"`
	State           string    `json:"state"` // open | acknowledged | merged
}

ConflictRecord is the durable record of a losing offline write (OFFLINE-003). It survives restarts until acknowledged or merged.

func NewConflictRecord

func NewConflictRecord(site, doctype, docName string, losingExpected, winningActual int64, loserKey string, now time.Time) ConflictRecord

NewConflictRecord builds an open conflict from a losing write.

type Consumer

type Consumer interface {
	Run(ctx context.Context, handler Handler) error
	Drain(ctx context.Context) error
}

Consumer subscribes to a durable message stream.

type ConsumerDefinition added in v1.0.0

type ConsumerDefinition struct {
	ConsumerID           string               `json:"consumer_id"`
	OwnerModuleID        ModuleID             `json:"owner_module_id"`
	AcceptedEventSchemas map[string]SchemaRef `json:"accepted_event_schemas"`
}

ConsumerDefinition declares owner-controlled event subscriptions.

type ContinuationView added in v1.0.0

type ContinuationView struct {
	OperationID OperationID    `json:"operation_id"`
	State       OperationState `json:"state"`
}

type CrossEntityOperation added in v1.0.0

type CrossEntityOperation struct {
	OperationID    string   `json:"operation_id"`
	SourceEntityID string   `json:"source_entity_id"`
	TargetEntityID string   `json:"target_entity_id"`
	Resource       string   `json:"resource"`
	Operation      string   `json:"operation"`
	TenantID       TenantID `json:"tenant_id"`
}

CrossEntityOperation is an explicit command envelope for an operation that must act across two legal entities. Both scoped grants are checked before a command handler is allowed to execute it.

func (CrossEntityOperation) Validate added in v1.0.0

func (o CrossEntityOperation) Validate() error

type Cursor

type Cursor struct {
	Token   string    `json:"token"`
	Version int64     `json:"version,omitempty"`
	Nonce   string    `json:"nonce,omitempty"`
	At      time.Time `json:"at"`
}

Cursor is an opaque, resumable position for a durable stream: an AI run checkpoint, a conversation delivery cursor, or an offline sync cursor.

type DBServerID added in v1.0.0

type DBServerID string

func ParseDBServerID added in v1.0.0

func ParseDBServerID(raw string) (DBServerID, error)

type DecisionID added in v1.0.0

type DecisionID string

func ParseDecisionID added in v1.0.0

func ParseDecisionID(raw string) (DecisionID, error)

type DefinitionID added in v1.0.0

type DefinitionID string

func ParseDefinitionID added in v1.0.0

func ParseDefinitionID(raw string) (DefinitionID, error)

type DefinitionVersionRef added in v1.0.0

type DefinitionVersionRef struct {
	DefinitionID DefinitionID `json:"definition_id"`
	Version      uint32       `json:"version"`
	Digest       string       `json:"digest"`
}

type DeleteTenant added in v1.0.0

type DeleteTenant struct {
	Meta CommandMeta `json:"meta"`
	//contract:minLength=3
	//contract:maxLength=160
	//contract:pattern=^[A-Za-z0-9][A-Za-z0-9._:-]{1,159}$
	RecoveryCheckpointRef string `json:"recovery_checkpoint_ref"`
}

type Delivery

type Delivery struct {
	ID   string `json:"id"`
	Type string `json:"type"`
	Site string `json:"site"`
	//contract:json
	Data    json.RawMessage `json:"data"`
	Attempt int             `json:"attempt"`
}

Delivery carries a message to a Consumer handler (RFC §7).

type DeploymentID added in v1.0.0

type DeploymentID string

func ParseDeploymentID added in v1.0.0

func ParseDeploymentID(raw string) (DeploymentID, error)

type DesiredReport

type DesiredReport struct {
	DeploymentID string            `json:"deployment_id"`
	TenantID     string            `json:"tenant_id"`
	Generation   int               `json:"generation"`
	Status       DesiredStatus     `json:"status"`
	Resources    []DesiredResource `json:"resources"`
	CreatedAt    time.Time         `json:"created_at"`
	Signature    []byte            `json:"signature,omitempty"`
}

DesiredReport is the signed desired-state batch published by Cloud or an activation controller.

type DesiredResource

type DesiredResource struct {
	Ref          ResourceRef   `json:"ref"`
	Required     bool          `json:"required,omitempty"`
	Dependencies []ResourceRef `json:"dependencies,omitempty"`
}

DesiredResource represents one resource the platform intends to have active at a target generation.

type DesiredStatus

type DesiredStatus string

DesiredStatus describes the current lifecycle posture of a desired state set.

const (
	DesiredPlanned    DesiredStatus = "planned"
	DesiredActive     DesiredStatus = "active"
	DesiredBlocked    DesiredStatus = "blocked"
	DesiredSuperseded DesiredStatus = "superseded"
)

type EndSpec added in v1.0.0

type EndSpec struct {
	//contract:minLength=1
	//contract:maxLength=120
	Outcome string `json:"outcome"`
}

type ErrCapabilityDenied

type ErrCapabilityDenied struct {
	Component  string
	Capability CapabilityName
}

ErrCapabilityDenied is a typed denial carrying the component and the capability that was refused. Callers match via errors.As, never by string.

func (*ErrCapabilityDenied) Error

func (e *ErrCapabilityDenied) Error() string

type ErrUIManifestInvalid

type ErrUIManifestInvalid struct {
	Path   string
	Detail string
}

ErrUIManifestInvalid is a typed validation failure carrying the key path and a human detail.

func (*ErrUIManifestInvalid) Error

func (e *ErrUIManifestInvalid) Error() string

type Error

type Error struct {
	Type    Code   `json:"type"`
	Message string `json:"message"`
	Field   string `json:"field,omitempty"`
	//contract:json
	Details json.RawMessage `json:"details,omitempty"`
}

Error is the structured, versioned error contract. Error codes are stable machine-readable values per RFC §7.1.

func NewError

func NewError(code Code, message string) *Error

NewError builds a structured error with the given code and message.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

type EventEnvelope

type EventEnvelope struct {
	ID   string `json:"id"`
	Type string `json:"type"`
	//contract:min=1
	Version int `json:"version"`
	// Sequence is assigned by the tenant outbox transaction and orders source
	// events for rebuild cutoffs. It remains a decimal string to avoid JSON
	// number precision loss in JavaScript consumers.
	Sequence       Revision      `json:"sequence,omitempty"`
	Source         string        `json:"source"`
	Site           string        `json:"site"`
	BusinessScope  BusinessScope `json:"business_scope,omitempty"`
	AggregateType  string        `json:"aggregate_type,omitempty"`
	AggregateID    string        `json:"aggregate_id,omitempty"`
	OccurredAt     time.Time     `json:"occurred_at"`
	CorrelationID  string        `json:"correlation_id,omitempty"`
	CausationID    string        `json:"causation_id,omitempty"`
	CausationDepth uint16        `json:"causation_depth,omitempty"`
	Actor          ActorContext  `json:"actor,omitempty"`
	Capability     ResourceRef   `json:"capability,omitempty"`
	Skill          ResourceRef   `json:"skill,omitempty"`
	ModelRevision  string        `json:"model_revision,omitempty"`
	ProvenanceIDs  []string      `json:"provenance_ids,omitempty"`
	//contract:json
	Data json.RawMessage `json:"data"`
}

EventEnvelope is the versioned transport for a domain event (RFC §7/§8.3).

func (EventEnvelope) OrderKey

func (e EventEnvelope) OrderKey() SiteAggregateKey

OrderKey returns the stable ordering key for an event envelope. Events for the same (site, aggregate) must be delivered in publish order.

func (EventEnvelope) Validate added in v1.0.0

func (e EventEnvelope) Validate() error

Validate checks the minimum semantic envelope required for durable delivery.

type EventPublisher

type EventPublisher interface {
	Publish(ctx context.Context, event EventEnvelope) error
}

EventPublisher publishes events. Local WAL rotation/replay is not part of this contract; it lives behind LocalProvider.

type ExecutePublishedOperation added in v1.0.0

type ExecutePublishedOperation struct {
	Meta        CommandMeta `json:"meta"`
	InputSchema SchemaRef   `json:"input_schema"`
	//contract:maxJSONBytes=1048576
	//contract:json
	Input json.RawMessage `json:"input"`
}

ExecutePublishedOperation asks Engine to invoke a registered public module operation. Caller provenance and provider selection are resolved by Engine.

func (ExecutePublishedOperation) Validate added in v1.0.0

func (r ExecutePublishedOperation) Validate() error

type ExecutionInspection added in v1.0.0

type ExecutionInspection struct {
	ExecutionID         string           `json:"execution_id"`
	CallerModuleID      ModuleID         `json:"caller_module_id"`
	OwnerModuleID       ModuleID         `json:"owner_module_id"`
	ProviderID          string           `json:"provider_id"`
	BindingRevision     uint64           `json:"binding_revision"`
	Contract            CapabilityAction `json:"contract"`
	CorrelationID       string           `json:"correlation_id"`
	DeliveryState       string           `json:"delivery_state"`
	ReconciliationState string           `json:"reconciliation_state"`
}

ExecutionInspection describes a pinned execution without exposing its payload.

type ExtensionField added in v1.0.0

type ExtensionField struct {
	Key    string    `json:"key"`
	Schema SchemaRef `json:"schema"`
}

ExtensionField must use an extender-owned namespaced key.

type ExtensionKind added in v1.0.0

type ExtensionKind string

ExtensionKind is a behavior explicitly allowed by an owner-declared point.

const (
	ExtensionFields     ExtensionKind = "fields"
	ExtensionValidation ExtensionKind = "validation"
	ExtensionPostCommit ExtensionKind = "post_commit"
)

type ExtensionPoint added in v1.0.0

type ExtensionPoint struct {
	OwnerModuleID   ModuleID    `json:"owner_module_id"`
	ID              string      `json:"id"`
	Version         uint32      `json:"version"`
	Target          ResourceRef `json:"target"`
	AllowedKinds    []string    `json:"allowed_kinds"`
	ProtectedFields []string    `json:"protected_fields,omitempty"`
	InputSchema     SchemaRef   `json:"input_schema"`
	OutputSchema    SchemaRef   `json:"output_schema"`
	ExecutionPhase  string      `json:"execution_phase"`
	FailurePolicy   string      `json:"failure_policy"`
}

ExtensionPoint is an owner declaration of a narrowly scoped extension surface.

type ExtensionRegistration added in v1.0.0

type ExtensionRegistration struct {
	ID               string           `json:"id"`
	ExtenderModuleID ModuleID         `json:"extender_module_id"`
	PointID          string           `json:"point_id"`
	PointVersion     uint32           `json:"point_version"`
	Kind             ExtensionKind    `json:"kind"`
	ArtifactDigest   string           `json:"artifact_digest"`
	HandlerRef       ResourceRef      `json:"handler_ref"`
	Event            string           `json:"event,omitempty"`
	Order            int32            `json:"order"`
	DependsOn        []string         `json:"depends_on,omitempty"`
	AddedFields      []ExtensionField `json:"added_fields,omitempty"`
}

ExtensionRegistration grants no resource mutation authority.

type ExternalOutcome added in v1.0.0

type ExternalOutcome string
const (
	ExternalApplied    ExternalOutcome = "applied"
	ExternalNotApplied ExternalOutcome = "not_applied"
	ExternalUnknown    ExternalOutcome = "unknown"
)

type FieldCondition added in v1.0.0

type FieldCondition struct {
	Field    string `json:"field"`
	Operator string `json:"operator"`
	//contract:json
	//contract:maxJSONBytes=8192
	Value json.RawMessage `json:"value,omitempty"`
}

FieldCondition is the table-bound, typed alternative to entering an expression. Value must be a JSON scalar and Field must exist on the trigger table.

type FieldHint

type FieldHint struct {
	Name           string   `json:"name"`
	Label          string   `json:"label,omitempty"`
	Fieldtype      string   `json:"fieldtype"`
	Type           string   `json:"type,omitempty"`
	Format         string   `json:"format,omitempty"`
	Options        []string `json:"options,omitempty"`
	LinkTarget     string   `json:"link_target,omitempty"`
	TableTarget    string   `json:"table_target,omitempty"`
	Required       bool     `json:"required,omitempty"`
	ReadOnly       bool     `json:"read_only,omitempty"`
	Computed       bool     `json:"computed,omitempty"`
	Writable       bool     `json:"writable"`
	StandardFilter bool     `json:"standard_filter,omitempty"`
	SearchIndex    bool     `json:"search_index,omitempty"`
	InListView     bool     `json:"in_list_view,omitempty"`
	Unique         bool     `json:"unique,omitempty"`
	Description    string   `json:"description,omitempty"`
}

FieldHint is the canonical, serialized description of a doctype field exposed through a tool projection. It is intentionally free of doctype package types.

type FieldRef

type FieldRef struct {
	Name string `json:"name"`
}

FieldRef references one field by name.

type GenerationInfo

type GenerationInfo struct {
	Site           string `json:"site"`
	ConfigVersion  int64  `json:"config_version"`
	ProjectionHash string `json:"projection_hash"`
}

GenerationInfo identifies the projection generation a client holds (OFFLINE-001). ConfigVersion bumps on every activated config change; ProjectionHash identifies the derived local schema.

type GrantScope

type GrantScope string

GrantScope bounds the lifetime of an issued handle.

const (
	GrantScopeComponent GrantScope = "component" // lives as long as the component is bound
	GrantScopeOperation GrantScope = "operation" // lives for one operation/kernel invocation
	GrantScopeCall      GrantScope = "call"      // lives for one provider call
)

type GrantTenantMember added in v1.0.0

type GrantTenantMember struct {
	Meta CommandMeta `json:"meta"`
	//contract:minLength=1
	//contract:maxLength=160
	InvitationID string `json:"invitation_id"`
	// Subject is the immutable Cloud user ID and becomes the tenant user key.
	//contract:minLength=3
	//contract:maxLength=140
	//contract:pattern=^[A-Za-z0-9][A-Za-z0-9._:-]{2,139}$
	Subject PrincipalID `json:"subject"`
	//contract:minLength=3
	//contract:maxLength=254
	//contract:maxBytes=254
	Email string `json:"email"`
	//contract:minLength=1
	//contract:maxBytes=140
	FullName string `json:"full_name"`
	//contract:minItems=1
	//contract:maxItems=1
	Roles []string `json:"roles"`
}

GrantTenantMember starts a durable operation that creates or re-enables the tenant user keyed by the Cloud subject with the invited roles. The idempotency key must equal the Cloud invitation ID, so retries of one acceptance replay the same operation. The Engine rechecks the roles.

type HandleIssuer

type HandleIssuer interface {
	Issue(ctx OperationContext, component string, want []CapabilityName) ([]CapabilityHandle, error)
}

HandleIssuer issues capability handles for a component. It returns a typed ErrCapabilityDenied for anything the component did not declare.

type Handler

type Handler func(ctx context.Context, d Delivery) error

Handler processes a single Delivery. Returning a nil error acknowledges the message; returning a non-nil error causes redelivery per policy.

type HistoricalSnapshot added in v1.0.0

type HistoricalSnapshot struct {
	Source        BusinessRef   `json:"source"`
	BusinessScope BusinessScope `json:"business_scope"`
	CapturedAt    time.Time     `json:"captured_at"`
	Schema        SchemaRef     `json:"schema"`
	//contract:json
	Data json.RawMessage `json:"data"`
}

HistoricalSnapshot retains approved provider fields captured at issuance.

func (HistoricalSnapshot) Validate added in v1.0.0

func (s HistoricalSnapshot) Validate() error

type HistoricalSnapshotValidator added in v1.0.0

type HistoricalSnapshotValidator func(SchemaRef, HistoricalSnapshot) error

HistoricalSnapshotValidator checks a retained snapshot against its declared field schema and verified transaction scope without consulting its provider.

type HumanRequestTemplate added in v1.0.0

type HumanRequestTemplate struct {
	Kind    RequestKind    `json:"kind"`
	Subject SubjectBinding `json:"subject"`
	//contract:minLength=1
	//contract:maxLength=160
	Title string `json:"title"`
	//contract:maxBytes=8192
	Message    string          `json:"message"`
	PolicyID   string          `json:"policy_id,omitempty"`
	Assignment *AssignmentSpec `json:"assignment,omitempty"`
	//contract:min=1
	//contract:max=2678400
	DueAfterSeconds   uint32     `json:"due_after_seconds"`
	InformationSchema *SchemaRef `json:"information_schema,omitempty"`
}

type HumanSpec added in v1.0.0

type HumanSpec struct {
	Request     HumanRequestTemplate    `json:"request"`
	Outcomes    map[ResponseKind]StepID `json:"outcomes"`
	OnExpired   StepID                  `json:"on_expired"`
	OnCancelled StepID                  `json:"on_cancelled"`
	OnStale     StepID                  `json:"on_stale"`
}

type IdempotencyKey added in v1.0.0

type IdempotencyKey string

func ParseIdempotencyKey added in v1.0.0

func ParseIdempotencyKey(raw string) (IdempotencyKey, error)

func PublishedOperationIntentKey added in v1.0.0

func PublishedOperationIntentKey(scope BusinessScope, operationRef string, key IdempotencyKey) (IdempotencyKey, error)

PublishedOperationIntentKey derives the internal kernel retry key from the complete public operation intent. The raw caller key is never persisted as the kernel key or included in logs/URLs.

type IdentityAssertion

type IdentityAssertion struct {
	ProviderInstanceID string    `json:"provider_instance_id"`
	Issuer             string    `json:"issuer"`
	Subject            string    `json:"subject"`
	Email              string    `json:"email,omitempty"`
	EmailVerified      bool      `json:"email_verified"`
	FullName           string    `json:"full_name,omitempty"`
	Claims             []Claim   `json:"claims,omitempty"`
	AuthenticatedAt    time.Time `json:"authenticated_at"`
	Amr                string    `json:"amr,omitempty"`
	Acr                string    `json:"acr,omitempty"`
	SessionBinding     string    `json:"session_binding,omitempty"`
}

IdentityAssertion is the single normalized identity result every provider produces. ProviderInstanceID + Issuer + Subject form the canonical identity key; Email is a verification hint only, never a merge key.

type InboxView added in v1.0.0

type InboxView string
const (
	InboxAction    InboxView = "needs_action"
	InboxSent      InboxView = "sent"
	InboxWaiting   InboxView = "waiting"
	InboxCompleted InboxView = "completed"
)

type InformationResponse added in v1.0.0

type InformationResponse struct {
	SchemaID      string `json:"schema_id"`
	SchemaVersion uint32 `json:"schema_version"`
	//contract:json
	//contract:maxJSONBytes=65536
	Values json.RawMessage `json:"values"`
}

type InstalledPackage added in v1.0.0

type InstalledPackage struct {
	PackageID string            `json:"package_id"`
	ReleaseID string            `json:"release_id"`
	Version   string            `json:"version"`
	Digest    string            `json:"digest"`
	Requires  []ManifestPackRef `json:"requires,omitempty"`
	Conflicts []ManifestPackRef `json:"conflicts,omitempty"`
}

InstalledPackage preserves immutable package identity and composition constraints already checked before package resources were activated. It lives in the existing module snapshot rather than a second registry.

type InstanceID added in v1.0.0

type InstanceID string

func ParseInstanceID added in v1.0.0

func ParseInstanceID(raw string) (InstanceID, error)

type InstanceStatus added in v1.0.0

type InstanceStatus string
const (
	InstanceReady     InstanceStatus = "ready"
	InstanceRunning   InstanceStatus = "running"
	InstanceWaiting   InstanceStatus = "waiting"
	InstanceRetrying  InstanceStatus = "retrying"
	InstanceCompleted InstanceStatus = "completed"
	InstanceCancelled InstanceStatus = "cancelled"
	InstanceFailed    InstanceStatus = "failed"
	InstanceUncertain InstanceStatus = "outcome_unknown"
)

type InvitationDeliveryOutcome added in v1.0.0

type InvitationDeliveryOutcome string

InvitationDeliveryOutcome is an operator's verified provider finding after an SMTP result was uncertain. "not_delivered" authorizes a fresh link send.

const (
	InvitationDelivered    InvitationDeliveryOutcome = "delivered"
	InvitationNotDelivered InvitationDeliveryOutcome = "not_delivered"
)

type Layout

type Layout struct {
	Desktop int `json:"desktop"`
	Tablet  int `json:"tablet"`
	Mobile  int `json:"mobile"`
}

Layout records responsive column spans per breakpoint.

type LineEntryLayout added in v1.0.0

type LineEntryLayout struct {
	LinesPath     string            `json:"lines_path"`
	LookupQuery   string            `json:"lookup_query"`
	LookupInput   string            `json:"lookup_input"`
	ItemMap       map[string]string `json:"item_map"`
	QuantityField string            `json:"quantity_field"`
	AmountExpr    string            `json:"amount_expr,omitempty"`
	TotalOutput   string            `json:"total_output,omitempty"`
}

LineEntryLayout hints that an operation renders as search, add, adjust, submit.

func (LineEntryLayout) Validate added in v1.0.0

func (l LineEntryLayout) Validate(inputSchema, outputSchema json.RawMessage, lookupFields []string) error

Validate checks the hint against the operation schemas and the lookup query's published fields. Cross-module query resolution is the caller's job.

type LookupPublishedOperation added in v1.0.0

type LookupPublishedOperation struct {
	OperationRef   string         `json:"operation_ref"`
	IdempotencyKey IdempotencyKey `json:"idempotency_key"`
}

LookupPublishedOperation asks for a prior result without dispatching work.

func (LookupPublishedOperation) Validate added in v1.0.0

func (r LookupPublishedOperation) Validate() error

type ManagedChannelClientV2 added in v1.0.0

type ManagedChannelClientV2 struct {
	Name        string `json:"name"`
	AccessToken string `json:"access_token"`
	Warning     string `json:"warning"`
}

type ManagedOperation added in v1.0.0

type ManagedOperation struct {
	ID               OperationID    `json:"id"`
	Tenant           TenantID       `json:"tenant_id"`
	State            OperationState `json:"state"`
	ObservedRevision Revision       `json:"observed_revision,omitempty"`
	Error            *Error         `json:"error,omitempty"`
}

type ManagedSiteIdentityV2 added in v1.0.0

type ManagedSiteIdentityV2 struct {
	SiteID         string `json:"site_id"`
	Status         string `json:"status"`
	ConfigRevision uint64 `json:"config_revision"`
	Healthy        bool   `json:"healthy"`
}

type ManagementCapabilitiesV2 added in v1.0.0

type ManagementCapabilitiesV2 struct {
	Version       uint16                 `json:"version"`
	Capabilities  []ManagementCapability `json:"capabilities"`
	EngineVersion string                 `json:"engine_version,omitempty"`
}

ManagementCapabilitiesV2 is an authenticated, read-only projection of the management routes that the current Engine process has enabled.

type ManagementCapability added in v1.0.0

type ManagementCapability string

ManagementCapability names a durable operation route that this Engine has composed with its worker and authorization boundary.

const (
	ManagementCapabilityTenantProvision       ManagementCapability = "tenant.provision"
	ManagementCapabilityTenantProvisionRetry  ManagementCapability = "tenant.provision.reconcile"
	ManagementCapabilityTenantPackageApply    ManagementCapability = "tenant.package.apply"
	ManagementCapabilityTenantPackageRetry    ManagementCapability = "tenant.package.reconcile"
	ManagementCapabilityTenantStateSet        ManagementCapability = "tenant.state.set"
	ManagementCapabilityTenantStateRetry      ManagementCapability = "tenant.state.reconcile"
	ManagementCapabilityTenantDelete          ManagementCapability = "tenant.delete"
	ManagementCapabilityTenantDeleteRetry     ManagementCapability = "tenant.delete.reconcile"
	ManagementCapabilityTenantInvitation      ManagementCapability = "tenant.invitation.deliver"
	ManagementCapabilityTenantInvitationRetry ManagementCapability = "tenant.invitation.reconcile"
	ManagementCapabilityModuleLifecycle       ManagementCapability = "tenant.module.lifecycle"
	ManagementCapabilityTenantMemberPlan      ManagementCapability = "tenant.member.plan"
	ManagementCapabilityTenantMemberGrant     ManagementCapability = "tenant.member.grant"
	ManagementCapabilityTenantMemberRevoke    ManagementCapability = "tenant.member.revoke"
	ManagementCapabilityOperationRead         ManagementCapability = "operation.read"
)

type ManifestComponent added in v1.0.0

type ManifestComponent struct {
	ReleaseID string `json:"release_id"`
	Selection string `json:"selection"`
	Unlocks   string `json:"unlocks,omitempty"`
}

type ManifestEngine added in v1.0.0

type ManifestEngine struct {
	MinVersion string `json:"min_version"`
}

type ManifestExports added in v1.0.0

type ManifestExports struct {
	Doctypes     []string `json:"doctypes,omitempty"`
	Commands     []string `json:"commands,omitempty"`
	Events       []string `json:"events,omitempty"`
	Capabilities []string `json:"capabilities,omitempty"`
}

type ManifestPackRef added in v1.0.0

type ManifestPackRef struct {
	PackageID string `json:"package_id"`
	ReleaseID string `json:"release_id,omitempty"`
	Version   string `json:"version,omitempty"`
}

type ManifestPrice added in v1.0.0

type ManifestPrice struct {
	Mode        string `json:"mode"`
	PlanCode    string `json:"plan_code,omitempty"`
	Currency    string `json:"currency,omitempty"`
	AmountMinor int64  `json:"amount_minor,omitempty"`
	Period      string `json:"period,omitempty"`
}

type ManifestPublic added in v1.0.0

type ManifestPublic struct {
	Slug         string                     `json:"slug"`
	Name         string                     `json:"name"`
	Summary      string                     `json:"summary"`
	Category     string                     `json:"category,omitempty"`
	Audiences    []string                   `json:"audiences,omitempty"`
	Outcomes     []string                   `json:"outcomes,omitempty"`
	Requirements []string                   `json:"requirements,omitempty"`
	DetailPage   *TemplateDetailPageContent `json:"detail_page,omitempty"`
	Price        *ManifestPrice             `json:"price,omitempty"`
}

type ManifestStates

type ManifestStates struct {
	Loading string `json:"loading"`
	Empty   string `json:"empty"`
	Error   string `json:"error"`
	Offline string `json:"offline"`
}

ManifestStates declares the standard UI state rendering tokens.

type MarketplacePackageManifest added in v1.0.0

type MarketplacePackageManifest struct {
	SchemaVersion int                      `json:"schema_version"`
	PackageID     string                   `json:"package_id"`
	ReleaseID     string                   `json:"release_id"`
	Version       string                   `json:"version"`
	Kind          string                   `json:"kind"`
	Public        ManifestPublic           `json:"public"`
	Requires      []ManifestPackRef        `json:"requires,omitempty"`
	Exports       ManifestExports          `json:"exports,omitempty"`
	Conflicts     []ManifestPackRef        `json:"conflicts,omitempty"`
	Composition   []ManifestComponent      `json:"composition,omitempty"`
	Modules       []ModuleDescriptor       `json:"modules,omitempty"`
	ScheduledJobs []ScheduledJobDefinition `json:"scheduled_jobs,omitempty"`
	Engine        ManifestEngine           `json:"engine"`
}

MarketplacePackageManifest is the immutable marketplace manifest shared by Cloud and Engine. Storage keys, review state, and timestamps belong to Cloud records.

func DecodeMarketplacePackageManifest added in v1.0.0

func DecodeMarketplacePackageManifest(data []byte) (MarketplacePackageManifest, error)

DecodeMarketplacePackageManifest strictly decodes the immutable package contract.

type ModuleAccess added in v1.0.0

type ModuleAccess string

type ModuleBlocker added in v1.0.0

type ModuleBlocker struct {
	Code     string   `json:"code"`
	Count    uint32   `json:"count"`
	Examples []string `json:"examples,omitempty"`
}

ModuleBlocker is deliberately small and excludes business payloads.

type ModuleChangePlan added in v1.0.0

type ModuleChangePlan struct {
	ModuleID           ModuleID             `json:"module_id"`
	TargetState        ModuleLifecycleState `json:"target_state"`
	TargetVersion      string               `json:"target_version,omitempty"`
	ProviderSelections []ProviderSelection  `json:"provider_selections,omitempty"`
	PlanHash           string               `json:"plan_hash"`
	BaseRevision       uint64               `json:"base_revision"`
	DependencyBlockers []ModuleBlocker      `json:"dependency_blockers,omitempty"`
	OpenWorkBlockers   []ModuleBlocker      `json:"open_work_blockers,omitempty"`
	BindingChanges     []string             `json:"binding_changes,omitempty"`
}

ModuleChangePlan carries bounded reasons why an operation cannot proceed.

type ModuleDescriptor added in v1.0.0

type ModuleDescriptor struct {
	ID                  ModuleID                `json:"id"`
	Version             string                  `json:"version"`
	Schemas             []ModuleSchemaDocument  `json:"schemas,omitempty"`
	Resources           []OwnedResource         `json:"resources,omitempty"`
	Queries             []PublishedQuery        `json:"queries,omitempty"`
	PublishedOperations []PublishedOperation    `json:"published_operations,omitempty"`
	Projections         []ProjectionDefinition  `json:"projections,omitempty"`
	Provides            []CapabilityOffer       `json:"provides,omitempty"`
	Requires            []CapabilityRequirement `json:"requires,omitempty"`
	ExtensionPoints     []ExtensionPoint        `json:"extension_points,omitempty"`
	Extensions          []ExtensionRegistration `json:"extensions,omitempty"`
}

ModuleDescriptor is the canonical package level business module contract.

func (ModuleDescriptor) OwnerOf added in v1.0.0

func (m ModuleDescriptor) OwnerOf(ref ResourceRef) (OwnedResource, bool)

func (ModuleDescriptor) Validate added in v1.0.0

func (m ModuleDescriptor) Validate(registeredSchema func(SchemaRef) bool) error

type ModuleExecution added in v1.0.0

type ModuleExecution struct {
	TenantID          TenantID
	CallerModuleID    ModuleID
	OwnerModuleID     ModuleID
	BindingRevision   uint64
	AllowedOperation  string
	AuthorizedCommand string
	Scope             BusinessScope
	// contains filtered or unexported fields
}

ModuleExecution is trusted in-process provenance minted by module dispatch. It must never be decoded from a user request.

func NewCommandModuleExecution added in v1.0.0

func NewCommandModuleExecution(scope BusinessScope, caller, owner ModuleID, revision uint64, command, operation string) (ModuleExecution, error)

func NewModuleExecution added in v1.0.0

func NewModuleExecution(scope BusinessScope, caller, owner ModuleID, revision uint64, operation string) (ModuleExecution, error)

func (ModuleExecution) Verified added in v1.0.0

func (e ModuleExecution) Verified() bool

func (ModuleExecution) WithWorkflowCommandPin added in v1.0.0

func (e ModuleExecution) WithWorkflowCommandPin(instance InstanceID, step StepID, key IdempotencyKey) (ModuleExecution, error)

func (ModuleExecution) WorkflowCommandPin added in v1.0.0

func (e ModuleExecution) WorkflowCommandPin() (WorkflowCommandPin, bool)

type ModuleID added in v1.0.0

type ModuleID string

ModuleID identifies a durable business ownership boundary. It is independent of package identity, tenant identity, and ResourceRef namespace.

type ModuleInspection added in v1.0.0

type ModuleInspection struct {
	ConfigRevision         uint64                 `json:"config_revision"`
	Installations          []ModuleInstallation   `json:"installations"`
	ResourceOwners         []ResourceOwnership    `json:"resource_owners"`
	Bindings               []BindingInspection    `json:"bindings"`
	CapabilityAvailability []CapabilityInspection `json:"capability_availability"`
	BlockingReasons        []ModuleBlocker        `json:"blocking_reasons"`
	PendingWork            PendingWorkSummary     `json:"pending_work"`
}

ModuleInspection is a redacted, tenant scoped runtime status projection.

type ModuleInstallation added in v1.0.0

type ModuleInstallation struct {
	TenantID                 TenantID    `json:"tenant_id"`
	ModuleID                 ModuleID    `json:"module_id"`
	Version                  string      `json:"version"`
	ArtifactDigest           string      `json:"artifact_digest"`
	State                    string      `json:"state"`
	Revision                 uint64      `json:"revision"`
	StateChangedAt           time.Time   `json:"state_changed_at,omitempty"`
	LastLifecycleOperationID OperationID `json:"last_lifecycle_operation_id,omitempty"`
}

ModuleInstallation is the persisted lifecycle identity for one tenant module.

type ModuleLifecycleState added in v1.0.0

type ModuleLifecycleState string
const (
	ModuleInstalled ModuleLifecycleState = "installed"
	ModuleActive    ModuleLifecycleState = "active"
	ModuleDraining  ModuleLifecycleState = "draining"
	ModuleDisabled  ModuleLifecycleState = "disabled"
	ModuleRemoved   ModuleLifecycleState = "removed"
)

type ModuleSchemaDocument added in v1.0.0

type ModuleSchemaDocument struct {
	Ref SchemaRef `json:"ref"`
	//contract:maxJSONBytes=65536
	//contract:json
	Schema json.RawMessage `json:"schema"`
}

ModuleSchemaDocument is the bounded JSON Schema document published by a module for its explicitly referenced client surfaces.

type ModuleSnapshot added in v1.0.0

type ModuleSnapshot struct {
	TenantID           TenantID             `json:"tenant_id"`
	Revision           uint64               `json:"revision"`
	Modules            []ModuleDescriptor   `json:"modules,omitempty"`
	Packages           []InstalledPackage   `json:"packages,omitempty"`
	Installations      []ModuleInstallation `json:"installations"`
	Ownership          []ResourceOwnership  `json:"ownership"`
	ProviderSelections []ProviderSelection  `json:"provider_selections,omitempty"`
}

ModuleSnapshot is a complete candidate/published ownership state.

type ModuleStore added in v1.0.0

type ModuleStore interface {
	Load(tenant TenantID) (ModuleSnapshot, error)
	CommitProviderSelections(ctx context.Context, tenant TenantID, expectedRevision uint64, selections []ProviderSelection) (ModuleSnapshot, error)
}

ModuleStore is the persistence boundary used by activation. CommitActivation must atomically compare and increment the snapshot revision with the caller's activation transaction.

type MutationMode added in v1.0.0

type MutationMode string

type ObservationReport

type ObservationReport struct {
	RuntimeID  string                 `json:"runtime_id"`
	TenantID   string                 `json:"tenant_id"`
	Generation int                    `json:"generation"`
	Components []ComponentObservation `json:"components"`
	ReportedAt time.Time              `json:"reported_at"`
	Signature  []byte                 `json:"signature,omitempty"`
}

ObservationReport is an authenticated, runtime-authored batch of component observations. Signature covers the canonical report body (excluding the Signature field); verification happens at the ingestion boundary.

type ObservationStatus

type ObservationStatus string

ObservationStatus is the runtime-reported health of a component.

const (
	ObservationHealthy  ObservationStatus = "healthy"
	ObservationDegraded ObservationStatus = "degraded"
	ObservationFailed   ObservationStatus = "failed"
	ObservationWaiting  ObservationStatus = "waiting"
)

type OfflineBootstrapRequest added in v1.0.0

type OfflineBootstrapRequest struct {
	Source          OfflineSourceRef `json:"source"`
	BusinessScope   BusinessScope    `json:"business_scope"`
	CatalogRevision uint64           `json:"catalog_revision"`
	Limit           uint16           `json:"limit"`
	SnapshotToken   string           `json:"snapshot_token,omitempty"`
	PageCursor      string           `json:"page_cursor,omitempty"`
	InputHash       string           `json:"input_hash,omitempty"`
}

type OfflineCapabilities added in v1.0.0

type OfflineCapabilities struct {
	ProtocolVersion         uint16                        `json:"protocol_version"`
	CatalogRevision         uint64                        `json:"catalog_revision"`
	MaxBatchSize            uint16                        `json:"max_batch_size"`
	MaxPageSize             uint16                        `json:"max_page_size"`
	SnapshotLifetimeSeconds uint32                        `json:"snapshot_lifetime_seconds"`
	OfflineQueries          []ApplicationCatalogQuery     `json:"offline_queries"`
	OfflineOperations       []ApplicationCatalogOperation `json:"offline_operations"`
}

OfflineCapabilities describes server bounds and the current catalog revision.

func (OfflineCapabilities) Validate added in v1.0.0

func (c OfflineCapabilities) Validate() error

type OfflineChange added in v1.0.0

type OfflineChange struct {
	FactKey string `json:"fact_key"`
	Deleted bool   `json:"deleted"`
	//contract:json
	Data json.RawMessage `json:"data,omitempty"`
}

OfflineChange carries a complete published row replacement or an explicit deletion for its stable owner fact key.

type OfflineConflict

type OfflineConflict struct {
	ID             string    `json:"id"`
	OperationID    string    `json:"operation_id"`
	DeviceID       string    `json:"device_id"`
	BranchID       string    `json:"branch_id"`
	Site           string    `json:"site"`
	EntityType     string    `json:"entity_type"`
	EntityID       string    `json:"entity_id,omitempty"`
	ReasonCode     Code      `json:"reason_code"`
	ResolutionMode string    `json:"resolution_mode"`
	ServerVersion  int       `json:"server_version"`
	RecordedAt     time.Time `json:"recorded_at"`
	//contract:json
	Snapshot json.RawMessage `json:"snapshot,omitempty"`
}

OfflineConflict captures a rejected or stale operation and the server-side reason that must stay auditable.

type OfflineIntent added in v1.0.0

type OfflineIntent struct {
	LocalOperationID string        `json:"local_operation_id"`
	BusinessScope    BusinessScope `json:"business_scope"`
	OperationRef     string        `json:"operation_ref"`
	InputSchema      SchemaRef     `json:"input_schema"`
	//contract:maxJSONBytes=1048576
	//contract:json
	Input            json.RawMessage `json:"input"`
	IdempotencyKey   IdempotencyKey  `json:"idempotency_key"`
	ExpectedRevision Revision        `json:"expected_revision,omitempty"`
	CatalogRevision  uint64          `json:"catalog_revision"`
}

OfflineIntent is a durable request to execute one explicitly published domain operation. Its stable identity must be retained by the client until Engine returns a terminal receipt.

func (OfflineIntent) Validate added in v1.0.0

func (i OfflineIntent) Validate() error

type OfflineIntentReceipt added in v1.0.0

type OfflineIntentReceipt struct {
	LocalOperationID string           `json:"local_operation_id"`
	Receipt          OperationReceipt `json:"receipt"`
}

OfflineIntentReceipt binds the client's stable local ID to Engine's authoritative operation receipt.

type OfflineIntentsRequest added in v1.0.0

type OfflineIntentsRequest struct {
	Intents []OfflineIntent `json:"intents"`
}

OfflineIntentsRequest is a bounded batch; each item is independently authorized and durably receipted through the published operation service.

type OfflineIntentsResponse added in v1.0.0

type OfflineIntentsResponse struct {
	Receipts []OfflineIntentReceipt `json:"receipts"`
}

type OfflineOperation

type OfflineOperation struct {
	ID            string                 `json:"id"`
	DeviceID      string                 `json:"device_id"`
	BranchID      string                 `json:"branch_id"`
	Site          string                 `json:"site"`
	EntityType    string                 `json:"entity_type"`
	EntityID      string                 `json:"entity_id,omitempty"`
	OperationType string                 `json:"operation_type"`
	BaseVersion   int                    `json:"base_version"`
	OccurredAt    time.Time              `json:"occurred_at"`
	SchemaVersion string                 `json:"schema_version"`
	Status        OfflineOperationStatus `json:"status"`
	//contract:json
	Payload  json.RawMessage   `json:"payload,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

OfflineOperation records one device/branch operation for later sync.

type OfflineOperationStatus

type OfflineOperationStatus string

OfflineOperationStatus is the local and server-side lifecycle of an offline operation. The RFC requires rejected operations to remain visible as conflict records rather than disappear.

const (
	OfflineOperationQueued    OfflineOperationStatus = "queued"
	OfflineOperationSent      OfflineOperationStatus = "sent"
	OfflineOperationAcked     OfflineOperationStatus = "acked"
	OfflineOperationConflict  OfflineOperationStatus = "conflict"
	OfflineOperationRejected  OfflineOperationStatus = "rejected"
	OfflineOperationDiscarded OfflineOperationStatus = "discarded"
)

type OfflinePullPage

type OfflinePullPage struct {
	Operations []OfflineOperation `json:"operations"`
	Cursor     SyncCursor         `json:"cursor"`
	NextCursor SyncCursor         `json:"next_cursor"`
}

OfflinePullPage is a repeatable page of operations and the cursor that should be used to continue from the last returned item.

func PullSince

func PullSince(ops []OfflineOperation, cursor SyncCursor) OfflinePullPage

PullSince returns a repeatable page of operations after the provided cursor.

type OfflinePullRequest added in v1.0.0

type OfflinePullRequest struct {
	Source          OfflineSourceRef `json:"source"`
	BusinessScope   BusinessScope    `json:"business_scope"`
	CatalogRevision uint64           `json:"catalog_revision"`
	SnapshotToken   string           `json:"snapshot_token"`
	InputHash       string           `json:"input_hash"`
	ReplayPosition  string           `json:"replay_position"`
	ThroughCursor   string           `json:"through_cursor,omitempty"`
	PageCursor      string           `json:"page_cursor,omitempty"`
	Limit           uint16           `json:"limit"`
}

type OfflinePullResponse added in v1.0.0

type OfflinePullResponse struct {
	Source          OfflineSourceRef `json:"source"`
	InputHash       string           `json:"input_hash"`
	BusinessScope   BusinessScope    `json:"business_scope"`
	SubjectID       string           `json:"subject_id"`
	SchemaRevision  SchemaRef        `json:"schema_revision"`
	CatalogRevision uint64           `json:"catalog_revision"`
	SnapshotToken   string           `json:"snapshot_token"`
	ReplayPosition  string           `json:"replay_position"`
	ThroughCursor   string           `json:"through_cursor"`
	NextPageCursor  string           `json:"next_page_cursor,omitempty"`
	Changes         []OfflineChange  `json:"changes"`
	HasMore         bool             `json:"has_more"`
}

type OfflineReceipt

type OfflineReceipt struct {
	OperationID string                 `json:"operation_id"`
	Status      OfflineOperationStatus `json:"status"`
	Conflict    *OfflineConflict       `json:"conflict,omitempty"`
	ReceivedAt  time.Time              `json:"received_at"`
	NextCursor  SyncCursor             `json:"next_cursor"`
}

OfflineReceipt is the acknowledgement returned by the central intake.

type OfflineSchemaGate

type OfflineSchemaGate string

OfflineSchemaGate records whether a client schema bundle is accepted.

const (
	OfflineSchemaGateAccepted OfflineSchemaGate = "accepted"
	OfflineSchemaGateRejected OfflineSchemaGate = "rejected"
	OfflineSchemaGateStale    OfflineSchemaGate = "stale"
)

type OfflineSnapshotPage added in v1.0.0

type OfflineSnapshotPage struct {
	Source          OfflineSourceRef `json:"source"`
	FactKeyField    string           `json:"fact_key_field"`
	InputHash       string           `json:"input_hash"`
	BusinessScope   BusinessScope    `json:"business_scope"`
	SubjectID       string           `json:"subject_id"`
	SchemaRevision  SchemaRef        `json:"schema_revision"`
	CatalogRevision uint64           `json:"catalog_revision"`
	SnapshotToken   string           `json:"snapshot_token"`
	PageCursor      string           `json:"page_cursor,omitempty"`
	NextPageCursor  string           `json:"next_page_cursor,omitempty"`
	ReplayPosition  string           `json:"replay_position"`
	//contract:json
	Rows     json.RawMessage `json:"rows"`
	Complete bool            `json:"complete"`
}

OfflineSnapshotPage binds result pages and the first replay position to the same actor, scope, query input and catalog revision.

func (OfflineSnapshotPage) Validate added in v1.0.0

func (p OfflineSnapshotPage) Validate(query PublishedQuery, limit uint16, scope BusinessScope) error

type OfflineSourceRef added in v1.0.0

type OfflineSourceRef struct {
	OwnerModuleID ModuleID  `json:"owner_module_id"`
	QueryName     string    `json:"query_name"`
	InputSchema   SchemaRef `json:"input_schema"`
	//contract:maxJSONBytes=65536
	//contract:json
	Input json.RawMessage `json:"input"`
}

OfflineSourceRef selects one owner-published query. Input is validated by that query's registered schema; actor and entity restrictions come from the authenticated request and Engine policy.

type OfflineStore

type OfflineStore interface {
	SaveOperation(OfflineOperation) error
	SaveConflict(OfflineConflict) error
	SaveTombstone(OfflineTombstone) error
	AdvanceCursor(SyncCursor) error
}

OfflineStore is the minimal persistence surface for the reference sync service. Implementations can back it with SQL, an embedded cache, or a test double.

type OfflineSyncBatch

type OfflineSyncBatch struct {
	SchemaVersion string             `json:"schema_version"`
	Gate          OfflineSchemaGate  `json:"gate"`
	Operations    []OfflineOperation `json:"operations"`
	Conflicts     []OfflineConflict  `json:"conflicts,omitempty"`
	Cursor        SyncCursor         `json:"cursor"`
	NextCursor    SyncCursor         `json:"next_cursor,omitempty"`
}

OfflineSyncBatch groups operations under one schema gate result.

type OfflineSyncService

type OfflineSyncService struct {
	Store OfflineStore
	Clock func() time.Time
}

OfflineSyncService coordinates local apply, intake, and acknowledgement.

func (OfflineSyncService) Acknowledge

func (s OfflineSyncService) Acknowledge(op OfflineOperation, cursor SyncCursor, conflict *OfflineConflict) error

Acknowledge advances the cursor for a confirmed operation and optionally stores the resulting conflict if the operation was rejected upstream.

func (OfflineSyncService) ApplyLocal

func (s OfflineSyncService) ApplyLocal(op OfflineOperation) error

ApplyLocal records a device/branch operation locally and preserves audit visibility before the batch is sent upstream.

func (OfflineSyncService) Intake

Intake applies a batch at the central site. Accepted operations are acknowledged with a monotonic cursor advance. Rejected operations become conflict records and remain retryable or manually reviewable.

type OfflineTombstone

type OfflineTombstone struct {
	ID            string    `json:"id"`
	DeviceID      string    `json:"device_id"`
	BranchID      string    `json:"branch_id"`
	Site          string    `json:"site"`
	EntityType    string    `json:"entity_type"`
	EntityID      string    `json:"entity_id"`
	DeletedAt     time.Time `json:"deleted_at"`
	RetainUntil   time.Time `json:"retain_until"`
	SchemaVersion string    `json:"schema_version"`
}

OfflineTombstone records a retained delete marker. Tombstones remain visible for the supported offline window so deletes can be replayed, retried, and rejected deterministically.

func PruneExpiredTombstones

func PruneExpiredTombstones(tombstones []OfflineTombstone, now time.Time) []OfflineTombstone

PruneExpiredTombstones removes tombstones that have aged past their retention window so GC can keep the retained delete set bounded.

type OpenWorkCoverageInspector added in v1.0.0

type OpenWorkCoverageInspector interface {
	OpenWorkDomains() []string
	OpenWorkInspector
}

type OpenWorkDomainInspector added in v1.0.0

type OpenWorkDomainInspector interface {
	OpenWorkDomain() string
	OpenWorkInspector
}

OpenWorkDomainInspector declares which lifecycle work category it covers. Registration is explicit so one adapter cannot accidentally stand in for unrelated owner work such as obligations or event delivery.

type OpenWorkInspector added in v1.0.0

type OpenWorkInspector interface {
	InspectOpenWork(context.Context, TenantID, ModuleID, uint16) ([]ModuleBlocker, error)
}

type OperationAvailability added in v1.0.0

type OperationAvailability string
const (
	OperationAvailable   OperationAvailability = "available"
	OperationUnavailable OperationAvailability = "unavailable"
	OperationDisabled    OperationAvailability = "disabled"
	OperationDraining    OperationAvailability = "draining"
)

type OperationContext

type OperationContext struct {
	Site     string
	Actor    string
	TraceID  string
	Deadline time.Time
	Scope    BusinessScope
}

OperationContext is the minimal, explicit execution context for capability issuance. It is distinct from the kernel's richer OperationContext; the kernel adapts its context into this shape at the capability boundary.

type OperationEffect added in v1.0.0

type OperationEffect string

type OperationID added in v1.0.0

type OperationID string

func ParseOperationID added in v1.0.0

func ParseOperationID(raw string) (OperationID, error)

type OperationReceipt added in v1.0.0

type OperationReceipt struct {
	ExecutionID   OperationID            `json:"execution_id"`
	OperationRef  string                 `json:"operation_ref"`
	BusinessScope BusinessScope          `json:"business_scope"`
	Status        OperationReceiptStatus `json:"status"`
	OutputSchema  *SchemaRef             `json:"output_schema,omitempty"`
	//contract:maxJSONBytes=1048576
	//contract:json
	Output        json.RawMessage `json:"output,omitempty"`
	Error         *Error          `json:"error,omitempty"`
	CorrelationID string          `json:"correlation_id,omitempty"`
	Revision      string          `json:"revision"`
}

OperationReceipt reports one registered operation attempt. Transport status does not determine this business outcome.

func (OperationReceipt) Validate added in v1.0.0

func (r OperationReceipt) Validate() error

type OperationReceiptStatus added in v1.0.0

type OperationReceiptStatus string
const (
	ReceiptAccepted       OperationReceiptStatus = "accepted"
	ReceiptRunning        OperationReceiptStatus = "running"
	ReceiptCompleted      OperationReceiptStatus = "completed"
	ReceiptRejected       OperationReceiptStatus = "rejected"
	ReceiptConflict       OperationReceiptStatus = "conflict"
	ReceiptFailed         OperationReceiptStatus = "failed"
	ReceiptOutcomeUnknown OperationReceiptStatus = "outcome_unknown"
)

type OperationSpec added in v1.0.0

type OperationSpec struct {
	Name   string          `json:"name"`
	Input  SchemaRef       `json:"input"`
	Output SchemaRef       `json:"output"`
	Effect OperationEffect `json:"effect"`
}

type OperationState added in v1.0.0

type OperationState string
const (
	OperationRequested        OperationState = "requested"
	OperationRunning          OperationState = "running"
	OperationSucceeded        OperationState = "succeeded"
	OperationFailed           OperationState = "failed"
	OperationRecoveryRequired OperationState = "recovery_required"
)

type OwnedResource added in v1.0.0

type OwnedResource struct {
	Ref          ResourceRef       `json:"ref"`
	Access       ModuleAccess      `json:"access"`
	MutationMode MutationMode      `json:"mutation_mode"`
	ScopeKind    ResourceScopeKind `json:"scope_kind"`
	ScopeField   string            `json:"scope_field,omitempty"`
}

type PKCEVerifier

type PKCEVerifier struct {
	CodeVerifier  string
	CodeChallenge string
	Method        string // "S256"
}

PKCEVerifier carries the proof-of-key code exchange material for OAuth2 authorization-code flows. CodeVerifier is the client secret; CodeChallenge is the S256-transformed value sent in the authorization request.

type PackFile added in v1.0.0

type PackFile struct {
	Path string `json:"path"`
	//contract:maxBytes=262144
	Content     string `json:"content"`
	ContentType string `json:"content_type"`
}

type PackFinding added in v1.0.0

type PackFinding struct {
	Code     string `json:"code"`
	Severity string `json:"severity"`
	Path     string `json:"path,omitempty"`
	Message  string `json:"message"`
}

type PackManifest added in v1.0.0

type PackManifest struct {
	SchemaVersion int                      `json:"schema_version"`
	Name          string                   `json:"name"`
	Version       string                   `json:"version"`
	Requires      []ManifestPackRef        `json:"requires,omitempty"`
	Conflicts     []ManifestPackRef        `json:"conflicts,omitempty"`
	Exports       ManifestExports          `json:"exports"`
	ScheduledJobs []ScheduledJobDefinition `json:"scheduled_jobs,omitempty"`
	Modules       []ModuleDescriptor       `json:"modules,omitempty"`
}

PackManifest is the Engine-validation projection of MarketplacePackageManifest.

func MarketplacePackManifest added in v1.0.0

func MarketplacePackManifest(m MarketplacePackageManifest) PackManifest

MarketplacePackManifest projects the canonical marketplace declaration into the Engine package validation contract. Keep this as the sole projection so validation and activation cannot drift as PackManifest evolves.

type PackValidation added in v1.0.0

type PackValidation struct {
	Valid    bool          `json:"valid"`
	Findings []PackFinding `json:"findings"`
}

type PackageComposition added in v1.0.0

type PackageComposition struct {
	Base     ResourceRef   `json:"base"`
	Packages []ResourceRef `json:"packages,omitempty"`
	Plugins  []ResourceRef `json:"plugins,omitempty"`
	Profiles []ResourceRef `json:"profiles,omitempty"`
	Patches  []ResourceRef `json:"patches,omitempty"`
}

type PackageDependency added in v1.0.0

type PackageDependency struct {
	PackageID string `json:"package_id"`
	ReleaseID string `json:"release_id,omitempty"`
	Version   string `json:"version,omitempty"`
	Required  bool   `json:"required"`
}

PackageDependency preserves immutable package requirements and conflicts.

type PackageManifest added in v1.0.0

type PackageManifest struct {
	Ref         ResourceRef   `json:"ref"`
	Provides    []ResourceRef `json:"provides,omitempty"`
	Requires    []ResourceRef `json:"requires,omitempty"`
	Permissions []string      `json:"permissions,omitempty"`
	Migrations  []string      `json:"migrations,omitempty"`
	Cleanup     []string      `json:"cleanup,omitempty"`
}

type Page added in v1.0.0

type Page[T any] struct {
	Items      []T        `json:"items"`
	NextCursor PageCursor `json:"next_cursor,omitempty"`
}

Page is a bounded keyset-paginated result. It is a Go helper; concrete HTTP responses are declared and generated as named wire types when endpoints are added, so the generic type is deliberately not a schema root.

type PageCursor added in v1.0.0

type PageCursor string

PageCursor is an opaque cursor for new paginated APIs. Cursor remains the existing structured stream/sync cursor for wire compatibility.

type PageManifest

type PageManifest struct {
	SchemaVersion string         `json:"schema_version"`
	Page          string         `json:"page"`
	Title         string         `json:"title"`
	Regions       []Region       `json:"regions"`
	States        ManifestStates `json:"states"`
}

PageManifest is the pure-data description of one page.

func LoadPageManifestJSON

func LoadPageManifestJSON(data []byte) (*PageManifest, error)

LoadPageManifestJSON decodes a manifest strictly (unknown fields rejected) and validates it.

func (PageManifest) Validate

func (m PageManifest) Validate() error

Validate checks required fields, block kinds, and action commands. It returns the first failure as a typed *ErrUIManifestInvalid.

type PageRequest added in v1.0.0

type PageRequest struct {
	Cursor PageCursor `json:"cursor,omitempty"`
	//contract:min=1
	//contract:max=100
	Limit uint16 `json:"limit"`
}

PageRequest is a bounded, stable-order page query.

type PatchOperation added in v1.0.0

type PatchOperation struct {
	Path  string `json:"path"`
	Op    string `json:"op"`
	Value any    `json:"value,omitempty"`
}

type PaymentOperationContract added in v1.0.0

type PaymentOperationContract struct {
	SourceDoctype  string `json:"source_doctype"`
	LinesField     string `json:"lines_field"`
	ReferenceField string `json:"reference_field"`
	AmountField    string `json:"amount_field"`
	CurrencyField  string `json:"currency_field"`
}

PaymentOperationContract publishes the payment binding of a payment-guarded operation: the record payment intents are made for and the input fields that carry the payment lines.

func (PaymentOperationContract) Validate added in v1.0.0

func (c PaymentOperationContract) Validate(inputSchema json.RawMessage) error

Validate checks the binding against the operation input schema.

type PendingWorkSummary added in v1.0.0

type PendingWorkSummary struct {
	WorkflowCount       uint32 `json:"workflow_count"`
	DeliveryCount       uint32 `json:"delivery_count"`
	UnknownOutcomeCount uint32 `json:"unknown_outcome_count"`
	ScheduledCount      uint32 `json:"scheduled_count"`
	OpenObligationCount uint32 `json:"open_obligation_count"`
}

PendingWorkSummary provides counts only.

type PermissionGrant added in v1.0.0

type PermissionGrant struct {
	Doctype string `json:"doctype"`
	Role    string `json:"role"`
	Read    bool   `json:"read"`
	Write   bool   `json:"write"`
	Create  bool   `json:"create"`
	Delete  bool   `json:"delete"`
	Submit  bool   `json:"submit"`
	Cancel  bool   `json:"cancel"`
	Amend   bool   `json:"amend"`
	Export  bool   `json:"export"`
	Import  bool   `json:"import"`
	Report  bool   `json:"report"`
	IfOwner bool   `json:"if_owner"`
}

PermissionGrant is the stable JSON permission projection accepted when a managed channel session is issued. Engine converts this wire value into its internal authorization model at the HTTP boundary.

type PinnedDispatch added in v1.0.0

type PinnedDispatch struct {
	ExecutionID      string           `json:"execution_id"`
	Scope            BusinessScope    `json:"scope"`
	CallerModuleID   ModuleID         `json:"caller_module_id"`
	ProviderModuleID ModuleID         `json:"provider_module_id,omitempty"`
	ProviderID       string           `json:"provider_id"`
	BindingRevision  uint64           `json:"binding_revision"`
	Operation        CapabilityAction `json:"operation"`
	IdempotencyKey   IdempotencyKey   `json:"idempotency_key"`
	InputHash        string           `json:"input_hash"`
}

PinnedDispatch records provider and operation identity before an effect attempt.

func (PinnedDispatch) Validate added in v1.0.0

func (d PinnedDispatch) Validate() error

type PlanModuleChange added in v1.0.0

type PlanModuleChange struct {
	ModuleID           ModuleID             `json:"module_id"`
	TargetState        ModuleLifecycleState `json:"target_state"`
	TargetVersion      string               `json:"target_version,omitempty"`
	ProviderSelections []ProviderSelection  `json:"provider_selections,omitempty"`
	ExpectedRevision   uint64               `json:"expected_revision"`
}

PlanModuleChange is the optimistic input to lifecycle planning.

type PlanTenantMember added in v1.0.0

type PlanTenantMember struct {
	Meta CommandMeta `json:"meta"`
	//contract:minLength=3
	//contract:maxLength=254
	//contract:maxBytes=254
	Email string `json:"email"`
	// Roles holds exactly one tenant role name in M1.
	//contract:minItems=1
	//contract:maxItems=1
	Roles []string `json:"roles"`
}

PlanTenantMember asks the Engine whether a Cloud invitation may later grant this email the requested tenant roles. Tenant identity comes from the authenticated management route. Planning has no durable effect.

type PluginService added in v1.0.0

type PluginService struct {
	Name        string       `json:"name"`
	Provider    ResourceRef  `json:"provider"`
	Scope       ServiceScope `json:"scope"`
	Permissions []string     `json:"permissions,omitempty"`
	Cleanup     []string     `json:"cleanup,omitempty"`
}

type PolicyDecision added in v1.0.0

type PolicyDecision string
const (
	PolicyAllow   PolicyDecision = "allow"
	PolicyDeny    PolicyDecision = "deny"
	PolicyApprove PolicyDecision = "requires_approval"
)

type PolicyEvaluation added in v1.0.0

type PolicyEvaluation struct {
	Decision    PolicyDecision `json:"decision"`
	Capability  ResourceRef    `json:"capability"`
	Actor       ActorContext   `json:"actor"`
	Policy      ResourceRef    `json:"policy,omitempty"`
	Reason      string         `json:"reason,omitempty"`
	EvaluatedAt time.Time      `json:"evaluated_at"`
}

PolicyEvaluation is safe to persist as provenance for an operation.

type PrincipalID added in v1.0.0

type PrincipalID string

func ParsePrincipalID added in v1.0.0

func ParsePrincipalID(raw string) (PrincipalID, error)

type PrincipalType

type PrincipalType string

PrincipalType classifies the kind of authenticated principal carrying out an operation. ai-assistant, mcp-agent, and similar strings are not implicit users, roles, or owners; they are always resolved to a typed principal.

const (
	PrincipalHuman   PrincipalType = "human"
	PrincipalService PrincipalType = "service"
	PrincipalAgent   PrincipalType = "agent"
	PrincipalPublic  PrincipalType = "public"
)

type Profile added in v1.0.0

type Profile struct {
	Ref          ResourceRef   `json:"ref"`
	Packages     []ResourceRef `json:"packages,omitempty"`
	Capabilities []ResourceRef `json:"capabilities,omitempty"`
}

type Projection

type Projection string

Projection is the consumer-approved data projection that an event payload may carry (RFC §8.3). Full documents and old-document snapshots are restricted to explicitly authorized audit or rebuild consumers.

const (
	ProjectionMetadata      Projection = "metadata"
	ProjectionChangedFields Projection = "changed_fields"
	ProjectionSummary       Projection = "summary"
	ProjectionFullDocument  Projection = "full_document"
)

type ProjectionCheckpoint added in v1.0.0

type ProjectionCheckpoint struct {
	ProjectionID string        `json:"projection_id"`
	TenantID     TenantID      `json:"tenant_id"`
	EntityScope  BusinessScope `json:"entity_scope"`
	SourceID     string        `json:"source_id"`
	Cursor       string        `json:"cursor"`
	UpdatedAt    time.Time     `json:"updated_at"`
}

ProjectionCheckpoint resumes projection replay from one source and scope.

func (ProjectionCheckpoint) Validate added in v1.0.0

func (p ProjectionCheckpoint) Validate() error

type ProjectionDefinition added in v1.0.0

type ProjectionDefinition struct {
	ID            string             `json:"id"`
	OwnerModuleID ModuleID           `json:"owner_module_id"`
	Sources       []ProjectionSource `json:"sources"`
	ScopePolicy   ResourceScopeKind  `json:"scope_policy"`
	FactKey       string             `json:"fact_key"`
	OwnerField    string             `json:"owner_field,omitempty"`
	AllowedFields []string           `json:"allowed_fields"`
	OutputSchema  SchemaRef          `json:"output_schema"`
	// consistent_snapshot requires every source to return the same non-empty
	// global snapshot token and as-of instant. Each paginated cursor must stay
	// pinned to that immutable snapshot; providers unable to prove that complete
	// cross-source boundary are unavailable for rebuild.
	RebuildStrategy string `json:"rebuild_strategy"`
}

ProjectionDefinition declares a rebuildable, owner-controlled projection.

func (ProjectionDefinition) Validate added in v1.0.0

func (p ProjectionDefinition) Validate() error

type ProjectionSource added in v1.0.0

type ProjectionSource struct {
	OwnerModuleID ModuleID  `json:"owner_module_id"`
	QueryName     string    `json:"query_name"`
	OutputSchema  SchemaRef `json:"output_schema"`
}

ProjectionSource pins one projection input to a published query contract.

type ProvenanceRecord added in v1.0.0

type ProvenanceRecord struct {
	ID         string        `json:"id"`
	Resource   ResourceRef   `json:"resource"`
	Inputs     []ResourceRef `json:"inputs,omitempty"`
	Rule       ResourceRef   `json:"rule,omitempty"`
	Actor      ActorContext  `json:"actor"`
	Capability ResourceRef   `json:"capability,omitempty"`
	Output     string        `json:"output,omitempty"`
	EventID    string        `json:"event_id"`
	RecordedAt time.Time     `json:"recorded_at"`
}

type ProviderFamily

type ProviderFamily string

ProviderFamily classifies a sign-in provider family. Families are advertised by capability, never inferred from a rendered button.

const (
	ProviderFamilyOIDC     ProviderFamily = "oidc"
	ProviderFamilySAML     ProviderFamily = "saml"
	ProviderFamilyLDAP     ProviderFamily = "ldap"
	ProviderFamilyWebAuthn ProviderFamily = "webauthn"
	ProviderFamilySocial   ProviderFamily = "social"
	ProviderFamilySCIM     ProviderFamily = "scim"
)

type ProviderProfile

type ProviderProfile struct {
	Family         ProviderFamily   `json:"family"`
	Status         CapabilityStatus `json:"status"`
	Capabilities   []string         `json:"capabilities,omitempty"`
	RequiredChecks []string         `json:"required_checks,omitempty"`
}

ProviderProfile is the public capability surface of a provider. It must never carry secret references or credentials. Status uses the shared CapabilityStatus vocabulary (planned/experimental/supported/retired).

type ProviderRegistration added in v1.0.0

type ProviderRegistration struct {
	TenantID      TenantID
	Scope         BusinessScope
	ProviderID    string
	OwnerModuleID ModuleID
	Kind          string
	Offers        []CapabilityOffer
}

type ProviderSelection added in v1.0.0

type ProviderSelection struct {
	Key        BindingKey `json:"key"`
	ProviderID string     `json:"provider_id"`
}

func (ProviderSelection) Validate added in v1.0.0

func (selection ProviderSelection) Validate() error

type ProvisionTenant added in v1.0.0

type ProvisionTenant struct {
	Meta   CommandMeta `json:"meta"`
	Tenant TenantID    `json:"tenant_id"`
	// The Engine creates a passwordless bootstrap administrator. This command
	// does not claim or trigger enrollment-link delivery; that requires a
	// separately durable notification flow. A password never crosses the
	// management boundary.
	//contract:minLength=3
	//contract:maxLength=254
	BootstrapAdminEmail string `json:"bootstrap_admin_email"`
	// BootstrapAdminSubject is the immutable Cloud user ID. Email is only a
	// verified contact attribute and is never the principal key.
	//contract:minLength=3
	//contract:maxLength=160
	BootstrapAdminSubject string `json:"bootstrap_admin_subject"`
	// PrimaryAlias is the canonical hostname used for tenant application routes
	// and configuration records. Aliases contains only additional hostnames.
	//contract:minLength=1
	//contract:maxLength=253
	//contract:pattern=^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$
	PrimaryAlias string `json:"primary_alias"`
	//contract:maxItems=49
	//contract:itemPattern=^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$
	Aliases    []string     `json:"aliases"`
	Deployment DeploymentID `json:"deployment_id"`
	//contract:minLength=3
	//contract:maxLength=160
	//contract:pattern=^[A-Za-z0-9][A-Za-z0-9._:-]{1,159}$
	DatabaseAllocationRef string `json:"database_allocation_ref"`
	//contract:minLength=64
	//contract:maxLength=64
	//contract:pattern=^[a-f0-9]{64}$
	PackageDigest string `json:"package_digest,omitempty"`
	// DisplayName is the optional human workspace name the customer typed (for
	// example "Dbg Duka"). It seeds the tenant's branding.app_name, shown on
	// sign-in, in the sidebar and as the page title. It is a presentation seed
	// only: it is not part of tenant identity, never affects aliases, database
	// names or the hostname slug, and a provisioning retry does not overwrite a
	// name the tenant administrator later changed. Absent keeps the
	// hostname-derived label. The Engine trims surrounding whitespace; control
	// and bidirectional-override characters are rejected.
	//contract:maxLength=120
	DisplayName string `json:"display_name,omitempty"`
}

type PublishedOperation added in v1.0.0

type PublishedOperation struct {
	Name           string              `json:"name"`
	Capability     CapabilityName      `json:"capability"`
	Operation      string              `json:"operation"`
	ScopePolicy    ResourceScopeKind   `json:"scope_policy"`
	AllowedCallers []ModuleID          `json:"allowed_callers"`
	Presentation   SurfacePresentation `json:"presentation"`
	// OfflineEligible permits clients to queue this business intent for server replay.
	OfflineEligible bool                       `json:"offline_eligible,omitempty"`
	Checkout        *CheckoutOperationContract `json:"checkout,omitempty"`
	Payment         *PaymentOperationContract  `json:"payment,omitempty"`
}

PublishedOperation explicitly makes one owner operation discoverable in the actor catalog. Its capability and schema bindings are checked against the module's existing offers; declaring it does not grant caller authority.

type PublishedQuery added in v1.0.0

type PublishedQuery struct {
	OwnerModuleID ModuleID            `json:"owner_module_id"`
	Name          string              `json:"name"`
	Capability    CapabilityName      `json:"capability"`
	Operation     string              `json:"operation"`
	InputSchema   SchemaRef           `json:"input_schema"`
	OutputSchema  SchemaRef           `json:"output_schema"`
	ScopePolicy   ResourceScopeKind   `json:"scope_policy"`
	AllowedFields []string            `json:"allowed_fields"`
	OwnerField    string              `json:"owner_field,omitempty"`
	PageLimit     uint16              `json:"page_limit"`
	Presentation  SurfacePresentation `json:"presentation"`
	// OfflineEligible permits this published query to back an actor-scoped offline feed.
	// Providers must still support pinned snapshots and actor-scoped replay.
	OfflineEligible bool `json:"offline_eligible,omitempty"`
	// OfflineFactKey names the stable scalar identity in offline snapshot rows.
	OfflineFactKey  string                    `json:"offline_fact_key,omitempty"`
	ReferenceLookup *PublishedReferenceLookup `json:"reference_lookup,omitempty"`
}

PublishedQuery is an owner-controlled, read-only capability surface. The operation must be declared by the owner module with EffectQuery; consumers never receive direct access to the provider's tables.

type PublishedQueryRequest added in v1.0.0

type PublishedQueryRequest struct {
	//contract:maxJSONBytes=65536
	//contract:json
	Input json.RawMessage `json:"input"`
	//contract:maxLength=1024
	Cursor string `json:"cursor,omitempty"`
	//contract:max=1000
	Limit uint16 `json:"limit,omitempty"`
}

PublishedQueryRequest is the public request envelope for owner-published reads. The module's registered input schema validates Input after this envelope.

func (PublishedQueryRequest) Validate added in v1.0.0

func (r PublishedQueryRequest) Validate() error

type PublishedReferenceLookup added in v1.0.0

type PublishedReferenceLookup struct {
	ResourceType string `json:"resource_type"`
	SearchField  string `json:"search_field"`
	ValueField   string `json:"value_field"`
	LabelField   string `json:"label_field"`
}

PublishedReferenceLookup binds a query row to a provider-qualified reference.

func (PublishedReferenceLookup) Validate added in v1.0.0

func (r PublishedReferenceLookup) Validate(allowed []string) error

type QueryFreshness added in v1.0.0

type QueryFreshness string

QueryFreshness describes whether a published query result is current.

const (
	QueryFresh      QueryFreshness = "fresh"
	QueryStale      QueryFreshness = "stale"
	QueryUnknown    QueryFreshness = "unknown"
	QueryIncomplete QueryFreshness = "incomplete"
)

type QueryReplayChange added in v1.0.0

type QueryReplayChange struct {
	FactKey string `json:"fact_key"`
	Deleted bool   `json:"deleted,omitempty"`
	//contract:json
	Data json.RawMessage `json:"data,omitempty"`
}

type QueryReplayPage added in v1.0.0

type QueryReplayPage struct {
	Changes        []QueryReplayChange `json:"changes"`
	NextCursor     string              `json:"next_cursor,omitempty"`
	ThroughCursor  string              `json:"through_cursor"`
	SourceRevision string              `json:"source_revision"`
	AsOf           time.Time           `json:"as_of"`
	Freshness      QueryFreshness      `json:"freshness"`
}

QueryReplayPage is one bounded page of owner-published changes after a snapshot cursor. ThroughCursor pins all pages to one replay high-water mark. A change with Deleted=true removes the FactKey; otherwise Data is a full replacement row conforming to the query output schema.

func (QueryReplayPage) Validate added in v1.0.0

func (p QueryReplayPage) Validate(query PublishedQuery, limit uint16) error

type QueryResult added in v1.0.0

type QueryResult struct {
	//contract:json
	Data       json.RawMessage `json:"data"`
	NextCursor string          `json:"next_cursor,omitempty"`
	// SnapshotToken pins every page in a paginated query to one immutable source snapshot.
	SnapshotToken string `json:"snapshot_token,omitempty"`
	// SourceCursor is the owner's durable change-log position at SnapshotToken.
	// Projection rebuilds replay changes after this position before publishing.
	SourceCursor   string         `json:"source_cursor,omitempty"`
	SourceRevision string         `json:"source_revision,omitempty"`
	AsOf           time.Time      `json:"as_of"`
	Freshness      QueryFreshness `json:"freshness"`
}

QueryResult is a bounded, schema-validated result from a published query.

func (QueryResult) Validate added in v1.0.0

func (q QueryResult) Validate(query PublishedQuery, limit uint16, scope BusinessScope) error

type ReassignRequest added in v1.0.0

type ReassignRequest struct {
	Meta         CommandMeta  `json:"meta"`
	AssignmentID AssignmentID `json:"assignment_id"`
	To           Assignee     `json:"to"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

type ReconcileTenantDeleteOperation added in v1.0.0

type ReconcileTenantDeleteOperation struct {
	Meta CommandMeta `json:"meta"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

ReconcileTenantDeleteOperation requests another attempt of a caller-owned tenant deletion after Engine has verified its immutable checkpoint. The executor must reverify the same checkpoint and allocation before resuming teardown; this command never replaces that evidence.

type ReconcileTenantInvitationOperation added in v1.0.0

type ReconcileTenantInvitationOperation struct {
	Meta    CommandMeta               `json:"meta"`
	Outcome InvitationDeliveryOutcome `json:"outcome"`
	//contract:minLength=8
	//contract:maxLength=1000
	Reason string `json:"reason"`
}

ReconcileTenantInvitationOperation resolves one uncertain invitation under the same durable operation identity.

type ReconcileTenantPackageOperation added in v1.0.0

type ReconcileTenantPackageOperation struct {
	Meta CommandMeta `json:"meta"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

ReconcileTenantPackageOperation requeues the same immutable package apply operation after the operator has reviewed its journal and tenant state. Engine repeats artifact digest verification and resumes schema activation from the durable per-tenant activation journal.

type ReconcileTenantProvisionOperation added in v1.0.0

type ReconcileTenantProvisionOperation struct {
	Meta CommandMeta `json:"meta"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

ReconcileTenantProvisionOperation retries only the base tenant provisioning operation. Engine verifies the immutable tenant identity and assigned data allocation before replaying its idempotent database bootstrap; package and external notification effects are not included.

type ReconcileTenantStateOperation added in v1.0.0

type ReconcileTenantStateOperation struct {
	Meta CommandMeta `json:"meta"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

ReconcileTenantStateOperation requests another execution of an uncertain tenant state operation. Engine accepts this only for the same durable set-tenant-state operation because its directory transition is revision fenced and idempotent; other operation kinds require their own recovery evidence and cannot use this request.

type ReconcileWorkflow added in v1.0.0

type ReconcileWorkflow struct {
	Meta    CommandMeta           `json:"meta"`
	StepID  StepID                `json:"step_id"`
	Outcome ReconciliationOutcome `json:"outcome"`
	//contract:maxLength=512
	EvidenceRef string `json:"evidence_ref"`
	//contract:minLength=1
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

type ReconciliationOutcome added in v1.0.0

type ReconciliationOutcome string
const (
	ReconcileSucceeded  ReconciliationOutcome = "confirmed_succeeded"
	ReconcileNotApplied ReconciliationOutcome = "confirmed_not_applied"
	ReconcileAbandon    ReconciliationOutcome = "abandon"
)

type RecordChangeEventData added in v1.0.0

type RecordChangeEventData struct {
	Table         string   `json:"table"`
	RecordID      string   `json:"record_id"`
	Revision      string   `json:"revision"`
	ChangedFields []string `json:"changed_fields,omitempty"`
}

type RecordTrigger added in v1.0.0

type RecordTrigger struct {
	Kind          string   `json:"kind"` // record.created | record.updated
	Table         string   `json:"table"`
	WatchedFields []string `json:"watched_fields,omitempty"`
}

RecordTrigger starts a workflow from a committed tenant record mutation. WatchedFields is empty for every update; otherwise at least one listed field must have changed. Table names are canonical DocType names, never SQL names.

type ReferenceRule added in v1.0.0

type ReferenceRule struct {
	Kind           string         `json:"kind"`
	CapabilityName CapabilityName `json:"capability_name,omitempty"`
	ResourceType   string         `json:"resource_type"`
}

ReferenceRule declares whether a field points to a local row or a published provider-owned business identity.

func (ReferenceRule) Validate added in v1.0.0

func (r ReferenceRule) Validate() error

type Region

type Region struct {
	Name   string  `json:"name"`
	Blocks []Block `json:"blocks"`
	Layout Layout  `json:"layout"`
}

Region is a named layout area containing blocks.

type RequestFilter added in v1.0.0

type RequestFilter struct {
	Page        PageRequest  `json:"page"`
	View        InboxView    `json:"view"`
	Kind        *RequestKind `json:"kind,omitempty"`
	OverdueOnly bool         `json:"overdue_only"`
}

type RequestHistoryEntry added in v1.0.0

type RequestHistoryEntry struct {
	Sequence         Revision           `json:"sequence"`
	Kind             RequestHistoryKind `json:"kind"`
	Actor            *PrincipalID       `json:"actor,omitempty"`
	AssignmentID     AssignmentID       `json:"assignment_id,omitempty"`
	PreviousAssignee *Assignee          `json:"previous_assignee,omitempty"`
	NewAssignee      *Assignee          `json:"new_assignee,omitempty"`
	Response         *ResponseKind      `json:"response,omitempty"`
	Comment          string             `json:"comment,omitempty"`
	At               time.Time          `json:"at"`
}

type RequestHistoryKind added in v1.0.0

type RequestHistoryKind string
const (
	HistoryCreated    RequestHistoryKind = "created"
	HistoryAssigned   RequestHistoryKind = "assigned"
	HistoryResponded  RequestHistoryKind = "responded"
	HistoryReassigned RequestHistoryKind = "reassigned"
	HistoryResolved   RequestHistoryKind = "resolved"
	HistoryCancelled  RequestHistoryKind = "cancelled"
	HistoryExpired    RequestHistoryKind = "expired"
	HistoryStale      RequestHistoryKind = "stale"
)

type RequestID added in v1.0.0

type RequestID string

func ParseRequestID added in v1.0.0

func ParseRequestID(raw string) (RequestID, error)

type RequestKind added in v1.0.0

type RequestKind string
const (
	RequestApproval       RequestKind = "approval"
	RequestReview         RequestKind = "review"
	RequestInformation    RequestKind = "information"
	RequestAcknowledgment RequestKind = "acknowledgment"
	RequestTask           RequestKind = "task"
)

type RequestOutcome added in v1.0.0

type RequestOutcome string
const (
	OutcomeApproved     RequestOutcome = "approved"
	OutcomeRejected     RequestOutcome = "rejected"
	OutcomeReturned     RequestOutcome = "returned_for_changes"
	OutcomeProvided     RequestOutcome = "information_provided"
	OutcomeAcknowledged RequestOutcome = "acknowledged"
	OutcomeCompleted    RequestOutcome = "completed"
)

type RequestSource added in v1.0.0

type RequestSource struct {
	InstanceID InstanceID `json:"instance_id,omitempty"`
	StepID     StepID     `json:"step_id,omitempty"`
}

type RequestStatus added in v1.0.0

type RequestStatus string
const (
	RequestPending   RequestStatus = "pending"
	RequestResolved  RequestStatus = "resolved"
	RequestCancelled RequestStatus = "cancelled"
	RequestExpired   RequestStatus = "expired"
	RequestStale     RequestStatus = "stale"
)

type RequestTenantInvitation added in v1.0.0

type RequestTenantInvitation struct {
	Meta CommandMeta `json:"meta"`
	//contract:minLength=3
	//contract:maxLength=254
	//contract:maxBytes=254
	Email string `json:"email"`
}

RequestTenantInvitation starts a durable Engine-owned sign-in-link delivery operation for the active tenant administrator. Tenant identity is supplied by the authenticated management route.

type RequestView added in v1.0.0

type RequestView struct {
	ID                RequestID         `json:"id"`
	Revision          Revision          `json:"revision"`
	Kind              RequestKind       `json:"kind"`
	Status            RequestStatus     `json:"status"`
	Requester         PrincipalID       `json:"requester"`
	Subject           *SubjectRef       `json:"subject,omitempty"`
	Title             string            `json:"title"`
	Message           string            `json:"message"`
	Source            *RequestSource    `json:"source,omitempty"`
	InformationSchema *SchemaRef        `json:"information_schema,omitempty"`
	DueAt             *time.Time        `json:"due_at,omitempty"`
	AllowedResponses  []ResponseKind    `json:"allowed_responses"`
	Assignments       []AssignmentView  `json:"assignments"`
	Outcome           *RequestOutcome   `json:"outcome,omitempty"`
	ResolvedAt        *time.Time        `json:"resolved_at,omitempty"`
	Continuation      *ContinuationView `json:"continuation,omitempty"`
	CreatedAt         time.Time         `json:"created_at"`
	UpdatedAt         time.Time         `json:"updated_at"`
}

type ResolvedBusinessRef added in v1.0.0

type ResolvedBusinessRef struct {
	Canonical BusinessRef
	Revision  uint64
	Display   string
}

func ValidateBusinessReference added in v1.0.0

func ValidateBusinessReference(ctx context.Context, resolver BusinessReferenceResolver, scope ScopeContext, ref BusinessRef, expectedResourceType string) (ResolvedBusinessRef, error)

type ResolvedModuleExtension added in v1.0.0

type ResolvedModuleExtension struct {
	Point        ExtensionPoint        `json:"point"`
	Registration ExtensionRegistration `json:"registration"`
}

ResolvedModuleExtension is an activation-ordered extension registration.

func OrderModuleExtensions added in v1.0.0

func OrderModuleExtensions(modules []ModuleDescriptor, registered func(SchemaRef) bool) ([]ResolvedModuleExtension, error)

OrderModuleExtensions validates declarations and returns a stable dependency order shared by activation and runtime consumers.

type ResourceDescriptor

type ResourceDescriptor struct {
	Ref          ResourceRef       `json:"ref"`
	Kind         ResourceKind      `json:"kind"`
	Hash         string            `json:"hash"`
	Fields       []TypedField      `json:"fields,omitempty"`
	DependsOn    []ResourceRef     `json:"depends_on,omitempty"`
	Lifecycle    ResourceLifecycle `json:"lifecycle,omitempty"`
	CreatedAt    time.Time         `json:"created_at"`
	SupersededAt time.Time         `json:"superseded_at,omitempty"`
}

ResourceDescriptor is the immutable desired-state definition of one resource version. Hash is the canonical SHA-256 of the descriptor content (excluding the Hash field itself).

type ResourceKind

type ResourceKind string

ResourceKind enumerates the resource classes the engine addresses through a ResourceRef. New kinds are added only with a contract version bump.

const (
	ResourceKindDoctype     ResourceKind = "doctype"
	ResourceKindCollection  ResourceKind = "collection"
	ResourceKindCommand     ResourceKind = "command"
	ResourceKindQuery       ResourceKind = "query"
	ResourceKindRelation    ResourceKind = "relation"
	ResourceKindComputation ResourceKind = "computation"
	ResourceKindRule        ResourceKind = "rule"
	ResourceKindPolicy      ResourceKind = "policy"
	ResourceKindAction      ResourceKind = "action"
	ResourceKindWorkflow    ResourceKind = "workflow"
	ResourceKindCapability  ResourceKind = "capability"
	ResourceKindSkill       ResourceKind = "skill"
	ResourceKindRole        ResourceKind = "role"
	ResourceKindAgent       ResourceKind = "agent"
	ResourceKindView        ResourceKind = "view"
	ResourceKindEvent       ResourceKind = "event"
	ResourceKindIntegration ResourceKind = "integration"
	ResourceKindPlugin      ResourceKind = "plugin"
	ResourceKindPackage     ResourceKind = "package"
	ResourceKindPage        ResourceKind = "page"
	ResourceKindComponent   ResourceKind = "component"
)

type ResourceLifecycle added in v1.0.0

type ResourceLifecycle string
const (
	LifecycleDraft    ResourceLifecycle = "draft"
	LifecyclePreview  ResourceLifecycle = "preview"
	LifecycleActive   ResourceLifecycle = "active"
	LifecycleDisabled ResourceLifecycle = "disabled"
	LifecycleRetired  ResourceLifecycle = "retired"
)

type ResourceOwnership added in v1.0.0

type ResourceOwnership struct {
	TenantID      TenantID    `json:"tenant_id"`
	Resource      ResourceRef `json:"resource"`
	OwnerModuleID ModuleID    `json:"owner_module_id"`
}

ResourceOwnership is durable ownership of a canonical resource identity.

type ResourceRef

type ResourceRef struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
	Version   int    `json:"version"`
}

ResourceRef is the namespaced, versioned identity of a resource. Namespace is the tenant or system scope and is never empty; Version is monotonic per (namespace, name).

func (ResourceRef) String

func (r ResourceRef) String() string

String renders a stable, human-readable identity ("namespace/name@version").

type ResourceRegistry

type ResourceRegistry interface {
	Register(ctx context.Context, d ResourceDescriptor) (ResourceRef, error)
	Resolve(ref ResourceRef) (ResourceDescriptor, error)
	List(namespace string, kind ResourceKind) ([]ResourceDescriptor, error)
}

ResourceRegistry is the registration and resolution surface for resources. Implementations must enforce namespace isolation and monotonic versioning. The context is the standard library context; the operation kernel adapts its OperationContext into it at the boundary.

type ResourceScopeKind added in v1.0.0

type ResourceScopeKind string
const (
	ScopeTenantShared ResourceScopeKind = "tenant_shared"
	ScopeEntityOwned  ResourceScopeKind = "entity_owned"
)

type RespondRequest added in v1.0.0

type RespondRequest struct {
	Meta         CommandMeta  `json:"meta"`
	AssignmentID AssignmentID `json:"assignment_id"`
	Response     ResponseKind `json:"response"`
	//contract:maxBytes=8192
	Comment     string               `json:"comment,omitempty"`
	Information *InformationResponse `json:"information,omitempty"`
}

type ResponseDetail added in v1.0.0

type ResponseDetail struct {
	DecisionID   DecisionID           `json:"decision_id"`
	RequestID    RequestID            `json:"request_id"`
	AssignmentID AssignmentID         `json:"assignment_id"`
	Response     ResponseKind         `json:"response"`
	Comment      string               `json:"comment,omitempty"`
	Information  *InformationResponse `json:"information,omitempty"`
	At           time.Time            `json:"at"`
}

type ResponseKind added in v1.0.0

type ResponseKind string
const (
	ResponseApprove     ResponseKind = "approve"
	ResponseReject      ResponseKind = "reject"
	ResponseReturn      ResponseKind = "return_for_changes"
	ResponseProvide     ResponseKind = "provide_information"
	ResponseAcknowledge ResponseKind = "acknowledge"
	ResponseComplete    ResponseKind = "complete"
)

type ResponseReceipt added in v1.0.0

type ResponseReceipt struct {
	RequestID    RequestID         `json:"request_id"`
	DecisionID   DecisionID        `json:"decision_id"`
	Revision     Revision          `json:"revision"`
	Status       RequestStatus     `json:"status"`
	Outcome      *RequestOutcome   `json:"outcome,omitempty"`
	Continuation *ContinuationView `json:"continuation,omitempty"`
}

type Revision added in v1.0.0

type Revision string

func ParseRevision added in v1.0.0

func ParseRevision(raw string) (Revision, error)

type RevokeCapability added in v1.0.0

type RevokeCapability struct {
	Scope            BusinessScope
	Selector         CapabilitySelector
	ExpectedRevision uint64
	Reason           string
}

RevokeCapability is a revision-fenced security decision for one exact capability selector in one tenant or legal-entity scope.

func (RevokeCapability) Validate added in v1.0.0

func (r RevokeCapability) Validate() error

type RevokeManagedChannelClientResultV2 added in v1.0.0

type RevokeManagedChannelClientResultV2 struct {
	Revoked bool `json:"revoked"`
}

type RevokeManagedChannelClientV2 added in v1.0.0

type RevokeManagedChannelClientV2 struct {
	//contract:minLength=64
	//contract:maxLength=64
	//contract:pattern=^[a-f0-9]{64}$
	CredentialFingerprint string `json:"credential_fingerprint"`
}

RevokeManagedChannelClientV2 disables the current Cloud-managed channel credential only when it still matches the credential Cloud intends to revoke. The fingerprint is SHA-256 over the one-time access token; the token itself is never sent back to Engine or logged by this command.

type RevokeTenantMember added in v1.0.0

type RevokeTenantMember struct {
	Meta CommandMeta `json:"meta"`
	//contract:minLength=3
	//contract:maxLength=140
	//contract:pattern=^[A-Za-z0-9][A-Za-z0-9._:-]{2,139}$
	Subject PrincipalID `json:"subject"`
	//contract:minLength=1
	//contract:maxBytes=1000
	Reason string `json:"reason"`
}

RevokeTenantMember starts a durable operation that disables the tenant user keyed by the Cloud subject, clears its roles and drops its sessions. The row is kept because records reference it.

type Runtime

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

Runtime is the capability registry. Implementations register capabilities and, before marking anything supported, must resolve every blocking risk and attach test evidence.

func NewRuntime

func NewRuntime() *Runtime

NewRuntime returns an empty capability registry.

func (*Runtime) Blocked

func (r *Runtime) Blocked() []Capability

Blocked reports whether any registered capability still carries a blocking risk while marked supported.

func (*Runtime) Get

func (r *Runtime) Get(name string) (Capability, bool)

Get returns a capability by name and whether it exists.

func (*Runtime) Names

func (r *Runtime) Names() []string

Names returns the sorted list of registered capability names.

func (*Runtime) Register

func (r *Runtime) Register(c Capability)

Register records a capability. It panics on a duplicate name so that a name cannot silently be overwritten with a conflicting status.

func (*Runtime) SetStatus

func (r *Runtime) SetStatus(name string, status CapabilityStatus) bool

SetStatus updates the status of a registered capability. Unknown capabilities are registered without a description. It is a no-op with a false return if the capability is not found.

func (*Runtime) Status

func (r *Runtime) Status(name string) CapabilityStatus

Status returns the status of a named capability. Unknown capabilities are "planned" so that a missing registration never reads as "supported".

type ScheduledJobDefinition added in v1.0.0

type ScheduledJobDefinition struct {
	Name              string         `json:"name"`
	OwnerModuleID     ModuleID       `json:"owner_module_id,omitempty"`
	Type              string         `json:"type"`
	Schedule          string         `json:"schedule"`
	Scope             *BusinessScope `json:"scope,omitempty"`
	RequiredResource  string         `json:"required_resource,omitempty"`
	RequiredOperation string         `json:"required_operation,omitempty"`
	//contract:json
	Config json.RawMessage `json:"config,omitempty"`
}

ScheduledJobDefinition is an immutable tenant job supplied by a package. Type is application-owned; Engine validates and dispatches it generically.

type SchemaRef added in v1.0.0

type SchemaRef struct {
	ID      string `json:"id"`
	Version uint32 `json:"version"`
}

func BusinessEventPayloadSchema added in v1.0.0

func BusinessEventPayloadSchema(data json.RawMessage) (SchemaRef, error)

BusinessEventPayloadSchema reads the domain schema marker carried inside Data; EventEnvelope.Version remains the transport contract version.

type ScopeContext added in v1.0.0

type ScopeContext struct {
	Scope      BusinessScope
	ProviderID string
}

type ServiceScope added in v1.0.0

type ServiceScope string
const (
	ScopeTenant    ServiceScope = "tenant"
	ScopeSession   ServiceScope = "session"
	ScopeWorkflow  ServiceScope = "workflow"
	ScopeExecution ServiceScope = "execution"
)

type SetTenantState added in v1.0.0

type SetTenantState struct {
	Meta  CommandMeta `json:"meta"`
	State TenantState `json:"state"`
	// ExpectedConfigRevision fences the transition against a stale Cloud view.
	// Retries that find the requested state already applied are idempotent.
	//contract:minLength=1
	//contract:maxLength=20
	//contract:pattern=^(0|[1-9][0-9]*)$
	ExpectedConfigRevision Revision `json:"expected_config_revision"`
	//contract:maxBytes=8192
	Reason string `json:"reason"`
}

type SiteAggregateKey

type SiteAggregateKey struct {
	Site          string
	AggregateType string
	AggregateID   string
}

SiteAggregateKey is the ordering key for durable events (DURABLE-001). Providers must preserve per-key FIFO; events with the same key are delivered in publish order.

func (SiteAggregateKey) String

func (k SiteAggregateKey) String() string

OrderKeyString renders the ordering key as a stable string.

type SiteDescriptor added in v1.0.0

type SiteDescriptor struct {
	Version           int      `json:"version"`
	SiteID            string   `json:"site_id"`
	Aliases           []string `json:"aliases"`
	Status            string   `json:"status"`
	ConfigRevision    uint64   `json:"config_revision,omitempty"`
	DirectoryRevision uint64   `json:"directory_revision,omitempty"`
	RuntimeCellID     string   `json:"runtime_cell_id,omitempty"`
	DataPlaneRef      string   `json:"data_plane_ref,omitempty"`
}

SiteDescriptor is the credential-free projection shared by Engine and its control-plane consumers. Database connection details are never part of this contract; data-plane references are opaque identifiers only.

type SiteDirectoryEntryV2 added in v1.0.0

type SiteDirectoryEntryV2 struct {
	Version           uint16       `json:"version"`
	SiteID            TenantID     `json:"site_id"`
	Aliases           []string     `json:"aliases"`
	Status            string       `json:"status"`
	ConfigRevision    Revision     `json:"config_revision"`
	DirectoryRevision Revision     `json:"directory_revision"`
	DeploymentID      DeploymentID `json:"deployment_id"`
	DataPlaneRef      string       `json:"data_plane_ref,omitempty"`
}

SiteDirectoryEntryV2 is the versioned, deployment-neutral projection used by deployment ingress. RuntimeCellID remains the v1 storage/wire adapter during migration; it is the only writable assignment source until cutover.

type SkillContract added in v1.0.0

type SkillContract struct {
	Ref        ResourceRef `json:"ref"`
	Capability ResourceRef `json:"capability"`
	Steps      []string    `json:"steps,omitempty"`
	Escalation string      `json:"escalation,omitempty"`
}

SkillContract is a versioned procedure attached to a capability.

type StaleProjectionError

type StaleProjectionError struct {
	Kind              string `json:"kind"` // "stale_generation" | "capability_missing"
	ClientGeneration  int64  `json:"client_generation"`
	ServerGeneration  int64  `json:"server_generation"`
	MissingCapability string `json:"missing_capability,omitempty"`
}

StaleProjectionError is a typed rejection when a client's projection is stale or missing a required capability. It is never a bare string error.

func CheckProjectionGate

func CheckProjectionGate(client, server GenerationInfo, requiredCaps, clientCaps []string) *StaleProjectionError

CheckProjectionGate compares a client's generation and capability set against the server and returns a typed *StaleProjectionError on any mismatch. A nil return means the projection is accepted.

func (*StaleProjectionError) Error

func (e *StaleProjectionError) Error() string

type StartWorkflow added in v1.0.0

type StartWorkflow struct {
	Meta              CommandMeta   `json:"meta"`
	DefinitionID      DefinitionID  `json:"definition_id"`
	DefinitionVersion uint32        `json:"definition_version"`
	Subject           SubjectRef    `json:"subject"`
	BusinessScope     BusinessScope `json:"business_scope,omitempty"`
}

type StaticIssuer

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

StaticIssuer is a deny-by-default HandleIssuer backed by an explicit grant table. An undeclared capability is never issued, even read-only.

func NewStaticIssuer

func NewStaticIssuer(grants []CapabilityGrant) *StaticIssuer

NewStaticIssuer builds a StaticIssuer from grants. Duplicate grants for the same (component, capability) are resolved by last-write.

func (*StaticIssuer) Issue

func (s *StaticIssuer) Issue(ctx OperationContext, component string, want []CapabilityName) ([]CapabilityHandle, error)

Issue grants exactly the requested capabilities that the component declared; any undeclared capability aborts the whole request with a typed denial. This is fail-closed: a mixed request does not partially succeed.

type Status

type Status string

Status is the operation result state for a command or query.

The RFC defines exactly these five states. They are stable machine-readable values used uniformly across all externally callable operations.

const (
	StatusCompleted Status = "completed"
	StatusAccepted  Status = "accepted"
	StatusRejected  Status = "rejected"
	StatusConflict  Status = "conflict"
	StatusFailed    Status = "failed"
	StatusPending   Status = "pending"
)

type StepDefinition added in v1.0.0

type StepDefinition struct {
	ID        StepID         `json:"id"`
	Kind      StepKind       `json:"kind"`
	Action    *ActionSpec    `json:"action,omitempty"`
	Condition *ConditionSpec `json:"condition,omitempty"`
	Human     *HumanSpec     `json:"human,omitempty"`
	Wait      *WaitSpec      `json:"wait,omitempty"`
	End       *EndSpec       `json:"end,omitempty"`
}

type StepID added in v1.0.0

type StepID string

func ParseStepID added in v1.0.0

func ParseStepID(raw string) (StepID, error)

type StepKind added in v1.0.0

type StepKind string
const (
	StepAction    StepKind = "action"
	StepCondition StepKind = "condition"
	StepHuman     StepKind = "human"
	StepWait      StepKind = "wait"
	StepEnd       StepKind = "end"
)

type SubjectBinding added in v1.0.0

type SubjectBinding string
const SubjectInstance SubjectBinding = "instance_subject"

type SubjectRef added in v1.0.0

type SubjectRef struct {
	Kind     string   `json:"kind"`
	ID       string   `json:"id"`
	Revision Revision `json:"revision"`
}

SubjectRef binds an operation or request to a versioned business subject.

type SubmitRequest added in v1.0.0

type SubmitRequest struct {
	Meta    CommandMeta `json:"meta"`
	Kind    RequestKind `json:"kind"`
	Subject *SubjectRef `json:"subject,omitempty"`
	//contract:minLength=1
	//contract:maxLength=160
	Title string `json:"title"`
	//contract:maxBytes=8192
	Message           string          `json:"message"`
	Assignment        *AssignmentSpec `json:"assignment,omitempty"`
	DueAt             *time.Time      `json:"due_at,omitempty"`
	PolicyID          string          `json:"policy_id,omitempty"`
	InformationSchema *SchemaRef      `json:"information_schema,omitempty"`
}

type Surface

type Surface struct {
	Name        string        `json:"name"`
	Status      SurfaceStatus `json:"status"`
	Description string        `json:"description"`
}

Surface describes one public contract area in this package.

func ContractInventory

func ContractInventory() []Surface

ContractInventory returns the current contract surface that is actually implemented in this repository. The list is intentionally small and explicit: callers should use it to distinguish the stable, experimental, partial, and target-state surfaces when generating docs or acceptance plans.

type SurfacePresentation added in v1.0.0

type SurfacePresentation struct {
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Form        string `json:"form,omitempty"`
	List        string `json:"list,omitempty"`
	// Layout is "", "form" or "line_entry". Clients ignore unknown values as form.
	Layout    string           `json:"layout,omitempty"`
	LineEntry *LineEntryLayout `json:"line_entry,omitempty"`
}

type SurfaceStatus

type SurfaceStatus string

SurfaceStatus summarizes how a contract area should be treated by callers. The values mirror the repo-wide capability vocabulary so the inventory can be used directly in docs and handoff notes.

const (
	SurfaceSupported    SurfaceStatus = "supported"
	SurfaceExperimental SurfaceStatus = "experimental"
	SurfacePlanned      SurfaceStatus = "planned"
	SurfacePartial      SurfaceStatus = "partial"
	SurfaceDiverged     SurfaceStatus = "diverged"
)

type SyncCursor

type SyncCursor struct {
	Token    string    `json:"token"`
	BranchID string    `json:"branch_id"`
	DeviceID string    `json:"device_id"`
	Version  int       `json:"version"`
	At       time.Time `json:"at"`
}

SyncCursor is the opaque cursor shared by pull and acknowledgement flows.

type SystemFieldHint

type SystemFieldHint struct {
	Name      string `json:"name"`
	Fieldtype string `json:"fieldtype"`
	Writable  bool   `json:"writable"`
}

SystemFieldHint describes a system column exposed through a tool projection.

type TaskReceipt

type TaskReceipt struct {
	OperationID   string    `json:"operation_id"`
	CorrelationID string    `json:"correlation_id"`
	Status        Status    `json:"status"`
	AcceptedAt    time.Time `json:"accepted_at"`
}

TaskReceipt acknowledges a submitted (asynchronous) command. Receiving a receipt does not imply completion (RFC §7).

type TemplateDetailPageContent added in v1.0.0

type TemplateDetailPageContent struct {
	BreadcrumbLabel        string `json:"breadcrumb_label"`
	TemplatesLink          string `json:"templates_link"`
	PrimaryAction          string `json:"primary_action"`
	PrimaryReassurance     string `json:"primary_reassurance"`
	PreparationHeading     string `json:"preparation_heading"`
	OutcomesHeading        string `json:"outcomes_heading"`
	CompositionHeading     string `json:"composition_heading"`
	PartLabel              string `json:"part_label"`
	PartsLabel             string `json:"parts_label"`
	IncludedLabel          string `json:"included_label"`
	OptionalLabel          string `json:"optional_label"`
	OptionalContinueAction string `json:"optional_continue_action"`
	UnavailableHeading     string `json:"unavailable_heading"`
	UnavailableDescription string `json:"unavailable_description"`
}

TemplateDetailPageContent carries customer-facing template detail labels.

type TenantDescriptorV2 added in v1.0.0

type TenantDescriptorV2 struct {
	//contract:const=2
	Version uint16   `json:"version"`
	SiteID  TenantID `json:"site_id"`
	//contract:maxItems=50
	//contract:itemPattern=^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$
	Aliases        []string    `json:"aliases"`
	Status         TenantState `json:"status"`
	ConfigRevision Revision    `json:"config_revision"`
	// TenantConfigRevision advances with tenant-local config mutations. It is
	// separate from ConfigRevision, the platform directory CAS revision.
	TenantConfigRevision Revision     `json:"tenant_config_revision,omitempty"`
	DirectoryRevision    Revision     `json:"directory_revision"`
	Deployment           DeploymentID `json:"deployment_id"`
	//contract:minLength=1
	//contract:maxLength=160
	//contract:pattern=^[A-Za-z0-9][A-Za-z0-9._:-]{1,159}$
	DataPlaneRef string `json:"data_plane_ref,omitempty"`
}

type TenantID added in v1.0.0

type TenantID string

func ParseTenantID added in v1.0.0

func ParseTenantID(raw string) (TenantID, error)

type TenantMemberPlan added in v1.0.0

type TenantMemberPlan struct {
	Allowed bool `json:"allowed"`
	//contract:maxItems=8
	Problems []TenantMemberProblem `json:"problems,omitempty"`
}

TenantMemberPlan is the Engine's role and membership check. Allowed is true exactly when Problems is empty.

type TenantMemberProblem added in v1.0.0

type TenantMemberProblem struct {
	Code TenantMemberProblemCode `json:"code"`
	//contract:minLength=1
	//contract:maxLength=500
	Message string `json:"message"`
}

type TenantMemberProblemCode added in v1.0.0

type TenantMemberProblemCode string

TenantMemberProblemCode names one reason the Engine refuses a member plan.

const (
	TenantMemberRoleUnknown       TenantMemberProblemCode = "role.unknown"
	TenantMemberRoleNotAssignable TenantMemberProblemCode = "role.not_assignable"
	TenantMemberAlreadyExists     TenantMemberProblemCode = "member.already_exists"
	TenantMemberEmailInUse        TenantMemberProblemCode = "member.email_in_use"
)

type TenantState added in v1.0.0

type TenantState string
const (
	TenantProvisioning TenantState = "provisioning"
	TenantActive       TenantState = "active"
	TenantSuspended    TenantState = "suspended"
	TenantDeleting     TenantState = "deleting"
	TenantFailed       TenantState = "failed"
)

type ToolArgumentVersion

type ToolArgumentVersion string

ToolArgumentVersion labels the frozen argument schema for a tool. It is bumped whenever a tool's arguments change in a breaking way (RFC §10.4.2).

type ToolCall added in v1.0.0

type ToolCall struct {
	ID         string      `json:"id"`
	Agent      ResourceRef `json:"agent"`
	Capability ResourceRef `json:"capability"`
	State      string      `json:"state"`
	ApprovalID string      `json:"approval_id,omitempty"`
	StartedAt  time.Time   `json:"started_at"`
	FinishedAt time.Time   `json:"finished_at,omitempty"`
}

type ToolCatalog

type ToolCatalog struct {
	Version string           `json:"version"`
	Tools   []ToolDescriptor `json:"tools"`
}

ToolCatalog is the versioned registry projection shared across adapters.

type ToolDescriptor

type ToolDescriptor struct {
	ID                      string              `json:"id"`
	Source                  string              `json:"source"`
	Name                    string              `json:"name"`
	Description             string              `json:"description"`
	InputSchema             map[string]any      `json:"input_schema"`
	SafetyLevel             ToolSafetyLevel     `json:"safety_level"`
	RequiresConfirmation    bool                `json:"requires_confirmation"`
	RequiresRecentAuth      bool                `json:"requires_recent_auth"`
	ChannelAllowlist        []string            `json:"channel_allowlist"`
	ArgumentContractVersion ToolArgumentVersion `json:"argument_contract_version"`
	Operation               string              `json:"operation"`
	Doctype                 string              `json:"doctype,omitempty"`
	DoctypeLabel            string              `json:"doctype_label,omitempty"`
	TitleField              string              `json:"title_field,omitempty"`
	SearchFields            []string            `json:"search_fields,omitempty"`
	SortField               string              `json:"sort_field,omitempty"`
	SortOrder               string              `json:"sort_order,omitempty"`
	FieldHints              []FieldHint         `json:"field_hints,omitempty"`
	SystemFields            []SystemFieldHint   `json:"system_fields,omitempty"`
}

ToolDescriptor is the canonical, versioned description of a callable tool. The RFC mandates that BuildToolCatalog becomes the sole registry projection and that every adapter (chat, channel, MCP, SDK, UI, HTTP, NATS) renders from this shape. This type carries no provider-specific or doctype-package dependencies so it can be serialized on the wire and compared across adapters.

type ToolSafetyLevel

type ToolSafetyLevel string

ToolSafetyLevel classifies the risk of a tool. Adapters render this into their own presentation (e.g., confirmation dialogs), but the value originates here.

const (
	ToolSafetySafe     ToolSafetyLevel = "safe"
	ToolSafetyStandard ToolSafetyLevel = "standard"
	ToolSafetyElevated ToolSafetyLevel = "elevated"
	ToolSafetyHigh     ToolSafetyLevel = "high"
	ToolSafetySystem   ToolSafetyLevel = "system"
)

type TypedField

type TypedField struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Label    string `json:"label,omitempty"`
	Required bool   `json:"required,omitempty"`
	Unique   bool   `json:"unique,omitempty"`
}

TypedField is the minimal field projection carried on a ResourceDescriptor. It is a contract-level representation; doctype.Field projects onto it at the registry boundary. Field values never cross a package boundary as map[string]any.

type UsageClass

type UsageClass string

UsageClass classifies a token/usage record per the FinOps FOCUS-normalized attribution model referenced in RFC §18.

const (
	UsageClassInput     UsageClass = "input"
	UsageClassOutput    UsageClass = "output"
	UsageClassReasoning UsageClass = "reasoning"
	UsageClassTotal     UsageClass = "total"
	UsageClassPartial   UsageClass = "partial"
)

type UsageEvent

type UsageEvent struct {
	ID           string               `json:"id"`
	Site         string               `json:"site"`
	Organization string               `json:"organization_id,omitempty"`
	UserID       string               `json:"user_id,omitempty"`
	Model        string               `json:"model"`
	Provider     string               `json:"provider"`
	RunID        string               `json:"run_id,omitempty"`
	StepID       string               `json:"step_id,omitempty"`
	Channel      string               `json:"channel,omitempty"`
	Attempt      int                  `json:"attempt"`
	Status       string               `json:"status"` // completed|partial|failed|zero
	Tokens       map[UsageClass]int64 `json:"tokens,omitempty"`
	LatencyMs    int64                `json:"latency_ms,omitempty"`
	OccurredAt   time.Time            `json:"occurred_at"`
	RetryOf      string               `json:"retry_of,omitempty"`
	Attribution  map[string]string    `json:"attribution,omitempty"`
}

UsageEvent is an immutable record of one provider attempt (RFC §10.4.4 / §14.4.7). It is never overwritten; corrections and reconciliation create new records rather than mutating this one.

type ValidationIssue added in v1.0.0

type ValidationIssue struct {
	Path   string `json:"path"`
	Code   string `json:"code"`
	Detail string `json:"detail"`
}

type ValidationResult added in v1.0.0

type ValidationResult struct {
	Valid bool `json:"valid"`
	//contract:maxItems=100
	Issues []ValidationIssue `json:"issues"`
}

type VersionMismatchError

type VersionMismatchError struct {
	Kind            string `json:"kind"` // "version_mismatch"
	Doctype         string `json:"-"`
	Name            string `json:"-"`
	ExpectedVersion int64  `json:"expected_version"`
	ActualVersion   int64  `json:"actual_version"`
}

VersionMismatchError is the typed result of a failed document-level optimistic-concurrency write (OFFLINE-003). ExpectedVersion is what the writer assumed; ActualVersion is the current committed version.

func DetectVersionConflict

func DetectVersionConflict(expected, actual int64) *VersionMismatchError

DetectVersionConflict reports a conflict when a writer's expected version is stale (positive and not equal to the actual committed version). It returns nil when the write is up-to-date or versioning is not enforced (expected<=0).

func (*VersionMismatchError) Error

func (e *VersionMismatchError) Error() string

type WaitSpec added in v1.0.0

type WaitSpec struct {
	EventType        string `json:"event_type,omitempty"`
	CorrelationField string `json:"correlation_field,omitempty"`
	//contract:min=1
	//contract:max=2678400
	TimeoutSeconds uint32 `json:"timeout_seconds"`
	OnEvent        StepID `json:"on_event,omitempty"`
	OnTimeout      StepID `json:"on_timeout"`
}

type WorkflowCommandPin added in v1.0.0

type WorkflowCommandPin struct {
	InstanceID     InstanceID
	StepID         StepID
	IdempotencyKey IdempotencyKey
}

type WorkflowDefinition added in v1.0.0

type WorkflowDefinition struct {
	ID            DefinitionID   `json:"id"`
	OwnerModuleID ModuleID       `json:"owner_module_id,omitempty"`
	Version       uint32         `json:"version"`
	Entry         StepID         `json:"entry"`
	Trigger       *RecordTrigger `json:"trigger,omitempty"`
	//contract:minItems=1
	//contract:maxItems=100
	Steps []StepDefinition `json:"steps"`
}

type WorkflowEventData added in v1.0.0

type WorkflowEventData struct {
	InstanceID InstanceID `json:"instance_id"`
	Revision   Revision   `json:"revision"`
	ChangeKind string     `json:"change_kind"`
}

type WorkflowHistoryEntry added in v1.0.0

type WorkflowHistoryEntry struct {
	//contract:min=1
	Sequence uint64 `json:"sequence"`
	//contract:maxLength=160
	StepID StepID `json:"step_id"`
	//contract:maxLength=80
	Kind string `json:"kind"`
	//contract:maxLength=80
	Status string `json:"status"`
	//contract:maxBytes=8192
	Detail    string    `json:"detail,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

WorkflowHistoryEntry is the bounded, payload-free execution history exposed to tenant clients.

type WorkflowInstance added in v1.0.0

type WorkflowInstance struct {
	ID                InstanceID     `json:"id"`
	Revision          Revision       `json:"revision"`
	DefinitionID      DefinitionID   `json:"definition_id"`
	DefinitionVersion uint32         `json:"definition_version"`
	Subject           SubjectRef     `json:"subject"`
	BusinessScope     BusinessScope  `json:"business_scope,omitempty"`
	CausationDepth    uint16         `json:"causation_depth,omitempty"`
	Status            InstanceStatus `json:"status"`
	CurrentStep       StepID         `json:"current_step"`
	NextWakeAt        *time.Time     `json:"next_wake_at,omitempty"`
	CreatedAt         time.Time      `json:"created_at"`
	UpdatedAt         time.Time      `json:"updated_at"`
}

Directories

Path Synopsis
Command gen produces a deterministic JSON Schema snapshot for the stable wire types in contract.
Command gen produces a deterministic JSON Schema snapshot for the stable wire types in contract.

Jump to

Keyboard shortcuts

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