Skip to content

Commit 14769e5

Browse files
Codexclaude
andcommitted
refactor(backend): remove placeholders left by removed features
Follow-up to the two placeholder-context functions: the same Cindy, plugin-host and overdraft commits left more of the same kind. Billing (openai_gateway_usage.go) is back to upstream's shape: no unused account/tokens parameters, no error return that was nil on every path, no duplicated channel-pricing branch. Result structs lose fields that were only written or never assigned. Runtime-block code loses a condition that was always false and a fallback no caller could reach. Functions with no production caller go with their tests. Blank parameters whose reason is gone are dropped from their signatures; wire_gen.go is regenerated. Kept on purpose: blank parameters required by an interface, a callback or wire ordering, and signatures kept identical to upstream. No request changes what it sends, bills or fails on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 94b7784 commit 14769e5

81 files changed

Lines changed: 246 additions & 635 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎backend/cmd/server/wire_gen.go‎

Lines changed: 5 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎backend/internal/accounttools/policy/import_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestImportPolicyPlansEachItemByIdentityMatches(t *testing.T) {
3030
}
3131
request.Phase = "finalize"
3232
raw, _ := json.Marshal(request)
33-
if _, err := New().Invoke(context.Background(), extensionv1.Invocation{Capability: extensionv1.CapabilityAdmin, Operation: "import.plan", Payload: raw}); err == nil {
33+
if _, err := New().Invoke(context.Background(), extensionv1.Invocation{Operation: "import.plan", Payload: raw}); err == nil {
3434
t.Fatal("incomplete prepared phase was accepted")
3535
}
3636
}

‎backend/internal/accounttools/policy/module.go‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,6 @@ import (
1414
type Module struct{}
1515

1616
func New() *Module { return &Module{} }
17-
func (m *Module) ValidateConfig(_ context.Context, raw json.RawMessage) (json.RawMessage, error) {
18-
var fields map[string]json.RawMessage
19-
if json.Unmarshal(raw, &fields) != nil || fields == nil || len(fields) != 0 {
20-
return nil, errors.New("account tools has no additional configuration")
21-
}
22-
return json.RawMessage(`{}`), nil
23-
}
24-
func (m *Module) ApplyConfig(ctx context.Context, raw json.RawMessage) error {
25-
_, err := m.ValidateConfig(ctx, raw)
26-
return err
27-
}
28-
func (m *Module) Status(context.Context) (json.RawMessage, error) {
29-
return json.Marshal(map[string]any{"taxonomy": true, "reasoning_selection": true, "text_prompt": true})
30-
}
3117

3218
func failure(code, message string, status int) extensionv1.Result {
3319
return extensionv1.Result{Code: code, Message: message, HTTPStatus: status}
@@ -46,9 +32,6 @@ func (m *Module) Invoke(ctx context.Context, in extensionv1.Invocation) (extensi
4632
if err := ctx.Err(); err != nil {
4733
return extensionv1.Result{}, err
4834
}
49-
if in.Capability != extensionv1.CapabilityAdmin {
50-
return extensionv1.Result{}, errors.New("unsupported account tools capability")
51-
}
5235
var output any = map[string]bool{"valid": true}
5336
switch in.Operation {
5437
case "import.plan":
@@ -68,9 +51,6 @@ func (m *Module) Invoke(ctx context.Context, in extensionv1.Invocation) (extensi
6851
if !request.ValidUTF8 || request.Characters < 0 || request.Characters > 8192 {
6952
return failure("ACCOUNT_TEST_PROMPT_INVALID", "test prompt must be valid UTF-8 and at most 8192 characters", 400), nil
7053
}
71-
case "tools.describe":
72-
raw, err := m.Status(ctx)
73-
return extensionv1.Result{Payload: raw}, err
7454
case "taxonomy.name":
7555
var request extensionv1.TaxonomyName
7656
if json.Unmarshal(in.Payload, &request) != nil {

‎backend/internal/accounttools/policy/module_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestTaxonomyPoliciesRejectAmbiguityAndInvalidAssignments(t *testing.T) {
2121
{"taxonomy.assignment", `{"tag_ids":[-1]}`, "ACCOUNT_TAG_ID_INVALID"},
2222
{"taxonomy.assignment", `{"tag_ids":[1,1,2]}`, ""},
2323
} {
24-
out, err := New().Invoke(context.Background(), extensionv1.Invocation{Capability: extensionv1.CapabilityAdmin, Operation: tc.operation, Payload: json.RawMessage(tc.payload)})
24+
out, err := New().Invoke(context.Background(), extensionv1.Invocation{Operation: tc.operation, Payload: json.RawMessage(tc.payload)})
2525
if err != nil || out.Code != tc.code {
2626
t.Fatalf("%s: %v %+v", tc.operation, err, out)
2727
}
@@ -34,7 +34,7 @@ func TestReasoningSelectionValidatesTheSuppliedWireCapabilities(t *testing.T) {
3434
valid bool
3535
}{{"default", "ultra", true}, {"text", "ultra", true}, {"compact", "ultra", false}, {"default", " high ", false}, {"default", "high", false}, {"default", "", true}} {
3636
raw, _ := json.Marshal(extensionv1.ReasoningSelection{Mode: tc.mode, Effort: tc.effort, Levels: []string{"ultra"}})
37-
out, err := New().Invoke(context.Background(), extensionv1.Invocation{Capability: extensionv1.CapabilityAdmin, Operation: "test.reasoning", Payload: raw})
37+
out, err := New().Invoke(context.Background(), extensionv1.Invocation{Operation: "test.reasoning", Payload: raw})
3838
if err != nil || (out.Code == "") != tc.valid {
3939
t.Fatalf("%s/%s: %v %+v", tc.mode, tc.effort, err, out)
4040
}

‎backend/internal/handler/admin/account_handler_traffic_telemetry_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestAccountHandlerTrafficTelemetryFollowsTelemetrySwitch(t *testing.T) {
5353
stub.getAccountResult = &service.Account{ID: 18, Platform: service.PlatformOpenAI, Type: service.AccountTypeAPIKey, Concurrency: 3, Credentials: map[string]any{"api_key": "never-return-secret"}}
5454
cache := &stubAccountTrafficObserveCache{snapshot: map[service.AccountTrafficProtocol]service.AccountTrafficObserveState{service.AccountTrafficProtocolHTTP: {Started: 3, Completed2xx: 2}}}
5555
handler := NewAccountHandler(stub, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
56-
handler.SetAccountTrafficObserver(service.NewAccountTrafficObserver(cache, nil))
56+
handler.SetAccountTrafficObserver(service.NewAccountTrafficObserver(cache))
5757
router := gin.New()
5858
router.GET("/accounts/:id/traffic-telemetry", handler.GetTrafficTelemetry)
5959
recorder := httptest.NewRecorder()
@@ -91,7 +91,7 @@ func TestAccountHandlerGetTrafficTelemetryReturnsSnapshot(t *testing.T) {
9191
service.AccountTrafficProtocolHTTP: {Started: 3, Completed2xx: 2, Upstream429: 1, PeakInFlight: 2, RequestsLast60s: 1},
9292
service.AccountTrafficProtocolWS: {},
9393
},
94-
}, nil))
94+
}))
9595
router := gin.New()
9696
router.GET("/accounts/:id/traffic-telemetry", handler.GetTrafficTelemetry)
9797

‎backend/internal/handler/grok_media.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ func (h *OpenAIGatewayHandler) handleGrokMedia(c *gin.Context, endpoint service.
431431
if slotResult != openAISlotAcquireOK {
432432
if retryingSameAccount && lastFailoverErr != nil && h.failoverAfterSameAccountSlotFailure(
433433
c, account, grokMediaScheduleModel(account, routingModel, nil), lastFailoverErr, failedAccountIDs,
434-
&switchCount, maxAccountSwitches, &oauth429FailoverState, streamStarted,
434+
&switchCount, maxAccountSwitches, &oauth429FailoverState,
435435
"grok_media", reqLog, !endpoint.IsVideoLookupRequest(),
436436
func() { h.handleFailoverExhausted(c, lastFailoverErr, streamStarted) },
437437
) {

‎backend/internal/handler/openai_alpha_search.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (h *OpenAIGatewayHandler) AlphaSearch(c *gin.Context) {
201201
if slotResult != openAISlotAcquireOK {
202202
if retryingSameAccount && lastFailoverErr != nil && h.failoverAfterSameAccountSlotFailure(
203203
c, account, account.GetMappedModel(requestedModel), lastFailoverErr, failedAccountIDs,
204-
&switchCount, h.maxAccountSwitches, &oauth429FailoverState, streamStarted,
204+
&switchCount, h.maxAccountSwitches, &oauth429FailoverState,
205205
"alpha_search", reqLog, true,
206206
func() { h.handleFailoverExhausted(c, lastFailoverErr, streamStarted) },
207207
) {

‎backend/internal/handler/openai_chat_completions.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func (h *OpenAIGatewayHandler) ChatCompletions(c *gin.Context) {
269269
if slotResult != openAISlotAcquireOK {
270270
if retryingSameAccount && lastFailoverErr != nil && h.failoverAfterSameAccountSlotFailure(
271271
c, account, account.GetMappedModel(routingModel), lastFailoverErr, failedAccountIDs,
272-
&switchCount, maxAccountSwitches, &oauth429FailoverState, streamStarted,
272+
&switchCount, maxAccountSwitches, &oauth429FailoverState,
273273
"chat_completions", reqLog, true,
274274
func() { h.handleFailoverExhausted(c, lastFailoverErr, streamStarted) },
275275
) {

‎backend/internal/handler/openai_codex_models_handler.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (h *OpenAIGatewayHandler) CodexModels(c *gin.Context) {
160160
if slotResult != openAISlotAcquireOK {
161161
if retryingSameAccount && lastFailoverErr != nil && h.failoverAfterSameAccountSlotFailure(
162162
c, account, "", lastFailoverErr, failedAccountIDs,
163-
&switchCount, maxAccountSwitches, &oauth429FailoverState, false,
163+
&switchCount, maxAccountSwitches, &oauth429FailoverState,
164164
"codex_models", nil, true,
165165
func() {
166166
h.errorResponse(c, infraerrors.Code(lastUpstreamErr), "upstream_error", infraerrors.Message(lastUpstreamErr))

‎backend/internal/handler/openai_count_tokens_model_not_supported_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestWriteCountTokensFailoverErrorPreservesModelNotSupported(t *testing.T) {
1818
writeCountTokensFailoverError(ctx, &service.UpstreamFailoverError{
1919
StatusCode: http.StatusBadRequest,
2020
Reason: service.GatewayFailureReason("upstream_400_model_not_supported"),
21-
}, nil)
21+
})
2222

2323
var envelope map[string]any
2424
require.NoError(t, json.Unmarshal(recorder.Body.Bytes(), &envelope))

0 commit comments

Comments
 (0)