chore(config): remove dead [agent], [oidc], [image] and containers.enabled keys
None had a production consumer: [agent] and containers.enabled were decoded only so old files kept loading, [oidc] was never read (archie-ui takes OIDC from flags), and [image] was validated but no provider exists.
This commit is contained in:
1 parent
58eac052a8
commit
9a0efa295e
16 files changed
+23
-397
No files matched your search
@@ -145,8 +145,6 @@ For environment failures:
|
||||
launch environment rather than Compose.
|
||||
- `containerEnv` translates configured NATS token name into `NATS_TOKEN` and
|
||||
forwards configured provider key variables.
|
||||
- `SubprocessRunner` forwards default compatibility variables, configured
|
||||
`[agent].env` names, and only the requested provider key.
|
||||
- Top-level `[forge] token_env` is converted to an env `SecretRef` by
|
||||
`finalize`; explicit `[forge.token]` wins.
|
||||
|
||||
|
||||
@@ -55,20 +55,16 @@ There is no config-only or dry-run flag.
|
||||
| Flag or environment | Exact behavior |
|
||||
|---|---|
|
||||
| `-nats-url <url>` | Select NATS; falls back to `NATS_URL`. One of them is required. |
|
||||
| `-consumer <name>` | Set the durable JetStream consumer name; default `archie-agent`. |
|
||||
| `NATS_TOKEN` | Optional NATS token read directly by the worker. |
|
||||
|
||||
Both linked binaries may also display Go's `-quickchecks` flag from
|
||||
`testing/quick`; it is not an Archie operations control.
|
||||
|
||||
## Select the execution mode deliberately
|
||||
## Execution mode
|
||||
|
||||
| Config shape | What runs | Operational status on 2026-09-18 |
|
||||
|---|---|---|
|
||||
| `agent.mode = "inprocess"` and no `[nats]` | `archied` polls and claims through the State Store, runs workflow stages and model tools in-process. | **Production-wired candidate.** No process or OS isolation. |
|
||||
| `agent.mode = "subprocess"` | `archied` starts `agent.command` per stage and expects one JSON invocation on stdin, one response on stdout. | **Open/broken with default command.** `cmd/archie-agent` is a long-running NATS worker and never calls `agentexec.ServeOne`. |
|
||||
| `agent.mode = "nats"`, `[nats]`, containers disabled | `archied` runs the workflow; each autonomous stage goes to a separately started `archie-agent`. | **Implemented but operator-assembled.** Launch and supervise a worker separately. |
|
||||
| `agent.mode = "nats"`, `[nats]`, `containers.enabled = true` | `archied` publishes task discovery through JetStream, prepares a worktree, spawns one agent container, sends the whole workflow on `archie.taskrun.<id>`. | **Host daemon + Compose NATS path.** `deployments/docker-nats-stack.toml` demonstrates it. |
|
||||
| Config shape | What runs |
|
||||
|---|---|
|
||||
| `[nats]` absent (embedded) or `url` set (external) | `archied` polls and claims through the State Store, prepares a worktree, spawns one task-scoped agent container and sends the whole workflow on `archie.taskrun.<id>`. There is no other execution mode. |
|
||||
|
||||
## Run a local foreground daemon
|
||||
|
||||
|
||||
@@ -304,23 +304,6 @@ listen = "127.0.0.1:8484"
|
||||
# [memory]
|
||||
# engine = "builtin" # "builtin" is the only engine implemented so far
|
||||
|
||||
# Image generation capability (internal/domain/image). No provider is
|
||||
# implemented yet -- this section defines the contract/config surface only
|
||||
# (archie-core-1786748942147-2-47cd5bd1). Absent is valid and registers no
|
||||
# provider. default names the provider /image uses without asking; leaving
|
||||
# it unset means /image always asks which mechanism to use. Every provider
|
||||
# is off by default -- a hosted provider spends real API credits per call,
|
||||
# and a local one can saturate the host GPU, so both require an explicit
|
||||
# enabled = true, never an inferred one from the presence of a key alone.
|
||||
# [image.hosted.openai]
|
||||
# enabled = false
|
||||
# class = "openai"
|
||||
# api_key_env = "OPENAI_API_KEY"
|
||||
#
|
||||
# [image.local.sdxl]
|
||||
# enabled = false
|
||||
# backend = "sdxl-turbo"
|
||||
|
||||
# Notifications for human-in-the-loop moments
|
||||
# (approval requests, gate failures, parked tasks).
|
||||
# Archie POSTs a JSON payload to the webhook
|
||||
|
||||
@@ -30,10 +30,6 @@ func TestExternalNATSProfileLoadsWithManagedWorkers(t *testing.T) {
|
||||
if doc.Config.Containers.Image == "" {
|
||||
t.Error("managed worker image is empty")
|
||||
}
|
||||
legacy := doc.Config.LegacyAgent
|
||||
if legacy.Mode != "" || legacy.Command != "" || len(legacy.Env) != 0 {
|
||||
t.Errorf("legacy agent selector decoded from supported profile: %#v", doc.Config.LegacyAgent)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstallerUsesNativeDaemonAndManagedWorkerImage(t *testing.T) {
|
||||
|
||||
@@ -140,9 +140,6 @@ var reloadableFields = map[string]bool{
|
||||
// per-task half of this list is pinned mechanically; this webui-only
|
||||
// entry is pinned by TestChangedNonReloadableFields.
|
||||
"MaxRetries": true,
|
||||
// [agent] is a decode-only compatibility shim; changes have no runtime
|
||||
// consumer and therefore require neither reload nor restart.
|
||||
"LegacyAgent": true,
|
||||
// Tools.Policy (MaxResultChars/SpillDir) is carried into TaskConfig by
|
||||
// ForTask (config.go) and applied fresh per dispatch via
|
||||
// agentworker.applyToolLimits. See reloadableSubFields["Tools"].
|
||||
@@ -160,7 +157,7 @@ var reloadableFields = map[string]bool{
|
||||
// forge client itself is startup-built, so Type/Token/TokenEnv stay
|
||||
// requires-restart.
|
||||
var reloadableSubFields = map[string]map[string]bool{
|
||||
"Containers": {"LegacyEnabled": true, "VolumeTTL": true},
|
||||
"Containers": {"VolumeTTL": true},
|
||||
"Forge": {"Host": true},
|
||||
// Policy is carried into TaskConfig by ForTask (config.go); MCPServers,
|
||||
// WebFetch and Minimax are not and stay requires-restart.
|
||||
|
||||
@@ -198,19 +198,6 @@ func TestChangedNonReloadableFields(t *testing.T) {
|
||||
t.Fatalf("reloadable-only: got %v, want []", got)
|
||||
}
|
||||
|
||||
// The removed [agent] section remains decode-only for old files. Changing
|
||||
// it has no running consumer and must not claim a restart will apply it.
|
||||
legacyOnly := base
|
||||
legacyOnly.LegacyAgent = config.LegacyAgent{Mode: "subprocess"}
|
||||
if got := changedNonReloadableFields(base, legacyOnly); len(got) != 0 {
|
||||
t.Fatalf("legacy agent change: got %v, want []", got)
|
||||
}
|
||||
legacyContainers := base
|
||||
legacyContainers.Containers.LegacyEnabled = true
|
||||
if got := changedNonReloadableFields(base, legacyContainers); len(got) != 0 {
|
||||
t.Fatalf("legacy containers.enabled change: got %v, want []", got)
|
||||
}
|
||||
|
||||
// Containers sub-field granularity: Image change warns, MaxConcurrency
|
||||
// and VolumeTTL changes do not.
|
||||
c1 := base
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestRuntimeConfigUsesDatabaseResourcesAndPreservesBootstrapOnlySecrets(t *t
|
||||
SchedulingPolicyKind: map[string]any{"poll_interval": "2m", "max_retries": 7, "dispatch": map[string]any{"trigger": "assignee"}},
|
||||
ToolSettingsKind: map[string]any{"mcp_servers": []map[string]any{{"name": "docs", "transport": "http", "url": "https://mcp.example.com", "headers_configured": true}}, "policy": map[string]any{}, "web_fetch": map[string]any{}, "minimax": map[string]any{"enabled": false, "credential_configured": false}},
|
||||
PluginSettingsKind: map[string]any{"plugin_dir": "/plugins", "module_dir": "/modules", "secret_engine_dir": "/secrets", "skills_dir": "/skills"},
|
||||
ContainerRuntimePoliciesKind: config.ContainerConfig{LegacyEnabled: true, Image: "archie:next", PullPolicy: "missing"},
|
||||
ContainerRuntimePoliciesKind: config.ContainerConfig{Image: "archie:next", PullPolicy: "missing"},
|
||||
}})
|
||||
|
||||
got, versions, err := client.RuntimeConfig(t.Context(), base)
|
||||
|
||||
@@ -25,14 +25,9 @@ func TestConfigCloneDeepCopiesReferenceFields(t *testing.T) {
|
||||
MCPServers: []MCPServer{{Headers: map[string]string{"A": "b"}, Args: []string{"x"}}},
|
||||
WebFetch: WebFetchConfig{Enabled: &enabled},
|
||||
},
|
||||
Chat: ChatConfig{Telegram: TelegramConfig{AllowedUserIDs: []int64{1}}},
|
||||
LegacyAgent: LegacyAgent{Env: []string{"HOME"}},
|
||||
Extra: map[string]any{"custom": 1},
|
||||
Bindings: BindingsConfig{PreviousEncryptionKeys: []SecretRef{{Engine: "env", Key: "K0"}}},
|
||||
Image: ImageConfig{
|
||||
Hosted: map[string]ImageHostedProvider{"openai": {Enabled: true}},
|
||||
Local: map[string]ImageLocalProvider{"sdxl": {Enabled: true}},
|
||||
},
|
||||
Chat: ChatConfig{Telegram: TelegramConfig{AllowedUserIDs: []int64{1}}},
|
||||
Extra: map[string]any{"custom": 1},
|
||||
Bindings: BindingsConfig{PreviousEncryptionKeys: []SecretRef{{Engine: "env", Key: "K0"}}},
|
||||
Services: Services{
|
||||
ServiceNameState: {Target: "127.0.0.1:9090", TargetToken: "secret"},
|
||||
},
|
||||
@@ -49,14 +44,11 @@ func TestConfigCloneDeepCopiesReferenceFields(t *testing.T) {
|
||||
got.Tools.MCPServers[0].Headers["A"] = "changed"
|
||||
got.Tools.MCPServers[0].Args[0] = "changed"
|
||||
got.Chat.Telegram.AllowedUserIDs[0] = 99
|
||||
got.LegacyAgent.Env[0] = "changed"
|
||||
got.Extra["custom"] = 2
|
||||
got.Bindings.PreviousEncryptionKeys[0] = SecretRef{Engine: "env", Key: "changed"}
|
||||
*got.Tools.WebFetch.Enabled = false
|
||||
*got.DiffCapLines = 1
|
||||
*got.Identities[0].DiffCapLines = 2
|
||||
got.Image.Hosted["openai"] = ImageHostedProvider{Enabled: false}
|
||||
got.Image.Local["sdxl"] = ImageLocalProvider{Enabled: false}
|
||||
got.Services[ServiceNameState] = ServiceConnection{Target: "changed"}
|
||||
|
||||
if orig.Models["builder"] != "m" {
|
||||
@@ -80,9 +72,6 @@ func TestConfigCloneDeepCopiesReferenceFields(t *testing.T) {
|
||||
if orig.Chat.Telegram.AllowedUserIDs[0] != 1 {
|
||||
t.Error("Telegram.AllowedUserIDs is shared")
|
||||
}
|
||||
if orig.LegacyAgent.Env[0] != "HOME" {
|
||||
t.Error("Agent.Env is shared")
|
||||
}
|
||||
if orig.Extra["custom"] != 1 {
|
||||
t.Error("Extra map is shared")
|
||||
}
|
||||
@@ -98,12 +87,6 @@ func TestConfigCloneDeepCopiesReferenceFields(t *testing.T) {
|
||||
if !*orig.Tools.WebFetch.Enabled {
|
||||
t.Error("WebFetch.Enabled pointer is shared")
|
||||
}
|
||||
if !orig.Image.Hosted["openai"].Enabled {
|
||||
t.Error("Image.Hosted map is shared")
|
||||
}
|
||||
if !orig.Image.Local["sdxl"].Enabled {
|
||||
t.Error("Image.Local map is shared")
|
||||
}
|
||||
if orig.Services[ServiceNameState].TargetToken != "secret" {
|
||||
t.Error("Services map is shared")
|
||||
}
|
||||
|
||||
@@ -182,16 +182,6 @@ type Provider struct {
|
||||
BaseURL string `toml:"base_url" yaml:"base_url" json:"base_url"`
|
||||
}
|
||||
|
||||
// LegacyAgent decodes the removed [agent] section so existing operator files
|
||||
// continue to load during migration. Its fields have no runtime consumers:
|
||||
// autonomous work always uses a task-scoped archie-agent container over NATS.
|
||||
// Remove the section from new and updated configurations.
|
||||
type LegacyAgent struct {
|
||||
Mode string `toml:"mode" yaml:"mode"`
|
||||
Command string `toml:"command" yaml:"command"`
|
||||
Env []string `toml:"env" yaml:"env"`
|
||||
}
|
||||
|
||||
// Forge intake modes for Forge.Intake. Poll is the default; webhook reacts to
|
||||
// forge events as they arrive instead of (or in addition to) polling.
|
||||
const (
|
||||
@@ -282,40 +272,6 @@ func (d Dispatch) LabelValues() []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// ImageConfig configures the image generation capability
|
||||
// (internal/domain/image). See docs/prds/image-capability-contract.md.
|
||||
type ImageConfig struct {
|
||||
// Default selects which registered provider name /image uses when the
|
||||
// request/session has not already picked one. Empty means /image must
|
||||
// always ask which mechanism to use -- a valid, and the default, state.
|
||||
Default string `toml:"default" yaml:"default" json:"default"`
|
||||
// Hosted configures hosted (paid) providers, keyed by provider name.
|
||||
Hosted map[string]ImageHostedProvider `toml:"hosted" yaml:"hosted" json:"hosted"`
|
||||
// Local configures local GPU recipes, keyed by provider name.
|
||||
Local map[string]ImageLocalProvider `toml:"local" yaml:"local" json:"local"`
|
||||
}
|
||||
|
||||
// ImageHostedProvider configures one hosted image provider. Mirrors
|
||||
// MinimaxConfig's cost guard: Enabled defaults false, since a hosted
|
||||
// provider spends real API credits per call and must never activate from
|
||||
// the mere presence of a key.
|
||||
type ImageHostedProvider struct {
|
||||
Enabled bool `toml:"enabled" yaml:"enabled" json:"enabled"`
|
||||
Class string `toml:"class" yaml:"class" json:"class"`
|
||||
APIKeyEnv string `toml:"api_key_env" yaml:"api_key_env" json:"api_key_env"`
|
||||
APIKey SecretRef `toml:"api_key" yaml:"api_key" json:"-"`
|
||||
BaseURL string `toml:"base_url" yaml:"base_url" json:"base_url,omitempty"`
|
||||
}
|
||||
|
||||
// ImageLocalProvider configures one local GPU image recipe. Enabled
|
||||
// defaults false too: a local backend can saturate the host GPU/CPU, its
|
||||
// own kind of unwanted cost, so it gets the same explicit gate as a hosted
|
||||
// provider rather than an on-by-default treatment.
|
||||
type ImageLocalProvider struct {
|
||||
Enabled bool `toml:"enabled" yaml:"enabled" json:"enabled"`
|
||||
Backend string `toml:"backend" yaml:"backend" json:"backend"`
|
||||
}
|
||||
|
||||
// MemoryConfig holds memory engine configuration.
|
||||
type MemoryConfig struct {
|
||||
// Engine selects among the domain/memory engine family
|
||||
@@ -523,12 +479,10 @@ type Config struct {
|
||||
// model ref ("provider/model").
|
||||
Models map[string]string `toml:"models" yaml:"models"`
|
||||
|
||||
Providers map[string]Provider `toml:"providers" yaml:"providers"`
|
||||
LegacyAgent LegacyAgent `toml:"agent" yaml:"agent"`
|
||||
Providers map[string]Provider `toml:"providers" yaml:"providers"`
|
||||
|
||||
Budgets Budgets `toml:"budgets" yaml:"budgets"`
|
||||
Web Web `toml:"web" yaml:"web"`
|
||||
Oidc Oidc `toml:"oidc" yaml:"oidc"`
|
||||
Health Health `toml:"health" yaml:"health"`
|
||||
Log Log `toml:"log" yaml:"log"`
|
||||
Notify Notify `toml:"notify" yaml:"notify"`
|
||||
@@ -541,10 +495,6 @@ type Config struct {
|
||||
// Memory holds memory provider configuration (from config.memory.yaml).
|
||||
Memory MemoryConfig `toml:"memory" yaml:"memory"`
|
||||
|
||||
// Image configures the image generation capability. Absent is valid
|
||||
// and registers no provider.
|
||||
Image ImageConfig `toml:"image" yaml:"image" json:"image"`
|
||||
|
||||
// Tools holds MCP server and tool policy configuration (from config.tools.yaml).
|
||||
Tools ToolsConfig `toml:"tools" yaml:"tools"`
|
||||
|
||||
@@ -721,7 +671,6 @@ func (c Config) Clone() Config {
|
||||
c.ModelLimits = maps.Clone(c.ModelLimits)
|
||||
c.Providers = maps.Clone(c.Providers)
|
||||
c.Dispatch.Labels = cloneStringMap(c.Dispatch.Labels)
|
||||
c.LegacyAgent.Env = append([]string(nil), c.LegacyAgent.Env...)
|
||||
c.Repos = cloneRepos(c.Repos)
|
||||
c.Identities = cloneIdentities(c.Identities)
|
||||
c.Chat.Models = append([]string(nil), c.Chat.Models...)
|
||||
@@ -730,8 +679,6 @@ func (c Config) Clone() Config {
|
||||
c.Chat.Telegram.UpdateInstallCommand = append([]string(nil), c.Chat.Telegram.UpdateInstallCommand...)
|
||||
c.Bindings.PreviousEncryptionKeys = append([]SecretRef(nil), c.Bindings.PreviousEncryptionKeys...)
|
||||
c.Tools.MCPServers = cloneMCPServers(c.Tools.MCPServers)
|
||||
c.Image.Hosted = maps.Clone(c.Image.Hosted)
|
||||
c.Image.Local = maps.Clone(c.Image.Local)
|
||||
// Services is a map of structs, so the header is shared by the value copy
|
||||
// above and yaml.Unmarshal writes keys into whatever map it is handed. Without
|
||||
// this line an overlay -- or a dashboard PATCH -- rewrites the PUBLISHED
|
||||
@@ -883,10 +830,6 @@ type BindingsConfig struct {
|
||||
|
||||
// ContainerConfig configures Docker sandbox execution of archie-agent.
|
||||
type ContainerConfig struct {
|
||||
// LegacyEnabled decodes the removed containers.enabled switch so existing
|
||||
// operator files keep loading. It has no runtime consumer: autonomous
|
||||
// workflows always require managed task containers.
|
||||
LegacyEnabled bool `toml:"enabled" yaml:"enabled"`
|
||||
// Image is the Docker image to run (e.g. "ghcr.io/sam/archie-agent:latest").
|
||||
Image string `toml:"image" yaml:"image"`
|
||||
// MaxConcurrency limits simultaneous daemon tasks and containers.
|
||||
@@ -1152,19 +1095,6 @@ type Notify struct {
|
||||
Webhook string `toml:"webhook" json:"webhook" yaml:"webhook"`
|
||||
}
|
||||
|
||||
// Oidc configures verification of identity-provider tokens. An empty issuer
|
||||
// disables it, and the dashboard keeps its shared-token gate -- which attributes
|
||||
// a request to a credential, not to a person.
|
||||
type Oidc struct {
|
||||
// Issuer is the provider's issuer URL. Discovery and the signing keys are
|
||||
// read from it, so archie holds no key material of its own.
|
||||
Issuer string `toml:"issuer" yaml:"issuer"`
|
||||
// Audience is the resource identifier archie accepts tokens for. Required
|
||||
// when an issuer is set: without it a token the provider minted for another
|
||||
// service would authenticate here.
|
||||
Audience string `toml:"audience" yaml:"audience"`
|
||||
}
|
||||
|
||||
// Web configures the observability dashboard.
|
||||
// Health is archied's own liveness surface, always on. It is separate from
|
||||
// the dashboard's /healthz because the process whose restart is being
|
||||
|
||||
@@ -99,24 +99,6 @@ func TestApplyOverlayValuesMergesEveryMapEntry(t *testing.T) {
|
||||
overlay map[string]any
|
||||
check func(t *testing.T, cfg config.Config)
|
||||
}{
|
||||
{
|
||||
name: "image.hosted entry keeps the fields the overlay omits",
|
||||
start: config.Config{Image: config.ImageConfig{Hosted: map[string]config.ImageHostedProvider{
|
||||
"minimax": {Enabled: true, Class: "minimax", APIKeyEnv: "MINIMAX_API_KEY"},
|
||||
}}},
|
||||
overlay: map[string]any{"image": map[string]any{"hosted": map[string]any{
|
||||
"minimax": map[string]any{"base_url": "https://api.example"},
|
||||
}}},
|
||||
check: func(t *testing.T, cfg config.Config) {
|
||||
t.Helper()
|
||||
want := map[string]config.ImageHostedProvider{
|
||||
"minimax": {Enabled: true, Class: "minimax", APIKeyEnv: "MINIMAX_API_KEY", BaseURL: "https://api.example"},
|
||||
}
|
||||
if !maps.Equal(cfg.Image.Hosted, want) {
|
||||
t.Errorf("Image.Hosted = %+v, want %+v", cfg.Image.Hosted, want)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "providers entry keeps the fields the overlay omits",
|
||||
start: config.Config{Providers: map[string]config.Provider{
|
||||
|
||||
@@ -2,7 +2,6 @@ package configuration
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -42,29 +41,6 @@ func TestLoadDispatchAckReaction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLegacyContainersEnabledCannotSelectExecutionTopology(t *testing.T) {
|
||||
for _, enabled := range []bool{false, true} {
|
||||
t.Run(map[bool]string{false: "disabled", true: "enabled"}[enabled], func(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.toml")
|
||||
contents := fmt.Sprintf("bot_user = \"widget\"\n[forge]\ntype = \"none\"\n[containers]\nenabled = %t\n", enabled)
|
||||
if err := os.WriteFile(path, []byte(contents), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
doc, err := New(nil).File(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if doc.Config.Containers.LegacyEnabled != enabled {
|
||||
t.Errorf("LegacyEnabled = %v, want decoded %v", doc.Config.Containers.LegacyEnabled, enabled)
|
||||
}
|
||||
if doc.Config.Containers.Image != defaultContainerImage {
|
||||
t.Errorf("Image = %q, want mandatory default %q", doc.Config.Containers.Image, defaultContainerImage)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadExpandsConfiguredHomePaths(t *testing.T) {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
@@ -312,11 +288,6 @@ func TestLoadRejectsInvalidConfigEnumsAndGlobs(t *testing.T) {
|
||||
body: fileConfigPrefix + "[capture]\nretention = \"-1h\"\n",
|
||||
wantLoadErr: true,
|
||||
},
|
||||
{
|
||||
name: "image default naming no provider",
|
||||
body: fileConfigPrefix + "[image]\ndefault = \"not-a-real-provider\"\n",
|
||||
wantLoadErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -343,38 +314,6 @@ func TestLoadRejectsInvalidConfigEnumsAndGlobs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadLegacyAgentSectionWithoutApplyingExecutionDefaults(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
agent string
|
||||
wantMode string
|
||||
wantCommand string
|
||||
wantEnv []string
|
||||
}{
|
||||
{name: "absent section stays empty"},
|
||||
{
|
||||
name: "legacy values decode without validation", agent: "\n[agent]\nmode = \"removed-mode\"\ncommand = \"/opt/old-agent\"\nenv = [\"TOKEN=value\"]\n",
|
||||
wantMode: "removed-mode", wantCommand: "/opt/old-agent", wantEnv: []string{"TOKEN=value"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.toml")
|
||||
contents := "bot_user = \"widget\"\n" + tt.agent + "\n[[repos]]\nowner = \"acme\"\nname = \"app\"\n"
|
||||
if err := os.WriteFile(path, []byte(contents), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, err := loadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.LegacyAgent.Mode != tt.wantMode || cfg.LegacyAgent.Command != tt.wantCommand || strings.Join(cfg.LegacyAgent.Env, ",") != strings.Join(tt.wantEnv, ",") {
|
||||
t.Fatalf("legacy agent config = %#v", cfg.LegacyAgent)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestLoadToolPolicyDefaultsAndOverrides covers the result-size and turn-budget
|
||||
// limits end to end from TOML. Before these fields carried toml tags they could
|
||||
// not be set from the daemon's config at all, so a test that only exercised
|
||||
@@ -547,7 +486,7 @@ func TestLoadContainerVolumeTTL(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.toml")
|
||||
contents := "bot_user = \"widget\"\n" +
|
||||
"[nats]\nurl = \"nats://localhost:4222\"\n" +
|
||||
"[containers]\nenabled = true\nimage = \"archie-agent:test\"\n" + tt.ttl +
|
||||
"[containers]\nimage = \"archie-agent:test\"\n" + tt.ttl +
|
||||
"[[repos]]\nowner = \"acme\"\nname = \"app\"\npersistent_storage = true\n"
|
||||
if err := os.WriteFile(path, []byte(contents), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -573,7 +512,7 @@ func TestLoadRejectsNegativeContainerVolumeTTL(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.toml")
|
||||
contents := "bot_user = \"widget\"\n" +
|
||||
"[nats]\nurl = \"nats://localhost:4222\"\n" +
|
||||
"[containers]\nenabled = true\nimage = \"archie-agent:test\"\nvolume_ttl = \"-1h\"\n" +
|
||||
"[containers]\nimage = \"archie-agent:test\"\nvolume_ttl = \"-1h\"\n" +
|
||||
"[[repos]]\nowner = \"acme\"\nname = \"app\"\npersistent_storage = true\n"
|
||||
if err := os.WriteFile(path, []byte(contents), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -614,16 +553,16 @@ func TestOverlay(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
basePath := filepath.Join(dir, "config.toml")
|
||||
base := "bot_user = \"widget\"\nwork_dir = \"/base/work\"\n" +
|
||||
"[agent]\nmode = \"inprocess\"\n" +
|
||||
"[log]\nlevel = \"warn\"\n" +
|
||||
"[[repos]]\nowner = \"acme\"\nname = \"app\"\n"
|
||||
if err := os.WriteFile(basePath, []byte(base), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
overlayPath := filepath.Join(dir, "config.docker.toml")
|
||||
overlay := "work_dir = \"/var/lib/archie/work\"\n[agent]\nmode = \"nats\"\n" +
|
||||
overlay := "work_dir = \"/var/lib/archie/work\"\n[log]\nlevel = \"debug\"\n" +
|
||||
"[nats]\nurl = \"nats://nats:4222\"\n" +
|
||||
"[containers]\nenabled = true\nimage = \"archie-agent:latest\"\n"
|
||||
"[containers]\nimage = \"archie-agent:latest\"\n"
|
||||
if err := os.WriteFile(overlayPath, []byte(overlay), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -636,8 +575,8 @@ func TestOverlay(t *testing.T) {
|
||||
if cfg.WorkDir != "/var/lib/archie/work" {
|
||||
t.Errorf("WorkDir: got %q, want overlay value", cfg.WorkDir)
|
||||
}
|
||||
if cfg.LegacyAgent.Mode != "nats" {
|
||||
t.Errorf("LegacyAgent.Mode: got %q, want %q", cfg.LegacyAgent.Mode, "nats")
|
||||
if cfg.Log.Level != "debug" {
|
||||
t.Errorf("Log.Level: got %q, want %q", cfg.Log.Level, "debug")
|
||||
}
|
||||
// Fields the overlay omits keep the base value.
|
||||
if cfg.BotUser != "widget" {
|
||||
@@ -652,8 +591,8 @@ func TestOverlay(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if baseOnly.LegacyAgent.Mode != "inprocess" {
|
||||
t.Errorf("LegacyAgent.Mode with empty overlay: got %q, want %q", baseOnly.LegacyAgent.Mode, "inprocess")
|
||||
if baseOnly.Log.Level != "warn" {
|
||||
t.Errorf("Log.Level with empty overlay: got %q, want %q", baseOnly.Log.Level, "warn")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,28 +636,6 @@ func TestResolveFileOverlayPreservesOmittedMapEntryFields(t *testing.T) {
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
// An enabled hosted provider must keep its class and key env: the
|
||||
// overlay naming only base_url would otherwise clear them and fail
|
||||
// validation after the load.
|
||||
name: "image.hosted entry keeps the fields it does not name",
|
||||
base: "[image.hosted.minimax]\nenabled = true\nclass = \"minimax\"\n" +
|
||||
"api_key_env = \"MINIMAX_API_KEY\"\n",
|
||||
overlay: "[image.hosted.minimax]\nbase_url = \"https://api.example\"\n",
|
||||
check: func(t *testing.T, cfg config.Config) {
|
||||
t.Helper()
|
||||
got := cfg.Image.Hosted["minimax"]
|
||||
want := config.ImageHostedProvider{
|
||||
Enabled: true,
|
||||
Class: "minimax",
|
||||
APIKeyEnv: "MINIMAX_API_KEY",
|
||||
BaseURL: "https://api.example",
|
||||
}
|
||||
if got != want {
|
||||
t.Errorf("image.hosted.minimax = %+v, want %+v", got, want)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "providers entry keeps the fields it does not name",
|
||||
base: "[providers.anthropic]\nclass = \"anthropic\"\n" +
|
||||
|
||||
@@ -9,8 +9,7 @@ import (
|
||||
|
||||
// minimalValidConfigTOML is enough to pass Validate on its own, so these tests
|
||||
// isolate the unknown-key behaviour from unrelated validation failures.
|
||||
const minimalValidConfigTOML = "bot_user = \"widget\"\nwork_dir = \"/base/work\"\n" +
|
||||
"[agent]\nmode = \"inprocess\"\n"
|
||||
const minimalValidConfigTOML = "bot_user = \"widget\"\nwork_dir = \"/base/work\"\n"
|
||||
|
||||
// TestUnknownKeysAreReported pins plan-config-drift.md step 1: a
|
||||
// misspelled key must not parse, validate and silently do nothing. Today
|
||||
|
||||
@@ -106,9 +106,6 @@ func validateBootstrap(cfg *config.Config) error {
|
||||
if err := validateMemory(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateImage(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateCurators(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -139,43 +136,6 @@ func validateDatabaseOwned(cfg *config.Config) error {
|
||||
return validateRepositoryContents(cfg)
|
||||
}
|
||||
|
||||
// validateImage rejects an enabled hosted provider with no class or no
|
||||
// resolvable credential, and a Default naming a provider that is not both
|
||||
// present and enabled -- either would let /image silently fall back to
|
||||
// "always ask" (harmless) or fail at call time with a confusing error
|
||||
// (not harmless). An absent [image] section is valid and registers no
|
||||
// provider, matching the epic's non-goal that a paid provider must never
|
||||
// activate by omission.
|
||||
func validateImage(cfg *config.Config) error {
|
||||
for name, p := range cfg.Image.Hosted {
|
||||
if !p.Enabled {
|
||||
continue
|
||||
}
|
||||
if p.Class == "" {
|
||||
return fmt.Errorf("%w: image.hosted.%s.class is required when enabled", ErrInvalidInput, name)
|
||||
}
|
||||
if p.APIKeyEnv == "" && p.APIKey == (config.SecretRef{}) {
|
||||
return fmt.Errorf("%w: image.hosted.%s requires api_key_env or api_key when enabled", ErrInvalidInput, name)
|
||||
}
|
||||
}
|
||||
for name, p := range cfg.Image.Local {
|
||||
if p.Enabled && p.Backend == "" {
|
||||
return fmt.Errorf("%w: image.local.%s.backend is required when enabled", ErrInvalidInput, name)
|
||||
}
|
||||
}
|
||||
if cfg.Image.Default != "" {
|
||||
hosted, hostedOK := cfg.Image.Hosted[cfg.Image.Default]
|
||||
local, localOK := cfg.Image.Local[cfg.Image.Default]
|
||||
switch {
|
||||
case hostedOK && hosted.Enabled, localOK && local.Enabled:
|
||||
// found and enabled
|
||||
default:
|
||||
return fmt.Errorf("%w: image.default %q must name an enabled provider under image.hosted or image.local", ErrInvalidInput, cfg.Image.Default)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateCurators rejects a curator definition with no interval. The
|
||||
// interval is a live-path value: a definition missing it is refused with a
|
||||
// clear error rather than defaulted at registration or pass time, so a
|
||||
|
||||
@@ -611,104 +611,3 @@ func TestValidateMemoryNamesTheValidSet(t *testing.T) {
|
||||
t.Errorf("error text = %q, want it to contain %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageAcceptsAbsentSection(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
if err := validateImage(&cfg); err != nil {
|
||||
t.Fatalf("validateImage(absent) = %v, want nil", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageRejectsEnabledHostedWithoutClass(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Hosted = map[string]config.ImageHostedProvider{
|
||||
"openai": {Enabled: true, APIKeyEnv: "OPENAI_API_KEY"},
|
||||
}
|
||||
err := validateImage(&cfg)
|
||||
if !errors.Is(err, ErrInvalidInput) {
|
||||
t.Fatalf("validateImage(no class) = %v, want wrapping ErrInvalidInput", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), "image.hosted.openai.class") {
|
||||
t.Errorf("error text = %q, want it to name the field", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageRejectsEnabledHostedWithoutCredential(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Hosted = map[string]config.ImageHostedProvider{
|
||||
"openai": {Enabled: true, Class: "openai"},
|
||||
}
|
||||
err := validateImage(&cfg)
|
||||
if !errors.Is(err, ErrInvalidInput) {
|
||||
t.Fatalf("validateImage(no credential) = %v, want wrapping ErrInvalidInput", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageAcceptsDisabledHostedWithoutCredential(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Hosted = map[string]config.ImageHostedProvider{
|
||||
"openai": {Enabled: false},
|
||||
}
|
||||
if err := validateImage(&cfg); err != nil {
|
||||
t.Fatalf("validateImage(disabled) = %v, want nil", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageAcceptsEnabledHostedWithCredential(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Hosted = map[string]config.ImageHostedProvider{
|
||||
"openai": {Enabled: true, Class: "openai", APIKeyEnv: "OPENAI_API_KEY"},
|
||||
}
|
||||
if err := validateImage(&cfg); err != nil {
|
||||
t.Fatalf("validateImage(valid hosted) = %v, want nil", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageRejectsEnabledLocalWithoutBackend(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Local = map[string]config.ImageLocalProvider{
|
||||
"sdxl": {Enabled: true},
|
||||
}
|
||||
err := validateImage(&cfg)
|
||||
if !errors.Is(err, ErrInvalidInput) {
|
||||
t.Fatalf("validateImage(no backend) = %v, want wrapping ErrInvalidInput", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), "image.local.sdxl.backend") {
|
||||
t.Errorf("error text = %q, want it to name the field", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageRejectsDefaultNamingDisabledProvider(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Default = "openai"
|
||||
cfg.Image.Hosted = map[string]config.ImageHostedProvider{
|
||||
"openai": {Enabled: false},
|
||||
}
|
||||
err := validateImage(&cfg)
|
||||
if !errors.Is(err, ErrInvalidInput) {
|
||||
t.Fatalf("validateImage(default names disabled) = %v, want wrapping ErrInvalidInput", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), `image.default "openai"`) {
|
||||
t.Errorf("error text = %q, want it to name the field and value", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageRejectsDefaultNamingUnregisteredProvider(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Default = "missing"
|
||||
err := validateImage(&cfg)
|
||||
if !errors.Is(err, ErrInvalidInput) {
|
||||
t.Fatalf("validateImage(default names unregistered) = %v, want wrapping ErrInvalidInput", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateImageAcceptsDefaultNamingEnabledLocalProvider(t *testing.T) {
|
||||
cfg := minimalValidConfig()
|
||||
cfg.Image.Default = "sdxl"
|
||||
cfg.Image.Local = map[string]config.ImageLocalProvider{
|
||||
"sdxl": {Enabled: true, Backend: "sdxl-turbo"},
|
||||
}
|
||||
if err := validateImage(&cfg); err != nil {
|
||||
t.Fatalf("validateImage(default names enabled local) = %v, want nil", err)
|
||||
}
|
||||
}
|
||||
@@ -56,8 +56,7 @@ func configWithFakeSecrets() *config.Holder {
|
||||
Repos: []config.Repo{
|
||||
{Owner: "acme", Name: "widget", Base: "main", Gate: [][]string{{"task", "check"}}},
|
||||
},
|
||||
LegacyAgent: config.LegacyAgent{Mode: "subprocess", Command: "/usr/local/bin/archie-agent", Env: []string{"HOME"}},
|
||||
NATS: config.NATSConfig{URL: "nats://127.0.0.1:4222", TokenEnv: "NATS_TOKEN"},
|
||||
NATS: config.NATSConfig{URL: "nats://127.0.0.1:4222", TokenEnv: "NATS_TOKEN"},
|
||||
Chat: config.ChatConfig{
|
||||
Telegram: config.TelegramConfig{TokenEnv: "TELEGRAM_TOKEN"},
|
||||
},
|
||||
|
||||
@@ -84,8 +84,8 @@ type ConfigSection struct {
|
||||
// writing:
|
||||
// - reloadableFields lists BotUser, BotEmail, Label, DiffCapLines, Budgets,
|
||||
// Models -- all reloadable.
|
||||
// - reloadableSubFields["Containers"] allows only LegacyEnabled and
|
||||
// VolumeTTL -- every other Containers field (Image, MaxConcurrency,
|
||||
// - reloadableSubFields["Containers"] allows only VolumeTTL --
|
||||
// every other Containers field (Image, MaxConcurrency,
|
||||
// MaxUptime, PullPolicy, Network) requires a restart.
|
||||
// - reloadableSubFields["Forge"] allows only Host -- Forge.Type requires a
|
||||
// restart even though the dashboard already renders it as editable.
|
||||
|
||||
Reference in new issue
Block a user