solutions: Solutions Guide engine (catalog, rules, wizard state, native config, knowledge index, CLI)
New nested module yetano.dev/yetano/core/solutions: loads the catalog in assets/solutions on top of the Big Picture, evaluates questions and conditions, resolves packages/modules/capabilities, generates native configuration from typed fragments with per-value origins, and builds architecture graph, plan, lock file and handbook. Knowledge index with yetano: references, search and lint (incl. manual sections). CLI with yet's conventions (solution, task, knowledge, open), standalone as yetano-solutions. No execution, no network. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
586e76889c
commit
2481a0dd27
48 files changed
+10304
No files matched your search
@@ -0,0 +1,236 @@
|
||||
package engine
|
||||
|
||||
import "yetano.dev/yetano/core/solutions/catalog"
|
||||
|
||||
// State is the complete result of evaluating an instance: everything a
|
||||
// client shows. Clients never compute visibility, options or resolution
|
||||
// themselves (API-02); they render a State.
|
||||
type State struct {
|
||||
Solution SolutionInfo `json:"solution"`
|
||||
Instance string `json:"instance"`
|
||||
Mode catalog.Level `json:"mode"`
|
||||
Locale string `json:"locale"`
|
||||
Platform string `json:"platform,omitempty"`
|
||||
Questions []QuestionState `json:"questions"`
|
||||
Next string `json:"next,omitempty"`
|
||||
Progress Progress `json:"progress"`
|
||||
Complete bool `json:"complete"`
|
||||
Answers map[string]Answer `json:"answers"`
|
||||
Stale []StaleAnswer `json:"stale,omitempty"`
|
||||
Packages []PackageState `json:"packages"`
|
||||
Capabilities []CapState `json:"capabilities"`
|
||||
Rules []AppliedRule `json:"rules"`
|
||||
Messages []Message `json:"messages"`
|
||||
Recommended []Recommendation `json:"recommendations,omitempty"`
|
||||
Files []FilePreview `json:"files"`
|
||||
Steps []PlannedStep `json:"steps"`
|
||||
Checks []CheckResult `json:"checks"`
|
||||
Graph Graph `json:"graph"`
|
||||
References []string `json:"references"`
|
||||
Related []string `json:"related,omitempty"`
|
||||
}
|
||||
|
||||
// SolutionInfo identifies the evaluated solution or task.
|
||||
type SolutionInfo struct {
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
TaskKind string `json:"taskKind,omitempty"`
|
||||
Version string `json:"version"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary,omitempty"`
|
||||
Status catalog.Support `json:"status"`
|
||||
Category string `json:"category,omitempty"`
|
||||
BigPicture string `json:"bigpicture,omitempty"`
|
||||
}
|
||||
|
||||
// QuestionState is one question as the client shows it.
|
||||
type QuestionState struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Item string `json:"item,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Level catalog.Level `json:"level"`
|
||||
Title string `json:"title"`
|
||||
Help string `json:"help,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Decide string `json:"decide,omitempty"`
|
||||
Placeholder string `json:"placeholder,omitempty"`
|
||||
Examples []string `json:"examples,omitempty"`
|
||||
Visible bool `json:"visible"`
|
||||
Asked bool `json:"asked"` // shown in the current mode
|
||||
Required bool `json:"required"`
|
||||
InstanceSpecific bool `json:"instanceSpecific,omitempty"`
|
||||
Value any `json:"value,omitempty"`
|
||||
Origin string `json:"origin,omitempty"` // default | preset | instance | ""
|
||||
Default any `json:"default,omitempty"`
|
||||
Recommended any `json:"recommended,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Options []OptionState `json:"options,omitempty"`
|
||||
Errors []string `json:"errors,omitempty"`
|
||||
Warnings []Message `json:"warnings,omitempty"`
|
||||
References []string `json:"references,omitempty"`
|
||||
}
|
||||
|
||||
// OptionState is one option with whether and why it can be chosen.
|
||||
type OptionState struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Recommended bool `json:"recommended,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Support catalog.Support `json:"support"`
|
||||
SupportNote string `json:"supportNote,omitempty"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Disabled string `json:"disabledReason,omitempty"`
|
||||
Selected bool `json:"selected"`
|
||||
Adds []string `json:"adds,omitempty"` // packages/capabilities it brings in
|
||||
References []string `json:"references,omitempty"`
|
||||
}
|
||||
|
||||
// Progress counts asked questions.
|
||||
type Progress struct {
|
||||
Asked int `json:"asked"`
|
||||
Answered int `json:"answered"`
|
||||
Missing []string `json:"missing,omitempty"`
|
||||
Step int `json:"step"` // 1-based index of Next among asked questions
|
||||
}
|
||||
|
||||
// Answer is an effective answer and where it came from.
|
||||
type Answer struct {
|
||||
Value any `json:"value"`
|
||||
Origin string `json:"origin"`
|
||||
}
|
||||
|
||||
// StaleAnswer is an explicit answer that no longer counts (RULE-06).
|
||||
type StaleAnswer struct {
|
||||
Question string `json:"question"`
|
||||
Value any `json:"value"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
// Status values of packages, modules and capabilities in a state and a graph (BP-04).
|
||||
const (
|
||||
StRequired = "required"
|
||||
StSelected = "selected"
|
||||
StRecommended = "recommended"
|
||||
StOptional = "optional"
|
||||
StExternal = "external"
|
||||
StAlternative = "alternative"
|
||||
StDisabled = "disabled"
|
||||
StUnsupported = "unsupported"
|
||||
StMissing = "missing"
|
||||
StConflicting = "conflicting"
|
||||
StExcluded = "excluded"
|
||||
)
|
||||
|
||||
// PackageState is a package in the resolved solution.
|
||||
type PackageState struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Profile string `json:"profile,omitempty"`
|
||||
Reasons []string `json:"reasons"`
|
||||
Modules []ModuleState `json:"modules,omitempty"`
|
||||
Selected bool `json:"selected"`
|
||||
}
|
||||
|
||||
// ModuleState is a module of a selected package.
|
||||
type ModuleState struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Program string `json:"program,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Support catalog.Support `json:"support,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// CapState is a capability in the resolved solution.
|
||||
type CapState struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Status string `json:"status"`
|
||||
Provider string `json:"provider,omitempty"` // pkg/module or external:<id>
|
||||
Alternatives []string `json:"alternatives,omitempty"`
|
||||
Reasons []string `json:"reasons"`
|
||||
}
|
||||
|
||||
// AppliedRule records a rule (or an option's effects) that fired.
|
||||
type AppliedRule struct {
|
||||
ID string `json:"id"`
|
||||
Source string `json:"source"` // rule | option | package | capability
|
||||
Effect string `json:"effect"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Message is a warning, error or note.
|
||||
type Message struct {
|
||||
Severity string `json:"severity"` // info | warning | error
|
||||
Code string `json:"code"`
|
||||
Text string `json:"text"`
|
||||
Source string `json:"source,omitempty"`
|
||||
}
|
||||
|
||||
// Recommendation suggests an extension.
|
||||
type Recommendation struct {
|
||||
Package string `json:"package,omitempty"`
|
||||
Capability string `json:"capability,omitempty"`
|
||||
Reason string `json:"reason"`
|
||||
Source string `json:"source,omitempty"`
|
||||
}
|
||||
|
||||
// FilePreview is one generated file.
|
||||
type FilePreview struct {
|
||||
Path string `json:"path"`
|
||||
Package string `json:"package"`
|
||||
Content string `json:"content"`
|
||||
Origins map[string]Origin `json:"origins"`
|
||||
}
|
||||
|
||||
// Origin says where a configuration value came from (PROF-05).
|
||||
type Origin struct {
|
||||
Layer string `json:"layer"` // profile | solution | override
|
||||
Source string `json:"source"` // profile:yamase/mailbox, solution:mail-server#tls, override
|
||||
Params []string `json:"params,omitempty"`
|
||||
}
|
||||
|
||||
// PlannedStep is a setup step (never executed by the engine).
|
||||
type PlannedStep struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Phase string `json:"phase"`
|
||||
Package string `json:"package,omitempty"`
|
||||
Module string `json:"module,omitempty"`
|
||||
Run string `json:"run,omitempty"`
|
||||
Note string `json:"note,omitempty"`
|
||||
Mutating bool `json:"mutating"`
|
||||
Reversible *bool `json:"reversible,omitempty"`
|
||||
References []string `json:"references,omitempty"`
|
||||
}
|
||||
|
||||
// Check status values (DR-03).
|
||||
const (
|
||||
CheckPass = "PASS"
|
||||
CheckInfo = "INFO"
|
||||
CheckWarning = "WARNING"
|
||||
CheckError = "ERROR"
|
||||
CheckBlocked = "BLOCKED"
|
||||
CheckNotApplicable = "NOT_APPLICABLE"
|
||||
CheckNotChecked = "NOT_CHECKED"
|
||||
)
|
||||
|
||||
// CheckResult is a requirement/doctor check and its result.
|
||||
type CheckResult struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Kind string `json:"kind"`
|
||||
Severity string `json:"severity"`
|
||||
Local bool `json:"local"`
|
||||
Params map[string]string `json:"params,omitempty"`
|
||||
Run string `json:"run,omitempty"`
|
||||
Hint string `json:"hint,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Note string `json:"note,omitempty"`
|
||||
References []string `json:"references,omitempty"`
|
||||
}
|
||||
Reference in new issue
Block a user