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.
This commit is contained in:
sam committed 2026-09-06 02:13:03 +10:00
1 parent bec9caa24e
commit bf482f9d56
11 files changed
+14 -51

No files matched your search

-1
View File
@@ -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]
-1
View File
@@ -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"
@@ -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"
-1
View File
@@ -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]
+1 -4
View File
@@ -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
+3 -6
View File
@@ -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)
}),
+1 -2
View File
@@ -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"`
}
@@ -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)
@@ -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)
}
})
}
@@ -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
@@ -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"},
},
}
}