Files
DeepSeek-Reasonix/cmd/reasonix-studio-host/wiring_test.go
T
yhh 394da0a313 refactor: the kernel's packages live in the layer they belong to
internal/ was 141 packages side by side, so nothing but a reader's memory
said which were foundations and which assembled the rest. Each now sits in a
layer directory, and the directory is the declaration:

  base      L0  foundation with no domain in it
  contract  L1  types and interfaces the layers above agree on
  model, tools, safety, ext, state, platform
            L2  subsystems, peers of one another
  runtime   L3  the turn engine
  session   L4  the controller
  assembly  L5  the composition root
  frontend  L6  cli, serve, acp and the host adapters

Only paths change: package names, code and behaviour do not. Imports,
repolint and coverage baselines, sensitive paths, CI package lists and docs
follow the new paths; release notes keep the paths they were written with,
and sample paths inside tests and fixtures keep theirs.

repolint gains layer-order: a package may import its own layer and those
below it, read from where it lives. The 47 imports that point upward today
are recorded as that rule's opening debt (-allow-widen, a new rule's first
baseline) and can only go down. Most of it is config, which still reaches
into eight subsystems and is the next thing to take apart; the rest is
event, history and a few tools reaching into runtime for types that belong
in contract.
2026-09-23 18:28:21 -07:00

74 lines
2.3 KiB
Go

package main
import (
"go/ast"
"go/parser"
"go/token"
"testing"
"reasonix/internal/base/i18n"
"reasonix/internal/contract/config"
)
// A capability this host implements and does not hand to its hub is one the
// kernel never registers a route for. Nothing fails at compile time, and the
// shell in front of it simply cannot do the thing — which is how remote
// workspaces were missing here while the protocol for them was already green.
func TestTheHostHandsItsHubEveryCapabilityItImplements(t *testing.T) {
file, err := parser.ParseFile(token.NewFileSet(), "main.go", nil, 0)
if err != nil {
t.Fatalf("parse main.go: %v", err)
}
keys := map[string]bool{}
ast.Inspect(file, func(n ast.Node) bool {
lit, ok := n.(*ast.CompositeLit)
if !ok {
return true
}
sel, ok := lit.Type.(*ast.SelectorExpr)
if !ok || sel.Sel.Name != "HubOptions" {
return true
}
for _, elt := range lit.Elts {
if kv, ok := elt.(*ast.KeyValueExpr); ok {
if key, ok := kv.Key.(*ast.Ident); ok {
keys[key.Name] = true
}
}
}
return false
})
if len(keys) == 0 {
t.Fatal("no hub options found; this guard is watching nothing")
}
for _, want := range []string{"Tray", "Asks", "Remote", "DecorateSink", "Grant"} {
if !keys[want] {
t.Errorf("the hub is built without %s, so nothing can reach what this host implements for it", want)
}
}
}
// The kernel renders text of its own — the built-in slash hints are the ones a
// window shows — and it renders them from a process-wide catalogue that
// something has to point at a language. Every other entry point does it; this
// host did not, and English reached windows set to Chinese for as long as that
// was true. Restored after, because the catalogue outlives the test.
func TestTheHostPointsTheKernelsCatalogueAtTheConfiguredLanguage(t *testing.T) {
t.Cleanup(func() { i18n.DetectLanguage("en") })
for _, tt := range []struct {
lang string
want string
}{
{lang: "zh", want: i18n.Chinese.CmdContext},
{lang: "en", want: i18n.English.CmdContext},
} {
if got := resolveKernelLanguage(&config.Config{Language: tt.lang}); got == "" {
t.Fatalf("language %q resolved to nothing", tt.lang)
}
if i18n.M.CmdContext != tt.want {
t.Errorf("language %q: kernel says %q, want %q", tt.lang, i18n.M.CmdContext, tt.want)
}
}
}