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,61 @@
|
||||
package catalog
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCond(t *testing.T) {
|
||||
env := Env{Answers: map[string]any{"a": "x", "n": 3, "l": []any{"p", "q"}, "b": true, "e": ""}, Mode: LevelGuided}
|
||||
cases := []struct {
|
||||
c Cond
|
||||
want bool
|
||||
}{
|
||||
{Cond{}, true},
|
||||
{Cond{"a": "x"}, true},
|
||||
{Cond{"a": "y"}, false},
|
||||
{Cond{"a": []any{"y", "x"}}, true},
|
||||
{Cond{"l": "q"}, true},
|
||||
{Cond{"l": "z"}, false},
|
||||
{Cond{"a": map[string]any{"not": "x"}}, false},
|
||||
{Cond{"n": map[string]any{"gte": 3, "lt": 4}}, true},
|
||||
{Cond{"l": map[string]any{"count_gte": 2}}, true},
|
||||
{Cond{"e": map[string]any{"set": false}}, true},
|
||||
{Cond{"missing": map[string]any{"set": true}}, false},
|
||||
{Cond{"b": true}, true},
|
||||
{Cond{"b": "true"}, true},
|
||||
{Cond{"any": []any{map[string]any{"a": "y"}, map[string]any{"n": 3}}}, true},
|
||||
{Cond{"all": []any{map[string]any{"a": "x"}, map[string]any{"n": 4}}}, false},
|
||||
{Cond{"not": map[string]any{"a": "x"}}, false},
|
||||
{Cond{"$mode": "guided"}, true},
|
||||
}
|
||||
for i, c := range cases {
|
||||
got, err := c.c.Eval(env)
|
||||
if err != nil || got != c.want {
|
||||
t.Errorf("%d %v: got %v %v", i, c.c, got, err)
|
||||
}
|
||||
}
|
||||
if _, err := (Cond{"a": map[string]any{"regex": "x"}}).Eval(env); err == nil {
|
||||
t.Error("unknown operator accepted")
|
||||
}
|
||||
deep := Cond{"a": "x"}
|
||||
for i := 0; i < MaxCondDepth+2; i++ {
|
||||
deep = Cond{"not": map[string]any(deep)}
|
||||
}
|
||||
if _, err := deep.Eval(env); err == nil {
|
||||
t.Error("unbounded nesting accepted")
|
||||
}
|
||||
if r := (Cond{"any": []any{map[string]any{"x": 1}}, "y": 2, "$mode": "q"}).Refs(); len(r) != 2 || r[0] != "x" || r[1] != "y" {
|
||||
t.Errorf("refs %v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSafeRelPath(t *testing.T) {
|
||||
for _, ok := range []string{"a/b.yaml", "yamase/yamase.yaml"} {
|
||||
if !SafeRelPath(ok) {
|
||||
t.Errorf("%s rejected", ok)
|
||||
}
|
||||
}
|
||||
for _, bad := range []string{"", "/etc/passwd", "../x", "a/../../x", "a/./b", "a//b", ".hidden/x", `a\b`, "c:/x"} {
|
||||
if SafeRelPath(bad) {
|
||||
t.Errorf("%q accepted", bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user