init

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package init implements project-local configuration discovery, bootstrap, machine-local refresh, and crash-truthful installation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderConfigYAML

func RenderConfigYAML(codec appconfig.Codec, config appconfig.Config) ([]byte, error)

Types

type DiscoveryRow

type DiscoveryRow struct {
	Family                string `json:"family"`
	Selected              bool   `json:"selected"`
	Candidate             bool   `json:"candidate"`
	Configured            bool   `json:"configured"`
	Status                string `json:"status"`
	Reason                string `json:"reason,omitempty"`
	ExecutableSource      string `json:"executable_source,omitempty"`
	ModelSource           string `json:"model_source,omitempty"`
	DataHomeSource        string `json:"data_home_source,omitempty"`
	NodeExecutableSource  string `json:"node_executable_source,omitempty"`
	LauncherSource        string `json:"launcher_source,omitempty"`
	NativeHomeSource      string `json:"native_home_source,omitempty"`
	PermissionModeSource  string `json:"permission_mode_source,omitempty"`
	ReasoningEffortSource string `json:"reasoning_effort_source,omitempty"`
}

type DiscoverySourceFieldSpec

type DiscoverySourceFieldSpec struct {
	JSONName string
	Values   []string
}

DiscoverySourceFieldSpec defines one exact family-specific init discovery source field and its closed wire values.

type DiscoverySourceSpec

type DiscoverySourceSpec struct {
	Family string
	Fields []DiscoverySourceFieldSpec
}

DiscoverySourceSpec defines one branch of the init discovery discriminated union.

func DiscoverySourceSpecs

func DiscoverySourceSpecs() []DiscoverySourceSpec

DiscoverySourceSpecs returns a caller-owned copy of the command-owned source contract.

type Failure

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

func (*Failure) Class

func (failure *Failure) Class() domain.FailureClass

func (*Failure) Code

func (failure *Failure) Code() string

func (*Failure) Error

func (failure *Failure) Error() string

func (*Failure) Message

func (failure *Failure) Message() string

func (*Failure) Retryable

func (failure *Failure) Retryable() bool

func (*Failure) Unwrap

func (failure *Failure) Unwrap() error

type InitializeProjectRequest

type InitializeProjectRequest struct {
	ProjectRoot           ports.AnchoredRoot
	ProjectName           string
	ContextPath           string
	ProjectKind           string
	ArtistBriefPath       string
	ArtistDesignSpecGlobs []string
	NativeHome            string
	// NativeHomeAsserted records whether --native-home was supplied and verified
	// equal to the installed account home by the command boundary.
	NativeHomeAsserted   bool
	Selection            Selection
	RoleIDs              []string
	Overrides            Overrides
	RefreshLocal         bool
	ProjectPolicyOptions bool
}

type InitializeProjectResult

type InitializeProjectResult struct {
	Kind                  string                       `json:"kind"`
	ConfigURI             string                       `json:"config_uri"`
	ConfigSHA256          string                       `json:"config_sha256"`
	SelectedProviderIDs   []string                     `json:"selected_provider_ids"`
	CandidateProviderIDs  []string                     `json:"candidate_provider_ids"`
	ConfiguredProviderIDs []string                     `json:"configured_provider_ids"`
	ConfiguredRoleIDs     []string                     `json:"configured_role_ids"`
	WriteState            string                       `json:"write_state"`
	Committed             bool                         `json:"committed"`
	DestinationState      ports.ConfigDestinationState `json:"destination_state"`
	Discovery             []DiscoveryRow               `json:"discovery"`
}

func NewObservedFailureResult

func NewObservedFailureResult(selection Selection, destination ports.ConfigDestinationState) (InitializeProjectResult, error)

NewObservedFailureResult constructs the truthful pre-discovery projection used when the command boundary has observed the config destination before it can establish the native account identity.

func NewRejectedRequestResult

func NewRejectedRequestResult() InitializeProjectResult

NewRejectedRequestResult constructs the only truthful result projection for an init request rejected before a contract-valid selection can be frozen.

func (InitializeProjectResult) Validate

func (result InitializeProjectResult) Validate() error

Validate enforces the command-owned semantic relationship between the init result projections. JSON Schema additionally validates their wire shape.

type MutationOutcomeSpec

type MutationOutcomeSpec struct {
	Kind         string                       `json:"kind"`
	WriteState   string                       `json:"write_state"`
	Code         string                       `json:"code,omitempty"`
	Committed    bool                         `json:"committed"`
	Destination  ports.ConfigDestinationState `json:"destination_state"`
	Class        domain.FailureClass          `json:"class,omitempty"`
	Message      string                       `json:"message,omitempty"`
	Retryable    bool                         `json:"retryable"`
	DeliveryOnly bool                         `json:"delivery_only,omitempty"`
}

func MutationOutcomeSpecs

func MutationOutcomeSpecs() []MutationOutcomeSpec

type Overrides

type Overrides struct {
	KimiExecutable       string
	KimiModel            string
	KimiDataHome         string
	ZCodeNodeExecutable  string
	ZCodeLauncher        string
	AGYExecutable        string
	AGYPermissionMode    string
	CodexExecutable      string
	CodexModel           string
	CodexReasoningEffort string
}

type PrevalidatedOutcome

type PrevalidatedOutcome struct {
	Result  InitializeProjectResult
	Failure *Failure
}

PrevalidatedOutcome is one exact result and optional failure envelope that may be selected after filesystem mutation.

func (PrevalidatedOutcome) Validate

func (outcome PrevalidatedOutcome) Validate() error

Validate requires an exact row from the command-owned post-mutation outcome table. Result.Validate owns the result projection itself; this method also binds the failure class, code, message, and retryability to that projection.

type ResultPrevalidator

type ResultPrevalidator interface {
	PrevalidateInitOutcome(context.Context, PrevalidatedOutcome) error
}

ResultPrevalidator validates every exact result/failure envelope that can be selected after filesystem mutation.

type ResultPrevalidatorFunc

type ResultPrevalidatorFunc func(context.Context, PrevalidatedOutcome) error

ResultPrevalidatorFunc adapts a function to ResultPrevalidator.

func (ResultPrevalidatorFunc) PrevalidateInitOutcome

func (function ResultPrevalidatorFunc) PrevalidateInitOutcome(ctx context.Context, outcome PrevalidatedOutcome) error

type Selection

type Selection struct {
	Mode        SelectionMode
	ProviderIDs []string
}

type SelectionMode

type SelectionMode string
const (
	SelectionAuto     SelectionMode = "auto"
	SelectionSelected SelectionMode = "selected"
)

type Service

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

func NewService

func NewService(installer ports.ConfigInstaller, inspector ports.EnvironmentInspector, attestor ports.ConfigLocalityAttestor, prevalidator ResultPrevalidator, clock ports.Clock, sources ports.ConfigSourceFactory, codec appconfig.Codec, catalog ports.ContractCatalog) (*Service, error)

func (*Service) InitializeProject

func (service *Service) InitializeProject(ctx context.Context, request InitializeProjectRequest) (InitializeProjectResult, error)

Jump to

Keyboard shortcuts

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