diff --git a/config.example.toml b/config.example.toml index 025f80fdc..deaa28e4e 100644 --- a/config.example.toml +++ b/config.example.toml @@ -288,16 +288,16 @@ gate_max_failures = 5 # Services selects contract adapters at composition time (see # docs/prds/state-store-contract.md). -# [services.gateway] -# target = "127.0.0.1:8585" # archie-gateway's gRPC address (always remote once set) +[services.gateway] +target = "127.0.0.1:8585" # archie-gateway's gRPC address (always remote once set) # target_token = "..." # Bearer [REDACTED] for a NON-loopback listener. A loopback listener # # (127.0.0.1/::1/localhost) needs no token. A non-loopback # # listener without a token fails closed, as does a # # non-loopback dial without one. The same token is # # presented as GATEWAY_TOKEN by remote consumers. -# [services.state] -# target = "127.0.0.1:9090" # REQUIRED. The State Store gRPC address archied and +[services.state] +target = "127.0.0.1:9090" # REQUIRED. The State Store gRPC address archied and # # archie-gateway dial. They no longer own archie.db # # in-process: the standalone archie-state-store process # # owns the single SQLite file (docs/prds/state-store-contract.md diff --git a/deployment_contract_test.go b/deployment_contract_test.go index 716267cef..f9a7fbc4a 100644 --- a/deployment_contract_test.go +++ b/deployment_contract_test.go @@ -2,6 +2,7 @@ package configtemplate import ( "os" + "path/filepath" "strings" "testing" @@ -35,6 +36,77 @@ func TestExternalNATSProfileLoadsWithManagedWorkers(t *testing.T) { } } +// selfHostConfig reconstructs the config.toml the install.sh self-host branch +// writes through its hand-rolled heredoc, with the shell expansions resolved, +// so tests can parse exactly what a fresh self-host install would produce. +func selfHostConfig(t *testing.T) string { + t.Helper() + source := readDeploymentFile(t, "install.sh") + const marker = `cat < "${ARCHIE_CONFIG_DIR}/config.toml"` + start := strings.Index(source, marker) + if start < 0 { + t.Fatalf("install.sh is missing the self-host config heredoc marker %q", marker) + } + bodyStart := strings.IndexByte(source[start:], '\n') + if bodyStart < 0 { + t.Fatal("install.sh self-host config heredoc is malformed") + } + bodyStart += start + 1 + lines := strings.Split(source[bodyStart:], "\n") + var body strings.Builder + for _, line := range lines { + if line == "EOF" { + break + } + body.WriteString(line) + body.WriteByte('\n') + } + out := body.String() + // install.sh expands these two shell constructs inside the heredoc; pin + // concrete values here so the reconstructed document parses. The forge + // block is the GitHub output forge_block prints (install.sh's own function). + out = strings.Replace(out, "$(forge_block)", + "[forge]\ntype = \"github\"\nhost = \"https://github.com\"\ntoken = { engine = \"env\", key = \"ARCHIE_GITHUB_TOKEN\" }\n\n", 1) + out = strings.ReplaceAll(out, "ollama/${OLLAMA_MODEL}", "ollama/llama3") + return out +} + +func TestInstallerGeneratedConfigHasServiceTargets(t *testing.T) { + // Non-self-host branch: install.sh replaces only the [forge] block in + // config.example.toml, so every other section -- including the required + // [services.*] targets -- must already be active there. + example, err := configuration.New(nil).File("config.example.toml") + if err != nil { + t.Fatalf("load config.example.toml: %v", err) + } + if example.Config.Services.State.Target == "" { + t.Error("config.example.toml leaves services.state.target empty; the install.sh awk branch would emit an unbootable config") + } + exampleSource := readDeploymentFile(t, "config.example.toml") + if !strings.Contains(exampleSource, "\n[services.gateway]\n") { + t.Error("config.example.toml does not declare an active [services.gateway] section") + } + + // Self-host branch: install.sh writes a hand-rolled heredoc. Reconstruct + // it the way the installer would and require it to parse with the State + // Store target the daemon's openStateStoreAdapter enforces. + selfHost := selfHostConfig(t) + path := filepath.Join(t.TempDir(), "config.toml") + if err := os.WriteFile(path, []byte(selfHost), 0o600); err != nil { + t.Fatal(err) + } + generated, err := configuration.New(nil).File(path) + if err != nil { + t.Fatalf("load reconstructed self-host install config: %v", err) + } + if generated.Config.Services.State.Target == "" { + t.Error("install.sh self-host heredoc leaves services.state.target empty; generated config cannot boot") + } + if !strings.Contains(selfHost, "\n[services.gateway]\n") { + t.Error("install.sh self-host heredoc does not declare an active [services.gateway] section") + } +} + func TestInstallerUsesNativeDaemonAndManagedWorkerImage(t *testing.T) { source := readDeploymentFile(t, "install.sh") for _, forbidden := range []string{ diff --git a/install.sh b/install.sh index 6722895a5..04fc88861 100755 --- a/install.sh +++ b/install.sh @@ -389,6 +389,16 @@ class = "ollama" [nats] mode = "embedded" +# The daemon and gateway dial the standalone archie-state-store process and +# the standalone archie-gateway (the dashboard and chat front-ends dial it +# too). Loopback targets with no token are the no-setup default; see +# deployments/README.md for starting archie-state-store and archie-gateway. +[services.gateway] +target = "127.0.0.1:8585" + +[services.state] +target = "127.0.0.1:9090" + [containers] image = "ghcr.io/samcharles93/archie-agent:latest" pull_policy = "missing"