mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
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.
132 lines
3.9 KiB
Go
132 lines
3.9 KiB
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"reasonix/internal/platform/installlayout"
|
|
"reasonix/internal/platform/repair"
|
|
|
|
"reasonix/internal/base/tempdir"
|
|
)
|
|
|
|
func TestPreferVersionedWindowsActivation(t *testing.T) {
|
|
staging := tempdir.New(t)
|
|
if preferVersionedWindowsActivation(staging) {
|
|
t.Fatal("empty staging must not prefer versioned")
|
|
}
|
|
for _, name := range []string{
|
|
"reasonix-desktop.exe",
|
|
"reasonix-cli.exe",
|
|
"reasonix-update-helper.exe",
|
|
"reasonix-launcher.exe",
|
|
} {
|
|
if err := os.WriteFile(filepath.Join(staging, name), []byte(name), 0o700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if !preferVersionedWindowsActivation(staging) {
|
|
t.Fatal("complete staging must prefer versioned")
|
|
}
|
|
}
|
|
|
|
func TestActivateVersionedWindowsFromStaging(t *testing.T) {
|
|
installDir := tempdir.New(t)
|
|
staging := tempdir.New(t)
|
|
for _, name := range []string{
|
|
"reasonix-desktop.exe",
|
|
"reasonix-cli.exe",
|
|
"reasonix-update-helper.exe",
|
|
"reasonix-launcher.exe",
|
|
"reasonix-guard.exe",
|
|
} {
|
|
if err := os.WriteFile(filepath.Join(staging, name), []byte("payload:"+name), 0o700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
// Seed a flat desktop so cleanup is observable.
|
|
if err := os.WriteFile(filepath.Join(installDir, "reasonix-desktop.exe"), []byte("old"), 0o700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(installDir, "reasonix-guard.exe"), []byte("old-guard"), 0o700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
claimed := &repair.UpdateTransaction{
|
|
SchemaVersion: 1,
|
|
ToVersion: "v1.20.0",
|
|
TargetKind: "file",
|
|
TargetPath: filepath.Join(installDir, "reasonix-desktop.exe"),
|
|
CreatedAt: "2026-01-01T00:00:00Z",
|
|
}
|
|
if err := activateVersionedWindowsFromStaging(claimed, staging); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !installlayout.HasCurrent(installDir) {
|
|
t.Fatal("current.json missing")
|
|
}
|
|
ptr, err := installlayout.ReadCurrent(installDir)
|
|
if err != nil || ptr.ActiveVersion != "v1.20.0" {
|
|
t.Fatalf("pointer=%+v err=%v", ptr, err)
|
|
}
|
|
desktop, err := installlayout.ActiveDesktopPath(installDir)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
raw, err := os.ReadFile(desktop)
|
|
if err != nil || string(raw) != "payload:reasonix-desktop.exe" {
|
|
t.Fatalf("desktop payload = %q err=%v", raw, err)
|
|
}
|
|
for _, name := range []string{"reasonix-launcher.exe", "Reasonix.exe", "reasonix-cli.exe"} {
|
|
if _, err := os.Stat(filepath.Join(installDir, name)); err != nil {
|
|
t.Fatalf("root entry %s: %v", name, err)
|
|
}
|
|
}
|
|
if _, err := os.Stat(filepath.Join(installDir, "reasonix-desktop.exe")); !os.IsNotExist(err) {
|
|
t.Fatal("flat desktop should be removed")
|
|
}
|
|
if _, err := os.Stat(filepath.Join(installDir, "reasonix-guard.exe")); !os.IsNotExist(err) {
|
|
t.Fatal("flat guard should be removed")
|
|
}
|
|
if prefer := preferRelaunchPath("", installDir); filepath.Base(prefer) != "reasonix-launcher.exe" {
|
|
t.Fatalf("prefer relaunch = %s", prefer)
|
|
}
|
|
}
|
|
|
|
func TestInstallStagedWindowsReleaseUnitPrefersVersioned(t *testing.T) {
|
|
installDir := tempdir.New(t)
|
|
staging := tempdir.New(t)
|
|
for _, name := range []string{
|
|
"reasonix-desktop.exe",
|
|
"reasonix-cli.exe",
|
|
"reasonix-update-helper.exe",
|
|
"reasonix-launcher.exe",
|
|
"reasonix-guard.exe",
|
|
} {
|
|
if err := os.WriteFile(filepath.Join(staging, name), []byte("p:"+name), 0o700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
// Minimal claimed unit (versioned path does not need full flat file list).
|
|
claimed := &repair.UpdateTransaction{
|
|
SchemaVersion: 1,
|
|
ToVersion: "v1.20.0",
|
|
TargetKind: "file",
|
|
TargetPath: filepath.Join(installDir, "reasonix-desktop.exe"),
|
|
CreatedAt: "2026-01-01T00:00:00Z",
|
|
}
|
|
started, receipts, err := installStagedWindowsReleaseUnit(claimed, staging)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !started || receipts != nil {
|
|
t.Fatalf("started=%v receipts=%v want started with nil receipts", started, receipts)
|
|
}
|
|
if !installlayout.HasCurrent(installDir) {
|
|
t.Fatal("versioned activation did not write current.json")
|
|
}
|
|
}
|