From bf482f9d56cd11122b4e2fa6a2a6e3af622e44a8 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 6 Sep 2026 02:13:03 +1000 Subject: [PATCH] fix(gateway): drop services.gateway.mode, remote is the only transport Mode had exactly one legal value after the previous commit deleted the in-process path, which made it dead config surface that could only confuse an operator into thinking there was still a real choice. ServiceConnection is now just a target address; composeChatContract only checks it's non-blank, defaulting to 127.0.0.1:8585. --- deployments/docker-nats-stack.toml | 1 - deployments/local-ollama-standalone.toml | 1 - deployments/multi-forge-github-gitea.toml | 1 - deployments/single-forge-github.toml | 1 - internal/app/archied/chat_service.go | 5 +--- internal/app/archied/chat_service_test.go | 9 +++---- internal/config/services.go | 3 +-- .../infrastructure/configuration/defaults.go | 3 +-- .../configuration/services_test.go | 24 ++++++------------- .../infrastructure/configuration/validate.go | 15 ------------ .../configuration/validate_test.go | 2 +- 11 files changed, 14 insertions(+), 51 deletions(-) diff --git a/deployments/docker-nats-stack.toml b/deployments/docker-nats-stack.toml index 3da07a826..fd8f39432 100644 --- a/deployments/docker-nats-stack.toml +++ b/deployments/docker-nats-stack.toml @@ -18,7 +18,6 @@ work_dir = "~/.local/share/archie/work" db_path = "~/.local/share/archie/archie.db" [services.gateway] -mode = "remote" target = "127.0.0.1:8585" [forge] diff --git a/deployments/local-ollama-standalone.toml b/deployments/local-ollama-standalone.toml index bbb4e7e6b..185fcf878 100644 --- a/deployments/local-ollama-standalone.toml +++ b/deployments/local-ollama-standalone.toml @@ -9,7 +9,6 @@ work_dir = "~/.local/share/archie/work" db_path = "~/.local/share/archie/archie.db" [services.gateway] -mode = "remote" target = "127.0.0.1:8585" poll_interval = "60s" diff --git a/deployments/multi-forge-github-gitea.toml b/deployments/multi-forge-github-gitea.toml index 06fedf91f..a2ab04335 100644 --- a/deployments/multi-forge-github-gitea.toml +++ b/deployments/multi-forge-github-gitea.toml @@ -10,7 +10,6 @@ work_dir = "~/.local/share/archie/work" db_path = "~/.local/share/archie/archie.db" [services.gateway] -mode = "remote" target = "127.0.0.1:8585" poll_interval = "60s" diff --git a/deployments/single-forge-github.toml b/deployments/single-forge-github.toml index 4ddec6ca6..19337dc83 100644 --- a/deployments/single-forge-github.toml +++ b/deployments/single-forge-github.toml @@ -16,7 +16,6 @@ diff_cap_lines = 400 # The Gateway Service owns conversational state and serves ChatContract over # gRPC. Run archie-gateway alongside archied with this address. [services.gateway] -mode = "remote" target = "127.0.0.1:8585" [forge] diff --git a/internal/app/archied/chat_service.go b/internal/app/archied/chat_service.go index 86231ecae..20ca3af5a 100644 --- a/internal/app/archied/chat_service.go +++ b/internal/app/archied/chat_service.go @@ -15,11 +15,8 @@ import ( // composeChatContract dials the standalone archie-gateway, the sole owner of // ChatContract. func composeChatContract(settings config.ServiceConnection, options ...grpc.DialOption) (gateway.ChatContract, func(), error) { - if settings.Mode != "remote" { - return nil, nil, fmt.Errorf("unsupported gateway service mode %q; archie-gateway is required, see deployments/README.md", settings.Mode) - } if strings.TrimSpace(settings.Target) == "" { - return nil, nil, fmt.Errorf("remote gateway requires a target") + return nil, nil, fmt.Errorf("services.gateway.target is required") } // Deployments that put the Gateway on a separate trust boundary supply // their own transport credentials through options; the default must be diff --git a/internal/app/archied/chat_service_test.go b/internal/app/archied/chat_service_test.go index 6a25b46b6..8d52dbaa1 100644 --- a/internal/app/archied/chat_service_test.go +++ b/internal/app/archied/chat_service_test.go @@ -22,11 +22,8 @@ func TestComposeChatContractRejectsInvalidSettings(t *testing.T) { name string settings config.ServiceConnection }{ - {name: "unknown mode", settings: config.ServiceConnection{Mode: "automatic"}}, - {name: "default mode", settings: config.ServiceConnection{Target: "localhost:1234"}}, - {name: "inproc removed", settings: config.ServiceConnection{Mode: "inproc", Target: "localhost:1234"}}, - {name: "remote missing target", settings: config.ServiceConnection{Mode: "remote"}}, - {name: "remote blank target", settings: config.ServiceConnection{Mode: "remote", Target: " \t\n"}}, + {name: "missing target", settings: config.ServiceConnection{}}, + {name: "blank target", settings: config.ServiceConnection{Target: " \t\n"}}, } { t.Run(tt.name, func(t *testing.T) { chat, cleanup, err := composeChatContract(tt.settings) @@ -58,7 +55,7 @@ func TestComposeChatContractRemoteAndCleanup(t *testing.T) { }) chat, cleanup, err := composeChatContract( - config.ServiceConnection{Mode: "remote", Target: "passthrough:///chat"}, + config.ServiceConnection{Target: "passthrough:///chat"}, grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) { return listener.DialContext(ctx) }), diff --git a/internal/config/services.go b/internal/config/services.go index 3fda055ee..b8334323b 100644 --- a/internal/config/services.go +++ b/internal/config/services.go @@ -5,9 +5,8 @@ type Services struct { Gateway ServiceConnection `toml:"gateway" yaml:"gateway"` } -// ServiceConnection selects local calls or a TLS gRPC target. It does not +// ServiceConnection is the archie-gateway process's gRPC address. It does not // register services or start listeners. Changes require a daemon restart. type ServiceConnection struct { - Mode string `toml:"mode" yaml:"mode"` Target string `toml:"target" yaml:"target"` } diff --git a/internal/infrastructure/configuration/defaults.go b/internal/infrastructure/configuration/defaults.go index 6d6fa9e5f..a9eb507a5 100644 --- a/internal/infrastructure/configuration/defaults.go +++ b/internal/infrastructure/configuration/defaults.go @@ -59,8 +59,7 @@ const ( // input was to not call them. Splitting them means defaults can be applied, // inspected, and reasoned about independently of whether the result is valid. func (l *Loader) applyDefaults(cfg *config.Config) { - if cfg.Services.Gateway.Mode == "" { - cfg.Services.Gateway.Mode = "remote" + if cfg.Services.Gateway.Target == "" { cfg.Services.Gateway.Target = "127.0.0.1:8585" } l.applyGeneralDefaults(cfg) diff --git a/internal/infrastructure/configuration/services_test.go b/internal/infrastructure/configuration/services_test.go index 58af72c9a..faa2c161b 100644 --- a/internal/infrastructure/configuration/services_test.go +++ b/internal/infrastructure/configuration/services_test.go @@ -6,17 +6,12 @@ import ( "testing" ) -func TestLoadGatewayServiceMode(t *testing.T) { +func TestLoadGatewayServiceTarget(t *testing.T) { for _, tt := range []struct { - name, section string - wantError bool - wantTarget string + name, section, wantTarget string }{ {name: "default", wantTarget: "127.0.0.1:8585"}, - {name: "remote", section: "[services.gateway]\nmode = 'remote'\ntarget = 'dns:///gateway:8443'", wantTarget: "dns:///gateway:8443"}, - {name: "invalid mode", section: "[services.gateway]\nmode = 'typo'", wantError: true}, - {name: "inproc removed", section: "[services.gateway]\nmode = 'inproc'", wantError: true}, - {name: "remote without target", section: "[services.gateway]\nmode = 'remote'", wantError: true}, + {name: "explicit target", section: "[services.gateway]\ntarget = 'dns:///gateway:8443'", wantTarget: "dns:///gateway:8443"}, } { t.Run(tt.name, func(t *testing.T) { path := filepath.Join(t.TempDir(), "config.toml") @@ -24,16 +19,11 @@ func TestLoadGatewayServiceMode(t *testing.T) { t.Fatal(err) } cfg, err := loadFile(path) - if (err != nil) != tt.wantError { - t.Fatalf("load error = %v, want error %v", err, tt.wantError) + if err != nil { + t.Fatal(err) } - if err == nil { - if cfg.Services.Gateway.Mode != "remote" { - t.Fatalf("mode = %q, want %q", cfg.Services.Gateway.Mode, "remote") - } - if cfg.Services.Gateway.Target != tt.wantTarget { - t.Fatalf("target = %q, want %q", cfg.Services.Gateway.Target, tt.wantTarget) - } + if cfg.Services.Gateway.Target != tt.wantTarget { + t.Fatalf("target = %q, want %q", cfg.Services.Gateway.Target, tt.wantTarget) } }) } diff --git a/internal/infrastructure/configuration/validate.go b/internal/infrastructure/configuration/validate.go index 574b92cec..e47e8cf15 100644 --- a/internal/infrastructure/configuration/validate.go +++ b/internal/infrastructure/configuration/validate.go @@ -59,9 +59,6 @@ func Validate(cfg *config.Config) error { // validate reports the first problem that would stop the daemon running. // It does not modify cfg -- run applyDefaults first. func validate(cfg *config.Config) error { - if err := validateGatewayService(cfg.Services.Gateway); err != nil { - return err - } if err := validateDispatch(cfg); err != nil { return err } @@ -96,18 +93,6 @@ func validate(cfg *config.Config) error { return validateCapture(cfg) } -func validateGatewayService(service config.ServiceConnection) error { - switch service.Mode { - case "remote": - if strings.TrimSpace(service.Target) == "" { - return fmt.Errorf("%w: services.gateway.target is required in remote mode", ErrInvalidInput) - } - default: - return fmt.Errorf("%w: services.gateway.mode must be remote", ErrInvalidInput) - } - return nil -} - // 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 diff --git a/internal/infrastructure/configuration/validate_test.go b/internal/infrastructure/configuration/validate_test.go index 8db946071..993e71dd9 100644 --- a/internal/infrastructure/configuration/validate_test.go +++ b/internal/infrastructure/configuration/validate_test.go @@ -27,7 +27,7 @@ func minimalValidConfig() config.Config { Image: "ghcr.io/samcharles93/archie-agent:latest", }, Services: config.Services{ - Gateway: config.ServiceConnection{Mode: "remote", Target: "127.0.0.1:8585"}, + Gateway: config.ServiceConnection{Target: "127.0.0.1:8585"}, }, } }