config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config admits one project-local configuration and projects the fixed runtime policy consumed by review composition.

Index

Constants

View Source
const (
	ConfigVersion    = 1
	DefaultKimiModel = "kimi-code/kimi-for-coding"
	// DefaultAGYPermissionMode keeps AGY headless reviews inside Mulgae's
	// read-oriented permission boundary. The bounded snapshot and --sandbox
	// remain the workspace authority; write/shell requests stay soft-denied.
	// Explicit permission_mode: "dangerously-skip-permissions" remains opt-in.
	DefaultAGYPermissionMode  = "safe"
	SafeAGYPermissionMode     = "safe"
	HeadlessAGYPermissionMode = "dangerously-skip-permissions"
	DefaultProviderTimeout    = 15 * time.Minute
	MinimumProviderTimeout    = time.Minute
	MaximumProviderTimeout    = 60 * time.Minute
	ConfigRelativePath        = ".mulgae/config.yaml"
	MaximumConfigBytes        = 1 << 20
	ProjectKindNonUI          = "non_ui"
	ProjectKindUI             = "ui"
)

Variables

This section is empty.

Functions

func DefaultKimiDataHome

func DefaultKimiDataHome(nativeHome string) string

func NewAdmissionError

func NewAdmissionError(reason ReasonCode) error

func ParseProviderTimeout added in v0.1.2

func ParseProviderTimeout(value string) (time.Duration, error)

ParseProviderTimeout resolves an optional Config v1 provider timeout. An omitted value uses the fixed 15-minute default; admitted explicit values are bounded inclusively between one and sixty minutes.

func ProviderTimeoutText added in v0.1.2

func ProviderTimeoutText(timeout time.Duration) string

ProviderTimeoutText returns the stable Config v1 spelling for a valid provider timeout. Whole-minute values use the concise "30m" form.

func RunTotalOutputCapBytes

func RunTotalOutputCapBytes(config Config) (int64, error)

Types

type AGYProviderConfig

type AGYProviderConfig struct {
	Executable             string `yaml:"executable" json:"executable"`
	PermissionMode         string `yaml:"permission_mode,omitempty" json:"permission_mode"`
	Timeout                string `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	PermissionModeExplicit bool   `yaml:"-" json:"-"`
}

type AdmissionError

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

func AsAdmissionError

func AsAdmissionError(err error) (*AdmissionError, bool)

func (*AdmissionError) Error

func (err *AdmissionError) Error() string

func (*AdmissionError) Reason

func (err *AdmissionError) Reason() ReasonCode

type ArtistInputsConfig

type ArtistInputsConfig struct {
	TaskPath        string   `yaml:"task_path" json:"task_path"`
	DesignSpecGlobs []string `yaml:"design_spec_globs" json:"design_spec_globs"`
}

type CIConfig

type CIConfig struct {
	FailOnSeverity      []string `yaml:"fail_on_severity" json:"fail_on_severity"`
	DegradedReviewFails bool     `yaml:"degraded_review_fails" json:"degraded_review_fails"`
}

type Codec

type Codec interface {
	Decode([]byte) (Config, error)
	EncodeCanonical(Config) ([]byte, error)
}

Codec keeps serialization mechanics outside the application layer.

type Config

type Config struct {
	Version    int              `yaml:"version" json:"version"`
	Project    ProjectConfig    `yaml:"project" json:"project"`
	NativeUser NativeUserConfig `yaml:"native_user" json:"native_user"`
	Providers  ProvidersConfig  `yaml:"providers" json:"providers"`
	Execution  ExecutionConfig  `yaml:"execution" json:"execution"`
	Roles      RolesConfig      `yaml:"roles" json:"roles"`
	Review     ReviewConfig     `yaml:"review" json:"review"`
	Validation ValidationConfig `yaml:"validation" json:"validation"`
	Resources  ResourcesConfig  `yaml:"resources" json:"resources"`
	CI         CIConfig         `yaml:"ci" json:"ci"`
}

Config is the sole project-local Mulgae configuration authority.

type EvidenceConfig

type EvidenceConfig struct {
	RequireVerifiedFor []string `yaml:"require_verified_for" json:"require_verified_for"`
}

type ExecutionConfig

type ExecutionConfig struct {
	WorkspaceAccess string `yaml:"workspace_access" json:"workspace_access"`
}

type KimiProviderConfig

type KimiProviderConfig struct {
	Executable string `yaml:"executable" json:"executable"`
	Model      string `yaml:"model,omitempty" json:"model"`
	DataHome   string `yaml:"data_home,omitempty" json:"data_home"`
	Timeout    string `yaml:"timeout,omitempty" json:"timeout,omitempty"`
}

type NativeUserConfig

type NativeUserConfig struct {
	Home string `yaml:"home" json:"home"`
}

type ProjectConfig

type ProjectConfig struct {
	Name    string `yaml:"name" json:"name"`
	Context string `yaml:"context,omitempty" json:"context,omitempty"`
	Kind    string `yaml:"kind,omitempty" json:"kind,omitempty"`
}

type ProvenanceRow

type ProvenanceRow struct {
	Field       string `json:"field"`
	Source      string `json:"source"`
	Disposition string `json:"disposition"`
	ValueClass  string `json:"value_class"`
}

type ProvidersConfig

type ProvidersConfig struct {
	Kimi  *KimiProviderConfig  `yaml:"kimi,omitempty" json:"kimi,omitempty"`
	ZCode *ZCodeProviderConfig `yaml:"zcode,omitempty" json:"zcode,omitempty"`
	AGY   *AGYProviderConfig   `yaml:"agy,omitempty" json:"agy,omitempty"`
}

func (ProvidersConfig) Count

func (providers ProvidersConfig) Count() int

func (ProvidersConfig) Families

func (providers ProvidersConfig) Families() []string

func (ProvidersConfig) HasFamily

func (providers ProvidersConfig) HasFamily(family string) bool

HasFamily reports whether a provider family is explicitly configured.

type ReasonCode

type ReasonCode string
const (
	ReasonYAMLInvalid             ReasonCode = "config_yaml_invalid"
	ReasonSizeInvalid             ReasonCode = "config_size_invalid"
	ReasonProviderTimeoutInvalid  ReasonCode = "config_provider_timeout_invalid"
	ReasonCredentialKeyDetected   ReasonCode = "config_credential_key_detected"
	ReasonCredentialValueDetected ReasonCode = "config_credential_value_detected"
)

type RedactedConfig

type RedactedConfig struct {
	ConfiguredProviderIDs []string       `json:"configured_provider_ids" yaml:"configured_provider_ids"`
	Policy                RedactedPolicy `json:"policy" yaml:"policy"`
}

func Redact

func Redact(resolved ResolvedConfig) RedactedConfig

type RedactedPolicy

type RedactedPolicy struct {
	RoleAssignments        []RedactedRoleAssignment  `json:"role_assignments" yaml:"role_assignments"`
	ProviderTimeouts       []RedactedProviderTimeout `json:"provider_timeouts" yaml:"provider_timeouts"`
	AGYPermissionMode      string                    `json:"agy_permission_mode,omitempty" yaml:"agy_permission_mode,omitempty"`
	Warnings               []string                  `json:"warnings" yaml:"warnings"`
	RequiredRoles          []domain.Role             `json:"required_roles" yaml:"required_roles"`
	WorkspaceAccess        WorkspaceAccess           `json:"workspace_access" yaml:"workspace_access"`
	RequestChangesOn       []domain.Severity         `json:"request_changes_on" yaml:"request_changes_on"`
	RequireVerifiedFor     []domain.Severity         `json:"require_verified_for" yaml:"require_verified_for"`
	RoleMaxInvocations     int                       `json:"role_max_invocations" yaml:"role_max_invocations"`
	RunMaxInvocations      int                       `json:"run_max_invocations" yaml:"run_max_invocations"`
	RunTotalOutputCapBytes int64                     `json:"run_total_output_cap_bytes" yaml:"run_total_output_cap_bytes"`
	CIFailOnSeverity       []domain.Severity         `json:"ci_fail_on_severity" yaml:"ci_fail_on_severity"`
	DegradedReviewFails    bool                      `json:"degraded_review_fails" yaml:"degraded_review_fails"`
}

type RedactedProviderTimeout added in v0.1.2

type RedactedProviderTimeout struct {
	Family  string `json:"family" yaml:"family"`
	Timeout string `json:"timeout" yaml:"timeout"`
}

type RedactedRoleAssignment

type RedactedRoleAssignment struct {
	Role            domain.Role `json:"role" yaml:"role"`
	PrimaryProvider string      `json:"primary_provider" yaml:"primary_provider"`
}

type RepairConfig

type RepairConfig struct {
	Enabled      bool `yaml:"enabled" json:"enabled"`
	MaxAttempts  int  `yaml:"max_attempts" json:"max_attempts"`
	SameProvider bool `yaml:"same_provider" json:"same_provider"`
}

type Resolution

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

func (Resolution) CanonicalYAML

func (resolution Resolution) CanonicalYAML() []byte

func (Resolution) Config

func (resolution Resolution) Config() ResolvedConfig

func (Resolution) Provenance

func (resolution Resolution) Provenance() []ProvenanceRow

func (Resolution) RedactedJSON

func (resolution Resolution) RedactedJSON() []byte

func (Resolution) Revalidate

func (resolution Resolution) Revalidate() error

func (Resolution) SHA256

func (resolution Resolution) SHA256() string

func (Resolution) URI

func (resolution Resolution) URI() string

type ResolveRequest

type ResolveRequest struct {
	Source ports.ConfigSource
}

type ResolvedConfig

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

func ResolveConfiguration

func ResolveConfiguration(raw Config) (ResolvedConfig, error)

func (ResolvedConfig) CIFailOnSeverity

func (resolved ResolvedConfig) CIFailOnSeverity() []domain.Severity

func (ResolvedConfig) DegradedReviewFails

func (resolved ResolvedConfig) DegradedReviewFails() bool

func (ResolvedConfig) ProviderTimeout added in v0.1.2

func (resolved ResolvedConfig) ProviderTimeout(family string) (time.Duration, bool)

ProviderTimeout returns the effective timeout for a configured provider family. The boolean is false for an absent or unknown family.

func (ResolvedConfig) Providers

func (resolved ResolvedConfig) Providers() ProvidersConfig

func (ResolvedConfig) Raw

func (resolved ResolvedConfig) Raw() Config

func (ResolvedConfig) Redacted

func (resolved ResolvedConfig) Redacted() RedactedConfig

func (ResolvedConfig) RequestChangesOn

func (resolved ResolvedConfig) RequestChangesOn() []domain.Severity

func (ResolvedConfig) RequireVerifiedFor

func (resolved ResolvedConfig) RequireVerifiedFor() []domain.Severity

func (ResolvedConfig) RequiredRoles

func (resolved ResolvedConfig) RequiredRoles() []domain.Role

func (ResolvedConfig) Role

func (resolved ResolvedConfig) Role(role domain.Role) (ResolvedRole, bool)

func (ResolvedConfig) RoleMaxInvocations

func (resolved ResolvedConfig) RoleMaxInvocations() int

func (ResolvedConfig) RunMaxInvocations

func (resolved ResolvedConfig) RunMaxInvocations() int

func (ResolvedConfig) RunTotalOutputCapBytes

func (resolved ResolvedConfig) RunTotalOutputCapBytes() int64

func (ResolvedConfig) Runtime

func (resolved ResolvedConfig) Runtime() RuntimePolicy

func (ResolvedConfig) WorkspaceAccess

func (resolved ResolvedConfig) WorkspaceAccess() WorkspaceAccess

type ResolvedRole

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

func (ResolvedRole) Enabled

func (role ResolvedRole) Enabled() bool

func (ResolvedRole) PrimaryProvider

func (role ResolvedRole) PrimaryProvider() string

type ResourcesConfig

type ResourcesConfig struct {
	MaxActiveLanes        int    `yaml:"max_active_lanes" json:"max_active_lanes"`
	PrimaryRepairAttempts int    `yaml:"primary_repair_attempts" json:"primary_repair_attempts"`
	RoleMaxInvocations    int    `yaml:"role_max_invocations" json:"role_max_invocations"`
	RunMaxInvocations     int    `yaml:"run_max_invocations" json:"run_max_invocations"`
	RunTotalOutputCap     string `yaml:"run_total_output_cap" json:"run_total_output_cap"`
}

type ReviewConfig

type ReviewConfig struct {
	RequiredRoles    []string `yaml:"required_roles" json:"required_roles"`
	RequestChangesOn []string `yaml:"request_changes_on" json:"request_changes_on"`
}

type RoleConfig

type RoleConfig struct {
	Enabled         bool                `yaml:"enabled" json:"enabled"`
	PrimaryProvider string              `yaml:"primary_provider" json:"primary_provider"`
	Inputs          *ArtistInputsConfig `yaml:"inputs,omitempty" json:"inputs,omitempty"`
}

type RoleDefault added in v0.1.4

type RoleDefault struct {
	ProviderPreferences   []string
	ArtistTaskPath        string
	ArtistDesignSpecGlobs []string
}

RoleDefault is one role's build-owned generation-time default.

ProviderPreferences is an ordered family preference: the first configured family becomes the role's provider. Later entries keep the derivation total when a project configures a different provider set; they are not a fallback route, because a role runs on exactly one provider. The artist fields are populated only for the artist role.

type RoleDefaults added in v0.1.4

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

RoleDefaults is the validated, immutable set of build-owned defaults for every fixed role. It is the sole source of init's default provider routing and of the artist input defaults; no default assignment is spelled in Go.

func NewRoleDefaults added in v0.1.4

func NewRoleDefaults(entries map[domain.Role]RoleDefault) (RoleDefaults, error)

NewRoleDefaults validates and deep-copies a complete set of role defaults.

Every core role must name all three provider families. That keeps the derivation total: the intersection with any non-empty configured family set is never empty, so a role can never resolve to no primary provider.

func (RoleDefaults) Role added in v0.1.4

func (defaults RoleDefaults) Role(role domain.Role) (RoleDefault, bool)

Role returns a caller-owned copy of one role's defaults.

func (RoleDefaults) Valid added in v0.1.4

func (defaults RoleDefaults) Valid() bool

Valid reports whether the defaults carry every fixed role.

type RolesConfig

type RolesConfig struct {
	Logic           RoleConfig `yaml:"logic" json:"logic"`
	Security        RoleConfig `yaml:"security" json:"security"`
	Maintainability RoleConfig `yaml:"maintainability" json:"maintainability"`
	Product         RoleConfig `yaml:"product" json:"product"`
	Documentation   RoleConfig `yaml:"documentation" json:"documentation"`
	Testing         RoleConfig `yaml:"testing" json:"testing"`
	Artist          RoleConfig `yaml:"artist,omitempty" json:"artist,omitempty"`
}

func CanonicalRolesConfig

func CanonicalRolesConfig(defaults RoleDefaults, families []string) (RolesConfig, error)

CanonicalRolesConfig derives init's deterministic role assignments from the build-owned role defaults and the selected provider subset. Persisted configs remain explicit; runtime never calls this function to invent an assignment.

func CanonicalRolesConfigForSelection

func CanonicalRolesConfigForSelection(defaults RoleDefaults, families, selectedRoles []string) (RolesConfig, error)

CanonicalRolesConfigForSelection derives the deterministic assignments for every Config v1 role while enabling only the canonical project role set. Logic forms the project-level floor, not a per-run selection.

Each role resolves independently from its own build-owned preference order, so editing one role's defaults never moves another role's assignment.

func CanonicalRolesConfigForUI

func CanonicalRolesConfigForUI(defaults RoleDefaults, families []string) (RolesConfig, error)

func (RolesConfig) Ordered

func (roles RolesConfig) Ordered() []RoleConfig

Ordered returns the role configurations in canonical role order.

type RuntimePolicy

type RuntimePolicy struct{ MaxActiveLanes int }

type Service

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

func NewService

func NewService(codec Codec) *Service

func (*Service) Resolve

func (service *Service) Resolve(ctx context.Context, request ResolveRequest) (Resolution, error)

type ValidationConfig

type ValidationConfig struct {
	Evidence EvidenceConfig `yaml:"evidence" json:"evidence"`
	Repair   RepairConfig   `yaml:"repair" json:"repair"`
}

type WorkspaceAccess

type WorkspaceAccess string
const (
	WorkspaceNone             WorkspaceAccess = "none"
	WorkspaceReadonlySnapshot WorkspaceAccess = "readonly_snapshot"
)

func (WorkspaceAccess) Valid

func (access WorkspaceAccess) Valid() bool

type ZCodeProviderConfig

type ZCodeProviderConfig struct {
	NodeExecutable string `yaml:"node_executable" json:"node_executable"`
	Launcher       string `yaml:"launcher" json:"launcher"`
	Timeout        string `yaml:"timeout,omitempty" json:"timeout,omitempty"`
}

Jump to

Keyboard shortcuts

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