fix(install): emit an active State Store target so a fresh install can boot
install.sh produces config.toml two ways, and neither emitted an active [services.state].target. The self-host branch writes a hand-rolled heredoc with no [services] section at all, and the non-self-host branch rewrites only the [forge] block of config.example.toml -- where [services.state] sat commented out. openStateStoreAdapter requires a target, so a freshly installed archied aborted at startup with no way to boot from the config the installer had just written. Activate [services.state] with a loopback target in both sources, which is the producer fix: the config the installer emits is the invalid state, so it is corrected where it is generated rather than defended against at the daemon. [services.gateway] is activated alongside it for the same reason it is safe to -- internal/infrastructure/configuration/defaults.go already defaults that target to 127.0.0.1:8585, so declaring it changes no resolved value and only makes the emitted config explicit. Add TestInstallerGeneratedConfigHasServiceTargets, which parses what each branch actually produces: config.example.toml through the real config loader, and the install.sh heredoc reconstructed with its shell expansions resolved. Both assertions are red-first -- with the sources reverted the test fails on both branches with the boot-fatal message. Found by an adversarial package sweep (temp tracker: repo-root-deployment-1, .local/issue-tracker/).
This commit is contained in:
3 files changed
+86
-4
No files matched your search
+4
-4
@@ -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
|
||||
|
||||
@@ -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 <<EOF > "${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{
|
||||
|
||||
+10
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user