usecase

package
v0.0.0-...-1f39044 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 21 Imported by: 3 modules, 1 package

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

Index

Constants

View Source
const (
	NativeIdentityAbsent        = domain.NativeIdentityAbsent
	NativeIdentityManaged       = domain.NativeIdentityManaged
	NativeIdentityUnmanaged     = domain.NativeIdentityUnmanaged
	NativeIdentityIndeterminate = domain.NativeIdentityIndeterminate
)
View Source
const OpenCodeNamespaceCheckedCode = "opencode_global_namespace_checked"

Variables

View Source
var ErrProjectionPinChangeRequired = domain.ErrProjectionPinChangeRequired

ErrProjectionPinChangeRequired is what a saved dependency gets instead of ErrProjectionRefreshRequired: an update cannot refresh it, so the new rules wait for its next pin change.

View Source
var ErrProjectionRefreshRequired = domain.ErrProjectionRefreshRequired

ErrProjectionRefreshRequired means an intact package with installer-rendered components would be staged differently today than the recorded projection. Repair, a repeated add and a resumed activation keep the installed tree; only update applies the current rules. It is domain.ErrProjectionRefreshRequired, which the stager also returns.

Functions

This section is empty.

Types

type AddInput

type AddInput struct {
	ConfirmPluginEnable bool `json:"-"`

	InstallIntent domain.InstallIntent
	Envelope      domain.PackageEnvelope
	Client        domain.DetectedClient
	Scope         domain.InstallScope
	// OnlinePreview permits host probing during a read-only normal-operation preview.
	// It grants no mutation or confirmation permission.
	OnlinePreview      bool
	DryRun             bool
	Confirmed          bool
	Interactive        bool
	Hints              domain.CompatibilityHints
	InstallationID     string
	OperationID        string
	BackendExecutable  string
	ActivationComplete bool
	AuthComplete       bool
	// CompatibilityBindingID freezes the observed unselected binding across
	// the facade preflight and usecase mutation lock. Selected inputs leave it empty.
	CompatibilityBindingID string `json:"-"`
	// EnvironmentAuthority is mandatory for managed update/remove/repair and is
	// copied into the durable receipt before the first managed effect.
	EnvironmentAuthority *domain.EnvironmentAuthority
	// OriginMode and DirectoryResolution are supplied by the resolver. Omitting
	// OriginMode is treated as an explicit direct source for compatibility with
	// exact/local callers; Directory authority is never inferred from a name.
	OriginMode            domain.OriginMode
	DirectoryResolution   *domain.DirectoryOrigin
	DistributionSuspended bool
	ReleaseRevoked        bool
	// ProjectTrustConsent is set only by an explicit user add and is passed to
	// every activation of that operation, including finishing prepared setup.
	ProjectTrustConsent bool
	// PersistAuthoritativeObservations allows a read-only client verifier to
	// record negative evidence even during a plan-first CLI pass. It does not
	// authorize package, client, or user-requested lifecycle mutations.
	PersistAuthoritativeObservations bool
	// contains filtered or unexported fields
}

type AddResult

type AddResult struct {
	InstallationID       string                   `json:"installation_id"`
	Plan                 domain.DeliveryPlan      `json:"plan"`
	Activation           domain.ActivationOutcome `json:"activation,omitempty"`
	RequiresConfirmation bool                     `json:"requires_confirmation"`
	Mutated              bool                     `json:"mutated"`
	NoChange             bool                     `json:"no_change,omitempty"`
	Receipt              domain.MutationReceipt   `json:"-"`
	GroupPhase           GroupTargetPhase         `json:"group_phase,omitempty"`
	Failure              *GroupTargetFailure      `json:"failure,omitempty"`
}

type BindingChangeInput

type BindingChangeInput struct {
	Selector  string
	Envelope  domain.PackageEnvelope
	Confirmed bool
}

type BindingChangeMode

type BindingChangeMode string
const (
	BindingChangeRebind        BindingChangeMode = "rebind"
	BindingChangeMigrateFormat BindingChangeMode = "migrate_format"
	BindingChangeSwitch        BindingChangeMode = "switch"
)

type BindingChangePlan

type BindingChangePlan struct {
	Mode               BindingChangeMode         `json:"mode"`
	InstallationID     string                    `json:"installation_id"`
	OldName            string                    `json:"old_name"`
	NewName            string                    `json:"new_name"`
	OldSource          ProvenanceSummary         `json:"old_source"`
	NewSource          ProvenanceSummary         `json:"new_source"`
	OldFormat          FormatSummary             `json:"old_format"`
	NewFormat          FormatSummary             `json:"new_format"`
	OldComponents      domain.ComponentInventory `json:"old_components"`
	NewComponents      domain.ComponentInventory `json:"new_components"`
	Targets            []TargetChange            `json:"targets,omitempty"`
	NativeObjectCount  int                       `json:"native_object_count"`
	PluginDataDecision string                    `json:"plugin_data_decision"`
	CanApply           bool                      `json:"can_apply"`
	Blockers           []string                  `json:"blockers,omitempty"`
}

type BindingChangeResult

type BindingChangeResult struct {
	Plan                 BindingChangePlan         `json:"plan"`
	PluginData           domain.PluginDataDecision `json:"plugin_data"`
	RequiresConfirmation bool                      `json:"requires_confirmation"`
	Mutated              bool                      `json:"mutated"`
	NoChange             bool                      `json:"no_change,omitempty"`
}

type ClientPreparation

ClientPreparation freezes explicit host authority before a desired native plan. Process-inert planning must never launch a host executable.

type FormatSummary

type FormatSummary struct {
	LoaderKind string `json:"loader_kind"`
	FormatID   string `json:"format_id"`
	SchemaURI  string `json:"schema_uri"`
}

type GroupInput

type GroupInput struct {
	Targets             []AddInput
	CompatibilityChecks []AddInput
	OperationGroupID    string
	Progress            func(GroupProgressEvent)
	OnlinePreview       bool
	DryRun              bool
	Confirmed           bool
	Switch              bool
	Repair              bool
}

type GroupPhase

type GroupPhase string
const (
	GroupPhasePlanned                 GroupPhase = "planned"
	GroupPhasePreparationFailed       GroupPhase = "preparation_failed"
	GroupPhaseManagedUnchanged        GroupPhase = "managed_unchanged"
	GroupPhaseManagedRolledBack       GroupPhase = "managed_rolled_back"
	GroupPhaseManagedCommitUnknown    GroupPhase = "managed_commit_unknown"
	GroupPhaseManagedCommitted        GroupPhase = "managed_committed"
	GroupPhaseManagedActivationFailed GroupPhase = "managed_committed_activation_failed"
	GroupPhaseExternalPartialFailure  GroupPhase = "external_partial_failure"
	GroupPhaseCompleted               GroupPhase = "completed"
)

type GroupProgressEvent

type GroupProgressEvent struct {
	ClientID domain.ClientID
	Phase    GroupProgressPhase
	Result   AddResult
}

GroupProgressEvent reports observed checkpoints; it never grants consent or changes the outcome of an installation.

type GroupProgressPhase

type GroupProgressPhase string
const (
	GroupProgressPreparing   GroupProgressPhase = "preparing"
	GroupProgressConfiguring GroupProgressPhase = "configuring"
	GroupProgressConfigured  GroupProgressPhase = "configured"
	GroupProgressActivating  GroupProgressPhase = "activating"
	GroupProgressActivated   GroupProgressPhase = "activated"
)

type GroupResult

type GroupResult struct {
	// PreparedClients carries immutable host snapshots to this operation's apply.
	PreparedClients  []domain.DetectedClient   `json:"-"`
	InstallationID   string                    `json:"installation_id"`
	OperationGroupID string                    `json:"operation_group_id,omitempty"`
	Targets          []AddResult               `json:"targets"`
	PluginData       domain.PluginDataDecision `json:"plugin_data"`
	Receipts         []domain.MutationReceipt  `json:"-"`
	Mutated          bool                      `json:"mutated"`
	Phase            GroupPhase                `json:"phase"`
}

type GroupTargetError

type GroupTargetError struct {
	Clients []domain.ClientID
	Err     error
}

GroupTargetError attributes a failed group to the selected clients whose own preflight or package preparation failed. It is returned only before any managed state or client changed, only by the steps that plan, check and stage that target, and only while the group-wide profile and recovery checks still pass. Cross-target, input, state and lifecycle refusals are never attributed. Its text is the cause's text, unchanged.

A caller may run the remaining clients as a new group. Running them is the same as selecting only them: the group plans, checks and stages again under its own lock and commits as one transaction.

func (*GroupTargetError) Error

func (err *GroupTargetError) Error() string

func (*GroupTargetError) Unwrap

func (err *GroupTargetError) Unwrap() error

type GroupTargetFailure

type GroupTargetFailure struct {
	Stage   string `json:"stage"`
	Message string `json:"message"`
}

GroupTargetFailure records why one logical surface failed or was skipped during external activation. Retry commands belong in CLI presentation.

type GroupTargetPhase

type GroupTargetPhase string
const (
	GroupTargetPlanned              GroupTargetPhase = "planned"
	GroupTargetManagedRolledBack    GroupTargetPhase = "managed_rolled_back"
	GroupTargetManagedCommitted     GroupTargetPhase = "managed_committed"
	GroupTargetManagedUnknown       GroupTargetPhase = "managed_commit_unknown"
	GroupTargetExternalCompleted    GroupTargetPhase = "external_completed"
	GroupTargetExternalFailed       GroupTargetPhase = "external_failed"
	GroupTargetExternalPartial      GroupTargetPhase = "external_completed_managed_incomplete"
	GroupTargetExternalNotAttempted GroupTargetPhase = "external_not_attempted"
)

type InterruptedAttemptInput

type InterruptedAttemptInput struct {
	InstallationID       string
	Client               domain.DetectedClient
	Scope                domain.InstallScope
	BackendExecutable    string
	EnvironmentAuthority *domain.EnvironmentAuthority
	DryRun               bool
	Confirmed            bool
}

InterruptedAttemptInput selects the one binding whose native attempt a killed agentplugins process left open without a persisted intent.

type InterruptedAttemptResult

type InterruptedAttemptResult struct {
	AttemptID string
	Recorded  bool
}

InterruptedAttemptResult names the attempt and whether its confirmation was recorded; a dry run records nothing.

type LegacyRemoveInput

type LegacyRemoveInput struct {
	Selector    string
	DryRun      bool
	Confirmed   bool
	OperationID string
}

type LegacyRemoveResult

type LegacyRemoveResult struct {
	InstallationID       string                  `json:"installation_id"`
	Plugin               string                  `json:"plugin"`
	Targets              []string                `json:"targets"`
	LegacyPlan           ports.LegacyRemovalPlan `json:"legacy_plan"`
	RequiresConfirmation bool                    `json:"requires_confirmation"`
	Reconciled           bool                    `json:"reconciled,omitempty"`
	Mutated              bool                    `json:"mutated"`
}

type MCPNamespacePreflight

type MCPNamespacePreflight interface {
	CheckMCPNamespace(context.Context, domain.DetectedClient, domain.DeliveryPlan, *domain.ClientBinding) error
}

MCPNamespacePreflight is process-inert and checks the final selected MCP server names against a client's observable user-level configuration.

type NativeIdentityObservation

type NativeIdentityObservation = domain.NativeIdentityObservation

type NativeIdentityObserver

type NativeIdentityObserver interface {
	ObserveNativeIdentity(context.Context, domain.DetectedClient, domain.DeliveryPlan, *domain.ClientBinding) (domain.NativeIdentityObservation, error)
}

NativeIdentityObserver lets a backend prove that a same-name native object is absent or already owned. Unmanaged and indeterminate observations are always blocking; there is deliberately no adoption result.

type NativeIdentityState

type NativeIdentityState = domain.NativeIdentityState

type NativeIntentReconciler

type NativeIntentReconciler interface {
	ReconcileNativeIntent(context.Context, domain.PendingNativeIntent) (domain.ActivationOutcome, error)
}

NativeIntentReconciler is the selected adapter's narrow recovery operation. It must re-read the recorded physical settings and reconcile only the pending selector, refusing drift. It must not restore a document backup, rediscover a profile, or infer ownership from identical bytes without this pending intent. The future facade composes this explicitly; no production Local writer exists.

type PreparedIdentityObserver

type PreparedIdentityObserver interface {
	ObservePreparedIdentity(context.Context, domain.DetectedClient, domain.DeliveryPlan, *domain.ClientBinding) (domain.NativeIdentityObservation, error)
}

PreparedIdentityObserver is the process-inert subset used by dry-run. It may inspect package files and prepared registries, but must not launch a client executable or query a remote registry.

type ProvenanceSummary

type ProvenanceSummary struct {
	Kind             string `json:"kind"`
	Repository       string `json:"repository,omitempty"`
	PackageSubpath   string `json:"package_subpath,omitempty"`
	ResolvedRevision string `json:"resolved_revision,omitempty"`
	TreeDigest       string `json:"tree_digest,omitempty"`
}

type RemoveGroupInput

type RemoveGroupInput struct {
	Selector         string
	Targets          []RemoveInput
	OperationGroupID string
	DryRun           bool
	Confirmed        bool
	PurgeData        bool
}

type RemoveGroupResult

type RemoveGroupResult struct {
	InstallationID   string                   `json:"installation_id"`
	OperationGroupID string                   `json:"operation_group_id,omitempty"`
	Targets          []RemoveResult           `json:"targets"`
	Receipts         []domain.MutationReceipt `json:"-"`
	Mutated          bool                     `json:"mutated"`
	Phase            GroupPhase               `json:"phase"`
	ManagedPhase     GroupPhase               `json:"managed_phase,omitempty"`
}

type RemoveInput

type RemoveInput struct {
	SelectedDelivery     domain.SelectedDelivery
	Selector             string
	Client               domain.DetectedClient
	Scope                domain.InstallScope
	DryRun               bool
	Confirmed            bool
	Interactive          bool
	ExternalUninstalled  bool
	OperationID          string
	BackendExecutable    string
	PurgeData            bool
	EnvironmentAuthority *domain.EnvironmentAuthority
}

type RemoveResult

type RemoveResult struct {
	InstallationID       string                     `json:"installation_id"`
	Plugin               string                     `json:"plugin"`
	ClientID             domain.ClientID            `json:"client_id"`
	RequiresConfirmation bool                       `json:"requires_confirmation"`
	Mutated              bool                       `json:"mutated"`
	Deactivation         domain.DeactivationOutcome `json:"deactivation,omitempty"`
	Receipt              domain.MutationReceipt     `json:"-"`
	AffectedSurfaces     []string                   `json:"affected_surfaces,omitempty"`
	GroupPhase           GroupTargetPhase           `json:"group_phase,omitempty"`
}

type Service

type Service struct {
	CheckNamespace func() error `json:"-"`
	ProjectRoot    string       `json:"-"`

	ClientPreparation ClientPreparation
	// OpenCodeHosts retains the explicit legacy preparation seam for callers
	// without ClientPreparation; production composition uses ClientPreparation.
	OpenCodeHosts ports.OpenCodeHostPreparer
	// PrepareHostsForPreview authorizes online host preparation for a mutation's
	// plan-first pass. Offline callers leave this false, including CLI --dry-run.
	PrepareHostsForPreview bool
	PhysicalAuthority      ports.PhysicalProfileAuthority
	PhysicalProfiles       []domain.DetectedClient

	StateStore transaction.StateStore
	// Paths is required. There is deliberately no default: a silently supplied
	// one would let a caller that forgot to wire it keep running with whatever
	// containment rules that default happened to carry.
	Paths   ports.PathPolicy
	Planner ports.DeliveryPlanner
	Targets ports.DeliveryTargetResolver
	// Detected is the surface map for this operation. The planner is stateless
	// about detection; the use case copies this onto every PlanRequest.
	Detected           map[domain.ClientID]domain.DetectedClient
	Stager             ports.PackageStager
	Activator          ports.ClientActivator
	Legacy             ports.LegacyLifecycle
	LegacyLock         ports.MutationLock
	Lock               ports.MutationLock
	Kernel             transaction.Kernel
	NativeObserver     NativeIdentityObserver
	NamespacePreflight MCPNamespacePreflight
	PluginData         PluginDataManager
	Now                func() time.Time
	// contains filtered or unexported fields
}

func (Service) Add

func (service Service) Add(ctx context.Context, input AddInput) (AddResult, error)

func (Service) AddGroup

func (service Service) AddGroup(ctx context.Context, input GroupInput) (GroupResult, error)

func (Service) ConfirmInterruptedNativeAttempt

func (service Service) ConfirmInterruptedNativeAttempt(ctx context.Context, input InterruptedAttemptInput) (InterruptedAttemptResult, error)

ConfirmInterruptedNativeAttempt settles a native attempt that a killed agentplugins process left open. Under the mutation lock it verifies the binding and its installed package, lets the client adapter prove that no client command of that run is alive and read the client state once, and records only a certain effect: the attempt is closed, the confirmed ownership kept and the binding marked failed, so the ordinary repair or removal decides the rest. A dry run performs the same checks and writes nothing.

func (Service) ConfirmsInterruptedAttempt

func (service Service) ConfirmsInterruptedAttempt(id domain.ClientID, scope domain.InstallScope) bool

ConfirmsInterruptedAttempt reports whether the client can confirm such an attempt in scope.

func (Service) InspectOwnedBinding

func (service Service) InspectOwnedBinding(ctx context.Context, input AddInput, plan domain.DeliveryPlan, installation domain.Installation, binding domain.ClientBinding) (bool, error)

InspectOwnedBinding proves the complete recorded materialization through the same projection and verify-only adapter paths used by repair. It never repairs, acknowledges an attempt, or persists readiness. Known manual registration can be coherent while authentication and activation remain incomplete.

func (Service) InspectOwnedMaterialization

func (service Service) InspectOwnedMaterialization(ctx context.Context, input AddInput, plan domain.DeliveryPlan, installation domain.Installation, binding domain.ClientBinding) (bool, error)

InspectOwnedMaterialization accepts a fresh, adapter-qualified prepared installation without treating it as observed native runtime readiness.

func (Service) InspectOwnedProjection

func (service Service) InspectOwnedProjection(ctx context.Context, input AddInput, plan domain.DeliveryPlan, installation domain.Installation, binding domain.ClientBinding) (bool, error)

InspectOwnedProjection verifies immutable ownership and current projection without asserting that the client has activated or loaded those components.

func (Service) MigrateFormat

func (service Service) MigrateFormat(ctx context.Context, input BindingChangeInput) (BindingChangeResult, error)

func (Service) PurgeRetainedData

func (service Service) PurgeRetainedData(ctx context.Context, selector string, confirmed bool) error

PurgeRetainedData handles the only target-less removal: an explicit purge of a data_retained installation after complete ownership preflight.

func (Service) Rebind

func (service Service) Rebind(ctx context.Context, input BindingChangeInput) (BindingChangeResult, error)

func (Service) RecoverNativeIntent

func (service Service) RecoverNativeIntent(ctx context.Context, installationID, bindingID, attemptID string, reconciler NativeIntentReconciler) error

RecoverNativeIntents uses the same mutation lock, journal and binding state as installation. Its scope is one observed attempt, not every pending profile. A stale observation, missing reconciler or changed package refuses before the native callback. Persisted delivery facts are the only recovery input.

func (Service) RefreshProjection

func (service Service) RefreshProjection(ctx context.Context, input AddInput) (AddResult, error)

RefreshProjection restages an intact, exactly bound package with the caller's current host projection inputs. It is intended for host configuration changes that do not change the resolved package revision. Unlike Repair, it can commit a new projected digest even when the installed package is intact. A repeated refresh with identical projection output is a no-op.

func (Service) Remove

func (service Service) Remove(ctx context.Context, input RemoveInput) (RemoveResult, error)

func (Service) RemoveGroup

func (service Service) RemoveGroup(ctx context.Context, input RemoveGroupInput) (RemoveGroupResult, error)

func (Service) RemoveLegacy

func (service Service) RemoveLegacy(ctx context.Context, input LegacyRemoveInput) (LegacyRemoveResult, error)

func (Service) Repair

func (service Service) Repair(ctx context.Context, input AddInput) (AddResult, error)

Repair replaces a missing or modified managed directory from a freshly resolved package. It never uses a persisted target until that target has been matched to the target resolver's current safe result.

func (Service) RepairGroup

func (service Service) RepairGroup(ctx context.Context, input GroupInput) (GroupResult, error)

func (Service) SwitchGroup

func (service Service) SwitchGroup(ctx context.Context, input GroupInput) (GroupResult, error)

func (Service) SwitchRetained

func (service Service) SwitchRetained(ctx context.Context, input BindingChangeInput, origin domain.OriginMode, directory *domain.DirectoryOrigin) (BindingChangeResult, error)

SwitchRetained changes source only for a data_retained installation. Active installations must use SwitchGroup so every physical binding participates in the staged group transaction.

func (Service) Update

func (service Service) Update(ctx context.Context, input AddInput) (AddResult, error)

Update applies a new package revision. For an unchanged revision whose delivered tree also depends on installer rendering, it first refreshes the projection, so newer rules reach the installed tree; the ordinary update then runs as before, including runtime preparation and resume. Its preview is never reported as unchanged.

func (Service) UpdateGroup

func (service Service) UpdateGroup(ctx context.Context, input GroupInput) (GroupResult, error)

UpdateGroup refreshes every eligible target in turn before the group update. A preview marks those targets as needing confirmation and never as unchanged, and a refresh failure stops before the group update starts.

type TargetChange

type TargetChange struct {
	ClientID        string                      `json:"client_id"`
	Scope           string                      `json:"scope"`
	Materialization domain.MaterializationState `json:"materialization"`
	Decision        string                      `json:"decision"`
}

Jump to

Keyboard shortcuts

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