Skip to content

Commit 91695f6

Browse files
committed
refactor: adjust naming
1 parent 9a1ef9e commit 91695f6

23 files changed

Lines changed: 309 additions & 309 deletions

.env.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# Allow optional /p/{provider}/v1/... passthrough aliases while keeping /p/{provider}/... canonical (default: true)
1212
# ALLOW_PASSTHROUGH_V1_ALIAS=true
1313

14-
# Comma-separated allowlist of provider types for /p/{provider}/... passthrough (default: openai,anthropic)
15-
# ALLOWED_PASSTHROUGH_PROVIDERS=openai,anthropic
14+
# Comma-separated list of provider types enabled for /p/{provider}/... passthrough (default: openai,anthropic)
15+
# ENABLED_PASSTHROUGH_PROVIDERS=openai,anthropic
1616

1717
# HTTP Client Configuration (for upstream API requests)
1818
# Values in seconds (or Go duration format like "10m", "1h30m")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Key settings:
152152
| `GOMODEL_MASTER_KEY` | (none) | API key for authentication |
153153
| `ENABLE_PASSTHROUGH_ROUTES` | `true` | Enable provider-native passthrough routes under `/p/{provider}/...` |
154154
| `ALLOW_PASSTHROUGH_V1_ALIAS` | `true` | Allow `/p/{provider}/v1/...` aliases while keeping `/p/{provider}/...` canonical |
155-
| `ALLOWED_PASSTHROUGH_PROVIDERS` | `openai,anthropic` | Comma-separated allowlist for passthrough route providers |
155+
| `ENABLED_PASSTHROUGH_PROVIDERS` | `openai,anthropic` | Comma-separated list of enabled passthrough providers |
156156
| `CACHE_TYPE` | `local` | Cache backend (`local` or `redis`) |
157157
| `STORAGE_TYPE` | `sqlite` | Storage backend (`sqlite`, `postgresql`, `mongodb`) |
158158
| `METRICS_ENABLED` | `false` | Enable Prometheus metrics |

config/config.example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ server:
99
body_size_limit: "10M"
1010
enable_passthrough_routes: true # expose /p/{provider}/{endpoint} passthrough routes
1111
allow_passthrough_v1_alias: true # allow /p/{provider}/v1/... while keeping /p/{provider}/... canonical
12-
allowed_passthrough_providers: ["openai", "anthropic"] # providers allowed on /p/{provider}/...
12+
enabled_passthrough_providers: ["openai", "anthropic"] # providers enabled on /p/{provider}/...
1313

1414
cache:
1515
model:

config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ type ServerConfig struct {
341341
// AllowPassthroughV1Alias allows /p/{provider}/v1/... style passthrough routes
342342
// while keeping /p/{provider}/... as the canonical form. Default: true.
343343
AllowPassthroughV1Alias bool `yaml:"allow_passthrough_v1_alias" env:"ALLOW_PASSTHROUGH_V1_ALIAS"`
344-
// AllowedPassthroughProviders lists the provider types allowed on
344+
// EnabledPassthroughProviders lists the provider types enabled on
345345
// /p/{provider}/... passthrough routes. Default: ["openai", "anthropic"].
346-
AllowedPassthroughProviders []string `yaml:"allowed_passthrough_providers" env:"ALLOWED_PASSTHROUGH_PROVIDERS"`
346+
EnabledPassthroughProviders []string `yaml:"enabled_passthrough_providers" env:"ENABLED_PASSTHROUGH_PROVIDERS"`
347347
}
348348

349349
// MetricsConfig holds observability configuration for Prometheus metrics
@@ -409,7 +409,7 @@ func buildDefaultConfig() *Config {
409409
SwaggerEnabled: true,
410410
EnablePassthroughRoutes: true,
411411
AllowPassthroughV1Alias: true,
412-
AllowedPassthroughProviders: []string{
412+
EnabledPassthroughProviders: []string{
413413
"openai",
414414
"anthropic",
415415
},

config/config_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func clearProviderEnvVars(t *testing.T) {
2626
func clearAllConfigEnvVars(t *testing.T) {
2727
t.Helper()
2828
for _, key := range []string{
29-
"PORT", "GOMODEL_MASTER_KEY", "BODY_SIZE_LIMIT", "ENABLE_PASSTHROUGH_ROUTES", "ALLOW_PASSTHROUGH_V1_ALIAS", "ALLOWED_PASSTHROUGH_PROVIDERS",
29+
"PORT", "GOMODEL_MASTER_KEY", "BODY_SIZE_LIMIT", "ENABLE_PASSTHROUGH_ROUTES", "ALLOW_PASSTHROUGH_V1_ALIAS", "ENABLED_PASSTHROUGH_PROVIDERS",
3030
"GOMODEL_CACHE_DIR", "CACHE_REFRESH_INTERVAL",
3131
"REDIS_URL", "REDIS_KEY_MODELS", "REDIS_KEY_RESPONSES", "REDIS_TTL_MODELS", "REDIS_TTL_RESPONSES",
3232
"STORAGE_TYPE", "SQLITE_PATH", "POSTGRES_URL", "POSTGRES_MAX_CONNS",
@@ -73,8 +73,8 @@ func TestBuildDefaultConfig(t *testing.T) {
7373
if !cfg.Server.AllowPassthroughV1Alias {
7474
t.Error("expected Server.AllowPassthroughV1Alias=true")
7575
}
76-
if got, want := cfg.Server.AllowedPassthroughProviders, []string{"openai", "anthropic"}; len(got) != len(want) || got[0] != want[0] || got[1] != want[1] {
77-
t.Errorf("expected Server.AllowedPassthroughProviders=%v, got %v", want, got)
76+
if got, want := cfg.Server.EnabledPassthroughProviders, []string{"openai", "anthropic"}; len(got) != len(want) || got[0] != want[0] || got[1] != want[1] {
77+
t.Errorf("expected Server.EnabledPassthroughProviders=%v, got %v", want, got)
7878
}
7979
if cfg.Cache.Model.Local != nil {
8080
t.Error("expected Cache.Model.Local to be nil in raw defaults")
@@ -363,39 +363,39 @@ func TestLoad_ConfigExample_UsesNestedModelCacheSettings(t *testing.T) {
363363
if result.Config.Cache.Model.Redis != nil {
364364
t.Fatalf("expected Cache.Model.Redis to be nil in example config, got %+v", result.Config.Cache.Model.Redis)
365365
}
366-
gotProviders := result.Config.Server.AllowedPassthroughProviders
366+
gotProviders := result.Config.Server.EnabledPassthroughProviders
367367
wantProviders := []string{"openai", "anthropic"}
368368
if len(gotProviders) != len(wantProviders) || gotProviders[0] != wantProviders[0] || gotProviders[1] != wantProviders[1] {
369-
t.Fatalf("Server.AllowedPassthroughProviders = %v, want %v", gotProviders, wantProviders)
369+
t.Fatalf("Server.EnabledPassthroughProviders = %v, want %v", gotProviders, wantProviders)
370370
}
371371
})
372372
}
373373

374-
func TestLoad_AllowedPassthroughProviders_EnvOverridesYAML(t *testing.T) {
374+
func TestLoad_EnabledPassthroughProviders_EnvOverridesYAML(t *testing.T) {
375375
withTempDir(t, func(dir string) {
376376
clearAllConfigEnvVars(t)
377377

378378
yaml := `
379379
server:
380-
allowed_passthrough_providers:
380+
enabled_passthrough_providers:
381381
- openai
382382
- anthropic
383383
`
384384
if err := os.WriteFile(filepath.Join(dir, "config.yaml"), []byte(yaml), 0644); err != nil {
385385
t.Fatalf("Failed to write config.yaml: %v", err)
386386
}
387387

388-
t.Setenv("ALLOWED_PASSTHROUGH_PROVIDERS", " groq , gemini ")
388+
t.Setenv("ENABLED_PASSTHROUGH_PROVIDERS", " groq , gemini ")
389389

390390
result, err := Load()
391391
if err != nil {
392392
t.Fatalf("Load() failed: %v", err)
393393
}
394394

395-
got := result.Config.Server.AllowedPassthroughProviders
395+
got := result.Config.Server.EnabledPassthroughProviders
396396
want := []string{"groq", "gemini"}
397397
if len(got) != len(want) || got[0] != want[0] || got[1] != want[1] {
398-
t.Fatalf("AllowedPassthroughProviders = %v, want %v", got, want)
398+
t.Fatalf("EnabledPassthroughProviders = %v, want %v", got, want)
399399
}
400400
})
401401
}

docs/adr/0002-ingress-frame-and-semantic-envelope.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ GOModel needs a model that preserves the original request faithfully while still
2323

2424
## Flow Diagram
2525

26-
![RequestSnapshot and RequestSemantics request flow](assets/0002-ingress-frame-flow.svg)
26+
![RequestSnapshot and WhiteBoxPrompt request flow](assets/0002-ingress-frame-flow.svg)
2727

2828
## Decision
2929

30-
Use `RequestSnapshot` and `RequestSemantics` for transport-bearing model and provider request routes such as `/v1/chat/completions`, `/v1/responses`, `/v1/embeddings`, `/v1/batches*`, `/v1/files*`, and `/p/{provider}/{endpoint}`.
30+
Use `RequestSnapshot` and `WhiteBoxPrompt` for transport-bearing model and provider request routes such as `/v1/chat/completions`, `/v1/responses`, `/v1/embeddings`, `/v1/batches*`, `/v1/files*`, and `/p/{provider}/{endpoint}`.
3131

3232
Discovery routes such as `GET /v1/models` are out of scope.
3333

3434
`RequestSnapshot` is always present.
3535

36-
`RequestSemantics` is optional and best-effort. It may be rich, sparse, or absent, depending on how much the gateway understands about the route, content type, and request body.
36+
`WhiteBoxPrompt` is optional and best-effort. It may be rich, sparse, or absent, depending on how much the gateway understands about the route, content type, and request body.
3737

3838
This gives GOModel one consistent ingress model across both `/v1/*` and `/p/*`.
3939

@@ -62,9 +62,9 @@ Its job is to preserve what came over the wire so the gateway can:
6262

6363
`RequestSnapshot` must not be mutated.
6464

65-
## RequestSemantics
65+
## WhiteBoxPrompt
6666

67-
`RequestSemantics` is the gateway's best-effort semantic extraction from the ingress frame.
67+
`WhiteBoxPrompt` is the gateway's best-effort semantic extraction from the ingress frame.
6868

6969
It may contain:
7070

docs/adr/0003-policy-resolved-execution-plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Those concerns should not be scattered across handlers, provider adapters, and m
1616
ADR-0002 establishes the ingress boundary:
1717

1818
- immutable raw request capture via `RequestSnapshot`
19-
- optional best-effort semantic extraction via `RequestSemantics`
19+
- optional best-effort semantic extraction via `WhiteBoxPrompt`
2020

2121
GOModel still needs a single place where request processing policy is resolved into a concrete runtime decision.
2222

@@ -27,7 +27,7 @@ Introduce `ExecutionPlan` as the policy-resolved plan for handling a request.
2727
`ExecutionPlan` is derived after authentication and identity resolution, using:
2828

2929
- `RequestSnapshot`
30-
- `RequestSemantics`
30+
- `WhiteBoxPrompt`
3131
- route and endpoint metadata
3232
- resolved identity
3333
- API key, user, team, and organization context

docs/adr/assets/0002-ingress-frame-flow.svg

Lines changed: 3 additions & 3 deletions
Loading

internal/app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func New(ctx context.Context, cfg Config) (*App, error) {
169169
BatchStore: batchResult.Store,
170170
LogOnlyModelInteractions: appCfg.Logging.OnlyModelInteractions,
171171
DisablePassthroughRoutes: !appCfg.Server.EnablePassthroughRoutes,
172-
AllowedPassthroughProviders: appCfg.Server.AllowedPassthroughProviders,
172+
EnabledPassthroughProviders: appCfg.Server.EnabledPassthroughProviders,
173173
AllowPassthroughV1Alias: &allowPassthroughV1Alias,
174174
SwaggerEnabled: appCfg.Server.SwaggerEnabled,
175175
}

internal/core/context.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const (
1010
requestIDKey contextKey = "request-id"
1111
// requestSnapshotKey stores the immutable transport snapshot for the request.
1212
requestSnapshotKey contextKey = "request-snapshot"
13-
// requestSemanticsKey stores the best-effort semantic extraction for the request.
14-
requestSemanticsKey contextKey = "request-semantics"
13+
// whiteBoxPromptKey stores the best-effort semantic extraction for the request.
14+
whiteBoxPromptKey contextKey = "white-box-prompt"
1515
)
1616

1717
// WithRequestID returns a new context with the request ID attached.
@@ -45,16 +45,16 @@ func GetRequestSnapshot(ctx context.Context) *RequestSnapshot {
4545
return nil
4646
}
4747

48-
// WithRequestSemantics returns a new context with the request semantics attached.
49-
func WithRequestSemantics(ctx context.Context, semantics *RequestSemantics) context.Context {
50-
return context.WithValue(ctx, requestSemanticsKey, semantics)
48+
// WithWhiteBoxPrompt returns a new context with the white-box prompt attached.
49+
func WithWhiteBoxPrompt(ctx context.Context, prompt *WhiteBoxPrompt) context.Context {
50+
return context.WithValue(ctx, whiteBoxPromptKey, prompt)
5151
}
5252

53-
// GetRequestSemantics retrieves the request semantics from the context.
54-
func GetRequestSemantics(ctx context.Context) *RequestSemantics {
55-
if v := ctx.Value(requestSemanticsKey); v != nil {
56-
if semantics, ok := v.(*RequestSemantics); ok {
57-
return semantics
53+
// GetWhiteBoxPrompt retrieves the white-box prompt from the context.
54+
func GetWhiteBoxPrompt(ctx context.Context) *WhiteBoxPrompt {
55+
if v := ctx.Value(whiteBoxPromptKey); v != nil {
56+
if prompt, ok := v.(*WhiteBoxPrompt); ok {
57+
return prompt
5858
}
5959
}
6060
return nil

0 commit comments

Comments
 (0)